docs: Phase 195 Pattern 3 extension design (multi-carrier support)

Phase 195 design document for P3 (If-Else PHI) multi-carrier expansion:
- Goal: Handle 2-3 carriers in if-else branches simultaneously
- Scope: if-complete multi-carrier updates (flag+buffer, sum+count patterns)

Task breakdown:
- 195-1: Loop inventory (_parse_string simple, if-sum patterns)
- 195-2: LoopUpdateSummary/CarrierInfo design (multi-carrier support)
- 195-3: Pattern3 lowerer design (PhiGroup vs ExitLine extension)
- 195-4: Implementation scope (2-3 carriers, existing UpdateKind range)
- 195-5: Documentation updates (CURRENT_TASK.md + overview)

Design decisions:
-  ExitLine extension (no PhiGroupBox - YAGNI principle)
-  Both-branch carrier definition check (unchanged = use previous value)
-  No ConditionEnv expansion (Phase 200+ deferred)
-  LoopBodyLocal + MethodCall mix deferred to Phase 195+

Target loops:
1. JsonParser _parse_string (escaped flag + buffer)
   - Carrier 1: escaped (BoolFlag) - conditional flag
   - Carrier 2: buffer (StringAppend) - else-only update
2. selfhost if-sum (sum + count)
   - Carrier 1: sum (NumberAccumulation) - then-only update
   - Carrier 2: count (CounterLike) - then-only update

Test cases designed:
- phase195_flag_buffer.hako (BoolFlag + StringAppend)
- phase195_sum_count.hako (NumberAccumulation + CounterLike)

Expected outcome:
- phase195-pattern3-extension-design.md (complete design spec)
- Clear implementation scope for Phase 195-impl
- Path to 40% → 60% JsonParser coverage

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 13:22:14 +09:00
parent 3ca84e8d59
commit 22f97b67b1
3 changed files with 701 additions and 11 deletions

View File

@ -509,12 +509,28 @@ JoinIR は Rust 側だけでなく、将来的に .hako selfhost コンパイラ
- テスト: phase192_normalization_demo.hako → 123 ✅
- 制約: MethodCall を含む init 式は Phase 193 で対応予定
3. **MethodCall を含む init 式の対応Phase 193**
- `local digit = digits.indexOf(ch)` のような MethodCall init の lowering
3. **MethodCall を含む init 式の対応** → Phase 193 完了
- `local digit = digits.indexOf(ch)` のような MethodCall init の lowering 完了
- LoopBodyLocalInitLowerer 拡張BoxCall emission
- メソッド whitelist: indexOf, substring
- メソッド whitelist: indexOf, get, toString 対応
- 制約: body-local init のみ対応、condition 内の MethodCall は Phase 200+
4. **JsonParser 残り複雑ループ・selfhost ループへの適用(Phase 194+**
- `_parse_array` / `_parse_object`P4 Continue + 複数 MethodCall
- `_unescape_string`(複雑なキャリア + flatten
- selfhost `.hako` コンパイラの全ループを JoinIR で処理
4. **JsonParser 実戦投入P1/P2/P5 検証)** → Phase 194 完了
- 4/10 ループが JoinIR 経路で動作確認 (40% coverage)
- Target loops: _skip_whitespace, _trim (x2), _match_literal
- Deferred loops: _parse_number, _atoi (ConditionEnv constraint)
- Deferred loops: _parse_string, _unescape_string (complex carriers)
- Deferred loops: _parse_array, _parse_object (multiple MethodCalls)
- 詳細: phase194-loop-inventory.md, phase194-jsonparser-deployment.md
5. **Pattern 3 拡張(複数キャリア対応)** → Phase 195 設計中
- 目的: P3If-Else PHIで 2-3 個の Carrier を同時処理
- 設計判断: ExitLine 拡張で対応PhiGroupBox は作らない - YAGNI 原則)
- 対象: _parse_stringflag+buffer、if-sumsum+count
- Phase 195-impl で実装予定
6. **JsonParser 残り複雑ループへの適用Phase 195+, 200+**
- Phase 200+: ConditionEnv 拡張 (function-scoped variables) → _parse_number, _atoi
- Phase 195+: Pattern 3 拡張 (multi-flag carriers) → _parse_string, _unescape_string
- Phase 195+: MethodCall 拡張 (multiple calls in body) → _parse_array, _parse_object
- selfhost `.hako` コンパイラの全ループを JoinIR で処理 (Phase 210+)