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
80d75d2a
Commit
80d75d2a
authored
Feb 21, 2021
by
Zachary Snow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
confine genvar local typing to loops
parent
f84dd701
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
11 deletions
+24
-11
src/Convert/Scoper.hs
+9
-0
src/Convert/TypeOf.hs
+15
-11
No files found.
src/Convert/Scoper.hs
View file @
80d75d2a
...
...
@@ -46,6 +46,8 @@ module Convert.Scoper
,
embedScopes
,
withinProcedure
,
withinProcedureM
,
isLoopVar
,
isLoopVarM
,
lookupLocalIdent
,
lookupLocalIdentM
,
scopeModuleItemT
...
...
@@ -296,6 +298,13 @@ withinProcedureM = gets sProcedure
withinProcedure
::
Scopes
a
->
Bool
withinProcedure
=
sProcedure
isLoopVar
::
Scopes
a
->
Identifier
->
Bool
isLoopVar
scopes
x
=
any
matches
$
sCurrent
scopes
where
matches
=
(
==
x
)
.
tierIndex
isLoopVarM
::
Monad
m
=>
Identifier
->
ScoperT
a
m
Bool
isLoopVarM
=
embedScopes
isLoopVar
evalScoper
::
MapperM
(
Scoper
a
)
Decl
->
MapperM
(
Scoper
a
)
ModuleItem
...
...
src/Convert/TypeOf.hs
View file @
80d75d2a
...
...
@@ -37,7 +37,7 @@ convert = map $ traverseDescriptions $ partScoper
pattern
UnitType
::
Type
pattern
UnitType
=
IntegerVector
TLogic
Unspecified
[]
type
ST
=
Scoper
(
Type
,
Bool
)
type
ST
=
Scoper
Type
-- insert the given declaration into the scope, and convert an TypeOfs within
traverseDeclM
::
Decl
->
ST
Decl
...
...
@@ -72,7 +72,7 @@ traverseDeclM decl = do
insertType
::
Identifier
->
Type
->
ST
()
insertType
ident
typ
=
do
typ'
<-
scopeType
typ
insertElem
ident
(
typ'
,
False
)
insertElem
ident
typ'
-- rewrite an expression so that any identifiers it contains unambiguously refer
-- refer to currently visible declarations so it can be substituted elsewhere
...
...
@@ -82,18 +82,15 @@ scopeExpr expr = do
>>=
traverseExprTypesM
scopeType
details
<-
lookupElemM
expr'
case
details
of
Just
(
accesses
,
_
,
(
_
,
False
)
)
->
return
$
accessesToExpr
accesses
Just
(
accesses
,
_
,
_
)
->
return
$
accessesToExpr
accesses
_
->
return
expr'
scopeType
::
Type
->
ST
Type
scopeType
=
traverseNestedTypesM
$
traverseTypeExprsM
scopeExpr
-- convert TypeOf in a ModuleItem
traverseModuleItemM
::
ModuleItem
->
ST
ModuleItem
traverseModuleItemM
(
Genvar
x
)
=
insertElem
x
(
t
,
True
)
>>
return
(
Genvar
x
)
where
t
=
IntegerAtom
TInteger
Unspecified
traverseModuleItemM
item
=
traverseNodesM
traverseExprM
return
traverseTypeM
traverseLHSM
return
item
traverseModuleItemM
=
traverseNodesM
traverseExprM
return
traverseTypeM
traverseLHSM
return
where
traverseLHSM
=
traverseLHSExprsM
traverseExprM
-- convert TypeOf in a GenItem
...
...
@@ -130,7 +127,8 @@ traverseExprM (Cast (Left t1) expr) = do
traverseExprM
(
Cast
(
Right
(
Ident
x
))
expr
)
=
do
expr'
<-
traverseExprM
expr
details
<-
lookupElemM
x
if
details
==
Nothing
isGenvar
<-
isLoopVarM
x
if
details
==
Nothing
&&
not
isGenvar
then
return
$
Cast
(
Left
$
Alias
x
[]
)
expr'
else
elaborateSizeCast
(
Ident
x
)
expr'
traverseExprM
(
Cast
(
Right
size
)
expr
)
=
do
...
...
@@ -163,8 +161,14 @@ lookupTypeOf :: Expr -> ST Type
lookupTypeOf
expr
=
do
details
<-
lookupElemM
expr
case
details
of
Nothing
->
return
$
TypeOf
expr
Just
(
_
,
replacements
,
(
typ
,
_
))
->
do
Nothing
->
case
expr
of
Ident
x
->
do
isGenvar
<-
isLoopVarM
x
return
$
if
isGenvar
then
IntegerAtom
TInteger
Unspecified
else
TypeOf
expr
_
->
return
$
TypeOf
expr
Just
(
_
,
replacements
,
typ
)
->
do
let
typ'
=
toVarType
typ
return
$
replaceInType
replacements
typ'
where
...
...
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