Renamed the transformFunction pass into checkFunction, and adjusted the tests for it accordingly

This commit is contained in:
Neil Brown 2008-02-25 21:17:37 +00:00
parent 74838bcb80
commit dcf419744a
2 changed files with 15 additions and 19 deletions

View File

@ -35,6 +35,7 @@ import RainTypes
import TreeUtils
import Types
--TODO change this whole module to stop using everywhere
-- | An ordered list of the Rain-specific passes to be run.
rainPasses :: [Pass]
@ -60,7 +61,8 @@ rainPasses = makePassesDep' ((== FrontendRain) . csFrontend)
,("Convert seqeach/pareach loops over ranges into simple replicated SEQ/PAR",transformEachRange, typesDone, [Prop.eachRangeTransformed])
,("Convert seqeach/pareach loops into classic replicated SEQ/PAR",transformEach, typesDone ++ [Prop.eachRangeTransformed], [Prop.eachTransformed])
,("Convert simple Rain range constructors into more general array constructors",transformRangeRep, typesDone ++ [Prop.eachRangeTransformed], [Prop.rangeTransformed])
,("Transform Rain functions into the occam form",transformFunction, typesDone ++ [Prop.eachTransformed], []) -- TODO need to sort out functions anyway
,("Transform Rain functions into the occam form",checkFunction, typesDone ++ [Prop.eachTransformed], [])
--TODO add an export property. Maybe check other things too (lack of comms etc -- but that could be combined with occam?)
,("Pull up par declarations", pullUpParDeclarations, [], [Prop.rainParDeclarationsPulledUp])
]
where
@ -250,8 +252,8 @@ transformRangeRep = everywhereM (mkM transformRangeRep')
) (A.ExprVariable m $ A.Variable m rep)
transformRangeRep' s = return s
transformFunction :: Data t => t -> PassM t
transformFunction = return {- TODO handle functions again everywhereM (mkM transformFunction')
checkFunction :: Data t => t -> PassM t
checkFunction = return {- everywhereM (mkM transformFunction')
where
transformFunction' :: A.SpecType -> PassM A.SpecType
transformFunction' (A.Function m specMode types params body)

View File

@ -478,27 +478,22 @@ testRangeRepPass1 = TestCase $ testPassShouldFail "testRangeRepPass1" (transform
--TODO consider/test pulling up the definitions of variables involved in return statements in functions
{-
-- | Test a fairly standard function:
testTransformFunction0 :: Test
testTransformFunction0 = TestCase $ testPass "testTransformFunction0" exp (transformFunction orig) (return ())
testCheckFunction0 :: Test
testCheckFunction0 = TestCase $ testPass "testCheckFunction0" orig (checkFunction orig) (return ())
where
orig = A.Specification m (procName "id") $
A.Function m A.PlainSpec [A.Byte] [A.Formal A.ValAbbrev A.Byte (simpleName "x")] $
(A.Only m $ A.Seq m $ A.Several m [A.Only m $ A.ExpressionList m [exprVariable "x"]])
exp = tag3 A.Specification DontCare (procNamePattern "id") $
tag5 A.Function DontCare A.PlainSpec [A.Byte] [tag3 A.Formal A.ValAbbrev A.Byte (simpleNamePattern "x")] $
tag3 A.ProcThen DontCare (tag2 A.Seq DontCare $ mSeveralP DontCare []) $
mOnlyEL $ tag2 A.ExpressionList DontCare [exprVariablePattern "x"]
A.Function m A.PlainSpec [A.Byte] [A.Formal A.ValAbbrev A.Byte (simpleName "x")] $ Right
(A.Seq m $ A.Several m [A.Only m $ A.Assign m [variable "id"] $ A.ExpressionList m [exprVariable "x"]])
-- | Test a function without a return as the final statement:
testTransformFunction1 :: Test
testTransformFunction1 = TestCase $ testPassShouldFail "testTransformFunction1" (transformFunction orig) (return ())
testCheckFunction1 :: Test
testCheckFunction1 = TestCase $ testPassShouldFail "testCheckunction1" (checkFunction orig) (return ())
where
orig = A.Specification m (procName "brokenid") $
A.Function m A.PlainSpec [A.Byte] [A.Formal A.ValAbbrev A.Byte (simpleName "x")] $
(A.Only m $ A.Seq m $ A.Several m [])
-}
(Right $ A.Seq m $ A.Several m [])
testPullUpParDecl0 :: Test
testPullUpParDecl0 = TestCase $ testPass "testPullUpParDecl0" orig (pullUpParDeclarations orig) (return ())
where
@ -556,9 +551,8 @@ tests = TestLabel "RainPassesTest" $ TestList
,testParamPass8
,testRangeRepPass0
,testRangeRepPass1
-- TODO get functions working again
-- ,testTransformFunction0
-- ,testTransformFunction1
,testCheckFunction0
,testCheckFunction1
,testPullUpParDecl0
,testPullUpParDecl1
,testPullUpParDecl2