// compare_scan_box.hako — CompareScanBox
// Responsibility: Parse compare instruction (v0/v1) and return dst/lhs/rhs/kind
// - v0: keys cmp/lhs/rhs/dst
// - v1: operation:"==" maps to Eq (CompareOpsBox)
// Returns: map({ dst:int|null, lhs:int|null, rhs:int|null, kind:String }) or null

using selfhost.shared.json.utils.json_frag as JsonFragBox
using selfhost.vm.helpers.compare_ops as CompareOpsBox

static box CompareScanBox {
  parse(seg) {
    if seg == null { return null }
    local dst = JsonFragBox.get_int(seg, "dst")
    local lhs = JsonFragBox.get_int(seg, "lhs")
    local rhs = JsonFragBox.get_int(seg, "rhs")
    local kind = JsonFragBox.get_str(seg, "cmp")
    if kind == "" {
      local sym = JsonFragBox.get_str(seg, "operation")
      if sym != "" { kind = CompareOpsBox.map_symbol(sym) } else { kind = "Eq" }
    }
    return { dst: dst, lhs: lhs, rhs: rhs, kind: kind }
  }
}

static box CompareScanMain { main(args){ return 0 } }
