| ... | @@ -71,7 +71,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter | ... | @@ -71,7 +71,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter |
| 71 | const gpa = comp.gpa; | 71 | const gpa = comp.gpa; |
| 72 | const io = comp.io; | 72 | const io = comp.io; |
| 73 | const ip = &pt.zcu.intern_pool; | 73 | const ip = &pt.zcu.intern_pool; |
| 74 | switch (node.get(self.file.zoir.?)) { | 74 | switch (node.get(&self.file.zoir.?)) { |
| 75 | .true => return .bool_true, | 75 | .true => return .bool_true, |
| 76 | .false => return .bool_false, | 76 | .false => return .bool_false, |
| 77 | .null => return .null_value, | 77 | .null => return .null_value, |
| ... | @@ -101,7 +101,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter | ... | @@ -101,7 +101,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter |
| 101 | gpa, | 101 | gpa, |
| 102 | io, | 102 | io, |
| 103 | pt.tid, | 103 | pt.tid, |
| 104 | val.get(self.file.zoir.?), | 104 | val.get(&self.file.zoir.?), |
| 105 | .no_embedded_nulls, | 105 | .no_embedded_nulls, |
| 106 | ), | 106 | ), |
| 107 | }), | 107 | }), |
| ... | @@ -174,7 +174,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter | ... | @@ -174,7 +174,7 @@ fn lowerExprAnonResTy(self: *LowerZon, node: Zoir.Node.Index) CompileError!Inter |
| 174 | gpa, | 174 | gpa, |
| 175 | io, | 175 | io, |
| 176 | pt.tid, | 176 | pt.tid, |
| 177 | zoir_name.get(self.file.zoir.?), | 177 | zoir_name.get(&self.file.zoir.?), |
| 178 | .no_embedded_nulls, | 178 | .no_embedded_nulls, |
| 179 | ); | 179 | ); |
| 180 | field_ty.* = ip.typeOf(field_val); | 180 | field_ty.* = ip.typeOf(field_val); |
| ... | @@ -312,7 +312,7 @@ fn checkTypeInner( | ... | @@ -312,7 +312,7 @@ fn checkTypeInner( |
| 312 | fn nodeSrc(self: *LowerZon, node: Zoir.Node.Index) LazySrcLoc { | 312 | fn nodeSrc(self: *LowerZon, node: Zoir.Node.Index) LazySrcLoc { |
| 313 | return .{ | 313 | return .{ |
| 314 | .base_node_inst = self.base_node_inst, | 314 | .base_node_inst = self.base_node_inst, |
| 315 | .offset = .{ .node_abs = node.getAstNode(self.file.zoir.?) }, | 315 | .offset = .{ .node_abs = node.getAstNode(&self.file.zoir.?) }, |
| 316 | }; | 316 | }; |
| 317 | } | 317 | } |
| 318 | | 318 | |
| ... | @@ -363,7 +363,7 @@ fn lowerExprKnownResTyInner( | ... | @@ -363,7 +363,7 @@ fn lowerExprKnownResTyInner( |
| 363 | .optional => return pt.intern(.{ | 363 | .optional => return pt.intern(.{ |
| 364 | .opt = .{ | 364 | .opt = .{ |
| 365 | .ty = res_ty.toIntern(), | 365 | .ty = res_ty.toIntern(), |
| 366 | .val = if (node.get(self.file.zoir.?) == .null) b: { | 366 | .val = if (node.get(&self.file.zoir.?) == .null) b: { |
| 367 | break :b .none; | 367 | break :b .none; |
| 368 | } else b: { | 368 | } else b: { |
| 369 | const child_type = res_ty.optionalChild(pt.zcu); | 369 | const child_type = res_ty.optionalChild(pt.zcu); |
| ... | @@ -418,7 +418,7 @@ fn lowerExprKnownResTyInner( | ... | @@ -418,7 +418,7 @@ fn lowerExprKnownResTyInner( |
| 418 | } | 418 | } |
| 419 | | 419 | |
| 420 | fn lowerBool(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { | 420 | fn lowerBool(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { |
| 421 | return switch (node.get(self.file.zoir.?)) { | 421 | return switch (node.get(&self.file.zoir.?)) { |
| 422 | .true => .bool_true, | 422 | .true => .bool_true, |
| 423 | .false => .bool_false, | 423 | .false => .bool_false, |
| 424 | else => return error.WrongType, | 424 | else => return error.WrongType, |
| ... | @@ -431,7 +431,7 @@ fn lowerInt( | ... | @@ -431,7 +431,7 @@ fn lowerInt( |
| 431 | res_ty: Type, | 431 | res_ty: Type, |
| 432 | ) !InternPool.Index { | 432 | ) !InternPool.Index { |
| 433 | @setFloatMode(.strict); | 433 | @setFloatMode(.strict); |
| 434 | return switch (node.get(self.file.zoir.?)) { | 434 | return switch (node.get(&self.file.zoir.?)) { |
| 435 | .int_literal => |int| switch (int) { | 435 | .int_literal => |int| switch (int) { |
| 436 | .small => |val| { | 436 | .small => |val| { |
| 437 | const rhs: i32 = val; | 437 | const rhs: i32 = val; |
| ... | @@ -555,7 +555,7 @@ fn lowerFloat( | ... | @@ -555,7 +555,7 @@ fn lowerFloat( |
| 555 | res_ty: Type, | 555 | res_ty: Type, |
| 556 | ) !InternPool.Index { | 556 | ) !InternPool.Index { |
| 557 | @setFloatMode(.strict); | 557 | @setFloatMode(.strict); |
| 558 | const value = switch (node.get(self.file.zoir.?)) { | 558 | const value = switch (node.get(&self.file.zoir.?)) { |
| 559 | .int_literal => |int| switch (int) { | 559 | .int_literal => |int| switch (int) { |
| 560 | .small => |val| try self.sema.pt.floatValue(res_ty, @as(f128, @floatFromInt(val))), | 560 | .small => |val| try self.sema.pt.floatValue(res_ty, @as(f128, @floatFromInt(val))), |
| 561 | .big => |val| try self.sema.pt.floatValue(res_ty, val.toFloat(f128, .nearest_even)[0]), | 561 | .big => |val| try self.sema.pt.floatValue(res_ty, val.toFloat(f128, .nearest_even)[0]), |
| ... | @@ -592,7 +592,7 @@ fn lowerFloat( | ... | @@ -592,7 +592,7 @@ fn lowerFloat( |
| 592 | } | 592 | } |
| 593 | | 593 | |
| 594 | fn lowerNull(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { | 594 | fn lowerNull(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { |
| 595 | switch (node.get(self.file.zoir.?)) { | 595 | switch (node.get(&self.file.zoir.?)) { |
| 596 | .null => return .null_value, | 596 | .null => return .null_value, |
| 597 | else => return error.WrongType, | 597 | else => return error.WrongType, |
| 598 | } | 598 | } |
| ... | @@ -600,7 +600,7 @@ fn lowerNull(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { | ... | @@ -600,7 +600,7 @@ fn lowerNull(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { |
| 600 | | 600 | |
| 601 | fn lowerArray(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.Index { | 601 | fn lowerArray(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.Index { |
| 602 | const array_info = res_ty.arrayInfo(self.sema.pt.zcu); | 602 | const array_info = res_ty.arrayInfo(self.sema.pt.zcu); |
| 603 | const nodes: Zoir.Node.Index.Range = switch (node.get(self.file.zoir.?)) { | 603 | const nodes: Zoir.Node.Index.Range = switch (node.get(&self.file.zoir.?)) { |
| 604 | .array_literal => |nodes| nodes, | 604 | .array_literal => |nodes| nodes, |
| 605 | .empty_literal => .{ .start = node, .len = 0 }, | 605 | .empty_literal => .{ .start = node, .len = 0 }, |
| 606 | else => return error.WrongType, | 606 | else => return error.WrongType, |
| ... | @@ -633,13 +633,13 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I | ... | @@ -633,13 +633,13 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I |
| 633 | const io = comp.io; | 633 | const io = comp.io; |
| 634 | const ip = &pt.zcu.intern_pool; | 634 | const ip = &pt.zcu.intern_pool; |
| 635 | try self.sema.ensureLayoutResolved(res_ty, self.import_loc, .init); | 635 | try self.sema.ensureLayoutResolved(res_ty, self.import_loc, .init); |
| 636 | switch (node.get(self.file.zoir.?)) { | 636 | switch (node.get(&self.file.zoir.?)) { |
| 637 | .enum_literal => |field_name| { | 637 | .enum_literal => |field_name| { |
| 638 | const field_name_interned = try ip.getOrPutString( | 638 | const field_name_interned = try ip.getOrPutString( |
| 639 | gpa, | 639 | gpa, |
| 640 | io, | 640 | io, |
| 641 | self.sema.pt.tid, | 641 | self.sema.pt.tid, |
| 642 | field_name.get(self.file.zoir.?), | 642 | field_name.get(&self.file.zoir.?), |
| 643 | .no_embedded_nulls, | 643 | .no_embedded_nulls, |
| 644 | ); | 644 | ); |
| 645 | const field_index = res_ty.enumFieldIndex(field_name_interned, self.sema.pt.zcu) orelse { | 645 | const field_index = res_ty.enumFieldIndex(field_name_interned, self.sema.pt.zcu) orelse { |
| ... | @@ -648,7 +648,7 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I | ... | @@ -648,7 +648,7 @@ fn lowerEnum(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool.I |
| 648 | "enum {f} has no member named '{f}'", | 648 | "enum {f} has no member named '{f}'", |
| 649 | .{ | 649 | .{ |
| 650 | res_ty.fmt(self.sema.pt), | 650 | res_ty.fmt(self.sema.pt), |
| 651 | std.zig.fmtId(field_name.get(self.file.zoir.?)), | 651 | std.zig.fmtId(field_name.get(&self.file.zoir.?)), |
| 652 | }, | 652 | }, |
| 653 | ); | 653 | ); |
| 654 | }; | 654 | }; |
| ... | @@ -667,13 +667,13 @@ fn lowerEnumLiteral(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { | ... | @@ -667,13 +667,13 @@ fn lowerEnumLiteral(self: *LowerZon, node: Zoir.Node.Index) !InternPool.Index { |
| 667 | const gpa = comp.gpa; | 667 | const gpa = comp.gpa; |
| 668 | const io = comp.io; | 668 | const io = comp.io; |
| 669 | const ip = &pt.zcu.intern_pool; | 669 | const ip = &pt.zcu.intern_pool; |
| 670 | switch (node.get(self.file.zoir.?)) { | 670 | switch (node.get(&self.file.zoir.?)) { |
| 671 | .enum_literal => |field_name| { | 671 | .enum_literal => |field_name| { |
| 672 | const field_name_interned = try ip.getOrPutString( | 672 | const field_name_interned = try ip.getOrPutString( |
| 673 | gpa, | 673 | gpa, |
| 674 | io, | 674 | io, |
| 675 | self.sema.pt.tid, | 675 | self.sema.pt.tid, |
| 676 | field_name.get(self.file.zoir.?), | 676 | field_name.get(&self.file.zoir.?), |
| 677 | .no_embedded_nulls, | 677 | .no_embedded_nulls, |
| 678 | ); | 678 | ); |
| 679 | return self.sema.pt.intern(.{ .enum_literal = field_name_interned }); | 679 | return self.sema.pt.intern(.{ .enum_literal = field_name_interned }); |
| ... | @@ -696,7 +696,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -696,7 +696,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 696 | | 696 | |
| 697 | const tuple_info = ip.indexToKey(res_ty.toIntern()).tuple_type; | 697 | const tuple_info = ip.indexToKey(res_ty.toIntern()).tuple_type; |
| 698 | | 698 | |
| 699 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(self.file.zoir.?)) { | 699 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(&self.file.zoir.?)) { |
| 700 | .array_literal => |nodes| nodes, | 700 | .array_literal => |nodes| nodes, |
| 701 | .empty_literal => .{ .start = node, .len = 0 }, | 701 | .empty_literal => .{ .start = node, .len = 0 }, |
| 702 | else => return error.WrongType, | 702 | else => return error.WrongType, |
| ... | @@ -720,7 +720,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -720,7 +720,7 @@ fn lowerTuple(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 720 | "index {} outside tuple of length {}", | 720 | "index {} outside tuple of length {}", |
| 721 | .{ | 721 | .{ |
| 722 | elems.len, | 722 | elems.len, |
| 723 | elem_nodes.at(@intCast(i)).getAstNode(self.file.zoir.?), | 723 | elem_nodes.at(@intCast(i)).getAstNode(&self.file.zoir.?), |
| 724 | }, | 724 | }, |
| 725 | ); | 725 | ); |
| 726 | } | 726 | } |
| ... | @@ -760,7 +760,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool | ... | @@ -760,7 +760,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool |
| 760 | try self.sema.ensureStructDefaultsResolved(res_ty, self.import_loc); | 760 | try self.sema.ensureStructDefaultsResolved(res_ty, self.import_loc); |
| 761 | const struct_info = self.sema.pt.zcu.typeToStruct(res_ty).?; | 761 | const struct_info = self.sema.pt.zcu.typeToStruct(res_ty).?; |
| 762 | | 762 | |
| 763 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.file.zoir.?)) { | 763 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(&self.file.zoir.?)) { |
| 764 | .struct_literal => |fields| fields, | 764 | .struct_literal => |fields| fields, |
| 765 | .empty_literal => .{ .names = &.{}, .vals = .{ .start = node, .len = 0 } }, | 765 | .empty_literal => .{ .names = &.{}, .vals = .{ .start = node, .len = 0 } }, |
| 766 | else => return error.WrongType, | 766 | else => return error.WrongType, |
| ... | @@ -780,7 +780,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool | ... | @@ -780,7 +780,7 @@ fn lowerStruct(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool |
| 780 | gpa, | 780 | gpa, |
| 781 | io, | 781 | io, |
| 782 | self.sema.pt.tid, | 782 | self.sema.pt.tid, |
| 783 | fields.names[i].get(self.file.zoir.?), | 783 | fields.names[i].get(&self.file.zoir.?), |
| 784 | .no_embedded_nulls, | 784 | .no_embedded_nulls, |
| 785 | ); | 785 | ); |
| 786 | const field_node = fields.vals.at(@intCast(i)); | 786 | const field_node = fields.vals.at(@intCast(i)); |
| ... | @@ -844,7 +844,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -844,7 +844,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 844 | const string_alignment = ptr_info.flags.alignment == .none or ptr_info.flags.alignment == .@"1"; | 844 | const string_alignment = ptr_info.flags.alignment == .none or ptr_info.flags.alignment == .@"1"; |
| 845 | const string_sentinel = ptr_info.sentinel == .none or ptr_info.sentinel == .zero_u8; | 845 | const string_sentinel = ptr_info.sentinel == .none or ptr_info.sentinel == .zero_u8; |
| 846 | if (string_alignment and ptr_info.child == .u8_type and string_sentinel) { | 846 | if (string_alignment and ptr_info.child == .u8_type and string_sentinel) { |
| 847 | switch (node.get(self.file.zoir.?)) { | 847 | switch (node.get(&self.file.zoir.?)) { |
| 848 | .string_literal => |val| { | 848 | .string_literal => |val| { |
| 849 | const ip_str = try ip.getOrPutString(gpa, io, self.sema.pt.tid, val, .maybe_embedded_nulls); | 849 | const ip_str = try ip.getOrPutString(gpa, io, self.sema.pt.tid, val, .maybe_embedded_nulls); |
| 850 | const str_ref = try self.sema.addStrLit(ip_str, val.len); | 850 | const str_ref = try self.sema.addStrLit(ip_str, val.len); |
| ... | @@ -860,7 +860,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -860,7 +860,7 @@ fn lowerSlice(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 860 | } | 860 | } |
| 861 | | 861 | |
| 862 | // Slice literals | 862 | // Slice literals |
| 863 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(self.file.zoir.?)) { | 863 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(&self.file.zoir.?)) { |
| 864 | .array_literal => |nodes| nodes, | 864 | .array_literal => |nodes| nodes, |
| 865 | .empty_literal => .{ .start = node, .len = 0 }, | 865 | .empty_literal => .{ .start = node, .len = 0 }, |
| 866 | else => return error.WrongType, | 866 | else => return error.WrongType, |
| ... | @@ -927,19 +927,19 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -927,19 +927,19 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 927 | const union_info = pt.zcu.typeToUnion(res_ty).?; | 927 | const union_info = pt.zcu.typeToUnion(res_ty).?; |
| 928 | const enum_tag_info = ip.loadEnumType(union_info.enum_tag_type); | 928 | const enum_tag_info = ip.loadEnumType(union_info.enum_tag_type); |
| 929 | | 929 | |
| 930 | const field_name, const maybe_field_node = switch (node.get(self.file.zoir.?)) { | 930 | const field_name, const maybe_field_node = switch (node.get(&self.file.zoir.?)) { |
| 931 | .enum_literal => |name| b: { | 931 | .enum_literal => |name| b: { |
| 932 | const field_name = try ip.getOrPutString( | 932 | const field_name = try ip.getOrPutString( |
| 933 | gpa, | 933 | gpa, |
| 934 | io, | 934 | io, |
| 935 | self.sema.pt.tid, | 935 | self.sema.pt.tid, |
| 936 | name.get(self.file.zoir.?), | 936 | name.get(&self.file.zoir.?), |
| 937 | .no_embedded_nulls, | 937 | .no_embedded_nulls, |
| 938 | ); | 938 | ); |
| 939 | break :b .{ field_name, null }; | 939 | break :b .{ field_name, null }; |
| 940 | }, | 940 | }, |
| 941 | .struct_literal => b: { | 941 | .struct_literal => b: { |
| 942 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(self.file.zoir.?)) { | 942 | const fields: @FieldType(Zoir.Node, "struct_literal") = switch (node.get(&self.file.zoir.?)) { |
| 943 | .struct_literal => |fields| fields, | 943 | .struct_literal => |fields| fields, |
| 944 | else => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(self.sema.pt)}), | 944 | else => return self.fail(node, "expected type '{f}'", .{res_ty.fmt(self.sema.pt)}), |
| 945 | }; | 945 | }; |
| ... | @@ -950,7 +950,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. | ... | @@ -950,7 +950,7 @@ fn lowerUnion(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool. |
| 950 | gpa, | 950 | gpa, |
| 951 | io, | 951 | io, |
| 952 | self.sema.pt.tid, | 952 | self.sema.pt.tid, |
| 953 | fields.names[0].get(self.file.zoir.?), | 953 | fields.names[0].get(&self.file.zoir.?), |
| 954 | .no_embedded_nulls, | 954 | .no_embedded_nulls, |
| 955 | ); | 955 | ); |
| 956 | break :b .{ field_name, fields.vals.at(0) }; | 956 | break :b .{ field_name, fields.vals.at(0) }; |
| ... | @@ -986,7 +986,7 @@ fn lowerVector(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool | ... | @@ -986,7 +986,7 @@ fn lowerVector(self: *LowerZon, node: Zoir.Node.Index, res_ty: Type) !InternPool |
| 986 | | 986 | |
| 987 | const vector_info = ip.indexToKey(res_ty.toIntern()).vector_type; | 987 | const vector_info = ip.indexToKey(res_ty.toIntern()).vector_type; |
| 988 | | 988 | |
| 989 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(self.file.zoir.?)) { | 989 | const elem_nodes: Zoir.Node.Index.Range = switch (node.get(&self.file.zoir.?)) { |
| 990 | .array_literal => |nodes| nodes, | 990 | .array_literal => |nodes| nodes, |
| 991 | .empty_literal => .{ .start = node, .len = 0 }, | 991 | .empty_literal => .{ .start = node, .len = 0 }, |
| 992 | else => return error.WrongType, | 992 | else => return error.WrongType, |