feat(joinir): Phase 41-4.1 Add NestedIfMerge JoinInst variant
Add structural support for nested if patterns with PHI-sensitive variables: 1. JoinInst::NestedIfMerge in mod.rs - conds: Vec<VarId> (outer to inner conditions) - merges: Vec<MergePair> (variable updates at deepest level) - k_next: Option<JoinContId> (continuation after merge) 2. JSON serialization in json.rs - Type: "nested_if_merge" - Fields: conds[], merges[], k_next 3. Runner/Bridge stubs - JoinIR Runner: Returns error (use VM Bridge instead) - VM Bridge: panic placeholder (41-4.3 will implement) Target: ParserControlBox.parse_loop() (4-level nested if) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@ -322,6 +322,38 @@ pub enum JoinInst {
|
||||
args: Vec<VarId>,
|
||||
},
|
||||
|
||||
/// Phase 41-4: 深いネスト if の複数変数 merge(else なし)
|
||||
///
|
||||
/// # Pattern
|
||||
/// ```text
|
||||
/// if cond1 {
|
||||
/// if cond2 {
|
||||
/// if cond3 {
|
||||
/// x = new_val // modifications only at deepest level
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// // merge: x = phi(new_val if all conds true, original otherwise)
|
||||
/// ```
|
||||
///
|
||||
/// # Semantics
|
||||
/// - `conds`: 外側から内側への条件リスト
|
||||
/// - `merges`: 最深レベルでの変数更新
|
||||
/// - then_val: 全ての conds が true の場合の値
|
||||
/// - else_val: いずれかの cond が false の場合の値(元の値)
|
||||
/// - MIR 変換時に多段 Branch + PHI を生成
|
||||
///
|
||||
/// # Target
|
||||
/// ParserControlBox.parse_loop() の 4 レベルネスト if パターン
|
||||
NestedIfMerge {
|
||||
/// 条件リスト(外側から内側へ)
|
||||
conds: Vec<VarId>,
|
||||
/// 変数更新(全条件 true 時 → then_val、いずれか false 時 → else_val)
|
||||
merges: Vec<MergePair>,
|
||||
/// merge 後の継続
|
||||
k_next: Option<JoinContId>,
|
||||
},
|
||||
|
||||
/// それ以外の演算は、現行 MIR の算術/比較/boxcall を再利用
|
||||
Compute(MirLikeInst),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user