| author | |
| committer | |
| log | d312d64c9aa058293d69b2bf97c51f4caa7a2d9d |
| tree | 3c8a6a4ec1d691157b3098d3dcd3be1027d5adf2 |
| parent | 95682484503f031efefb2c085cdd4d0b64cf8795 |
5 files changed, 127 insertions(+), 47 deletions(-)
src-self-hosted/Module.zig+4-1| ... | @@ -3146,6 +3146,9 @@ pub fn floatSub(self: *Module, scope: *Scope, float_type: Type, src: usize, lhs: | ... | @@ -3146,6 +3146,9 @@ pub fn floatSub(self: *Module, scope: *Scope, float_type: Type, src: usize, lhs: |
| 3146 | } | 3146 | } |
| 3147 | 3147 | ||
| 3148 | pub fn simplePtrType(self: *Module, scope: *Scope, src: usize, elem_ty: Type, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) Allocator.Error!Type { | 3148 | pub fn simplePtrType(self: *Module, scope: *Scope, src: usize, elem_ty: Type, mutable: bool, size: std.builtin.TypeInfo.Pointer.Size) Allocator.Error!Type { |
| 3149 | if (size == .Slice and elem_ty.eql(Type.initTag(.u8))) { | ||
| 3150 | return Type.initTag(.const_slice_u8); | ||
| 3151 | } | ||
| 3149 | // TODO stage1 type inference bug | 3152 | // TODO stage1 type inference bug |
| 3150 | const T = Type.Tag; | 3153 | const T = Type.Tag; |
| 3151 | 3154 | ||
| ... | @@ -3156,7 +3159,7 @@ pub fn simplePtrType(self: *Module, scope: *Scope, src: usize, elem_ty: Type, mu | ... | @@ -3156,7 +3159,7 @@ pub fn simplePtrType(self: *Module, scope: *Scope, src: usize, elem_ty: Type, mu |
| 3156 | .One => if (mutable) T.single_mut_pointer else T.single_const_pointer, | 3159 | .One => if (mutable) T.single_mut_pointer else T.single_const_pointer, |
| 3157 | .Many => if (mutable) T.many_mut_pointer else T.many_const_pointer, | 3160 | .Many => if (mutable) T.many_mut_pointer else T.many_const_pointer, |
| 3158 | .C => if (mutable) T.c_mut_pointer else T.c_const_pointer, | 3161 | .C => if (mutable) T.c_mut_pointer else T.c_const_pointer, |
| 3159 | else => unreachable, | 3162 | .Slice => if (mutable) T.mut_slice else T.const_slice, |
| 3160 | }, | 3163 | }, |
| 3161 | }, | 3164 | }, |
| 3162 | .pointee_type = elem_ty, | 3165 | .pointee_type = elem_ty, |
src-self-hosted/astgen.zig+29-21| ... | @@ -262,6 +262,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr | ... | @@ -262,6 +262,7 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr |
| 262 | .EnumLiteral => return rlWrap(mod, scope, rl, try enumLiteral(mod, scope, node.castTag(.EnumLiteral).?)), | 262 | .EnumLiteral => return rlWrap(mod, scope, rl, try enumLiteral(mod, scope, node.castTag(.EnumLiteral).?)), |
| 263 | .MultilineStringLiteral => return rlWrap(mod, scope, rl, try multilineStrLiteral(mod, scope, node.castTag(.MultilineStringLiteral).?)), | 263 | .MultilineStringLiteral => return rlWrap(mod, scope, rl, try multilineStrLiteral(mod, scope, node.castTag(.MultilineStringLiteral).?)), |
| 264 | .CharLiteral => return rlWrap(mod, scope, rl, try charLiteral(mod, scope, node.castTag(.CharLiteral).?)), | 264 | .CharLiteral => return rlWrap(mod, scope, rl, try charLiteral(mod, scope, node.castTag(.CharLiteral).?)), |
| 265 | .SliceType => return rlWrap(mod, scope, rl, try sliceType(mod, scope, node.castTag(.SliceType).?)), | ||
| 265 | 266 | ||
| 266 | .Defer => return mod.failNode(scope, node, "TODO implement astgen.expr for .Defer", .{}), | 267 | .Defer => return mod.failNode(scope, node, "TODO implement astgen.expr for .Defer", .{}), |
| 267 | .Catch => return mod.failNode(scope, node, "TODO implement astgen.expr for .Catch", .{}), | 268 | .Catch => return mod.failNode(scope, node, "TODO implement astgen.expr for .Catch", .{}), |
| ... | @@ -275,7 +276,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr | ... | @@ -275,7 +276,6 @@ pub fn expr(mod: *Module, scope: *Scope, rl: ResultLoc, node: *ast.Node) InnerEr |
| 275 | .NegationWrap => return mod.failNode(scope, node, "TODO implement astgen.expr for .NegationWrap", .{}), | 276 | .NegationWrap => return mod.failNode(scope, node, "TODO implement astgen.expr for .NegationWrap", .{}), |
| 276 | .Resume => return mod.failNode(scope, node, "TODO implement astgen.expr for .Resume", .{}), | 277 | .Resume => return mod.failNode(scope, node, "TODO implement astgen.expr for .Resume", .{}), |
| 277 | .Try => return mod.failNode(scope, node, "TODO implement astgen.expr for .Try", .{}), | 278 | .Try => return mod.failNode(scope, node, "TODO implement astgen.expr for .Try", .{}), |
| 278 | .SliceType => return mod.failNode(scope, node, "TODO implement astgen.expr for .SliceType", .{}), | ||
| 279 | .Slice => return mod.failNode(scope, node, "TODO implement astgen.expr for .Slice", .{}), | 279 | .Slice => return mod.failNode(scope, node, "TODO implement astgen.expr for .Slice", .{}), |
| 280 | .ArrayAccess => return mod.failNode(scope, node, "TODO implement astgen.expr for .ArrayAccess", .{}), | 280 | .ArrayAccess => return mod.failNode(scope, node, "TODO implement astgen.expr for .ArrayAccess", .{}), |
| 281 | .ArrayInitializer => return mod.failNode(scope, node, "TODO implement astgen.expr for .ArrayInitializer", .{}), | 281 | .ArrayInitializer => return mod.failNode(scope, node, "TODO implement astgen.expr for .ArrayInitializer", .{}), |
| ... | @@ -569,15 +569,16 @@ fn optionalType(mod: *Module, scope: *Scope, node: *ast.Node.SimplePrefixOp) Inn | ... | @@ -569,15 +569,16 @@ fn optionalType(mod: *Module, scope: *Scope, node: *ast.Node.SimplePrefixOp) Inn |
| 569 | return addZIRUnOp(mod, scope, src, .optional_type, operand); | 569 | return addZIRUnOp(mod, scope, src, .optional_type, operand); |
| 570 | } | 570 | } |
| 571 | 571 | ||
| 572 | fn ptrType(mod: *Module, scope: *Scope, node: *ast.Node.PtrType) InnerError!*zir.Inst { | 572 | fn sliceType(mod: *Module, scope: *Scope, node: *ast.Node.SliceType) InnerError!*zir.Inst { |
| 573 | const tree = scope.tree(); | 573 | const tree = scope.tree(); |
| 574 | const src = tree.token_locs[node.op_token].start; | 574 | const src = tree.token_locs[node.op_token].start; |
| 575 | const meta_type = try addZIRInstConst(mod, scope, src, .{ | 575 | return ptrSliceType(mod, scope, src, &node.ptr_info, node.rhs, .Slice); |
| 576 | .ty = Type.initTag(.type), | 576 | } |
| 577 | .val = Value.initTag(.type_type), | ||
| 578 | }); | ||
| 579 | 577 | ||
| 580 | const size: std.builtin.TypeInfo.Pointer.Size = switch (tree.token_ids[node.op_token]) { | 578 | fn ptrType(mod: *Module, scope: *Scope, node: *ast.Node.PtrType) InnerError!*zir.Inst { |
| 579 | const tree = scope.tree(); | ||
| 580 | const src = tree.token_locs[node.op_token].start; | ||
| 581 | return ptrSliceType(mod, scope, src, &node.ptr_info, node.rhs, switch (tree.token_ids[node.op_token]) { | ||
| 581 | .Asterisk, .AsteriskAsterisk => .One, | 582 | .Asterisk, .AsteriskAsterisk => .One, |
| 582 | // TODO stage1 type inference bug | 583 | // TODO stage1 type inference bug |
| 583 | .LBracket => @as(std.builtin.TypeInfo.Pointer.Size, switch (tree.token_ids[node.op_token + 2]) { | 584 | .LBracket => @as(std.builtin.TypeInfo.Pointer.Size, switch (tree.token_ids[node.op_token + 2]) { |
| ... | @@ -585,43 +586,50 @@ fn ptrType(mod: *Module, scope: *Scope, node: *ast.Node.PtrType) InnerError!*zir | ... | @@ -585,43 +586,50 @@ fn ptrType(mod: *Module, scope: *Scope, node: *ast.Node.PtrType) InnerError!*zir |
| 585 | else => .Many, | 586 | else => .Many, |
| 586 | }), | 587 | }), |
| 587 | else => unreachable, | 588 | else => unreachable, |
| 588 | }; | 589 | }); |
| 590 | } | ||
| 589 | 591 | ||
| 590 | const simple = node.ptr_info.allowzero_token == null and | 592 | fn ptrSliceType(mod: *Module, scope: *Scope, src: usize, ptr_info: *ast.PtrInfo, rhs: *ast.Node, size: std.builtin.TypeInfo.Pointer.Size) InnerError!*zir.Inst { |
| 591 | node.ptr_info.align_info == null and | 593 | const meta_type = try addZIRInstConst(mod, scope, src, .{ |
| 592 | node.ptr_info.volatile_token == null and | 594 | .ty = Type.initTag(.type), |
| 593 | node.ptr_info.sentinel == null; | 595 | .val = Value.initTag(.type_type), |
| 596 | }); | ||
| 597 | |||
| 598 | const simple = ptr_info.allowzero_token == null and | ||
| 599 | ptr_info.align_info == null and | ||
| 600 | ptr_info.volatile_token == null and | ||
| 601 | ptr_info.sentinel == null; | ||
| 594 | 602 | ||
| 595 | if (simple) { | 603 | if (simple) { |
| 596 | const child_type = try expr(mod, scope, .{ .ty = meta_type }, node.rhs); | 604 | const child_type = try expr(mod, scope, .{ .ty = meta_type }, rhs); |
| 597 | const mutable = node.ptr_info.const_token == null; | 605 | const mutable = ptr_info.const_token == null; |
| 598 | // TODO stage1 type inference bug | 606 | // TODO stage1 type inference bug |
| 599 | const T = zir.Inst.Tag; | 607 | const T = zir.Inst.Tag; |
| 600 | return addZIRUnOp(mod, scope, src, switch (size) { | 608 | return addZIRUnOp(mod, scope, src, switch (size) { |
| 601 | .One => if (mutable) T.single_mut_ptr_type else T.single_const_ptr_type, | 609 | .One => if (mutable) T.single_mut_ptr_type else T.single_const_ptr_type, |
| 602 | .Many => if (mutable) T.many_mut_ptr_type else T.many_const_ptr_type, | 610 | .Many => if (mutable) T.many_mut_ptr_type else T.many_const_ptr_type, |
| 603 | .C => if (mutable) T.c_mut_ptr_type else T.c_const_ptr_type, | 611 | .C => if (mutable) T.c_mut_ptr_type else T.c_const_ptr_type, |
| 604 | else => unreachable, | 612 | .Slice => if (mutable) T.mut_slice_type else T.mut_slice_type, |
| 605 | }, child_type); | 613 | }, child_type); |
| 606 | } | 614 | } |
| 607 | 615 | ||
| 608 | var kw_args: std.meta.fieldInfo(zir.Inst.PtrType, "kw_args").field_type = .{}; | 616 | var kw_args: std.meta.fieldInfo(zir.Inst.PtrType, "kw_args").field_type = .{}; |
| 609 | kw_args.size = size; | 617 | kw_args.size = size; |
| 610 | kw_args.@"allowzero" = node.ptr_info.allowzero_token != null; | 618 | kw_args.@"allowzero" = ptr_info.allowzero_token != null; |
| 611 | if (node.ptr_info.align_info) |some| { | 619 | if (ptr_info.align_info) |some| { |
| 612 | kw_args.@"align" = try expr(mod, scope, .none, some.node); | 620 | kw_args.@"align" = try expr(mod, scope, .none, some.node); |
| 613 | if (some.bit_range) |bit_range| { | 621 | if (some.bit_range) |bit_range| { |
| 614 | kw_args.align_bit_start = try expr(mod, scope, .none, bit_range.start); | 622 | kw_args.align_bit_start = try expr(mod, scope, .none, bit_range.start); |
| 615 | kw_args.align_bit_end = try expr(mod, scope, .none, bit_range.end); | 623 | kw_args.align_bit_end = try expr(mod, scope, .none, bit_range.end); |
| 616 | } | 624 | } |
| 617 | } | 625 | } |
| 618 | kw_args.mutable = node.ptr_info.const_token == null; | 626 | kw_args.mutable = ptr_info.const_token == null; |
| 619 | kw_args.@"volatile" = node.ptr_info.volatile_token != null; | 627 | kw_args.@"volatile" = ptr_info.volatile_token != null; |
| 620 | if (node.ptr_info.sentinel) |some| { | 628 | if (ptr_info.sentinel) |some| { |
| 621 | kw_args.sentinel = try expr(mod, scope, .none, some); | 629 | kw_args.sentinel = try expr(mod, scope, .none, some); |
| 622 | } | 630 | } |
| 623 | 631 | ||
| 624 | const child_type = try expr(mod, scope, .{ .ty = meta_type }, node.rhs); | 632 | const child_type = try expr(mod, scope, .{ .ty = meta_type }, rhs); |
| 625 | if (kw_args.sentinel) |some| { | 633 | if (kw_args.sentinel) |some| { |
| 626 | kw_args.sentinel = try addZIRBinOp(mod, scope, some.src, .as, child_type, some); | 634 | kw_args.sentinel = try addZIRBinOp(mod, scope, some.src, .as, child_type, some); |
| 627 | } | 635 | } |
src-self-hosted/type.zig+78-19| ... | @@ -74,6 +74,8 @@ pub const Type = extern union { | ... | @@ -74,6 +74,8 @@ pub const Type = extern union { |
| 74 | .many_mut_pointer, | 74 | .many_mut_pointer, |
| 75 | .c_const_pointer, | 75 | .c_const_pointer, |
| 76 | .c_mut_pointer, | 76 | .c_mut_pointer, |
| 77 | .const_slice, | ||
| 78 | .mut_slice, | ||
| 77 | .pointer, | 79 | .pointer, |
| 78 | => return .Pointer, | 80 | => return .Pointer, |
| 79 | 81 | ||
| ... | @@ -122,6 +124,8 @@ pub const Type = extern union { | ... | @@ -122,6 +124,8 @@ pub const Type = extern union { |
| 122 | .many_mut_pointer, | 124 | .many_mut_pointer, |
| 123 | .c_const_pointer, | 125 | .c_const_pointer, |
| 124 | .c_mut_pointer, | 126 | .c_mut_pointer, |
| 127 | .const_slice, | ||
| 128 | .mut_slice, | ||
| 125 | .optional_single_const_pointer, | 129 | .optional_single_const_pointer, |
| 126 | .optional_single_mut_pointer, | 130 | .optional_single_mut_pointer, |
| 127 | => @fieldParentPtr(Payload.PointerSimple, "base", self.ptr_otherwise), | 131 | => @fieldParentPtr(Payload.PointerSimple, "base", self.ptr_otherwise), |
| ... | @@ -388,6 +392,8 @@ pub const Type = extern union { | ... | @@ -388,6 +392,8 @@ pub const Type = extern union { |
| 388 | .many_mut_pointer, | 392 | .many_mut_pointer, |
| 389 | .c_const_pointer, | 393 | .c_const_pointer, |
| 390 | .c_mut_pointer, | 394 | .c_mut_pointer, |
| 395 | .const_slice, | ||
| 396 | .mut_slice, | ||
| 391 | .optional_single_mut_pointer, | 397 | .optional_single_mut_pointer, |
| 392 | .optional_single_const_pointer, | 398 | .optional_single_const_pointer, |
| 393 | => return self.copyPayloadSingleField(allocator, Payload.PointerSimple, "pointee_type"), | 399 | => return self.copyPayloadSingleField(allocator, Payload.PointerSimple, "pointee_type"), |
| ... | @@ -550,6 +556,18 @@ pub const Type = extern union { | ... | @@ -550,6 +556,18 @@ pub const Type = extern union { |
| 550 | ty = payload.pointee_type; | 556 | ty = payload.pointee_type; |
| 551 | continue; | 557 | continue; |
| 552 | }, | 558 | }, |
| 559 | .const_slice => { | ||
| 560 | const payload = @fieldParentPtr(Payload.PointerSimple, "base", ty.ptr_otherwise); | ||
| 561 | try out_stream.writeAll("[]const "); | ||
| 562 | ty = payload.pointee_type; | ||
| 563 | continue; | ||
| 564 | }, | ||
| 565 | .mut_slice => { | ||
| 566 | const payload = @fieldParentPtr(Payload.PointerSimple, "base", ty.ptr_otherwise); | ||
| 567 | try out_stream.writeAll("[]"); | ||
| 568 | ty = payload.pointee_type; | ||
| 569 | continue; | ||
| 570 | }, | ||
| 553 | .int_signed => { | 571 | .int_signed => { |
| 554 | const payload = @fieldParentPtr(Payload.IntSigned, "base", ty.ptr_otherwise); | 572 | const payload = @fieldParentPtr(Payload.IntSigned, "base", ty.ptr_otherwise); |
| 555 | return out_stream.print("i{}", .{payload.bits}); | 573 | return out_stream.print("i{}", .{payload.bits}); |
| ... | @@ -701,14 +719,7 @@ pub const Type = extern union { | ... | @@ -701,14 +719,7 @@ pub const Type = extern union { |
| 701 | // TODO lazy types | 719 | // TODO lazy types |
| 702 | .array => self.elemType().hasCodeGenBits() and self.arrayLen() != 0, | 720 | .array => self.elemType().hasCodeGenBits() and self.arrayLen() != 0, |
| 703 | .array_u8 => self.arrayLen() != 0, | 721 | .array_u8 => self.arrayLen() != 0, |
| 704 | .array_sentinel => self.elemType().hasCodeGenBits(), | 722 | .array_sentinel, .single_const_pointer, .single_mut_pointer, .many_const_pointer, .many_mut_pointer, .c_const_pointer, .c_mut_pointer, .const_slice, .mut_slice, .pointer => self.elemType().hasCodeGenBits(), |
| 705 | .single_const_pointer => self.elemType().hasCodeGenBits(), | ||
| 706 | .single_mut_pointer => self.elemType().hasCodeGenBits(), | ||
| 707 | .many_const_pointer => self.elemType().hasCodeGenBits(), | ||
| 708 | .many_mut_pointer => self.elemType().hasCodeGenBits(), | ||
| 709 | .c_const_pointer => self.elemType().hasCodeGenBits(), | ||
| 710 | .c_mut_pointer => self.elemType().hasCodeGenBits(), | ||
| 711 | .pointer => self.elemType().hasCodeGenBits(), | ||
| 712 | .int_signed => self.cast(Payload.IntSigned).?.bits == 0, | 723 | .int_signed => self.cast(Payload.IntSigned).?.bits == 0, |
| 713 | .int_unsigned => self.cast(Payload.IntUnsigned).?.bits == 0, | 724 | .int_unsigned => self.cast(Payload.IntUnsigned).?.bits == 0, |
| 714 | 725 | ||
| ... | @@ -763,6 +774,8 @@ pub const Type = extern union { | ... | @@ -763,6 +774,8 @@ pub const Type = extern union { |
| 763 | .many_mut_pointer, | 774 | .many_mut_pointer, |
| 764 | .c_const_pointer, | 775 | .c_const_pointer, |
| 765 | .c_mut_pointer, | 776 | .c_mut_pointer, |
| 777 | .const_slice, | ||
| 778 | .mut_slice, | ||
| 766 | .optional_single_const_pointer, | 779 | .optional_single_const_pointer, |
| 767 | .optional_single_mut_pointer, | 780 | .optional_single_mut_pointer, |
| 768 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), | 781 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), |
| ... | @@ -868,10 +881,12 @@ pub const Type = extern union { | ... | @@ -868,10 +881,12 @@ pub const Type = extern union { |
| 868 | .i32, .u32 => return 4, | 881 | .i32, .u32 => return 4, |
| 869 | .i64, .u64 => return 8, | 882 | .i64, .u64 => return 8, |
| 870 | 883 | ||
| 871 | .isize, | 884 | .isize, .usize => return @divExact(target.cpu.arch.ptrBitWidth(), 8), |
| 872 | .usize | 885 | |
| 873 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8), | 886 | .const_slice, |
| 874 | .const_slice_u8 => return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2, | 887 | .mut_slice, |
| 888 | .const_slice_u8, | ||
| 889 | => return @divExact(target.cpu.arch.ptrBitWidth(), 8) * 2, | ||
| 875 | 890 | ||
| 876 | .optional_single_const_pointer, | 891 | .optional_single_const_pointer, |
| 877 | .optional_single_mut_pointer, | 892 | .optional_single_mut_pointer, |
| ... | @@ -992,6 +1007,8 @@ pub const Type = extern union { | ... | @@ -992,6 +1007,8 @@ pub const Type = extern union { |
| 992 | .many_mut_pointer, | 1007 | .many_mut_pointer, |
| 993 | .c_const_pointer, | 1008 | .c_const_pointer, |
| 994 | .c_mut_pointer, | 1009 | .c_mut_pointer, |
| 1010 | .const_slice, | ||
| 1011 | .mut_slice, | ||
| 995 | => false, | 1012 | => false, |
| 996 | 1013 | ||
| 997 | .single_const_pointer, | 1014 | .single_const_pointer, |
| ... | @@ -1062,7 +1079,10 @@ pub const Type = extern union { | ... | @@ -1062,7 +1079,10 @@ pub const Type = extern union { |
| 1062 | .enum_literal, | 1079 | .enum_literal, |
| 1063 | => false, | 1080 | => false, |
| 1064 | 1081 | ||
| 1065 | .const_slice_u8 => true, | 1082 | .const_slice, |
| 1083 | .mut_slice, | ||
| 1084 | .const_slice_u8, | ||
| 1085 | => true, | ||
| 1066 | 1086 | ||
| 1067 | .pointer => self.cast(Payload.Pointer).?.size == .Slice, | 1087 | .pointer => self.cast(Payload.Pointer).?.size == .Slice, |
| 1068 | }; | 1088 | }; |
| ... | @@ -1121,6 +1141,7 @@ pub const Type = extern union { | ... | @@ -1121,6 +1141,7 @@ pub const Type = extern union { |
| 1121 | .optional_single_mut_pointer, | 1141 | .optional_single_mut_pointer, |
| 1122 | .optional_single_const_pointer, | 1142 | .optional_single_const_pointer, |
| 1123 | .enum_literal, | 1143 | .enum_literal, |
| 1144 | .mut_slice, | ||
| 1124 | => false, | 1145 | => false, |
| 1125 | 1146 | ||
| 1126 | .single_const_pointer, | 1147 | .single_const_pointer, |
| ... | @@ -1128,6 +1149,7 @@ pub const Type = extern union { | ... | @@ -1128,6 +1149,7 @@ pub const Type = extern union { |
| 1128 | .c_const_pointer, | 1149 | .c_const_pointer, |
| 1129 | .single_const_pointer_to_comptime_int, | 1150 | .single_const_pointer_to_comptime_int, |
| 1130 | .const_slice_u8, | 1151 | .const_slice_u8, |
| 1152 | .const_slice, | ||
| 1131 | => true, | 1153 | => true, |
| 1132 | 1154 | ||
| 1133 | .pointer => !self.cast(Payload.Pointer).?.mutable, | 1155 | .pointer => !self.cast(Payload.Pointer).?.mutable, |
| ... | @@ -1186,6 +1208,8 @@ pub const Type = extern union { | ... | @@ -1186,6 +1208,8 @@ pub const Type = extern union { |
| 1186 | .many_mut_pointer, | 1208 | .many_mut_pointer, |
| 1187 | .c_const_pointer, | 1209 | .c_const_pointer, |
| 1188 | .c_mut_pointer, | 1210 | .c_mut_pointer, |
| 1211 | .const_slice, | ||
| 1212 | .mut_slice, | ||
| 1189 | .single_const_pointer_to_comptime_int, | 1213 | .single_const_pointer_to_comptime_int, |
| 1190 | .const_slice_u8, | 1214 | .const_slice_u8, |
| 1191 | .optional, | 1215 | .optional, |
| ... | @@ -1307,12 +1331,15 @@ pub const Type = extern union { | ... | @@ -1307,12 +1331,15 @@ pub const Type = extern union { |
| 1307 | 1331 | ||
| 1308 | .array => self.cast(Payload.Array).?.elem_type, | 1332 | .array => self.cast(Payload.Array).?.elem_type, |
| 1309 | .array_sentinel => self.cast(Payload.ArraySentinel).?.elem_type, | 1333 | .array_sentinel => self.cast(Payload.ArraySentinel).?.elem_type, |
| 1310 | .single_const_pointer => self.castPointer().?.pointee_type, | 1334 | .single_const_pointer, |
| 1311 | .single_mut_pointer => self.castPointer().?.pointee_type, | 1335 | .single_mut_pointer, |
| 1312 | .many_const_pointer => self.castPointer().?.pointee_type, | 1336 | .many_const_pointer, |
| 1313 | .many_mut_pointer => self.castPointer().?.pointee_type, | 1337 | .many_mut_pointer, |
| 1314 | .c_const_pointer => self.castPointer().?.pointee_type, | 1338 | .c_const_pointer, |
| 1315 | .c_mut_pointer => self.castPointer().?.pointee_type, | 1339 | .c_mut_pointer, |
| 1340 | .const_slice, | ||
| 1341 | .mut_slice, | ||
| 1342 | => self.castPointer().?.pointee_type, | ||
| 1316 | .array_u8, .array_u8_sentinel_0, .const_slice_u8 => Type.initTag(.u8), | 1343 | .array_u8, .array_u8_sentinel_0, .const_slice_u8 => Type.initTag(.u8), |
| 1317 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), | 1344 | .single_const_pointer_to_comptime_int => Type.initTag(.comptime_int), |
| 1318 | .pointer => self.cast(Payload.Pointer).?.pointee_type, | 1345 | .pointer => self.cast(Payload.Pointer).?.pointee_type, |
| ... | @@ -1411,6 +1438,8 @@ pub const Type = extern union { | ... | @@ -1411,6 +1438,8 @@ pub const Type = extern union { |
| 1411 | .many_mut_pointer, | 1438 | .many_mut_pointer, |
| 1412 | .c_const_pointer, | 1439 | .c_const_pointer, |
| 1413 | .c_mut_pointer, | 1440 | .c_mut_pointer, |
| 1441 | .const_slice, | ||
| 1442 | .mut_slice, | ||
| 1414 | .single_const_pointer_to_comptime_int, | 1443 | .single_const_pointer_to_comptime_int, |
| 1415 | .const_slice_u8, | 1444 | .const_slice_u8, |
| 1416 | .int_unsigned, | 1445 | .int_unsigned, |
| ... | @@ -1476,6 +1505,8 @@ pub const Type = extern union { | ... | @@ -1476,6 +1505,8 @@ pub const Type = extern union { |
| 1476 | .many_mut_pointer, | 1505 | .many_mut_pointer, |
| 1477 | .c_const_pointer, | 1506 | .c_const_pointer, |
| 1478 | .c_mut_pointer, | 1507 | .c_mut_pointer, |
| 1508 | .const_slice, | ||
| 1509 | .mut_slice, | ||
| 1479 | .single_const_pointer_to_comptime_int, | 1510 | .single_const_pointer_to_comptime_int, |
| 1480 | .const_slice_u8, | 1511 | .const_slice_u8, |
| 1481 | .int_unsigned, | 1512 | .int_unsigned, |
| ... | @@ -1531,6 +1562,8 @@ pub const Type = extern union { | ... | @@ -1531,6 +1562,8 @@ pub const Type = extern union { |
| 1531 | .many_mut_pointer, | 1562 | .many_mut_pointer, |
| 1532 | .c_const_pointer, | 1563 | .c_const_pointer, |
| 1533 | .c_mut_pointer, | 1564 | .c_mut_pointer, |
| 1565 | .const_slice, | ||
| 1566 | .mut_slice, | ||
| 1534 | .single_const_pointer_to_comptime_int, | 1567 | .single_const_pointer_to_comptime_int, |
| 1535 | .const_slice_u8, | 1568 | .const_slice_u8, |
| 1536 | .int_unsigned, | 1569 | .int_unsigned, |
| ... | @@ -1597,6 +1630,8 @@ pub const Type = extern union { | ... | @@ -1597,6 +1630,8 @@ pub const Type = extern union { |
| 1597 | .many_mut_pointer, | 1630 | .many_mut_pointer, |
| 1598 | .c_const_pointer, | 1631 | .c_const_pointer, |
| 1599 | .c_mut_pointer, | 1632 | .c_mut_pointer, |
| 1633 | .const_slice, | ||
| 1634 | .mut_slice, | ||
| 1600 | .single_const_pointer_to_comptime_int, | 1635 | .single_const_pointer_to_comptime_int, |
| 1601 | .const_slice_u8, | 1636 | .const_slice_u8, |
| 1602 | .int_signed, | 1637 | .int_signed, |
| ... | @@ -1663,6 +1698,8 @@ pub const Type = extern union { | ... | @@ -1663,6 +1698,8 @@ pub const Type = extern union { |
| 1663 | .many_mut_pointer, | 1698 | .many_mut_pointer, |
| 1664 | .c_const_pointer, | 1699 | .c_const_pointer, |
| 1665 | .c_mut_pointer, | 1700 | .c_mut_pointer, |
| 1701 | .const_slice, | ||
| 1702 | .mut_slice, | ||
| 1666 | .single_const_pointer_to_comptime_int, | 1703 | .single_const_pointer_to_comptime_int, |
| 1667 | .const_slice_u8, | 1704 | .const_slice_u8, |
| 1668 | .optional, | 1705 | .optional, |
| ... | @@ -1727,6 +1764,8 @@ pub const Type = extern union { | ... | @@ -1727,6 +1764,8 @@ pub const Type = extern union { |
| 1727 | .many_mut_pointer, | 1764 | .many_mut_pointer, |
| 1728 | .c_const_pointer, | 1765 | .c_const_pointer, |
| 1729 | .c_mut_pointer, | 1766 | .c_mut_pointer, |
| 1767 | .const_slice, | ||
| 1768 | .mut_slice, | ||
| 1730 | .single_const_pointer_to_comptime_int, | 1769 | .single_const_pointer_to_comptime_int, |
| 1731 | .const_slice_u8, | 1770 | .const_slice_u8, |
| 1732 | .int_unsigned, | 1771 | .int_unsigned, |
| ... | @@ -1820,6 +1859,8 @@ pub const Type = extern union { | ... | @@ -1820,6 +1859,8 @@ pub const Type = extern union { |
| 1820 | .many_mut_pointer, | 1859 | .many_mut_pointer, |
| 1821 | .c_const_pointer, | 1860 | .c_const_pointer, |
| 1822 | .c_mut_pointer, | 1861 | .c_mut_pointer, |
| 1862 | .const_slice, | ||
| 1863 | .mut_slice, | ||
| 1823 | .single_const_pointer_to_comptime_int, | 1864 | .single_const_pointer_to_comptime_int, |
| 1824 | .const_slice_u8, | 1865 | .const_slice_u8, |
| 1825 | .u8, | 1866 | .u8, |
| ... | @@ -1889,6 +1930,8 @@ pub const Type = extern union { | ... | @@ -1889,6 +1930,8 @@ pub const Type = extern union { |
| 1889 | .many_mut_pointer, | 1930 | .many_mut_pointer, |
| 1890 | .c_const_pointer, | 1931 | .c_const_pointer, |
| 1891 | .c_mut_pointer, | 1932 | .c_mut_pointer, |
| 1933 | .const_slice, | ||
| 1934 | .mut_slice, | ||
| 1892 | .single_const_pointer_to_comptime_int, | 1935 | .single_const_pointer_to_comptime_int, |
| 1893 | .const_slice_u8, | 1936 | .const_slice_u8, |
| 1894 | .u8, | 1937 | .u8, |
| ... | @@ -1957,6 +2000,8 @@ pub const Type = extern union { | ... | @@ -1957,6 +2000,8 @@ pub const Type = extern union { |
| 1957 | .many_mut_pointer, | 2000 | .many_mut_pointer, |
| 1958 | .c_const_pointer, | 2001 | .c_const_pointer, |
| 1959 | .c_mut_pointer, | 2002 | .c_mut_pointer, |
| 2003 | .const_slice, | ||
| 2004 | .mut_slice, | ||
| 1960 | .single_const_pointer_to_comptime_int, | 2005 | .single_const_pointer_to_comptime_int, |
| 1961 | .const_slice_u8, | 2006 | .const_slice_u8, |
| 1962 | .u8, | 2007 | .u8, |
| ... | @@ -2025,6 +2070,8 @@ pub const Type = extern union { | ... | @@ -2025,6 +2070,8 @@ pub const Type = extern union { |
| 2025 | .many_mut_pointer, | 2070 | .many_mut_pointer, |
| 2026 | .c_const_pointer, | 2071 | .c_const_pointer, |
| 2027 | .c_mut_pointer, | 2072 | .c_mut_pointer, |
| 2073 | .const_slice, | ||
| 2074 | .mut_slice, | ||
| 2028 | .single_const_pointer_to_comptime_int, | 2075 | .single_const_pointer_to_comptime_int, |
| 2029 | .const_slice_u8, | 2076 | .const_slice_u8, |
| 2030 | .u8, | 2077 | .u8, |
| ... | @@ -2090,6 +2137,8 @@ pub const Type = extern union { | ... | @@ -2090,6 +2137,8 @@ pub const Type = extern union { |
| 2090 | .many_mut_pointer, | 2137 | .many_mut_pointer, |
| 2091 | .c_const_pointer, | 2138 | .c_const_pointer, |
| 2092 | .c_mut_pointer, | 2139 | .c_mut_pointer, |
| 2140 | .const_slice, | ||
| 2141 | .mut_slice, | ||
| 2093 | .single_const_pointer_to_comptime_int, | 2142 | .single_const_pointer_to_comptime_int, |
| 2094 | .const_slice_u8, | 2143 | .const_slice_u8, |
| 2095 | .u8, | 2144 | .u8, |
| ... | @@ -2155,6 +2204,8 @@ pub const Type = extern union { | ... | @@ -2155,6 +2204,8 @@ pub const Type = extern union { |
| 2155 | .many_mut_pointer, | 2204 | .many_mut_pointer, |
| 2156 | .c_const_pointer, | 2205 | .c_const_pointer, |
| 2157 | .c_mut_pointer, | 2206 | .c_mut_pointer, |
| 2207 | .const_slice, | ||
| 2208 | .mut_slice, | ||
| 2158 | .single_const_pointer_to_comptime_int, | 2209 | .single_const_pointer_to_comptime_int, |
| 2159 | .const_slice_u8, | 2210 | .const_slice_u8, |
| 2160 | .u8, | 2211 | .u8, |
| ... | @@ -2240,6 +2291,8 @@ pub const Type = extern union { | ... | @@ -2240,6 +2291,8 @@ pub const Type = extern union { |
| 2240 | .many_mut_pointer, | 2291 | .many_mut_pointer, |
| 2241 | .c_const_pointer, | 2292 | .c_const_pointer, |
| 2242 | .c_mut_pointer, | 2293 | .c_mut_pointer, |
| 2294 | .const_slice, | ||
| 2295 | .mut_slice, | ||
| 2243 | .single_const_pointer_to_comptime_int, | 2296 | .single_const_pointer_to_comptime_int, |
| 2244 | .const_slice_u8, | 2297 | .const_slice_u8, |
| 2245 | .optional, | 2298 | .optional, |
| ... | @@ -2290,6 +2343,8 @@ pub const Type = extern union { | ... | @@ -2290,6 +2343,8 @@ pub const Type = extern union { |
| 2290 | .array_sentinel, | 2343 | .array_sentinel, |
| 2291 | .array_u8_sentinel_0, | 2344 | .array_u8_sentinel_0, |
| 2292 | .const_slice_u8, | 2345 | .const_slice_u8, |
| 2346 | .const_slice, | ||
| 2347 | .mut_slice, | ||
| 2293 | .c_void, | 2348 | .c_void, |
| 2294 | .optional, | 2349 | .optional, |
| 2295 | .optional_single_mut_pointer, | 2350 | .optional_single_mut_pointer, |
| ... | @@ -2392,6 +2447,8 @@ pub const Type = extern union { | ... | @@ -2392,6 +2447,8 @@ pub const Type = extern union { |
| 2392 | .single_mut_pointer, | 2447 | .single_mut_pointer, |
| 2393 | .many_const_pointer, | 2448 | .many_const_pointer, |
| 2394 | .many_mut_pointer, | 2449 | .many_mut_pointer, |
| 2450 | .const_slice, | ||
| 2451 | .mut_slice, | ||
| 2395 | .optional, | 2452 | .optional, |
| 2396 | .optional_single_mut_pointer, | 2453 | .optional_single_mut_pointer, |
| 2397 | .optional_single_const_pointer, | 2454 | .optional_single_const_pointer, |
| ... | @@ -2467,6 +2524,8 @@ pub const Type = extern union { | ... | @@ -2467,6 +2524,8 @@ pub const Type = extern union { |
| 2467 | many_mut_pointer, | 2524 | many_mut_pointer, |
| 2468 | c_const_pointer, | 2525 | c_const_pointer, |
| 2469 | c_mut_pointer, | 2526 | c_mut_pointer, |
| 2527 | const_slice, | ||
| 2528 | mut_slice, | ||
| 2470 | int_signed, | 2529 | int_signed, |
| 2471 | int_unsigned, | 2530 | int_unsigned, |
| 2472 | function, | 2531 | function, |
src-self-hosted/zir.zig+14-6| ... | @@ -194,18 +194,22 @@ pub const Inst = struct { | ... | @@ -194,18 +194,22 @@ pub const Inst = struct { |
| 194 | shl, | 194 | shl, |
| 195 | /// Integer shift-right. Arithmetic or logical depending on the signedness of the integer type. | 195 | /// Integer shift-right. Arithmetic or logical depending on the signedness of the integer type. |
| 196 | shr, | 196 | shr, |
| 197 | /// Create a const pointer type based on the element type. `*const T` | 197 | /// Create a const pointer type with element type T. `*const T` |
| 198 | single_const_ptr_type, | 198 | single_const_ptr_type, |
| 199 | /// Create a mutable pointer type based on the element type. `*T` | 199 | /// Create a mutable pointer type with element type T. `*T` |
| 200 | single_mut_ptr_type, | 200 | single_mut_ptr_type, |
| 201 | /// Create a const pointer type based on the element type. `[*]const T` | 201 | /// Create a const pointer type with element type T. `[*]const T` |
| 202 | many_const_ptr_type, | 202 | many_const_ptr_type, |
| 203 | /// Create a mutable pointer type based on the element type. `[*]T` | 203 | /// Create a mutable pointer type with element type T. `[*]T` |
| 204 | many_mut_ptr_type, | 204 | many_mut_ptr_type, |
| 205 | /// Create a const pointer type based on the element type. `[*c]const T` | 205 | /// Create a const pointer type with element type T. `[*c]const T` |
| 206 | c_const_ptr_type, | 206 | c_const_ptr_type, |
| 207 | /// Create a mutable pointer type based on the element type. `[*c]T` | 207 | /// Create a mutable pointer type with element type T. `[*c]T` |
| 208 | c_mut_ptr_type, | 208 | c_mut_ptr_type, |
| 209 | /// Create a mutable slice type with element type T. `[]T` | ||
| 210 | mut_slice_type, | ||
| 211 | /// Create a const slice type with element type T. `[]T` | ||
| 212 | const_slice_type, | ||
| 209 | /// Create a pointer type with attributes | 213 | /// Create a pointer type with attributes |
| 210 | ptr_type, | 214 | ptr_type, |
| 211 | /// Write a value to a pointer. For loading, see `deref`. | 215 | /// Write a value to a pointer. For loading, see `deref`. |
| ... | @@ -274,6 +278,8 @@ pub const Inst = struct { | ... | @@ -274,6 +278,8 @@ pub const Inst = struct { |
| 274 | .many_mut_ptr_type, | 278 | .many_mut_ptr_type, |
| 275 | .c_const_ptr_type, | 279 | .c_const_ptr_type, |
| 276 | .c_mut_ptr_type, | 280 | .c_mut_ptr_type, |
| 281 | .mut_slice_type, | ||
| 282 | .const_slice_type, | ||
| 277 | .optional_type, | 283 | .optional_type, |
| 278 | .unwrap_optional_safe, | 284 | .unwrap_optional_safe, |
| 279 | .unwrap_optional_unsafe, | 285 | .unwrap_optional_unsafe, |
| ... | @@ -416,6 +422,8 @@ pub const Inst = struct { | ... | @@ -416,6 +422,8 @@ pub const Inst = struct { |
| 416 | .many_mut_ptr_type, | 422 | .many_mut_ptr_type, |
| 417 | .c_const_ptr_type, | 423 | .c_const_ptr_type, |
| 418 | .c_mut_ptr_type, | 424 | .c_mut_ptr_type, |
| 425 | .mut_slice_type, | ||
| 426 | .const_slice_type, | ||
| 419 | .store, | 427 | .store, |
| 420 | .str, | 428 | .str, |
| 421 | .sub, | 429 | .sub, |
src-self-hosted/zir_sema.zig+2| ... | @@ -57,6 +57,8 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! | ... | @@ -57,6 +57,8 @@ pub fn analyzeInst(mod: *Module, scope: *Scope, old_inst: *zir.Inst) InnerError! |
| 57 | .many_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), | 57 | .many_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.many_mut_ptr_type).?, true, .Many), |
| 58 | .c_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), | 58 | .c_const_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_const_ptr_type).?, false, .C), |
| 59 | .c_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), | 59 | .c_mut_ptr_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.c_mut_ptr_type).?, true, .C), |
| 60 | .const_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.const_slice_type).?, false, .Slice), | ||
| 61 | .mut_slice_type => return analyzeInstSimplePtrType(mod, scope, old_inst.castTag(.mut_slice_type).?, true, .Slice), | ||
| 60 | .ptr_type => return analyzeInstPtrType(mod, scope, old_inst.castTag(.ptr_type).?), | 62 | .ptr_type => return analyzeInstPtrType(mod, scope, old_inst.castTag(.ptr_type).?), |
| 61 | .store => return analyzeInstStore(mod, scope, old_inst.castTag(.store).?), | 63 | .store => return analyzeInstStore(mod, scope, old_inst.castTag(.store).?), |
| 62 | .str => return analyzeInstStr(mod, scope, old_inst.castTag(.str).?), | 64 | .str => return analyzeInstStr(mod, scope, old_inst.castTag(.str).?), |