Files
hakorune/docs/development/current/main/joinir-architecture-overview.md

311 lines
18 KiB
Markdown
Raw Normal View History

feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
# JoinIR Architecture Overview (20251208)
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
このドキュメントは、JoinIR ライン全体Loop/If lowering, ExitLine, Boundary, 条件式 lowering
「箱」と「契約」を横串でまとめた設計図だよ。selfhost / JsonParser / hako_check など、
どの呼び出し元から見てもここを見れば「JoinIR 層の責務と流れ」が分かるようにしておく。
変更があったら、Phase ドキュメントではなく **このファイルを随時更新する** 方針。
---
## 1. 不変条件Invariants
JoinIR ラインで守るべきルールを先に書いておくよ:
1. **JoinIR 内部は JoinIR ValueId だけ**
- JoinIR lowering が発行する `JoinInst``ValueId` は、すべて `alloc_value()` で割り当てるローカル ID。
- Rust/MIR 側の ValueId`builder.variable_map` に入っている IDは、JoinIR には直接持ち込まない。
2. **host ↔ join の橋渡しは JoinInlineBoundary 系だけ**
- host から JoinIR への入力(ループ変数 / 条件専用変数)は
- `JoinInlineBoundary.join_inputs + host_inputs`
- `JoinInlineBoundary.condition_bindings`ConditionBinding
だけで接続する。
- 出力(キャリアの出口)は `JoinInlineBoundary.exit_bindings` に一本化する。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
3. **LoopHeader PHI を SSA の単一源泉にする**
- ループ変数とキャリアは **LoopHeaderPhiBuilder/LoopHeaderPhiInfo** でヘッダ PHI を作り、これを「現在値」の SSOT にする。
- exit 用の PHI も組むが、変数再接続や expr_result 収集はヘッダ PHI を経由して行うSSAundef 防止)。
4. **式としての戻り値とキャリア更新を分離する**
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 「ループが式として値を返す」ケース(例: `let r = loop_min_while(...)`)の出口は **exit_phi_builder** が扱う。
- 「ループが状態更新だけする」ケース(例: `trim``start/end`)の出口は **ExitLineExitMeta / ExitBinding / ExitLineReconnector** だけが扱う。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
5. **ループ制御 vs 条件式の分離**
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- ループの「形」Pattern14, LoopFeaturesは control-flow 専用の箱が担当。
- 条件式(`i < len && (ch == " " || ch == "\t")` 等)は **BoolExprLowerer / condition_to_joinir** が担当し、
ループパターンは boolean ValueId だけを受け取る。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
6. **FailFast**
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- JoinIR が対応していないループパターン / if パターンは、必ず `[joinir/freeze]` 等で明示的にエラーにする。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- LoopBuilder 等へのサイレントフォールバックは禁止。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
---
## 2. 主な箱と責務
### 2.1 Loop 構造・検出ライン
- **LoopFeatures / LoopPatternKind / router**
- ファイル:
- `src/mir/loop_pattern_detection.rs`
- `src/mir/builder/control_flow/joinir/patterns/router.rs`
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- `src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- AST から break/continue/ifelse PHI などの特徴を抽出ast_feature_extractor
- `classify(&LoopFeatures)` で Pattern14 に分類し、テーブル駆動の `LOOP_PATTERNS` でルーティング。
- ルータ順序は P4(continue) → P3(ifphi) → P1(simple) → P2(break) で固定(優先度フィールドはデバッグ用)。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **Pattern Lowerers (Pattern14)**
- ファイル例:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- `pattern1_minimal.rs`Simple while
- `pattern2_with_break.rs`break 付き / Trim 昇格パスを含む)
- `pattern3_with_if_phi.rs`ifphi キャリア)
- `pattern4_with_continue.rs`continue を Select で表現)
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
- LoopScopeShape / AST / LoopFeatures を入力として JoinIR の `JoinModule` を構築。
- `JoinFragmentMeta{ expr_result, exit_meta }` を返し、出口情報を ExitLine に渡す。
- host/MIR の ValueId は一切扱わないJoinIR ローカルの ValueId のみ)。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **Scope / Env Builders**
- `loop_scope_shape_builder.rs`: ループ本体ローカルの収集、LoopScopeShape 統一生成。
- `condition_env_builder.rs`: 条件専用変数の環境と ConditionBinding を一括構築。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **CommonPatternInitializer** (Phase 33-22)
- ファイル: `src/mir/builder/control_flow/joinir/patterns/common_init.rs`
- 責務:
- 全 Pattern 共通の初期化ロジック統一化(ループ変数抽出 + CarrierInfo 構築)。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 全パターンで boundary.loop_var_name を確実に設定し、SSAundef を防ぐ。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **JoinIRConversionPipeline** (Phase 33-22)
- ファイル: `src/mir/builder/control_flow/joinir/patterns/conversion_pipeline.rs`
- 責務:
- JoinIR → MIR 変換フロー統一化JoinModule → MirModule → merge_joinir_mir_blocks
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- JoinIR/MIR の関数数・ブロック数をログ出力し、全パターンが同じ入口でマージする。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
### 2.2 条件式ライン(式の箱)
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **BoolExprLowerer / condition_to_joinir**
- ファイル:
- `src/mir/join_ir/lowering/bool_expr_lowerer.rs`
- `src/mir/join_ir/lowering/condition_to_joinir.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 通常の if/while 条件を MIR Compare/BinOp/UnaryOp へ lowering。
- ループ lowerer 用の「AST 条件 → JoinIR Compute 命令列」を ConditionEnv とセットで構築。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **ConditionEnv/ConditionBinding + ConditionEnvBuilder**
- ファイル:
- `src/mir/join_ir/lowering/condition_env.rs`
- `src/mir/builder/control_flow/joinir/patterns/condition_env_builder.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 変数名→JoinIR ValueId の環境を組み立て、host↔join の橋渡しを ConditionBinding に明示する。
- Pattern 2 では break 条件の全変数をスキャンし、JoinInlineBoundary.condition_bindings に渡す。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **LoopConditionScopeBoxPhase 170-D 実装済み)**
- ファイル: `src/mir/loop_pattern_detection/loop_condition_scope.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 条件式の各変数を LoopParam / OuterLocal / LoopBodyLocal に分類。
- 関数パラメータ誤分類バグは `condition_var_analyzer.rs` の修正で解消済みOuterLocal として扱う)。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **LoopBodyCarrierPromoterPhase 171-C-2 実装済み)**
- ファイル: `src/mir/loop_pattern_detection/loop_body_carrier_promoter.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- LoopBodyLocal を Trim パターンとして bool キャリアへ昇格substring + equality 連鎖を検出)。
- 昇格成功 → CarrierInfo に統合し Pattern 2/4 へ橋渡し。昇格失敗は FailFast。
- Pattern 2 は安全な Trim なら実際に前処理substring 生成 + 空白比較の初期化)を emit してから JoinIR lowering。
- Pattern 4 は Trim 昇格が起きた場合はガード付きでエラーにし、未実装を明示FailFast
feat(joinir): Phase 174 - JsonParser complex loop P5 extension design - Task 174-1: Complex loop inventory (_parse_string/_parse_array/_parse_object) - Analyzed remaining JsonParser loops for P5 expansion potential - Identified _parse_string as most Trim-like structure (99% similarity) - Documented complexity scores and minimization potential - Task 174-2: Selected _parse_string as next P5 target (closest to Trim) - Reason: LoopBodyLocal 'ch' usage matches Trim pattern exactly - Structure: loop(pos < len) + substring + char comparison + break - Minimization: Remove escape/buffer/continue → identical to Trim - Task 174-3: Design doc for P5B extension (TrimLoopHelper reuse strategy) - File: docs/development/current/main/phase174-jsonparser-p5b-design.md - Strategy: Reuse existing TrimLoopHelper without modifications - Proven: Pattern applies to any character comparison, not just whitespace - Task 174-4: Minimal PoC (_parse_string without escape) successful - Test: local_tests/test_jsonparser_parse_string_min.hako - Result: [pattern2/trim] Safe Trim pattern detected ✅ - Detection: Trim with literals=['"'] (quote instead of whitespace) - Routing: Added whitelist entries for JsonParserStringTest methods - Task 174-5: Documentation updates - Updated CURRENT_TASK.md with Phase 174 summary - Updated joinir-architecture-overview.md with P5 generality proof - Created phase174-jsonparser-loop-inventory-2.md (detailed analysis) - Created phase174-jsonparser-p5b-design.md (implementation strategy) Success Criteria Met: ✅ _parse_string minimized version runs on P5 pipeline ✅ TrimLoopHelper works with '"' (non-whitespace character) ✅ Proven: Trim pattern is character-comparison-generic, not whitespace-specific ✅ Two new design docs (inventory + design) ✅ Phase 175+ roadmap established (multi-carrier, escape sequences) Technical Achievement: The P5 Trim pipeline successfully handled a quote-detection loop with zero code changes, proving the architecture's generality beyond whitespace trimming.
2025-12-08 13:08:44 +09:00
- 汎用性:
- Phase 173 で `_skip_whitespace`JsonParserが Trim パターンで動作確認済み。
- Phase 174 で `_parse_string` 最小化版(終端クォート検出)でも動作確認済み。
- → 空白文字以外の文字比較ループにも対応可能TrimLoopHelper の汎用性実証)。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **ContinueBranchNormalizer / LoopUpdateAnalyzer**
- ファイル:
- `src/mir/join_ir/lowering/continue_branch_normalizer.rs`
- `src/mir/join_ir/lowering/loop_update_analyzer.rs`
- 責務:
- else-continue を then-continue へ正規化し、Select ベースの continue を簡潔にする。
- ループ本体で実際に更新されるキャリアだけを抽出Pattern 4 で不要キャリアを排除)。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
### 2.3 キャリア / Exit / Boundary ライン
- **CarrierInfo / LoopUpdateAnalyzer**
- ファイル:
- `src/mir/join_ir/lowering/carrier_info.rs`
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- `src/mir/join_ir/lowering/loop_update_analyzer.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- ループで更新される変数carrierを検出し、UpdateExpr を保持。
- Pattern 4 では実際に更新されるキャリアだけを残す。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **ExitMeta / JoinFragmentMeta**
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- ファイル: `carrier_info.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- JoinIR lowerer が出口の JoinIR ValueId を記録expr_result とキャリアを明確に分離)。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **LoopHeader PHI Builder**
- ファイル:
- `src/mir/builder/control_flow/joinir/merge/loop_header_phi_info.rs`
- `loop_header_phi_builder.rs`
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- ループ変数とキャリアの PHI をヘッダブロックに生成し、entry/latch の 2 入力で SSA を確立。
- instruction_rewriter が latch 側を埋めた後に finalize して挿入する。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **JoinInlineBoundary**
- ファイル: `src/mir/join_ir/lowering/inline_boundary.rs`
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 主フィールド:
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- `join_inputs / host_inputs`:ループパラメータの橋渡し
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- `condition_bindings`条件専用変数の橋渡しJoinIR ValueId を明示)
- `exit_bindings`キャリア出口の橋渡しcarrier 名を明示)
- `expr_result` / `loop_var_name`expr result / ヘッダ PHI 生成用のメタ情報
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- 「host ↔ JoinIR」の境界情報の SSOT。各パターン lowerer がここに全て詰めてから merge する。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **BoundaryInjector**
- ファイル: `src/mir/builder/joinir_inline_boundary_injector.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- `join_inputs``condition_bindings` を entry block に Copy で注入し、JoinIR ローカル ID と host ID を接続。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- **ExitLine (ExitMetaCollector / ExitLineReconnector / ExitLineOrchestrator)**
- ファイル:
- `src/mir/builder/control_flow/joinir/merge/exit_line/mod.rs`
- `exit_line/meta_collector.rs`
- `exit_line/reconnector.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- ExitMeta から exit_bindings を構築Collector
- 変数再接続はヘッダ PHI の dst を使って `builder.variable_map` を更新Reconnector
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- expr 用の PHI には一切触れないcarrier 専用ライン)。
- **JoinInlineBoundaryBuilderPhase 200-2 / Phase 201 完了)**
- ファイル: `src/mir/join_ir/lowering/inline_boundary_builder.rs`
- 責務:
- JoinInlineBoundary の構築を Builder パターンで統一化。
- フィールド直書きの散乱を防ぎ、inputs/outputs/condition_bindings/exit_bindings/loop_var_name/expr_result の設定を fluent API で実施。
- **Phase 201 で Pattern1/2/3/4 全てに適用完了**(境界情報組み立てを 1 箇所に集約)。
- **JoinIRVerifierPhase 200-3 追加)**
- ファイル: `src/mir/builder/control_flow/joinir/merge/mod.rs`debug_assertions 専用関数)
- 責務:
- LoopHeader PHI / ExitLine 契約をデバッグビルドで検証する門番。
- `verify_loop_header_phis()`: loop_var_name がある場合にヘッダ PHI が存在するか確認。
- `verify_exit_line()`: exit_bindings が exit block に対応しているか確認。
- `verify_joinir_contracts()`: merge_joinir_mir_blocks() の最後で全契約を一括チェック。
- release ビルドでは完全に除去される(`#[cfg(debug_assertions)]`)。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
### 2.4 expr result ライン(式としての戻り値)
- **exit_phi_builder**
- ファイル: `src/mir/builder/control_flow/joinir/merge/exit_phi_builder.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- JoinIR fragment が `expr_result` を持つときに exit ブロックへ PHI を生成。
- carrier_inputs も受け取り exit ブロックに PHI を作るが、再接続の SSOT は LoopHeader PHIExitLine はヘッダ PHI を使用)。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- **InstructionRewriter**
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
- ファイル: `instruction_rewriter.rs`
- 責務:
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
- continuation 関数k_exitをスキップし、Return → exit ブロック Jump に変換。
- `JoinFragmentMeta.expr_result` と exit_bindings をヘッダ PHI 経由で収集し、`exit_phi_inputs` / `carrier_inputs` を復活させたSSAundef 修正済み)。
- tail call を Branch/Jump に書き換えつつ、LoopHeaderPhiInfo に latch 入力を記録する。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
---
## 3. JoinIR → MIR 統合の全体フロー
1. Pattern router が AST/LoopFeatures から Pattern14 を選択し、各 lowerer が
`(JoinModule, JoinFragmentMeta)` を生成。
2. `JoinInlineBoundary` が:
- ループ入力join_inputs/host_inputs
- 条件変数condition_bindings
- キャリア出口exit_bindings
を保持。
feat(joinir): Phase 33-23 Stage 2 - Pattern-specific analyzers (Issue 2, Issue 6) Implements Stage 2 of the JoinIR refactoring roadmap, extracting specialized analyzer logic from pattern implementations. ## Issue 2: Continue Analysis Extraction (80-100 lines reduction) **New Module**: `pattern4_carrier_analyzer.rs` (346 lines) - `analyze_carriers()` - Filter carriers based on loop body updates - `analyze_carrier_updates()` - Delegate to LoopUpdateAnalyzer - `normalize_continue_branches()` - Delegate to ContinueBranchNormalizer - `validate_continue_structure()` - Verify continue pattern validity - **6 unit tests** covering validation, filtering, normalization **Updated**: `pattern4_with_continue.rs` - Removed direct ContinueBranchNormalizer usage (24 lines) - Removed carrier filtering logic (replaced with analyzer call) - Cleaner delegation to Pattern4CarrierAnalyzer **Line Reduction**: 24 lines direct removal from pattern4 ## Issue 6: Break Condition Analysis Extraction (60-80 lines reduction) **New Module**: `break_condition_analyzer.rs` (466 lines) - `extract_break_condition()` - Extract break condition from if-else-break - `has_break_in_else_clause()` - Check for else-break pattern - `validate_break_structure()` - Validate condition well-formedness - `extract_condition_variables()` - Collect variable dependencies - `negate_condition()` - Helper for condition negation - **10 unit tests** covering all analyzer functions **Updated**: `ast_feature_extractor.rs` - Delegated `has_break_in_else_clause()` to BreakConditionAnalyzer (40 lines) - Delegated `extract_break_condition()` to BreakConditionAnalyzer - Added Phase 33-23 documentation - Cleaner separation of concerns **Line Reduction**: 40 lines direct removal from feature extractor ## Module Structure Updates **Updated**: `src/mir/builder/control_flow/joinir/patterns/mod.rs` - Added pattern4_carrier_analyzer module export - Phase 33-23 documentation **Updated**: `src/mir/loop_pattern_detection/mod.rs` - Added break_condition_analyzer module export - Phase 33-23 documentation ## Test Results ✅ **cargo build --release**: Success (0 errors, warnings only) ✅ **New tests**: 16/16 PASS - pattern4_carrier_analyzer: 6/6 PASS - break_condition_analyzer: 10/10 PASS ✅ **No regressions**: All new analyzer tests pass ## Stage 2 Summary **Total Implementation**: - 2 new analyzer modules (812 lines) - 16 comprehensive unit tests - 4 files updated - 2 mod.rs exports added **Total Line Reduction**: 64 lines direct removal - pattern4_with_continue.rs: -24 lines - ast_feature_extractor.rs: -40 lines **Combined with Stage 1**: 130 lines total reduction (66 + 64) **Progress**: 130/630 lines (21% of 30% goal achieved) ## Design Benefits **Pattern4CarrierAnalyzer**: - Single responsibility: Continue pattern analysis only - Reusable for future continue-based patterns - Independent testability - Clear delegation hierarchy **BreakConditionAnalyzer**: - Generic break pattern analysis - Used by Pattern 2 and future patterns - No MirBuilder dependencies - Pure function design ## Box Theory Compliance ✅ Single responsibility per module ✅ Clear public API boundaries ✅ Appropriate visibility (pub(in control_flow::joinir::patterns)) ✅ No cross-module leakage ✅ Testable units 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-08 04:00:44 +09:00
3. `merge_joinir_mir_blocks` が(マルチ関数対応):
- 全関数の BlockID を再割り当てblock_allocatorし、ValueId はパラメータを除外して収集。
- Boundary の condition/exit Bindings の JoinIR ValueId も remap 対象に追加。
- LoopHeader PHI を生成loop_header_phi_builderし、latch 側は instruction_rewriter が埋める。
- instruction_rewriter で関数をマージしつつ Call→Jump に変換、k_exit 関数はスキップ。
- BoundaryInjector で entry block に Copy を注入join_inputs + condition_bindings
- Header PHI を finalize → exit_phi_builder で expr_result/carrier の exit PHI を構築。
- ExitLineOrchestrator がヘッダ PHI dst を使って variable_map を更新。
- host の現在ブロックから JoinIR entry へ jump を張り、exit ブロックに切り替える。
feat(joinir): Phase 33-22 CommonPatternInitializer & JoinIRConversionPipeline integration Unifies initialization and conversion logic across all 4 loop patterns, eliminating code duplication and establishing single source of truth. ## Changes ### Infrastructure (New) - CommonPatternInitializer (117 lines): Unified loop var extraction + CarrierInfo building - JoinIRConversionPipeline (127 lines): Unified JoinIR→MIR→Merge flow ### Pattern Refactoring - Pattern 1: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 2: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 3: Uses CommonPatternInitializer + JoinIRConversionPipeline (-25 lines) - Pattern 4: Uses CommonPatternInitializer + JoinIRConversionPipeline (-40 lines) ### Code Reduction - Total reduction: ~115 lines across all patterns - Zero code duplication in initialization/conversion - Pattern files: 806 lines total (down from ~920) ### Quality Improvements - Single source of truth for initialization - Consistent conversion flow across all patterns - Guaranteed boundary.loop_var_name setting (prevents SSA-undef bugs) - Improved maintainability and testability ### Testing - All 4 patterns tested and passing: - Pattern 1 (Simple While): ✅ - Pattern 2 (With Break): ✅ - Pattern 3 (If-Else PHI): ✅ - Pattern 4 (With Continue): ✅ ### Documentation - Phase 33-22 inventory and results document - Updated joinir-architecture-overview.md with new infrastructure ## Breaking Changes None - pure refactoring with no API changes 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
2025-12-07 21:02:20 +09:00
この全体フローの詳細は `src/mir/builder/control_flow/joinir/merge/mod.rs`
`phase-189-multi-function-mir-merge/README.md` を参照。
---
## 4. selfhost / .hako JoinIR Frontend との関係
JoinIR は Rust 側だけでなく、将来的に .hako selfhost コンパイラ側でも生成・解析される予定だよ:
- .hako 側の JsonParser/分析箱は、Program JSON / MIR JSON v1 を読んで JoinIR/MIR を解析する。
- Rust 側 JoinIR ラインの設計変更(特に ValueId/ExitLine/Boundary 周り)は、
**必ずこのファイルを更新してから** .hako 側にも段階的に反映する方針。
「JoinIR の仕様」「箱の責務」「境界の契約」は、このファイルを SSOT として運用していく。
---
## 5. 関連ドキュメント
- `docs/development/current/main/10-Now.md`
- 全体の「いまどこ」を短くまとめたダッシュボード。
- `docs/private/roadmap2/phases/phase-180-joinir-unification-before-selfhost/README.md`
- JoinIR 統一フェーズ全体のロードマップと進捗。
- 各 Phase 詳細:
- 185188: Strict mode / LoopBuilder 削除 / Pattern14 基盤
- 189193: Multi-function merge / Select bridge / ExitLine 箱化
- 171172 / 3310/13: ConditionEnv, ConditionBinding, JoinFragmentMeta, ExitLineRefactor 等
- `docs/development/current/main/loop_pattern_space.md`
- JoinIR ループパターン空間の整理メモ。
どの軸(継続条件 / break / continue / PHI / 条件変数スコープ / 更新パターン)でパターンを分けるか、
そして P1P4 / Trim(P5) の位置づけと、今後追加候補のパターン一覧がまとまっている。
feat(joinir): Phase 176 Pattern2 multi-carrier lowering complete Task 176-1: Pattern2 limitation investigation - Identified 10 limitation points where only position carrier was handled - Added TODO markers for Phase 176-2/3 implementation - Created phase176-pattern2-limitations.md documentation Task 176-2: CarrierUpdateLowerer helper implementation - Implemented emit_carrier_update() helper function - Supports CounterLike and AccumulationLike UpdateExpr patterns - Added 6 unit tests (all passing) - Fail-Fast error handling for carrier/variable not found Task 176-3: Pattern2 lowerer multi-carrier extension - Extended header PHI generation for all carriers - Implemented loop update for all carriers using emit_carrier_update() - Extended ExitLine/ExitMeta construction for all carriers - Updated function call/jump args to include all carriers - 9/10 tests passing (1 pre-existing test issue) Task 176-4: E2E testing and bug fixes - Fixed Trim pattern loop_var_name overwrite bug (pattern2_with_break.rs) - Fixed InstructionRewriter latch_incoming mapping bug - All E2E tests passing (RC=0): pos + result dual-carrier loops work - test_jsonparser_parse_string_min2.hako verified Task 176-5: Documentation updates - Created phase176-completion-report.md - Updated phase175-multicarrier-design.md with completion status - Updated joinir-architecture-overview.md roadmap - Updated CURRENT_TASK.md with Phase 176 completion + Phase 177 TODO - Updated loop_pattern_space.md F-axis (multi-carrier support complete) Technical achievements: - Pattern2 now handles single/multiple carriers uniformly - CarrierInfo architecture proven to work end-to-end - Two critical bugs fixed (loop_var overwrite, latch_incoming mapping) - No regressions in existing tests Next: Phase 177 - Apply to JsonParser _parse_string full implementation
2025-12-08 15:17:53 +09:00
---
## 6. RoadmapJoinIR の今後のゴール)
ここから先の JoinIR の「目指す形」を、箱レベルでざっくり書いておくよ。フェーズ詳細は各 phase ドキュメントに分散させて、このセクションは常に最新の方向性だけを保つ。
### 6.1 直近Phase 176-177 まわり)
- **P5Trim/JsonParser 系)ループの複数キャリア対応** ✅ Phase 176 完了 (2025-12-08)
- 完了内容:
- Pattern2 lowerer を全キャリア対応に拡張(ヘッダ PHI / ループ更新 / ExitLine
- CarrierUpdateLowerer ヘルパで UpdateExpr → JoinIR 変換を統一。
- 2キャリアpos + resultE2E テスト完全成功。
- 技術的成果:
- CarrierInfo / ExitMeta / ExitLine / LoopHeaderPhiBuilder の multi-carrier 対応を Pattern2 lowerer で完全活用。
- Trim pattern の「キャリア = ループ変数」という誤解を解消loop_var は特殊キャリア)。
- 次のステップ (Phase 177):
- JsonParser `_parse_string` 本体を P2+P5 で通すpos + result の 2 キャリアで実ループ動作確認)。
### 6.2 中期selfhost depth2 / JsonParser 本体)
- **JsonParserBox / Trim 系ループの本線化**
- 目標:
- `_trim` / `_skip_whitespace` / `_parse_string` / `_parse_array` などの主要ループが、すべて JoinIR Pattern14 + P5 で通ること。
- LoopConditionScopeBox + LoopBodyCarrierPromoter + TrimLoopHelper の上で安全に正規化できるループを広げていく。
- 方針:
- 「ループの形」は P1P4 から増やさず、複雑さは BoolExprLowerer / ContinueBranchNormalizer / P5 系の補助箱で吸収する。
- LoopPatternSpace の P6/P7/P12 候補break+continue 同時 / 複数キャリア条件更新 / early returnは、実アプリで必要になった順に小さく足す。
- **selfhost depth2.hako JoinIR/MIR Frontend**
- 目標:
- `.hako → JsonParserBox → Program/MIR JSON → MirAnalyzerBox/JoinIrAnalyzerBox → VM/LLVM` の深度 2 ループを、日常的に回せるようにする。
- Rust 側の JoinIR は「JSON を受け取って実行・検証するランナー層」、.hako 側が「JoinIR/MIR を構築・解析する言語側 SSOT」という役割分担に近づける。
- 前提:
- 本ドキュメントjoinir-architecture-overview.mdを .hako 側の JoinIR 実装の参照設計として維持し、仕様変更は必ずここを更新してから .hako にも反映する。
### 6.3 当面やらないことNonGoals
- ループパターンを闇雲に増やすこと
- P1P4構造 P5bodylocal 条件を昇格する補助パス)を「骨格」とみなし、
新しいパターンが必要になったときは LoopPatternSpace に追記してから、小さな箱で補う方針。
- LoopBuilder の復活や、JoinIR 以外の別ラインによるループ lowering
- LoopBuilder 系は Phase 186187 で完全に削除済み。
ループに関する新しい要件はすべて JoinIR 側のパターン/箱の拡張で扱う。
- JoinIR の中に言語固有のハードコード(特定 Box 名や変数名)を戻すこと
- Trim/JsonParser 系は、構造パターンと補助箱Promoter/Helperで扱い、
「sum」「ch」など名前ベースの判定は LoopUpdateSummary / TrimLoopHelper の内部に閉じ込める。
この Roadmap は、JoinIR 層の変更や selfhost 深度を進めるたびに更新していくよ。