Files
hakorune/lang/src/vm/json_loader.hako
nyash-codex 6a452b2dca fix(mir): PHI検証panic修正 - update_cfg()を検証前に呼び出し
A案実装: debug_verify_phi_inputs呼び出し前にCFG predecessorを更新

修正箇所(7箇所):
- src/mir/builder/phi.rs:50, 73, 132, 143
- src/mir/builder/ops.rs:273, 328, 351

根本原因:
- Branch/Jump命令でsuccessorは即座に更新
- predecessorはupdate_cfg()で遅延再構築
- PHI検証が先に実行されてpredecessor未更新でpanic

解決策:
- 各debug_verify_phi_inputs呼び出し前に
  if let Some(func) = self.current_function.as_mut() {
      func.update_cfg();
  }
  を挿入してCFGを同期

影響: if/else文、論理演算子(&&/||)のPHI生成が正常動作
2025-11-01 13:28:56 +09:00

51 lines
1.5 KiB
Plaintext

// MiniJsonLoader (Stage-B scaffold)
// Purpose: centralize minimal JSON cursor ops for Mini-VM.
// Implementation note: For now we delegate to local MiniJsonCur-compatible
// helpers. In a later step, this can be swapped to use `apps/libs/json_cur.hako`
// (JsonCursorBox) without touching Mini-VM call sites.
static box MiniJsonLoader {
read_quoted_from(s, pos) {
// Local fallback (same behavior as MiniJsonCur.read_quoted_from)
// Keep in sync with Mini-VM until libs adoption gate is enabled.
local i = pos
if s.substring(i, i+1) != "\"" { return "" }
i = i + 1
local out = ""
local n = s.length()
loop (i < n) {
local ch = s.substring(i, i+1)
if ch == "\"" { break }
if ch == "\\" { i = i + 1 ch = s.substring(i, i+1) }
out = out + ch
i = i + 1
}
return out
}
read_digits_from(s, pos) {
local out = ""
local i = pos
if i == null { return out }
if i < 0 { return out }
loop (true) {
local ch = s.substring(i, i+1)
if ch == "" { break }
if ch == "0" || ch == "1" || ch == "2" || ch == "3" || ch == "4" || ch == "5" || ch == "6" || ch == "7" || ch == "8" || ch == "9" {
out = out + ch
i = i + 1
} else { break }
}
return out
}
next_non_ws(s, pos) {
local i = pos
local n = s.length()
loop (i < n) {
local ch = s.substring(i, i+1)
if ch != " " && ch != "\n" && ch != "\r" && ch != "\t" { return i }
i = i + 1
}
return -1
}
}