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
82228f67
Commit
82228f67
authored
Feb 19, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
typedef conversion avoids excess traversals
parent
2b9fff78
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
20 deletions
+28
-20
src/Convert/Typedef.hs
+28
-20
No files found.
src/Convert/Typedef.hs
View file @
82228f67
...
...
@@ -35,14 +35,19 @@ traverseTypeOrExprM other = return other
traverseExprM
::
Expr
->
Scoper
Type
Expr
traverseExprM
(
Cast
v
e
)
=
do
v'
<-
traverseTypeOrExprM
v
return
$
Cast
v'
e
traverseExprM'
$
Cast
v'
e
traverseExprM
(
DimsFn
f
v
)
=
do
v'
<-
traverseTypeOrExprM
v
return
$
DimsFn
f
v'
traverseExprM'
$
DimsFn
f
v'
traverseExprM
(
DimFn
f
v
e
)
=
do
v'
<-
traverseTypeOrExprM
v
return
$
DimFn
f
v'
e
traverseExprM
other
=
return
other
traverseExprM'
$
DimFn
f
v'
e
traverseExprM
other
=
traverseExprM'
other
traverseExprM'
::
Expr
->
Scoper
Type
Expr
traverseExprM'
=
traverseSinglyNestedExprsM
traverseExprM
>=>
traverseExprTypesM
traverseTypeM
traverseModuleItemM
::
ModuleItem
->
Scoper
Type
ModuleItem
traverseModuleItemM
(
Instance
m
params
x
rs
p
)
=
do
...
...
@@ -53,39 +58,42 @@ traverseModuleItemM item = traverseModuleItemM' item
traverseModuleItemM'
::
ModuleItem
->
Scoper
Type
ModuleItem
traverseModuleItemM'
=
traverse
TypesM
(
traverseNestedTypesM
traverseTypeM
)
>=>
traverseExprsM
(
traverseNestedExprsM
traverseExprM
)
traverse
NodesM
traverseExprM
return
traverseTypeM
traverseLHSM
return
where
traverseLHSM
=
traverseLHSExprsM
traverseExprM
traverseGenItemM
::
GenItem
->
Scoper
Type
GenItem
traverseGenItemM
=
traverseGenItemExprsM
(
traverseNestedExprsM
traverseExprM
)
traverseGenItemM
=
traverseGenItemExprsM
traverseExprM
traverseDeclM
::
Decl
->
Scoper
Type
Decl
traverseDeclM
decl
=
do
item
<-
traverseModuleItemM
(
MIPackageItem
$
Decl
decl
)
let
MIPackageItem
(
Decl
decl'
)
=
item
decl'
<-
traverseDeclExprsM
traverseExprM
decl
>>=
traverseDeclTypesM
traverseTypeM
case
decl'
of
Variable
{}
->
return
decl'
Param
{}
->
return
decl'
ParamType
Localparam
x
t
->
do
t'
<-
traverseNestedTypesM
traverseTypeM
t
insertElem
x
t'
traverseTypeM
t
>>=
insertElem
x
return
$
CommentDecl
$
"removed localparam type "
++
x
ParamType
{}
->
return
decl'
CommentDecl
{}
->
return
decl'
traverseStmtM
::
Stmt
->
Scoper
Type
Stmt
traverseStmtM
=
traverseStmtExprsM
$
traverseNestedExprsM
traverseStmtExprM
where
traverseStmtExprM
::
Expr
->
Scoper
Type
Expr
traverseStmtExprM
=
traverseExprTypesM
(
traverseNestedTypesM
traverseTypeM
)
>=>
traverseExprM
traverseStmtM
=
traverseStmtExprsM
traverseExprM
traverseTypeM
::
Type
->
Scoper
Type
Type
traverseTypeM
(
Alias
st
rs1
)
=
do
details
<-
lookupElemM
st
rs1'
<-
mapM
traverseRangeM
rs1
return
$
case
details
of
Nothing
->
Alias
st
rs1
Just
(
_
,
_
,
typ
)
->
tf
$
rs1
++
rs2
Nothing
->
Alias
st
rs1
'
Just
(
_
,
_
,
typ
)
->
tf
$
rs1
'
++
rs2
where
(
tf
,
rs2
)
=
typeRanges
typ
traverseTypeM
other
=
return
other
traverseTypeM
other
=
traverseSinglyNestedTypesM
traverseTypeM
other
>>=
traverseTypeExprsM
traverseExprM
traverseRangeM
::
Range
->
Scoper
Type
Range
traverseRangeM
(
a
,
b
)
=
do
a'
<-
traverseExprM
a
b'
<-
traverseExprM
b
return
(
a'
,
b'
)
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