summary_showcase17.md 3.3 KB

Session summary — 2026-09-29: CHAR-array +, ConvResults, CLASS lowering

Suite 142/142; self-hosting fixpoint OK (bootstrap/fixpoint.sh, image 2,188,065 bytes). master, tree clean except the user's uncommitted compiler/toto.mod.

Three features landed this session, each its own tagged step.

Steps, tags and headline commits

Step Tag Commit What
CHAR-array + + ConvResults v3-charcat-convresults 5e2056f ARRAY OF CHAR concatenation test; ISO ConvResults
Clarion CLASS lowering v3-class-lowering ed02804 fields, methods, THIS, single inheritance
Showcase v3-showcase17 de27462 the three together

1. CHAR-array + (verified + tested)

String concatenation for ARRAY OF CHAR already worked end-to-end from the earlier string work; it just had no test. t_charcat.mod (15) now locks in a + b, a + "c", "x" + a and a + a + a.

(Classic note: a single-character string literal is a CHAR, so b := "z" into a CHAR array is 210 — use b := "zz"; the + operator accepts the CHAR form directly.)

2. ISO ConvResults

Conversions now reports a status enumeration:

TYPE ConvResults = (strAllRight, strOutOfRange, strWrongFormat,
                    strEmpty);
PROCEDURE StrToInt (s : ARRAY OF CHAR; VAR n : INTEGER) : ConvResults;
PROCEDURE StrToCard(s : ARRAY OF CHAR; VAR n : CARDINAL): ConvResults;
PROCEDURE StrToReal(VAR s : ARRAY OF CHAR; VAR x : REAL): ConvResults;

Overflow is detected before the 32-bit accumulate wraps (V3 has no VAL(LONGINT, int) or long→int narrowing). The BOOLEAN shortcuts live on as IntVal/CardVal/RealVal.

3. Clarion CLASS lowering

Classes now execute (see docs/summary_class-lowering.md for the full design):

  • A class is a record for layout; single inheritance lays a child's fields after the parent's, and field lookups walk the parent chain.
  • Each method has a hidden THIS VAR parameter, pushed as the current WITH base so bare field names mean THIS^.field.
  • obj.M(args) binds statically with the receiver as the hidden first argument; a CLASS IMPLEMENTATION reuses the declared method symbol (matching call-site and definition uids).
  • VIRTUAL is accepted but dispatches statically for now; bare sibling-method calls and a class BEGIN init body stay 230.

4. Showcase

compiler/tests/showcase17.mod (Showcase17, exit 42) ties them together: a Bounded counter class (inheriting from Counter) driven through its receiver, a value parsed with ConvResults, and a label built by CHAR-array concatenation.

showcase17 total=42

Tests (142, was 139)

New: t_charcat (15), convresults_prog (127), t_classmethod (7), t_classinherit (7), TClassDefProg (8), Showcase17 (42). conv_prog/showcase14 moved to IntVal/RealVal; t_classdef.mod became t_classdef.def (a definition used by TClassDefProg).

Resume

cd .../m2compiler-V3
./bootstrap/fixpoint.sh                       # FIXPOINT OK
cd compiler && ./build.sh && ./run_tests.sh   # 142/142

Remaining polish

  • CLASS: VIRTUAL vtable dispatch, sibling-method calls, class init bodies.
  • VAL(LONGINT|REAL, x) and long→int narrowing.
  • IOChan-over-Files extras; deeper Strings/Math.