Skip to content

Commit ce68818

Browse files
Phase V.6 → V.8b: self-hosting bytecode bootstrap reaches fixpoint
Six progressive milestones bringing OMC to a closed self-hosting loop at the bytecode level: V.6 — examples/self_hosting_bytecode.omc AST → textual bytecode encoder + stack-VM executor in OMC. Integer arithmetic, while, if/else. Discovered OMC's pass-by-value array semantics; encoder uses return-and-rebind with relative jumps so concatenation needs no patch pass. V.7 — examples/self_hosting_v7.omc Function definitions, CALL/RETURN, call frames + scope stacks in the OMC executor. Headline: fib(10) → 55 via 177 recursive CALL/RETURN cycles, all on OMC-written infrastructure. V.7b — examples/self_hosting_v7b.omc LOAD_STR, MAKE_ARR, CALL_BUILTIN. Strings, array literals, read-only host primitives (arr_get/arr_len/str_*/concat_many) dispatched through a single switch. 7/7 tests pass. V.7c — examples/self_hosting_v7c.omc ARR_PUSH_NAMED, ARR_SET_NAMED — mutating array builtins via named-store opcodes. Test 7/8 contrast (rebind vs discard the return value) shows pass-by-value semantics are byte-faithful to tree-walk. Bytecode VM now structurally supports every construct the V.7b compiler uses. V.8 — examples/self_hosting_v8.omc Round-trip fixpoint driver. The same OMC code, evaluated two ways (tree-walk vs lex/parse/encode/execute on bytecode VM), returns byte-identical arrays. execute() now surfaces a return value via the __result scope binding. concat_many fixed to use to_string per arg (Display, not Debug) — closes the V.7b cosmetic divergence. Two demos: embedded_program and build_pyramid. Both ✓ FIXPOINT. V.8b — examples/self_hosting_v8b.omc # line comments, `-> type` annotations, and `break` round-trip identically. classify_word exercises all three. tokenize_subset (a real lexer, 186 bytecode ops) round-trips byte-identical to tree-walk — gen2 == gen3 for a compiler component. The bootstrap loop is architecturally closed at the feature-surface level. A side-quest finding: OMC's str_len returns BYTE count while str_slice is char-indexed. Hand-written lexers over non-ASCII source overshoot. Worked around with ASCII-only embedded source; logged for V.9. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
1 parent ddb553d commit ce68818

7 files changed

Lines changed: 7470 additions & 0 deletions

CHANGELOG.md

Lines changed: 253 additions & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)