Changed the constant folder to fold RetypesExpr

This commit is contained in:
Neil Brown 2009-03-26 18:38:53 +00:00
parent bd2dfe3d2a
commit 86bbdc8b8e

View File

@ -122,6 +122,14 @@ foldConstants = occamOnlyPass "Fold constants"
-- (Even if it isn't an expression itself, it might have others inside it,
-- so we just update them all.)
doSpecification :: A.Specification -> PassM A.Specification
doSpecification spec@(A.Specification m n (A.RetypesExpr _ _ t _))
= do e <- getConstantName n
case e of
Just e' ->
let newSpec = A.Is m A.ValAbbrev t (A.ActualExpression e') in
do modifyName n $ \nd -> nd { A.ndSpecType = newSpec }
return $ A.Specification m n newSpec
Nothing -> return spec
doSpecification s@(A.Specification _ n st)
= do modifyName n (\nd -> nd { A.ndSpecType = st })
return s