853d80ba74
feat(joinir): Phase 34-7.5 helpers + Phase 34-8 Break/Continue implementation
...
Phase 34-7.5: Code organization improvements
- Added type conversion helpers (as_cont/as_func) in join_ir/mod.rs
- Enhanced docstrings for JoinCall/JoinJump with usage examples
- Improved error messages in join_ir_vm_bridge.rs
JoinIrFrontendTestRunner box implementation
- Created src/tests/helpers/joinir_frontend.rs (119 lines)
- Reduced test code by 83% (70 lines → 12 lines per test)
- 26% overall reduction in test file (284 → 209 lines)
Phase 34-8: Break/Continue pattern implementation
- Extended ast_lowerer.rs (+630 lines)
- lower_loop_break_pattern(): Break as Jump (early return)
- lower_loop_continue_pattern(): Continue as Select + Call
- Added Bool literal support in extract_value()
- Created 2 fixtures: loop_frontend_{break,continue}.program.json
- Added 2 A/B tests (all 6 Phase 34 tests PASS)
Technical achievements:
- Break = Jump (early return pattern)
- Continue = Select + Call (NOT Jump) - critical discovery
- 3-function structure sufficient (no k_continue needed)
- SSA-style re-assignment with natural var_map updates
Test results:
✅ joinir_frontend_if_select_simple_ab_test
✅ joinir_frontend_if_select_local_ab_test
✅ joinir_frontend_json_shape_read_value_ab_test
✅ joinir_frontend_loop_simple_ab_test
✅ joinir_frontend_loop_break_ab_test
✅ joinir_frontend_loop_continue_ab_test
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-28 01:02:49 +09:00
588129db65
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
35cd93a37a
Phase 33-2: JoinInst::Select implementation + minimal If JoinIR lowering
...
Implementation:
- Add JoinInst::Select variant to JoinIR schema
- Implement Select execution in JoinIR Runner (Bool/Int cond support)
- Add Select handling in JoinIR→MIR Bridge (4-block structure)
- Create test cases (joinir_if_select_simple/local.hako)
- Add dev toggle NYASH_JOINIR_IF_SELECT=1
- Create lowering infrastructure (if_select.rs, stub for Phase 33-3)
Tests:
- 3/3 unit tests pass (test_select_true/false/int_cond)
- Integration tests pass (RC: 0)
- A/B execution verified (existing if_phi vs JoinIR Select)
Files changed:
- New: apps/tests/joinir_if_select_{simple,local}.hako
- New: src/mir/join_ir/lowering/if_select.rs
- Modified: src/mir/join_ir/{mod,json,runner,vm_bridge}.rs
- Modified: src/config/env.rs (joinir_if_select_enabled)
- Modified: docs/reference/environment-variables.md
Phase 33-3 ready: MIR pattern recognition + auto-lowering pending
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-27 02:58:38 +09:00
1eea40454f
test(joinir): L-2.2 Step-3 - Add Stage-B JoinIR→MIR structure tests
...
- Expose `convert_joinir_to_mir` as `pub(crate)` for test access
- Add `joinir_stageb_body_structure_test` and
`joinir_stageb_funcscanner_structure_test` to `joinir_json_min.rs`
- Verify: JoinIR lowering succeeds, JoinIR→MIR conversion succeeds,
function count matches, each function has >= 1 block
- Result: Both Stage-B functions produce 2 JoinIR functions
(entry + loop_step) with appropriate block counts
- Note: Current tests verify handwritten JoinIR→MIR bridge layer,
not full MIR→JoinIR roundtrip (future improvement)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-26 11:38:45 +09:00
51ff558904
feat(phase32): L-2.1 Stage-1 UsingResolver JoinIR integration + cleanup
...
Phase 32 L-2.1 complete implementation:
1. Stage-1 UsingResolver main line JoinIR connection
- CFG-based LoopForm construction for resolve_for_source/5
- LoopToJoinLowerer integration with handwritten fallback
- JSON snapshot tests 6/6 PASS
2. JoinIR/VM Bridge improvements
- Simplified join_ir_vm_bridge.rs dispatch logic
- Enhanced json.rs serialization
- PHI core boxes cleanup (local_scope_inspector, loop_exit_liveness, loop_var_classifier)
3. Stage-1 CLI enhancements
- Extended args.rs, groups.rs, mod.rs for new options
- Improved stage1_bridge module (args, env, mod)
- Updated stage1_cli.hako
4. MIR builder cleanup
- Simplified if_form.rs control flow
- Removed dead code from loop_builder.rs
- Enhanced phi_merge.rs
5. Runner module updates
- json_v0_bridge/lowering.rs improvements
- dispatch.rs, selfhost.rs, modes/vm.rs cleanup
6. Documentation updates
- CURRENT_TASK.md, AGENTS.md
- Various docs/ updates
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-26 10:17:37 +09:00
ee2b3115ee
feat(joinir): FuncScannerBox.trim/1 JoinIR VM Bridge A/B test
...
Phase 30.x: JoinIR VM Bridge でPHI問題を設計で解決できることを実証
変更内容:
- src/runner/modes/vm.rs: FuncScannerBox.trim/1 検出時にJoinIR経由実行
- src/mir/join_ir_vm_bridge.rs: Non-tail call サポート追加
- dst=Some(id) の場合、結果を格納して次の命令へ継続
- src/tests/joinir_vm_bridge_trim.rs: A/Bテスト新規作成
- メインテスト: Route A (VM) → "void" (PHI bug), Route C (JoinIR) → "abc" ✅
- エッジケース: 5パターン全てPASS
- src/config/env.rs: joinir_vm_bridge_debug() 追加
- docs: Phase 30 TASKS.md に L-0.4 追加
テスト結果:
Route A (MIR→VM直接): "void" ← PHI バグ
Route C (MIR→JoinIR→VM): "abc" ← 正解 ✅
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-25 12:22:08 +09:00
da1a5558e5
Normalize passes keep spans and clean warnings
2025-11-24 15:02:51 +09:00
466e636af6
Span trace utilities and runner source hint
2025-11-24 14:17:02 +09:00
bff223eff9
feat(joinir): Phase 27-shortterm S-4 完了 - JoinIR → Rust VM ブリッジ参考実装
...
## 実装内容
### S-4.1: VM インターフェース調査
- VMValue 定義調査(Integer/Float/Bool/String/Future/Void/BoxRef)
- execute_module() API 調査
### S-4.2: JoinValue ↔ VMValue 変換関数実装
- src/mir/join_ir_ops.rs に変換関数追加(+121行)
- to_vm_value()/from_vm_value() 実装
- Float/Future/BoxRef は非対応エラー
### S-4.3: join_ir_vm_bridge.rs 基本構造実装
- src/mir/join_ir_vm_bridge.rs 新規作成(362行)
- run_joinir_via_vm() API 実装
- convert_join_function_to_mir() 実装
- 7つのコンパイルエラー修正完了
### S-4.4-A: Call/Jump 命令実装(skip_ws パターンのみ)
- Call: 末尾呼び出しのみサポート
- Jump: Multi-block CFG 生成(Branch + Return)
- 非対応パターンは unimplemented!() で落とす
### S-4.4-B: A/B テスト作成
- src/tests/joinir_vm_bridge_skip_ws.rs 作成(104行)
- Route A: 直接 VM 実行
- Route C: JoinIR → VM bridge 経由
- skip_ws(" abc") → 3 の A/B 比較実装
## 戦略転換
ChatGPT 先生 + Task 先生の分析により、**Approach 2 (JoinIR Runner 本線化 + ガードレール)** への移行が決定。
本ブリッジ実装は参考実装として保持し、これ以上は太らせない方針。次フェーズで JoinIR Runner を method_router 経由で Rust VM と統合する。
2025-11-24 07:24:42 +09:00
7a9b23c9d1
feat(joinir): Phase 27-shortterm S-4.1~S-4.3 - JoinIR→VM Bridge基本実装
...
## S-4.1: VM インターフェース調査
- VMValue 型定義確認 (Integer, Bool, String, Void, BoxRef)
- VM API 確認 (execute_module, stats_counters)
- Task tool による詳細レポート取得
## S-4.2: JoinValue ↔ VMValue 変換関数実装
**新規追加**: src/mir/join_ir_ops.rs (+121行)
- JoinValue::to_vm_value() - 4型すべて対応
- JoinValue::from_vm_value() - エラーハンドリング付き
- Float/Future/BoxRef は非対応(エラー返却)
- 包括的テスト追加 (正常系・異常系)
## S-4.3: join_ir_vm_bridge.rs 基本構造実装
**新規ファイル**: src/mir/join_ir_vm_bridge.rs (350行)
### Public API
- run_joinir_via_vm() - JoinIR モジュールを VM で実行
### JoinIR → MIR 変換
- convert_joinir_to_mir() - JoinModule → MirModule
- convert_join_function_to_mir() - JoinFunction → MirFunction
- convert_mir_like_inst() - Compute命令変換
### 最小実装スコープ (Phase 27-shortterm)
✅ Compute 命令 (Const, BinOp, Compare, BoxCall)
✅ Ret 命令
⏳ Call/Jump 命令 (TODO: S-4.4 で実装)
### 設計方針
- JoinIR の正規化構造 (Pinned/Carrier, Exit φ) を保持
- マッピングだけで済ませる(正規化は消えない)
- VM の機能 (GC, plugins, error handling) を活用
## コンパイル
✅ 完全成功 (0エラー)
## 次のステップ
S-4.4: skip_ws で A/B テスト green 化
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-24 06:16:45 +09:00