From 5093a5cd193ed3cd4107f0fcdb0ed1ab9dda30f5 Mon Sep 17 00:00:00 2001 From: mlugg Date: Tue, 16 Jul 2024 19:35:31 +0100 Subject: std.Zir: some declaration traversal fixes --- lib/std/zig/Zir.zig | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) (limited to 'lib/std') diff --git a/lib/std/zig/Zir.zig b/lib/std/zig/Zir.zig index 600ca488e6..128e91eef4 100644 --- a/lib/std/zig/Zir.zig +++ b/lib/std/zig/Zir.zig @@ -3791,11 +3791,15 @@ fn findDeclsSwitch( break :blk multi_cases_len; } else 0; + if (extra.data.bits.any_has_tag_capture) { + extra_index += 1; + } + const special_prong = extra.data.bits.specialProng(); if (special_prong != .none) { - const body_len: u31 = @truncate(zir.extra[extra_index]); + const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]); extra_index += 1; - const body = zir.bodySlice(extra_index, body_len); + const body = zir.bodySlice(extra_index, prong_info.body_len); extra_index += body.len; try zir.findDeclsBody(list, body); @@ -3805,10 +3809,10 @@ fn findDeclsSwitch( const scalar_cases_len = extra.data.bits.scalar_cases_len; for (0..scalar_cases_len) |_| { extra_index += 1; - const body_len: u31 = @truncate(zir.extra[extra_index]); + const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]); extra_index += 1; - const body = zir.bodySlice(extra_index, body_len); - extra_index += body_len; + const body = zir.bodySlice(extra_index, prong_info.body_len); + extra_index += body.len; try zir.findDeclsBody(list, body); } @@ -3819,20 +3823,13 @@ fn findDeclsSwitch( extra_index += 1; const ranges_len = zir.extra[extra_index]; extra_index += 1; - const body_len: u31 = @truncate(zir.extra[extra_index]); + const prong_info: Inst.SwitchBlock.ProngInfo = @bitCast(zir.extra[extra_index]); extra_index += 1; - const items = zir.refSlice(extra_index, items_len); - extra_index += items_len; - _ = items; - var range_i: usize = 0; - while (range_i < ranges_len) : (range_i += 1) { - extra_index += 1; - extra_index += 1; - } + extra_index += items_len + ranges_len * 2; - const body = zir.bodySlice(extra_index, body_len); - extra_index += body_len; + const body = zir.bodySlice(extra_index, prong_info.body_len); + extra_index += body.len; try zir.findDeclsBody(list, body); } -- cgit v1.2.3