From cddebeb01ff72870472c6b035983ef1d0a570d81 Mon Sep 17 00:00:00 2001 From: Stephen Gutekanst Date: Sun, 1 Dec 2024 11:45:38 -0700 Subject: [PATCH] object: fix Objects.is() function Signed-off-by: Stephen Gutekanst --- src/module.zig | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/module.zig b/src/module.zig index 53859c52..e0f03e4a 100644 --- a/src/module.zig +++ b/src/module.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const mach = @import("../main.zig"); +const mach = @import("main.zig"); const StringTable = @import("StringTable.zig"); const Graph = @import("graph.zig").Graph; @@ -114,22 +114,22 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type { dead.set(unpacked.index); } - pub fn next(iter: *Slice) ?ObjectID { - const dead = &iter.objs.internal.dead; - const generation = &iter.objs.internal.generation; + pub fn next(s: *Slice) ?ObjectID { + const dead = &s.objs.internal.dead; + const generation = &s.objs.internal.generation; const num_objects = generation.items.len; while (true) { - if (iter.index == num_objects) { - iter.index = 0; + if (s.index == num_objects) { + s.index = 0; return null; } - defer iter.index += 1; + defer s.index += 1; - if (!dead.isSet(iter.index)) return @bitCast(PackedID{ - .type_id = iter.objs.internal.type_id, - .generation = generation.items[iter.index], - .index = iter.index, + if (!dead.isSet(s.index)) return @bitCast(PackedID{ + .type_id = s.objs.internal.type_id, + .generation = generation.items[s.index], + .index = s.index, }); } } @@ -305,7 +305,7 @@ pub fn Objects(options: ObjectsOptions, comptime T: type) type { } // TODO: this doesn't type check currently, but it should (verify id is from this pool of objects.) - fn validateAndUnpack(objs: *@This(), id: ObjectID, comptime fn_name: []const u8) PackedID { + fn validateAndUnpack(objs: *const @This(), id: ObjectID, comptime fn_name: []const u8) PackedID { const dead = &objs.internal.dead; const generation = &objs.internal.generation;