tock-mirror/fco2/testcases/nonconst-array-literal.occ
Adam Sampson d5766c5fe5 Implement arrays inside records.
... which required a bunch of stuff:

- Record handling in the literal evaluator (to solve a nasty problem with
  record literals documented in the code).

- Splitting abbrevModeOfVariable into two functions which do the two
  (different) things it was previously used for.

- Clean up how arrays are handled in GenerateC.

- Fix the pullup rules for record literals containing arrays.
2007-05-16 19:34:10 +00:00

17 lines
555 B
Plaintext

-- This tests an oddball case in occam-to-C translation: an array subscript is
-- not constant in C99 (even if it's a constant subscript of a constant).
-- We therefore have to avoid doing the "obvious" C translation of the code below
-- by constant-folding the subscript out of existance -- and making sure it
-- doesn't get pulled back out to a variable again!
VAL []INT xs IS [1, 2, 3, 4]:
VAL []INT ys IS [12, xs[2], 34]:
VAL [][]INT yss IS [[xs[0], xs[1]]]:
DATA TYPE ONE.REC
RECORD
[1]INT a:
:
VAL ONE.REC rec IS [[xs[2]]]:
PROC P ()
SKIP
: