raz / commit d16c846a

commit
d16c846a843eec267dfc55a99666da3da23ba2c3
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
6a2ca870
Self step 3a: README and PLAN

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

patch · log

2 files changed, +20 -1

PLAN.md (history) modified +2 -1

@@ -32,7 +32,8 @@
3232 seed's and list what `Sys` and the library lacked. Stop for review:
3333 if the cost is too high, mend the code generator first.
3434 2. `chunk`, `sym` (2a, done); `link`, `elf`, `x64` (2b, done).
35-3. `gen`, `item`.
35+3. `gen` (3a, done: `Gen.raz`, tested by `test/GenDump`, a script of
36+ calls whose bytes and listing are the same), `item` (3b).
3637 4. `parse`, `raz`: the first compiler that builds.
3738 5. Fixpoint: the seed builds `self`, that builds `self`, that builds
3839 `self` again, and the last two are byte for byte the same. Then

self/README.md modified +18 -0

@@ -22,6 +22,12 @@
2222 script, bytes, fixups and listing, and by `test/AsmDump` on the files
2323 `test/genasm.py` makes: a long run of every instruction the assembler
2424 knows, and a file for each of its errors.
25+`Gen` is tested by `test/GenDump`, a script of calls, valid by
26+construction (an expression pushes its operands and then operates; a
27+statement leaves the stack as it found it), that compiles 80 procedures
28+with every kind of expression, statement, call, check, frame and defer,
29+and the entry point, static and dynamic: the bytes, fixups, line notes
30+and listing must be the same.
2531
2632 `check.sh` builds a dumper for each side, `test/ScanDump.pas` over the
2733 seed's units and `test/ScanDump.raz` over these, and has both read the
@@ -80,6 +86,18 @@
8086 `setStripped` and `X64.setListing`. The file is written by
8187 `Files.write` and made executable by `Sys.chmod`, in place of one
8288 `open` with mode 755 (which the umask would trim).
89+- **`Gen`.** The seed's `Mark` in the middle of a push or a check
90+ can't give an error back: `newEntry` (the stack's 256 places) and
91+ `check` (4,096 checks a procedure) show it and go on without doing
92+ what they couldn't, and the parser's `resetStack` makes the stack
93+ right again; `endProc` returns its error ("frame too big") and
94+ `codeProc` the assembler's. A `var` out of the seed became a result
95+ (`topConst`, `operands`, `deferBegin`); the labels, which are chains
96+ that a call extends, stay `var`. `inPlace` has a setter. The seed's
97+ `Call` record is `CallInfo` (the procedure is `call`) and `TLink` is
98+ `Link`. A `match` on an enumeration takes one name to an arm, and a
99+ set holds at most 64 names, so `Scan.Sym` (over 64) has none: the
100+ seed's sets of its names are chains of `=`.
83101 - **No bit cast.** A real's bits and back go through a pointer.
84102 - **Speed.** On the 348,025 lines of `test/genbench.py`, 7.6 MB, the
85103 seed's scanner takes 75 ms and this one 74. It took 121 at first.