2025-12-05 21:11:43 +09:00
|
|
|
//! Debug utilities for control flow tracing.
|
|
|
|
|
//!
|
|
|
|
|
//! This module provides diagnostic tools for tracing and debugging
|
|
|
|
|
//! control flow behavior during MIR construction.
|
|
|
|
|
//!
|
|
|
|
|
//! # Environment Variables
|
|
|
|
|
//!
|
|
|
|
|
//! - `NYASH_TRACE_VARMAP=1` - Enable variable map tracing
|
2025-12-05 20:41:19 +09:00
|
|
|
|
|
|
|
|
use super::super::MirBuilder;
|
|
|
|
|
|
|
|
|
|
impl MirBuilder {
|
|
|
|
|
/// Trace variable_map state for debugging
|
|
|
|
|
/// Enable with NYASH_TRACE_VARMAP=1
|
|
|
|
|
pub(in crate::mir::builder) fn trace_varmap(&self, context: &str) {
|
|
|
|
|
if std::env::var("NYASH_TRACE_VARMAP").is_ok() {
|
|
|
|
|
let vars: Vec<_> = self.variable_map.iter()
|
|
|
|
|
.map(|(k, v)| format!("{}={:?}", k, v))
|
|
|
|
|
.collect();
|
|
|
|
|
eprintln!("[varmap/{}] {{{}}}", context, vars.join(", "));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|