feat(joinir/refactor): Phase 33-10-P1 ExitMetaCollector Box modularization
Box theory refactoring: Extract exit_bindings construction logic from pattern lowerers into focused, reusable ExitMetaCollector Box. **Changes**: 1. Created meta_collector.rs (+102 lines): - ExitMetaCollector::collect() builds exit_bindings from ExitMeta - Pure function (no side effects) - Reusable by all pattern lowerers 2. Updated pattern2_with_break.rs (-20 lines): - Use ExitMetaCollector::collect() instead of inline filter_map - Removed manual binding construction loop - Cleaner caller code 3. Made exit_line module public: - Allows pattern lowerers to use ExitMetaCollector - Clear module visibility boundaries **Box Design**: - Single responsibility: Convert ExitMeta + variable_map → exit_bindings - Pure function: No side effects, testable independently - Reusable: Can be used by Pattern 3, Pattern 4, etc. **Testing**: - Build: ✅ Success (1m 04s) - Execution: ✅ RC: 0 (Pattern 2 verified) - Regression: ✅ No issues **Metrics**: - New lines: +102 (meta_collector.rs) - Removed lines: -20 (pattern2_with_break.rs) - Net change: +82 lines - Code clarity: Significantly improved 🤖 Generated with Claude Code Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -179,21 +179,11 @@ impl MirBuilder {
|
||||
//
|
||||
// The loop variable's exit value needs to be reflected back to variable_map.
|
||||
// ExitMeta provides the correct JoinIR-local ValueId for k_exit parameter.
|
||||
use crate::mir::join_ir::lowering::inline_boundary::LoopExitBinding;
|
||||
// Phase 33-10-Refactor-P1: Use ExitMetaCollector Box to build exit_bindings
|
||||
use crate::mir::builder::control_flow::joinir::merge::exit_line::ExitMetaCollector;
|
||||
|
||||
// Phase 172-3: Build exit bindings from ExitMeta (provides actual k_exit parameter ValueId)
|
||||
let exit_bindings: Vec<LoopExitBinding> = exit_meta.exit_values
|
||||
.iter()
|
||||
.filter_map(|(carrier_name, join_exit_value)| {
|
||||
// Look up host slot from variable_map
|
||||
let host_slot = self.variable_map.get(carrier_name).copied()?;
|
||||
Some(LoopExitBinding {
|
||||
carrier_name: carrier_name.clone(),
|
||||
join_exit_value: *join_exit_value,
|
||||
host_slot,
|
||||
})
|
||||
})
|
||||
.collect();
|
||||
// Phase 33-10: Collect exit bindings from ExitMeta using Box
|
||||
let exit_bindings = ExitMetaCollector::collect(self, &exit_meta, debug);
|
||||
|
||||
// Phase 172-3: Build boundary with both condition_bindings and exit_bindings
|
||||
let mut boundary = crate::mir::join_ir::lowering::inline_boundary::JoinInlineBoundary::new_inputs_only(
|
||||
@ -203,14 +193,6 @@ impl MirBuilder {
|
||||
boundary.condition_bindings = condition_bindings;
|
||||
boundary.exit_bindings = exit_bindings.clone();
|
||||
|
||||
// Phase 172-3 Debug: Log exit bindings from ExitMeta
|
||||
for binding in &exit_bindings {
|
||||
eprintln!(
|
||||
"[cf_loop/pattern2] Phase 172-3: exit_binding '{}' JoinIR {:?} → HOST {:?}",
|
||||
binding.carrier_name, binding.join_exit_value, binding.host_slot
|
||||
);
|
||||
}
|
||||
|
||||
// Phase 189: Capture exit PHI result (now used for reconnect)
|
||||
let _ = self.merge_joinir_mir_blocks(&mir_module, Some(&boundary), debug)?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user