diff options
| author | mlugg <mlugg@mlugg.co.uk> | 2023-10-24 04:36:35 +0100 |
|---|---|---|
| committer | mlugg <mlugg@mlugg.co.uk> | 2023-10-24 14:28:33 +0100 |
| commit | 20bb81166f36668413703e0d74b3e283c55ab8ca (patch) | |
| tree | d68649f59e0899fbc49e7f9a188d3738f0ca1a3f /src/InternPool.zig | |
| parent | bb0419599aa93455f3ae0969f4bfd80204807596 (diff) | |
| download | zig-20bb81166f36668413703e0d74b3e283c55ab8ca.tar.gz zig-20bb81166f36668413703e0d74b3e283c55ab8ca.zip | |
InternPool: remove runtime_value representation
The main goal of this commit is to remove the `runtime_value` field from
`InternPool.Key` (and its associated representation), but there are a
few dominos. Specifically, this mostly eliminates the "maybe runtime"
concept from value resolution in Sema: so some resolution functions like
`resolveMaybeUndefValAllowVariablesMaybeRuntime` are gone. This required
a small change to struct/union/array initializers, to no longer
use `runtime_value` if a field was a `variable` - I'm not convinced this
case was even reachable, as `variable` should only ever exist as the
trivial value of a global runtime `var` decl.
Now, the only case in which a `Sema.resolveMaybeUndefVal`-esque function
can return the `variable` key is `resolveMaybeUndefValAllowVariables`,
which is directly called from `Sema.resolveInstValueAllowVariables`
(previously `Sema.resolveInstValue`), which is only used for resolving
the value of a Decl from `Module.semaDecl`.
While changing these functions, I also slightly reordered and
restructured some of them, and updated their doc comments.
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 32 |
1 files changed, 1 insertions, 31 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index 32cb76593e..e881208e9d 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -237,7 +237,6 @@ pub const Key = union(enum) { /// Typed `undefined`. This will never be `none`; untyped `undefined` is represented /// via `simple_value` and has a named `Index` tag for it. undef: Index, - runtime_value: TypeValue, simple_value: SimpleValue, variable: Variable, extern_func: ExternFunc, @@ -1181,8 +1180,6 @@ pub const Key = union(enum) { .payload => |y| Hash.hash(seed + 1, asBytes(&x.ty) ++ asBytes(&y)), }, - .runtime_value => |x| Hash.hash(seed, asBytes(&x.val)), - inline .opaque_type, .enum_type, .variable, @@ -1413,10 +1410,6 @@ pub const Key = union(enum) { const b_info = b.undef; return a_info == b_info; }, - .runtime_value => |a_info| { - const b_info = b.runtime_value; - return a_info.val == b_info.val; - }, .opt => |a_info| { const b_info = b.opt; return std.meta.eql(a_info, b_info); @@ -1703,8 +1696,7 @@ pub const Key = union(enum) { .func_type, => .type_type, - inline .runtime_value, - .ptr, + inline .ptr, .int, .float, .opt, @@ -2138,7 +2130,6 @@ pub const Index = enum(u32) { }, undef: DataIsIndex, - runtime_value: struct { data: *Tag.TypeValue }, simple_value: struct { data: SimpleValue }, ptr_decl: struct { data: *PtrDecl }, ptr_mut_decl: struct { data: *PtrMutDecl }, @@ -2580,10 +2571,6 @@ pub const Tag = enum(u8) { /// `data` is `Index` of the type. /// Untyped `undefined` is stored instead via `simple_value`. undef, - /// A wrapper for values which are comptime-known but should - /// semantically be runtime-known. - /// data is extra index of `TypeValue`. - runtime_value, /// A value that can be represented with only an enum tag. /// data is SimpleValue enum value. simple_value, @@ -2795,7 +2782,6 @@ pub const Tag = enum(u8) { .type_function => TypeFunction, .undef => unreachable, - .runtime_value => TypeValue, .simple_value => unreachable, .ptr_decl => PtrDecl, .ptr_mut_decl => PtrMutDecl, @@ -3730,7 +3716,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { .type_function => .{ .func_type = ip.extraFuncType(data) }, .undef => .{ .undef = @as(Index, @enumFromInt(data)) }, - .runtime_value => .{ .runtime_value = ip.extraData(Tag.TypeValue, data) }, .opt_null => .{ .opt = .{ .ty = @as(Index, @enumFromInt(data)), .val = .none, @@ -4556,13 +4541,6 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { .data = @intFromEnum(ty), }); }, - .runtime_value => |runtime_value| { - assert(runtime_value.ty == ip.typeOf(runtime_value.val)); - ip.items.appendAssumeCapacity(.{ - .tag = .runtime_value, - .data = try ip.addExtra(gpa, runtime_value), - }); - }, .struct_type => unreachable, // use getStructType() instead .anon_struct_type => unreachable, // use getAnonStructType() instead @@ -7237,7 +7215,6 @@ fn dumpStatsFallible(ip: *const InternPool, arena: Allocator) anyerror!void { }, .undef => 0, - .runtime_value => @sizeOf(Tag.TypeValue), .simple_type => 0, .simple_value => 0, .ptr_decl => @sizeOf(PtrDecl), @@ -7370,7 +7347,6 @@ fn dumpAllFallible(ip: *const InternPool) anyerror!void { .type_union, .type_function, .undef, - .runtime_value, .ptr_decl, .ptr_mut_decl, .ptr_anon_decl, @@ -7793,7 +7769,6 @@ pub fn typeOf(ip: *const InternPool, index: Index) Index { .ptr_slice, .opt_payload, .error_union_payload, - .runtime_value, .int_small, .int_lazy_align, .int_lazy_size, @@ -7906,10 +7881,6 @@ pub fn isUndef(ip: *const InternPool, val: Index) bool { return val == .undef or ip.items.items(.tag)[@intFromEnum(val)] == .undef; } -pub fn isRuntimeValue(ip: *const InternPool, val: Index) bool { - return ip.items.items(.tag)[@intFromEnum(val)] == .runtime_value; -} - pub fn isVariable(ip: *const InternPool, val: Index) bool { return ip.items.items(.tag)[@intFromEnum(val)] == .variable; } @@ -8116,7 +8087,6 @@ pub fn zigTypeTagOrPoison(ip: *const InternPool, index: Index) error{GenericPois // values, not types .undef, - .runtime_value, .simple_value, .ptr_decl, .ptr_mut_decl, |
