Files
hakorune/docs/development/current/main/design
tomoaki 21387f3816 feat(edgecfg): Phase 265 P2 - seq/if_ 実装(wires/exits 分離)
## 目的

「解決済み配線(wires)」と「未解決 exit(exits)」を分離し、
Frag 合成の基本パターンを完成させる。

## 実装内容

### 1. Frag 構造体の変更
- `wires: Vec<EdgeStub>` フィールド追加
- 不変条件:
  - exits: target = None のみ(未配線、外へ出る exit)
  - wires: target = Some(...) のみ(配線済み、内部配線)

### 2. loop_() の wires 対応
- Break/Continue を exits から wires に移動
- P1 テスト 3個を wires 検証に更新

### 3. seq(a, b) 実装
- a.Normal → b.entry を wires に追加(内部配線)
- seq の exits[Normal] は b の Normal のみ
- 新規テスト 2個追加

### 4. if_(header, cond, t, e, join_frag) 実装
- シグネチャ変更: join: BasicBlockId → join_frag: Frag
- t/e.Normal → join_frag.entry を wires に追加
- if の exits は join_frag.exits
- 新規テスト 2個追加

### 5. verify_frag_invariants() 強化
- wires/exits 分離契約の検証追加(警告のみ)
- Err 化は Phase 266 で実施

## テスト結果

- edgecfg::api: 13/13 PASS(frag 3 + compose 9 + verify 1)
- 全 lib テスト: 1388/1388 PASS(退行なし)

## 核心的な設計判断

1. **wires/exits 分離**:
   - 問題: 解決済み配線と未解決 exit を混ぜると再配線バグ
   - 解決: 分離して不変条件を強化
   - 効果: Phase 266 で wires を MIR terminator に落とすだけ

2. **if_ は join_frag 受け取り**:
   - 問題: join: BasicBlockId では「join block」か「join 以降」か曖昧
   - 解決: join_frag: Frag で「join 以降」を明確化
   - 効果: PHI 生成の柔軟性確保

3. **verify は警告のみ**:
   - P2 の役割: wires/exits 分離の証明に集中
   - Phase 266 で MIR 生成時に厳格化

## 次フェーズへの橋渡し

- Phase 266: wires を MIR terminator に落とす
- Phase 267: Pattern6/7/8 を Frag 化

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

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
2025-12-21 16:47:47 +09:00
..

design/

docs/development/current/main/design/ は、長期参照する設計図SSOT 寄り)を置く場所。

  • 原則: “Phaseの作業ログ/完了報告” は ../phases/ に置く。
  • 原則: “不具合調査ログ” は ../investigations/ に置く。

現役の設計図(入口)

  • JoinIR の地図navigation SSOT: docs/development/current/main/design/joinir-design-map.md
  • Join-Explicit CFG Constructionnorth star: docs/development/current/main/design/join-explicit-cfg-construction.md
  • Catch / Cleanup / Async設計メモ: docs/development/current/main/design/exception-cleanup-async.md
  • Loop Canonicalizer設計 SSOT: docs/development/current/main/design/loop-canonicalizer.md
  • ControlTree / StepTree構造SSOT: docs/development/current/main/design/control-tree.md
  • Normalized ExprLowerer式の一般化 SSOT: docs/development/current/main/design/normalized-expr-lowering.md