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
9af38e78
Commit
9af38e78
authored
Feb 16, 2020
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
globally imported items are selectively nested
parent
29b51365
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
src/Convert/NestPI.hs
+2
-6
src/Convert/Package.hs
+13
-4
test/basic/unused_imports.sv
+8
-0
test/basic/unused_imports.v
+4
-0
No files found.
src/Convert/NestPI.hs
View file @
9af38e78
...
...
@@ -31,6 +31,7 @@ convert =
(
traverseDescriptions
.
convertDescription
)
curr
isPI
::
Description
->
Bool
isPI
(
PackageItem
Import
{})
=
False
isPI
(
PackageItem
item
)
=
piName
item
/=
Nothing
isPI
_
=
False
...
...
@@ -55,8 +56,7 @@ convertDescription pis (orig @ Part{}) =
,
collectTypesM
$
collectNestedTypesM
collectTypenamesM
,
collectExprsM
$
collectNestedExprsM
collectIdentsM
]
neededPIs
=
Set
.
difference
(
Set
.
union
usedPIs
imports
)
existingPIs
imports
=
Map
.
keysSet
$
Map
.
filter
isImport
pis
neededPIs
=
Set
.
difference
usedPIs
existingPIs
newItems
=
map
MIPackageItem
$
Map
.
elems
$
Map
.
restrictKeys
pis
neededPIs
-- place data declarations at the beginning to obey declaration
...
...
@@ -104,7 +104,3 @@ piName (Decl (CommentDecl _)) = Nothing
piName
(
Import
x
y
)
=
Just
$
show
$
Import
x
y
piName
(
Export
_
)
=
Nothing
piName
(
Directive
_
)
=
Nothing
isImport
::
PackageItem
->
Bool
isImport
Import
{}
=
True
isImport
_
=
False
src/Convert/Package.hs
View file @
9af38e78
...
...
@@ -53,7 +53,7 @@ convertFile :: Packages -> AST -> AST
convertFile
packages
ast
=
(
++
)
globalItems
$
filter
(
not
.
isCollected
)
$
traverseDescriptions
(
traverseDescription
packages
)
$
concatMap
(
traverseDescription
packages
)
$
ast
where
globalItems
=
map
PackageItem
$
...
...
@@ -127,11 +127,20 @@ collectDescriptionM (Package _ name items) =
isImport
_
=
False
collectDescriptionM
_
=
return
()
traverseDescription
::
Packages
->
Description
->
Description
traverseDescription
::
Packages
->
Description
->
[
Description
]
traverseDescription
packages
(
PackageItem
(
Import
x
y
))
=
map
(
\
(
MIPackageItem
item
)
->
PackageItem
item
)
items
where
orig
=
Part
[]
False
Module
Inherit
"DNE"
[]
[
MIPackageItem
$
Import
x
y
]
[
orig'
]
=
traverseDescription
packages
orig
Part
[]
False
Module
Inherit
"DNE"
[]
items
=
orig'
traverseDescription
packages
description
=
traverseModuleItems
(
traverseModuleItem
existingItemNames
packages
)
description
[
description'
]
where
description'
=
traverseModuleItems
(
traverseModuleItem
existingItemNames
packages
)
description
existingItemNames
=
execWriter
$
collectModuleItemsM
writePIName
description
writePIName
::
ModuleItem
->
Writer
Idents
()
...
...
test/basic/unused_imports.sv
0 → 100644
View file @
9af38e78
package
P
;
localparam
FOO
=
1
;
localparam
BAR
=
2
;
endpackage
import
P
::*;
module
top
;
initial
$
display
(
FOO
)
;
endmodule
test/basic/unused_imports.v
0 → 100644
View file @
9af38e78
module
top
;
localparam
FOO
=
1
;
initial
$
display
(
FOO
)
;
endmodule
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