Expression retyping

This commit is contained in:
Adam Sampson 2007-04-29 17:22:13 +00:00
parent 2be9b16cc7
commit d2c522bec0
3 changed files with 11 additions and 2 deletions

View File

@ -896,7 +896,7 @@ introduceSpec (A.Specification _ n (A.Proc _ fs p))
tell ["}\n"]
introduceSpec (A.Specification _ n (A.Retypes _ am t v))
= do origT <- typeOfVariable v
let (rhs, rhsSizes) = abbrevVariable am origT v
let (rhs, rhsSizes) = abbrevVariable A.Abbrev origT v
genDecl am t n
tell [" = ("]
genDeclType am t

View File

@ -105,7 +105,8 @@ pullUp = doGeneric `extM` doStructured `extM` doProcess `extM` doSpecification `
popPullContext
return p''
-- | *Don't* pull anything that's already an abbreviation.
-- | *Don't* pull anything that's already an abbreviation -- but do convert
-- RetypesExpr into Retypes (of a variable).
doSpecification :: A.Specification -> PassM A.Specification
doSpecification (A.Specification m n (A.Is m' am t v))
= do v' <- doGeneric v -- note doGeneric rather than pullUp
@ -113,6 +114,12 @@ pullUp = doGeneric `extM` doStructured `extM` doProcess `extM` doSpecification `
doSpecification (A.Specification m n (A.IsExpr m' am t e))
= do e' <- doGeneric e -- note doGeneric rather than pullUp
return $ A.Specification m n (A.IsExpr m' am t e')
doSpecification (A.Specification m n (A.RetypesExpr m' am toT e))
= do e' <- doExpression e
fromT <- typeOfExpression e'
spec@(A.Specification _ n' _) <- makeNonceIsExpr "retypes_expr" m' fromT e'
addPulled $ A.Spec m' spec
return $ A.Specification m n (A.Retypes m' am toT (A.Variable m' n'))
doSpecification s = doGeneric s
-- | Pull array expressions that aren't already non-subscripted variables.

View File

@ -71,6 +71,8 @@ time.
Real-to-integer conversions don't work correctly.
Slice checks should not be generated if the slice is known to be safe.
## Long-term
If we have constant folding, we're three-quarters of the way towards having an