docs: JoinIR Chapter 1 foundation complete summary + Phase 191 spec

- Added Section 7 to joinir-architecture-overview.md with completion status
- Updated CURRENT_TASK.md with Phase 191-193 roadmap
- Created phase191-body-local-integration.md instruction document

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 03:18:05 +09:00
parent 1af92d8aea
commit 57cf67002e
3 changed files with 261 additions and 12 deletions

View File

@ -456,3 +456,51 @@ JoinIR は Rust 側だけでなく、将来的に .hako selfhost コンパイラ
「sum」「ch」など名前ベースの判定は LoopUpdateSummary / TrimLoopHelper の内部に閉じ込める。
この Roadmap は、JoinIR 層の変更や selfhost 深度を進めるたびに更新していくよ。
---
## 7. JoinIR 第1章基盤完成サマリ2025-12-09 時点)
### 7.1 現在の対応状況
**Pattern サポート**:
| Pattern | 説明 | 状態 |
|---------|------|------|
| P1 Simple | `loop(cond) { body }` | ✅ 完成 |
| P2 Break | `loop(cond) { if(...) break }` | ✅ 完成 |
| P3 If-PHI | `loop { if(...) a else b; use(φ) }` | ✅ 完成 |
| P4 Continue | `loop { if(...) continue }` | ✅ 完成 |
| P5 Trim | LoopBodyLocal → bool carrier 昇格 | ✅ 基本完成 |
**UpdateKind サポート**:
| UpdateKind | 例 | 状態 |
|------------|-----|------|
| CounterLike | `i = i + 1` | ✅ |
| AccumulationLike | `sum = sum + x` | ✅ |
| StringAppendChar | `s = s + ch` | ✅ |
| StringAppendLiteral | `s = s + "lit"` | ✅ |
| NumberAccumulation | `v = v * 10 + digit` | ✅ (Phase 190) |
| Complex | method call 含む | ❌ Fail-Fast |
**アーキテクチャ SSOT ライン**:
- ✅ LoopHeaderPhiBuilder: ループ変数・キャリアの PHI を SSOT で生成
- ✅ ExitLineReconnector: PHI dst → variable_map 接続
- ✅ JoinInlineBoundaryBuilder: 全パターンで Builder パターン統一
- ✅ JoinIRVerifier: デバッグビルドで契約検証
- ✅ ExitLine Contract Verifier: PHI 配線検証Phase 190-impl-D
### 7.2 残タスクPhase 191+ で対応予定)
1. **body-local 変数の init + update loweringPhase 186/191 ライン)**
- `local digit = s[i] - '0'` のような body-local 変数の JoinIR/MIR 生成
- LoopBodyLocalEnv / UpdateEnv インフラは Phase 184 で実装済み
- Pattern2/4 への統合が残タスク
2. **Complex addend 対応Phase 191+**
- `v = v * 10 + digits.indexOf(ch)` のような method call を含む NumberAccumulation
- 現状は Fail-Fast で拒否、将来的に addend を事前計算して temp に格納
3. **JsonParser 残り複雑ループ・selfhost ループへの適用**
- `_parse_array` / `_parse_object`P4 Continue + 複数 MethodCall
- `_unescape_string`(複雑なキャリア + flatten
- selfhost `.hako` コンパイラの全ループを JoinIR で処理