Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sv2v
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
sv2v
Commits
2a51d20f
Commit
2a51d20f
authored
Sep 14, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
package item nesting resolves across and throughout files
parent
c5f7f2cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
22 deletions
+27
-22
src/Convert/NestPI.hs
+27
-22
No files found.
src/Convert/NestPI.hs
View file @
2a51d20f
...
...
@@ -6,9 +6,9 @@
module
Convert.NestPI
(
convert
)
where
import
Control.Monad.State
import
Control.Monad.Writer
import
Data.List
(
isPrefixOf
)
import
Data.List.Unique
(
complex
)
import
qualified
Data.Set
as
Set
import
Convert.Traverse
...
...
@@ -18,37 +18,35 @@ type PIs = [(Identifier, PackageItem)]
type
Idents
=
Set
.
Set
Identifier
convert
::
[
AST
]
->
[
AST
]
convert
asts
=
map
(
filter
(
not
.
isPI
)
.
nest
)
asts
convert
=
map
(
filter
(
not
.
isPI
)
)
.
nest
where
nest
::
AST
->
AST
nest
::
[
AST
]
->
[
AST
]
nest
curr
=
if
next
==
curr
then
curr
else
nest
next
where
next
=
evalState
(
traverseM
curr
)
[]
traverseM
=
traverseDescriptionsM
traverseDescriptionM
next
=
traverseFiles
(
collectDescriptionsM
collectDescriptionM
)
(
traverseDescriptions
.
convertDescription
)
curr
isPI
::
Description
->
Bool
isPI
(
PackageItem
item
)
=
piName
item
/=
Nothing
isPI
_
=
False
-- collects
and nests in tasks and functions missing from modules
traverseDescriptionM
::
Description
->
State
PIs
Description
traverse
DescriptionM
(
PackageItem
item
)
=
do
()
<-
case
piName
item
of
-- collects
packages items missing
collectDescriptionM
::
Description
->
Writer
PIs
()
collect
DescriptionM
(
PackageItem
item
)
=
do
case
piName
item
of
Nothing
->
return
()
Just
ident
->
modify
$
flip
(
++
)
[(
ident
,
item
)]
return
$
PackageItem
item
traverseDescriptionM
(
orig
@
(
Part
extern
kw
lifetime
name
ports
items
))
=
do
tfs
<-
get
let
neededPIs
=
Set
.
difference
(
Set
.
union
usedPIs
$
Set
.
filter
(
isPrefixOf
"import "
)
$
Set
.
fromList
$
map
fst
tfs
)
existingPIs
let
newItems
=
map
MIPackageItem
$
map
snd
$
filter
(
\
(
x
,
_
)
->
Set
.
member
x
neededPIs
)
tfs
return
$
Part
extern
kw
lifetime
name
ports
(
newItems
++
items
)
Just
ident
->
tell
[(
ident
,
item
)]
collectDescriptionM
_
=
return
()
-- nests packages items missing from modules
convertDescription
::
PIs
->
Description
->
Description
convertDescription
pis
(
orig
@
(
Part
extern
kw
lifetime
name
ports
items
))
=
Part
extern
kw
lifetime
name
ports
(
newItems
++
items
)
where
existingPIs
=
execWriter
$
collectModuleItemsM
collectPIsM
orig
runner
f
=
execWriter
$
collectModuleItemsM
f
orig
...
...
@@ -57,7 +55,14 @@ traverseDescriptionM (orig @ (Part extern kw lifetime name ports items)) = do
,
collectTypesM
$
collectNestedTypesM
collectTypenamesM
,
collectExprsM
$
collectNestedExprsM
collectIdentsM
]
traverseDescriptionM
other
=
return
other
neededPIs
=
Set
.
difference
(
Set
.
union
usedPIs
$
Set
.
filter
(
isPrefixOf
"import "
)
$
Set
.
fromList
$
map
fst
pis
)
existingPIs
uniq
l
=
l'
where
(
l'
,
_
,
_
)
=
complex
l
newItems
=
uniq
$
map
MIPackageItem
$
map
snd
$
filter
(
\
(
x
,
_
)
->
Set
.
member
x
neededPIs
)
pis
convertDescription
_
other
=
other
-- writes down the names of package items
collectPIsM
::
ModuleItem
->
Writer
Idents
()
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment