From 48fbf5f3e17a9e9bedcdff558ca90603887f61ed Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Tue, 20 May 2008 23:44:07 +0000 Subject: [PATCH] Added pulling up of list literals and list-constructed expressions --- transformations/SimplifyExprs.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/transformations/SimplifyExprs.hs b/transformations/SimplifyExprs.hs index c8e392d..866d5fa 100644 --- a/transformations/SimplifyExprs.hs +++ b/transformations/SimplifyExprs.hs @@ -336,8 +336,10 @@ pullUp pullUpArraysInsideRecords doLiteralRepr lr = doGeneric lr -- | Pull array expressions that aren't already non-subscripted variables. + -- Also pull lists that are literals or constructed doExpression :: A.Expression -> PassM A.Expression doExpression e + -- This part handles recursing into the expression first: = do e' <- doExpression' e t <- astTypeOf e' case t of @@ -347,6 +349,11 @@ pullUp pullUpArraysInsideRecords A.ExprVariable _ (A.DirectedVariable _ _ _) -> return e' --TODO work out whether to pull up DerefVariable _ -> pull t e' + A.List _ -> + case e' of + A.ExprConstr {} -> pull t e' + A.Literal {} -> pull t e' + _ -> return e' _ -> return e' where pull :: A.Type -> A.Expression -> PassM A.Expression