Changed the occam type-checker and the Rain stuff to be okay with the new step count

This commit is contained in:
Neil Brown 2009-01-28 23:47:36 +00:00
parent 6d7f456791
commit 2c6f624ea3
4 changed files with 14 additions and 12 deletions

View File

@ -733,7 +733,7 @@ inferTypes = occamOnlyPass "Infer types"
doReplicator :: Transform A.Replicator
doReplicator rep
= case rep of
A.For _ _ _ -> inTypeContext (Just A.Int) $ descend rep
A.For _ _ _ _ -> inTypeContext (Just A.Int) $ descend rep
A.ForEach _ _ -> noTypeContext $ descend rep
doAlternative :: Transform A.Alternative
@ -1267,9 +1267,10 @@ checkSpecTypes = checkDepthM doSpecType
checkRetypes m fromT t
checkValAM m am
checkAbbrev m A.ValAbbrev am
doSpecType (A.Rep _ (A.For _ start count))
doSpecType (A.Rep _ (A.For _ start count step))
= do checkExpressionInt start
checkExpressionInt count
checkExpressionInt step
doSpecType (A.Rep _ (A.ForEach _ e))
= do t <- astTypeOf e
checkSequence (findMeta e) t

View File

@ -298,12 +298,13 @@ testOccamTypes = TestList
, testFail 1186 $ A.Input m tim $ A.InputTimerFor m realE
-- Replicators
, testOK 1200 $ testRep i $ A.For m intE intE
, testFail 1201 $ testRep i $ A.For m realE intE
, testFail 1202 $ testRep i $ A.For m intE realE
, testOK 1200 $ testRep i $ A.For m intE intE intE
, testFail 1201 $ testRep i $ A.For m realE intE intE
, testFail 1202 $ testRep i $ A.For m intE realE intE
, testOK 1203 $ testRep i $ A.ForEach m twoIntsE
, testOK 1204 $ testRep i $ A.ForEach m listE
, testFail 1205 $ testRep i $ A.ForEach m intE
, testFail 1206 $ testRep i $ A.For m intE intE realE
-- Choices
, testOK 1300 $ testChoice $ A.Choice m boolE skip

View File

@ -191,7 +191,7 @@ transformEachRange = rainOnlyPass "Convert seqeach/pareach loops over ranges int
= do -- Need to change the stored abbreviation mode to original:
modifyName loopVar $ \nd -> nd { A.ndAbbrevMode = A.Original }
return $ A.Specification mspec loopVar $ A.Rep repMeta $ A.For eachMeta begin
(addOne $ subExprs end begin)
(addOne $ subExprs end begin) (makeConstant eachMeta 1)
doSpec s = return s
-- | A pass that changes all the Rain range constructor expressions into the more general array constructor expressions
@ -209,7 +209,7 @@ transformRangeRep = rainOnlyPass "Convert simple Rain range constructors into mo
= do A.Specification _ rep _ <- makeNonceVariable "rep_constr" m A.Int A.ValAbbrev
let count = addOne $ subExprs end begin
return $ A.ExprConstr m $ A.RepConstr m t rep
(A.For m begin count)
(A.For m begin count $ makeConstant m 1)
(A.ExprVariable m $ A.Variable m rep)
doExpression e = return e

View File

@ -74,7 +74,7 @@ testEachRangePass0 = TestCase $ testPass "testEachRangePass0" exp transformEachR
undefined (intLiteral 0) (intLiteral 9)))))
(A.Only m (makeSimpleAssign "c" "x"))
exp = A.Par m A.PlainPar $ A.Spec m (A.Specification m (simpleName "x")
$ A.Rep m (A.For m (intLiteral 0) (makeRange 0 9)))
$ A.Rep m (A.For m (intLiteral 0) (makeRange 0 9) (intLiteral 1)))
(A.Only m (makeSimpleAssign "c" "x"))
testEachRangePass1 :: Test
@ -86,7 +86,7 @@ testEachRangePass1 = TestCase $ testPass "testEachRangePass1" exp transformEachR
(A.Only m (makeSimpleAssign "c" "x"))
exp = A.Par m A.PlainPar $ A.Spec m (A.Specification m (simpleName "x")
$ A.Rep m (A.For m (intLiteral (-5)) (makeRange (-5)
(-2))))
(-2)) (intLiteral 1)))
(A.Only m (makeSimpleAssign "c" "x"))
testEachRangePass2 :: Test
@ -97,7 +97,7 @@ testEachRangePass2 = TestCase $ testPass "testEachRangePass2" exp transformEachR
(intLiteral 6) (intLiteral 6)))))
(A.Only m (makeSimpleAssign "c" "x"))
exp = A.Seq m $ A.Spec m (A.Specification m (simpleName "x") $ A.Rep m
(A.For m (intLiteral 6) (makeRange 6 6)))
(A.For m (intLiteral 6) (makeRange 6 6) (intLiteral 1)))
(A.Only m (makeSimpleAssign "c" "x"))
testEachRangePass3 :: Test
@ -108,7 +108,7 @@ testEachRangePass3 = TestCase $ testPass "testEachRangePass3" exp transformEachR
(intLiteral 6) (intLiteral 0)))))
(A.Only m (makeSimpleAssign "c" "x"))
exp = A.Seq m $ A.Spec m (A.Specification m (simpleName "x") $ A.Rep m
(A.For m (intLiteral 6) (makeRange 6 0)))
(A.For m (intLiteral 6) (makeRange 6 0) (intLiteral 1)))
(A.Only m (makeSimpleAssign "c" "x"))
@ -357,7 +357,7 @@ testRangeRepPass0 = TestCase $ testPass "testRangeRepPass0" exp transformRangeRe
where
orig = A.ExprConstr m $ A.RangeConstr m A.Byte (intLiteral 0) (intLiteral 1)
exp = tag2 A.ExprConstr DontCare $ mRepConstr A.Byte ("repIndex"@@DontCare)
(mFor (intLiteral 0) (makeRange 0 1))
(mFor (intLiteral 0) (makeRange 0 1) (intLiteral 1))
(tag2 A.ExprVariable DontCare $ tag2 A.Variable DontCare $ "repIndex"@@DontCare)
--TODO consider/test pulling up the definitions of variables involved in return statements in functions