Altered transformConstr to handle array constructors with types in them

This commit is contained in:
Neil Brown 2008-03-19 13:23:20 +00:00
parent a930e17f89
commit cb819d142a

View File

@ -205,14 +205,11 @@ transformConstr = doGeneric `ext1M` doStructured
-- indexvar := indexvar + 1
-- ...
doStructured :: Data a => A.Structured a -> PassM (A.Structured a)
doStructured (A.Spec m (A.Specification m' n (A.IsExpr _ _ _ expr@(A.ExprConstr m'' (A.RepConstr _ rep exp)))) scope)
doStructured (A.Spec m (A.Specification m' n (A.IsExpr _ _ _ expr@(A.ExprConstr m'' (A.RepConstr _ t rep exp)))) scope)
= do indexVarSpec@(A.Specification _ indexName _) <- makeNonceVariable "array_constr_index" m'' A.Int A.VariableName A.Original
let indexVar = A.Variable m'' indexName
scope' <- doGeneric scope
-- Recompute the type, in order to get the array dimension into it.
t <- typeOfExpression expr
return $ A.Spec m (A.Specification m' n (A.Declaration m' t)) $ A.ProcThen m''
(A.Seq m'' $ A.Spec m'' indexVarSpec $ A.Several m'' [
A.Only m'' $ A.Assign m'' [indexVar] $ A.ExpressionList m'' [A.Literal m'' A.Int $ A.IntLiteral m'' "0"],