447d4ea246
feat(llvm): Phase 132 - Pattern 1 exit value parity fix + Box-First refactoring
...
## Phase 132: Exit PHI Value Parity Fix
### Problem
Pattern 1 (Simple While) returned 0 instead of final loop variable value (3)
- VM: RC: 3 ✅ (correct)
- LLVM: Result: 0 ❌ (wrong)
### Root Cause (Two Layers)
1. **JoinIR/Boundary**: Missing exit_bindings → ExitLineReconnector not firing
2. **LLVM Python**: block_end_values snapshot dropping PHI values
### Fix
**JoinIR** (simple_while_minimal.rs):
- Jump(k_exit, [i_param]) passes exit value
**Boundary** (pattern1_minimal.rs):
- Added LoopExitBinding with carrier_name="i", role=LoopState
- Enables ExitLineReconnector to update variable_map
**LLVM** (block_lower.py):
- Use predeclared_ret_phis for reliable PHI filtering
- Protect builder.vmap PHIs from overwrites (SSOT principle)
### Result
- ✅ VM: RC: 3
- ✅ LLVM: Result: 3
- ✅ VM/LLVM parity achieved
## Phase 132-Post: Box-First Refactoring
### Rust Side
**JoinModule::require_function()** (mod.rs):
- Encapsulate function search logic
- 10 lines → 1 line (90% reduction)
- Reusable for Pattern 2-5
### Python Side
**PhiManager Box** (phi_manager.py - new):
- Centralized PHI lifecycle management
- 47 lines → 8 lines (83% reduction)
- SSOT: builder.vmap owns PHIs
- Fail-Fast: No silent overwrites
**Integration**:
- LLVMBuilder: Added phi_manager
- block_lower.py: Delegated to PhiManager
- tagging.py: Register PHIs with manager
### Documentation
**New Files**:
- docs/development/architecture/exit-phi-design.md
- docs/development/current/main/investigations/phase132-llvm-exit-phi-wrong-result.md
- docs/development/current/main/phases/phase-132/
**Updated**:
- docs/development/current/main/10-Now.md
- docs/development/current/main/phase131-3-llvm-lowering-inventory.md
### Design Principles
- Box-First: Logic encapsulated in classes/methods
- SSOT: Single Source of Truth (builder.vmap for PHIs)
- Fail-Fast: Early explicit failures, no fallbacks
- Separation of Concerns: 3-layer architecture
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com >
2025-12-15 03:17:31 +09:00
db9c9055fa
obs(joinir): Phase 72 - PHI Reserved Region Observation Complete
...
## Summary
Observed PHI dst ValueId distribution to determine if verifier can enforce
reserved region (0-99). **Conclusion: Verifier strengthening NOT recommended.**
## Key Finding
PHI dst allocation does NOT architecturally respect reserved region:
- PHI dst comes from `builder.next_value_id()` (host MirBuilder)
- Reserved region (0-99) is a JoinValueSpace contract for JoinIR lowering
- These are separate allocation pools with no enforcement mechanism
- Current stability is accidental (ValueId allocation ordering)
## Evidence
Manual verification (`apps/tests/loop_min_while.hako`):
- PHI dst = %3 (ValueId(3)) ✅ in reserved region
- Works because PHI allocated early in function (0-20 typical)
- JoinValueSpace allocates high (100+, 1000+)
- Accidental separation, not enforced
## Implementation
Added observation infrastructure (debug-only):
- `src/mir/join_ir/verify_phi_reserved.rs` (266 lines)
- PHI dst observer with distribution analyzer
- Region classifier (Reserved/Param/Local)
- Human-readable report generator
- Instrumentation at PHI allocation points:
- loop_header_phi_builder.rs:94, 151
- Debug-only `observe_phi_dst()` calls
## Test Results
- Unit tests: ✅ 4/4 PASS (verify_phi_reserved module)
- Lib tests: ✅ 950/950 PASS, 56 ignored
- Normalized tests: ✅ 54/54 PASS
- Manual verification: ✅ PHI dst in 0-99 observed
## Decision: Document, Don't Enforce
**Rationale**:
1. No architectural mechanism to enforce PHI dst ∈ [0, 99]
2. Adding verifier creates false assumptions about allocation order
3. Current system stable through separate pools (950/950 tests)
4. Future architectural fix possible (Phase 73+) but not urgent
## Documentation
- PHASE_72_SUMMARY.md: Executive summary and implementation record
- phase72-phi-reserved-observation.md: Detailed findings and analysis
- CURRENT_TASK.md: Phase 72 completion entry
## Next Steps
- Phase 73: Update architecture overview with Phase 72 findings
- Optional: Explicit PHI reserved pool (future enhancement)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-13 03:23:02 +09:00
2d10c5ce3f
docs(joinir): Phase 56 - Ownership-Relay Design + interface skeleton
...
「読むのは自由、管理は直下 owned だけ」アーキテクチャの設計文書と型定義。
Key changes:
- Design doc: phase56-ownership-relay-design.md
- Core definitions: owned/carriers/captures/relay
- Invariants: Ownership Uniqueness, Carrier Locality, Relay Propagation
- Shadowing rules, multi-writer merge semantics
- JoinIR mapping from current system to new system
- Implementation phases roadmap (56-61)
- New module: src/mir/join_ir/ownership/
- types.rs: ScopeId, ScopeOwnedVar, RelayVar, CapturedVar, OwnershipPlan
- mod.rs: Module documentation with responsibility boundaries
- README.md: Usage guide and examples
- API methods:
- OwnershipPlan::carriers() - owned AND written variables
- OwnershipPlan::condition_only_carriers() - condition-only carriers
- OwnershipPlan::verify_invariants() - invariant checking
Tests: 942/942 PASS (+3 unit tests)
Zero behavioral change - analysis module skeleton only.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 17:39:59 +09:00
ed8e2d3142
feat(joinir): Phase 248 - Normalized JoinIR infrastructure
...
Major refactoring of JoinIR normalization pipeline:
Key changes:
- Structured→Normalized→MIR(direct) pipeline established
- ShapeGuard enhanced with Pattern2 loop validation
- dev_env.rs: New development fixtures and env control
- fixtures.rs: jsonparser_parse_number_real fixture
- normalized_bridge/direct.rs: Direct MIR generation from Normalized
- pattern2_step_schedule.rs: Extracted step scheduling logic
Files changed:
- normalized.rs: Enhanced NormalizedJoinModule with DevEnv support
- shape_guard.rs: Pattern2-specific validation (+300 lines)
- normalized_bridge.rs: Unified bridge with direct path
- loop_with_break_minimal.rs: Integrated step scheduling
- Deleted: step_schedule.rs (moved to pattern2_step_schedule.rs)
New files:
- param_guess.rs: Loop parameter inference
- pattern2_step_schedule.rs: Step scheduling for Pattern2
- phase43-norm-canon-p2-mid.md: Design doc
Tests: 937/937 PASS (+6 from baseline 931)
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com >
2025-12-12 03:15:45 +09:00
af6f95cd4b
Phase 33 NORM canon test: enforce normalized dev route for P1/P2/JP mini
2025-12-11 20:54:33 +09:00
c63e6deb32
feat(joinir): Task 200-3 - JoinIRVerifier for LoopHeader PHI and ExitLine contracts
...
Debug-only verification module to catch JoinIR contract violations early:
- verify_loop_header_phis: Checks loop_var_name → PHI exists in header block
- verify_exit_line: Checks exit_bindings → values exist, exit block in range
- verify_joinir_contracts: Main entry point, runs all checks
Implementation:
- Added verification functions to merge/mod.rs (private module has type access)
- Called from merge_joinir_mir_blocks after exit block setup
- Only active in debug builds (#[cfg(debug_assertions)])
Benefits:
- Catches "动くけど header PHI 無い" bugs immediately
- Validates exit_bindings before variable_map reconnection
- Prevents silent contract violations during development
2025-12-08 04:33:33 +09:00
638182a8a2
feat(joinir): Phase 188-Impl-3 Pattern 3 (Loop with If-Else PHI) implementation
...
Add Pattern 3 lowerer for `loop { if cond { x = a } else { x = b } ... }` pattern.
New files:
- loop_with_if_phi_minimal.rs (381 lines): JoinIR lowerer for Pattern 3
- Multiple loop variables (counter + accumulator)
- In-loop if/else PHI using Select instruction
- Carriers passed to next iteration via tail recursion
Modified files:
- join_ir/mod.rs: Add Mod to BinOpKind, Select to MirLikeInst
- loop_pattern_detection.rs: Add is_loop_with_conditional_phi_pattern() detection
- lowering/mod.rs: Pattern 3 router integration
- loop_patterns.rs: Pattern 3 entry point delegation
- json.rs: Mod/Select JSON serialization
- join_ir_ops.rs: Mod operation evaluation (a % b)
- join_ir_runner.rs: Select instruction execution
- join_ir_vm_bridge/convert.rs: Mod/Select conversion handlers
Implementation:
- Pattern 3 generates 3 JoinIR functions: main, loop_step(i, sum), k_exit(sum_final)
- Exit condition: !(i <= 5) with Jump to k_exit
- In-loop if/else: if (i % 2 == 1) { sum + i } else { sum + 0 }
- Select instruction: sum_new = Select(if_cond, sum_then, sum_else)
- Both carriers updated: Call(loop_step, [i_next, sum_new])
Build status: ✅ Compiles successfully (0 errors, 34 warnings)
Integration: Infrastructure complete, MIR boundary mapping pending
All 3 patterns now have lowering infrastructure in place for Phase 188.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-05 15:45:42 +09:00
6d069ba61d
feat(joinir): Phase 188 Print instruction + Router integration
...
- Add MirLikeInst::Print variant for direct output operations
- Implement Print instruction in JSON serialization
- Update simple_while_minimal.rs to use Print instead of BoxCall
- Add Print handling in JoinIR VM bridge and runner
- Add router logic to call Pattern 1 lowerer from main pipeline
Note: Router integration exposes ValueId mismatch issue between
Pattern 1's hardcoded IDs and host function's variables.
This architectural issue needs resolution in next phase.
🤖 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-05 12:50:05 +09:00
6b9cef9ee5
feat(phase72): Phase 72-C Step 2: JoinIR dev flags SSOT completion
...
Extended joinir_dev.rs with 11 remaining flag helpers (total 20 flags):
- NYASH_JOINIR_LOWER_FROM_MIR, NYASH_JOINIR_LLVM_EXPERIMENT (2 NYASH flags)
- HAKO_JOINIR_IF_TOPLEVEL, IF_TOPLEVEL_TRACE, IF_IN_LOOP_TRACE (3 if-related)
- HAKO_JOINIR_NESTED_IF, PRINT_TOKENS_MAIN, ARRAY_FILTER_MAIN (3 ast_lowerer)
- HAKO_JOINIR_READ_QUOTED, READ_QUOTED_IFMERGE (2 read_quoted)
Updated src/mir/join_ir/mod.rs env_flag_is_1() dispatcher:
- Routes all 16 known JoinIR dev flags to config::env::joinir_dev helpers
- Maintains fallback for backward compatibility
- Centralizes all body code ENV reads through SSOT layer
Achievement: Complete SSOT consolidation for JoinIR development flags
- Test side: joinir_env.rs (is_experiment_enabled, set_if_select_*)
- Body code: config::env::joinir_dev.rs (20 flag helpers)
- Dispatcher: env_flag_is_1() routes all reads to centralized layer
🤖 Generated with Claude Code
Co-Authored-By: Claude <noreply@anthropic.com >
2025-12-02 12:52:38 +09:00
2ea0f2a202
Remove Trio boxes and tidy loop scope warnings
2025-11-30 11:46:14 +09:00
6a05243f10
feat(joinir): Phase 65-2-B Box コンストラクタ型ヒント実装
...
Phase 65-2-B 完了:P3-B(Box コンストラクタ)型ヒント実装
## 実装内容
### 1. JoinInst::NewBox に type_hint 追加
- `src/mir/join_ir/mod.rs`: `type_hint: Option<MirType>` フィールド追加
- 段階的拡大のため Optional 設計(既存コード破壊なし)
### 2. expr.rs で型ヒント自動推論
- `infer_box_type()` 関数使用で Box 名から型を自動推論
- ArrayBox → Box("ArrayBox")
- StringBox → String
- MapBox → Box("MapBox")
- IntegerBox → Integer
- BoolBox → Bool
### 3. convert.rs/json.rs で型ヒント対応
- パターンマッチに type_hint 追加(Phase 65-3 で活用予定)
- JSON シリアライズ対応
## テスト結果
- ✅ type_inference モジュール: 8/8 PASS
- ✅ ビルド: 0 エラー
## 次のステップ
- Phase 65-3: lifecycle.rs で P3-A/P3-B 型ヒント統合
---
🌟 Generated with [Claude Code](https://claude.com/claude-code )
Co-Authored-By: Claude <noreply@anthropic.com >
2025-11-30 06:14:52 +09:00
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