Browse Source

docs: session summary — result suffixes, coroutines, core library

Eric Streit 1 week ago
parent
commit
e8442239a0
3 changed files with 110 additions and 6 deletions
  1. 18 3
      docs/analysis_gaps.md
  2. 15 3
      docs/features.md
  3. 77 0
      docs/summary_resultsfx-coroutines-lib.md

+ 18 - 3
docs/analysis_gaps.md

@@ -108,6 +108,21 @@ Also done: opaque/pointer-like types (incl. `String`), variant-record
 assignment (flat blit), nested-`MODULE` lowering, `ADDRESS`↔pointer
 assignment (flat blit), nested-`MODULE` lowering, `ADDRESS`↔pointer
 assignment.
 assignment.
 
 
-Remaining after today: `GOTO`/labels, result suffixes, generics,
-coroutines, multiple inheritance (deliberate), and the library holes
-in §2.
+Remaining after today: `GOTO`/labels, generics, multiple inheritance
+(deliberate), result *suffixes on statement designators*, and the
+channel/device library holes in §2.
+
+## 7. Done after the gap analysis (this session)
+
+- **Result suffixes** — `F()^`, `F()[i]`, `F().field` (expression
+  context).  Statement-context suffix targets (`F()[i] := x`) and
+  chained post-call calls (`F().M()`) are still not accepted.
+- **PIM coroutines** — `PROCESS` + `NEWPROCESS`/`TRANSFER`/`IOTRANSFER`
+  (ucontext-backed).
+- **Core text/ISO library** — `ConvTypes`, `IOConsts`, `SIOResult`,
+  `TERMINATION`, `StrIO`, `InOut`, `StdIO`, `WholeStr`, `RealStr`,
+  `LongStr`, `LongMath`, `STextIO`, `SWholeIO`, `SRealIO`,
+  `DynamicStrings` (core), `SysStorage`.
+- **Backend** — procedure values / LONGINT are 8-byte in array load/
+  store and in the parameter prologue (were 32-bit); driver session
+  file cap 32 → 128.

+ 15 - 3
docs/features.md

@@ -95,8 +95,9 @@ Legend: ✅ done · 🔄 partial · ⏸ not started / deferred.
   truncated to the array capacity, NUL-terminated), `LEN`/`LENGTH` of
   truncated to the array capacity, NUL-terminated), `LEN`/`LENGTH` of
   arrays and string literals. UString `+`/`LEN` likewise.
   arrays and string literals. UString `+`/`LEN` likewise.
 - ✅ `NIL` comparisons/assignment.
 - ✅ `NIL` comparisons/assignment.
-- ✅ `VAL`/`ADR`/`TSIZE`/`SIZE`/`HIGH`/`LEN` work. ⏸ Result suffixes
-  (`F()^`).
+- ✅ `VAL`/`ADR`/`TSIZE`/`SIZE`/`HIGH`/`LEN` work. ✅ Result suffixes
+  (`F()^`, `F()[i]`, `F().field`): components after a call result,
+  loaded like Design components.
 
 
 ## Procedures & modules
 ## Procedures & modules
 - ✅ Value + `VAR` params, function results, recursion, mutual
 - ✅ Value + `VAR` params, function results, recursion, mutual
@@ -129,12 +130,23 @@ Legend: ✅ done · 🔄 partial · ⏸ not started / deferred.
 - ✅ `runtime/syslib`: `SysShim`, `FileIO`, `Utf8` (UTF-8 codec).
 - ✅ `runtime/syslib`: `SysShim`, `FileIO`, `Utf8` (UTF-8 codec).
 - ✅ `stdlib`: `SysIO`, `TextIO` (+ UTF-8 `U*`), `WholeIO`,
 - ✅ `stdlib`: `SysIO`, `TextIO` (+ UTF-8 `U*`), `WholeIO`,
   `Math` (incl. `log10`/`atan2`/`sinh`/`cosh`/`tanh`/`hypot`/
   `Math` (incl. `log10`/`atan2`/`sinh`/`cosh`/`tanh`/`hypot`/
-  `floor`/`ceil`/`trunc`/`round`/`fmod`), `Strings` (incl. `Slice`
+  `floor`/`ceil`/`trunc`/`round`/`fmod`; `ln`/`arctan` wrap `log`/`atan`),
+  `Strings` (incl. `Slice`
   (Python-style), `Insert`, `Replace`, `Capitalize`), `CharClass`,
   (Python-style), `Insert`, `Replace`, `Capitalize`), `CharClass`,
   `Files` (layered on `IOChan`),
   `Files` (layered on `IOChan`),
   `Conversions` (ISO `ConvResults` statuses + BOOLEAN shortcuts),
   `Conversions` (ISO `ConvResults` statuses + BOOLEAN shortcuts),
   `RealIO`, `ProgramArgs`, `SysClock`,
   `RealIO`, `ProgramArgs`, `SysClock`,
   `IOChan` (streams + files; `Position`/`Seek`/`Rewind`), `Storage`.
   `IOChan` (streams + files; `Position`/`Seek`/`Rewind`), `Storage`.
+- ✅ gm2/ISO text + conversion library added: `ConvTypes`, `IOConsts`,
+  `SIOResult`, `TERMINATION`, `StrIO`, `InOut`, `StdIO`, `WholeStr`,
+  `RealStr`, `LongStr`, `LongMath`, `STextIO`, `SWholeIO`, `SRealIO`,
+  `DynamicStrings` (core subset), `SysStorage`.
+
+## Coroutines
+- ✅ PIM/SYSTEM coroutines: `PROCESS`, `NEWPROCESS`, `TRANSFER`,
+  `IOTRANSFER` (the last degrades to a transfer without an interrupt
+  subsystem).  Bind to `ucontext` helpers in the shim; coroutine
+  bodies are called with a 0 static link (module-level procedures).
 
 
 ## Not started
 ## Not started
 - ✅ Clarion `CLASS`: fields, methods (value/VAR formals, results),
 - ✅ Clarion `CLASS`: fields, methods (value/VAR formals, results),

+ 77 - 0
docs/summary_resultsfx-coroutines-lib.md

@@ -0,0 +1,77 @@
+# 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`, `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: `LongIO`/`LongWholeIO` (channel-based),
+`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
+
+```sh
+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.