summary_resultsfx-coroutines-lib.md 3.3 KB

Session summary — 2026-10-01: result suffixes, coroutines, core library

Suite 173/173; self-hosting fixpoint OK (image 2,785,569 bytes). Work on items 2 (result suffixes), 4 (coroutines) and 6 (library holes) of the remaining-gaps list; items 1 (GOTO), 3 (generics) and 5 (multiple inheritance) were left alone.

1. Result suffixes (F()^, F()[i], F().field)

New ResultComp production (M2.atg) applied to a call result inside Fact: the [ ArgList { ResultComp } ] group is entered only when the lookahead is (, so the component starters [ . ^ stay disjoint from Design's own component loop (no new Coco/R LL(1) conflict). After a call the result is in t/q with sfx := FALSE; ^ dereferences a pointer result, [i] indexes an array result, .f selects a record field, and a final scalar is loaded with ElemLoad. Expression context only; statement-context suffix targets and chained post-call calls are not accepted.

2. PIM coroutines (SYSTEM.NEWPROCESS/TRANSFER/IOTRANSFER)

  • PROCESS is predefined pointer-sized; PROC is a new parameterless procedure-type descriptor (dProc).
  • NEWPROCESS, TRANSFER, IOTRANSFER are predefined external procedures (SymTab.PredefCProc/AddFormal) with explicit signatures; calls bind to m2_newprocess/m2_transfer/ m2_iotransfer.
  • The shim implements them over ucontext: NEWPROCESS builds a context on the caller's workspace, TRANSFER saves/resumes. IOTRANSFER degrades to a transfer (no interrupt subsystem).

3. Backend fixes exposed by the library

  • ElemLoad/ElemStore and the function-parameter prologue treated procedure values (and LONGINT) as 32-bit; they are now loadl/ storel (ClProc, ClClass, ClLong). This fixes arrays of procedure values (StdIO's push/pop stacks) and proc/long formals.
  • The M2 driver's session file table was capped at 32 sources; raised to 128 (compiler.frm).
  • Math.ln/Math.arctan now wrap the C log/atan (they bound to non-existent ln/arctan).

4. Standard library (gm2/ISO names, layered on the shim)

Added: ConvTypes, IOConsts, SIOResult, TERMINATION, StrIO, InOut, StdIO, WholeStr, RealStr, LongStr, LongMath, STextIO, SWholeIO, SRealIO, LongIO, DynamicStrings (core subset), SysStorage. TERMINATION.def is uppercase (gm2 spelling).

New shim helpers: m2readline, m2writeintwidth, m2realconv, m2terminating, m2hashalted, and the m2ds* DynamicStrings core (heap C strings; String is an opaque type completed to ADDRESS).

Still missing from the §2 list: LongWholeIO, wrapclock/wraptime/ wrapc, TimeString, and the gm2 device framework (ChanConsts/ GenDevIF/DeviceTablePtr/StdChans/StreamFile/FIO).

Tests (173, was 171)

New: t_resultsfx (deref/index/field of call results), t_coroutine (two coroutines ping-pong), t_dynstr (DynamicStrings + SysStorage), library1 (a session exercising 16 library modules).

Resume

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

Remaining

GOTO/labels, generics, multiple inheritance (deliberate), full forward variables, statement-context result suffixes, and the channel/ device library holes listed above.