docs(joinir): Phase 190 NumberAccumulation design (doc-only)

Design document for `result = result * 10 + digit` patterns:

- Section 1-2: Target loop analysis (_atoi, _parse_number)
- Section 3: UpdateKind::NumberAccumulation { base: i64 }
- Section 4: classify_number_update() algorithm
- Section 5: Pattern2/4 can_lower() specification
- Section 6: CarrierUpdateLowerer 2-instruction emission
- Section 7-12: Implementation roadmap, testing strategy

Key decisions:
- Safe: lhs = lhs * CONST + Variable/Const
- Unsafe: LHS 2+ occurrences, variable base, method calls
- Integer type only (no string)
- Fail-Fast for Complex patterns

Next: Phase 190-impl for code implementation

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-09 01:54:53 +09:00
parent 88e9fff141
commit 0b705f9ca0
3 changed files with 999 additions and 4 deletions

View File

@ -322,6 +322,10 @@ Phase 181 で JsonParserBox 内の 11 ループを棚卸しした結果、
- LoopUpdateAnalyzer の `UpdateKind` / `UpdateRhs` で「安全な更新パターン」を列挙し、
そのうち string にも適用可能なものだけを **ホワイトリストで許可**する。
- 実際の lowering は CarrierUpdateLowerer / 式 Lowerer 側で行い、JoinIR のループ形P1P4は増やさない。
3. 数値の桁展開Phase 190 設計完了)
- `v = v * 10 + digit` のような NumberAccumulation パターンを UpdateKind で whitelist 制御。
- 型制約: Integer のみ許可String は StringAppendChar 使用)。
- 検出: AST 構造解析名前依存禁止、Complex パターンは Fail-Fast で reject。
- **Phase 183 で LoopBodyLocal 役割分離完了** ✅:
- **設計**: LoopBodyLocal を 2 カテゴリに分類:
- **Condition LoopBodyLocal**: ループ条件header/break/continueで使用 → Trim 昇格対象