diff options
Diffstat (limited to 'src/type.zig')
| -rw-r--r-- | src/type.zig | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/type.zig b/src/type.zig index fceb3c4dfd..72347f5adc 100644 --- a/src/type.zig +++ b/src/type.zig @@ -2520,6 +2520,20 @@ pub const Type = extern union { }; } + /// Returns the type of a pointer to an element. + /// Asserts that the type is a pointer, and that the element type is indexable. + /// For *[N]T, return *T + /// For [*]T, returns *T + /// For []T, returns *T + /// Handles const-ness and address spaces in particular. + pub fn elemPtrType(ptr_ty: Type, arena: *Allocator) !Type { + return try Type.ptr(arena, .{ + .pointee_type = ptr_ty.elemType2(), + .mutable = ptr_ty.ptrIsMutable(), + .@"addrspace" = ptr_ty.ptrAddressSpace(), + }); + } + fn shallowElemType(child_ty: Type) Type { return switch (child_ty.zigTypeTag()) { .Array, .Vector => child_ty.childType(), |
