diff options
| author | Jacob Young <jacobly0@users.noreply.github.com> | 2023-05-25 19:23:01 -0400 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:47:55 -0700 |
| commit | 70cc68e9994f7dca53904075e15b2b6f87342539 (patch) | |
| tree | a02b75bcd056c2ce2d9a16a2ec51c4da06e03d9f /src/InternPool.zig | |
| parent | 72e4ea38216aab7e7ed05978d04c5d32de44b5ce (diff) | |
| download | zig-70cc68e9994f7dca53904075e15b2b6f87342539.tar.gz zig-70cc68e9994f7dca53904075e15b2b6f87342539.zip | |
Air: remove constant tag
Some uses have been moved to their own tag, the rest use interned.
Also, finish porting comptime mutation to be more InternPool aware.
Diffstat (limited to 'src/InternPool.zig')
| -rw-r--r-- | src/InternPool.zig | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/InternPool.zig b/src/InternPool.zig index 429b86a8a6..dfde352600 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -515,10 +515,12 @@ pub const Key = union(enum) { pub const ErrorUnion = struct { ty: Index, - val: union(enum) { + val: Value, + + pub const Value = union(enum) { err_name: NullTerminatedString, payload: Index, - }, + }; }; pub const EnumTag = struct { @@ -1068,7 +1070,7 @@ pub const Key = union(enum) { .false, .true => .bool_type, .empty_struct => .empty_struct_type, .@"unreachable" => .noreturn_type, - .generic_poison => unreachable, + .generic_poison => .generic_poison_type, }, }; } @@ -2671,6 +2673,10 @@ pub fn indexToKey(ip: InternPool, index: Index) Key { .only_possible_value => { const ty = @intToEnum(Index, data); return switch (ip.indexToKey(ty)) { + .array_type, .vector_type => .{ .aggregate = .{ + .ty = ty, + .storage = .{ .elems = &.{} }, + } }, // TODO: migrate structs to properly use the InternPool rather // than using the SegmentedList trick, then the struct type will // have a slice of comptime values that can be used here for when @@ -3184,7 +3190,11 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { assert(!(try ip.map.getOrPutAdapted(gpa, key, adapter)).found_existing); try ip.items.ensureUnusedCapacity(gpa, 1); ip.items.appendAssumeCapacity(.{ - .tag = .ptr_elem, + .tag = switch (ptr.addr) { + .elem => .ptr_elem, + .field => .ptr_field, + else => unreachable, + }, .data = try ip.addExtra(gpa, PtrBaseIndex{ .ty = ptr.ty, .base = base_index.base, |
