aboutsummaryrefslogtreecommitdiff
path: root/src/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-08-17 14:25:18 -0700
committerAndrew Kelley <andrew@ziglang.org>2023-08-17 18:16:03 -0700
commit7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b (patch)
tree6a76839d8be347648741e17f50d6c70d8313adc3 /src/Module.zig
parent8c1329b222ab620d7388d766e9e558baa502ce93 (diff)
downloadzig-7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.tar.gz
zig-7ef1eb1c27754cb0349fdc10db1f02ff2dddd99b.zip
InternPool: safer enum API
The key changes in this commit are: ```diff - names: []const NullTerminatedString, + names: NullTerminatedString.Slice, - values: []const Index, + values: Index.Slice, ``` Which eliminates the slices from `InternPool.Key.EnumType` and replaces them with structs that contain `start` and `len` indexes. This makes the lifetime of `EnumType` change from expiring with updates to InternPool, to expiring when the InternPool is garbage-collected, which is currently never. This is gearing up for a larger change I started working on locally which moves union types into InternPool. As a bonus, I fixed some unnecessary instances of `@as`.
Diffstat (limited to 'src/Module.zig')
-rw-r--r--src/Module.zig2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/Module.zig b/src/Module.zig
index c19b742b54..2c78ddd881 100644
--- a/src/Module.zig
+++ b/src/Module.zig
@@ -6655,7 +6655,7 @@ pub fn enumValueFieldIndex(mod: *Module, ty: Type, field_index: u32) Allocator.E
return (try ip.get(gpa, .{ .enum_tag = .{
.ty = ty.toIntern(),
- .int = enum_type.values[field_index],
+ .int = enum_type.values.get(ip)[field_index],
} })).toValue();
}