Converted one of the tests for pullRepCounts to use the new mechanism, which in turn exposed that the pass was not altering the definition in the state (which it may as well)
This commit is contained in:
parent
771297632d
commit
bfacb526fb
|
@ -19,7 +19,9 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
-- | The necessary components for using an occam EDSL (for building test-cases).
|
||||
module OccamEDSL (ExpInp, ExpInpT, oSEQ, oPAR, oPROC, oSKIP, oINT,
|
||||
oCASE, oCASEinput, oALT, guard,
|
||||
Occ, oA, oB, oC, oX, oY, oZ, p0, p1, p2, (*?), (*!), (*:=), decl, decl', oempty, testOccamPass,
|
||||
Occ, oA, oB, oC, oX, oY, oZ, p0, p1, p2, (*?), (*!), (*:=), decl, decl', decl'',
|
||||
oempty, testOccamPass,
|
||||
oprocess,
|
||||
testOccamPassTransform, ExpInpC(shouldComeFrom),
|
||||
caseOption, inputCaseOption,
|
||||
becomes) where
|
||||
|
@ -273,6 +275,14 @@ decl' n sp scope = do
|
|||
return $ A.Spec emptyMeta (A.Specification emptyMeta n sp)
|
||||
(singlify $ A.Several emptyMeta s)
|
||||
|
||||
decl'' :: Data a => A.Name -> A.SpecType -> A.AbbrevMode ->
|
||||
[O (A.Structured a)] -> O (A.Structured a)
|
||||
decl'' n sp am scope = do
|
||||
defineThing (A.nameName n) sp am
|
||||
s <- sequence scope
|
||||
return $ A.Spec emptyMeta (A.Specification emptyMeta n sp)
|
||||
(singlify $ A.Several emptyMeta s)
|
||||
|
||||
|
||||
-- | A type-class to finesse the difference between components of expressions (such
|
||||
-- as variables, literals) and actual expressions
|
||||
|
@ -309,6 +319,9 @@ instance CanBeInput A.InputMode where
|
|||
oempty :: Data a => O (A.Structured a)
|
||||
oempty = return $ A.Several emptyMeta []
|
||||
|
||||
oprocess :: O (A.Structured A.Process) -> O (A.Structured A.Process)
|
||||
oprocess = id
|
||||
|
||||
testOccamPass :: Data a => String -> O a -> Pass -> Test
|
||||
testOccamPass str code pass
|
||||
= let ExpInpT expm inpm = code
|
||||
|
|
|
@ -571,6 +571,23 @@ testPullRepCounts = TestList
|
|||
,testUnchanged 3 $ A.Alt emptyMeta True
|
||||
,testUnchanged 4 $ A.If emptyMeta
|
||||
|
||||
,testOccamPassTransform "testPullRepCounts 5" (nameAndStopCaringPattern "nonce" "A")
|
||||
(oprocess $ oSEQ
|
||||
[decl' (simpleName "X")
|
||||
(A.Rep emptyMeta (A.For emptyMeta (intLiteral 0) (intLiteral 6)))
|
||||
[]
|
||||
]
|
||||
`becomes`
|
||||
oSEQ
|
||||
[decl'' (simpleName "A")
|
||||
(A.IsExpr emptyMeta A.ValAbbrev A.Int $ intLiteral 6) A.ValAbbrev
|
||||
[decl' (simpleName "X")
|
||||
(A.Rep emptyMeta (A.For emptyMeta (intLiteral 0) (exprVariable "A")))
|
||||
[]
|
||||
]
|
||||
]
|
||||
) pullRepCounts
|
||||
|
||||
,TestCase $ testPass "testPullRepCounts 5"
|
||||
(nameAndStopCaringPattern "nonce" "nonce" $ mkPattern $ A.Seq emptyMeta $
|
||||
A.Spec emptyMeta (A.Specification emptyMeta (simpleName "nonce") (A.IsExpr emptyMeta A.ValAbbrev A.Int $ intLiteral 6)) $
|
||||
|
|
|
@ -174,9 +174,10 @@ pullRepCounts = pass "Pull up replicator counts for SEQs"
|
|||
= do t <- astTypeOf for
|
||||
spec@(A.Specification _ nonceName _) <- makeNonceIsExpr "rep_for" mspec t for
|
||||
scope' <- pullRepCountSeq scope
|
||||
let newSpec = (A.Rep mrep (A.For mfor from (A.ExprVariable mspec $ A.Variable mspec nonceName)))
|
||||
modifyName n $ \nd -> nd { A.ndSpecType = newSpec }
|
||||
return $ A.Spec mspec spec $
|
||||
A.Spec m (A.Specification mspec n (A.Rep mrep
|
||||
(A.For mfor from (A.ExprVariable mspec $ A.Variable mspec nonceName)))) scope'
|
||||
A.Spec m (A.Specification mspec n newSpec) scope'
|
||||
pullRepCountSeq (A.Spec m sp str)
|
||||
= do str' <- pullRepCountSeq str
|
||||
return $ A.Spec m sp str'
|
||||
|
|
Loading…
Reference in New Issue
Block a user