Changed the occam type-checker and the Rain stuff to be okay with the new step count
This commit is contained in:
parent
6d7f456791
commit
2c6f624ea3
|
@ -733,7 +733,7 @@ inferTypes = occamOnlyPass "Infer types"
|
||||||
doReplicator :: Transform A.Replicator
|
doReplicator :: Transform A.Replicator
|
||||||
doReplicator rep
|
doReplicator rep
|
||||||
= case rep of
|
= case rep of
|
||||||
A.For _ _ _ -> inTypeContext (Just A.Int) $ descend rep
|
A.For _ _ _ _ -> inTypeContext (Just A.Int) $ descend rep
|
||||||
A.ForEach _ _ -> noTypeContext $ descend rep
|
A.ForEach _ _ -> noTypeContext $ descend rep
|
||||||
|
|
||||||
doAlternative :: Transform A.Alternative
|
doAlternative :: Transform A.Alternative
|
||||||
|
@ -1267,9 +1267,10 @@ checkSpecTypes = checkDepthM doSpecType
|
||||||
checkRetypes m fromT t
|
checkRetypes m fromT t
|
||||||
checkValAM m am
|
checkValAM m am
|
||||||
checkAbbrev m A.ValAbbrev am
|
checkAbbrev m A.ValAbbrev am
|
||||||
doSpecType (A.Rep _ (A.For _ start count))
|
doSpecType (A.Rep _ (A.For _ start count step))
|
||||||
= do checkExpressionInt start
|
= do checkExpressionInt start
|
||||||
checkExpressionInt count
|
checkExpressionInt count
|
||||||
|
checkExpressionInt step
|
||||||
doSpecType (A.Rep _ (A.ForEach _ e))
|
doSpecType (A.Rep _ (A.ForEach _ e))
|
||||||
= do t <- astTypeOf e
|
= do t <- astTypeOf e
|
||||||
checkSequence (findMeta e) t
|
checkSequence (findMeta e) t
|
||||||
|
|
|
@ -298,12 +298,13 @@ testOccamTypes = TestList
|
||||||
, testFail 1186 $ A.Input m tim $ A.InputTimerFor m realE
|
, testFail 1186 $ A.Input m tim $ A.InputTimerFor m realE
|
||||||
|
|
||||||
-- Replicators
|
-- Replicators
|
||||||
, testOK 1200 $ testRep i $ A.For m intE intE
|
, testOK 1200 $ testRep i $ A.For m intE intE intE
|
||||||
, testFail 1201 $ testRep i $ A.For m realE intE
|
, testFail 1201 $ testRep i $ A.For m realE intE intE
|
||||||
, testFail 1202 $ testRep i $ A.For m intE realE
|
, testFail 1202 $ testRep i $ A.For m intE realE intE
|
||||||
, testOK 1203 $ testRep i $ A.ForEach m twoIntsE
|
, testOK 1203 $ testRep i $ A.ForEach m twoIntsE
|
||||||
, testOK 1204 $ testRep i $ A.ForEach m listE
|
, testOK 1204 $ testRep i $ A.ForEach m listE
|
||||||
, testFail 1205 $ testRep i $ A.ForEach m intE
|
, testFail 1205 $ testRep i $ A.ForEach m intE
|
||||||
|
, testFail 1206 $ testRep i $ A.For m intE intE realE
|
||||||
|
|
||||||
-- Choices
|
-- Choices
|
||||||
, testOK 1300 $ testChoice $ A.Choice m boolE skip
|
, testOK 1300 $ testChoice $ A.Choice m boolE skip
|
||||||
|
|
|
@ -191,7 +191,7 @@ transformEachRange = rainOnlyPass "Convert seqeach/pareach loops over ranges int
|
||||||
= do -- Need to change the stored abbreviation mode to original:
|
= do -- Need to change the stored abbreviation mode to original:
|
||||||
modifyName loopVar $ \nd -> nd { A.ndAbbrevMode = A.Original }
|
modifyName loopVar $ \nd -> nd { A.ndAbbrevMode = A.Original }
|
||||||
return $ A.Specification mspec loopVar $ A.Rep repMeta $ A.For eachMeta begin
|
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
|
doSpec s = return s
|
||||||
|
|
||||||
-- | A pass that changes all the Rain range constructor expressions into the more general array constructor expressions
|
-- | 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
|
= do A.Specification _ rep _ <- makeNonceVariable "rep_constr" m A.Int A.ValAbbrev
|
||||||
let count = addOne $ subExprs end begin
|
let count = addOne $ subExprs end begin
|
||||||
return $ A.ExprConstr m $ A.RepConstr m t rep
|
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)
|
(A.ExprVariable m $ A.Variable m rep)
|
||||||
doExpression e = return e
|
doExpression e = return e
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@ testEachRangePass0 = TestCase $ testPass "testEachRangePass0" exp transformEachR
|
||||||
undefined (intLiteral 0) (intLiteral 9)))))
|
undefined (intLiteral 0) (intLiteral 9)))))
|
||||||
(A.Only m (makeSimpleAssign "c" "x"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
exp = A.Par m A.PlainPar $ A.Spec m (A.Specification m (simpleName "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"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
|
|
||||||
testEachRangePass1 :: Test
|
testEachRangePass1 :: Test
|
||||||
|
@ -86,7 +86,7 @@ testEachRangePass1 = TestCase $ testPass "testEachRangePass1" exp transformEachR
|
||||||
(A.Only m (makeSimpleAssign "c" "x"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
exp = A.Par m A.PlainPar $ A.Spec m (A.Specification m (simpleName "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)
|
$ A.Rep m (A.For m (intLiteral (-5)) (makeRange (-5)
|
||||||
(-2))))
|
(-2)) (intLiteral 1)))
|
||||||
(A.Only m (makeSimpleAssign "c" "x"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
|
|
||||||
testEachRangePass2 :: Test
|
testEachRangePass2 :: Test
|
||||||
|
@ -97,7 +97,7 @@ testEachRangePass2 = TestCase $ testPass "testEachRangePass2" exp transformEachR
|
||||||
(intLiteral 6) (intLiteral 6)))))
|
(intLiteral 6) (intLiteral 6)))))
|
||||||
(A.Only m (makeSimpleAssign "c" "x"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
exp = A.Seq m $ A.Spec m (A.Specification m (simpleName "x") $ A.Rep m
|
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"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
|
|
||||||
testEachRangePass3 :: Test
|
testEachRangePass3 :: Test
|
||||||
|
@ -108,7 +108,7 @@ testEachRangePass3 = TestCase $ testPass "testEachRangePass3" exp transformEachR
|
||||||
(intLiteral 6) (intLiteral 0)))))
|
(intLiteral 6) (intLiteral 0)))))
|
||||||
(A.Only m (makeSimpleAssign "c" "x"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
exp = A.Seq m $ A.Spec m (A.Specification m (simpleName "x") $ A.Rep m
|
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"))
|
(A.Only m (makeSimpleAssign "c" "x"))
|
||||||
|
|
||||||
|
|
||||||
|
@ -357,7 +357,7 @@ testRangeRepPass0 = TestCase $ testPass "testRangeRepPass0" exp transformRangeRe
|
||||||
where
|
where
|
||||||
orig = A.ExprConstr m $ A.RangeConstr m A.Byte (intLiteral 0) (intLiteral 1)
|
orig = A.ExprConstr m $ A.RangeConstr m A.Byte (intLiteral 0) (intLiteral 1)
|
||||||
exp = tag2 A.ExprConstr DontCare $ mRepConstr A.Byte ("repIndex"@@DontCare)
|
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)
|
(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
|
--TODO consider/test pulling up the definitions of variables involved in return statements in functions
|
||||||
|
|
Loading…
Reference in New Issue
Block a user