ad9daf37ac
feat(joinir): Phase 56 ArrayExtBox.filter JoinIR lowering完全実装
...
## Summary
ArrayExtBox.filter/2 の JoinIR Frontend lowering を完全実装し、
ConditionalMethodCall 命令を導入して filter パターンに対応。
56 JoinIR テスト全て PASS(退行なし)。
## Technical Changes
### 1. ConditionalMethodCall 命令追加
- **新規命令**: `if pred(v) { acc.push(v) }` パターン用
- **構造**: cond が true なら method 実行、false なら no-op
- **MIR 変換**: 4ブロック構造 (cond→then/else→merge)
### 2. AST JSON 拡張
- Break/Continue/FunctionCall に "type" フィールド追加
- ArrayLiteral/MapLiteral に "type" フィールド追加
- JoinIR Frontend 互換性向上
### 3. Expression Handler 拡張
- Unary 演算子(not, 負号)サポート
- Call(変数関数呼び出し)を MethodCall に変換
### 4. Loop Pattern Binding 修正
- `BoundExpr::Variable("n")` 問題修正
- `MethodCall { receiver: "arr", method: "size" }` に変更
- external_refs (arr, pred) を step 関数に伝播
### 5. If Statement Handler 拡張
- 条件付き側効果パターン(ケース4)追加
- MethodCall/Method 形式の statement を ConditionalMethodCall に変換
## Files Modified (10 files, +456/-45 lines)
- ast_json.rs: AST JSON "type" フィールド追加
- loop_frontend_binding.rs: n バインディング修正
- control_flow.rs: external_refs params 追加
- loop_patterns.rs: external_refs step 関数伝播
- expr.rs: Unary, Call handler 追加
- stmt_handlers.rs: ConditionalMethodCall パターン追加
- mod.rs: ConditionalMethodCall, UnaryOp 定義
- json.rs: ConditionalMethodCall, UnaryOp シリアライズ
- join_ir_runner.rs: ConditionalMethodCall, UnaryOp スタブ
- convert.rs: ConditionalMethodCall → MIR 変換
## Test Results
- 56 JoinIR tests: ✅ PASSED
- Regression: ❌ None
- ArrayExtBox.filter/2: ✅ JoinIR lowering 成功
## Milestone
JoinIR 2ループ完走達成:
- ✅ JsonTokenizer.print_tokens/0
- ✅ ArrayExtBox.filter/2 (NEW!)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-29 06:51:43 +09:00
e27934d91a
feat(joinir): Phase 52-53 LoopFrontendBinding JSON + Statement Handlers
...
Phase 52: LoopFrontendBinding JSON generation fixes
- Add receiver_to_json() for Field node structure (me.tokens)
- Add needs_me_receiver() for instance method detection
- Fix "condition" → "cond" key for JoinIR Frontend
- Add me parameter propagation in loop_patterns.rs
- Add JoinIR-compatible type fields in ast_json.rs
- Variable → "type": "Var"
- Literal → "type": "Int"/"Bool" (literal_to_joinir_json)
- BinaryOp → "type": "Binary"/"Compare" (is_compare_op)
- MethodCall → "type": "Method"
Phase 53: Statement Handler module for loop body
- NEW: stmt_handlers.rs with StatementEffect type
- Support: Local, Assignment, Print, Method, If statements
- If lowering: single variable update → Select instruction
- Remove hardcoded assert in loop_patterns.rs
- Replace with generic lower_statement() calls
Test results: 56 JoinIR tests PASS, 7 loop_frontend_binding tests PASS
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-29 04:42:16 +09:00
3dc691d39f
feat(joinir): Phase 50 Loop Frontend Binding layer
...
Phase 50 implements the Loop Frontend Binding layer that maps
actual loop variables to JoinIR Frontend's expected names (i, acc, n).
## Changes
- Add loop_frontend_binding.rs module with:
- LoopFrontendBinding struct for variable mapping
- for_print_tokens() and for_array_filter() factory methods
- generate_local_declarations() for JSON v0 format
- rename_body_variables() for out → acc renaming
- Integrate binding with cf_loop_joinir_impl:
- Create binding based on function name
- Inject i/acc/n Local declarations into JSON v0
- Use correct JoinIR Frontend type names (Int/Var/Method)
## Limitations Found
JoinIR Frontend doesn't support:
- Field access (me.tokens) - blocks print_tokens
- NewBox (new ArrayBox()) - blocks array_filter
These will be addressed in Phase 51.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-28 20:59:54 +09:00