Просмотр исходного кода

docs: session handoff + park blocked ChanConsts/StreamFile

- docs/session-handoff-2026-10-01.md: end-of-day state, what landed
  (forward vars, result suffixes, wrapper library), the one blocked
  feature (aggregate/set values in CONST), and a branch-first plan.
- docs/wip/: ChanConsts + StreamFile definition/implementation, kept
  out of stdlib until the CONST-set feature exists.

Suite 177/177; fixpoint OK (2,899,706 bytes).
Eric Streit 1 неделя назад
Родитель
Сommit
521290c002

+ 82 - 0
docs/session-handoff-2026-10-01.md

@@ -0,0 +1,82 @@
+# Session handoff — 2026-10-01 (end of day)
+
+State: `master` at tag **`v3-wrap-modules`** (`bdcefbb`).  Suite
+**177/177**, fixpoint **OK** (2,899,706 bytes).  Working tree clean
+except the user's `compiler/toto.mod`.
+
+## What landed today
+
+| Tag | Commit | What |
+| --- | --- | --- |
+| (prev) | `678f20e` | showcase21: expression result suffixes, coroutines, core library |
+| `v3-fwdvars-resultsfx` | `a613e7b` | **forward module-level variables**, expression result suffixes, `LongIO`/`LongWholeIO`/`DynamicStrings`/`SysStorage` |
+| `v3-wrap-modules` | `05d9bd0` | `StdChans`, `TimeString`, `wrapclock`, `wraptime`, `wrapc` |
+| `v3-wrap-modules` | `bdcefbb` | showcase22 + `docs/summary_wrap-modules.md` |
+
+Docs: `docs/language-report.md` (feature set + gaps),
+`docs/summary_fwdvars-resultsfx.md`, `docs/summary_wrap-modules.md`.
+
+## The one blocked feature
+
+**`ChanConsts` and `StreamFile`** are written and parked in
+`docs/wip/` (not compiled into the tree).  They are blocked by a single
+missing language feature:
+
+> **Aggregate (set) values in `CONST` declarations.**
+> `read = FlagSet{readFlag}` — and even `CONST b = BITSET{0}` — is
+> rejected with `not supported yet`.
+
+Important precision: this is **not** a "typed set constructor"
+problem.  `T{…}` constructors already work in expression/assignment
+position, including `a := FSet{r}` over an enum base.  The gap is
+specifically that `ConstDecl` (`compiler/src/M2.atg`) accepts only
+`ClArray`/`ClRecord`/`ClClass`/`ClStr`/`ClUStr` as aggregate constants
+and has **no set case**; a set value has no single immediate operand.
+
+### Why it was not attempted
+It touches the riskiest area of the frontend (`M2.atg`) across
+`ConstDecl`, `TypedBraceLit`/`BraceElem` and `Design`, plus new
+`SymTab` set-word storage and `QbeGen` set-constant materialisation —
+a multi-step change, each step needing the full
+build → suite → fixpoint loop.  Today's session showed that grammar
+edits here can silently break self-hosting; doing it unreliably would
+risk the green state.
+
+## Suggested plan for next time (branch-first)
+
+Work on a branch off `bdcefbb`; after **every** increment run
+`./bootstrap/fixpoint.sh` **and** `cd compiler && ./build.sh &&
+./run_tests.sh`.  Revert the increment (`git checkout -- compiler/src`)
+if either fails.  Commit only when both are green.
+
+Increments:
+1. `SymTab`: store a set constant's bit words per symbol
+   (`SetSymSet`/`GetSymSet`), reusing `SymNode.val` or a small array.
+2. `QbeGen`: `SetConstBegin/SetConstBit/SetConstEnd` accumulating words,
+   and `SetConstLoad(name)` materialising `NewSetTemp` + `Zero` +
+   word stores at a use site.
+3. Grammar: a `constCtx` flag set in `ConstDecl`; in `TypedBraceLit`
+   (set branch) accumulate words when `constCtx`; `ConstDecl` stores
+   them; `Design`'s `KindConst` + `ClSet` calls `SetConstLoad`.
+4. Activate `docs/wip/chanconsts.*` and `docs/wip/streamfile.*`
+   (move back to `stdlib/`), add them to `run_tests.sh`, and add a
+   `wrapflags.mod` test.
+
+## Other open items (see `docs/language-report.md` §9)
+
+- `GOTO`/labels.
+- Generics.
+- Statement-context result suffixes (`F()[i] := x`).
+- Multiple inheritance (deliberate).
+- Full forward variables: module scope only (done); forward *procedure*
+  references rely on the DEFINITION being present.
+- `BITSET` is not accepted as a function-result type (hence
+  `wrapc.ReadOnly`/`WriteOnly` return `CARDINAL`).
+
+## Resume
+
+```sh
+cd ~/Projets/Projets-Modula2/MyWork/m2compiler-V3
+./bootstrap/fixpoint.sh                       # FIXPOINT OK
+cd compiler && ./build.sh && ./run_tests.sh   # 177/177
+```

+ 25 - 0
docs/wip/chanconsts.def

@@ -0,0 +1,25 @@
+DEFINITION MODULE ChanConsts;
+(* ISO 10514-1: channel flags and open-result codes. *)
+
+TYPE
+  ChanFlags = (readFlag, writeFlag, oldFlag, textFlag, rawFlag,
+               interactiveFlag, echoFlag);
+  FlagSet = SET OF ChanFlags;
+
+CONST
+  read        = FlagSet{readFlag};
+  write       = FlagSet{writeFlag};
+  old         = FlagSet{oldFlag};
+  text        = FlagSet{textFlag};
+  raw         = FlagSet{rawFlag};
+  interactive = FlagSet{interactiveFlag};
+  echo        = FlagSet{echoFlag};
+
+TYPE
+  OpenResults = (opened, wrongNameFormat, wrongFlags, tooManyOpen,
+                 outOfChans, wrongPermissions, noRoomOnDevice,
+                 noSuchFile, fileExists, wrongFileType,
+                 noTextOperations, noRawOperations, noMixedOperations,
+                 alreadyOpen, otherProblem);
+
+END ChanConsts.

+ 3 - 0
docs/wip/chanconsts.mod

@@ -0,0 +1,3 @@
+IMPLEMENTATION MODULE ChanConsts;
+(* Constants and types only. *)
+END ChanConsts.

+ 25 - 0
docs/wip/streamfile.def

@@ -0,0 +1,25 @@
+DEFINITION MODULE StreamFile;
+(* ISO 10514-1: opening and closing sequential-stream channels.
+   Layered on IOChan; the read flag implies old, and text is implied
+   unless raw is requested. *)
+
+IMPORT IOChan, ChanConsts;
+
+TYPE
+  ChanId = IOChan.ChanId;
+  FlagSet = ChanConsts.FlagSet;
+  OpenResults = ChanConsts.OpenResults;
+
+CONST
+  read  = FlagSet{ChanConsts.readFlag};
+  write = FlagSet{ChanConsts.writeFlag};
+  old   = FlagSet{ChanConsts.oldFlag};
+  text  = FlagSet{ChanConsts.textFlag};
+  raw   = FlagSet{ChanConsts.rawFlag};
+
+PROCEDURE Open (VAR cid : ChanId; name : ARRAY OF CHAR;
+                flags : FlagSet; VAR res : OpenResults);
+PROCEDURE IsStreamFile (cid : ChanId) : BOOLEAN;
+PROCEDURE Close (VAR cid : ChanId);
+
+END StreamFile.

+ 49 - 0
docs/wip/streamfile.mod

@@ -0,0 +1,49 @@
+IMPLEMENTATION MODULE StreamFile;
+(* Open/close maps onto IOChan's OpenRead/OpenWrite; IsStreamFile is
+   TRUE for any open channel (V3's channels are all streams). *)
+
+IMPORT IOChan, ChanConsts;
+FROM ChanConsts IMPORT opened, noSuchFile, wrongFlags;
+FROM ChanConsts IMPORT readFlag, writeFlag;
+
+PROCEDURE HasFlag (flags : ChanConsts.FlagSet;
+                   f : ChanConsts.ChanFlags) : BOOLEAN;
+BEGIN
+  RETURN f IN flags
+END HasFlag;
+
+PROCEDURE Open (VAR cid : IOChan.ChanId; name : ARRAY OF CHAR;
+                flags : ChanConsts.FlagSet;
+                VAR res : ChanConsts.OpenResults);
+  VAR c : IOChan.ChanId;
+BEGIN
+  c := IOChan.MakeChan(NIL);
+  IF HasFlag(flags, readFlag) THEN
+    (* read implies old *)
+    IF NOT IOChan.IsOpen(IOChan.OpenRead(name)) THEN
+      cid := c; res := noSuchFile; RETURN
+    END;
+    c := IOChan.OpenRead(name)
+  ELSIF HasFlag(flags, writeFlag) THEN
+    c := IOChan.OpenWrite(name);
+    IF NOT IOChan.IsOpen(c) THEN
+      cid := IOChan.MakeChan(NIL); res := noSuchFile; RETURN
+    END
+  ELSE
+    cid := c; res := wrongFlags; RETURN
+  END;
+  cid := c;
+  res := opened
+END Open;
+
+PROCEDURE IsStreamFile (cid : IOChan.ChanId) : BOOLEAN;
+BEGIN
+  RETURN IOChan.IsOpen(cid)
+END IsStreamFile;
+
+PROCEDURE Close (VAR cid : IOChan.ChanId);
+BEGIN
+  IOChan.Close(cid)
+END Close;
+
+END StreamFile.