feat(.hako): CompilerBuilder.apply_all()配線追加 (Phase 1)
Exit PHI実装の準備として、.hakoコンパイラに CompilerBuilder.apply_all()呼び出しを追加 変更内容: - compiler_stageb.hako: parse_program2直後にapply_all()配線 - hako_module.toml: builder.mod export追加 - nyash.toml: モジュールマッピング追加 デバッグ: - HAKO_COMPILER_BUILDER_TRACE=1 で詳細ログ出力 - [compiler-builder] before/after で変換前後を確認可能 次のステップ: - Phase 2: BreakFinderBox実装 - Phase 3: PhiInjectorBox実装 - Phase 4: LoopSSA.stabilize_merges実装 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -14,6 +14,7 @@ using hako.compiler.entry.bundle_resolver as BundleResolver
|
|||||||
using lang.compiler.parser.box as ParserBox
|
using lang.compiler.parser.box as ParserBox
|
||||||
using lang.compiler.entry.func_scanner as FuncScannerBox
|
using lang.compiler.entry.func_scanner as FuncScannerBox
|
||||||
using lang.compiler.entry.using_resolver as Stage1UsingResolverBox
|
using lang.compiler.entry.using_resolver as Stage1UsingResolverBox
|
||||||
|
using lang.compiler.builder.mod as CompilerBuilder
|
||||||
|
|
||||||
// Phase 25.1c: CLI argument → source resolution
|
// Phase 25.1c: CLI argument → source resolution
|
||||||
static box StageBArgsBox {
|
static box StageBArgsBox {
|
||||||
@ -647,6 +648,26 @@ static box StageBDriverBox {
|
|||||||
// 既定で MIR 直出力は行わない(重い経路を避け、一行出力を保証)。
|
// 既定で MIR 直出力は行わない(重い経路を避け、一行出力を保証)。
|
||||||
local ast_json = p.parse_program2(body_src)
|
local ast_json = p.parse_program2(body_src)
|
||||||
|
|
||||||
|
// 6.3) Apply SSA transformations (CompilerBuilder pipeline)
|
||||||
|
{
|
||||||
|
local trace = env.get("HAKO_COMPILER_BUILDER_TRACE")
|
||||||
|
if trace != null && ("" + trace) == "1" {
|
||||||
|
local preview_len = 200
|
||||||
|
local ajson_len = ("" + ast_json).length()
|
||||||
|
if ajson_len < preview_len { preview_len = ajson_len }
|
||||||
|
print("[compiler-builder] before: " + ("" + ast_json).substring(0, preview_len) + "...")
|
||||||
|
}
|
||||||
|
|
||||||
|
ast_json = CompilerBuilder.apply_all(ast_json)
|
||||||
|
|
||||||
|
if trace != null && ("" + trace) == "1" {
|
||||||
|
local preview_len = 200
|
||||||
|
local ajson_len = ("" + ast_json).length()
|
||||||
|
if ajson_len < preview_len { preview_len = ajson_len }
|
||||||
|
print("[compiler-builder] after: " + ("" + ast_json).substring(0, preview_len) + "...")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 6.5) Dev-toggle: scan for function definitions (static box { method <name>(...) {...} })
|
// 6.5) Dev-toggle: scan for function definitions (static box { method <name>(...) {...} })
|
||||||
// Toggle: HAKO_STAGEB_FUNC_SCAN
|
// Toggle: HAKO_STAGEB_FUNC_SCAN
|
||||||
// Policy:
|
// Policy:
|
||||||
|
|||||||
@ -29,6 +29,7 @@ pipeline_v2.emit_return_box = "pipeline_v2/emit_return_box.hako"
|
|||||||
pipeline_v2.emit_binop_box = "pipeline_v2/emit_binop_box.hako"
|
pipeline_v2.emit_binop_box = "pipeline_v2/emit_binop_box.hako"
|
||||||
|
|
||||||
# Builder / SSA / Rewrite (scaffolds)
|
# Builder / SSA / Rewrite (scaffolds)
|
||||||
|
builder.mod = "builder/mod.hako"
|
||||||
builder.ssa.local = "builder/ssa/local_ssa.hako"
|
builder.ssa.local = "builder/ssa/local_ssa.hako"
|
||||||
builder.ssa.loop = "builder/ssa/loopssa.hako"
|
builder.ssa.loop = "builder/ssa/loopssa.hako"
|
||||||
builder.ssa.cond_inserter = "builder/ssa/cond_inserter.hako"
|
builder.ssa.cond_inserter = "builder/ssa/cond_inserter.hako"
|
||||||
|
|||||||
@ -121,8 +121,10 @@ path = "lang/src/shared/common/string_helpers.hako"
|
|||||||
"selfhost.shared.json.json_inst_encode_box" = "lang/src/shared/json/json_inst_encode_box.hako"
|
"selfhost.shared.json.json_inst_encode_box" = "lang/src/shared/json/json_inst_encode_box.hako"
|
||||||
"selfhost.shared.common.string_ops" = "lang/src/shared/common/string_ops.hako"
|
"selfhost.shared.common.string_ops" = "lang/src/shared/common/string_ops.hako"
|
||||||
"lang.compiler.pipeline_v2.using_resolver" = "lang/src/compiler/pipeline_v2/using_resolver_box.hako"
|
"lang.compiler.pipeline_v2.using_resolver" = "lang/src/compiler/pipeline_v2/using_resolver_box.hako"
|
||||||
|
"lang.compiler.builder.mod" = "lang/src/compiler/builder/mod.hako"
|
||||||
"lang.compiler.builder.ssa.localvar" = "lang/src/compiler/builder/ssa/local_ssa.hako"
|
"lang.compiler.builder.ssa.localvar" = "lang/src/compiler/builder/ssa/local_ssa.hako"
|
||||||
"lang.compiler.builder.ssa.loop" = "lang/src/compiler/builder/ssa/loopssa.hako"
|
"lang.compiler.builder.ssa.loop" = "lang/src/compiler/builder/ssa/loopssa.hako"
|
||||||
|
"lang.compiler.builder.ssa.loopssa" = "lang/src/compiler/builder/ssa/loopssa.hako"
|
||||||
"lang.compiler.builder.ssa.cond_inserter" = "lang/src/compiler/builder/ssa/cond_inserter.hako"
|
"lang.compiler.builder.ssa.cond_inserter" = "lang/src/compiler/builder/ssa/cond_inserter.hako"
|
||||||
"lang.compiler.builder.rewrite.special" = "lang/src/compiler/builder/rewrite/special.hako"
|
"lang.compiler.builder.rewrite.special" = "lang/src/compiler/builder/rewrite/special.hako"
|
||||||
"lang.compiler.builder.rewrite.known" = "lang/src/compiler/builder/rewrite/known.hako"
|
"lang.compiler.builder.rewrite.known" = "lang/src/compiler/builder/rewrite/known.hako"
|
||||||
|
|||||||
Reference in New Issue
Block a user