Rain: corrected the transformation of foreach loops to use ValAbbrev when looping over an expression
This commit is contained in:
parent
9e8dd73149
commit
d90f0aa680
|
@ -74,7 +74,8 @@ testEachPass0 = testPassWithItemsStateCheck "testEachPass0" exp (transformEach o
|
||||||
(tag4 A.For DontCare indexVar (intLiteral 0) (tag2 A.SizeVariable DontCare listVar))
|
(tag4 A.For DontCare indexVar (intLiteral 0) (tag2 A.SizeVariable DontCare listVar))
|
||||||
(tag3 A.Spec DontCare
|
(tag3 A.Spec DontCare
|
||||||
(tag3 A.Specification DontCare (simpleName "c")
|
(tag3 A.Specification DontCare (simpleName "c")
|
||||||
(tag4 A.Is DontCare A.Abbrev A.Byte
|
--ValAbbrev because we are abbreviating an expression:
|
||||||
|
(tag4 A.Is DontCare A.ValAbbrev A.Byte
|
||||||
(tag3 A.SubscriptedVariable DontCare
|
(tag3 A.SubscriptedVariable DontCare
|
||||||
(tag2 A.Subscript DontCare (tag2 A.ExprVariable DontCare (tag2 A.Variable DontCare indexVar)))
|
(tag2 A.Subscript DontCare (tag2 A.ExprVariable DontCare (tag2 A.Variable DontCare indexVar)))
|
||||||
listVar
|
listVar
|
||||||
|
|
|
@ -135,11 +135,11 @@ transformEach = everywhereM (mkM transformEach')
|
||||||
where
|
where
|
||||||
transformEach' :: A.Structured -> PassM A.Structured
|
transformEach' :: A.Structured -> PassM A.Structured
|
||||||
transformEach' (A.Rep m (A.ForEach m' loopVar loopExp) s)
|
transformEach' (A.Rep m (A.ForEach m' loopVar loopExp) s)
|
||||||
= do (spec,var) <- case loopExp of
|
= do (spec,var,am) <- case loopExp of
|
||||||
(A.ExprVariable _ v) -> return (id,v)
|
(A.ExprVariable _ v) -> return (id,v,A.Abbrev)
|
||||||
_ -> do t <- typeOfExpression loopExp
|
_ -> do t <- typeOfExpression loopExp
|
||||||
spec@(A.Specification _ n' _) <- makeNonceIsExpr "loopVar" m t loopExp
|
spec@(A.Specification _ n' _) <- makeNonceIsExpr "loopVar" m t loopExp
|
||||||
return (A.Spec m spec,A.Variable m n')
|
return (A.Spec m spec,A.Variable m n',A.ValAbbrev)
|
||||||
--spec is a function A.Structured -> A.Structured, var is an A.Variable
|
--spec is a function A.Structured -> A.Structured, var is an A.Variable
|
||||||
|
|
||||||
loopVarType <- typeOfName loopVar
|
loopVarType <- typeOfName loopVar
|
||||||
|
@ -148,7 +148,7 @@ transformEach = everywhereM (mkM transformEach')
|
||||||
let newRep = A.For m' loopIndexName (intLiteral 0) (A.SizeVariable m' var)
|
let newRep = A.For m' loopIndexName (intLiteral 0) (A.SizeVariable m' var)
|
||||||
let s' = A.Spec m'
|
let s' = A.Spec m'
|
||||||
(A.Specification m' loopVar
|
(A.Specification m' loopVar
|
||||||
(A.Is m' A.Abbrev loopVarType
|
(A.Is m' am loopVarType
|
||||||
(A.SubscriptedVariable m' (A.Subscript m' (A.ExprVariable m' (A.Variable m' loopIndexName))) var)
|
(A.SubscriptedVariable m' (A.Subscript m' (A.ExprVariable m' (A.Variable m' loopIndexName))) var)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user