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
5161a9e7
Commit
5161a9e7
authored
Aug 01, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
allow scope traversals to rename tasks and functions
parent
3834b9f1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
16 deletions
+21
-16
src/Convert/Scoper.hs
+17
-12
src/Convert/SizeCast.hs
+4
-4
No files found.
src/Convert/Scoper.hs
View file @
5161a9e7
...
...
@@ -291,6 +291,14 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items =
argIdxDecl
ParamType
{}
=
Nothing
argIdxDecl
CommentDecl
{}
=
Nothing
redirectTFDecl
::
Type
->
Identifier
->
ScoperT
a
m
(
Type
,
Identifier
)
redirectTFDecl
typ
ident
=
do
res
<-
declMapper
$
Variable
Local
typ
ident
[]
Nil
case
res
of
Variable
Local
newType
newName
[]
Nil
->
return
(
newType
,
newName
)
_
->
error
$
"redirected func ret traverse failed: "
++
show
res
wrappedModuleItemMapper
::
ModuleItem
->
ScoperT
a
m
ModuleItem
wrappedModuleItemMapper
item
=
do
item'
<-
fullModuleItemMapper
item
...
...
@@ -303,26 +311,23 @@ evalScoperT declMapper moduleItemMapper genItemMapper stmtMapper topName items =
return
$
Generate
$
map
GenModuleItem
$
injected'
++
[
item'
]
fullModuleItemMapper
::
ModuleItem
->
ScoperT
a
m
ModuleItem
fullModuleItemMapper
(
MIPackageItem
(
Function
ml
t
x
decls
stmts
))
=
do
(
t'
,
x'
)
<-
redirectTFDecl
t
x
enterProcedure
t'
<-
do
res
<-
declMapper
$
Variable
Local
t
x
[]
Nil
case
res
of
Variable
Local
newType
_
[]
Nil
->
return
newType
_
->
error
$
"redirected func ret traverse failed: "
++
show
res
enterScope
x
""
enterScope
x'
""
decls'
<-
mapTFDecls
decls
stmts'
<-
mapM
fullStmtMapper
stmts
exitScope
x
""
exitScope
x
'
""
exitProcedure
return
$
MIPackageItem
$
Function
ml
t'
x
decls'
stmts'
fullModuleItemMapper
(
MIPackageItem
(
Task
ml
x
decls
stmts
))
=
do
return
$
MIPackageItem
$
Function
ml
t'
x'
decls'
stmts'
fullModuleItemMapper
(
MIPackageItem
(
Task
ml
x
decls
stmts
))
=
do
(
_
,
x'
)
<-
redirectTFDecl
(
Implicit
Unspecified
[]
)
x
enterProcedure
enterScope
x
""
enterScope
x
'
""
decls'
<-
mapTFDecls
decls
stmts'
<-
mapM
fullStmtMapper
stmts
exitScope
x
""
exitScope
x
'
""
exitProcedure
return
$
MIPackageItem
$
Task
ml
x
decls'
stmts'
return
$
MIPackageItem
$
Task
ml
x'
decls'
stmts'
fullModuleItemMapper
(
MIPackageItem
(
Decl
decl
))
=
declMapper
decl
>>=
return
.
MIPackageItem
.
Decl
fullModuleItemMapper
(
AlwaysC
kw
stmt
)
=
do
...
...
src/Convert/SizeCast.hs
View file @
5161a9e7
...
...
@@ -29,7 +29,7 @@ traverseDeclM decl = do
Variable
_
t
x
_
_
->
do
details
<-
lookupElemM
x
if
isPrefixOf
"sv2v_cast_"
x
&&
details
/=
Nothing
then
return
$
Variable
Local
DuplicateTag
x
[]
Nil
then
return
$
Variable
Local
t
DuplicateTag
[]
Nil
else
insertElem
x
t
>>
return
decl
Param
_
t
x
_
->
do
inProcedure
<-
withinProcedureM
...
...
@@ -39,11 +39,11 @@ traverseDeclM decl = do
CommentDecl
_
->
return
decl
traverseDeclExprsM
traverseExprM
decl'
pattern
DuplicateTag
::
Type
pattern
DuplicateTag
=
Alias
":duplicate_cast_to_be_removed:"
[]
pattern
DuplicateTag
::
Identifier
pattern
DuplicateTag
=
":duplicate_cast_to_be_removed:"
dropDuplicateCaster
::
ModuleItem
->
ModuleItem
dropDuplicateCaster
(
MIPackageItem
(
Function
_
DuplicateTag
_
_
_
))
=
dropDuplicateCaster
(
MIPackageItem
(
Function
_
_
DuplicateTag
_
_
))
=
Generate
[]
dropDuplicateCaster
other
=
other
...
...
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