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
55aebec3
Commit
55aebec3
authored
Apr 11, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
flatten generate blocks into their parent description where trivially possible
parent
231b7f99
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
4 deletions
+19
-4
src/Convert/Traverse.hs
+19
-4
No files found.
src/Convert/Traverse.hs
View file @
55aebec3
...
...
@@ -103,8 +103,10 @@ maybeDo _ Nothing = return Nothing
maybeDo
fun
(
Just
val
)
=
fun
val
>>=
return
.
Just
traverseModuleItemsM
::
Monad
m
=>
MapperM
m
ModuleItem
->
MapperM
m
Description
traverseModuleItemsM
mapper
(
Part
extern
kw
lifetime
name
ports
items
)
=
mapM
fullMapper
items
>>=
return
.
Part
extern
kw
lifetime
name
ports
traverseModuleItemsM
mapper
(
Part
extern
kw
lifetime
name
ports
items
)
=
do
items'
<-
mapM
fullMapper
items
let
items''
=
concatMap
breakGenerate
items'
return
$
Part
extern
kw
lifetime
name
ports
items''
where
fullMapper
(
Generate
[
GenBlock
Nothing
genItems
])
=
mapM
fullGenItemMapper
genItems
>>=
mapper
.
Generate
...
...
@@ -118,6 +120,17 @@ traverseModuleItemsM mapper (Part extern kw lifetime name ports items) =
Generate
subItems
->
GenBlock
Nothing
subItems
_
->
GenModuleItem
moduleItem'
genItemMapper
other
=
return
other
breakGenerate
::
ModuleItem
->
[
ModuleItem
]
breakGenerate
(
Generate
genItems
)
=
if
all
isGenModuleItem
genItems
then
map
(
\
(
GenModuleItem
item
)
->
item
)
genItems
else
[
Generate
genItems
]
where
isGenModuleItem
::
GenItem
->
Bool
isGenModuleItem
(
GenModuleItem
_
)
=
True
isGenModuleItem
_
=
False
breakGenerate
other
=
[
other
]
traverseModuleItemsM
mapper
(
PackageItem
packageItem
)
=
do
let
item
=
MIPackageItem
packageItem
Part
False
Module
Nothing
"DNE"
[]
[
item'
]
<-
...
...
@@ -782,9 +795,11 @@ collectAsgnsM = collectAsgnsM' IncludeTFs
traverseNestedModuleItemsM
::
Monad
m
=>
MapperM
m
ModuleItem
->
MapperM
m
ModuleItem
traverseNestedModuleItemsM
mapper
item
=
do
Part
False
Module
Nothing
"DNE"
[]
[
item'
]
<-
Part
False
Module
Nothing
"DNE"
[]
items'
<-
traverseModuleItemsM
mapper
(
Part
False
Module
Nothing
"DNE"
[]
[
item
])
return
item'
return
$
case
items'
of
[
item'
]
->
item'
_
->
Generate
$
map
GenModuleItem
items'
traverseNestedModuleItems
::
Mapper
ModuleItem
->
Mapper
ModuleItem
traverseNestedModuleItems
=
unmonad
traverseNestedModuleItemsM
...
...
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