Unify condition lowering logic across Pattern 2/4 with trait-based API. New infrastructure: - condition_lowering_box.rs: ConditionLoweringBox trait + ConditionContext (293 lines) - ExprLowerer implements ConditionLoweringBox trait (+51 lines) Pattern migrations: - Pattern 2 (loop_with_break_minimal.rs): Use trait API - Pattern 4 (loop_with_continue_minimal.rs): Use trait API Benefits: - Unified condition lowering interface - Extensible for future lowering strategies - Clean API boundary between patterns and lowering logic - Zero code duplication Test results: 911/911 PASS (+2 new tests) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
103 lines
11 KiB
Plaintext
103 lines
11 KiB
Plaintext
╔══════════════════════════════════════════════════════════════════════════════╗
|
|
║ Phase 243-EX Investigation Complete ║
|
|
║ JoinIR Refactoring Analysis ║
|
|
╚══════════════════════════════════════════════════════════════════════════════╝
|
|
|
|
📊 CURRENT STATE
|
|
┌──────────────────────────────────────────────────────────────────────────────┐
|
|
│ 74 files │ 23,183 lines │ 52 root files (TOO FLAT!) │ 15 large files (>500) │
|
|
└──────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
🎯 TOP 3 OPPORTUNITIES
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ 1. ConditionLoweringBox ⭐⭐⭐ │
|
|
│ Impact: 19 files │ Effort: Medium │ Value: HIGH │
|
|
│ Unify: condition_lowerer.rs + 4 related modules (1,639 lines) │
|
|
│ Phase: 244 (1-2 days) │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ 2. CarrierManagerBox ⭐⭐ │
|
|
│ Impact: 7 files │ Effort: Low │ Value: Medium │
|
|
│ Extend: Phase 228 infrastructure (carrier lifecycle) │
|
|
│ Phase: 245 (0.5-1 day) │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ 3. Module Reorganization ⭐⭐ │
|
|
│ Impact: All 74 files │ Effort: Large │ Value: Medium │
|
|
│ Result: 52 root files → 7 directories (86% reduction) │
|
|
│ Phase: 246 (1-2 days) │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
🗺️ ROADMAP (Phases 244-248)
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ Phase 244: ConditionLoweringBox │ 1-2 days │ Medium Risk │ ⭐⭐⭐ │
|
|
│ Phase 245: CarrierManagerBox │ 0.5-1 day │ Low Risk │ ⭐⭐ │
|
|
│ Phase 246: Module Reorganization │ 1-2 days │ Low Risk │ ⭐⭐ │
|
|
│ Phase 247: PatternDetectorBox │ 1 day │ Medium Risk │ ⭐⭐ │
|
|
│ Phase 248: Legacy Cleanup │ 0.5 day │ Low Risk │ ⭐ │
|
|
├─────────────────────────────────────────────────────────────────────────────┤
|
|
│ TOTAL: 4-6 days │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
📈 PROPOSED STRUCTURE (Phase 246)
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ BEFORE (Flat): │ AFTER (Hierarchical): │
|
|
│ │ │
|
|
│ src/mir/join_ir/ │ src/mir/join_ir/lowering/ │
|
|
│ lowering/ │ ├── core/ (condition, carrier, exit) │
|
|
│ ├── *.rs (52 files) │ ├── infrastructure/ (expr, scope, boundary) │
|
|
│ └── (5 subdirs) │ ├── patterns/ (detection, loop, if) │
|
|
│ │ ├── specialized/ (function-specific) │
|
|
│ │ └── generic_case_a/ (generic) │
|
|
│ │ │
|
|
│ Navigation: HARD ❌ │ Navigation: EASY ✅ │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
✅ INFRASTRUCTURE READY (Phases 227-242)
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ ✅ Phase 227: CarrierRole (LoopState vs ConditionOnly) │
|
|
│ ✅ Phase 228: CarrierInit (FromHost vs BoolConst) │
|
|
│ ✅ Phase 231: ExprLowerer + ScopeManager trait │
|
|
│ ✅ Phase 33-10: ExitLineReconnector (already boxified!) │
|
|
│ ✅ Phase 240-EX: ExprLowerer integrated (Pattern 3) │
|
|
│ ✅ Phase 242-EX-A: Complex conditions (BinaryOp LHS) │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
🎯 SUCCESS METRICS
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ Test Status: 909 PASS → 909 PASS (maintained) ✅ │
|
|
│ Root Files: 52 → 7 directories (86% reduction) ✅ │
|
|
│ Unified APIs: 3 new boxes (Condition, Carrier, Pattern) ✅ │
|
|
│ Duplication: Consolidate 1,639 lines ✅ │
|
|
│ Maintainability: Single responsibility per module ✅ │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
📚 DOCUMENTS GENERATED
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ 1. PHASE_243_SUMMARY.md (This overview - 5K words) │
|
|
│ 2. phase243-ex-summary.md (Quick reference - 2K words) │
|
|
│ 3. phase243-ex-refactoring-opportunities.md (Full report - 12K words) │
|
|
│ 4. phase243-ex-dependency-graph.md (Visual graphs - 8K words) │
|
|
│ 5. phase243-ex-visual-summary.txt (ASCII art - this file) │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
🔒 RISK MITIGATION
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ ✅ Test-Driven: Run 909 tests after each step │
|
|
│ ✅ Backward Compat: Shims maintain existing API during migration │
|
|
│ ✅ Incremental: One phase at a time (can pause/adjust) │
|
|
│ ✅ Rollback: Git commits per phase (easy to revert) │
|
|
│ ✅ No Logic Changes: Initial refactoring is pure reorganization │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
🚀 NEXT ACTIONS
|
|
┌─────────────────────────────────────────────────────────────────────────────┐
|
|
│ 1. Review this summary + linked documents │
|
|
│ 2. Approve Phase 244 (ConditionLoweringBox) │
|
|
│ 3. Start implementation (1-2 days) │
|
|
│ 4. Track progress in CURRENT_TASK.md │
|
|
└─────────────────────────────────────────────────────────────────────────────┘
|
|
|
|
╔══════════════════════════════════════════════════════════════════════════════╗
|
|
║ Status: ✅ Investigation Complete - Ready for Phase 244 Implementation ║
|
|
║ Confidence: HIGH │ Risk: LOW-MEDIUM │ Recommendation: PROCEED 🚀 ║
|
|
╚══════════════════════════════════════════════════════════════════════════════╝
|