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:
11
lang/src/selfhost/hako_module.toml
Normal file
11
lang/src/selfhost/hako_module.toml
Normal 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"
|
||||
|
||||
9
lang/src/selfhost/mir_builder/LAYER_GUARD.hako
Normal file
9
lang/src/selfhost/mir_builder/LAYER_GUARD.hako
Normal 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"] }
|
||||
}
|
||||
|
||||
30
lang/src/selfhost/mir_builder/README.md
Normal file
30
lang/src/selfhost/mir_builder/README.md
Normal file
@ -0,0 +1,30 @@
|
||||
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.
|
||||
|
||||
18
lang/src/selfhost/mir_builder/builder.hako
Normal file
18
lang/src/selfhost/mir_builder/builder.hako
Normal file
@ -0,0 +1,18 @@
|
||||
// builder.hako — Self‑host MIR(JSON v0) Builder (Scaffold)
|
||||
// Phase‑20.12b: emit‑only 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
|
||||
}
|
||||
}
|
||||
|
||||
17
lang/src/selfhost/mir_builder/phi.hako
Normal file
17
lang/src/selfhost/mir_builder/phi.hako
Normal file
@ -0,0 +1,17 @@
|
||||
// phi.hako — PHI helpers (Scaffold)
|
||||
// Phase‑20.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
|
||||
}
|
||||
}
|
||||
|
||||
10
lang/src/selfhost/mir_builder/verify.hako
Normal file
10
lang/src/selfhost/mir_builder/verify.hako
Normal file
@ -0,0 +1,10 @@
|
||||
// verify.hako — Selfhost MIR verifier (Scaffold)
|
||||
// Phase‑20.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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user