Stage-B: route FlowEntry context (using/extern) and default Stage-B entry
This commit is contained in:
@ -65,7 +65,10 @@ static box StageBMain {
|
||||
local externs_json = p.get_externs_json()
|
||||
local ast_json = p.parse_program2(src)
|
||||
local prefer = flags.prefer_cfg
|
||||
local jv0 = FlowEntryBox.emit_v0_from_ast(ast_json, prefer)
|
||||
local jv0 = FlowEntryBox.emit_v0_from_ast_with_context(ast_json, prefer, usings_json, null, externs_json)
|
||||
if jv0 == null {
|
||||
jv0 = FlowEntryBox.emit_v0_from_ast(ast_json, prefer)
|
||||
}
|
||||
// Attach usings metadata when available(Stage-B pipeline consumes via resolver)
|
||||
if jv0 == null || jv0 == "" { jv0 = "{\"version\":0,\"kind\":\"Program\",\"body\":[{\"type\":\"Return\",\"expr\":{\"type\":\"Int\",\"value\":0}}]}" }
|
||||
print(jv0)
|
||||
|
||||
@ -9,12 +9,27 @@ static box FlowEntryBox {
|
||||
emit_v0_from_ast(ast_json, prefer_cfg) {
|
||||
return PipelineV2.lower_stage1_to_mir(ast_json, prefer_cfg)
|
||||
}
|
||||
// Emit v0 with using context (alias/module maps) — prefer this when names need resolution
|
||||
// Emit v0 with using context(alias/module maps)
|
||||
emit_v0_from_ast_with_usings(ast_json, prefer_cfg, usings_json, modules_json) {
|
||||
print("[DEBUG FlowEntry] emit_v0_from_ast_with_usings called")
|
||||
local result = PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
print("[DEBUG FlowEntry] result=" + result)
|
||||
return result
|
||||
return PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
}
|
||||
|
||||
// Emit v0 with optional using / extern metadata(Stage‑B entry)
|
||||
emit_v0_from_ast_with_context(ast_json, prefer_cfg, usings_json, modules_json, externs_json) {
|
||||
local used_with_usings = 0
|
||||
local out = null
|
||||
if usings_json != null && usings_json != "" && usings_json != "[]" {
|
||||
out = PipelineV2.lower_stage1_to_mir_with_usings(ast_json, prefer_cfg, usings_json, modules_json)
|
||||
if out != null { used_with_usings = 1 }
|
||||
}
|
||||
if out == null {
|
||||
out = PipelineV2.lower_stage1_to_mir(ast_json, prefer_cfg)
|
||||
}
|
||||
if externs_json != null && externs_json != "" && externs_json != "[]" && used_with_usings == 0 {
|
||||
local j1 = PipelineV2.lower_stage1_to_mir_v1_with_meta(ast_json, prefer_cfg, externs_json)
|
||||
if j1 != null { out = MirJsonV1Adapter.to_v0(j1) }
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Emit v1 → v0 互換 JSON(unified mir_call を一旦生成して適応)。自己ホスト実行向け
|
||||
|
||||
Reference in New Issue
Block a user