Stopped the expansion of inner array literals into subscripted elements

This expansion was causing a big blow-up in the code, as things like:

VAL [2][1]INT as IS [[0,1]]

were getting transformed into:

VAL [2]INT n0 IS [0,1]:
VAL [2]INT n1 IS [0,1]:
VAL [2]INT n2 IS [n0[0], n1[1]]:
VAL [2][1]INT as IS [n2]:

Or something similar -- the inner arrays were pulled up into multiple definitions that were then subscripted, because the first pull-up did this:

VAL [2]INT n2 IS [[0,1][0], [0,1][1]]:

and then the inner arrays got pulled up again, separately.  The change hasn't immediately broken anything, but I haven't fully tested it yet
This commit is contained in:
Neil Brown 2009-02-02 17:30:39 +00:00
parent 40b9a8b76b
commit 88d6136dcf

View File

@ -128,8 +128,9 @@ expandArrayLiterals = pass "Expand array literals"
doArrayElem :: A.Structured A.Expression -> PassM (A.Structured A.Expression)
doArrayElem ae@(A.Only _ e)
= do t <- astTypeOf e
case t of
A.Array ds _ -> expand ds e
case (t, e) of
(A.Array {}, A.Literal {}) -> return ae
(A.Array ds _, _) -> expand ds e
_ -> return ae
doArrayElem ae = return ae