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

621 lines
38 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
7. **Param の役割ParamRoleを分ける**
- JoinIR 側で扱うパラメータは概念的に 3 種類に分かれる:
- 条件専用Condition param: 継続条件や break 条件だけに使う値
- キャリアCarrier param: ループ状態pos/result など)として更新される値
- 式結果Expr param: ループが式として返す値
- ExitLine / Header PHI / InstructionRewriter は **Carrier param だけ** を対象にし、Condition/Expr param は上書きしない。
- 現状は ConditionBinding/ExitMeta/JoinFragmentMeta で役割を区別しており、将来 ParamRole enum として明示する予定。
8. **LoopHeader PHI dst は予約領域(上書き禁止)**
- LoopHeaderPhiBuilder が生成したヘッダ PHI の dst ValueId は「現在のループ値」の SSOT として扱い、
BoundaryInjector や InstructionRewriter が `Copy` などで二度書きすることを禁止する。
- merge ラインでは「ヘッダ PHI dst に対する新しい定義が出てきたら debug モードで panic する」ことで契約違反を早期検出する。
9. **ParamRole の不変条件Phase 200-A 追加)**
- **Condition 役のパラメータは「PHI dst にしてはいけない」**
- 理由: 条件専用変数はループ内で更新されない(例: `digits` in `_atoi()`
- LoopHeaderPhiBuilder は Condition 役の変数に対して header PHI を生成しない
- **Condition 役のパラメータは「ExitLine の対象にも入れない」**
- 理由: 条件専用変数はループ外で使われない(ループ内でのみ参照)
- ExitLineReconnector は Condition 役の変数を exit_bindings から除外
- **ParamRole の分類**:
- `LoopParam`: ループ制御変数(例: `i` in `loop(i < len)`)→ header PHI + exit_bindings
- `Condition`: 条件専用変数(例: `digits` in `digits.indexOf(ch)`)→ condition_bindings のみ
- `Carrier`: 状態更新変数(例: `sum`, `count`)→ header PHI + exit_bindings
- `ExprResult`: ループ戻り値 → exit_phi_builder で処理
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
- **PatternPipelineContext** (Phase 179-B)
- ファイル: `src/mir/builder/control_flow/joinir/patterns/pattern_pipeline.rs`
- 責務:
- 全 Pattern の前処理結果を格納する「解析済みコンテキスト箱」。
- CommonPatternInitializer + LoopScopeShapeBuilder の結果を統一的に保持。
- Pattern 1-4 の共通データloop_var_name, loop_var_id, carrier_info, loop_scopeを提供。
- Pattern 2/4 専用データcondition_env, carrier_updates, trim_helperは Option<T> で保持。
- **Analyzer-only dependencies**: 解析ロジックのみ依存、JoinIR emission ロジックは含まない。
- **TrimLoopLowerer (P5 Dedicated Module)** (Phase 180)
- ファイル: `src/mir/builder/control_flow/joinir/patterns/trim_loop_lowering.rs`
- 責務:
- Trim/CharComparison (Pattern 5) 専用の lowering ロジックを一箇所に集約。
- Pattern2/4 から呼ばれ、LoopBodyLocal 変数を carrier に昇格し、Trim パターンの break 条件を置き換える。
- TrimPatternValidator/TrimPatternLowerer を内部で利用し、carrier 初期化コード生成・条件式置換を実行。
- 入力:
- MirBuilder, LoopScopeShape, loop_cond, break_cond, body, loop_var_name, carrier_info, alloc_join_value
- 出力:
- `Some(TrimLoweringResult)`: Trim パターン検出・lowering 成功時(置換後条件、更新 carrier_info、condition_bindings
- `None`: Trim パターンでない場合(通常ループ処理に戻る)
- `Err`: Trim パターン検出したが lowering 失敗時
- 使用元:
- Pattern2 (pattern2_with_break.rs): Trim/P5 ロジックを完全委譲(~160 行削減)
- Pattern4 (pattern4_with_continue.rs): 将来の Phase 172+ で Trim lowering 実装時に利用予定
- デザイン原則:
- Pure analysis container前処理結果のみ保持、emission なし)
- Pattern-specific variantsOption<T> でパターン固有データ管理)
- Single source of truth全パターンが同じ前処理経路を使用
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 で不要キャリアを排除)。
- **LoopBodyLocalEnv / UpdateEnv / CarrierUpdateEmitterPhase 184, 191統合完了**
feat(joinir): Phase 184 - Body-local MIR Lowering Infrastructure Phase 184 implements the foundation for body-local variable support in update expressions, completing the three-box architecture: LoopBodyLocalEnv (storage), UpdateEnv (composition), and CarrierUpdateEmitter (emission). ## Implementation Summary ### Task 184-1: Design Document - Created phase184-body-local-mir-lowering.md - Two-Environment System design (ConditionEnv + LoopBodyLocalEnv) - Box-First design principles documented ### Task 184-2: LoopBodyLocalEnv Implementation - New file: src/mir/join_ir/lowering/loop_body_local_env.rs (216 lines) - Storage box for body-local variable name → ValueId mappings - BTreeMap for deterministic ordering (PHI consistency) - 7 unit tests: empty env, single/multiple locals, get/contains, iteration ### Task 184-3: UpdateEnv Implementation - New file: src/mir/join_ir/lowering/update_env.rs (237 lines) - Composition box for unified variable resolution - Priority order: ConditionEnv (condition vars) → LoopBodyLocalEnv (body-local) - 8 unit tests: priority, fallback, not found, combined lookup ### Task 184-4: CarrierUpdateEmitter Integration - Modified: src/mir/join_ir/lowering/carrier_update_emitter.rs - Added emit_carrier_update_with_env() (UpdateEnv version) - Kept emit_carrier_update() for backward compatibility - 4 new unit tests: body-local variable, priority, not found, const update - Total 10 tests PASS (6 existing + 4 new) ### Task 184-5: Representative Test Cases - apps/tests/phase184_body_local_update.hako (Pattern1 baseline) - apps/tests/phase184_body_local_with_break.hako (Pattern2, Phase 185 target) ### Task 184-6: Documentation Updates - Updated: docs/development/current/main/joinir-architecture-overview.md - Updated: CURRENT_TASK.md (Phase 184 completion record) ## Test Results All 25 unit tests PASS: - LoopBodyLocalEnv: 7 tests - UpdateEnv: 8 tests - CarrierUpdateEmitter: 10 tests (6 existing + 4 new) Build: ✅ Success (0 errors) ## Design Constraints Following 箱理論 (Box Theory) principles: - Single Responsibility: Each box has one clear purpose - Deterministic: BTreeMap ensures consistent ordering - Conservative: Pattern5 (Trim) integration deferred to Phase 185 - Fail-Fast: Explicit errors for unsupported patterns ## Scope Limitation Phase 184 provides the **infrastructure only**: - ✅ Storage box (LoopBodyLocalEnv) - ✅ Composition box (UpdateEnv) - ✅ Emission support (CarrierUpdateEmitter) - ❌ Pattern2/4 integration (requires body-local collection, Phase 185) ## Next Steps Phase 185: Pattern2/4 Integration - Integrate LoopBodyLocalEnv into Pattern2/4 lowerers - Add body-local variable collection from loop body AST - Enable full E2E body-local variable support in update expressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-08 23:59:19 +09:00
- ファイル:
- `src/mir/join_ir/lowering/loop_body_local_env.rs`
- `src/mir/join_ir/lowering/update_env.rs`
- `src/mir/join_ir/lowering/carrier_update_emitter.rs`
- `src/mir/join_ir/lowering/loop_with_break_minimal.rs`Phase 191統合
feat(joinir): Phase 184 - Body-local MIR Lowering Infrastructure Phase 184 implements the foundation for body-local variable support in update expressions, completing the three-box architecture: LoopBodyLocalEnv (storage), UpdateEnv (composition), and CarrierUpdateEmitter (emission). ## Implementation Summary ### Task 184-1: Design Document - Created phase184-body-local-mir-lowering.md - Two-Environment System design (ConditionEnv + LoopBodyLocalEnv) - Box-First design principles documented ### Task 184-2: LoopBodyLocalEnv Implementation - New file: src/mir/join_ir/lowering/loop_body_local_env.rs (216 lines) - Storage box for body-local variable name → ValueId mappings - BTreeMap for deterministic ordering (PHI consistency) - 7 unit tests: empty env, single/multiple locals, get/contains, iteration ### Task 184-3: UpdateEnv Implementation - New file: src/mir/join_ir/lowering/update_env.rs (237 lines) - Composition box for unified variable resolution - Priority order: ConditionEnv (condition vars) → LoopBodyLocalEnv (body-local) - 8 unit tests: priority, fallback, not found, combined lookup ### Task 184-4: CarrierUpdateEmitter Integration - Modified: src/mir/join_ir/lowering/carrier_update_emitter.rs - Added emit_carrier_update_with_env() (UpdateEnv version) - Kept emit_carrier_update() for backward compatibility - 4 new unit tests: body-local variable, priority, not found, const update - Total 10 tests PASS (6 existing + 4 new) ### Task 184-5: Representative Test Cases - apps/tests/phase184_body_local_update.hako (Pattern1 baseline) - apps/tests/phase184_body_local_with_break.hako (Pattern2, Phase 185 target) ### Task 184-6: Documentation Updates - Updated: docs/development/current/main/joinir-architecture-overview.md - Updated: CURRENT_TASK.md (Phase 184 completion record) ## Test Results All 25 unit tests PASS: - LoopBodyLocalEnv: 7 tests - UpdateEnv: 8 tests - CarrierUpdateEmitter: 10 tests (6 existing + 4 new) Build: ✅ Success (0 errors) ## Design Constraints Following 箱理論 (Box Theory) principles: - Single Responsibility: Each box has one clear purpose - Deterministic: BTreeMap ensures consistent ordering - Conservative: Pattern5 (Trim) integration deferred to Phase 185 - Fail-Fast: Explicit errors for unsupported patterns ## Scope Limitation Phase 184 provides the **infrastructure only**: - ✅ Storage box (LoopBodyLocalEnv) - ✅ Composition box (UpdateEnv) - ✅ Emission support (CarrierUpdateEmitter) - ❌ Pattern2/4 integration (requires body-local collection, Phase 185) ## Next Steps Phase 185: Pattern2/4 Integration - Integrate LoopBodyLocalEnv into Pattern2/4 lowerers - Add body-local variable collection from loop body AST - Enable full E2E body-local variable support in update expressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-08 23:59:19 +09:00
- 責務:
- **LoopBodyLocalEnv**: ループ本体で宣言された body-local 変数の名前→ValueId マッピングを管理(箱化設計)。
- **UpdateEnv**: 条件変数ConditionEnvと body-local 変数LoopBodyLocalEnvを統合した変数解決層。
- Priority order: 1. Condition variables高優先度 → 2. Body-local variablesフォールバック
- **CarrierUpdateEmitter**: UpdateExpr を JoinIR 命令に変換する際、UpdateEnv を使用して body-local 変数をサポート。
- `emit_carrier_update_with_env()`: UpdateEnv 版Phase 184 新規)
- `emit_carrier_update()`: ConditionEnv 版(後方互換)
- **LoopBodyLocalInitLowerer**: Phase 191 で Pattern2 に統合完了。
- 対応済み init 式: 整数リテラル、変数参照、二項演算(`local digit = i + 1`
- UpdateEnv の優先順位により ConditionEnv → LoopBodyLocalEnv の順で変数解決
feat(joinir): Phase 184 - Body-local MIR Lowering Infrastructure Phase 184 implements the foundation for body-local variable support in update expressions, completing the three-box architecture: LoopBodyLocalEnv (storage), UpdateEnv (composition), and CarrierUpdateEmitter (emission). ## Implementation Summary ### Task 184-1: Design Document - Created phase184-body-local-mir-lowering.md - Two-Environment System design (ConditionEnv + LoopBodyLocalEnv) - Box-First design principles documented ### Task 184-2: LoopBodyLocalEnv Implementation - New file: src/mir/join_ir/lowering/loop_body_local_env.rs (216 lines) - Storage box for body-local variable name → ValueId mappings - BTreeMap for deterministic ordering (PHI consistency) - 7 unit tests: empty env, single/multiple locals, get/contains, iteration ### Task 184-3: UpdateEnv Implementation - New file: src/mir/join_ir/lowering/update_env.rs (237 lines) - Composition box for unified variable resolution - Priority order: ConditionEnv (condition vars) → LoopBodyLocalEnv (body-local) - 8 unit tests: priority, fallback, not found, combined lookup ### Task 184-4: CarrierUpdateEmitter Integration - Modified: src/mir/join_ir/lowering/carrier_update_emitter.rs - Added emit_carrier_update_with_env() (UpdateEnv version) - Kept emit_carrier_update() for backward compatibility - 4 new unit tests: body-local variable, priority, not found, const update - Total 10 tests PASS (6 existing + 4 new) ### Task 184-5: Representative Test Cases - apps/tests/phase184_body_local_update.hako (Pattern1 baseline) - apps/tests/phase184_body_local_with_break.hako (Pattern2, Phase 185 target) ### Task 184-6: Documentation Updates - Updated: docs/development/current/main/joinir-architecture-overview.md - Updated: CURRENT_TASK.md (Phase 184 completion record) ## Test Results All 25 unit tests PASS: - LoopBodyLocalEnv: 7 tests - UpdateEnv: 8 tests - CarrierUpdateEmitter: 10 tests (6 existing + 4 new) Build: ✅ Success (0 errors) ## Design Constraints Following 箱理論 (Box Theory) principles: - Single Responsibility: Each box has one clear purpose - Deterministic: BTreeMap ensures consistent ordering - Conservative: Pattern5 (Trim) integration deferred to Phase 185 - Fail-Fast: Explicit errors for unsupported patterns ## Scope Limitation Phase 184 provides the **infrastructure only**: - ✅ Storage box (LoopBodyLocalEnv) - ✅ Composition box (UpdateEnv) - ✅ Emission support (CarrierUpdateEmitter) - ❌ Pattern2/4 integration (requires body-local collection, Phase 185) ## Next Steps Phase 185: Pattern2/4 Integration - Integrate LoopBodyLocalEnv into Pattern2/4 lowerers - Add body-local variable collection from loop body AST - Enable full E2E body-local variable support in update expressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-08 23:59:19 +09:00
- 設計原則:
- **箱理論**: 各 Box が単一責任を持ち、境界明確。
- **決定性**: BTreeMap 使用で一貫した順序保証PHI 生成の決定性)。
- **Phase 192完了**: Complex addend`v = v*10 + f(x)`)は ComplexAddendNormalizer で temp に分解してから NumberAccumulation に載せる。
- `complex_addend_normalizer.rs`: Pure AST transformer前処理箱
- Pattern2 統合完了、emission ライン再利用(変更なし)
- 制約: MethodCall を含む init 式は Phase 193 で対応予定
feat(joinir): Phase 184 - Body-local MIR Lowering Infrastructure Phase 184 implements the foundation for body-local variable support in update expressions, completing the three-box architecture: LoopBodyLocalEnv (storage), UpdateEnv (composition), and CarrierUpdateEmitter (emission). ## Implementation Summary ### Task 184-1: Design Document - Created phase184-body-local-mir-lowering.md - Two-Environment System design (ConditionEnv + LoopBodyLocalEnv) - Box-First design principles documented ### Task 184-2: LoopBodyLocalEnv Implementation - New file: src/mir/join_ir/lowering/loop_body_local_env.rs (216 lines) - Storage box for body-local variable name → ValueId mappings - BTreeMap for deterministic ordering (PHI consistency) - 7 unit tests: empty env, single/multiple locals, get/contains, iteration ### Task 184-3: UpdateEnv Implementation - New file: src/mir/join_ir/lowering/update_env.rs (237 lines) - Composition box for unified variable resolution - Priority order: ConditionEnv (condition vars) → LoopBodyLocalEnv (body-local) - 8 unit tests: priority, fallback, not found, combined lookup ### Task 184-4: CarrierUpdateEmitter Integration - Modified: src/mir/join_ir/lowering/carrier_update_emitter.rs - Added emit_carrier_update_with_env() (UpdateEnv version) - Kept emit_carrier_update() for backward compatibility - 4 new unit tests: body-local variable, priority, not found, const update - Total 10 tests PASS (6 existing + 4 new) ### Task 184-5: Representative Test Cases - apps/tests/phase184_body_local_update.hako (Pattern1 baseline) - apps/tests/phase184_body_local_with_break.hako (Pattern2, Phase 185 target) ### Task 184-6: Documentation Updates - Updated: docs/development/current/main/joinir-architecture-overview.md - Updated: CURRENT_TASK.md (Phase 184 completion record) ## Test Results All 25 unit tests PASS: - LoopBodyLocalEnv: 7 tests - UpdateEnv: 8 tests - CarrierUpdateEmitter: 10 tests (6 existing + 4 new) Build: ✅ Success (0 errors) ## Design Constraints Following 箱理論 (Box Theory) principles: - Single Responsibility: Each box has one clear purpose - Deterministic: BTreeMap ensures consistent ordering - Conservative: Pattern5 (Trim) integration deferred to Phase 185 - Fail-Fast: Explicit errors for unsupported patterns ## Scope Limitation Phase 184 provides the **infrastructure only**: - ✅ Storage box (LoopBodyLocalEnv) - ✅ Composition box (UpdateEnv) - ✅ Emission support (CarrierUpdateEmitter) - ❌ Pattern2/4 integration (requires body-local collection, Phase 185) ## Next Steps Phase 185: Pattern2/4 Integration - Integrate LoopBodyLocalEnv into Pattern2/4 lowerers - Add body-local variable collection from loop body AST - Enable full E2E body-local variable support in update expressions 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-08 23:59:19 +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
### 2.3 キャリア / Exit / Boundary ライン
- **CarrierInfo / LoopUpdateAnalyzer / CarrierUpdateEmitter**
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/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`
- `src/mir/join_ir/lowering/carrier_update_emitter.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 では実際に更新されるキャリアだけを残す。
- **Phase 188 完了** ✅: String 更新StringAppendChar/StringAppendLiteralを UpdateRhs ベースのホワイトリストで受理し、JoinIR BinOp を emit。
- 許可: `UpdateRhs::Const`, `UpdateRhs::Variable`, `UpdateRhs::StringLiteral`
- 拒否: `UpdateRhs::Other`method call / nested BinOp 等の複雑パターンのみ)
- Pattern2/4 の can_lower() で選別、carrier_update_emitter.rs で JoinIR 生成
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)]`)。
- **FunctionScopeCaptureAnalyzer / CapturedEnvPhase 200-A 追加)**
- ファイル: `src/mir/loop_pattern_detection/function_scope_capture.rs`
- 責務:
- 関数スコープで宣言され、ループ内で不変な変数("実質定数")を検出。
- 例: `local digits = "0123456789"` in `JsonParser._atoi()`
- CapturedVar: `{ name, host_id, is_immutable }`
- CapturedEnv: 検出された変数のコレクション
- **Phase 200-A**: 型と空実装のみskeleton
- **Phase 200-B**: 実際の検出ロジックを実装予定AST スキャン + 再代入チェック)。
- **ParamRole enumPhase 200-A 追加)**
- ファイル: `src/mir/join_ir/lowering/inline_boundary_builder.rs`
- 責務:
- JoinInlineBoundary のパラメータ役割を明示的に区別。
- LoopParam / Condition / Carrier / ExprResult の 4 種類。
- **不変条件**:
- **Condition 役**: PHI dst にしてはいけない(ループ内で更新されない)。
- **Condition 役**: ExitLine の対象にも入れない(ループ外で使われない)。
- 理由: 条件専用変数(例: `digits`)はループ内でのみ参照され、不変。
- **Phase 200-A**: enum 定義のみ。
- **Phase 200-B**: ルーティングロジック実装予定CapturedEnv 統合時)。
- **ConditionEnvBuilder::build_with_capturesPhase 200-A 追加)**
- ファイル: `src/mir/builder/control_flow/joinir/patterns/condition_env_builder.rs`
- 責務:
- 将来 CapturedEnv を受け取り、ConditionEnv に統合する v2 入口。
- **Phase 200-A**: 既存実装に委譲する skeleton。
- **Phase 200-B**: CapturedEnv の変数を 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
### 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 入力を記録する。
- **Select 展開の不変条件Phase 196**:
- PHI の入力 ValueId は必ず `remapper.remap_instruction()` で remap 済みの MIR ValueId を使用。
- InstructionRewriter では ValueId の二重 remap を行わないblock ID のみ remap
- 詳細: [phase196-select-bug-analysis.md](./phase196-select-bug-analysis.md)
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. JsonParser / Trim / P5 ループの現在地Phase 170181
### 4.1 JsonParser ループ空間と P1P5
Phase 181 で JsonParserBox 内の 11 ループを棚卸しした結果、
構造的には **すべて JoinIR Pattern14 (+ P5) で扱える** ことが分かったよ。
- 既に JoinIR 経路で動作しているもの:
- `_skip_whitespace`P2 + P5 Trim
- `_trim` leading/trailingP2 + P5 Trim
- **Phase 182 で P1/P2 パターン検証完了** ✅:
- Pattern1 (Simple): `_match_literal` 系ループで動作確認済みapps/tests/phase182_p1_match_literal.hako
- Pattern2 (Break): 整数演算ループで動作確認済みapps/tests/phase182_p2_break_integer.hako
- **ブロッカー発見**: 実際の JsonParser ループには 2 つの制約が必要:
1. LoopBodyLocal 変数の扱い(`ch`, `digit_pos`, `pos` など)
- 現状は Trim pattern 専用の carrier 昇格を試みてエラーになる
- P1/P2 では純粋なローカル変数(昇格不要)として扱うべき
2. 文字列連結フィルタPhase 178
- `num_str = num_str + ch` のような string concat を保守的に reject
- JsonParser では必須の操作なので段階的に有効化が必要
- **設計原則**:
- string は「特別扱いのパターン」ではなく、あくまで MirType の 1 種類として扱う。
- Pattern2/4 側で型名や変数名(`"result"`, `"num_str"` など)に依存した分岐は入れない。
- LoopUpdateAnalyzer の `UpdateKind` / `UpdateRhs` で「安全な更新パターン」を列挙し、
そのうち string にも適用可能なものだけを **ホワイトリストで許可**する。
- 実際の lowering は CarrierUpdateLowerer / 式 Lowerer 側で行い、JoinIR のループ形P1P4は増やさない。
3. 数値の桁展開Phase 190 設計完了)
- `v = v * 10 + digit` のような NumberAccumulation パターンを UpdateKind で whitelist 制御。
- 型制約: Integer のみ許可String は StringAppendChar 使用)。
- 検出: AST 構造解析名前依存禁止、Complex パターンは Fail-Fast で reject。
feat(joinir): Phase 183 LoopBodyLocal role separation Implements role-based separation of LoopBodyLocal variables to prevent inappropriate Trim promotion for body-only local variables. ## Changes ### Task 183-1: Design Documentation - Created `phase183-loopbodylocal-role-separation.md` with role taxonomy: - Condition LoopBodyLocal: Used in loop conditions → Trim promotion target - Body-only LoopBodyLocal: Only in body → No promotion needed - Documented architectural approach and implementation strategy ### Task 183-2: Implementation - Added `TrimLoopLowerer::is_var_used_in_condition()` helper - Recursively checks if variable appears in condition AST - Handles BinaryOp, UnaryOp, MethodCall node types - Updated `try_lower_trim_like_loop()` to filter condition LoopBodyLocal - Only processes LoopBodyLocal that appear in break conditions - Skips body-only LoopBodyLocal (returns Ok(None) early) - Added 5 unit tests for variable detection logic ### Task 183-3: Test Files - Created `phase183_body_only_loopbodylocal.hako` - Demonstrates body-only LoopBodyLocal (`temp`) not triggering Trim - Verified trace output: "No LoopBodyLocal detected, skipping Trim lowering" - Created additional test files (phase183_p1_match_literal, phase183_p2_atoi, phase183_p2_parse_number) ### Task 183-4: Documentation Updates - Updated `joinir-architecture-overview.md` with Phase 183 results - Updated `CURRENT_TASK.md` with Phase 183 completion status ## Results ✅ LoopBodyLocal role separation complete ✅ Body-only LoopBodyLocal skips Trim promotion ✅ 5 unit tests passing ✅ Trace verification successful ## Next Steps (Phase 184+) - Body-local variable MIR lowering support - String concatenation filter relaxation - Full _parse_number/_atoi implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-08 23:14:10 +09:00
- **Phase 183 で LoopBodyLocal 役割分離完了** ✅:
- **設計**: LoopBodyLocal を 2 カテゴリに分類:
- **Condition LoopBodyLocal**: ループ条件header/break/continueで使用 → Trim 昇格対象
- **Body-only LoopBodyLocal**: ループ本体のみで使用 → 昇格不要、pure local 扱い
- **実装**: TrimLoopLowerer に `is_var_used_in_condition()` ヘルパー追加
- 条件で使われていない LoopBodyLocal は Trim 昇格スキップ
- 5 つの unit test で変数検出ロジックを検証
- **テスト**: `apps/tests/phase183_body_only_loopbodylocal.hako` で動作確認
- `[TrimLoopLowerer] No LoopBodyLocal detected` トレース出力で body-only 判定成功
- **次の課題→Phase 184 で対応)**: body-local 変数の MIR lowering 対応(`local temp` in loop body
feat(joinir): Phase 183 LoopBodyLocal role separation Implements role-based separation of LoopBodyLocal variables to prevent inappropriate Trim promotion for body-only local variables. ## Changes ### Task 183-1: Design Documentation - Created `phase183-loopbodylocal-role-separation.md` with role taxonomy: - Condition LoopBodyLocal: Used in loop conditions → Trim promotion target - Body-only LoopBodyLocal: Only in body → No promotion needed - Documented architectural approach and implementation strategy ### Task 183-2: Implementation - Added `TrimLoopLowerer::is_var_used_in_condition()` helper - Recursively checks if variable appears in condition AST - Handles BinaryOp, UnaryOp, MethodCall node types - Updated `try_lower_trim_like_loop()` to filter condition LoopBodyLocal - Only processes LoopBodyLocal that appear in break conditions - Skips body-only LoopBodyLocal (returns Ok(None) early) - Added 5 unit tests for variable detection logic ### Task 183-3: Test Files - Created `phase183_body_only_loopbodylocal.hako` - Demonstrates body-only LoopBodyLocal (`temp`) not triggering Trim - Verified trace output: "No LoopBodyLocal detected, skipping Trim lowering" - Created additional test files (phase183_p1_match_literal, phase183_p2_atoi, phase183_p2_parse_number) ### Task 183-4: Documentation Updates - Updated `joinir-architecture-overview.md` with Phase 183 results - Updated `CURRENT_TASK.md` with Phase 183 completion status ## Results ✅ LoopBodyLocal role separation complete ✅ Body-only LoopBodyLocal skips Trim promotion ✅ 5 unit tests passing ✅ Trace verification successful ## Next Steps (Phase 184+) - Body-local variable MIR lowering support - String concatenation filter relaxation - Full _parse_number/_atoi implementation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-08 23:14:10 +09:00
- Phase 183 では "Trim promotion しない" 判定まで完了
- 実際の MIR 生成インフラは Phase 184 で実装済みPattern2/4 への統合は次フェーズ)
### 4.2 Body-local 変数の MIR lowering 基盤Phase 184
Phase 184 では、「条件には出てこない LoopBodyLocal 変数」を安全に JoinIR→MIR に落とすためのインフラ箱だけを追加したよ。
- **LoopBodyLocalEnv**
- 責務: ループ本体内で `local` 定義された変数の「JoinIR 側 ValueId のみ」を管理する。
- 入力: ループ本体 AST / JoinIR ビルダー。
- 出力: `name -> join_value_id` のマップ。
- 特徴: host 側との対応は持たない。ConditionEnv とは完全に分離された「本体専用ローカル環境」。
- **UpdateEnv**
- 責務: UpdateExpr lowering 時の変数解決順序をカプセル化する。
- 仕様: `ConditionEnv`(条件・キャリア)と `LoopBodyLocalEnv`(本体ローカル)を中で束ねて、
`resolve(name)` で「条件→ローカル」の順に ValueId を返す。
- 利用箇所: CarrierUpdateEmitter / CarrierUpdateLowerer が、変数名ベースで UpdateExpr を JoinIR に落とす時に利用。
- **CarrierUpdateEmitter 拡張**
- 責務: `LoopUpdateSummary`UpdateKindに応じて、int 系キャリア更新を JoinIR 命令に変換する。
- 変更点: 直接 `variable_map` を読むのではなく、`UpdateEnv` 経由で名前解決するように変更。
- 効果: 本体専用の LoopBodyLocal 変数(`temp`を、Pattern2/4 から安全に扱える土台が整った。
このフェーズではあくまで「ストレージ・名前解決・emit の箱」までで止めてあり、
Pattern2/4 への統合(実際に Body-local 更新を使うループを JoinIR 経路に載せるは次フェーズPhase 185 以降)の仕事として分離している。
- 構造的に P1P4 で対応可能(代表例):
- `_parse_number` / `_atoi`P2 Break- Phase 182 でブロッカー特定済み
- `_match_literal`P1 Simple while- Phase 182 で動作確認済み ✅
- `_parse_string` / `_parse_array` / `_parse_object`
P2 + P4 + P5 の組み合わせで表現可能なことを設計上確認済み)
- 低優先度だが理論上は P1P4 からの拡張で吸収可能:
- `_unescape_string` など、複雑な continue / 条件付き更新を含むループ
方針:
- **ループの「形」は P1P4 から増やさない**。
複雑さLoopBodyLocal 条件、OR chain、continue 多用など)は BoolExprLowerer /
ContinueBranchNormalizer / TrimLoopLowerer (P5) といった補助箱側で吸収する。
- JsonParser 側の P5 適用Trim / `_skip_whitespace` / `_parse_string` 最小版)は実証済み。
残りのループは Phase 17x18x で、P1P4+P5 の組み合わせとして段階的に実装していく。
---
## 5. selfhost / .hako JoinIR Frontend との関係
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 は 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 深度を進めるたびに更新していくよ。
---
## 7. JoinIR 第1章基盤完成サマリ2025-12-09 時点)
### 7.1 現在の対応状況
**Pattern サポート**:
| Pattern | 説明 | 状態 |
|---------|------|------|
| P1 Simple | `loop(cond) { body }` | ✅ 完成 |
| P2 Break | `loop(cond) { if(...) break }` | ✅ 完成 |
| P3 If-PHI | `loop { if(...) a else b; use(φ) }` | ✅ 完成 |
| P4 Continue | `loop { if(...) continue }` | ✅ 完成 |
| P5 Trim | LoopBodyLocal → bool carrier 昇格 | ✅ 基本完成 |
**UpdateKind サポート**:
| UpdateKind | 例 | 状態 |
|------------|-----|------|
| CounterLike | `i = i + 1` | ✅ |
| AccumulationLike | `sum = sum + x` | ✅ |
| StringAppendChar | `s = s + ch` | ✅ |
| StringAppendLiteral | `s = s + "lit"` | ✅ |
| NumberAccumulation | `v = v * 10 + digit` | ✅ (Phase 190) |
| Complex | method call 含む | ❌ Fail-Fast |
**アーキテクチャ SSOT ライン**:
- ✅ LoopHeaderPhiBuilder: ループ変数・キャリアの PHI を SSOT で生成
- ✅ ExitLineReconnector: PHI dst → variable_map 接続
- ✅ JoinInlineBoundaryBuilder: 全パターンで Builder パターン統一
- ✅ JoinIRVerifier: デバッグビルドで契約検証
- ✅ ExitLine Contract Verifier: PHI 配線検証Phase 190-impl-D
### 7.2 残タスクPhase 192+ で対応予定)
1. **✅ body-local 変数の init + update lowering** → Phase 191 完了
- `local digit = i + 1` のような body-local 変数の JoinIR/MIR 生成完了
- 対応済み: 整数リテラル、変数参照、二項演算
- テスト: `phase191_body_local_atoi.hako` → 期待値 123 ✅
2. **✅ Complex addend 対応** → Phase 192 完了
- `v = v * 10 + digits.indexOf(ch)` のような method call を含む NumberAccumulation対応
- ComplexAddendNormalizer で `temp = f(x)` に分解してから NumberAccumulation に載せる実装完了
- テスト: phase192_normalization_demo.hako → 123 ✅
- 制約: MethodCall を含む init 式は Phase 193 で対応予定
docs: Phase 195 Pattern 3 extension design (multi-carrier support) Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion: - Goal: Handle 2-3 carriers in if-else branches simultaneously - Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns) Task breakdown: - 195-1: Loop inventory (_parse_string simple, if-sum patterns) - 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support) - 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension) - 195-4: Implementation scope (2-3 carriers, existing UpdateKind range) - 195-5: Documentation updates (CURRENT_TASK.md + overview) Design decisions: - ✅ ExitLine extension (no PhiGroupBox - YAGNI principle) - ✅ Both-branch carrier definition check (unchanged = use previous value) - ❌ No ConditionEnv expansion (Phase 200+ deferred) - ❌ LoopBodyLocal + MethodCall mix deferred to Phase 195+ Target loops: 1. JsonParser _parse_string (escaped flag + buffer) - Carrier 1: escaped (BoolFlag) - conditional flag - Carrier 2: buffer (StringAppend) - else-only update 2. selfhost if-sum (sum + count) - Carrier 1: sum (NumberAccumulation) - then-only update - Carrier 2: count (CounterLike) - then-only update Test cases designed: - phase195_flag_buffer.hako (BoolFlag + StringAppend) - phase195_sum_count.hako (NumberAccumulation + CounterLike) Expected outcome: - phase195-pattern3-extension-design.md (complete design spec) - Clear implementation scope for Phase 195-impl - Path to 40% → 60% JsonParser coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 13:22:14 +09:00
3. **✅ MethodCall を含む init 式の対応** → Phase 193 完了
- `local digit = digits.indexOf(ch)` のような MethodCall init の lowering 完了
- LoopBodyLocalInitLowerer 拡張BoxCall emission
docs: Phase 195 Pattern 3 extension design (multi-carrier support) Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion: - Goal: Handle 2-3 carriers in if-else branches simultaneously - Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns) Task breakdown: - 195-1: Loop inventory (_parse_string simple, if-sum patterns) - 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support) - 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension) - 195-4: Implementation scope (2-3 carriers, existing UpdateKind range) - 195-5: Documentation updates (CURRENT_TASK.md + overview) Design decisions: - ✅ ExitLine extension (no PhiGroupBox - YAGNI principle) - ✅ Both-branch carrier definition check (unchanged = use previous value) - ❌ No ConditionEnv expansion (Phase 200+ deferred) - ❌ LoopBodyLocal + MethodCall mix deferred to Phase 195+ Target loops: 1. JsonParser _parse_string (escaped flag + buffer) - Carrier 1: escaped (BoolFlag) - conditional flag - Carrier 2: buffer (StringAppend) - else-only update 2. selfhost if-sum (sum + count) - Carrier 1: sum (NumberAccumulation) - then-only update - Carrier 2: count (CounterLike) - then-only update Test cases designed: - phase195_flag_buffer.hako (BoolFlag + StringAppend) - phase195_sum_count.hako (NumberAccumulation + CounterLike) Expected outcome: - phase195-pattern3-extension-design.md (complete design spec) - Clear implementation scope for Phase 195-impl - Path to 40% → 60% JsonParser coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 13:22:14 +09:00
- メソッド whitelist: indexOf, get, toString 対応
- 制約: body-local init のみ対応、condition 内の MethodCall は Phase 200+
4. **✅ JsonParser 実戦投入P1/P2/P5 検証)** → Phase 194 完了
- 4/10 ループが JoinIR 経路で動作確認 (40% coverage)
- Target loops: _skip_whitespace, _trim (x2), _match_literal
- Deferred loops: _parse_number, _atoi (ConditionEnv constraint)
- Deferred loops: _parse_string, _unescape_string (complex carriers)
- Deferred loops: _parse_array, _parse_object (multiple MethodCalls)
- 詳細: phase194-loop-inventory.md, phase194-jsonparser-deployment.md
5. **Pattern 3 拡張(複数キャリア対応)** → Phase 195 + 196 完了 ✅
docs: Phase 195 Pattern 3 extension design (multi-carrier support) Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion: - Goal: Handle 2-3 carriers in if-else branches simultaneously - Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns) Task breakdown: - 195-1: Loop inventory (_parse_string simple, if-sum patterns) - 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support) - 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension) - 195-4: Implementation scope (2-3 carriers, existing UpdateKind range) - 195-5: Documentation updates (CURRENT_TASK.md + overview) Design decisions: - ✅ ExitLine extension (no PhiGroupBox - YAGNI principle) - ✅ Both-branch carrier definition check (unchanged = use previous value) - ❌ No ConditionEnv expansion (Phase 200+ deferred) - ❌ LoopBodyLocal + MethodCall mix deferred to Phase 195+ Target loops: 1. JsonParser _parse_string (escaped flag + buffer) - Carrier 1: escaped (BoolFlag) - conditional flag - Carrier 2: buffer (StringAppend) - else-only update 2. selfhost if-sum (sum + count) - Carrier 1: sum (NumberAccumulation) - then-only update - Carrier 2: count (CounterLike) - then-only update Test cases designed: - phase195_flag_buffer.hako (BoolFlag + StringAppend) - phase195_sum_count.hako (NumberAccumulation + CounterLike) Expected outcome: - phase195-pattern3-extension-design.md (complete design spec) - Clear implementation scope for Phase 195-impl - Path to 40% → 60% JsonParser coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 13:22:14 +09:00
- 目的: P3If-Else PHIで 2-3 個の Carrier を同時処理
- **Phase 195**: Lowerer 側完了multi-carrier PHI 生成: sum + count
- **Phase 196**: Select 二重 remap バグ修正 ✅
- 根本原因: `instruction_rewriter.rs` で PHI inputs を二重 remap
- 修正: block ID のみ remap、ValueId は既に remap 済み
- **E2E 結果**: phase195_sum_count.hako → 93 ✅
- 詳細: phase196-select-bug-analysis.md
6. **✅ JoinIR 実戦適用(軽量ループ検証)** → Phase 197 完了 ✅
- 目的: Phase 196 までの安定基盤を実戦の小さいループで検証
- 対象ループ5本:
1. `_match_literal` (P1) - JsonParser 単純 while ✅
2. `_skip_whitespace` (P2) - JsonParser break パターン ✅
3. `phase195_sum_count.hako` (P3 multi-carrier) ✅
4. `loop_if_phi.hako` (P3 single-carrier) ✅
5. `loop_min_while.hako` (P1 minimal) ✅
- 結果:
- [x] routing 確認: 全ループ whitelisted ✅
- [x] E2E 実行: 4/5 ループで期待値出力、1/5 routing 確認 ✅
- [x] 退行なし: Phase 190-196 テスト全 PASS ✅
- 詳細: phase197-lightweight-loops-deployment.md
7. **JsonParser/selfhost 実戦 JoinIR 適用状況** (2025-12-09 更新)
| Function | Pattern | Status | Note |
|----------|---------|--------|------|
| `_match_literal` | P1 | ✅ JoinIR OK | Phase 197 検証済みE2E PASS|
| `_skip_whitespace` | P2 | ✅ JoinIR OK | Phase 197 routing 確認whitelisted|
| `_trim` (leading) | P5 | ✅ JoinIR OK | Phase 173 実証済み |
| `_trim` (trailing) | P5 | ✅ JoinIR OK | Phase 173 実証済み |
| `phase195_sum_count` | P3 | ✅ JoinIR OK | Phase 196 検証済みmulti-carrier|
| `loop_if_phi` | P3 | ✅ JoinIR OK | Phase 196 検証済みsingle-carrier|
| `loop_min_while` | P1 | ✅ JoinIR OK | Phase 165 基本検証済み |
| `_parse_number` | P2 | ⚠️ Deferred | ConditionEnv 制約Phase 200+|
| `_atoi` | P2 | ⚠️ Deferred | ConditionEnv 制約Phase 200+|
| `_parse_string` | P3 | ⚠️ Deferred | 複雑キャリアPhase 195+ 拡張後)|
| `_unescape_string` | P3 | ⚠️ Deferred | 複雑キャリアPhase 195+ 拡張後)|
| `_parse_array` | - | ⚠️ Deferred | 複数 MethodCallPhase 195+|
| `_parse_object` | - | ⚠️ Deferred | 複数 MethodCallPhase 195+|
**Coverage**: 7/13 ループ JoinIR 対応済み54%
**Verification**: 4/7 ループ E2E PASS、3/7 structural/routing 確認済み
8. **JsonParser 残り複雑ループへの適用Phase 198+, 200+**
docs: Phase 195 Pattern 3 extension design (multi-carrier support) Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion: - Goal: Handle 2-3 carriers in if-else branches simultaneously - Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns) Task breakdown: - 195-1: Loop inventory (_parse_string simple, if-sum patterns) - 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support) - 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension) - 195-4: Implementation scope (2-3 carriers, existing UpdateKind range) - 195-5: Documentation updates (CURRENT_TASK.md + overview) Design decisions: - ✅ ExitLine extension (no PhiGroupBox - YAGNI principle) - ✅ Both-branch carrier definition check (unchanged = use previous value) - ❌ No ConditionEnv expansion (Phase 200+ deferred) - ❌ LoopBodyLocal + MethodCall mix deferred to Phase 195+ Target loops: 1. JsonParser _parse_string (escaped flag + buffer) - Carrier 1: escaped (BoolFlag) - conditional flag - Carrier 2: buffer (StringAppend) - else-only update 2. selfhost if-sum (sum + count) - Carrier 1: sum (NumberAccumulation) - then-only update - Carrier 2: count (CounterLike) - then-only update Test cases designed: - phase195_flag_buffer.hako (BoolFlag + StringAppend) - phase195_sum_count.hako (NumberAccumulation + CounterLike) Expected outcome: - phase195-pattern3-extension-design.md (complete design spec) - Clear implementation scope for Phase 195-impl - Path to 40% → 60% JsonParser coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 13:22:14 +09:00
- Phase 200+: ConditionEnv 拡張 (function-scoped variables) → _parse_number, _atoi
- Phase 198+: Pattern 3 拡張 (multi-flag carriers) → _parse_string, _unescape_string
- Phase 198+: MethodCall 拡張 (multiple calls in body) → _parse_array, _parse_object
docs: Phase 195 Pattern 3 extension design (multi-carrier support) Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion: - Goal: Handle 2-3 carriers in if-else branches simultaneously - Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns) Task breakdown: - 195-1: Loop inventory (_parse_string simple, if-sum patterns) - 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support) - 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension) - 195-4: Implementation scope (2-3 carriers, existing UpdateKind range) - 195-5: Documentation updates (CURRENT_TASK.md + overview) Design decisions: - ✅ ExitLine extension (no PhiGroupBox - YAGNI principle) - ✅ Both-branch carrier definition check (unchanged = use previous value) - ❌ No ConditionEnv expansion (Phase 200+ deferred) - ❌ LoopBodyLocal + MethodCall mix deferred to Phase 195+ Target loops: 1. JsonParser _parse_string (escaped flag + buffer) - Carrier 1: escaped (BoolFlag) - conditional flag - Carrier 2: buffer (StringAppend) - else-only update 2. selfhost if-sum (sum + count) - Carrier 1: sum (NumberAccumulation) - then-only update - Carrier 2: count (CounterLike) - then-only update Test cases designed: - phase195_flag_buffer.hako (BoolFlag + StringAppend) - phase195_sum_count.hako (NumberAccumulation + CounterLike) Expected outcome: - phase195-pattern3-extension-design.md (complete design spec) - Clear implementation scope for Phase 195-impl - Path to 40% → 60% JsonParser coverage 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-09 13:22:14 +09:00
- selfhost `.hako` コンパイラの全ループを JoinIR で処理 (Phase 210+)