| ... | ... | @@ -299,9 +299,36 @@ const Writer = struct { |
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | fn writeSwitchBr(w: *Writer, s: anytype, inst: Air.Inst.Index) @TypeOf(s).Error!void { |
| 302 | | _ = w; |
| 303 | | _ = inst; |
| 304 | | try s.writeAll("TODO"); |
| 302 | const pl_op = w.air.instructions.items(.data)[inst].pl_op; |
| 303 | const extra = w.air.extraData(Air.SwitchBr, pl_op.payload); |
| 304 | const cases = w.air.extra[extra.end..][0..extra.data.cases_len]; |
| 305 | const else_body = w.air.extra[extra.end + cases.len ..][0..extra.data.else_body_len]; |
| 306 | |
| 307 | try w.writeInstRef(s, pl_op.operand); |
| 308 | try s.writeAll(", {\n"); |
| 309 | |
| 310 | const old_indent = w.indent; |
| 311 | if (else_body.len != 0) { |
| 312 | w.indent += 2; |
| 313 | try w.writeBody(s, else_body); |
| 314 | try s.writeByteNTimes(' ', old_indent); |
| 315 | try s.writeAll("}, {\n"); |
| 316 | w.indent = old_indent; |
| 317 | } |
| 318 | |
| 319 | for (cases) |case_index| { |
| 320 | const case = w.air.extraData(Air.SwitchBr.Case, case_index); |
| 321 | const case_body = w.air.extra[case.end..][0..case.data.body_len]; |
| 322 | |
| 323 | w.indent += 2; |
| 324 | try w.writeBody(s, case_body); |
| 325 | try s.writeByteNTimes(' ', old_indent); |
| 326 | try s.writeAll("}, {\n"); |
| 327 | w.indent = old_indent; |
| 328 | } |
| 329 | |
| 330 | try s.writeByteNTimes(' ', old_indent); |
| 331 | try s.writeAll("}"); |
| 305 | 332 | } |
| 306 | 333 | |
| 307 | 334 | fn writeInstRef(w: *Writer, s: anytype, inst: Air.Inst.Ref) @TypeOf(s).Error!void { |