Corrected the pass that creates abbreviations for output expressions to also work on OutputCase statements

This commit is contained in:
Neil Brown 2007-10-13 20:52:42 +00:00
parent ffe8477237
commit 443b648d73
2 changed files with 28 additions and 1 deletions

View File

@ -219,6 +219,29 @@ testOutExprs = TestList
(defineName (xName) $ simpleDefDecl "x" A.Byte)
(checkTempVarTypes "testOutExprs 3" [("temp_var", A.Byte)])
-- Test that OutputCase is also processed:
,TestCase $ testPassWithItemsStateCheck "testOutExprs 4"
(tag2 A.Seq DontCare $ (abbr "temp_var" A.Int (eXM 1))
(tag2 A.OnlyP DontCare $ tag4 A.OutputCase emptyMeta chan (simpleName "foo")
[tag2 A.OutExpression emptyMeta (tag2 A.ExprVariable DontCare (tag2 A.Variable DontCare (Named "temp_var" DontCare)))])
)
(outExprs $
A.OutputCase emptyMeta chan (simpleName "foo") [outXM 1]
)
(defineName (xName) $ simpleDefDecl "x" A.Int)
(checkTempVarTypes "testOutExprs 3" [("temp_var", A.Int)])
-- Test that an empty outputcase works okay:
,TestCase $ testPass "testOutExprs 5"
(tag2 A.Seq DontCare $
(tag2 A.OnlyP DontCare $ A.OutputCase emptyMeta chan (simpleName "foo") [])
)
(outExprs $
A.OutputCase emptyMeta chan (simpleName "foo") []
)
(return ())
]
where
outX = A.OutExpression emptyMeta $ exprVariable "x"

View File

@ -44,8 +44,12 @@ outExprs = doGeneric `extM` doProcess
doProcess :: A.Process -> PassM A.Process
doProcess (A.Output m c ois)
= do (ois', specs) <- mapAndUnzipM changeItem ois
let foldedSpec = foldl1 (.) specs
let foldedSpec = foldl (.) id specs
return $ A.Seq m (foldedSpec $ A.OnlyP m $ A.Output m c ois')
doProcess (A.OutputCase m c tag ois)
= do (ois', specs) <- mapAndUnzipM changeItem ois
let foldedSpec = foldl (.) id specs
return $ A.Seq m (foldedSpec $ A.OnlyP m $ A.OutputCase m c tag ois')
doProcess p = doGeneric p
changeItem :: A.OutputItem -> PassM (A.OutputItem, A.Structured -> A.Structured)