goal_step8.md 2.8 KB

Goals — steps 8+ (saved, to implement next)

Roadmap after step 7 (backend listing). Order is priority order; each step keeps the full suite green with no cascades.

Step 8 — opaque types (recommended next)

Scope (finishes the step-5 library story: information hiding):

  • TYPE T; (opaque declaration) in DEFINITION; the full declaration in IMPLEMENTATION (TYPE T = RECORD ... END;).
  • Outside the implementation, opaque T is usable only behind POINTER TO T, as a VAR formal type, and for assignment between same-opaques. No client VAR of type T, no field access, no construction, no value parameters or function results of opaque type (all static 230s/201s).

Design deltas (vs step 7):

  • SymTab: opaque descriptor form (or alias-with-hidden-target + flag); export table carries opaque-ness; completion in the implementation reuses one descriptor index so both sides agree; compatibility: same-opaque assigns, nothing else crosses.
  • Grammar: TYPE ident ; alternative in definitions (mid-rule: TYPE T = ... stays); implementation TYPE accepts the completion (name/type match, else 221-ish/230).
  • MGen: expected unchanged (clients can never size an opaque — pointers are 1 slot; the implementation walks the completed descriptor normally).

Acceptance (same bar):

  • ~4 run tests (counter/stack ADT: New/Free/Use/Count ExitCodes)
    • ~5 rejection tests (client VAR, field access, value param, opaque result, completion mismatch); 65-test regression green.

Suggested first tests:

  • DCounter-style ADT (New returns pointer, Inc/Get), completion mismatch (different base → reject), client VAR x : T → reject, p^.field from client → reject.

Step 9 — procedure types + indirect calls

Scope: TYPE H = PROCEDURE (INTEGER): INTEGER; variables, procedure constants as values, calls through variables, handlers as actuals. Requires a VM design spike first: no direct indirect- call opcode exists (CE jump_stack = bare computed jump; return linkage/frames must be designed, possibly a new opcode or a linkage convention in MGen). Do NOT start emitting before the spike lands in mc64-spec.md.

Step 10 — LONGINT / LONGREAL

Scope: 64-bit LONGINT/LONGCARD (0C5–CC), LONGREAL quads (0x12), literals, conversions, full operator lowering, print helper extension. Large but mechanical: lexer, descriptors, every operator family, mixed-type rules. (Predefs currently alias to 32-bit/64-bit-float as placeholders.)

Later (explicitly deferred)

  • Multi-.MC4 emission with depCount loading (loader path is proven by STAK/DEP; the emitter side is the work).
  • Source-line mapping for DumpImage (needs positions on AST nodes: grammar + AST + backend change).
  • WITH-field / CHAR tails as VAR actuals, open-to-open array passing, circular imports (v1 hardening list, unchecked here so far).