aboutsummaryrefslogtreecommitdiff
path: root/src/type.zig
diff options
context:
space:
mode:
authorVeikka Tuominen <git@vexu.eu>2022-03-13 18:22:29 +0200
committerVeikka Tuominen <git@vexu.eu>2022-03-16 09:26:10 +0200
commitaf2b03de83b8ec60c967e53823496904ecc66c0d (patch)
tree980622f781ce15a3232c0d72e1f622deb283df5b /src/type.zig
parent8a43d67c3bf878fa32ef4876897a32969a4b5d24 (diff)
downloadzig-af2b03de83b8ec60c967e53823496904ecc66c0d.tar.gz
zig-af2b03de83b8ec60c967e53823496904ecc66c0d.zip
Type: implement ptrInfo for optional pointers
Diffstat (limited to 'src/type.zig')
-rw-r--r--src/type.zig30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig
index ffa43d32c0..7b45b89816 100644
--- a/src/type.zig
+++ b/src/type.zig
@@ -486,6 +486,36 @@ pub const Type = extern union {
.pointer => return self.castTag(.pointer).?.*,
+ .optional_single_mut_pointer => return .{ .data = .{
+ .pointee_type = self.castPointer().?.data,
+ .sentinel = null,
+ .@"align" = 0,
+ .@"addrspace" = .generic,
+ .bit_offset = 0,
+ .host_size = 0,
+ .@"allowzero" = false,
+ .mutable = true,
+ .@"volatile" = false,
+ .size = .One,
+ } },
+ .optional_single_const_pointer => return .{ .data = .{
+ .pointee_type = self.castPointer().?.data,
+ .sentinel = null,
+ .@"align" = 0,
+ .@"addrspace" = .generic,
+ .bit_offset = 0,
+ .host_size = 0,
+ .@"allowzero" = false,
+ .mutable = false,
+ .@"volatile" = false,
+ .size = .One,
+ } },
+ .optional => {
+ var buf: Payload.ElemType = undefined;
+ const child_type = self.optionalChild(&buf);
+ return child_type.ptrInfo();
+ },
+
else => unreachable,
}
}