Suite 159/159; self-hosting fixpoint OK
(image 2,639,067 bytes). master, tree clean except the user's
uncommitted compiler/toto.mod.
This session added GNU Modula-2 aggregate constructors and showcased them.
| Step | Tag | Commit | What |
|---|---|---|---|
| Array constructors | v3-array-ctors |
c03563e |
T{…} static descriptors |
| Records + runtime | v3-ctor-records |
382125a |
Rec{…}, runtime build |
| Showcase | v3-showcase20 |
(this commit) | constructors end to end |
TypeName{…} (GNU Modula-2) is now an aggregate constructor for arrays
and records:
CtorEnd bakes a
pooled descriptor (data $ctoN = { … }) with the same layout as a
declared object: array l n, …, record fields in declaration order,
nested constructors inlined as aggregate fields (and consumed),
strings inlined into matching CHAR-array fields. A CONST of an
aggregate type resolves to the descriptor address.CtorEnd allocate the
descriptor on the stack (alloc8) and fill it in place
(ElemStore / InitArrHeader+CopyArray / CopyRecord /
CopySet), so constructors also work outside CONST.ARRAY OF CHAR,
and the expr BY n repeat form.QbeGen.CtorBegin/CtorElem/CtorEnd (CtorElem derives the element
type itself); the old TypedSetLit became the unified TypedBraceLit
(BITSET{…} stays a set).
compiler/tests/showcase20.mod (Showcase20, exit 42) exercises:
Greet = Name {'H','e','l','l','o','!','!','!'} — CHAR-array CONST;Base = Triple {7, 7 BY 2} — the BY repeat form (7,7,7);p := Person{"Modula", Date{1980, 5, 3}} — static record
constructor (string field + inlined nested record);q := Person{"Runtime", Date{i, i+1, i+2}} — runtime record
constructor;a := Triple{i, i+1, i+2} — runtime array constructor.Sum: 21 (Base) + 18 (a) + 3 (p.born.d) = 42.
showcase20 total=42
New: Showcase20 (42), plus t_ctor{1..6} (t_ctor1 CHAR-array
copy, t_ctor2 BY repeat, t_ctor3 nested strings, t_ctor4
static record, t_ctor5 runtime array, t_ctor6 runtime record).
$V3_LIBS)gm2 testsuite 283/612 compile-OK (was 242 before this work; 0
CRASH). strcons.mod, testarray.mod, arrayconst{1,2,3}.mod,
lazyunique.mod's array constructor now compile.
cd .../m2compiler-V3
./bootstrap/fixpoint.sh # FIXPOINT OK
cd compiler && ./build.sh && ./run_tests.sh # 159/159
ARRAY <type> OF T (index-type arrays).MIN/MAX builtins; more SYSTEM facilities.