|
|
447bbec998
|
refactor(joinir): Split ast_lowerer and join_ir_vm_bridge into modules
ast_lowerer.rs → ast_lowerer/ (10 files):
- mod.rs: public surface + entry dispatch
- context.rs: ExtractCtx helpers
- expr.rs: expression-to-JoinIR extraction
- if_return.rs: simple if→Select lowering
- loop_patterns.rs: loop variants (simple/break/continue)
- read_quoted.rs: read_quoted_from lowering (Phase 45-46)
- nested_if.rs: NestedIfMerge lowering
- analysis.rs: loop if-var analysis + metadata helpers
- tests.rs: frontend lowering tests
- README.md: module documentation
join_ir_vm_bridge.rs → join_ir_vm_bridge/ (5 files):
- mod.rs: public surface + shared helpers
- convert.rs: JoinIR→MIR lowering
- runner.rs: VM execution entry (run_joinir_via_vm)
- meta.rs: experimental metadata-aware hooks
- tests.rs: bridge-specific unit tests
- README.md: module documentation
Benefits:
- Clear separation of concerns per pattern
- Easier navigation and maintenance
- Each file has single responsibility
- README documents module boundaries
Co-authored-by: ChatGPT <noreply@openai.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-28 17:42:19 +09:00 |
|
|
|
d8a1d97222
|
feat(joinir): Phase 41-4.1 Add NestedIfMerge JoinInst variant
Add structural support for nested if patterns with PHI-sensitive variables:
1. JoinInst::NestedIfMerge in mod.rs
- conds: Vec<VarId> (outer to inner conditions)
- merges: Vec<MergePair> (variable updates at deepest level)
- k_next: Option<JoinContId> (continuation after merge)
2. JSON serialization in json.rs
- Type: "nested_if_merge"
- Fields: conds[], merges[], k_next
3. Runner/Bridge stubs
- JoinIR Runner: Returns error (use VM Bridge instead)
- VM Bridge: panic placeholder (41-4.3 will implement)
Target: ParserControlBox.parse_loop() (4-level nested if)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-28 12:32:25 +09:00 |
|
|
|
c2fb9dab6b
|
feat(joinir): Phase 35-5 PHI box deletion (430 lines HIGH safety)
Phase 35-5: First wave deletion
- Deleted if_body_local_merge.rs (339 lines, 0 external calls)
- Inlined logic into PhiBuilderBox::compute_modified_names_if()
- Absorbed into PhiBuilderBox (isolated box with no external dependencies)
- Deleted phi_invariants.rs (91 lines, moved to JoinIR Verifier)
- Removed ensure_if_values_exist() call from phi_builder_box.rs
- Validation responsibility transferred to JoinIR Verifier
- Updated PHI_BOX_INVENTORY.md with deletion records
Phase 35-3/4: Documentation and route unification
- Added frontend_covered column to PHI_BOX_INVENTORY.md
- Documented JoinIR Runner routes (Route A: SSOT, Route B: structure validation)
- Updated join_ir_runner.rs module docstring with clear route guidelines
Build and test status:
✅ cargo build --release: Clean
✅ Phase 34 tests: All PASS (no regression)
✅ JoinIR tests: joinir_frontend_if_select, test_if_merge_simple_pattern PASS
Total reduction: 430 lines (HIGH safety achieved)
Phase 36+ potential: ~3,275 lines (MEDIUM/LOW safety)
Related docs:
- docs/private/roadmap2/phases/phase-35-phi-reduction/README.md
- docs/private/roadmap2/phases/phase-35-phi-reduction-investigation-report.md
- docs/private/roadmap2/phases/phase-30-final-joinir-world/PHI_BOX_INVENTORY.md
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-28 01:18:57 +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 |
|
|
|
466e636af6
|
Span trace utilities and runner source hint
|
2025-11-24 14:17:02 +09:00 |
|
|
|
98dadf446f
|
feat(joinir): S-5.2-improved - VM完全意味論統合完了
Phase 27-shortterm S-5.2-improved 実装完了:
## 実装内容
1. **execute_box_call() ラッパー追加**:
- src/backend/mir_interpreter/mod.rs に公開 API 実装
- 1_000_000 番台レジスタで一時値管理
- 適切なクリーンアップ処理実装
2. **handle_box_call 可視性変更**:
- src/backend/mir_interpreter/handlers/boxes.rs を pub に変更
- JoinIR Runner からアクセス可能に
3. **JoinIR Runner BoxCall 統合**:
- src/mir/join_ir_runner.rs の BoxCall 処理を書き換え
- StringBox 直接呼び出し削除
- VM の execute_box_call 経由に変更
- JoinValue ↔ VMValue 変換で統合
4. **不要な関数削除**:
- expect_str(), expect_int(), box_to_join_value() 削除
- VMValue 変換に一本化
5. **テスト更新**:
- joinir_runner_standalone.rs: VM インスタンス追加
- joinir_runner_min.rs: VM 再利用
## 期待される効果
✅ Void guards 完全対応 (Void.length() → 0)
✅ PluginBox/InstanceBox 将来対応可能
✅ VM の完全な BoxCall 意味論統一
✅ VM 2号機回避(ガードレール設計成功)
## テスト結果
✅ joinir_runner_standalone_skip_ws ... ok
✅ joinir_runner_standalone_trim ... ok
✅ ビルド成功(0エラー)
## 完了タスク
- [x] MirInterpreter::execute_box_call() 実装
- [x] 1_000_000 レジスタ帯域割り当て
- [x] regs クリーンアップ実装
- [x] JoinIR Runner BoxCall 書き換え
- [x] テスト更新&PASS確認
🎉 VM 完全意味論統合完了!
|
2025-11-24 08:37:59 +09:00 |
|
|
|
a8555e67d5
|
feat(joinir): S-5.2完了 - BoxCall → VM method_router 経由実装
実装内容:
- box_to_join_value() ヘルパー関数追加(VM Box → JoinValue 変換)
- StringBox.length/substring を VM 実装経由で呼び出し(hardcoded削除)
- safe_substring() 削除(不要になった)
技術的成果:
- ガードレール設計実現: 制御フローは JoinIR Runner、Box実装は VM に委譲
- VM 2号機 回避: Box実装の重複なし
- テスト全 PASS: joinir_runner_standalone_skip_ws/trim 両方成功
Phase 27-shortterm S-5.2 完了 ✅
|
2025-11-24 08:01:56 +09:00 |
|
|
|
78c9d4d7fc
|
feat(joinir): Phase 27.8-1~3 — Ops Box導入 + Toggle対応完了
## Phase 27.8-1: JoinIR 命令意味箱(Ops Box)作成 ✅
**新規ファイル**: `src/mir/join_ir_ops.rs`
- `eval_binop()`: Add, Sub, Mul, Div, Or, And の評価ロジック一元化
- `eval_compare()`: Lt, Le, Gt, Ge, Eq, Ne の比較ロジック一元化
- エラー処理: `JoinIrOpError` 型で型安全
- 完全テストカバレッジ: 13個のユニットテスト
**効果**:
- BinOp/Compare の評価ロジックを一箇所に集約
- 再利用可能な API で将来の拡張が容易
- テスタビリティ向上
## Phase 27.8-2: join_ir_runner.rs の Ops Box 統合 ✅
**変更**: `src/mir/join_ir_runner.rs`
- BinOp/Compare の実装を ops box に完全移譲(約70行削減)
- `JoinValue` / `JoinIrOpError` を ops box から再エクスポート
- 後方互換性維持: `JoinRuntimeError = JoinIrOpError`
**効果**:
- コード重複削減(約70行)
- 実装の一貫性保証(ops box の単一実装を使用)
## Phase 27.8-3: MIR→JoinIR Toggle 対応 ✅
**変更**: `src/mir/join_ir.rs`
- `lower_skip_ws_to_joinir()`: トグル対応ディスパッチャー
- `lower_skip_ws_handwritten()`: 既存実装をリネーム(Phase 27.1-27.7)
- `lower_skip_ws_from_mir()`: MIR自動解析版スタブ(Phase 27.8-4 で実装予定)
**環境変数制御**:
```bash
# 手書き版(デフォルト)
./target/release/hakorune program.hako
# MIR自動解析版(Phase 27.8-4 実装予定)
NYASH_JOINIR_LOWER_FROM_MIR=1 ./target/release/hakorune program.hako
```
**効果**:
- 段階的な移行が可能(既存動作を完全に維持)
- A/B テストによる検証が容易
## 変更ファイル
- `src/mir/join_ir_ops.rs` (新規): Ops Box 実装
- `src/mir/join_ir_runner.rs`: Ops Box 使用に変更
- `src/mir/join_ir.rs`: Toggle 対応ディスパッチャー追加
- `src/mir/mod.rs`: join_ir_ops モジュール追加
## コンパイル結果
✅ 0 errors, 18 warnings(既存警告のみ)
✅ ビルド成功
## 次のステップ
**Phase 27.8-4**: `lower_skip_ws_from_mir()` 本実装
- MirQuery を使った MIR 解析
- パターンマッチング(init, header, break checks, body)
- JoinIR 自動生成(entry function + loop_step function)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
|
2025-11-23 14:47:00 +09:00 |
|
|
|
0852a397d9
|
Add experimental JoinIR runner and tests
|
2025-11-23 08:38:15 +09:00 |
|