From 502c61b01eb1c9b41c8931b58f63b6eb049d68db Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 2 Feb 2009 23:51:57 +0000 Subject: [PATCH] Fixed the expansion of array literals to be more like it used to be All the usual cgtests now compile and run --- transformations/SimplifyExprs.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/transformations/SimplifyExprs.hs b/transformations/SimplifyExprs.hs index 3f753ee..fc1d139 100644 --- a/transformations/SimplifyExprs.hs +++ b/transformations/SimplifyExprs.hs @@ -129,7 +129,6 @@ expandArrayLiterals = pass "Expand array literals" doArrayElem ae@(A.Only _ e) = do t <- astTypeOf e case (t, e) of - (A.Array {}, A.Literal {}) -> return ae (A.Array ds _, _) -> expand ds e _ -> return ae doArrayElem ae = return ae @@ -141,7 +140,10 @@ expandArrayLiterals = pass "Expand array literals" expand (A.Dimension n:ds) e = do -- Because it's an array literal, we must know the size. size <- evalIntExpression n - elems <- sequence [expand ds (A.SubscriptedExpr m + elems <- sequence [case e of + A.Literal _ _ (A.ArrayListLiteral _ (A.Several _ ls)) -> + return $ ls !! i + _ -> expand ds (A.SubscriptedExpr m (A.Subscript m A.NoCheck $ makeConstant m i) e) | i <- [0 .. size - 1]]