feat(joinir): Phase 171-172 Issue 4 - LoopScopeShapeBuilder unified initialization

Eliminates 50-60 lines of duplicated LoopScopeShape initialization across all 4 patterns.

**Changes**:
- New: `loop_scope_shape_builder.rs` with factory methods
- `empty_body_locals()`: For Pattern 1, 3 (condition-only analysis)
- `with_body_locals()`: For Pattern 2, 4 (AST-based body variable extraction)
- Updated all 4 patterns to use unified builder
- Includes unit tests for both factory methods

**Impact**:
- Pattern 1: 11 lines → 6 lines (5-line reduction)
- Pattern 2: 18 lines → 8 lines (10-line reduction)
- Pattern 3: 11 lines → 6 lines (5-line reduction)
- Pattern 4: 18 lines → 8 lines (10-line reduction)
- Total: 58 lines → 28 lines (30-line reduction, ~52%)

**Test**:
- cargo build --release:  PASS
- cargo test --release:  720/800 PASS (same as before)
- Unit tests:  3/3 PASS

Phase 171-172 Stage 1: 25-30% deletion target (30 lines achieved)
This commit is contained in:
nyash-codex
2025-12-08 03:39:46 +09:00
parent 5ba11468e4
commit 5e3dec99e3
6 changed files with 255 additions and 80 deletions

View File

@ -23,11 +23,15 @@
//! Phase 33-22: Common Pattern Infrastructure
//! - common_init.rs: CommonPatternInitializer for unified initialization
//! - conversion_pipeline.rs: JoinIRConversionPipeline for unified conversion flow
//!
//! Phase 171-172: Refactoring Infrastructure
//! - loop_scope_shape_builder.rs: Unified LoopScopeShape initialization (Issue 4)
pub(in crate::mir::builder) mod ast_feature_extractor;
pub(in crate::mir::builder) mod common_init;
pub(in crate::mir::builder) mod conversion_pipeline;
pub(in crate::mir::builder) mod exit_binding;
pub(in crate::mir::builder) mod loop_scope_shape_builder;
pub(in crate::mir::builder) mod pattern1_minimal;
pub(in crate::mir::builder) mod pattern2_with_break;
pub(in crate::mir::builder) mod pattern3_with_if_phi;