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`.
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user