Files
hakorune/docs/development/current/main/phase33-10-implementation-recommendation.md

256 lines
7.6 KiB
Markdown
Raw Normal View History

refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
# Phase 33-10: Pattern 4 PHI Loss Analysis & Fix Recommendation
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Created**: 2025-12-06
**Context**: Comparison between Pattern 3 (loop_if_phi.hako) and Pattern 4 (loop_continue_pattern4.hako)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## Executive Summary
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Problem**: Pattern 4 loses its loop-body PHI instruction during JoinIR→MIR merge phase.
**Root Cause**: Block overwrite in `instruction_rewriter.rs` line 92
**Impact**: CRITICAL - incorrect sum calculation in continue scenarios
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 1. Evidence
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Pattern 3 ✅ (Preserves PHI)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```mir
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
bb10:
1: %23 = phi [%20, bb8], [%22, bb9] ← PHI PRESENT
1: %24 = const 1
1: %25 = %11 Add %24
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Pattern 4 ❌ (Loses PHI)
```mir
bb10:
1: %8 = copy %14 ← NO PHI!
1: br label bb5
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### JoinIR Creation Phase (Both Successful)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
[joinir_block/handle_select] Created merge_block BasicBlockId(5) with 1 instructions
[joinir_block/finalize_block] Preserving 1 PHI instructions in block BasicBlockId(5)
[joinir/meta] Block BasicBlockId(5): X instructions (1 PHI)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
- Pattern 3: 5 instructions (1 PHI)
- Pattern 4: 3 instructions (1 PHI)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 2. Root Cause Analysis
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Hypothesis: Block Overwrite in instruction_rewriter.rs
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Location**: `src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs:92`
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Problem Code**:
```rust
for (old_block_id, old_block) in blocks_merge {
let new_block_id = remapper.get_block(func_name, *old_block_id)...;
let mut new_block = BasicBlock::new(new_block_id); // ← ALWAYS CREATES FRESH BLOCK!
// ... copy instructions from old_block ...
current_func.add_block(new_block); // line 365
}
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Why This Fails**:
1. `handle_select()` creates bb10 (BasicBlockId → bb10) with PHI instruction
2. Later, merge phase processes JoinIR's BasicBlockId(5) which also maps to bb10
3. `BasicBlock::new(new_block_id)` creates FRESH block, discarding existing PHI
4. `add_block()` overwrites the block in HashMap
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 3. Recommended Fix
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Step 1: Add Debug Logging (Verification)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
Add to `instruction_rewriter.rs` around line 87:
```rust
for (old_block_id, old_block) in blocks_merge {
let new_block_id = remapper.get_block(func_name, *old_block_id)...;
// DEBUG: Check if block already exists
if let Some(ref current_func) = builder.current_function {
if let Some(existing) = current_func.blocks.get(&new_block_id) {
let phi_count = existing.instructions.iter()
.filter(|i| matches!(i, MirInstruction::Phi{..}))
.count();
eprintln!("[cf_loop/joinir] 🚨 Block {:?} ALREADY EXISTS: {} inst, {} PHI",
new_block_id, existing.instructions.len(), phi_count);
}
}
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
let mut new_block = BasicBlock::new(new_block_id); // ← This OVERWRITES!
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
```
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Step 2: Preserve Existing Blocks (RECOMMENDED FIX)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Modify line 92** in `instruction_rewriter.rs`:
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
```rust
// OLD: Always creates fresh block (loses existing PHI!)
let mut new_block = BasicBlock::new(new_block_id);
// NEW: Preserve existing block if present
let mut new_block = if let Some(ref mut current_func) = builder.current_function {
// Remove and reuse existing block (preserves PHI!)
current_func.blocks.remove(&new_block_id)
.unwrap_or_else(|| BasicBlock::new(new_block_id))
} else {
BasicBlock::new(new_block_id)
};
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Why This Works**:
- If bb10 was created by `handle_select()` with PHI, we **retrieve and reuse** it
- New instructions from JoinIR merge are **appended** to existing instructions
- PHI instruction at the beginning of bb10 is **preserved**
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Step 3: Alternative - Check add_block() Logic
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
If Step 2 doesn't work, check `MirFunction::add_block()` implementation:
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
```rust
// If this uses .insert(), it will OVERWRITE existing blocks!
pub fn add_block(&mut self, block: BasicBlock) {
self.blocks.insert(block.id, block); // ← HashMap::insert overwrites!
}
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
// Should be:
pub fn add_block(&mut self, block: BasicBlock) {
if let Some(existing) = self.blocks.get_mut(&block.id) {
// Merge: prepend existing PHI, append new instructions
let mut merged = existing.instructions.clone();
merged.extend(block.instructions);
existing.instructions = merged;
existing.terminator = block.terminator;
} else {
self.blocks.insert(block.id, block);
}
}
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 4. Testing Strategy
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 4.1 Before Fix - Reproduce PHI Loss
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
```bash
./target/release/hakorune --dump-mir apps/tests/loop_continue_pattern4.hako 2>&1 | \
grep -A3 "^bb10:"
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Current Output (BUG)**:
```mir
bb10:
1: %8 = copy %14 ← NO PHI!
1: br label bb5
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 4.2 After Fix - Verify PHI Preservation
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
```bash
# Same command after applying Step 2 fix
./target/release/hakorune --dump-mir apps/tests/loop_continue_pattern4.hako 2>&1 | \
grep -A3 "^bb10:"
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Expected Output (FIXED)**:
```mir
bb10:
1: %16 = phi [%4, bb8], [%14, bb9] ← PHI RESTORED!
1: %8 = copy %14
1: br label bb5
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 4.3 Compare with Pattern 3 (Control)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
Pattern 3 should continue to work correctly (no regression):
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
```bash
./target/release/hakorune --dump-mir apps/tests/loop_if_phi.hako 2>&1 | \
grep -A3 "^bb10:"
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Expected Output (Control)**:
```mir
bb10:
1: %23 = phi [%20, bb8], [%22, bb9] ← PHI PRESENT (as before)
1: %24 = const 1
1: %25 = %11 Add %24
```
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 5. Code Locations
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Files to Modify
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
| File | Lines | Purpose |
|------|-------|---------|
| `src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs` | 92 | Fix block overwrite |
| `src/mir/builder/control_flow/joinir/merge/instruction_rewriter.rs` | 87-90 | Add debug logging |
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### Reference Files (For Understanding)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
| File | Purpose |
|------|---------|
| `src/mir/join_ir_vm_bridge/joinir_block_converter.rs` | Select→PHI conversion (handle_select) |
| `src/mir/join_ir/lowering/loop_with_continue_minimal.rs` | Pattern 4 lowerer (Select at line 304) |
| `src/mir/join_ir/lowering/loop_with_if_phi_minimal.rs` | Pattern 3 lowerer (comparison) |
| `apps/tests/loop_continue_pattern4.hako` | Test case showing PHI loss |
| `apps/tests/loop_if_phi.hako` | Control test case (PHI preserved) |
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
---
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 6. Summary & Next Steps
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 6.1 Key Findings
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
1. **PHI Loss Mechanism**: Block overwrite in merge phase, not JoinIR conversion
2. **Root Cause**: `BasicBlock::new()` always creates fresh block at line 92
3. **Impact**: Pattern 4 produces incorrect results due to missing PHI
4. **Solution**: Preserve existing blocks by removing before recreating
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 6.2 Implementation Checklist
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
- [ ] Add debug logging (Step 1) - 5 minutes
- [ ] Apply block preservation fix (Step 2) - 10 minutes
- [ ] Test Pattern 4 PHI restoration - 5 minutes
- [ ] Verify Pattern 3 no regression - 2 minutes
- [ ] Run full test suite - 10 minutes
- [ ] Commit with detailed message - 5 minutes
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Total Time**: ~40 minutes
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
### 6.3 Expected Impact
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Correctness**:
- ✅ Pattern 4 will produce correct sum values
- ✅ PHI instructions preserved in all loop patterns
- ✅ No regression for existing patterns
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Code Quality**:
- ✅ Proper block lifecycle management
- ✅ No silent instruction loss
- ✅ Better debugging with added logging
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
---
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
## 7. Related Documentation
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
- **Analysis Document**: [phase33-10-joinir-merge-phi-loss-analysis.md](phase33-10-joinir-merge-phi-loss-analysis.md)
- **Local Pattern Analysis**: [phase33-10-local-pattern-mir-analysis.md](phase33-10-local-pattern-mir-analysis.md)
- **JoinIR Design**: [if_joinir_design.md](../../../private/roadmap2/phases/phase-33-joinir-if-phi-cleanup/if_joinir_design.md)
feat(joinir): Phase 34-6 MethodCall 構造と本物の substring 意味論 **Phase 34-6 実装完了**: MethodCall 構造を JoinIR に追加し、本物の substring 呼び出しを通すことに成功。 ## 主要変更 ### 1. MethodCall 構造追加 (34-6.1) - `src/mir/join_ir/mod.rs`: JoinInst::MethodCall バリアント (+8 lines) - 構造: `{ dst, receiver, method, args }` - 設計原則: JoinIR は構造のみ、意味論は MIR レベル ### 2. extract_value 更新 (34-6.2) - `src/mir/join_ir/frontend/ast_lowerer.rs`: Method 処理本物化 (+37 lines) - receiver/args を extract_value で再帰処理 - ダミー Const(0) 削除 → 本物の MethodCall 生成 - cond 処理修正: ValueId(0) ハードコード → extract_value で取得 ### 3. JoinIR→MIR 変換実装 (34-6.3) - `src/mir/join_ir_vm_bridge.rs`: MethodCall → BoxCall 変換 (+12 lines) - `src/mir/join_ir/json.rs`: MethodCall JSON シリアライゼーション (+16 lines) - `src/mir/join_ir_runner.rs`: MethodCall 未対応エラー (+7 lines) ### 4. テスト更新 (34-6.4) - `docs/.../fixtures/json_shape_read_value.program.json`: 本物の substring 構造 - `src/tests/joinir_frontend_if_select.rs`: run_joinir_via_vm 使用 - テスト成功: v="hello", at=3 → "hel" ✅ ## 成果 - ✅ テスト全通過(1 passed; 0 failed) - ✅ 設計原則確立: JoinIR = 構造 SSOT、意味論 = MIR レベル - ✅ Phase 33-10 原則との整合性: Method でも同じ原則適用 **ドキュメント更新**: CURRENT_TASK.md + TASKS.md(Phase 34-6 完了記録) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-27 17:05:46 +09:00
---
refactor(joinir): Phase 193-1 - AST Feature Extractor Box modularization **Phase 193-1**: Create independent AST Feature Extractor Box module ## Summary Extracted feature detection logic from router.rs into a new, reusable ast_feature_extractor.rs module. This improves: - **Modularity**: Feature extraction is now a pure, side-effect-free module - **Reusability**: Can be used for Pattern 5-6 detection and analysis tools - **Testability**: Pure functions can be unit tested independently - **Maintainability**: Clear separation of concerns (router does dispatch, extractor does analysis) ## Changes ### New Files - **src/mir/builder/control_flow/joinir/patterns/ast_feature_extractor.rs** (+180 lines) - `detect_continue_in_body()`: Detect continue statements - `detect_break_in_body()`: Detect break statements - `extract_features()`: Full feature extraction pipeline - `detect_if_else_phi_in_body()`: Pattern detection for if-else PHI - `count_carriers_in_body()`: Heuristic carrier counting - Unit tests for basic functionality ### Modified Files - **src/mir/builder/control_flow/joinir/patterns/router.rs** - Removed 75 lines of feature detection code - Now delegates to `ast_features::` module - Phase 193 documentation in comments - Cleaner separation of concerns - **src/mir/builder/control_flow/joinir/patterns/mod.rs** - Added module declaration for ast_feature_extractor - Updated documentation with Phase 193 info ## Architecture ``` router.rs (10 lines) └─→ ast_feature_extractor.rs (180 lines) - Pure functions for AST analysis - No side effects - High reusability - Testable in isolation ``` ## Testing ✅ Build succeeds: `cargo build --release` compiles cleanly ✅ Binary compatibility: Existing .hako files execute correctly ✅ No logic changes: Feature detection identical to previous implementation ## Metrics - Lines moved from router to new module: 75 - New module total: 180 lines (including tests and documentation) - Router.rs reduced by ~40% in feature detection code - New module rated ⭐⭐⭐⭐⭐ for reusability and independence ## Next Steps - Phase 193-2: CarrierInfo Builder Enhancement - Phase 193-3: Pattern Classification Improvement - Phase 194: Further pattern detection optimizations 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-06 03:30:03 +09:00
**Created**: 2025-12-06
**Status**: Analysis Complete, Ready for Implementation
**Priority**: HIGH (Correctness Issue)