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
5ea2ec9d
Commit
5ea2ec9d
authored
Apr 01, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added conversion for name task and function arguments
parent
f1ac4fc0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
0 deletions
+55
-0
src/Convert.hs
+2
-0
src/Convert/KWArgs.hs
+52
-0
sv2v.cabal
+1
-0
No files found.
src/Convert.hs
View file @
5ea2ec9d
...
...
@@ -14,6 +14,7 @@ import qualified Convert.AsgnOp
import
qualified
Convert.Enum
import
qualified
Convert.FuncRet
import
qualified
Convert.Interface
import
qualified
Convert.KWArgs
import
qualified
Convert.Logic
import
qualified
Convert.PackedArray
import
qualified
Convert.Return
...
...
@@ -32,6 +33,7 @@ phases excludes =
,
selectExclude
(
Job
.
Logic
,
Convert
.
Logic
.
convert
)
,
Convert
.
FuncRet
.
convert
,
Convert
.
Enum
.
convert
,
Convert
.
KWArgs
.
convert
,
Convert
.
PackedArray
.
convert
,
Convert
.
StarPort
.
convert
,
Convert
.
StmtBlock
.
convert
...
...
src/Convert/KWArgs.hs
0 → 100644
View file @
5ea2ec9d
{- sv2v
- Author: Zachary Snow <zach@zachjs.com>
-
- Conversion for named function and task arguments
-}
module
Convert.KWArgs
(
convert
)
where
import
Data.List
(
elemIndex
,
sortOn
)
import
Data.Maybe
(
mapMaybe
)
import
Control.Monad.Writer
import
qualified
Data.Map.Strict
as
Map
import
Convert.Traverse
import
Language.SystemVerilog.AST
type
TFs
=
Map
.
Map
Identifier
[
Identifier
]
convert
::
AST
->
AST
convert
=
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
description
=
traverseModuleItems
(
traverseExprs
$
traverseNestedExprs
$
convertExpr
tfs
)
description
where
tfs
=
execWriter
$
collectModuleItemsM
collectTF
description
collectTF
::
ModuleItem
->
Writer
TFs
()
collectTF
(
MIPackageItem
(
Function
_
_
f
decls
_
))
=
collectTFDecls
f
decls
collectTF
(
MIPackageItem
(
Task
_
f
decls
_
))
=
collectTFDecls
f
decls
collectTF
_
=
return
()
collectTFDecls
::
Identifier
->
[
Decl
]
->
Writer
TFs
()
collectTFDecls
name
decls
=
tell
$
Map
.
singleton
name
$
mapMaybe
getInput
decls
where
getInput
::
Decl
->
Maybe
Identifier
getInput
(
Variable
Input
_
ident
_
_
)
=
Just
ident
getInput
_
=
Nothing
convertExpr
::
TFs
->
Expr
->
Expr
convertExpr
_
(
orig
@
(
Call
_
(
Args
_
[]
)))
=
orig
convertExpr
tfs
(
Call
func
(
Args
pnArgs
kwArgs
))
=
case
tfs
Map
.!?
func
of
Nothing
->
Call
func
(
Args
pnArgs
kwArgs
)
Just
ordered
->
Call
func
(
Args
args
[]
)
where
args
=
pnArgs
++
(
map
snd
$
sortOn
position
kwArgs
)
position
(
x
,
_
)
=
elemIndex
x
ordered
convertExpr
_
other
=
other
sv2v.cabal
View file @
5ea2ec9d
...
...
@@ -54,6 +54,7 @@ executable sv2v
Convert.Enum
Convert.FuncRet
Convert.Interface
Convert.KWArgs
Convert.Logic
Convert.PackedArray
Convert.Return
...
...
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