Files
hakorune/lang/src/selfhost/mir_builder
..

SelfHost MIR Builder (Scaffold) — Phase20.12b

Purpose

  • Prepare a minimal, optin skeleton to generate MIR(JSON v0) in Hakorune (selfhost) alongside the current Rust generator.
  • Keep default behavior unchanged (Rust MIR remains the source of truth). This module is emitonly in early phases.

Scope (this scaffold)

  • Files: builder.hako, phi.hako, verify.hako, LAYER_GUARD.hako
  • Behavior: noop/identity placeholders with clearly defined interfaces and gates.
  • Docs: specs/mir-json-v0.md describes the minimal JSON v0 shape targeted by this builder.

NonGoals (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 (emitonly; v0 returns input path)
  • SelfhostMirVerify.verify(json_path) -> bool/int (0=ok; v0 always ok)
  • SelfhostPhiBox helpers (shape only; no logic yet)

Gates (optin)

  • NYASH_USE_NY_COMPILER=1 → future: emitonly 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.