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

@ -314,6 +314,24 @@ impl MirBuilder {
self.debug_scope_stack.last().cloned()
}
// ----------------------
// Compile trace helpers (dev only; env-gated)
// ----------------------
#[inline]
pub(super) fn compile_trace_enabled() -> bool {
std::env::var("NYASH_MIR_COMPILE_TRACE")
.ok()
.as_deref()
== Some("1")
}
#[inline]
pub(super) fn trace_compile<S: AsRef<str>>(&self, msg: S) {
if Self::compile_trace_enabled() {
eprintln!("[mir-compile] {}", msg.as_ref());
}
}
// ----------------------
// Method tail index (performance helper)
// ----------------------