From 88d6136dcf75703e1c462030324f3e948bd9a7d3 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 2 Feb 2009 17:30:39 +0000 Subject: [PATCH] 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 --- transformations/SimplifyExprs.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/transformations/SimplifyExprs.hs b/transformations/SimplifyExprs.hs index 1b82b4c..ef9e3e9 100644 --- a/transformations/SimplifyExprs.hs +++ b/transformations/SimplifyExprs.hs @@ -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