diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2021-09-25 22:18:43 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2021-09-25 22:18:43 -0700 |
| commit | 1f2f9f05c254374044d8c30cce6f299d7a18da72 (patch) | |
| tree | 868df45684a4db5f092b4106e7b17ddb05fbda1e /src/Module.zig | |
| parent | 04366576ea4be4959b596ebff7041d17e18d08d8 (diff) | |
| download | zig-1f2f9f05c254374044d8c30cce6f299d7a18da72.tar.gz zig-1f2f9f05c254374044d8c30cce6f299d7a18da72.zip | |
stage2: implement zirCoerceResultPtr
and remove Module.simplePtrType and Module.ptrType in favor of `Type.ptr`.
Diffstat (limited to 'src/Module.zig')
| -rw-r--r-- | src/Module.zig | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/src/Module.zig b/src/Module.zig index 278f8621d8..dbece09255 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -4460,82 +4460,6 @@ pub fn failWithOwnedErrorMsg(mod: *Module, scope: *Scope, err_msg: *ErrorMsg) Co return error.AnalysisFail; } -pub fn simplePtrType( - arena: *Allocator, - elem_ty: Type, - mutable: bool, - size: std.builtin.TypeInfo.Pointer.Size, - @"addrspace": std.builtin.AddressSpace, -) Allocator.Error!Type { - return ptrType( - arena, - elem_ty, - null, - 0, - @"addrspace", - 0, - 0, - mutable, - false, - false, - size, - ); -} - -pub fn ptrType( - arena: *Allocator, - elem_ty: Type, - sentinel: ?Value, - @"align": u32, - @"addrspace": std.builtin.AddressSpace, - bit_offset: u16, - host_size: u16, - mutable: bool, - @"allowzero": bool, - @"volatile": bool, - size: std.builtin.TypeInfo.Pointer.Size, -) Allocator.Error!Type { - assert(host_size == 0 or bit_offset < host_size * 8); - - if (sentinel != null or @"align" != 0 or @"addrspace" != .generic or - bit_offset != 0 or host_size != 0 or @"allowzero" or @"volatile") - { - return Type.Tag.pointer.create(arena, .{ - .pointee_type = elem_ty, - .sentinel = sentinel, - .@"align" = @"align", - .@"addrspace" = @"addrspace", - .bit_offset = bit_offset, - .host_size = host_size, - .@"allowzero" = @"allowzero", - .mutable = mutable, - .@"volatile" = @"volatile", - .size = size, - }); - } - - if (!mutable and size == .Slice and elem_ty.eql(Type.initTag(.u8))) { - return Type.initTag(.const_slice_u8); - } - - // TODO stage1 type inference bug - const T = Type.Tag; - - const type_payload = try arena.create(Type.Payload.ElemType); - type_payload.* = .{ - .base = .{ - .tag = switch (size) { - .One => if (mutable) T.single_mut_pointer else T.single_const_pointer, - .Many => if (mutable) T.many_mut_pointer else T.many_const_pointer, - .C => if (mutable) T.c_mut_pointer else T.c_const_pointer, - .Slice => if (mutable) T.mut_slice else T.const_slice, - }, - }, - .data = elem_ty, - }; - return Type.initPayload(&type_payload.base); -} - pub fn optionalType(arena: *Allocator, child_type: Type) Allocator.Error!Type { switch (child_type.tag()) { .single_const_pointer => return Type.Tag.optional_single_const_pointer.create( |
