selfhost-compiler: make EmitterBox/MirEmitterBox static; call as Class.method to avoid NewBox→birth warnings and stabilize JSON emission path
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// EmitterBox — thin wrapper to emit JSON v0 (extracted)
|
||||
box EmitterBox {
|
||||
static box EmitterBox {
|
||||
emit_program(json, usings_json) {
|
||||
if json == null { return json }
|
||||
// Normalize usings payload to at least an empty array so meta.usings is always present
|
||||
@ -20,7 +20,3 @@ box EmitterBox {
|
||||
return head + "\"meta\":{\"usings\":" + payload + "}" + tail
|
||||
}
|
||||
}
|
||||
|
||||
static box EmitterStub {
|
||||
main(args) { return 0 }
|
||||
}
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
// Scope: Return(Int) only (const + ret). Safe default to 0 when not found.
|
||||
// Future: add Binary/Compare/ExternCall/BoxCall lowering incrementally.
|
||||
|
||||
box MirEmitterBox {
|
||||
static box MirEmitterBox {
|
||||
// Extract first Return(Int) value from Stage-1 JSON (very small string scan)
|
||||
_extract_return_int(ast_json) {
|
||||
if ast_json == null { return 0 }
|
||||
@ -47,6 +47,3 @@ box MirEmitterBox {
|
||||
return s
|
||||
}
|
||||
}
|
||||
|
||||
static box MirEmitterStub { main(args) { return 0 } }
|
||||
|
||||
|
||||
@ -115,12 +115,10 @@ static box Main {
|
||||
|
||||
if emit_mir == 1 {
|
||||
// Lower minimal AST to MIR JSON (Return(Int) only for MVP)
|
||||
local mir = new MirEmitterBox()
|
||||
json = mir.emit_mir_min(ast_json)
|
||||
json = MirEmitterBox.emit_mir_min(ast_json)
|
||||
} else {
|
||||
// Emit Stage‑1 JSON with metadata
|
||||
local emitter = new EmitterBox()
|
||||
json = emitter.emit_program(ast_json, me._usings)
|
||||
json = EmitterBox.emit_program(ast_json, me._usings)
|
||||
}
|
||||
|
||||
// Output JSON
|
||||
|
||||
Reference in New Issue
Block a user