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:
nyash-codex
2025-11-28 12:32:25 +09:00
parent 1b9589e9a3
commit d8a1d97222
4 changed files with 83 additions and 0 deletions

View File

@ -180,6 +180,38 @@ fn write_inst<W: Write>(inst: &JoinInst, out: &mut W) -> std::io::Result<()> {
write!(out, "]")?;
write!(out, "}}")?;
}
// Phase 41-4: NestedIfMerge instruction JSON serialization
JoinInst::NestedIfMerge { conds, merges, k_next } => {
write!(out, "{{\"type\":\"nested_if_merge\"")?;
// conds array
write!(out, ",\"conds\":[")?;
for (i, cond) in conds.iter().enumerate() {
if i > 0 {
write!(out, ",")?;
}
write!(out, "{}", cond.0)?;
}
write!(out, "]")?;
// merges array
write!(out, ",\"merges\":[")?;
for (i, merge) in merges.iter().enumerate() {
if i > 0 {
write!(out, ",")?;
}
write!(out, "{{")?;
write!(out, "\"dst\":{}", merge.dst.0)?;
write!(out, ",\"then_val\":{}", merge.then_val.0)?;
write!(out, ",\"else_val\":{}", merge.else_val.0)?;
write!(out, "}}")?;
}
write!(out, "]")?;
// k_next
match k_next {
Some(k) => write!(out, ",\"k_next\":{}", k.0)?,
None => write!(out, ",\"k_next\":null")?,
}
write!(out, "}}")?;
}
JoinInst::Compute(mir_like) => {
write!(out, "{{\"type\":\"compute\",\"op\":")?;
write_mir_like_inst(mir_like, out)?;