Fix MIR builder me-call recursion and add compile tracing

This commit is contained in:
nyash-codex
2025-11-17 19:53:44 +09:00
parent c551131941
commit f300b9f3c9
7 changed files with 68 additions and 15 deletions

View File

@ -87,6 +87,8 @@ impl super::MirBuilder {
if name == "Main" {
main_static = Some((name.clone(), methods.clone()));
} else {
// Dev: trace which static box is being lowered (env-gated)
self.trace_compile(format!("lower static box {}", name));
// 🎯 箱理論: 各static boxに専用のコンパイルコンテキストを作成
// これにより、using文や前のboxからのメタデータ汚染を構造的に防止
// スコープを抜けると自動的にコンテキストが破棄される
@ -99,17 +101,17 @@ impl super::MirBuilder {
if let N::FunctionDeclaration { params, body, .. } = mast {
let func_name = format!("{}.{}{}", name, mname, format!("/{}", params.len()));
self.lower_static_method_as_function(func_name, params.clone(), body.clone())?;
self.static_method_index
.entry(mname.clone())
.or_insert_with(Vec::new)
.push((name.clone(), params.len()));
self.static_method_index
.entry(mname.clone())
.or_insert_with(Vec::new)
.push((name.clone(), params.len()));
}
}
}
// 🎯 箱理論: コンテキストをクリア(スコープ終了で自動破棄)
// これにより、次のstatic boxは汚染されていない状態から開始される
self.compilation_context = None;
}
// 🎯 箱理論: コンテキストをクリア(スコープ終了で自動破棄)
// これにより、次のstatic boxは汚染されていない状態から開始される
self.compilation_context = None;
}
} else {
// Instance box: register type and lower instance methods/ctors as functions