motiejus/zig

fork of https://codeberg.org/ziglang/zig
git clone https://git.jakstys.lt/motiejus/zig.git
Log | Tree | Refs | README | LICENSE

commit 123cfab98481554946208bd20a42ccc0c94681ef (tree)
parent 828756ceebaed09a90da81a5fc9a492443e2e8bb
Author: Jacob Young <jacobly0@users.noreply.github.com>
Date:   Thu,  1 Jun 2023 01:25:01 -0400

codegen: fix doubled global sentinels

Diffstat:
Msrc/codegen.zig | 46++++++++++++++++++----------------------------
1 file changed, 18 insertions(+), 28 deletions(-)

diff --git a/src/codegen.zig b/src/codegen.zig @@ -387,36 +387,26 @@ pub fn generateSymbol( } }, .aggregate => |aggregate| switch (mod.intern_pool.indexToKey(typed_value.ty.toIntern())) { - .array_type => |array_type| { - switch (aggregate.storage) { - .bytes => |bytes| try code.appendSlice(bytes), - .elems, .repeated_elem => { - var index: u64 = 0; - while (index < array_type.len) : (index += 1) { - switch (try generateSymbol(bin_file, src_loc, .{ - .ty = array_type.child.toType(), - .val = switch (aggregate.storage) { - .bytes => unreachable, - .elems => |elems| elems[@intCast(usize, index)], - .repeated_elem => |elem| elem, - }.toValue(), - }, code, debug_output, reloc_info)) { - .ok => {}, - .fail => |em| return .{ .fail = em }, - } + .array_type => |array_type| switch (aggregate.storage) { + .bytes => |bytes| try code.appendSlice(bytes), + .elems, .repeated_elem => { + var index: u64 = 0; + var len_including_sentinel = + array_type.len + @boolToInt(array_type.sentinel != .none); + while (index < len_including_sentinel) : (index += 1) { + switch (try generateSymbol(bin_file, src_loc, .{ + .ty = array_type.child.toType(), + .val = switch (aggregate.storage) { + .bytes => unreachable, + .elems => |elems| elems[@intCast(usize, index)], + .repeated_elem => |elem| elem, + }.toValue(), + }, code, debug_output, reloc_info)) { + .ok => {}, + .fail => |em| return .{ .fail = em }, } - }, - } - - if (array_type.sentinel != .none) { - switch (try generateSymbol(bin_file, src_loc, .{ - .ty = array_type.child.toType(), - .val = array_type.sentinel.toValue(), - }, code, debug_output, reloc_info)) { - .ok => {}, - .fail => |em| return .{ .fail = em }, } - } + }, }, .vector_type => |vector_type| { switch (aggregate.storage) {