stage-b (P0): stabilize entry — compiler_stageb.hako now emits Stage‑1 Program(JSON v0) directly (one-line), avoiding heavy MIR path; FlowEntry prefers v1→v0 first; noisy debug prints in pipeline with_usings gated. Quick core/stageb canaries PASS.

This commit is contained in:
nyash-codex
2025-11-02 07:22:40 +09:00
parent 4ee61b1477
commit 7180579cf8
3 changed files with 27 additions and 17 deletions

View File

@ -1,7 +1,6 @@
// Stage-B compiler entry — ParserBox → FlowEntry emit-only
using lang.compiler.parser.box as ParserBox
using lang.compiler.pipeline_v2.flow_entry as FlowEntryBox
static box StageBMain {
// Minimal StageB driver: parse args/env, extract main body if wrapped in `box Main { static method main(){...} }`,
@ -68,13 +67,11 @@ static box StageBMain {
if body_src == null { body_src = src }
// 5) Parse and emit MIR(JSON v0)
// 5) Parse and emit Stage1 JSON v0 (Program)
// Bridge(JSON v0) が Program v0 を受け取り MIR に lowering するため、ここでは AST(JSON v0) を出力する。
// 既定で MIR 直出力は行わない(重い経路を避け、一行出力を保証)。
local ast_json = p.parse_program2(body_src)
local prefer = 1
local out = FlowEntryBox.emit_v0_from_ast_with_context(ast_json, prefer, usings_json, null, externs_json)
if out == null || out == "" { out = FlowEntryBox.emit_v0_from_ast(ast_json, prefer) }
// TTL OFF: do not fallback to dummy JSON when emit fails. Empty output surfaces failure to caller.
print(out)
print(ast_json)
return 0
}
}