Files
hakorune/src/mir/builder/control_flow/normalization/mod.rs

26 lines
823 B
Rust
Raw Normal View History

refactor(control_flow): Phase 134 P0 - Normalization entry point SSOT Consolidate dual entry points into unified NormalizationPlan system: Problem: - Dual entry points: try_normalized_shadow() + suffix_router_box - ~220 lines of duplicated pattern detection logic - Maintenance burden: changes required in two places Solution: - New normalization module with Box-First architecture - NormalizationPlanBox: Single source of truth for pattern detection - NormalizationExecuteBox: Single source of truth for execution Implementation: - src/mir/builder/control_flow/normalization/ (new module) - README.md: Design contract (SSOT) - plan.rs: NormalizationPlan data structure - plan_box.rs: Pattern detection (7 unit tests) - execute_box.rs: Execution logic - mod.rs: Module integration Refactored files: - routing.rs::try_normalized_shadow(): 165 → 87 lines (-78 lines) - suffix_router_box::try_lower_loop_suffix(): 258 → 116 lines (-142 lines) Pattern support maintained: - Phase 131: loop(true) only (consumed: 1) - Phase 132: loop + single post (consumed: 3) - Phase 133: loop + multiple post (consumed: 2+N) Box-First principles: - Plan Box: Detection responsibility only - Execute Box: Execution responsibility only - README.md: Contract documentation (SSOT) - Clear separation enables independent testing Test results: - cargo test --lib: 1186 PASS (10 new tests added) - Phase 133 VM/LLVM EXE: PASS (exit code 6) - Phase 132 LLVM EXE: PASS (exit code 3) - Phase 131 LLVM EXE: PASS (exit code 1) Benefits: - Code duplication eliminated (~220 lines) - Single source of truth for normalization decisions - Improved maintainability and testability - Future-proof extensibility (easy to add new patterns) Default behavior unchanged: Dev-only guard maintained Related: Phase 134 normalization infrastructure improvement 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-18 22:29:29 +09:00
//! Normalization entry point consolidation (Phase 134 P0)
//!
//! ## Purpose
//!
//! Consolidate the dual entry points for Normalized shadow processing:
//! - `routing.rs::try_normalized_shadow()` (loop-only)
//! - `suffix_router_box::try_lower_loop_suffix()` (loop + post)
//!
//! Both now use the same NormalizationPlanBox for pattern detection.
//!
//! ## Architecture
//!
//! - **NormalizationPlanBox**: SSOT for "what to normalize" decision
//! - **NormalizationExecuteBox**: SSOT for "how to execute" normalization
//! - **NormalizationPlan**: Data structure for plan details
//!
//! See README.md for full design and contract documentation.
mod plan;
mod plan_box;
mod execute_box;
pub use plan::{NormalizationPlan, PlanKind};
pub use plan_box::NormalizationPlanBox;
pub use execute_box::NormalizationExecuteBox;