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
30acc3e3
Commit
30acc3e3
authored
Aug 12, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix spacing of as-patterns for future GHC upgrade
parent
536eba46
Hide whitespace changes
Inline
Side-by-side
Showing
27 changed files
with
103 additions
and
103 deletions
+103
-103
src/Convert/BlockDecl.hs
+1
-1
src/Convert/DimensionQuery.hs
+2
-2
src/Convert/EmptyArgs.hs
+1
-1
src/Convert/ExprUtils.hs
+12
-12
src/Convert/FuncRoutine.hs
+1
-1
src/Convert/HierConst.hs
+3
-3
src/Convert/ImplicitNet.hs
+4
-4
src/Convert/Interface.hs
+6
-6
src/Convert/Jump.hs
+1
-1
src/Convert/KWArgs.hs
+1
-1
src/Convert/MultiplePacked.hs
+8
-8
src/Convert/Package.hs
+7
-7
src/Convert/ParamNoDefault.hs
+1
-1
src/Convert/ParamType.hs
+8
-8
src/Convert/Scoper.hs
+1
-1
src/Convert/Simplify.hs
+1
-1
src/Convert/Stream.hs
+2
-2
src/Convert/StringParam.hs
+2
-2
src/Convert/Struct.hs
+5
-5
src/Convert/TypeOf.hs
+6
-6
src/Convert/UnbasedUnsized.hs
+2
-2
src/Convert/UnnamedGenBlock.hs
+6
-6
src/Language/SystemVerilog/AST/Expr.hs
+8
-8
src/Language/SystemVerilog/AST/Number.hs
+2
-2
src/Language/SystemVerilog/AST/Stmt.hs
+4
-4
src/Language/SystemVerilog/Parser/Parse.y
+4
-4
src/Language/SystemVerilog/Parser/ParseDecl.hs
+4
-4
No files found.
src/Convert/BlockDecl.hs
View file @
30acc3e3
...
...
@@ -42,7 +42,7 @@ convertStmt (Block Seq name decls stmts) =
convertStmt
other
=
other
splitDecl
::
Decl
->
(
Decl
,
Maybe
(
LHS
,
Expr
))
splitDecl
(
decl
@
(
Variable
_
_
_
_
Nil
)
)
=
splitDecl
decl
@
(
Variable
_
_
_
_
Nil
)
=
(
decl
,
Nothing
)
splitDecl
(
Variable
d
t
ident
a
e
)
=
(
Variable
d
t
ident
a
Nil
,
Just
(
LHSIdent
ident
,
e
))
...
...
src/Convert/DimensionQuery.hs
View file @
30acc3e3
...
...
@@ -56,12 +56,12 @@ convertExpr (DimsFn fn (Right e)) =
DimsFn
fn
$
Left
$
TypeOf
e
convertExpr
(
DimFn
fn
(
Right
e
)
d
)
=
DimFn
fn
(
Left
$
TypeOf
e
)
d
convertExpr
(
orig
@
(
DimsFn
FnUnpackedDimensions
(
Left
t
)
))
=
convertExpr
orig
@
(
DimsFn
FnUnpackedDimensions
(
Left
t
))
=
case
t
of
UnpackedType
_
rs
->
RawNum
$
fromIntegral
$
length
rs
TypeOf
{}
->
orig
_
->
RawNum
0
convertExpr
(
orig
@
(
DimsFn
FnDimensions
(
Left
t
)
))
=
convertExpr
orig
@
(
DimsFn
FnDimensions
(
Left
t
))
=
case
t
of
IntegerAtom
{}
->
RawNum
1
Alias
{}
->
orig
...
...
src/Convert/EmptyArgs.hs
View file @
30acc3e3
...
...
@@ -20,7 +20,7 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
(
description
@
Part
{})
=
convertDescription
description
@
Part
{}
=
traverseModuleItems
(
traverseExprs
$
traverseNestedExprs
$
convertExpr
functions
)
description'
...
...
src/Convert/ExprUtils.hs
View file @
30acc3e3
...
...
@@ -44,9 +44,9 @@ simplifyStep (Concat [Number (Decimal size _ value)]) =
Number
$
Decimal
size
False
value
simplifyStep
(
Concat
[
Number
(
Based
size
_
base
value
kinds
)])
=
Number
$
Based
size
False
base
value
kinds
simplifyStep
(
Concat
[
e
@
Stream
{}])
=
e
simplifyStep
(
Concat
[
e
@
Concat
{}])
=
e
simplifyStep
(
Concat
[
e
@
Repeat
{}])
=
e
simplifyStep
(
Concat
[
e
@
Stream
{}])
=
e
simplifyStep
(
Concat
[
e
@
Concat
{}])
=
e
simplifyStep
(
Concat
[
e
@
Repeat
{}])
=
e
simplifyStep
(
Concat
es
)
=
Concat
$
filter
(
/=
Concat
[]
)
es
simplifyStep
(
Repeat
(
Dec
0
)
_
)
=
Concat
[]
simplifyStep
(
Repeat
(
Dec
1
)
es
)
=
Concat
es
...
...
@@ -91,23 +91,23 @@ simplifyBinOp Add (UniOp UniSub e1) e2 = BinOp Sub e2 e1
simplifyBinOp
Sub
e1
(
UniOp
UniSub
e2
)
=
BinOp
Add
e1
e2
simplifyBinOp
Sub
(
UniOp
UniSub
e1
)
e2
=
UniOp
UniSub
$
BinOp
Add
e1
e2
simplifyBinOp
Add
(
BinOp
Add
e
(
n1
@
Number
{}))
(
n2
@
Number
{})
=
simplifyBinOp
Add
(
BinOp
Add
e
n1
@
Number
{})
n2
@
Number
{}
=
BinOp
Add
e
(
BinOp
Add
n1
n2
)
simplifyBinOp
Sub
(
n1
@
Number
{})
(
BinOp
Sub
(
n2
@
Number
{})
e
)
=
simplifyBinOp
Sub
n1
@
Number
{}
(
BinOp
Sub
n2
@
Number
{}
e
)
=
BinOp
Add
(
BinOp
Sub
n1
n2
)
e
simplifyBinOp
Sub
(
n1
@
Number
{})
(
BinOp
Sub
e
(
n2
@
Number
{})
)
=
simplifyBinOp
Sub
n1
@
Number
{}
(
BinOp
Sub
e
n2
@
Number
{}
)
=
BinOp
Sub
(
BinOp
Add
n1
n2
)
e
simplifyBinOp
Sub
(
BinOp
Add
e
(
n1
@
Number
{}))
(
n2
@
Number
{})
=
simplifyBinOp
Sub
(
BinOp
Add
e
n1
@
Number
{})
n2
@
Number
{}
=
BinOp
Add
e
(
BinOp
Sub
n1
n2
)
simplifyBinOp
Add
(
n1
@
Number
{})
(
BinOp
Add
(
n2
@
Number
{})
e
)
=
simplifyBinOp
Add
n1
@
Number
{}
(
BinOp
Add
n2
@
Number
{}
e
)
=
BinOp
Add
(
BinOp
Add
n1
n2
)
e
simplifyBinOp
Add
(
n1
@
Number
{})
(
BinOp
Sub
e
(
n2
@
Number
{})
)
=
simplifyBinOp
Add
n1
@
Number
{}
(
BinOp
Sub
e
n2
@
Number
{}
)
=
BinOp
Add
e
(
BinOp
Sub
n1
n2
)
simplifyBinOp
Sub
(
BinOp
Sub
e
(
n1
@
Number
{}))
(
n2
@
Number
{})
=
simplifyBinOp
Sub
(
BinOp
Sub
e
n1
@
Number
{})
n2
@
Number
{}
=
BinOp
Sub
e
(
BinOp
Add
n1
n2
)
simplifyBinOp
Add
(
BinOp
Sub
e
(
n1
@
Number
{}))
(
n2
@
Number
{})
=
simplifyBinOp
Add
(
BinOp
Sub
e
n1
@
Number
{})
n2
@
Number
{}
=
BinOp
Sub
e
(
BinOp
Sub
n1
n2
)
simplifyBinOp
Add
(
BinOp
Sub
(
n1
@
Number
{})
e
)
(
n2
@
Number
{})
=
simplifyBinOp
Add
(
BinOp
Sub
n1
@
Number
{}
e
)
n2
@
Number
{}
=
BinOp
Sub
(
BinOp
Add
n1
n2
)
e
simplifyBinOp
Ge
(
BinOp
Sub
e
(
Dec
1
))
(
Dec
0
)
=
BinOp
Ge
e
(
toDec
1
)
...
...
src/Convert/FuncRoutine.hs
View file @
30acc3e3
...
...
@@ -22,7 +22,7 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
(
description
@
Part
{})
=
convertDescription
description
@
Part
{}
=
traverseModuleItems
traverseModuleItem
description
where
traverseModuleItem
=
...
...
src/Convert/HierConst.hs
View file @
30acc3e3
...
...
@@ -48,7 +48,7 @@ convertDescription (Part attrs extern kw lifetime name ports items) =
convertDescription
description
=
description
expandParam
::
[
Identifier
]
->
ModuleItem
->
ModuleItem
expandParam
shadowed
(
MIPackageItem
(
Decl
(
param
@
(
Param
Parameter
_
x
_
)
)))
=
expandParam
shadowed
(
MIPackageItem
(
Decl
param
@
(
Param
Parameter
_
x
_
)))
=
if
elem
x
shadowed
then
Generate
$
map
(
GenModuleItem
.
wrap
)
[
param
,
extra
]
else
wrap
param
...
...
@@ -82,14 +82,14 @@ traverseDeclM decl = do
-- substitute hierarchical references to constants
traverseExprM
::
Expr
->
ST
Expr
traverseExprM
(
expr
@
(
Dot
_
x
)
)
=
do
traverseExprM
expr
@
(
Dot
_
x
)
=
do
expr'
<-
traverseSinglyNestedExprsM
traverseExprM
expr
detailsE
<-
lookupElemM
expr'
detailsX
<-
lookupElemM
x
case
(
detailsE
,
detailsX
)
of
(
Just
([
_
,
_
],
_
,
Left
{}),
Just
([
_
,
_
],
_
,
Left
{}))
->
return
$
Ident
x
(
Just
(
accesses
@
[
Access
_
Nil
,
_
],
_
,
Left
False
),
_
)
->
do
(
Just
(
accesses
@
[
Access
_
Nil
,
_
],
_
,
Left
False
),
_
)
->
do
details
<-
lookupElemM
$
prefix
x
when
(
details
==
Nothing
)
$
insertElem
accesses
(
Left
True
)
...
...
src/Convert/ImplicitNet.hs
View file @
30acc3e3
...
...
@@ -49,20 +49,20 @@ traverseDeclM decl = do
traverseModuleItemM
::
DefaultNetType
->
ModuleItem
->
Scoper
()
ModuleItem
traverseModuleItemM
_
(
Genvar
x
)
=
insertElem
x
()
>>
return
(
Genvar
x
)
traverseModuleItemM
defaultNetType
(
orig
@
(
Assign
_
x
_
)
)
=
do
traverseModuleItemM
defaultNetType
orig
@
(
Assign
_
x
_
)
=
do
needsLHS
defaultNetType
x
return
orig
traverseModuleItemM
defaultNetType
(
orig
@
(
NInputGate
_
_
x
lhs
exprs
)
)
=
do
traverseModuleItemM
defaultNetType
orig
@
(
NInputGate
_
_
x
lhs
exprs
)
=
do
insertElem
x
()
needsLHS
defaultNetType
lhs
_
<-
mapM
(
needsExpr
defaultNetType
)
exprs
return
orig
traverseModuleItemM
defaultNetType
(
orig
@
(
NOutputGate
_
_
x
lhss
expr
)
)
=
do
traverseModuleItemM
defaultNetType
orig
@
(
NOutputGate
_
_
x
lhss
expr
)
=
do
insertElem
x
()
_
<-
mapM
(
needsLHS
defaultNetType
)
lhss
needsExpr
defaultNetType
expr
return
orig
traverseModuleItemM
defaultNetType
(
orig
@
(
Instance
_
_
x
_
ports
)
)
=
do
traverseModuleItemM
defaultNetType
orig
@
(
Instance
_
_
x
_
ports
)
=
do
insertElem
x
()
_
<-
mapM
(
needsExpr
defaultNetType
.
snd
)
ports
return
orig
...
...
src/Convert/Interface.hs
View file @
30acc3e3
...
...
@@ -88,7 +88,7 @@ convertDescription parts (Part attrs extern Module lifetime name ports items) =
traverseModuleItemM
::
ModuleItem
->
Scoper
[
ModportDecl
]
ModuleItem
traverseModuleItemM
(
Modport
modportName
modportDecls
)
=
insertElem
modportName
modportDecls
>>
return
(
Generate
[]
)
traverseModuleItemM
(
instanceItem
@
Instance
{})
=
do
traverseModuleItemM
instanceItem
@
Instance
{}
=
do
modports
<-
embedScopes
(
\
l
()
->
l
)
()
if
isNothing
maybePartInfo
then
return
instanceItem
...
...
@@ -129,7 +129,7 @@ convertDescription parts (Part attrs extern Module lifetime name ports items) =
-- add explicit slices for bindings of entire modport instance arrays
addImpliedSlice
::
Scopes
[
ModportDecl
]
->
Expr
->
Expr
addImpliedSlice
modports
(
orig
@
(
Dot
expr
modportName
)
)
=
addImpliedSlice
modports
orig
@
(
Dot
expr
modportName
)
=
case
lookupIntfElem
modports
(
InstArrKey
expr
)
of
Just
(
_
,
_
,
InstArrVal
l
r
)
->
Dot
(
Range
expr
NonIndexed
(
l
,
r
))
modportName
...
...
@@ -485,7 +485,7 @@ inlineInstance global ranges modportBindings items partName
case
lookup
(
Bit
expr
Tag
)
exprReplacements
of
Just
resolved
->
replaceArrTag
(
replaceExpr'
local
elt
)
resolved
Nothing
->
Bit
(
replaceExpr'
local
expr
)
(
replaceExpr'
local
elt
)
replaceExpr'
local
(
expr
@
(
Dot
Ident
{}
_
)
)
=
replaceExpr'
local
expr
@
(
Dot
Ident
{}
_
)
=
case
lookup
expr
exprReplacements
of
Just
expr'
->
expr'
Nothing
->
checkExprResolution
local
expr
$
...
...
@@ -555,7 +555,7 @@ inlineInstance global ranges modportBindings items partName
Implicit
Unspecified
rs
->
IntegerVector
TLogic
Unspecified
rs
_
->
t
removeDeclDir
decl
@
Net
{}
=
removeDeclDir
decl
@
Net
{}
=
traverseNetAsVar
removeDeclDir
decl
removeDeclDir
other
=
other
...
...
@@ -620,7 +620,7 @@ inlineInstance global ranges modportBindings items partName
collectDeclDir
(
Variable
dir
_
ident
_
_
)
=
when
(
dir
/=
Local
)
$
tell
$
Map
.
singleton
ident
dir
collectDeclDir
net
@
Net
{}
=
collectDeclDir
net
@
Net
{}
=
collectNetAsVarM
collectDeclDir
net
collectDeclDir
_
=
return
()
findDeclDir
::
Identifier
->
Direction
...
...
@@ -641,7 +641,7 @@ inlineInstance global ranges modportBindings items partName
loopVar
=
"_arr_"
++
key
isArray
=
not
$
null
ranges
[
arrayRange
@
(
arrayLeft
,
arrayRight
)]
=
ranges
[
arrayRange
@
(
arrayLeft
,
arrayRight
)]
=
ranges
-- wrap the given item in a generate loop if necessary
wrapInstance
::
Identifier
->
[
ModuleItem
]
->
ModuleItem
...
...
src/Convert/Jump.hs
View file @
30acc3e3
...
...
@@ -105,7 +105,7 @@ addJumpStateDeclStmt stmt =
where
(
decls
,
[
stmt'
])
=
addJumpStateDeclTF
[]
[
stmt
]
removeJumpState
::
Stmt
->
Stmt
removeJumpState
(
orig
@
(
Asgn
_
_
(
LHSIdent
ident
)
_
)
)
=
removeJumpState
orig
@
(
Asgn
_
_
(
LHSIdent
ident
)
_
)
=
if
ident
==
jumpState
then
Null
else
orig
...
...
src/Convert/KWArgs.hs
View file @
30acc3e3
...
...
@@ -55,7 +55,7 @@ convertStmt tfs (Subroutine expr args) =
convertStmt
_
other
=
other
convertInvoke
::
TFs
->
(
Expr
->
Args
->
a
)
->
Expr
->
Args
->
a
convertInvoke
tfs
constructor
(
Ident
func
)
(
Args
pnArgs
(
kwArgs
@
(
_
:
_
)
))
=
convertInvoke
tfs
constructor
(
Ident
func
)
(
Args
pnArgs
kwArgs
@
(
_
:
_
))
=
case
tfs
Map
.!?
func
of
Nothing
->
constructor
(
Ident
func
)
(
Args
pnArgs
kwArgs
)
Just
ordered
->
constructor
(
Ident
func
)
(
Args
args
[]
)
...
...
src/Convert/MultiplePacked.hs
View file @
30acc3e3
...
...
@@ -42,7 +42,7 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
(
description
@
(
Part
_
_
Module
_
_
_
_
)
)
=
convertDescription
description
@
(
Part
_
_
Module
_
_
_
_
)
=
partScoper
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
description
convertDescription
other
=
other
...
...
@@ -52,7 +52,7 @@ traverseDeclM :: Decl -> Scoper TypeInfo Decl
traverseDeclM
(
Variable
dir
t
ident
a
e
)
=
do
t'
<-
traverseTypeM
t
a
ident
traverseDeclExprsM
traverseExprM
$
Variable
dir
t'
ident
a
e
traverseDeclM
net
@
Net
{}
=
traverseDeclM
net
@
Net
{}
=
traverseNetAsVarM
traverseDeclM
net
traverseDeclM
(
Param
s
t
ident
e
)
=
do
t'
<-
traverseTypeM
t
[]
ident
...
...
@@ -233,7 +233,7 @@ convertExpr scopes =
if
head
x
==
tag
then
Ident
$
tail
x
else
Ident
x
rewriteExpr
(
orig
@
(
Bit
(
Bit
expr
idxInner
)
idxOuter
)
)
=
rewriteExpr
orig
@
(
Bit
(
Bit
expr
idxInner
)
idxOuter
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
Bit
expr'
idx'
else
rewriteExprLowPrec
orig
...
...
@@ -244,7 +244,7 @@ convertExpr scopes =
idxOuter'
=
orientIdx
dimOuter
idxOuter
base
=
BinOp
Mul
idxInner'
(
rangeSize
dimOuter
)
idx'
=
simplify
$
BinOp
Add
base
idxOuter'
rewriteExpr
(
orig
@
(
Range
(
Bit
expr
idxInner
)
NonIndexed
rangeOuter
)
)
=
rewriteExpr
orig
@
(
Range
(
Bit
expr
idxInner
)
NonIndexed
rangeOuter
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
rewriteExpr
$
Range
exprOuter
IndexedMinus
range
else
rewriteExprLowPrec
orig
...
...
@@ -256,7 +256,7 @@ convertExpr scopes =
base
=
endianCondExpr
rangeOuter
baseDec
baseInc
len
=
rangeSize
rangeOuter
range
=
(
base
,
len
)
rewriteExpr
(
orig
@
(
Range
(
Bit
expr
idxInner
)
modeOuter
rangeOuter
)
)
=
rewriteExpr
orig
@
(
Range
(
Bit
expr
idxInner
)
modeOuter
rangeOuter
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
Range
expr'
modeOuter
range'
else
rewriteExprLowPrec
orig
...
...
@@ -279,7 +279,7 @@ convertExpr scopes =
rewriteExprLowPrec
other
rewriteExprLowPrec
::
Expr
->
Expr
rewriteExprLowPrec
(
orig
@
(
Bit
expr
idx
)
)
=
rewriteExprLowPrec
orig
@
(
Bit
expr
idx
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
Range
expr'
mode'
range'
else
orig
...
...
@@ -291,7 +291,7 @@ convertExpr scopes =
len
=
rangeSize
dimOuter
base
=
BinOp
Add
(
endianCondExpr
dimOuter
(
snd
dimOuter
)
(
fst
dimOuter
))
(
BinOp
Mul
idx'
len
)
range'
=
(
simplify
base
,
simplify
len
)
rewriteExprLowPrec
(
orig
@
(
Range
expr
NonIndexed
range
)
)
=
rewriteExprLowPrec
orig
@
(
Range
expr
NonIndexed
range
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
rewriteExpr
$
Range
expr
IndexedMinus
range'
else
orig
...
...
@@ -302,7 +302,7 @@ convertExpr scopes =
base
=
endianCondExpr
range
baseDec
baseInc
len
=
rangeSize
range
range'
=
(
base
,
len
)
rewriteExprLowPrec
(
orig
@
(
Range
expr
mode
range
)
)
=
rewriteExprLowPrec
orig
@
(
Range
expr
mode
range
)
=
if
isJust
maybeDims
&&
expr
==
rewriteExpr
expr
then
Range
expr'
mode'
range'
else
orig
...
...
src/Convert/Package.hs
View file @
30acc3e3
...
...
@@ -87,8 +87,8 @@ collectPackageM (Class _ name decls items) =
tell
(
Map
.
empty
,
Map
.
singleton
name
(
decls
,
map
unpackClassItem
items
),
[]
)
where
unpackClassItem
::
ClassItem
->
PackageItem
unpackClassItem
(
item
@
(
_
,
Task
{})
)
=
checkTF
item
unpackClassItem
(
item
@
(
_
,
Function
{})
)
=
checkTF
item
unpackClassItem
item
@
(
_
,
Task
{}
)
=
checkTF
item
unpackClassItem
item
@
(
_
,
Function
{}
)
=
checkTF
item
unpackClassItem
item
=
checkNonTF
item
checkTF
::
ClassItem
->
PackageItem
checkTF
(
QStatic
,
item
)
=
item
...
...
@@ -242,7 +242,7 @@ processItems topName packageName moduleItems = do
-- produces partial mappings of exported identifiers, while also
-- checking the validity of the exports
resolveExportMI
::
IdentStateMap
->
ModuleItem
->
PackagesState
IdentStateMap
resolveExportMI
mapping
(
MIPackageItem
(
item
@
(
Export
pkg
ident
)
))
=
resolveExportMI
mapping
(
MIPackageItem
item
@
(
Export
pkg
ident
))
=
if
null
packageName
then
error
$
"invalid "
++
(
init
$
show
item
)
++
" outside of package"
...
...
@@ -304,12 +304,12 @@ processItems topName packageName moduleItems = do
++
intercalate
", "
rootPkgs
traversePackageItemM
::
PackageItem
->
Scope
PackageItem
traversePackageItemM
(
orig
@
(
Import
pkg
ident
)
)
=
do
traversePackageItemM
orig
@
(
Import
pkg
ident
)
=
do
if
null
ident
then
wildcardImports
pkg
else
explicitImport
pkg
ident
return
$
Decl
$
CommentDecl
$
"removed "
++
show
orig
traversePackageItemM
(
orig
@
(
Export
pkg
ident
)
)
=
do
traversePackageItemM
orig
@
(
Export
pkg
ident
)
=
do
()
<-
when
(
not
(
null
pkg
||
null
ident
))
$
do
localName
<-
resolveIdent
ident
rootPkg
<-
lift
$
resolveRootPackage
pkg
ident
...
...
@@ -459,7 +459,7 @@ findPackage packageName = do
assertMsg
(
not
$
elem
packageName
stack
)
$
"package dependency loop: "
++
show
first
++
" depends on "
++
intercalate
", which depends on "
(
map
show
rest
)
let
Just
(
package
@
(
exports
,
_
))
=
maybePackage
let
Just
package
@
(
exports
,
_
)
=
maybePackage
if
Map
.
null
exports
then
do
-- process and resolve this package
...
...
@@ -613,7 +613,7 @@ toRootPackage sourcePackage identState =
-- nests packages items missing from modules
convertDescription
::
PIs
->
Description
->
Description
convertDescription
pis
(
orig
@
Part
{})
=
convertDescription
pis
orig
@
Part
{}
=
if
Map
.
null
pis
then
orig
else
Part
attrs
extern
kw
lifetime
name
ports
items'
...
...
src/Convert/ParamNoDefault.hs
View file @
30acc3e3
...
...
@@ -65,7 +65,7 @@ traverseDeclM other = return other
-- check for instances missing values for parameters without defaults
traverseModuleItem
::
Parts
->
ModuleItem
->
ModuleItem
traverseModuleItem
parts
(
orig
@
(
Instance
part
params
name
_
_
)
)
=
traverseModuleItem
parts
orig
@
(
Instance
part
params
name
_
_
)
=
if
maybePartInfo
==
Nothing
||
null
missingParams
then
orig
else
error
$
"instance "
++
show
name
++
" of "
++
show
part
...
...
src/Convert/ParamType.hs
View file @
30acc3e3
...
...
@@ -39,7 +39,7 @@ convert files =
-- add type parameter instantiations
files''
=
map
(
concatMap
explodeDescription
)
files'
explodeDescription
::
Description
->
[
Description
]
explodeDescription
(
part
@
(
Part
_
_
_
_
name
_
_
)
)
=
explodeDescription
part
@
(
Part
_
_
_
_
name
_
_
)
=
(
part
:
)
$
filter
(
not
.
alreadyExists
)
$
map
(
rewriteModule
part
)
theseInstances
...
...
@@ -57,7 +57,7 @@ convert files =
both
(
Map
.
fromListWith
Set
.
union
)
$
execWriter
$
mapM
(
mapM
collectUsageM
)
files''
collectUsageM
::
Description
->
Writer
(
UsageMap
,
UsageMap
)
()
collectUsageM
(
part
@
(
Part
_
_
_
_
name
_
_
)
)
=
collectUsageM
part
@
(
Part
_
_
_
_
name
_
_
)
=
tell
$
both
makeList
$
execWriter
$
(
collectModuleItemsM
collectModuleItemM
)
part
where
makeList
s
=
zip
(
Set
.
toList
s
)
(
repeat
$
Set
.
singleton
name
)
...
...
@@ -93,7 +93,7 @@ convert files =
-- instantiate the type parameters if this is a used default instance
reduceTypeDefaults
::
Description
->
Description
reduceTypeDefaults
(
part
@
(
Part
_
_
_
_
name
_
_
)
)
=
reduceTypeDefaults
part
@
(
Part
_
_
_
_
name
_
_
)
=
if
shouldntReduce
then
part
else
traverseModuleItems
(
traverseDecls
rewriteDecl
)
part
...
...
@@ -149,7 +149,7 @@ convert files =
additionalParamItems
=
concatMap
makeAddedParams
$
Map
.
toList
$
Map
.
map
snd
inst
rewriteExpr
::
Expr
->
Expr
rewriteExpr
(
orig
@
(
Dot
(
Ident
x
)
y
)
)
=
rewriteExpr
orig
@
(
Dot
(
Ident
x
)
y
)
=
if
x
==
m
then
Dot
(
Ident
m'
)
y
else
orig
...
...
@@ -157,7 +157,7 @@ convert files =
traverseExprTypes
rewriteType
$
traverseSinglyNestedExprs
rewriteExpr
other
rewriteLHS
::
LHS
->
LHS
rewriteLHS
(
orig
@
(
LHSDot
(
LHSIdent
x
)
y
)
)
=
rewriteLHS
orig
@
(
LHSDot
(
LHSIdent
x
)
y
)
=
if
x
==
m
then
LHSDot
(
LHSIdent
m'
)
y
else
orig
...
...
@@ -192,7 +192,7 @@ convert files =
-- write down module parameter names and type parameters
collectDescriptionM
::
Description
->
Writer
Modules
()
collectDescriptionM
(
part
@
(
Part
_
_
_
_
name
_
_
)
)
=
collectDescriptionM
part
@
(
Part
_
_
_
_
name
_
_
)
=
tell
$
Map
.
singleton
name
typeMap
where
typeMap
=
Map
.
fromList
$
execWriter
$
...
...
@@ -250,7 +250,7 @@ prepareTypeExprs instanceName paramName =
(
traverseTypeExprsM
$
traverseNestedExprsM
prepareExpr
)
where
prepareExpr
::
Expr
->
Writer
(
IdentSet
,
DeclMap
)
Expr
prepareExpr
(
e
@
Call
{})
=
do
prepareExpr
e
@
Call
{}
=
do
tell
(
Set
.
empty
,
Map
.
singleton
x
decl
)
prepareExpr
$
Ident
x
where
...
...
@@ -281,7 +281,7 @@ convertGenItemM other =
-- attempt to rewrite instantiations with type parameters
convertModuleItemM
::
ModuleItem
->
Writer
Instances
ModuleItem
convertModuleItemM
(
orig
@
(
Instance
m
bindings
x
r
p
)
)
=
convertModuleItemM
orig
@
(
Instance
m
bindings
x
r
p
)
=
if
hasOnlyExprs
then
return
orig
else
if
not
hasUnresolvedTypes
then
do
...
...
src/Convert/Scoper.hs
View file @
30acc3e3
...
...
@@ -276,7 +276,7 @@ directResolve mapping (Access x Nil : rest) = do
Entry
_
""
subMapping
<-
Map
.
lookup
x
mapping
directResolve
subMapping
rest
directResolve
mapping
(
Access
x
e
:
rest
)
=
do
Entry
_
(
index
@
(
_
:
_
)
)
subMapping
<-
Map
.
lookup
x
mapping
Entry
_
index
@
(
_
:
_
)
subMapping
<-
Map
.
lookup
x
mapping
(
replacements
,
element
)
<-
directResolve
subMapping
rest
let
replacements'
=
Map
.
insert
index
e
replacements
Just
(
replacements'
,
element
)
...
...
src/Convert/Simplify.hs
View file @
30acc3e3
...
...
@@ -155,6 +155,6 @@ substitute scopes expr =
substituteIdent
::
Scopes
Expr
->
Expr
->
Expr
substituteIdent
scopes
(
Ident
x
)
=
case
lookupElem
scopes
x
of
Just
(
_
,
_
,
n
@
Number
{})
->
n
Just
(
_
,
_
,
n
@
Number
{})
->
n
_
->
Ident
x
substituteIdent
_
other
=
other
src/Convert/Stream.hs
View file @
30acc3e3
...
...
@@ -27,7 +27,7 @@ traverseDeclM (Variable d t x [] (Stream StreamR _ exprs)) =
expr'
=
resize
exprSize
lhsSize
expr
lhsSize
=
DimsFn
FnBits
$
Left
t
exprSize
=
sizeof
expr
traverseDeclM
(
Variable
d
t
x
[]
(
expr
@
(
Stream
StreamL
chunk
exprs
)
))
=
do
traverseDeclM
(
Variable
d
t
x
[]
expr
@
(
Stream
StreamL
chunk
exprs
))
=
do
inProcedure
<-
withinProcedureM
if
inProcedure
then
return
$
Variable
d
t
x
[]
expr
...
...
@@ -40,7 +40,7 @@ traverseDeclM (Variable d t x [] (expr @ (Stream StreamL chunk exprs))) = do
expr'
=
Call
(
Ident
fnName
)
(
Args
[
Concat
exprs
]
[]
)
traverseDeclM
(
Variable
d
t
x
a
expr
)
=
traverseExprM
expr
>>=
return
.
Variable
d
t
x
a
traverseDeclM
decl
@
Net
{}
=
traverseNetAsVarM
traverseDeclM
decl
traverseDeclM
decl
@
Net
{}
=
traverseNetAsVarM
traverseDeclM
decl
traverseDeclM
decl
=
return
decl
traverseModuleItemM
::
ModuleItem
->
Scoper
()
ModuleItem
...
...
src/Convert/StringParam.hs
View file @
30acc3e3
...
...
@@ -72,7 +72,7 @@ collectQueriedIdentsM _ _ = return ()
elaborateStringParam
::
Idents
->
ModuleItem
->
ModuleItem
elaborateStringParam
idents
(
MIAttr
attr
item
)
=
MIAttr
attr
$
elaborateStringParam
idents
item
elaborateStringParam
idents
(
orig
@
(
StringParam
x
str
)
)
=
elaborateStringParam
idents
orig
@
(
StringParam
x
str
)
=
if
Set
.
member
x
idents
then
Generate
$
map
wrap
[
width
,
param
]
else
orig
...
...
@@ -99,7 +99,7 @@ mapInstance partStringParams (Instance m params x rs ports) =
where
expand
::
[
Identifier
]
->
ParamBinding
->
[
ParamBinding
]
expand
_
(
paramName
,
Left
t
)
=
[(
paramName
,
Left
t
)]
expand
stringParams
(
orig
@
(
paramName
,
Right
expr
)
)
=
expand
stringParams
orig
@
(
paramName
,
Right
expr
)
=
if
elem
paramName
stringParams
then
[(
widthName
paramName
,
Right
width
),
orig
]
else
[
orig
]
...
...
src/Convert/Struct.hs
View file @
30acc3e3
...
...
@@ -24,7 +24,7 @@ convert :: [AST] -> [AST]
convert
=
map
$
traverseDescriptions
convertDescription
convertDescription
::
Description
->
Description
convertDescription
(
description
@
(
Part
_
_
Module
_
_
_
_
)
)
=
convertDescription
description
@
(
Part
_
_
Module
_
_
_
_
)
=
partScoper
traverseDeclM
traverseModuleItemM
traverseGenItemM
traverseStmtM
description
convertDescription
other
=
other
...
...
@@ -103,7 +103,7 @@ convertType t1 =
-- write down the types of declarations
traverseDeclM
::
Decl
->
Scoper
Type
Decl
traverseDeclM
decl
@
Net
{}
=
traverseDeclM
decl
@
Net
{}
=
traverseNetAsVarM
traverseDeclM
decl
traverseDeclM
decl
=
do
decl'
<-
case
decl
of
...
...
@@ -196,7 +196,7 @@ convertExpr t (Mux c e1 e2) =
e1'
=
convertExpr
t
e1
e2'
=
convertExpr
t
e2
convertExpr
(
struct
@
(
Struct
_
fields
[]
)
)
(
Pattern
itemsOrig
)
=
convertExpr
struct
@
(
Struct
_
fields
[]
)
(
Pattern
itemsOrig
)
=
if
not
(
null
extraNames
)
then
error
$
"pattern "
++
show
(
Pattern
itemsOrig
)
++
" has extra named fields "
++
show
extraNames
++
...
...
@@ -302,7 +302,7 @@ convertExpr (Implicit sg rs) expr =
-- TODO: This is a conversion for concat array literals with elements
-- that are unsized numbers. This probably belongs somewhere else.
convertExpr
(
t
@
IntegerVector
{})
(
Concat
exprs
)
=
convertExpr
t
@
IntegerVector
{}
(
Concat
exprs
)
=
if
all
isUnsizedNumber
exprs
then
Concat
$
map
(
Cast
$
Left
t'
)
exprs
else
Concat
$
map
(
convertExpr
t'
)
exprs
...
...
@@ -317,7 +317,7 @@ convertExpr (t @ IntegerVector{}) (Concat exprs) =
-- TODO: This is really a conversion for using default patterns to
-- populate arrays. Maybe this should be somewhere else?
convertExpr
t
(
orig
@
(
Pattern
[(
Left
UnknownType
,
expr
)])
)
=
convertExpr
t
orig
@
(
Pattern
[(
Left
UnknownType
,
expr
)]
)
=
if
null
rs
then
orig
else
Repeat
count
[
expr'
]
...
...
src/Convert/TypeOf.hs
View file @
30acc3e3
...
...
@@ -41,7 +41,7 @@ type ST = Scoper Type
-- insert the given declaration into the scope, and convert an TypeOfs within
traverseDeclM
::
Decl
->
ST
Decl
traverseDeclM
decl
@
Net
{}
=
traverseDeclM
decl
@
Net
{}
=
traverseNetAsVarM
traverseDeclM
decl
traverseDeclM
decl
=
do
decl'
<-
traverseDeclNodesM
traverseTypeM
traverseExprM
decl
...
...
@@ -98,7 +98,7 @@ traverseExprM (Cast (Left (Implicit sg [])) expr) =
traverseExprM
(
Cast
(
Left
t
)
(
Number
(
UnbasedUnsized
bit
)))
=
-- defer until this expression becomes explicit
return
$
Cast
(
Left
t
)
(
Number
(
UnbasedUnsized
bit
))
traverseExprM
(
Cast
(
Left
(
t
@
(
IntegerAtom
TInteger
_
)
))
expr
)
=
traverseExprM
(
Cast
(
Left
t
@
(
IntegerAtom
TInteger
_
))
expr
)
=
-- convert to cast to an integer vector type
traverseExprM
$
Cast
(
Left
t'
)
expr
where
...
...
@@ -189,14 +189,14 @@ typeof (Number n) =
size
=
numberBitLength
n
sg
=
if
numberIsSigned
n
then
Signed
else
Unspecified
typeof
(
Call
(
Ident
x
)
args
)
=
typeofCall
x
args
typeof
(
orig
@
(
Bit
e
_
)
)
=
do
typeof
orig
@
(
Bit
e
_
)
=
do
t
<-
typeof
e
let
t'
=
popRange
t
case
t
of
TypeOf
{}
->
lookupTypeOf
orig
Alias
{}
->
return
$
TypeOf
orig
_
->
return
$
typeSignednessOverride
t'
Unsigned
t'
typeof
(
orig
@
(
Range
e
NonIndexed
r
)
)
=
do
typeof
orig
@
(
Range
e
NonIndexed
r
)
=
do
t
<-
typeof
e
let
t'
=
replaceRange
r
t
return
$
case
t
of
...
...
@@ -217,7 +217,7 @@ typeof (Range expr mode (base, len)) =
if
mode
==
IndexedPlus
then
BinOp
Sub
(
BinOp
Add
base
len
)
(
RawNum
1
)
else
BinOp
Add
(
BinOp
Sub
base
len
)
(
RawNum
1
)
typeof
(
orig
@
(
Dot
e
x
)
)
=
do
typeof
orig
@
(
Dot
e
x
)
=
do
t
<-
typeof
e
case
t
of
Struct
_
fields
[]
->
return
$
fieldsType
fields
...
...
@@ -404,7 +404,7 @@ typeCastUnneeded t1 t2 =
sz2
=
typeSize
t2
typeSize
::
Type
->
Maybe
Expr
typeSize
(
IntegerVector
_
_
rs
)
=
Just
$
dimensionsSize
rs
typeSize
(
t
@
IntegerAtom
{})
=
typeSize
t
@
IntegerAtom
{}
=
typeSize
$
tf
[(
RawNum
1
,
RawNum
1
)]
where
(
tf
,
[]
)
=
typeRanges
t
typeSize
_
=
Nothing
...
...
src/Convert/UnbasedUnsized.hs
View file @
30acc3e3
...
...
@@ -207,7 +207,7 @@ convertExpr _ (Cast te e) =
Cast
te
$
convertExpr
SelfDetermined
e
convertExpr
_
(
Concat
exprs
)
=
Concat
$
map
(
convertExpr
SelfDetermined
)
exprs
convertExpr
context
(
Pattern
[(
Left
UnknownType
,
e
@
UU
{})])
=
convertExpr
context
(
Pattern
[(
Left
UnknownType
,
e
@
UU
{})])
=
convertExpr
context
e
convertExpr
_
(
Pattern
items
)
=
Pattern
$
zip
...
...
@@ -218,7 +218,7 @@ convertExpr _ (Call expr (Args pnArgs [])) =
where
pnArgs'
=
map
(
convertExpr
SelfDetermined
)
pnArgs
convertExpr
_
(
Repeat
count
exprs
)
=
Repeat
count
$
map
(
convertExpr
SelfDetermined
)
exprs
convertExpr
SelfDetermined
(
Mux
cond
(
e1
@
UU
{})
(
e2
@
UU
{})
)
=
convertExpr
SelfDetermined
(
Mux
cond
e1
@
UU
{}
e2
@
UU
{}
)
=
Mux
(
convertExpr
SelfDetermined
cond
)
(
convertExpr
SelfDetermined
e1
)
...
...
src/Convert/UnnamedGenBlock.hs
View file @
30acc3e3
...
...
@@ -31,10 +31,10 @@ initialState :: Info
initialState
=
(
[]
,
1
)
traverseModuleItemM
::
ModuleItem
->
S
ModuleItem
traverseModuleItemM
(
item
@
(
Genvar
x
)
)
=
declaration
x
item
traverseModuleItemM
(
item
@
(
NInputGate
_
_
x
_
_
)
)
=
declaration
x
item
traverseModuleItemM
(
item
@
(
NOutputGate
_
_
x
_
_
)
)
=
declaration
x
item
traverseModuleItemM
(
item
@
(
Instance
_
_
x
_
_
)
)
=
declaration
x
item
traverseModuleItemM
item
@
(
Genvar
x
)
=
declaration
x
item
traverseModuleItemM
item
@
(
NInputGate
_
_
x
_
_
)
=
declaration
x
item
traverseModuleItemM
item
@
(
NOutputGate
_
_
x
_
_
)
=
declaration
x
item
traverseModuleItemM
item
@
(
Instance
_
_
x
_
_
)
=
declaration
x
item
traverseModuleItemM
(
MIPackageItem
(
Decl
decl
))
=
traverseDeclM
decl
>>=
return
.
MIPackageItem
.
Decl
traverseModuleItemM
(
MIAttr
attr
item
)
=
...
...
@@ -56,10 +56,10 @@ traverseDeclM decl =
-- label the generate blocks within an individual generate item which is already
-- in a list of generate items (top level or generate block)
traverseGenItemM
::
GenItem
->
S
GenItem
traverseGenItemM
(
item
@
GenIf
{})
=
do
traverseGenItemM
item
@
GenIf
{}
=
do
item'
<-
labelGenElse
item
incrCount
>>
return
item'
traverseGenItemM
(
item
@
GenBlock
{})
=
do
traverseGenItemM
item
@
GenBlock
{}
=
do
item'
<-
labelBlock
item
incrCount
>>
return
item'
traverseGenItemM
(
GenFor
a
b
c
item
)
=
do
...
...
src/Language/SystemVerilog/AST/Expr.hs
View file @
30acc3e3
...
...
@@ -91,11 +91,11 @@ instance Show Expr where
showPatternItem
(
Left
t
,
v
)
=
printf
"%s: %s"
tStr
(
show
v
)
where
tStr
=
if
null
(
show
t
)
then
"default"
else
show
t
show
(
MinTypMax
a
b
c
)
=
printf
"(%s : %s : %s)"
(
show
a
)
(
show
b
)
(
show
c
)
show
(
e
@
UniOp
{})
=
showsPrec
0
e
""
show
(
e
@
BinOp
{})
=
showsPrec
0
e
""
show
(
e
@
Dot
{})
=
showsPrec
0
e
""
show
(
e
@
Mux
{})
=
showsPrec
0
e
""
show
(
e
@
Call
{})
=
showsPrec
0
e
""
show
e
@
UniOp
{}
=
showsPrec
0
e
""
show
e
@
BinOp
{}
=
showsPrec
0
e
""
show
e
@
Dot
{}
=
showsPrec
0
e
""
show
e
@
Mux
{}
=
showsPrec
0
e
""
show
e
@
Call
{}
=
showsPrec
0
e
""
showsPrec
_
(
UniOp
o
e
)
=
shows
o
.
...
...
@@ -185,12 +185,12 @@ showRange :: Range -> String
showRange
(
h
,
l
)
=
'['
:
show
h
++
':'
:
show
l
++
"]"
showUniOpPrec
::
Expr
->
ShowS
showUniOpPrec
(
e
@
UniOp
{})
=
(
showParen
True
.
shows
)
e
showUniOpPrec
(
e
@
BinOp
{})
=
(
showParen
True
.
shows
)
e
showUniOpPrec
e
@
UniOp
{}
=
(
showParen
True
.
shows
)
e
showUniOpPrec
e
@
BinOp
{}
=
(
showParen
True
.
shows
)
e
showUniOpPrec
e
=
shows
e
showBinOpPrec
::
Expr
->
ShowS
showBinOpPrec
(
e
@
BinOp
{})
=
(
showParen
True
.
shows
)
e
showBinOpPrec
e
@
BinOp
{}
=
(
showParen
True
.
shows
)
e
showBinOpPrec
e
=
shows
e
type
ParamBinding
=
(
Identifier
,
TypeOrExpr
)
...
...
src/Language/SystemVerilog/AST/Number.hs
View file @
30acc3e3
...
...
@@ -449,7 +449,7 @@ chunk base n0 =
-- number concatenation
instance
Semigroup
Number
where
(
n1
@
Based
{})
<>
(
n2
@
Based
{})
=
n1
@
Based
{}
<>
n2
@
Based
{}
=
Based
size
signed
base
values
kinds
where
size
=
size1
+
size2
...
...
@@ -465,7 +465,7 @@ instance Semigroup Number where
n1
<>
n2
=
toBased
n1
<>
toBased
n2
where
toBased
(
n
@
Based
{})
=
n
toBased
n
@
Based
{}
=
n
toBased
(
Decimal
size
signed
num
)
=
Based
size
signed
Hex
num
0
toBased
(
UnbasedUnsized
bit
)
=
...
...
src/Language/SystemVerilog/AST/Stmt.hs
View file @
30acc3e3
...
...
@@ -104,9 +104,9 @@ showAssign :: (LHS, AsgnOp, Expr) -> String
showAssign
(
l
,
op
,
e
)
=
(
showPad
l
)
++
(
showPad
op
)
++
(
show
e
)
showBranch
::
Stmt
->
String
showBranch
(
Block
Seq
""
[]
(
stmts
@
[
CommentStmt
{},
_
])
)
=
showBranch
(
Block
Seq
""
[]
stmts
@
[
CommentStmt
{},
_
]
)
=
'
\n
'
:
(
indent
$
show
stmts
)
showBranch
(
block
@
Block
{})
=
' '
:
show
block
showBranch
block
@
Block
{}
=
' '
:
show
block
showBranch
stmt
=
'
\n
'
:
(
indent
$
show
stmt
)
showBlockedBranch
::
Stmt
->
String
...
...
@@ -129,11 +129,11 @@ showBlockedBranch stmt =
_
->
False
showElseBranch
::
Stmt
->
String
showElseBranch
(
stmt
@
If
{})
=
' '
:
show
stmt
showElseBranch
stmt
@
If
{}
=
' '
:
show
stmt
showElseBranch
stmt
=
showBranch
stmt
showShortBranch
::
Stmt
->
String
showShortBranch
(
stmt
@
Asgn
{})
=
' '
:
show
stmt
showShortBranch
stmt
@
Asgn
{}
=
' '
:
show
stmt
showShortBranch
stmt
=
showBranch
stmt
showCase
::
Case
->
String
...
...
src/Language/SystemVerilog/Parser/Parse.y
View file @
30acc3e3
...
...
@@ -1578,7 +1578,7 @@ caseInsideKW tok kw =
parseError
(
tokenPosition
tok
)
$
"cannot use inside with "
++
show
kw
addMIAttr
::
Attr
->
ModuleItem
->
ModuleItem
addMIAttr
_
(
item
@
(
MIPackageItem
(
Decl
CommentDecl
{})
))
=
item
addMIAttr
_
item
@
(
MIPackageItem
(
Decl
CommentDecl
{}
))
=
item
addMIAttr
attr
item
=
MIAttr
attr
item
missingToken
::
String
->
ParseState
a
...
...
@@ -1646,15 +1646,15 @@ makeTypeOf (Token _ _ pos) expr = (pos, check)
check
sg
[]
=
unexpectedSigning
pos
sg
(
show
typ
)
addMITrace
::
ModuleItem
->
[
ModuleItem
]
->
[
ModuleItem
]
addMITrace
_
items
@
(
MIPackageItem
(
Decl
CommentDecl
{})
:
_
)
=
items
addMITrace
_
items
@
(
MIPackageItem
(
Decl
CommentDecl
{})
:
_
)
=
items
addMITrace
trace
items
=
trace
:
items
addPITrace
::
PackageItem
->
[
PackageItem
]
->
[
PackageItem
]
addPITrace
_
items
@
(
Decl
CommentDecl
{}
:
_
)
=
items
addPITrace
_
items
@
(
Decl
CommentDecl
{}
:
_
)
=
items
addPITrace
trace
items
=
trace
:
items
addCITrace
::
ClassItem
->
[
ClassItem
]
->
[
ClassItem
]
addCITrace
_
items
@
((
_
,
Decl
CommentDecl
{})
:
_
)
=
items
addCITrace
_
items
@
((
_
,
Decl
CommentDecl
{})
:
_
)
=
items
addCITrace
trace
items
=
trace
:
items
makeFor
::
Either
[
Decl
]
[(
LHS
,
Expr
)]
->
Expr
->
[(
LHS
,
AsgnOp
,
Expr
)]
->
Stmt
->
Stmt
...
...
src/Language/SystemVerilog/Parser/ParseDecl.hs
View file @
30acc3e3
...
...
@@ -82,7 +82,7 @@ parseDTsAsPortDecls = parseDTsAsPortDecls' . dropTrailingComma
where
dropTrailingComma
::
[
DeclToken
]
->
[
DeclToken
]
dropTrailingComma
[]
=
[]
dropTrailingComma
[
DTComma
{},
end
@
DTEnd
{}]
=
[
end
]
dropTrailingComma
[
DTComma
{},
end
@
DTEnd
{}]
=
[
end
]
dropTrailingComma
(
tok
:
toks
)
=
tok
:
dropTrailingComma
toks
-- internal parseDTsAsPortDecls after the removal of an optional trailing comma
...
...
@@ -102,7 +102,7 @@ parseDTsAsPortDecls' pieces =
pieces'
=
filter
(
not
.
isAttr
)
pieces
propagateDirections
::
Direction
->
[
Decl
]
->
[
Decl
]
propagateDirections
dir
(
decl
@
(
Variable
_
InterfaceT
{}
_
_
_
)
:
decls
)
=
propagateDirections
dir
(
decl
@
(
Variable
_
InterfaceT
{}
_
_
_
)
:
decls
)
=
decl
:
propagateDirections
dir
decls
propagateDirections
lastDir
(
Variable
currDir
t
x
a
e
:
decls
)
=
decl
:
propagateDirections
dir
decls
...
...
@@ -167,7 +167,7 @@ parseDTsAsModuleItems tokens =
-- internal; attempt to parse an elaboration system task
asElabTask
::
[
DeclToken
]
->
Maybe
ModuleItem
asElabTask
tokens
=
do
DTIdent
_
x
@
(
'$'
:
_
)
<-
return
$
head
tokens
DTIdent
_
x
@
(
'$'
:
_
)
<-
return
$
head
tokens
severity
<-
lookup
x
elabTasks
Just
$
ElabTask
severity
args
where
...
...
@@ -328,7 +328,7 @@ parseDTsAsAsgns tokens =
"unexpected "
++
surprise
++
" in for loop initialization"
shiftIncOrDec
::
[
DeclToken
]
->
[
DeclToken
]
shiftIncOrDec
(
tok
@
(
DTAsgn
_
AsgnOp
{}
_
_
)
:
toks
)
=
shiftIncOrDec
(
tok
@
(
DTAsgn
_
AsgnOp
{}
_
_
)
:
toks
)
=
before
++
tok
:
delim
:
shiftIncOrDec
after
where
(
before
,
delim
:
after
)
=
break
isCommaOrEnd
toks
shiftIncOrDec
[]
=
[]
...
...
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