restore(lang): full lang tree from ff3ef452 (306 files) — compiler, vm, shared, runner, c-abi, etc.\n\n- Restores lang/ directory (files≈306, dirs≈64) as per historical branch with selfhost sources\n- Keeps our recent parser index changes in compiler/* (merged clean by checkout)\n- Unblocks selfhost development and documentation references

This commit is contained in:
nyash-codex
2025-10-31 20:45:46 +09:00
parent dbc285f2b1
commit e5f697eb22
244 changed files with 16915 additions and 47 deletions

View File

@ -0,0 +1,11 @@
[module]
name = "selfhost.mir_builder"
version = "0.1.0"
[exports]
README = "mir_builder/README.md"
LayerGuard = "mir_builder/LAYER_GUARD.hako"
Builder = "mir_builder/builder.hako"
Phi = "mir_builder/phi.hako"
Verify = "mir_builder/verify.hako"

View File

@ -0,0 +1,9 @@
// LAYER_GUARD — selfhost.mir_builder
// この層の責務: MIR(JSON v0) の生成将来的に。VM/LLVM/実行は非対象。
static box LayerGuard {
name() { return "selfhost.mir_builder" }
allowed_imports() { return ["json", "mir_spec", "fs"] }
forbidden_imports() { return ["vm", "llvm", "runtime", "plugins"] }
}

View File

@ -0,0 +1,30 @@
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.

View File

@ -0,0 +1,18 @@
// builder.hako — Selfhost MIR(JSON v0) Builder (Scaffold)
// Phase20.12b: emitonly placeholder. Returns input path unchanged.
static box SelfhostMirBuilder {
// Build MIR(JSON v0) from AST/source (scaffold)
// Returns: json_path (for now, identity)
build(input_path) {
// TODO(20.12b): parse/load, lower minimal ops (const/binop/compare/branch/ret/phi)
return input_path
}
// Future convenience: emit a minimal JSON header for parity checks
emit_min_header(json_path) {
// TODO(20.12b): write {"version":"0","kind":"Program"} header sidecar
return json_path
}
}

View File

@ -0,0 +1,17 @@
// phi.hako — PHI helpers (Scaffold)
// Phase20.12b: define shapes; real logic arrives in later steps.
static box SelfhostPhiBox {
// Merge two inputs (placeholder)
merge2(dst, in1, in2) {
// TODO: construct MIR JSON node: {op:"phi", dst, inputs:[[bb1,v1],[bb2,v2]]}
return dst
}
// Merge list of (bb,val) pairs (placeholder)
mergeN(dst, inputs) {
// TODO: validate inputs cover all predecessors
return dst
}
}

View File

@ -0,0 +1,10 @@
// verify.hako — Selfhost MIR verifier (Scaffold)
// Phase20.12b: minimal contract; always OK for now.
static box SelfhostMirVerify {
verify(json_path) {
// TODO: parse JSON and check: block start PHIs, pred coverage, no undefined uses
return 0 // 0=ok (placeholder)
}
}