Self‑Host MIR Builder (Scaffold) — Phase‑20.12b
Purpose
- Prepare a minimal, opt‑in skeleton to generate MIR(JSON v0) in Hakorune (self‑host) alongside the current Rust generator.
- Keep default behavior unchanged (Rust MIR remains the source of truth). This module is emit‑only in early phases.
Scope (this scaffold)
- Files: builder.hako, phi.hako, verify.hako, LAYER_GUARD.hako
- Behavior: no‑op/identity placeholders with clearly defined interfaces and gates.
- Docs: specs/mir-json-v0.md describes the minimal JSON v0 shape targeted by this builder.
Non‑Goals (now)
- Replacing Rust MIR generation by default
- Emitting full MIR coverage (call/extern/boxcall/complex boxes)
Interfaces (subject to evolution)
- SelfhostMirBuilder.build(ast_or_src_path) -> json_path (emit‑only; v0 returns input path)
- SelfhostMirVerify.verify(json_path) -> bool/int (0=ok; v0 always ok)
- SelfhostPhiBox helpers (shape only; no logic yet)
Gates (opt‑in)
- NYASH_USE_NY_COMPILER=1 → future: emit‑only builder path
- NYASH_JSON_ONLY=1 → future: sidecar JSON dump for parity check
Layer Guard
- See LAYER_GUARD.hako — allowed imports are restricted to shared JSON/MIR helpers. No VM/LLVM interaction here.
Rollback
- Folder is isolated under lang/src/selfhost/. Removing this directory reverts to current behavior.