diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-05-07 16:14:08 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2023-06-10 20:42:29 -0700 |
| commit | 4fe0c583be8890b1cb8059c2daff3bd82c53d2e9 (patch) | |
| tree | e491e68236f5c090076459d63d475dce93aa0d84 /src/type.zig | |
| parent | 4d88f825bc5eb14aa00446f046ab4714a4fdce70 (diff) | |
| download | zig-4fe0c583be8890b1cb8059c2daff3bd82c53d2e9.tar.gz zig-4fe0c583be8890b1cb8059c2daff3bd82c53d2e9.zip | |
stage2: more InternPool-related fixes
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/src/type.zig b/src/type.zig index 9c8c1f1591..b271a3ea45 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2058,16 +2058,23 @@ pub const Type = struct { } } - pub fn ptrAddressSpace(self: Type, mod: *const Module) std.builtin.AddressSpace { - return switch (self.tag()) { - .pointer => self.castTag(.pointer).?.data.@"addrspace", + pub fn ptrAddressSpace(ty: Type, mod: *const Module) std.builtin.AddressSpace { + return switch (ty.ip_index) { + .none => switch (ty.tag()) { + .pointer => ty.castTag(.pointer).?.data.@"addrspace", - .optional => { - const child_type = self.optionalChild(mod); - return child_type.ptrAddressSpace(mod); - }, + .optional => { + const child_type = ty.optionalChild(mod); + return child_type.ptrAddressSpace(mod); + }, - else => unreachable, + else => unreachable, + }, + else => switch (mod.intern_pool.indexToKey(ty.ip_index)) { + .ptr_type => |ptr_type| ptr_type.address_space, + .opt_type => |child| mod.intern_pool.indexToKey(child).ptr_type.address_space, + else => unreachable, + }, }; } |
