diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2024-06-11 21:00:39 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2024-06-15 00:57:52 +0100 |
| commit | 07a24bec9a578857920f4c5508f1d7eea65177b8 (patch) | |
| tree | 3edd81d1bff8219dd9122291041b28c5ea5ec9ce /src/InternPool.zig | |
| parent | e39cc0dff7fff510c3d72f61947b977589ea5583 (diff) | |
| download | zig-07a24bec9a578857920f4c5508f1d7eea65177b8.tar.gz zig-07a24bec9a578857920f4c5508f1d7eea65177b8.zip | |
compiler: move LazySrcLoc out of std
This is in preparation for some upcoming changes to how we represent
source locations in the compiler. The bulk of the change here is dealing
with the removal of `src()` methods from `Zir` types.
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index b6d5e77f53..f1c90311c4 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -391,8 +391,27 @@ pub const RuntimeIndex = enum(u32) { pub const ComptimeAllocIndex = enum(u32) { _ }; -pub const DeclIndex = std.zig.DeclIndex; -pub const OptionalDeclIndex = std.zig.OptionalDeclIndex; +pub const DeclIndex = enum(u32) { + _, + + pub fn toOptional(i: DeclIndex) OptionalDeclIndex { + return @enumFromInt(@intFromEnum(i)); + } +}; + +pub const OptionalDeclIndex = enum(u32) { + none = std.math.maxInt(u32), + _, + + pub fn init(oi: ?DeclIndex) OptionalDeclIndex { + return @enumFromInt(@intFromEnum(oi orelse return .none)); + } + + pub fn unwrap(oi: OptionalDeclIndex) ?DeclIndex { + if (oi == .none) return null; + return @enumFromInt(@intFromEnum(oi)); + } +}; pub const NamespaceIndex = enum(u32) { _, |
