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:
28
lang/src/runner/README.md
Normal file
28
lang/src/runner/README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# Runner Facade (Script‑First) — Phase 20.10
|
||||
|
||||
Responsibility
|
||||
- Provide a thin, opt‑in runner facade in Hakorune (script) to orchestrate entry selection and pre/post hooks.
|
||||
- Delegates actual execution to existing backends (Rust VM / LLVM). No behavior change by default.
|
||||
|
||||
Gate
|
||||
- Enable with `HAKO_SCRIPT_RUNNER=1` (default OFF). In 20.10 this runner is not wired by default; wiring will be added behind the gate.
|
||||
|
||||
Contracts (draft)
|
||||
- Entry: `Runner.run(entry: string, args: array<string>) -> i64`
|
||||
- Pre‑hooks: validate entry, shape args, emit diagnostics (short tokens) on failure.
|
||||
- Post‑hooks: normalize result (e.g., quiet result mode), optional metrics/logging.
|
||||
|
||||
Notes
|
||||
- Keep this layer pure and free of platform I/O. Defer I/O to C‑ABI utilities (`hako_*`).
|
||||
- Fail‑Fast: invalid entry/args → emit short diagnostics and return non‑zero.
|
||||
- Box‑First: add adapters for boundary objects (args, env) instead of sprinkling conditions.
|
||||
|
||||
Short Diagnostics & Observability
|
||||
- Pre‑invoke emits stable one‑liners for smokes:
|
||||
- Success: `[script-runner] invoke` (stdout)
|
||||
- Failure (dev injection or panic): `[script-runner] invoke: FAIL` (stdout)
|
||||
- The runner wiring prints a gate trace to stderr: `[script-runner] gate=on (facade)`.
|
||||
|
||||
Dev‑only toggle (TTL: Phase 20.10 bring‑up)
|
||||
- `HAKO_SCRIPT_RUNNER_FORCE_FAIL=1` forces the pre‑invoke to emit `[script-runner] invoke: FAIL` without executing the facade program.
|
||||
- Scope: tests/smokes only. Remove after runner wiring stabilizes (documented here as a temporary aid).
|
||||
13
lang/src/runner/core/README.md
Normal file
13
lang/src/runner/core/README.md
Normal file
@ -0,0 +1,13 @@
|
||||
# Runner Core (Plan Builder)
|
||||
|
||||
Scope
|
||||
- Decision-only layer to build a `RunnerPlan` from CLI/ENV inputs.
|
||||
- No I/O or process execution here. Rust (Floor) applies the plan.
|
||||
|
||||
Status
|
||||
- Phase 20.26‑C scaffold. Opt‑in via `HAKO_RUNNER_PLAN=1` once wired.
|
||||
|
||||
Contract (MVP)
|
||||
- Provide `RunnerPlanBuilder.build(args)` that returns a small JSON object with a minimal set of fields:
|
||||
- `{"action":"ExecuteCore|ExecuteVM|ExecuteNyLlvmc|Skip|Error", "gate_c":bool, "engine":"core|vm|llvm", "plugins":bool, "quiet":bool}`
|
||||
- Fail‑Fast on ambiguity; no silent fallbacks.
|
||||
34
lang/src/runner/core/plan_builder.hako
Normal file
34
lang/src/runner/core/plan_builder.hako
Normal file
@ -0,0 +1,34 @@
|
||||
// RunnerPlanBuilder (JSON Plan) — Phase 20.26‑C
|
||||
// Responsibility: Build a minimal RunnerPlan JSON from a tiny JSON payload.
|
||||
// Contract: build/1 accepts a JSON-like string and returns a JSON object string:
|
||||
// {"action":"ExecuteCore|ExecuteVM|ExecuteNyLlvmc|Skip|Error","gate_c":bool,
|
||||
// "engine":"core|vm|llvm", "plugins":bool, "quiet":bool }
|
||||
|
||||
static box RunnerPlanBuilder {
|
||||
build(j) {
|
||||
// MVP: naive scan (no JSON parser dependency).
|
||||
// Priority: explicit backend → ExecuteVM/ExecuteNyLlvmc;
|
||||
// boxes directive → ExecuteBoxes;
|
||||
// else if gate_c → ExecuteCore; else Skip.
|
||||
local gate = j.indexOf("\"gate_c\":true") >= 0
|
||||
local act = "Skip"
|
||||
if (j.indexOf("\"backend\":\"vm\"") >= 0) { act = "ExecuteVM" }
|
||||
else if (j.indexOf("\"backend\":\"llvm\"") >= 0) { act = "ExecuteNyLlvmc" }
|
||||
// boxes toggle (optional). If present and no stronger action decided, produce ExecuteBoxes
|
||||
local boxes_val = ""
|
||||
if (j.indexOf("\"boxes\":\"hako\"") >= 0) { boxes_val = "hako" }
|
||||
else if (j.indexOf("\"boxes\":\"rust\"") >= 0) { boxes_val = "rust" }
|
||||
if (act == "Skip" && boxes_val != "") { act = "ExecuteBoxes" }
|
||||
else if (act == "Skip" && gate) { act = "ExecuteCore" }
|
||||
|
||||
// Compose a compact JSON string (keys kept minimal and stable)
|
||||
local plan = "{\"action\":\"" + act + "\"," +
|
||||
"\"gate_c\":" + (gate ? "true" : "false") + "," +
|
||||
"\"engine\":\"core\"," +
|
||||
"\"plugins\":false," +
|
||||
"\"quiet\":true" +
|
||||
(boxes_val != "" ? ",\"boxes\":\"" + boxes_val + "\"" : "") +
|
||||
"}"
|
||||
return plan
|
||||
}
|
||||
}
|
||||
15
lang/src/runner/gate_c/controller.hako
Normal file
15
lang/src/runner/gate_c/controller.hako
Normal file
@ -0,0 +1,15 @@
|
||||
// Gate‑C Controller (Phase 20.26)
|
||||
// Responsibility: Provide a thin, stable entry to route MIR(JSON v0)
|
||||
// through the Ny/Core dispatcher when a wrapper route is needed.
|
||||
|
||||
include "lang/src/vm/core/dispatcher.hako"
|
||||
|
||||
static box GateCController {
|
||||
// route_json/1: String(JSON v0) -> String(last line)
|
||||
// Contract: returns a printable string (numeric or tag). No side effects.
|
||||
route_json(j) {
|
||||
// Delegate to the Core dispatcher runner
|
||||
return call("NyVmDispatcher.run/1", j)
|
||||
}
|
||||
}
|
||||
|
||||
7
lang/src/runner/hako_module.toml
Normal file
7
lang/src/runner/hako_module.toml
Normal file
@ -0,0 +1,7 @@
|
||||
[module]
|
||||
name = "selfhost.runner"
|
||||
version = "1.0.0"
|
||||
|
||||
[exports]
|
||||
Runner = "runner_facade.hako"
|
||||
|
||||
9
lang/src/runner/launcher.hako
Normal file
9
lang/src/runner/launcher.hako
Normal file
@ -0,0 +1,9 @@
|
||||
// launcher.hako — Minimal selfhost launcher (AOT target)
|
||||
// Goal: produce lang/bin/hakorune via tools/build_llvm.sh
|
||||
|
||||
static box Main {
|
||||
// No-args main() to avoid runtime Array allocation in AOT
|
||||
main(){
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
23
lang/src/runner/runner_facade.hako
Normal file
23
lang/src/runner/runner_facade.hako
Normal file
@ -0,0 +1,23 @@
|
||||
// runner_facade.hako — Phase 20.10 Script Runner (facade, draft)
|
||||
// Gate: HAKO_SCRIPT_RUNNER=1 (not wired by default in 20.10)
|
||||
|
||||
static box Runner {
|
||||
// Run facade. Returns process exit code (i64).
|
||||
run(entry, args){
|
||||
// Validate entry (simple dotted form expected)
|
||||
if (entry == null || entry == "") {
|
||||
call("env.console.warn/1", "VALIDATION");
|
||||
return 2;
|
||||
}
|
||||
// Trace invocation (stable short line for smokes) — opt-in
|
||||
// HAKO_SCRIPT_RUNNER_TRACE=1 で出力(既定は静穏)
|
||||
local tr = call("env.local.get/1", "HAKO_SCRIPT_RUNNER_TRACE");
|
||||
if tr && tr != "0" && tr != "false" {
|
||||
print("[script-runner] invoke");
|
||||
}
|
||||
// Future: pre-hooks (env snapshot / quiet-result policy)
|
||||
// Delegate to backend via existing CLI (placeholder; not wired in 20.10)
|
||||
// This facade is documented first; wiring is added from Rust side behind a gate.
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user