b4b6a01b92
feat(joinir): Phase 65-2-A StringBox メソッド型ヒント実装
...
Phase 65-2-A 完了:P3-A(StringBox メソッド)型ヒント実装
## 実装内容
### 1. type_inference.rs 新規作成
- `infer_method_return_type()`: StringBox/ArrayBox/MapBox メソッド型推論
- `infer_box_type()`: Box コンストラクタ型推論(Phase 65-2-B 用)
- 8 テスト全て PASS
### 2. JoinInst::MethodCall に type_hint 追加
- `src/mir/join_ir/mod.rs`: `type_hint: Option<MirType>` フィールド追加
- 段階的拡大のため Optional 設計(既存コード破壊なし)
### 3. read_quoted.rs で型ヒント設定
- substring() → String(4箇所)
- length() → Integer(1箇所)
- read_quoted 系関数で完全な型ヒント供給
### 4. 汎用経路は None で後方互換性維持
- expr.rs: 汎用 MethodCall は `type_hint: None`
- convert.rs: 型ヒント追加(Phase 65-3 で活用予定)
- json.rs: JSON シリアライズ対応
## テスト結果
- ✅ type_inference モジュール: 8/8 PASS
- ✅ ビルド: 0 エラー
## 次のステップ
- Phase 65-2-B: Box コンストラクタ型ヒント実装
---
🌟 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-30 06:10:58 +09:00
8f736358c4
feat(joinir): Phase 63-4 infer_type_from_phi degradation design
...
Phase 63-4: infer_type_from_phi を『JoinIR 型ヒント優先+従来ロジックフォールバック』に縮退する仕様を設計(実装は Phase 63-5+)
## Changes
### Documentation Updates
- **README.md**: Added complete Phase 63-4 design (63-4.1 through 63-4.5)
- 63-4.1: Current state analysis (definition location, callsites, role, JoinIR preparation)
- 63-4.2: Degradation spec (type_hint priority + fallback pattern)
- 63-4.3: Representative cases and A/B testing strategy (P1/P2/P3)
- 63-4.4: Deletion conditions (5 conditions, current: 2/5 = 40%)
- 63-4.5: Phase 63-5 handoff (infer_type_from_phi_with_hint() implementation tasks)
- **PHI_BOX_INVENTORY.md**: Updated if_phi.rs entry with Phase 63-4 deletion plan
- Added: "Phase 63-4完了: infer_type_from_phi の JoinIR type_hint 優先への縮退案を設計(実装は Phase 63-5+)"
- **CURRENT_TASK.md**: Added Phase 63-4 section with summary of design work
## Design Highlights
### Degradation Pattern
```rust
pub fn infer_type_from_phi_with_hint(
function: &MirFunction,
ret_val: ValueId,
types: &BTreeMap<ValueId, MirType>,
type_hint: Option<MirType>,
) -> Option<MirType> {
if let Some(hint) = type_hint {
return Some(hint); // Route B: JoinIR priority (SSOT)
}
infer_type_from_phi(function, ret_val, types) // Route A: Fallback
}
```
### Representative Cases
- **P1**: IfSelectTest.simple/local (Phase 63-5 target)
- **P2**: read_quoted_from (Phase 63-6+ target)
- **P3**: MethodCall/Box constructors (Phase 64+ expansion)
### Deletion Conditions (2/5 achieved)
1. ✅ JoinIR has type_hint field (Phase 63-3)
2. ✅ Type hints populated for representative cases (Phase 63-2)
3. ⏳ Degraded to type_hint priority (Phase 63-5)
4. ⏳ P1 cases determined by type_hint only (Phase 63-5)
5. ⏳ All functions use type hints (Phase 64+)
## Files Changed
- docs/private/roadmap2/phases/phase-63-joinir-type-info/README.md
- docs/private/roadmap2/phases/phase-30-final-joinir-world/PHI_BOX_INVENTORY.md
- CURRENT_TASK.md
## Next Steps
Phase 63-5: Implement degradation for P1 cases (IfSelectTest.simple/local)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-29 17:58:06 +09:00
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
6bb6f38a1c
feat(joinir): Phase 51 Field access / NewBox 式タイプ拡張
...
JoinIR Frontend の式タイプを拡張し、Field access と NewBox のパースと
MIR 変換をサポート。
## 新機能
### Field access (me.tokens 等)
- expr.rs に "Field" タイプハンドラ追加
- JoinInst::FieldAccess バリアント追加
- MIR 変換: FieldAccess → BoxCall (getter pattern)
### NewBox (new ArrayBox() 等)
- expr.rs に "NewBox" タイプハンドラ追加
- JoinInst::NewBox バリアント追加
- MIR 変換: NewBox → MirInstruction::NewBox
## 修正ファイル
- src/mir/join_ir/mod.rs: JoinInst 拡張
- src/mir/join_ir/frontend/ast_lowerer/expr.rs: パース対応
- src/mir/join_ir_vm_bridge/convert.rs: MIR 変換
- src/mir/join_ir_runner.rs: ハンドラ追加
- src/mir/join_ir/json.rs: JSON シリアライズ
## 注意
print_tokens/array_filter の JoinIR 完走には Phase 52 で
JSON 生成側 (LoopFrontendBinding) の修正が必要。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-28 21:10:30 +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
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
e9c7d27a7f
feat(joinir): Phase 30.x jsonir v0 - JoinIR JSON serialization
...
Implement JSON serialization for JoinIR module.
Implementation:
- src/mir/join_ir/json.rs: JSON serializer (~250 lines, no external deps)
- src/tests/joinir_json_min.rs: Integration tests (8 unit + 2 integration)
- 10 tests total, all passing
Features:
- JoinModule → JSON serialization
- All instruction types: Call, Jump, Ret, Compute
- All MirLikeInst types: Const, BinOp, Compare, BoxCall
- Full ConstValue support: Integer, Bool, String, Null
- Full operator coverage: Add/Sub/Mul/Div/Or/And, Lt/Le/Gt/Ge/Eq/Ne
- JSON string escaping for special characters
Usage:
use crate::mir::join_ir::json::join_module_to_json_string;
let json = join_module_to_json_string(&module);
Non-goals (this phase):
- CLI flag (--emit-joinir-json)
- JSON → JoinIR reverse conversion
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-25 09:53:26 +09:00
96ce02eef4
feat(joinir): add progress carrier verification for skip_ws (Phase 29 L-5.2)
...
Implement zero-progress backedge detection for JoinIR loops:
- Create verify.rs module with ProgressError enum
- verify_progress_for_skip_ws() checks BinOp::Add before recursive calls
- Hook into joinir_runner_standalone_skip_ws test (NYASH_JOINIR_EXPERIMENT=1)
- Currently warning-only, will upgrade to error in Phase 30
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-25 06:38:43 +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
3d5979c78e
refactor(joinir): Phase 27.9 - Modular separation of join_ir.rs into directory structure
...
Phase 27.9 で join_ir.rs (~1,336行) を以下のモジュール構造に分離:
## 新規ディレクトリ構造:
```
src/mir/join_ir/
├── mod.rs # 型定義・共通ユーティリティ (~330行)
└── lowering/
├── mod.rs # lowering インターフェース
├── min_loop.rs # lower_min_loop_to_joinir (~140行)
├── skip_ws.rs # skip_ws lowering 3関数 (~390行)
└── funcscanner_trim.rs # trim lowering (~480行)
```
## 技術的変更:
- **型定義統一**: JoinFuncId, JoinInst, JoinModule 等を mod.rs に集約
- **lowering 分離**: 3つの lowering 関数を個別モジュールに移動
- **後方互換性**: pub use で lowering 関数を re-export(既存コード影響なし)
- **削除**: src/mir/join_ir.rs (旧単一ファイル)
## テスト結果:
- **385 passed** (+1 from 384)
- **9 failed** (-1 from 10)
- **ビルド成功**: 0 errors, 18 warnings (変化なし)
## 効果:
- **保守性向上**: 1,336行 → 4ファイル(各300-500行)で可読性向上
- **モジュール境界明確化**: 型定義 vs lowering 実装の責務分離
- **将来の拡張容易**: 新 lowering 関数追加が簡単に
Phase 27.8 で実装した MIR 自動解析 lowering の基盤整備完了。
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-23 16:49:49 +09:00