docs(joinir): Phase 48 - Normalized P4 (Continue) design

Complete design documentation for Pattern4 (continue) Normalized support,
extending unified Normalized infrastructure to all 4 loop patterns.

Design documents:
- phase48-norm-p4-design.md: Complete P4 Normalized design (380 lines)
  - Key insight: continue = immediate TailCallFn(loop_step, ...) (no new instruction!)
  - Infrastructure reuse: 95%+ from P2/P3 (only ContinueCheck step kind new)
  - Target loops prioritized:
    - ◎ _parse_array (skip whitespace) - PRIMARY (Phase 48-A)
    - ○ _parse_object (skip whitespace) - Extended
    - △ _unescape_string, _parse_string - Later
  - Control flow: ContinueCheck before Updates (skip processing early)
  - Same EnvLayout/ConditionEnv/CarrierInfo/ExitLine as P2/P3
  - Implementation strategy: dev-only → canonical (proven approach)

Architecture:
- Unified Normalized for P1/P2/P3/P4 (all patterns same pipeline)
- P4 uses loop_step(env, k_exit) skeleton (same as P2/P3)
- continue semantics: TailCallFn = skip to next iteration (CPS natural fit)

Benefits:
- 95% infrastructure reuse from P2/P3
- No new JpInst needed (continue = existing TailCallFn)
- Incremental rollout (dev → canonical)
- Clear semantic: continue = immediate recursion

Implementation roadmap:
- Phase 48-A: Minimal continue (dev-only)
- Phase 48-B: Extended patterns (multi-carrier)
- Phase 48-C: Canonical promotion

Updates:
- joinir-architecture-overview.md: Added Phase 48 section
- CURRENT_TASK.md: Phase 48 entry (Design Complete)
- phase47-norm-p3-design.md: Minor formatting

Status: Design phase complete (doc-only, no implementation yet)
Next: Phase 48-A implementation (when requested)
This commit is contained in:
nyash-codex
2025-12-12 06:06:39 +09:00
parent 99bdf93dfe
commit 4ecb6435d3
4 changed files with 469 additions and 34 deletions

View File

@ -174,14 +174,18 @@
1. ~~Phase 245Bコード~~: ✅ 完了Phase 43/245B の一部)
2. ~~Phase 246-EXコード~~: ✅ 完了Phase 43/245B の一部)
3. **Phase 47-NORM-P3設計完了最小dev実装✅ 2025-12-12**: Pattern3 Normalized 設計
3. **Phase 47-NORM-P3設計完了最小devdirect✅ 2025-12-12**: Pattern3 Normalized 設計
- 設計詳細: [phase47-norm-p3-design.md](docs/development/current/main/phase47-norm-p3-design.md)
- P3 if-sum を Normalized JoinIR に載せる設計。P2 と同じ ConditionEnv/CarrierInfo/ExitLine インフラを再利用。
- Phase 47-A: Minimal sum_countdev-only 第1ステップ)として、`phase212_if_sum_min.hako` 相当の最小 if-sum ループを AST ベース lowerer + Structured→Normalized→Structured roundtripRunner 経路)で検証済み。
- Phase 47-B 以降: StepScheduleBox 拡張・direct Normalized→MIR ブリッジ・canonical 昇格は今後の実装フェーズで扱う。
4. **Phase 48-NORM-P4-DESIGN候補**: Pattern4 Normalized 設計
- `_parse_array` / `_parse_object` / continue 混在ループを棚卸しし、P4 をどの順番で Normalized に載せるかを整理。
- continue を TailCallFn でどう表現するか、EnvLayout との対応を設計メモに落とす。
- Phase 47-A: Minimal sum_countdev-onlyとして、`phase212_if_sum_min.hako` 相当の最小 if-sum ループを AST ベース lowerer + Structured→Normalized→Structured roundtripRunner 経路) Normalized→MIR(direct) で検証済み。
- Phase 47-B 以降: array_filter など body-local/MethodCall を含む P3 ループや canonical 昇格は今後の実装フェーズで扱う。
4. **Phase 48-NORM-P4-DESIGN設計完了✅ 2025-12-12**: Pattern4 (continue) Normalized 設計
- 設計詳細: [phase48-norm-p4-design.md](docs/development/current/main/phase48-norm-p4-design.md)
- ターゲットループ決定: _parse_array skip whitespace◎ PRIMARY、_parse_object、_unescape_string/parse_string
- 設計骨格: `continue` = 即座の `TailCallFn(loop_step, ...)` (新命令不要)
- P1/P2/P3 と同じ `loop_step(env, k_exit)` 骨格に載せる
- インフラ再利用率: 95%+ (StepKind の ContinueCheck のみ追加)
- 実装: Phase 48-A (minimal dev-only) → 48-B (extended) → 48-C (canonical)
5. JsonParser 残りループへの JoinIR 展開
- `_parse_array` / `_parse_object` / `_unescape_string` / 本体 `_parse_string` など。
- 既存の P2/P3/P4P5 パイプラインをどこまで延ばせるかを docs 側で設計 → コード側はその設計に沿って小さく実装。