authorgravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-27 15:51:58+03:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-09-27 18:33:23+03:00
log509bb82b20e9417d8b0ff604cd87f70fd1fcf4e9
tree01263a314e35da6bbe6e65727822fdac842a89c9
parent83fa216c8d2375476ee02ccf53bf6b5a9ed7480e

Sema: refactor common code to its own function


1 files changed, 39 insertions(+), 183 deletions(-)

src/Sema.zig+39-183
...@@ -606,6 +606,21 @@ fn resolveBody(...@@ -606,6 +606,21 @@ fn resolveBody(
606 return try sema.resolveInst(break_data.operand);606 return try sema.resolveInst(break_data.operand);
607}607}
608608
609fn analyzeBodyRuntimeBreak(sema: *Sema, block: *Block, body: []const Zir.Inst.Index) !void {
610 _ = sema.analyzeBodyInner(block, body) catch |err| switch (err) {
611 error.ComptimeBreak => {
612 const zir_datas = sema.code.instructions.items(.data);
613 const break_data = zir_datas[sema.comptime_break_inst].@"break";
614 try sema.addRuntimeBreak(block, .{
615 .block_inst = break_data.block_inst,
616 .operand = break_data.operand,
617 .inst = sema.comptime_break_inst,
618 });
619 },
620 else => |e| return e,
621 };
622}
623
609pub fn analyzeBody(624pub fn analyzeBody(
610 sema: *Sema,625 sema: *Sema,
611 block: *Block,626 block: *Block,
...@@ -10005,18 +10020,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10005,18 +10020,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10005 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {10020 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {
10006 // nothing to do here10021 // nothing to do here
10007 } else if (analyze_body) {10022 } else if (analyze_body) {
10008 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {10023 try sema.analyzeBodyRuntimeBreak(&case_block, body);
10009 error.ComptimeBreak => {
10010 const zir_datas = sema.code.instructions.items(.data);
10011 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10012 try sema.addRuntimeBreak(&case_block, .{
10013 .block_inst = break_data.block_inst,
10014 .operand = break_data.operand,
10015 .inst = sema.comptime_break_inst,
10016 });
10017 },
10018 else => |e| return e,
10019 };
10020 } else {10024 } else {
10021 _ = try case_block.addNoOp(.unreach);10025 _ = try case_block.addNoOp(.unreach);
10022 }10026 }
...@@ -10069,16 +10073,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10069,16 +10073,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10069 extra_index += 1;10073 extra_index += 1;
1007010074
10071 const item_first_ref = try sema.resolveInst(first_ref);10075 const item_first_ref = try sema.resolveInst(first_ref);
10072 var item_first = sema.resolveConstValue(block, .unneeded, item_first_ref, undefined) catch unreachable;10076 var item = sema.resolveConstValue(block, .unneeded, item_first_ref, undefined) catch unreachable;
10073 const item_last_ref = try sema.resolveInst(last_ref);10077 const item_last_ref = try sema.resolveInst(last_ref);
10074 const item_last = sema.resolveConstValue(block, .unneeded, item_last_ref, undefined) catch unreachable;10078 const item_last = sema.resolveConstValue(block, .unneeded, item_last_ref, undefined) catch unreachable;
1007510079
10076 while (item_first.compare(.lte, item_last, operand_ty, sema.mod)) : ({10080 while (item.compare(.lte, item_last, operand_ty, sema.mod)) : ({
10077 item_first = try sema.intAddScalar(block, case_src, item_first, Value.one);10081 item = try sema.intAddScalar(block, case_src, item, Value.one);
10078 }) {10082 }) {
10079 cases_len += 1;10083 cases_len += 1;
1008010084
10081 const item_ref = try sema.addConstant(operand_ty, item_first);10085 const item_ref = try sema.addConstant(operand_ty, item);
10082 case_block.inline_case_capture = item_ref;10086 case_block.inline_case_capture = item_ref;
1008310087
10084 case_block.instructions.shrinkRetainingCapacity(0);10088 case_block.instructions.shrinkRetainingCapacity(0);
...@@ -10087,25 +10091,12 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10087,25 +10091,12 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10087 if (emit_bb) try sema.emitBackwardBranch(block, case_src);10091 if (emit_bb) try sema.emitBackwardBranch(block, case_src);
10088 emit_bb = true;10092 emit_bb = true;
1008910093
10090 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {10094 try sema.analyzeBodyRuntimeBreak(&case_block, body);
10091 error.ComptimeBreak => {
10092 const zir_datas = sema.code.instructions.items(.data);
10093 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10094 try sema.addRuntimeBreak(&case_block, .{
10095 .block_inst = break_data.block_inst,
10096 .operand = break_data.operand,
10097 .inst = sema.comptime_break_inst,
10098 });
10099 },
10100 else => |e| return e,
10101 };
10102
10103 // try wip_captures.finalize();
1010410095
10105 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10096 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10106 cases_extra.appendAssumeCapacity(1); // items_len10097 cases_extra.appendAssumeCapacity(1); // items_len
10107 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));10098 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
10108 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));10099 cases_extra.appendAssumeCapacity(@enumToInt(case_block.inline_case_capture));
10109 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);10100 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
10110 }10101 }
10111 }10102 }
...@@ -10129,28 +10120,15 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10129,28 +10120,15 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10129 emit_bb = true;10120 emit_bb = true;
1013010121
10131 if (analyze_body) {10122 if (analyze_body) {
10132 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {10123 try sema.analyzeBodyRuntimeBreak(&case_block, body);
10133 error.ComptimeBreak => {
10134 const zir_datas = sema.code.instructions.items(.data);
10135 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10136 try sema.addRuntimeBreak(&case_block, .{
10137 .block_inst = break_data.block_inst,
10138 .operand = break_data.operand,
10139 .inst = sema.comptime_break_inst,
10140 });
10141 },
10142 else => |e| return e,
10143 };
10144 } else {10124 } else {
10145 _ = try case_block.addNoOp(.unreach);10125 _ = try case_block.addNoOp(.unreach);
10146 }10126 }
1014710127
10148 // try wip_captures.finalize();
10149
10150 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10128 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10151 cases_extra.appendAssumeCapacity(1); // items_len10129 cases_extra.appendAssumeCapacity(1); // items_len
10152 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));10130 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
10153 cases_extra.appendAssumeCapacity(@enumToInt(item));10131 cases_extra.appendAssumeCapacity(@enumToInt(case_block.inline_case_capture));
10154 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);10132 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
10155 }10133 }
1015610134
...@@ -10181,18 +10159,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10181,18 +10159,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10181 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {10159 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {
10182 // nothing to do here10160 // nothing to do here
10183 } else if (analyze_body) {10161 } else if (analyze_body) {
10184 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {10162 try sema.analyzeBodyRuntimeBreak(&case_block, body);
10185 error.ComptimeBreak => {
10186 const zir_datas = sema.code.instructions.items(.data);
10187 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10188 try sema.addRuntimeBreak(&case_block, .{
10189 .block_inst = break_data.block_inst,
10190 .operand = break_data.operand,
10191 .inst = sema.comptime_break_inst,
10192 });
10193 },
10194 else => |e| return e,
10195 };
10196 } else {10163 } else {
10197 _ = try case_block.addNoOp(.unreach);10164 _ = try case_block.addNoOp(.unreach);
10198 }10165 }
...@@ -10273,18 +10240,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10273,18 +10240,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10273 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {10240 if (err_set and try sema.maybeErrorUnwrap(&case_block, body, operand)) {
10274 // nothing to do here10241 // nothing to do here
10275 } else {10242 } else {
10276 _ = sema.analyzeBodyInner(&case_block, body) catch |err| switch (err) {10243 try sema.analyzeBodyRuntimeBreak(&case_block, body);
10277 error.ComptimeBreak => {
10278 const zir_datas = sema.code.instructions.items(.data);
10279 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10280 try sema.addRuntimeBreak(&case_block, .{
10281 .block_inst = break_data.block_inst,
10282 .operand = break_data.operand,
10283 .inst = sema.comptime_break_inst,
10284 });
10285 },
10286 else => |e| return e,
10287 };
10288 }10244 }
1028910245
10290 try wip_captures.finalize();10246 try wip_captures.finalize();
...@@ -10315,8 +10271,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10315,8 +10271,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
1031510271
10316 var final_else_body: []const Air.Inst.Index = &.{};10272 var final_else_body: []const Air.Inst.Index = &.{};
10317 if (special.body.len != 0 or !is_first or case_block.wantSafety()) {10273 if (special.body.len != 0 or !is_first or case_block.wantSafety()) {
10318 var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, child_block.wip_capture_scope);10274 var emit_bb = false;
10319 defer wip_captures.deinit();
10320 if (special.is_inline) switch (operand_ty.zigTypeTag()) {10275 if (special.is_inline) switch (operand_ty.zigTypeTag()) {
10321 .Enum => {10276 .Enum => {
10322 if (operand_ty.isNonexhaustiveEnum() and !union_originally) {10277 if (operand_ty.isNonexhaustiveEnum() and !union_originally) {
...@@ -10324,7 +10279,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10324,7 +10279,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10324 operand_ty.fmt(sema.mod),10279 operand_ty.fmt(sema.mod),
10325 });10280 });
10326 }10281 }
10327 var emit_bb = false;
10328 for (seen_enum_fields) |f, i| {10282 for (seen_enum_fields) |f, i| {
10329 if (f != null) continue;10283 if (f != null) continue;
10330 cases_len += 1;10284 cases_len += 1;
...@@ -10345,24 +10299,11 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10345,24 +10299,11 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10345 emit_bb = true;10299 emit_bb = true;
1034610300
10347 if (analyze_body) {10301 if (analyze_body) {
10348 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10302 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10349 error.ComptimeBreak => {
10350 const zir_datas = sema.code.instructions.items(.data);
10351 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10352 try sema.addRuntimeBreak(&case_block, .{
10353 .block_inst = break_data.block_inst,
10354 .operand = break_data.operand,
10355 .inst = sema.comptime_break_inst,
10356 });
10357 },
10358 else => |e| return e,
10359 };
10360 } else {10303 } else {
10361 _ = try case_block.addNoOp(.unreach);10304 _ = try case_block.addNoOp(.unreach);
10362 }10305 }
1036310306
10364 // try wip_captures.finalize();
10365
10366 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10307 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10367 cases_extra.appendAssumeCapacity(1); // items_len10308 cases_extra.appendAssumeCapacity(1); // items_len
10368 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));10309 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
...@@ -10376,7 +10317,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10376,7 +10317,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10376 operand_ty.fmt(sema.mod),10317 operand_ty.fmt(sema.mod),
10377 });10318 });
10378 }10319 }
10379 var emit_bb = false;
10380 for (operand_ty.errorSetNames()) |error_name| {10320 for (operand_ty.errorSetNames()) |error_name| {
10381 if (seen_errors.contains(error_name)) continue;10321 if (seen_errors.contains(error_name)) continue;
10382 cases_len += 1;10322 cases_len += 1;
...@@ -10391,20 +10331,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10391,20 +10331,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10391 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);10331 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
10392 emit_bb = true;10332 emit_bb = true;
1039310333
10394 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10334 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10395 error.ComptimeBreak => {
10396 const zir_datas = sema.code.instructions.items(.data);
10397 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10398 try sema.addRuntimeBreak(&case_block, .{
10399 .block_inst = break_data.block_inst,
10400 .operand = break_data.operand,
10401 .inst = sema.comptime_break_inst,
10402 });
10403 },
10404 else => |e| return e,
10405 };
10406
10407 // try wip_captures.finalize();
1040810335
10409 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10336 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10410 cases_extra.appendAssumeCapacity(1); // items_len10337 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -10415,7 +10342,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10415,7 +10342,6 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10415 },10342 },
10416 .Int => {10343 .Int => {
10417 var it = try RangeSetUnhandledIterator.init(sema, block, special_prong_src, operand_ty, range_set);10344 var it = try RangeSetUnhandledIterator.init(sema, block, special_prong_src, operand_ty, range_set);
10418 var emit_bb = false;
10419 while (try it.next()) |cur| {10345 while (try it.next()) |cur| {
10420 cases_len += 1;10346 cases_len += 1;
1042110347
...@@ -10428,30 +10354,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10428,30 +10354,16 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10428 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);10354 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
10429 emit_bb = true;10355 emit_bb = true;
1043010356
10431 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10357 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10432 error.ComptimeBreak => {
10433 const zir_datas = sema.code.instructions.items(.data);
10434 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10435 try sema.addRuntimeBreak(&case_block, .{
10436 .block_inst = break_data.block_inst,
10437 .operand = break_data.operand,
10438 .inst = sema.comptime_break_inst,
10439 });
10440 },
10441 else => |e| return e,
10442 };
10443
10444 // try wip_captures.finalize();
1044510358
10446 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10359 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10447 cases_extra.appendAssumeCapacity(1); // items_len10360 cases_extra.appendAssumeCapacity(1); // items_len
10448 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));10361 cases_extra.appendAssumeCapacity(@intCast(u32, case_block.instructions.items.len));
10449 cases_extra.appendAssumeCapacity(@enumToInt(item_ref));10362 cases_extra.appendAssumeCapacity(@enumToInt(case_block.inline_case_capture));
10450 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);10363 cases_extra.appendSliceAssumeCapacity(case_block.instructions.items);
10451 }10364 }
10452 },10365 },
10453 .Bool => {10366 .Bool => {
10454 var emit_bb = false;
10455 if (true_count == 0) {10367 if (true_count == 0) {
10456 cases_len += 1;10368 cases_len += 1;
10457 case_block.inline_case_capture = Air.Inst.Ref.bool_true;10369 case_block.inline_case_capture = Air.Inst.Ref.bool_true;
...@@ -10462,20 +10374,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10462,20 +10374,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10462 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);10374 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
10463 emit_bb = true;10375 emit_bb = true;
1046410376
10465 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10377 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10466 error.ComptimeBreak => {
10467 const zir_datas = sema.code.instructions.items(.data);
10468 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10469 try sema.addRuntimeBreak(&case_block, .{
10470 .block_inst = break_data.block_inst,
10471 .operand = break_data.operand,
10472 .inst = sema.comptime_break_inst,
10473 });
10474 },
10475 else => |e| return e,
10476 };
10477
10478 // try wip_captures.finalize();
1047910378
10480 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10379 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10481 cases_extra.appendAssumeCapacity(1); // items_len10380 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -10493,20 +10392,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10493,20 +10392,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10493 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);10392 if (emit_bb) try sema.emitBackwardBranch(block, special_prong_src);
10494 emit_bb = true;10393 emit_bb = true;
1049510394
10496 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10395 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10497 error.ComptimeBreak => {
10498 const zir_datas = sema.code.instructions.items(.data);
10499 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10500 try sema.addRuntimeBreak(&case_block, .{
10501 .block_inst = break_data.block_inst,
10502 .operand = break_data.operand,
10503 .inst = sema.comptime_break_inst,
10504 });
10505 },
10506 else => |e| return e,
10507 };
10508
10509 // try wip_captures.finalize();
1051010396
10511 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);10397 try cases_extra.ensureUnusedCapacity(gpa, 3 + case_block.instructions.items.len);
10512 cases_extra.appendAssumeCapacity(1); // items_len10398 cases_extra.appendAssumeCapacity(1); // items_len
...@@ -10520,6 +10406,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10520,6 +10406,9 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10520 }),10406 }),
10521 };10407 };
1052210408
10409 var wip_captures = try WipCaptureScope.init(gpa, sema.perm_arena, child_block.wip_capture_scope);
10410 defer wip_captures.deinit();
10411
10523 case_block.instructions.shrinkRetainingCapacity(0);10412 case_block.instructions.shrinkRetainingCapacity(0);
10524 case_block.wip_capture_scope = wip_captures.scope;10413 case_block.wip_capture_scope = wip_captures.scope;
10525 case_block.inline_case_capture = .none;10414 case_block.inline_case_capture = .none;
...@@ -10538,18 +10427,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError...@@ -10538,18 +10427,7 @@ fn zirSwitchBlock(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError
10538 {10427 {
10539 // nothing to do here10428 // nothing to do here
10540 } else if (special.body.len != 0 and analyze_body and !special.is_inline) {10429 } else if (special.body.len != 0 and analyze_body and !special.is_inline) {
10541 _ = sema.analyzeBodyInner(&case_block, special.body) catch |err| switch (err) {10430 try sema.analyzeBodyRuntimeBreak(&case_block, special.body);
10542 error.ComptimeBreak => {
10543 const zir_datas = sema.code.instructions.items(.data);
10544 const break_data = zir_datas[sema.comptime_break_inst].@"break";
10545 try sema.addRuntimeBreak(&case_block, .{
10546 .block_inst = break_data.block_inst,
10547 .operand = break_data.operand,
10548 .inst = sema.comptime_break_inst,
10549 });
10550 },
10551 else => |e| return e,
10552 };
10553 } else {10431 } else {
10554 // We still need a terminator in this block, but we have proven10432 // We still need a terminator in this block, but we have proven
10555 // that it is unreachable.10433 // that it is unreachable.
...@@ -15716,18 +15594,7 @@ fn zirCondbr(...@@ -15716,18 +15594,7 @@ fn zirCondbr(
15716 sub_block.runtime_index.increment();15594 sub_block.runtime_index.increment();
15717 defer sub_block.instructions.deinit(gpa);15595 defer sub_block.instructions.deinit(gpa);
1571815596
15719 _ = sema.analyzeBodyInner(&sub_block, then_body) catch |err| switch (err) {15597 try sema.analyzeBodyRuntimeBreak(&sub_block, then_body);
15720 error.ComptimeBreak => {
15721 const zir_datas = sema.code.instructions.items(.data);
15722 const break_data = zir_datas[sema.comptime_break_inst].@"break";
15723 try sema.addRuntimeBreak(&sub_block, .{
15724 .block_inst = break_data.block_inst,
15725 .operand = break_data.operand,
15726 .inst = sema.comptime_break_inst,
15727 });
15728 },
15729 else => |e| return e,
15730 };
15731 const true_instructions = sub_block.instructions.toOwnedSlice(gpa);15598 const true_instructions = sub_block.instructions.toOwnedSlice(gpa);
15732 defer gpa.free(true_instructions);15599 defer gpa.free(true_instructions);
1573315600
...@@ -15746,18 +15613,7 @@ fn zirCondbr(...@@ -15746,18 +15613,7 @@ fn zirCondbr(
15746 if (err_cond != null and try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?)) {15613 if (err_cond != null and try sema.maybeErrorUnwrap(&sub_block, else_body, err_cond.?)) {
15747 // nothing to do15614 // nothing to do
15748 } else {15615 } else {
15749 _ = sema.analyzeBodyInner(&sub_block, else_body) catch |err| switch (err) {15616 try sema.analyzeBodyRuntimeBreak(&sub_block, else_body);
15750 error.ComptimeBreak => {
15751 const zir_datas = sema.code.instructions.items(.data);
15752 const break_data = zir_datas[sema.comptime_break_inst].@"break";
15753 try sema.addRuntimeBreak(&sub_block, .{
15754 .block_inst = break_data.block_inst,
15755 .operand = break_data.operand,
15756 .inst = sema.comptime_break_inst,
15757 });
15758 },
15759 else => |e| return e,
15760 };
15761 }15617 }
15762 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +15618 try sema.air_extra.ensureUnusedCapacity(gpa, @typeInfo(Air.CondBr).Struct.fields.len +
15763 true_instructions.len + sub_block.instructions.items.len);15619 true_instructions.len + sub_block.instructions.items.len);