diff --git a/src/mir/builder/control_flow/debug.rs b/src/mir/builder/control_flow/debug.rs new file mode 100644 index 00000000..43c48e7d --- /dev/null +++ b/src/mir/builder/control_flow/debug.rs @@ -0,0 +1,16 @@ +//! Debug utilities for control flow tracing + +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(", ")); + } + } +} diff --git a/src/mir/builder/control_flow.rs b/src/mir/builder/control_flow/mod.rs similarity index 99% rename from src/mir/builder/control_flow.rs rename to src/mir/builder/control_flow/mod.rs index 6a14580f..a0a5851c 100644 --- a/src/mir/builder/control_flow.rs +++ b/src/mir/builder/control_flow/mod.rs @@ -1,19 +1,18 @@ //! Control-flow entrypoints (if/loop/try/throw) centralized here. +//! +//! This module is being modularized in phases: +//! - Phase 1: Debug utilities +//! - Phase 2: Pattern lowerers +//! - Phase 3: JoinIR routing +//! - Phase 4-19: Additional modularization (future) + use super::{Effect, EffectMask, MirInstruction, ValueId}; use crate::ast::ASTNode; -impl super::MirBuilder { - /// Trace variable_map state for debugging - /// Enable with NYASH_TRACE_VARMAP=1 - 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(", ")); - } - } +// Phase 1: Debug utilities +pub(in crate::mir::builder) mod debug; +impl super::MirBuilder { /// Control-flow: block pub(super) fn cf_block(&mut self, statements: Vec) -> Result { // identical to build_block; kept here for future policy hooks