From 2549de80b226cddd0664ce4ad8c40887101f302b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Sat, 25 Nov 2023 15:02:32 -0800 Subject: move Module.Decl.Index and Module.Namespace.Index to InternPool --- src/Module.zig | 46 ++++------------------------------------------ 1 file changed, 4 insertions(+), 42 deletions(-) (limited to 'src/Module.zig') diff --git a/src/Module.zig b/src/Module.zig index fd5bb5b5dc..f5850d7a3a 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -464,27 +464,8 @@ pub const Decl = struct { anon, }; - pub const Index = enum(u32) { - _, - - pub fn toOptional(i: Index) OptionalIndex { - return @as(OptionalIndex, @enumFromInt(@intFromEnum(i))); - } - }; - - pub const OptionalIndex = enum(u32) { - none = std.math.maxInt(u32), - _, - - pub fn init(oi: ?Index) OptionalIndex { - return @as(OptionalIndex, @enumFromInt(@intFromEnum(oi orelse return .none))); - } - - pub fn unwrap(oi: OptionalIndex) ?Index { - if (oi == .none) return null; - return @as(Index, @enumFromInt(@intFromEnum(oi))); - } - }; + const Index = InternPool.DeclIndex; + const OptionalIndex = InternPool.OptionalDeclIndex; pub const DepsTable = std.AutoArrayHashMapUnmanaged(Decl.Index, DepType); @@ -828,27 +809,8 @@ pub const Namespace = struct { /// Value is whether the usingnamespace decl is marked `pub`. usingnamespace_set: std.AutoHashMapUnmanaged(Decl.Index, bool) = .{}, - pub const Index = enum(u32) { - _, - - pub fn toOptional(i: Index) OptionalIndex { - return @as(OptionalIndex, @enumFromInt(@intFromEnum(i))); - } - }; - - pub const OptionalIndex = enum(u32) { - none = std.math.maxInt(u32), - _, - - pub fn init(oi: ?Index) OptionalIndex { - return @as(OptionalIndex, @enumFromInt(@intFromEnum(oi orelse return .none))); - } - - pub fn unwrap(oi: OptionalIndex) ?Index { - if (oi == .none) return null; - return @as(Index, @enumFromInt(@intFromEnum(oi))); - } - }; + const Index = InternPool.NamespaceIndex; + const OptionalIndex = InternPool.OptionalNamespaceIndex; const DeclContext = struct { module: *Module, -- cgit v1.2.3