docs: Phase 107 plan (find_balanced_array_end)

This commit is contained in:
nyash-codex
2025-12-17 22:21:42 +09:00
parent af3b851984
commit 97c65a9e6f
2 changed files with 9 additions and 18 deletions

View File

@ -120,6 +120,7 @@ JoinIR を触るときは、次を破ったら「即エラーで止める」前
- Pattern は「認識できる shape だけ」を通し、曖昧な許容をしない。 - Pattern は「認識できる shape だけ」を通し、曖昧な許容をしない。
- 形状が合わないときは `Ok(None)` で静かに進めない非JoinIRへの退避を作らない - 形状が合わないときは `Ok(None)` で静かに進めない非JoinIRへの退避を作らない
- 例外: 明確な “routing” で「別 JoinIR 経路」を選ぶのは可(同一層内での選択)。 - 例外: 明確な “routing” で「別 JoinIR 経路」を選ぶのは可(同一層内での選択)。
- depth-scanPhase 107: `find_balanced_*`)は Pattern2 の policy で受理し、break 条件は “derived 値depth_delta/depth_next” から合成して SSOT 化するby-name 分岐は禁止)。
### ValueId / PHI / Boundary の世界 ### ValueId / PHI / Boundary の世界

View File

@ -1,20 +1,10 @@
# Phase 107 — find_balanced_*doc-only / 準備 # Phase 107 — json_cur find_balanced_array_endActive
目的: `apps/libs/json_cur.hako``find_balanced_array_end` / `find_balanced_object_end`depth scan + nested ifを、 目的: `apps/libs/json_cur.hako``find_balanced_array_end`depth scan + nested if + return-in-loopを Pattern2 policy で受理し、VM/LLVM EXE parity を integration smoke で固定する。
次フェーズで fixture + integration smokeVM/LLVM EXEに落とすための設計メモを先に確定する 形状: `loop(i < n)` + `ch = s.substring(i, i+1)` + `depth += 1/-1` + `if depth == 0 { return i }` + `i = i + 1`
受け入れ基準: fixture で `[]``1`, `[[]]``3` を VM と LLVM EXE の両方で出すLLVM 前提不足時は SKIP のみ許容)。
## 期待するループ形(要点)
- `loop(...)` または `loop(true)` の中で `depth`i64を更新しながら走査
- `if ch == "[" { depth += 1 }` / `if ch == "]" { depth -= 1; if depth == 0 { break/return } }` のようなネスト if
- “break/return” の条件が複数boundary + depth==0 など)
## 必要になりそうな追加能力(予告)
- multi-branch delta: 1ループ内で `i += 1` 以外の分岐更新(例: `i += 2`)が混ざるケース
- nested-if merge: if の中で depth を更新し、その後の break 条件に反映される形
- early-exit parity: break だけでなく `return` を含む出口の固定VM/LLVM EXE
置き場SSOT の決め打ち):
- “shape/route の判断” は `src/mir/builder/control_flow/joinir/patterns/policies/` に集約し、lowering 本体は Pattern2/5 側で維持する。
TODO実装後に追記:
- fixture: `apps/tests/phase107_find_balanced_array_end_min.hako`
- smoke(VM): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_array_end_vm.sh`
- smoke(LLVM EXE): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_array_end_llvm_exe.sh`