Fixed the expansion of array literals to be more like it used to be

All the usual cgtests now compile and run
This commit is contained in:
Neil Brown 2009-02-02 23:51:57 +00:00
parent 0bffd42cad
commit 502c61b01e

View File

@ -129,7 +129,6 @@ expandArrayLiterals = pass "Expand array literals"
doArrayElem ae@(A.Only _ e) doArrayElem ae@(A.Only _ e)
= do t <- astTypeOf e = do t <- astTypeOf e
case (t, e) of case (t, e) of
(A.Array {}, A.Literal {}) -> return ae
(A.Array ds _, _) -> expand ds e (A.Array ds _, _) -> expand ds e
_ -> return ae _ -> return ae
doArrayElem ae = return ae doArrayElem ae = return ae
@ -141,7 +140,10 @@ expandArrayLiterals = pass "Expand array literals"
expand (A.Dimension n:ds) e expand (A.Dimension n:ds) e
= do -- Because it's an array literal, we must know the size. = do -- Because it's an array literal, we must know the size.
size <- evalIntExpression n 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 $ (A.Subscript m A.NoCheck $
makeConstant m i) e) makeConstant m i) e)
| i <- [0 .. size - 1]] | i <- [0 .. size - 1]]