Commit ad0b1e8
Phase V.9 + V.9b: UTF-8 safety + gen2 == gen3 of a compiler
V.9 — str_chars host builtin.
omnimcode-core/src/interpreter.rs gains a str_chars(s) -> int builtin
returning UTF-8 char count, matching str_slice's char-indexed semantics.
Where V.8b's hand-written lexers used str_len (byte count) as the loop
bound and silently overshot on multi-byte source, V.9 uses str_chars
and walks UTF-8 cleanly. One file changed; the fix reaches both the
tree-walker and the bytecode VM since CALL_BUILTIN routes through
vm_call_builtin -> call_function -> the same dispatch table.
examples/self_hosting_v9.omc ports the V.8b stack to str_chars at
every source-iteration site. The em-dash in TOKENIZE_SUBSET_SOURCE's
prologue comment — the exact byte that produced V.8b's silent
UNKNOWN_STMT — processes cleanly. Non-ASCII test inputs ("→→→",
"café") classify correctly. 2/2 fixpoints, zero warnings.
V.9b — gen2 == gen3 of a compiler.
examples/self_hosting_v9b.omc demonstrates the textbook self-application
fixpoint at compiler-bootstrap level. A real mini-compiler-as-function
(mini_enc: NUM/VAR/BIN expression encoder, ~30 lines) is run two ways
on the same hardcoded input AST `(89 + 144) * 2`:
Path A (gen1): tree-walk runs mini_enc directly.
Returns ["LOAD_INT 89", "LOAD_INT 144",
"ADD", "LOAD_INT 2", "MUL"].
Path B (gen2->gen3): tree-walk compiles MINI_ENC_SOURCE through
the V.9 stack to 140 bytecode ops. The OMC
bytecode VM executes that bytecode on the
same AST. Returns the same array.
A == B. The compiler is a fixed point under self-application.
The OMC self-hosting stack is now operationally complete. The
compiler-in-OMC and executor-in-OMC are functionally indistinguishable
from the host tree-walker for any program using their supported
feature surface. Full V.9-compiling-itself is a one-shot of time
(thousands of bytecode ops × dispatch branches per op), not a question
of architecture.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent ce68818 commit ad0b1e8
4 files changed
Lines changed: 3280 additions & 0 deletions
File tree
- examples
- omnimcode-core/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
7 | 45 | | |
8 | 46 | | |
9 | 47 | | |
| |||
0 commit comments