// lower_method_map_size_box.hako — Minimal structural MIR for MapBox.size
using selfhost.shared.json.utils.json_frag as JsonFragBox

static box LowerMethodMapSizeBox {
  try_lower(program_json) {
    if program_json == null { return null }
    local s = "" + program_json
    if JsonFragBox.index_of_from(s, "\"type\":\"New\"", 0) < 0 { return null }
    if JsonFragBox.index_of_from(s, "\"class\":\"MapBox\"", 0) < 0 { return null }
    local json = "{\"kind\":\"MIR\",\"schema_version\":\"1.0\",\"functions\":[{\"name\":\"main\",\"blocks\":[{\"id\":0,\"instructions\":[" +
               "{\"op\":\"mir_call\",\"dst\":1,\"mir_call\":{\"callee\":{\"type\":\"Constructor\",\"box_type\":\"MapBox\"},\"args\":[],\"effects\":[]}}," +
               "{\"op\":\"mir_call\",\"dst\":2,\"mir_call\":{\"callee\":{\"type\":\"Method\",\"box_name\":\"MapBox\",\"method\":\"size\",\"receiver\":1},\"args\":[],\"effects\":[]}}," +
               "{\"op\":\"const\",\"dst\":3,\"value\":{\"type\":\"i64\",\"value\":0}}," +
               "{\"op\":\"ret\",\"value\":3}]}]}]}"
    return json
  }
}
