Rain: added a skeleton pass for recording type names in CompState, and wrote a test for it
This commit is contained in:
parent
d7dc28ce47
commit
bc24ba16b1
|
@ -156,8 +156,20 @@ testUnique2 = testPassWithCheck "testUnique2" exp (uniquifyAndResolveVars orig)
|
|||
(tag2 A.OnlyP m $ tag3 A.Assign DontCare [tag2 A.Variable DontCare (Named "newc" DontCare)] (tag2 A.ExpressionList DontCare [(exprVariable "d")]))
|
||||
check items = assertItemNotEqual "testUnique2: Variable was not made unique" (simpleName "c") (Map.lookup "newc" items)
|
||||
|
||||
assertVarDef :: Data a => String -> CompState -> String -> a -> Assertion
|
||||
assertVarDef prefix state varName varDef
|
||||
= case (Map.lookup varName (csNames state)) of
|
||||
Nothing -> assertFailure $ prefix ++ " variable was not recorded: " ++ varName
|
||||
Just actVarDef -> assertPatternMatch (prefix ++ " variable definition not as expected for " ++ varName) varDef actVarDef
|
||||
|
||||
|
||||
testRecordNames0 :: Test
|
||||
testRecordNames0 = testPassWithStateCheck "testRecordNames0" exp (recordNameTypes orig) (return ()) check
|
||||
where
|
||||
orig = (A.Specification m (simpleName "c") $ A.Declaration m A.Byte)
|
||||
exp = orig
|
||||
check state = assertVarDef "testRecordNames0" state "c" (tag7 A.NameDef DontCare "c" "c" A.VariableName (A.Declaration m A.Byte) A.Original A.Unplaced)
|
||||
|
||||
--Returns the list of tests:
|
||||
tests :: Test
|
||||
tests = TestList
|
||||
|
@ -167,6 +179,7 @@ tests = TestList
|
|||
,testUnique0
|
||||
,testUnique1
|
||||
,testUnique2
|
||||
,testRecordNames0
|
||||
]
|
||||
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ rainPasses = runPasses passes
|
|||
where
|
||||
passes =
|
||||
[ ("Uniquify variable declarations and resolve variable names",uniquifyAndResolveVars)
|
||||
,("Record name types in dictionary",recordNameTypes)
|
||||
,("Convert seqeach/pareach loops into classic replicated SEQ/PAR",transformEach)
|
||||
]
|
||||
|
||||
|
@ -32,6 +33,8 @@ uniquifyAndResolveVars = everywhereM (mkM uniquifyAndResolveVars')
|
|||
replaceNameName :: String -> String -> A.Name -> A.Name
|
||||
replaceNameName find replace n = if (A.nameName n) == find then n {A.nameName = replace} else n
|
||||
|
||||
recordNameTypes :: Data t => t -> PassM t
|
||||
recordNameTypes = return
|
||||
|
||||
|
||||
transformEach :: Data t => t -> PassM t
|
||||
|
|
Loading…
Reference in New Issue
Block a user