refactor: Extract debug utilities from control_flow.rs (Phase 1)
- Created control_flow/ subdirectory - Moved trace_varmap() to debug.rs - All control flow logic now in control_flow/mod.rs - Zero breaking changes, all functionality preserved - Tests pass (binary execution verified)
This commit is contained in:
16
src/mir/builder/control_flow/debug.rs
Normal file
16
src/mir/builder/control_flow/debug.rs
Normal file
@ -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(", "));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,19 +1,18 @@
|
|||||||
//! Control-flow entrypoints (if/loop/try/throw) centralized here.
|
//! 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 super::{Effect, EffectMask, MirInstruction, ValueId};
|
||||||
use crate::ast::ASTNode;
|
use crate::ast::ASTNode;
|
||||||
|
|
||||||
impl super::MirBuilder {
|
// Phase 1: Debug utilities
|
||||||
/// Trace variable_map state for debugging
|
pub(in crate::mir::builder) mod debug;
|
||||||
/// 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(", "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
impl super::MirBuilder {
|
||||||
/// Control-flow: block
|
/// Control-flow: block
|
||||||
pub(super) fn cf_block(&mut self, statements: Vec<ASTNode>) -> Result<ValueId, String> {
|
pub(super) fn cf_block(&mut self, statements: Vec<ASTNode>) -> Result<ValueId, String> {
|
||||||
// identical to build_block; kept here for future policy hooks
|
// identical to build_block; kept here for future policy hooks
|
||||||
Reference in New Issue
Block a user