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
d7b36a03
Commit
d7b36a03
authored
Mar 07, 2019
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed enum complex type cast hack
parent
710da1a6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
src/Convert/Enum.hs
+9
-2
src/Convert/Traverse.hs
+2
-8
No files found.
src/Convert/Enum.hs
View file @
d7b36a03
...
@@ -33,8 +33,10 @@ convertDescription (description @ (Part _ _ _ _)) =
...
@@ -33,8 +33,10 @@ convertDescription (description @ (Part _ _ _ _)) =
where
where
enumPairs
=
concat
$
map
(
uncurry
enumVals
)
$
Set
.
toList
enums
enumPairs
=
concat
$
map
(
uncurry
enumVals
)
$
Set
.
toList
enums
enumItems
=
map
(
\
(
x
,
v
)
->
MIDecl
$
Localparam
(
Implicit
[]
)
x
v
)
enumPairs
enumItems
=
map
(
\
(
x
,
v
)
->
MIDecl
$
Localparam
(
Implicit
[]
)
x
v
)
enumPairs
(
Part
kw
name
ports
items
,
enums
)
=
runWriter
$
(
Part
kw
name
ports
items
,
enums
)
=
traverseModuleItemsM
(
traverseTypesM
traverseType
)
description
runWriter
$
traverseModuleItemsM
(
traverseTypesM
traverseType
)
$
traverseModuleItems
(
traverseExprs
traverseExpr
)
$
description
traverseType
::
Type
->
Writer
Enums
Type
traverseType
::
Type
->
Writer
Enums
Type
traverseType
(
Enum
t
v
r
)
=
do
traverseType
(
Enum
t
v
r
)
=
do
()
<-
tell
$
Set
.
singleton
(
t
,
v
)
()
<-
tell
$
Set
.
singleton
(
t
,
v
)
...
@@ -42,6 +44,11 @@ convertDescription (description @ (Part _ _ _ _)) =
...
@@ -42,6 +44,11 @@ convertDescription (description @ (Part _ _ _ _)) =
let
(
tf
,
rs
)
=
typeRanges
baseType
let
(
tf
,
rs
)
=
typeRanges
baseType
return
$
tf
(
rs
++
r
)
return
$
tf
(
rs
++
r
)
traverseType
other
=
return
other
traverseType
other
=
return
other
-- drop any enum type casts in favor of implicit conversion from the
-- converted type
traverseExpr
::
Expr
->
Expr
traverseExpr
(
Cast
(
Enum
_
_
_
)
e
)
=
e
traverseExpr
other
=
other
convertDescription
other
=
other
convertDescription
other
=
other
enumVals
::
Maybe
Type
->
[(
Identifier
,
Maybe
Expr
)]
->
[(
Identifier
,
Expr
)]
enumVals
::
Maybe
Type
->
[(
Identifier
,
Maybe
Expr
)]
->
[(
Identifier
,
Expr
)]
...
...
src/Convert/Traverse.hs
View file @
d7b36a03
...
@@ -380,14 +380,8 @@ traverseTypesM mapper item =
...
@@ -380,14 +380,8 @@ traverseTypesM mapper item =
types
<-
mapM
fullMapper
$
map
fst
fields
types
<-
mapM
fullMapper
$
map
fst
fields
let
idents
=
map
snd
fields
let
idents
=
map
snd
fields
return
$
Struct
p
(
zip
types
idents
)
r
return
$
Struct
p
(
zip
types
idents
)
r
exprMapper
(
Cast
t
e
)
=
do
exprMapper
(
Cast
t
e
)
=
t'
<-
fullMapper
t
fullMapper
t
>>=
\
t'
->
return
$
Cast
t'
e
-- TODO HACK: If the cast type is no longer "simple", we just drop
-- the case altogether. This probably doesn't work great in all
-- cases.
return
$
if
elem
' '
(
show
t'
)
then
e
else
Cast
t'
e
exprMapper
other
=
return
other
exprMapper
other
=
return
other
declMapper
(
Parameter
t
x
e
)
=
declMapper
(
Parameter
t
x
e
)
=
fullMapper
t
>>=
\
t'
->
return
$
Parameter
t'
x
e
fullMapper
t
>>=
\
t'
->
return
$
Parameter
t'
x
e
...
...
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