| author | |
| committer | |
| log | 2549de80b226cddd0664ce4ad8c40887101f302b |
| tree | 9674c446649114e88339256b24ef00660e1a168b |
| parent | 7103088e4a51d4362e6665d5949a9677e18fb74a |
28 files changed, 299 insertions(+), 295 deletions(-)
src/Air.zig+1-1| ... | @@ -1043,7 +1043,7 @@ pub const Inst = struct { | ... | @@ -1043,7 +1043,7 @@ pub const Inst = struct { |
| 1043 | inferred_alloc: InferredAlloc, | 1043 | inferred_alloc: InferredAlloc, |
| 1044 | 1044 | ||
| 1045 | pub const InferredAllocComptime = struct { | 1045 | pub const InferredAllocComptime = struct { |
| 1046 | decl_index: Module.Decl.Index, | 1046 | decl_index: InternPool.DeclIndex, |
| 1047 | alignment: InternPool.Alignment, | 1047 | alignment: InternPool.Alignment, |
| 1048 | is_const: bool, | 1048 | is_const: bool, |
| 1049 | }; | 1049 | }; |
src/Compilation.zig+4-4| ... | @@ -254,19 +254,19 @@ pub const RcIncludes = enum { | ... | @@ -254,19 +254,19 @@ pub const RcIncludes = enum { |
| 254 | 254 | ||
| 255 | const Job = union(enum) { | 255 | const Job = union(enum) { |
| 256 | /// Write the constant value for a Decl to the output file. | 256 | /// Write the constant value for a Decl to the output file. |
| 257 | codegen_decl: Module.Decl.Index, | 257 | codegen_decl: InternPool.DeclIndex, |
| 258 | /// Write the machine code for a function to the output file. | 258 | /// Write the machine code for a function to the output file. |
| 259 | /// This will either be a non-generic `func_decl` or a `func_instance`. | 259 | /// This will either be a non-generic `func_decl` or a `func_instance`. |
| 260 | codegen_func: InternPool.Index, | 260 | codegen_func: InternPool.Index, |
| 261 | /// Render the .h file snippet for the Decl. | 261 | /// Render the .h file snippet for the Decl. |
| 262 | emit_h_decl: Module.Decl.Index, | 262 | emit_h_decl: InternPool.DeclIndex, |
| 263 | /// The Decl needs to be analyzed and possibly export itself. | 263 | /// The Decl needs to be analyzed and possibly export itself. |
| 264 | /// It may have already be analyzed, or it may have been determined | 264 | /// It may have already be analyzed, or it may have been determined |
| 265 | /// to be outdated; in this case perform semantic analysis again. | 265 | /// to be outdated; in this case perform semantic analysis again. |
| 266 | analyze_decl: Module.Decl.Index, | 266 | analyze_decl: InternPool.DeclIndex, |
| 267 | /// The source file containing the Decl has been updated, and so the | 267 | /// The source file containing the Decl has been updated, and so the |
| 268 | /// Decl may need its line number information updated in the debug info. | 268 | /// Decl may need its line number information updated in the debug info. |
| 269 | update_line_number: Module.Decl.Index, | 269 | update_line_number: InternPool.DeclIndex, |
| 270 | /// The main source file for the module needs to be analyzed. | 270 | /// The main source file for the module needs to be analyzed. |
| 271 | analyze_mod: *Package.Module, | 271 | analyze_mod: *Package.Module, |
| 272 | 272 |
src/InternPool.zig+106-63| ... | @@ -32,12 +32,12 @@ string_bytes: std.ArrayListUnmanaged(u8) = .{}, | ... | @@ -32,12 +32,12 @@ string_bytes: std.ArrayListUnmanaged(u8) = .{}, |
| 32 | /// multi-threaded contention on an atomic counter. | 32 | /// multi-threaded contention on an atomic counter. |
| 33 | allocated_decls: std.SegmentedList(Module.Decl, 0) = .{}, | 33 | allocated_decls: std.SegmentedList(Module.Decl, 0) = .{}, |
| 34 | /// When a Decl object is freed from `allocated_decls`, it is pushed into this stack. | 34 | /// When a Decl object is freed from `allocated_decls`, it is pushed into this stack. |
| 35 | decls_free_list: std.ArrayListUnmanaged(Module.Decl.Index) = .{}, | 35 | decls_free_list: std.ArrayListUnmanaged(DeclIndex) = .{}, |
| 36 | 36 | ||
| 37 | /// Same pattern as with `allocated_decls`. | 37 | /// Same pattern as with `allocated_decls`. |
| 38 | allocated_namespaces: std.SegmentedList(Module.Namespace, 0) = .{}, | 38 | allocated_namespaces: std.SegmentedList(Module.Namespace, 0) = .{}, |
| 39 | /// Same pattern as with `decls_free_list`. | 39 | /// Same pattern as with `decls_free_list`. |
| 40 | namespaces_free_list: std.ArrayListUnmanaged(Module.Namespace.Index) = .{}, | 40 | namespaces_free_list: std.ArrayListUnmanaged(NamespaceIndex) = .{}, |
| 41 | 41 | ||
| 42 | /// Some types such as enums, structs, and unions need to store mappings from field names | 42 | /// Some types such as enums, structs, and unions need to store mappings from field names |
| 43 | /// to field index, or value to field index. In such cases, they will store the underlying | 43 | /// to field index, or value to field index. In such cases, they will store the underlying |
| ... | @@ -68,7 +68,6 @@ const Hash = std.hash.Wyhash; | ... | @@ -68,7 +68,6 @@ const Hash = std.hash.Wyhash; |
| 68 | const InternPool = @This(); | 68 | const InternPool = @This(); |
| 69 | const Module = @import("Module.zig"); | 69 | const Module = @import("Module.zig"); |
| 70 | const Zir = @import("Zir.zig"); | 70 | const Zir = @import("Zir.zig"); |
| 71 | const Sema = @import("Sema.zig"); | ||
| 72 | 71 | ||
| 73 | const KeyAdapter = struct { | 72 | const KeyAdapter = struct { |
| 74 | intern_pool: *const InternPool, | 73 | intern_pool: *const InternPool, |
| ... | @@ -113,6 +112,50 @@ pub const RuntimeIndex = enum(u32) { | ... | @@ -113,6 +112,50 @@ pub const RuntimeIndex = enum(u32) { |
| 113 | } | 112 | } |
| 114 | }; | 113 | }; |
| 115 | 114 | ||
| 115 | pub const DeclIndex = enum(u32) { | ||
| 116 | _, | ||
| 117 | |||
| 118 | pub fn toOptional(i: DeclIndex) OptionalDeclIndex { | ||
| 119 | return @enumFromInt(@intFromEnum(i)); | ||
| 120 | } | ||
| 121 | }; | ||
| 122 | |||
| 123 | pub const OptionalDeclIndex = enum(u32) { | ||
| 124 | none = std.math.maxInt(u32), | ||
| 125 | _, | ||
| 126 | |||
| 127 | pub fn init(oi: ?DeclIndex) OptionalDeclIndex { | ||
| 128 | return @enumFromInt(@intFromEnum(oi orelse return .none)); | ||
| 129 | } | ||
| 130 | |||
| 131 | pub fn unwrap(oi: OptionalDeclIndex) ?DeclIndex { | ||
| 132 | if (oi == .none) return null; | ||
| 133 | return @enumFromInt(@intFromEnum(oi)); | ||
| 134 | } | ||
| 135 | }; | ||
| 136 | |||
| 137 | pub const NamespaceIndex = enum(u32) { | ||
| 138 | _, | ||
| 139 | |||
| 140 | pub fn toOptional(i: NamespaceIndex) OptionalNamespaceIndex { | ||
| 141 | return @enumFromInt(@intFromEnum(i)); | ||
| 142 | } | ||
| 143 | }; | ||
| 144 | |||
| 145 | pub const OptionalNamespaceIndex = enum(u32) { | ||
| 146 | none = std.math.maxInt(u32), | ||
| 147 | _, | ||
| 148 | |||
| 149 | pub fn init(oi: ?NamespaceIndex) OptionalNamespaceIndex { | ||
| 150 | return @enumFromInt(@intFromEnum(oi orelse return .none)); | ||
| 151 | } | ||
| 152 | |||
| 153 | pub fn unwrap(oi: OptionalNamespaceIndex) ?NamespaceIndex { | ||
| 154 | if (oi == .none) return null; | ||
| 155 | return @enumFromInt(@intFromEnum(oi)); | ||
| 156 | } | ||
| 157 | }; | ||
| 158 | |||
| 116 | /// An index into `string_bytes`. | 159 | /// An index into `string_bytes`. |
| 117 | pub const String = enum(u32) { | 160 | pub const String = enum(u32) { |
| 118 | _, | 161 | _, |
| ... | @@ -351,9 +394,9 @@ pub const Key = union(enum) { | ... | @@ -351,9 +394,9 @@ pub const Key = union(enum) { |
| 351 | 394 | ||
| 352 | pub const OpaqueType = extern struct { | 395 | pub const OpaqueType = extern struct { |
| 353 | /// The Decl that corresponds to the opaque itself. | 396 | /// The Decl that corresponds to the opaque itself. |
| 354 | decl: Module.Decl.Index, | 397 | decl: DeclIndex, |
| 355 | /// Represents the declarations inside this opaque. | 398 | /// Represents the declarations inside this opaque. |
| 356 | namespace: Module.Namespace.Index, | 399 | namespace: NamespaceIndex, |
| 357 | }; | 400 | }; |
| 358 | 401 | ||
| 359 | /// Although packed structs and non-packed structs are encoded differently, | 402 | /// Although packed structs and non-packed structs are encoded differently, |
| ... | @@ -362,9 +405,9 @@ pub const Key = union(enum) { | ... | @@ -362,9 +405,9 @@ pub const Key = union(enum) { |
| 362 | pub const StructType = struct { | 405 | pub const StructType = struct { |
| 363 | extra_index: u32, | 406 | extra_index: u32, |
| 364 | /// `none` when the struct is `@TypeOf(.{})`. | 407 | /// `none` when the struct is `@TypeOf(.{})`. |
| 365 | decl: Module.Decl.OptionalIndex, | 408 | decl: OptionalDeclIndex, |
| 366 | /// `none` when the struct has no declarations. | 409 | /// `none` when the struct has no declarations. |
| 367 | namespace: Module.Namespace.OptionalIndex, | 410 | namespace: OptionalNamespaceIndex, |
| 368 | /// Index of the struct_decl ZIR instruction. | 411 | /// Index of the struct_decl ZIR instruction. |
| 369 | zir_index: Zir.Inst.Index, | 412 | zir_index: Zir.Inst.Index, |
| 370 | layout: std.builtin.Type.ContainerLayout, | 413 | layout: std.builtin.Type.ContainerLayout, |
| ... | @@ -718,11 +761,11 @@ pub const Key = union(enum) { | ... | @@ -718,11 +761,11 @@ pub const Key = union(enum) { |
| 718 | /// * Provide the other fields that do not require chasing the enum type. | 761 | /// * Provide the other fields that do not require chasing the enum type. |
| 719 | pub const UnionType = struct { | 762 | pub const UnionType = struct { |
| 720 | /// The Decl that corresponds to the union itself. | 763 | /// The Decl that corresponds to the union itself. |
| 721 | decl: Module.Decl.Index, | 764 | decl: DeclIndex, |
| 722 | /// The index of the `Tag.TypeUnion` payload. Ignored by `get`, | 765 | /// The index of the `Tag.TypeUnion` payload. Ignored by `get`, |
| 723 | /// populated by `indexToKey`. | 766 | /// populated by `indexToKey`. |
| 724 | extra_index: u32, | 767 | extra_index: u32, |
| 725 | namespace: Module.Namespace.Index, | 768 | namespace: NamespaceIndex, |
| 726 | flags: Tag.TypeUnion.Flags, | 769 | flags: Tag.TypeUnion.Flags, |
| 727 | /// The enum that provides the list of field names and values. | 770 | /// The enum that provides the list of field names and values. |
| 728 | enum_tag_ty: Index, | 771 | enum_tag_ty: Index, |
| ... | @@ -796,9 +839,9 @@ pub const Key = union(enum) { | ... | @@ -796,9 +839,9 @@ pub const Key = union(enum) { |
| 796 | 839 | ||
| 797 | pub const EnumType = struct { | 840 | pub const EnumType = struct { |
| 798 | /// The Decl that corresponds to the enum itself. | 841 | /// The Decl that corresponds to the enum itself. |
| 799 | decl: Module.Decl.Index, | 842 | decl: DeclIndex, |
| 800 | /// Represents the declarations inside this enum. | 843 | /// Represents the declarations inside this enum. |
| 801 | namespace: Module.Namespace.OptionalIndex, | 844 | namespace: OptionalNamespaceIndex, |
| 802 | /// An integer type which is used for the numerical value of the enum. | 845 | /// An integer type which is used for the numerical value of the enum. |
| 803 | /// This field is present regardless of whether the enum has an | 846 | /// This field is present regardless of whether the enum has an |
| 804 | /// explicitly provided tag type or auto-numbered. | 847 | /// explicitly provided tag type or auto-numbered. |
| ... | @@ -866,9 +909,9 @@ pub const Key = union(enum) { | ... | @@ -866,9 +909,9 @@ pub const Key = union(enum) { |
| 866 | 909 | ||
| 867 | pub const IncompleteEnumType = struct { | 910 | pub const IncompleteEnumType = struct { |
| 868 | /// Same as corresponding `EnumType` field. | 911 | /// Same as corresponding `EnumType` field. |
| 869 | decl: Module.Decl.Index, | 912 | decl: DeclIndex, |
| 870 | /// Same as corresponding `EnumType` field. | 913 | /// Same as corresponding `EnumType` field. |
| 871 | namespace: Module.Namespace.OptionalIndex, | 914 | namespace: OptionalNamespaceIndex, |
| 872 | /// The field names and field values are not known yet, but | 915 | /// The field names and field values are not known yet, but |
| 873 | /// the number of fields must be known ahead of time. | 916 | /// the number of fields must be known ahead of time. |
| 874 | fields_len: u32, | 917 | fields_len: u32, |
| ... | @@ -961,7 +1004,7 @@ pub const Key = union(enum) { | ... | @@ -961,7 +1004,7 @@ pub const Key = union(enum) { |
| 961 | pub const Variable = struct { | 1004 | pub const Variable = struct { |
| 962 | ty: Index, | 1005 | ty: Index, |
| 963 | init: Index, | 1006 | init: Index, |
| 964 | decl: Module.Decl.Index, | 1007 | decl: DeclIndex, |
| 965 | lib_name: OptionalNullTerminatedString = .none, | 1008 | lib_name: OptionalNullTerminatedString = .none, |
| 966 | is_extern: bool = false, | 1009 | is_extern: bool = false, |
| 967 | is_const: bool = false, | 1010 | is_const: bool = false, |
| ... | @@ -972,7 +1015,7 @@ pub const Key = union(enum) { | ... | @@ -972,7 +1015,7 @@ pub const Key = union(enum) { |
| 972 | pub const ExternFunc = struct { | 1015 | pub const ExternFunc = struct { |
| 973 | ty: Index, | 1016 | ty: Index, |
| 974 | /// The Decl that corresponds to the function itself. | 1017 | /// The Decl that corresponds to the function itself. |
| 975 | decl: Module.Decl.Index, | 1018 | decl: DeclIndex, |
| 976 | /// Library name if specified. | 1019 | /// Library name if specified. |
| 977 | /// For example `extern "c" fn write(...) usize` would have 'c' as library name. | 1020 | /// For example `extern "c" fn write(...) usize` would have 'c' as library name. |
| 978 | /// Index into the string table bytes. | 1021 | /// Index into the string table bytes. |
| ... | @@ -1008,7 +1051,7 @@ pub const Key = union(enum) { | ... | @@ -1008,7 +1051,7 @@ pub const Key = union(enum) { |
| 1008 | /// This will be 0 when the function is not a generic function instantiation. | 1051 | /// This will be 0 when the function is not a generic function instantiation. |
| 1009 | branch_quota_extra_index: u32, | 1052 | branch_quota_extra_index: u32, |
| 1010 | /// The Decl that corresponds to the function itself. | 1053 | /// The Decl that corresponds to the function itself. |
| 1011 | owner_decl: Module.Decl.Index, | 1054 | owner_decl: DeclIndex, |
| 1012 | /// The ZIR instruction that is a function instruction. Use this to find | 1055 | /// The ZIR instruction that is a function instruction. Use this to find |
| 1013 | /// the body. We store this rather than the body directly so that when ZIR | 1056 | /// the body. We store this rather than the body directly so that when ZIR |
| 1014 | /// is regenerated on update(), we can map this to the new corresponding | 1057 | /// is regenerated on update(), we can map this to the new corresponding |
| ... | @@ -1130,7 +1173,7 @@ pub const Key = union(enum) { | ... | @@ -1130,7 +1173,7 @@ pub const Key = union(enum) { |
| 1130 | pub const Addr = union(enum) { | 1173 | pub const Addr = union(enum) { |
| 1131 | const Tag = @typeInfo(Addr).Union.tag_type.?; | 1174 | const Tag = @typeInfo(Addr).Union.tag_type.?; |
| 1132 | 1175 | ||
| 1133 | decl: Module.Decl.Index, | 1176 | decl: DeclIndex, |
| 1134 | mut_decl: MutDecl, | 1177 | mut_decl: MutDecl, |
| 1135 | anon_decl: AnonDecl, | 1178 | anon_decl: AnonDecl, |
| 1136 | comptime_field: Index, | 1179 | comptime_field: Index, |
| ... | @@ -1141,7 +1184,7 @@ pub const Key = union(enum) { | ... | @@ -1141,7 +1184,7 @@ pub const Key = union(enum) { |
| 1141 | field: BaseIndex, | 1184 | field: BaseIndex, |
| 1142 | 1185 | ||
| 1143 | pub const MutDecl = struct { | 1186 | pub const MutDecl = struct { |
| 1144 | decl: Module.Decl.Index, | 1187 | decl: DeclIndex, |
| 1145 | runtime_index: RuntimeIndex, | 1188 | runtime_index: RuntimeIndex, |
| 1146 | }; | 1189 | }; |
| 1147 | pub const BaseIndex = struct { | 1190 | pub const BaseIndex = struct { |
| ... | @@ -1796,9 +1839,9 @@ pub const RequiresComptime = enum(u2) { no, yes, unknown, wip }; | ... | @@ -1796,9 +1839,9 @@ pub const RequiresComptime = enum(u2) { no, yes, unknown, wip }; |
| 1796 | // needed by semantic analysis. | 1839 | // needed by semantic analysis. |
| 1797 | pub const UnionType = struct { | 1840 | pub const UnionType = struct { |
| 1798 | /// The Decl that corresponds to the union itself. | 1841 | /// The Decl that corresponds to the union itself. |
| 1799 | decl: Module.Decl.Index, | 1842 | decl: DeclIndex, |
| 1800 | /// Represents the declarations inside this union. | 1843 | /// Represents the declarations inside this union. |
| 1801 | namespace: Module.Namespace.Index, | 1844 | namespace: NamespaceIndex, |
| 1802 | /// The enum tag type. | 1845 | /// The enum tag type. |
| 1803 | enum_tag_ty: Index, | 1846 | enum_tag_ty: Index, |
| 1804 | /// The integer tag type of the enum. | 1847 | /// The integer tag type of the enum. |
| ... | @@ -2168,7 +2211,7 @@ pub const Index = enum(u32) { | ... | @@ -2168,7 +2211,7 @@ pub const Index = enum(u32) { |
| 2168 | simple_type: struct { data: SimpleType }, | 2211 | simple_type: struct { data: SimpleType }, |
| 2169 | type_opaque: struct { data: *Key.OpaqueType }, | 2212 | type_opaque: struct { data: *Key.OpaqueType }, |
| 2170 | type_struct: struct { data: *Tag.TypeStruct }, | 2213 | type_struct: struct { data: *Tag.TypeStruct }, |
| 2171 | type_struct_ns: struct { data: Module.Namespace.Index }, | 2214 | type_struct_ns: struct { data: NamespaceIndex }, |
| 2172 | type_struct_anon: DataIsExtraIndexOfTypeStructAnon, | 2215 | type_struct_anon: DataIsExtraIndexOfTypeStructAnon, |
| 2173 | type_struct_packed: struct { data: *Tag.TypeStructPacked }, | 2216 | type_struct_packed: struct { data: *Tag.TypeStructPacked }, |
| 2174 | type_struct_packed_inits: struct { data: *Tag.TypeStructPacked }, | 2217 | type_struct_packed_inits: struct { data: *Tag.TypeStructPacked }, |
| ... | @@ -2609,7 +2652,7 @@ pub const Tag = enum(u8) { | ... | @@ -2609,7 +2652,7 @@ pub const Tag = enum(u8) { |
| 2609 | /// data == 0 represents `@TypeOf(.{})`. | 2652 | /// data == 0 represents `@TypeOf(.{})`. |
| 2610 | type_struct, | 2653 | type_struct, |
| 2611 | /// A non-packed struct type that has only a namespace; no fields. | 2654 | /// A non-packed struct type that has only a namespace; no fields. |
| 2612 | /// data is Module.Namespace.Index. | 2655 | /// data is NamespaceIndex. |
| 2613 | type_struct_ns, | 2656 | type_struct_ns, |
| 2614 | /// An AnonStructType which stores types, names, and values for fields. | 2657 | /// An AnonStructType which stores types, names, and values for fields. |
| 2615 | /// data is extra index of `TypeStructAnon`. | 2658 | /// data is extra index of `TypeStructAnon`. |
| ... | @@ -2902,7 +2945,7 @@ pub const Tag = enum(u8) { | ... | @@ -2902,7 +2945,7 @@ pub const Tag = enum(u8) { |
| 2902 | ty: Index, | 2945 | ty: Index, |
| 2903 | /// May be `none`. | 2946 | /// May be `none`. |
| 2904 | init: Index, | 2947 | init: Index, |
| 2905 | decl: Module.Decl.Index, | 2948 | decl: DeclIndex, |
| 2906 | /// Library name if specified. | 2949 | /// Library name if specified. |
| 2907 | /// For example `extern "c" var stderrp = ...` would have 'c' as library name. | 2950 | /// For example `extern "c" var stderrp = ...` would have 'c' as library name. |
| 2908 | lib_name: OptionalNullTerminatedString, | 2951 | lib_name: OptionalNullTerminatedString, |
| ... | @@ -2931,7 +2974,7 @@ pub const Tag = enum(u8) { | ... | @@ -2931,7 +2974,7 @@ pub const Tag = enum(u8) { |
| 2931 | /// A `none` value marks that the inferred error set is not resolved yet. | 2974 | /// A `none` value marks that the inferred error set is not resolved yet. |
| 2932 | pub const FuncDecl = struct { | 2975 | pub const FuncDecl = struct { |
| 2933 | analysis: FuncAnalysis, | 2976 | analysis: FuncAnalysis, |
| 2934 | owner_decl: Module.Decl.Index, | 2977 | owner_decl: DeclIndex, |
| 2935 | ty: Index, | 2978 | ty: Index, |
| 2936 | zir_body_inst: Zir.Inst.Index, | 2979 | zir_body_inst: Zir.Inst.Index, |
| 2937 | lbrace_line: u32, | 2980 | lbrace_line: u32, |
| ... | @@ -2948,7 +2991,7 @@ pub const Tag = enum(u8) { | ... | @@ -2948,7 +2991,7 @@ pub const Tag = enum(u8) { |
| 2948 | pub const FuncInstance = struct { | 2991 | pub const FuncInstance = struct { |
| 2949 | analysis: FuncAnalysis, | 2992 | analysis: FuncAnalysis, |
| 2950 | // Needed by the linker for codegen. Not part of hashing or equality. | 2993 | // Needed by the linker for codegen. Not part of hashing or equality. |
| 2951 | owner_decl: Module.Decl.Index, | 2994 | owner_decl: DeclIndex, |
| 2952 | ty: Index, | 2995 | ty: Index, |
| 2953 | branch_quota: u32, | 2996 | branch_quota: u32, |
| 2954 | /// Points to a `FuncDecl`. | 2997 | /// Points to a `FuncDecl`. |
| ... | @@ -3003,8 +3046,8 @@ pub const Tag = enum(u8) { | ... | @@ -3003,8 +3046,8 @@ pub const Tag = enum(u8) { |
| 3003 | size: u32, | 3046 | size: u32, |
| 3004 | /// Only valid after .have_layout | 3047 | /// Only valid after .have_layout |
| 3005 | padding: u32, | 3048 | padding: u32, |
| 3006 | decl: Module.Decl.Index, | 3049 | decl: DeclIndex, |
| 3007 | namespace: Module.Namespace.Index, | 3050 | namespace: NamespaceIndex, |
| 3008 | /// The enum that provides the list of field names and values. | 3051 | /// The enum that provides the list of field names and values. |
| 3009 | tag_ty: Index, | 3052 | tag_ty: Index, |
| 3010 | zir_index: Zir.Inst.Index, | 3053 | zir_index: Zir.Inst.Index, |
| ... | @@ -3028,10 +3071,10 @@ pub const Tag = enum(u8) { | ... | @@ -3028,10 +3071,10 @@ pub const Tag = enum(u8) { |
| 3028 | /// 1. name: NullTerminatedString for each fields_len | 3071 | /// 1. name: NullTerminatedString for each fields_len |
| 3029 | /// 2. init: Index for each fields_len // if tag is type_struct_packed_inits | 3072 | /// 2. init: Index for each fields_len // if tag is type_struct_packed_inits |
| 3030 | pub const TypeStructPacked = struct { | 3073 | pub const TypeStructPacked = struct { |
| 3031 | decl: Module.Decl.Index, | 3074 | decl: DeclIndex, |
| 3032 | zir_index: Zir.Inst.Index, | 3075 | zir_index: Zir.Inst.Index, |
| 3033 | fields_len: u32, | 3076 | fields_len: u32, |
| 3034 | namespace: Module.Namespace.OptionalIndex, | 3077 | namespace: OptionalNamespaceIndex, |
| 3035 | backing_int_ty: Index, | 3078 | backing_int_ty: Index, |
| 3036 | names_map: MapIndex, | 3079 | names_map: MapIndex, |
| 3037 | flags: Flags, | 3080 | flags: Flags, |
| ... | @@ -3066,7 +3109,7 @@ pub const Tag = enum(u8) { | ... | @@ -3066,7 +3109,7 @@ pub const Tag = enum(u8) { |
| 3066 | /// 2. if any_default_inits: | 3109 | /// 2. if any_default_inits: |
| 3067 | /// init: Index // for each field in declared order | 3110 | /// init: Index // for each field in declared order |
| 3068 | /// 3. if has_namespace: | 3111 | /// 3. if has_namespace: |
| 3069 | /// namespace: Module.Namespace.Index | 3112 | /// namespace: NamespaceIndex |
| 3070 | /// 4. if any_aligned_fields: | 3113 | /// 4. if any_aligned_fields: |
| 3071 | /// align: Alignment // for each field in declared order | 3114 | /// align: Alignment // for each field in declared order |
| 3072 | /// 5. if any_comptime_fields: | 3115 | /// 5. if any_comptime_fields: |
| ... | @@ -3075,7 +3118,7 @@ pub const Tag = enum(u8) { | ... | @@ -3075,7 +3118,7 @@ pub const Tag = enum(u8) { |
| 3075 | /// field_index: RuntimeOrder // for each field in runtime order | 3118 | /// field_index: RuntimeOrder // for each field in runtime order |
| 3076 | /// 7. field_offset: u32 // for each field in declared order, undef until layout_resolved | 3119 | /// 7. field_offset: u32 // for each field in declared order, undef until layout_resolved |
| 3077 | pub const TypeStruct = struct { | 3120 | pub const TypeStruct = struct { |
| 3078 | decl: Module.Decl.Index, | 3121 | decl: DeclIndex, |
| 3079 | zir_index: Zir.Inst.Index, | 3122 | zir_index: Zir.Inst.Index, |
| 3080 | fields_len: u32, | 3123 | fields_len: u32, |
| 3081 | flags: Flags, | 3124 | flags: Flags, |
| ... | @@ -3418,9 +3461,9 @@ pub const Array = struct { | ... | @@ -3418,9 +3461,9 @@ pub const Array = struct { |
| 3418 | /// 1. tag value: Index for each fields_len; declaration order | 3461 | /// 1. tag value: Index for each fields_len; declaration order |
| 3419 | pub const EnumExplicit = struct { | 3462 | pub const EnumExplicit = struct { |
| 3420 | /// The Decl that corresponds to the enum itself. | 3463 | /// The Decl that corresponds to the enum itself. |
| 3421 | decl: Module.Decl.Index, | 3464 | decl: DeclIndex, |
| 3422 | /// This may be `none` if there are no declarations. | 3465 | /// This may be `none` if there are no declarations. |
| 3423 | namespace: Module.Namespace.OptionalIndex, | 3466 | namespace: OptionalNamespaceIndex, |
| 3424 | /// An integer type which is used for the numerical value of the enum, which | 3467 | /// An integer type which is used for the numerical value of the enum, which |
| 3425 | /// has been explicitly provided by the enum declaration. | 3468 | /// has been explicitly provided by the enum declaration. |
| 3426 | int_tag_type: Index, | 3469 | int_tag_type: Index, |
| ... | @@ -3437,9 +3480,9 @@ pub const EnumExplicit = struct { | ... | @@ -3437,9 +3480,9 @@ pub const EnumExplicit = struct { |
| 3437 | /// 0. field name: NullTerminatedString for each fields_len; declaration order | 3480 | /// 0. field name: NullTerminatedString for each fields_len; declaration order |
| 3438 | pub const EnumAuto = struct { | 3481 | pub const EnumAuto = struct { |
| 3439 | /// The Decl that corresponds to the enum itself. | 3482 | /// The Decl that corresponds to the enum itself. |
| 3440 | decl: Module.Decl.Index, | 3483 | decl: DeclIndex, |
| 3441 | /// This may be `none` if there are no declarations. | 3484 | /// This may be `none` if there are no declarations. |
| 3442 | namespace: Module.Namespace.OptionalIndex, | 3485 | namespace: OptionalNamespaceIndex, |
| 3443 | /// An integer type which is used for the numerical value of the enum, which | 3486 | /// An integer type which is used for the numerical value of the enum, which |
| 3444 | /// was inferred by Zig based on the number of tags. | 3487 | /// was inferred by Zig based on the number of tags. |
| 3445 | int_tag_type: Index, | 3488 | int_tag_type: Index, |
| ... | @@ -3463,7 +3506,7 @@ pub const PackedU64 = packed struct(u64) { | ... | @@ -3463,7 +3506,7 @@ pub const PackedU64 = packed struct(u64) { |
| 3463 | 3506 | ||
| 3464 | pub const PtrDecl = struct { | 3507 | pub const PtrDecl = struct { |
| 3465 | ty: Index, | 3508 | ty: Index, |
| 3466 | decl: Module.Decl.Index, | 3509 | decl: DeclIndex, |
| 3467 | }; | 3510 | }; |
| 3468 | 3511 | ||
| 3469 | pub const PtrAnonDecl = struct { | 3512 | pub const PtrAnonDecl = struct { |
| ... | @@ -3480,7 +3523,7 @@ pub const PtrAnonDeclAligned = struct { | ... | @@ -3480,7 +3523,7 @@ pub const PtrAnonDeclAligned = struct { |
| 3480 | 3523 | ||
| 3481 | pub const PtrMutDecl = struct { | 3524 | pub const PtrMutDecl = struct { |
| 3482 | ty: Index, | 3525 | ty: Index, |
| 3483 | decl: Module.Decl.Index, | 3526 | decl: DeclIndex, |
| 3484 | runtime_index: RuntimeIndex, | 3527 | runtime_index: RuntimeIndex, |
| 3485 | }; | 3528 | }; |
| 3486 | 3529 | ||
| ... | @@ -3754,7 +3797,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { | ... | @@ -3754,7 +3797,7 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 3754 | 3797 | ||
| 3755 | .type_struct_ns => .{ .struct_type = .{ | 3798 | .type_struct_ns => .{ .struct_type = .{ |
| 3756 | .extra_index = 0, | 3799 | .extra_index = 0, |
| 3757 | .namespace = @as(Module.Namespace.Index, @enumFromInt(data)).toOptional(), | 3800 | .namespace = @as(NamespaceIndex, @enumFromInt(data)).toOptional(), |
| 3758 | .decl = .none, | 3801 | .decl = .none, |
| 3759 | .zir_index = undefined, | 3802 | .zir_index = undefined, |
| 3760 | .layout = .Auto, | 3803 | .layout = .Auto, |
| ... | @@ -4280,7 +4323,7 @@ fn extraStructType(ip: *const InternPool, extra_index: u32) Key.StructType { | ... | @@ -4280,7 +4323,7 @@ fn extraStructType(ip: *const InternPool, extra_index: u32) Key.StructType { |
| 4280 | }; | 4323 | }; |
| 4281 | const namespace = t: { | 4324 | const namespace = t: { |
| 4282 | if (!s.data.flags.has_namespace) break :t .none; | 4325 | if (!s.data.flags.has_namespace) break :t .none; |
| 4283 | const namespace: Module.Namespace.Index = @enumFromInt(ip.extra.items[index]); | 4326 | const namespace: NamespaceIndex = @enumFromInt(ip.extra.items[index]); |
| 4284 | index += 1; | 4327 | index += 1; |
| 4285 | break :t namespace.toOptional(); | 4328 | break :t namespace.toOptional(); |
| 4286 | }; | 4329 | }; |
| ... | @@ -5313,8 +5356,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { | ... | @@ -5313,8 +5356,8 @@ pub fn get(ip: *InternPool, gpa: Allocator, key: Key) Allocator.Error!Index { |
| 5313 | 5356 | ||
| 5314 | pub const UnionTypeInit = struct { | 5357 | pub const UnionTypeInit = struct { |
| 5315 | flags: Tag.TypeUnion.Flags, | 5358 | flags: Tag.TypeUnion.Flags, |
| 5316 | decl: Module.Decl.Index, | 5359 | decl: DeclIndex, |
| 5317 | namespace: Module.Namespace.Index, | 5360 | namespace: NamespaceIndex, |
| 5318 | zir_index: Zir.Inst.Index, | 5361 | zir_index: Zir.Inst.Index, |
| 5319 | fields_len: u32, | 5362 | fields_len: u32, |
| 5320 | enum_tag_ty: Index, | 5363 | enum_tag_ty: Index, |
| ... | @@ -5384,8 +5427,8 @@ pub fn getUnionType(ip: *InternPool, gpa: Allocator, ini: UnionTypeInit) Allocat | ... | @@ -5384,8 +5427,8 @@ pub fn getUnionType(ip: *InternPool, gpa: Allocator, ini: UnionTypeInit) Allocat |
| 5384 | } | 5427 | } |
| 5385 | 5428 | ||
| 5386 | pub const StructTypeInit = struct { | 5429 | pub const StructTypeInit = struct { |
| 5387 | decl: Module.Decl.Index, | 5430 | decl: DeclIndex, |
| 5388 | namespace: Module.Namespace.OptionalIndex, | 5431 | namespace: OptionalNamespaceIndex, |
| 5389 | layout: std.builtin.Type.ContainerLayout, | 5432 | layout: std.builtin.Type.ContainerLayout, |
| 5390 | zir_index: Zir.Inst.Index, | 5433 | zir_index: Zir.Inst.Index, |
| 5391 | fields_len: u32, | 5434 | fields_len: u32, |
| ... | @@ -5659,7 +5702,7 @@ pub fn getExternFunc(ip: *InternPool, gpa: Allocator, key: Key.ExternFunc) Alloc | ... | @@ -5659,7 +5702,7 @@ pub fn getExternFunc(ip: *InternPool, gpa: Allocator, key: Key.ExternFunc) Alloc |
| 5659 | } | 5702 | } |
| 5660 | 5703 | ||
| 5661 | pub const GetFuncDeclKey = struct { | 5704 | pub const GetFuncDeclKey = struct { |
| 5662 | owner_decl: Module.Decl.Index, | 5705 | owner_decl: DeclIndex, |
| 5663 | ty: Index, | 5706 | ty: Index, |
| 5664 | zir_body_inst: Zir.Inst.Index, | 5707 | zir_body_inst: Zir.Inst.Index, |
| 5665 | lbrace_line: u32, | 5708 | lbrace_line: u32, |
| ... | @@ -5716,7 +5759,7 @@ pub fn getFuncDecl(ip: *InternPool, gpa: Allocator, key: GetFuncDeclKey) Allocat | ... | @@ -5716,7 +5759,7 @@ pub fn getFuncDecl(ip: *InternPool, gpa: Allocator, key: GetFuncDeclKey) Allocat |
| 5716 | } | 5759 | } |
| 5717 | 5760 | ||
| 5718 | pub const GetFuncDeclIesKey = struct { | 5761 | pub const GetFuncDeclIesKey = struct { |
| 5719 | owner_decl: Module.Decl.Index, | 5762 | owner_decl: DeclIndex, |
| 5720 | param_types: []Index, | 5763 | param_types: []Index, |
| 5721 | noalias_bits: u32, | 5764 | noalias_bits: u32, |
| 5722 | comptime_bits: u32, | 5765 | comptime_bits: u32, |
| ... | @@ -6321,8 +6364,8 @@ fn getIncompleteEnumExplicit( | ... | @@ -6321,8 +6364,8 @@ fn getIncompleteEnumExplicit( |
| 6321 | } | 6364 | } |
| 6322 | 6365 | ||
| 6323 | pub const GetEnumInit = struct { | 6366 | pub const GetEnumInit = struct { |
| 6324 | decl: Module.Decl.Index, | 6367 | decl: DeclIndex, |
| 6325 | namespace: Module.Namespace.OptionalIndex, | 6368 | namespace: OptionalNamespaceIndex, |
| 6326 | tag_ty: Index, | 6369 | tag_ty: Index, |
| 6327 | names: []const NullTerminatedString, | 6370 | names: []const NullTerminatedString, |
| 6328 | values: []const Index, | 6371 | values: []const Index, |
| ... | @@ -6484,9 +6527,9 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { | ... | @@ -6484,9 +6527,9 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { |
| 6484 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { | 6527 | inline for (@typeInfo(@TypeOf(extra)).Struct.fields) |field| { |
| 6485 | ip.extra.appendAssumeCapacity(switch (field.type) { | 6528 | ip.extra.appendAssumeCapacity(switch (field.type) { |
| 6486 | Index, | 6529 | Index, |
| 6487 | Module.Decl.Index, | 6530 | DeclIndex, |
| 6488 | Module.Namespace.Index, | 6531 | NamespaceIndex, |
| 6489 | Module.Namespace.OptionalIndex, | 6532 | OptionalNamespaceIndex, |
| 6490 | MapIndex, | 6533 | MapIndex, |
| 6491 | OptionalMapIndex, | 6534 | OptionalMapIndex, |
| 6492 | RuntimeIndex, | 6535 | RuntimeIndex, |
| ... | @@ -6560,9 +6603,9 @@ fn extraDataTrail(ip: *const InternPool, comptime T: type, index: usize) struct | ... | @@ -6560,9 +6603,9 @@ fn extraDataTrail(ip: *const InternPool, comptime T: type, index: usize) struct |
| 6560 | const int32 = ip.extra.items[i + index]; | 6603 | const int32 = ip.extra.items[i + index]; |
| 6561 | @field(result, field.name) = switch (field.type) { | 6604 | @field(result, field.name) = switch (field.type) { |
| 6562 | Index, | 6605 | Index, |
| 6563 | Module.Decl.Index, | 6606 | DeclIndex, |
| 6564 | Module.Namespace.Index, | 6607 | NamespaceIndex, |
| 6565 | Module.Namespace.OptionalIndex, | 6608 | OptionalNamespaceIndex, |
| 6566 | MapIndex, | 6609 | MapIndex, |
| 6567 | OptionalMapIndex, | 6610 | OptionalMapIndex, |
| 6568 | RuntimeIndex, | 6611 | RuntimeIndex, |
| ... | @@ -7554,15 +7597,15 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) | ... | @@ -7554,15 +7597,15 @@ pub fn dumpGenericInstancesFallible(ip: *const InternPool, allocator: Allocator) |
| 7554 | try bw.flush(); | 7597 | try bw.flush(); |
| 7555 | } | 7598 | } |
| 7556 | 7599 | ||
| 7557 | pub fn declPtr(ip: *InternPool, index: Module.Decl.Index) *Module.Decl { | 7600 | pub fn declPtr(ip: *InternPool, index: DeclIndex) *Module.Decl { |
| 7558 | return ip.allocated_decls.at(@intFromEnum(index)); | 7601 | return ip.allocated_decls.at(@intFromEnum(index)); |
| 7559 | } | 7602 | } |
| 7560 | 7603 | ||
| 7561 | pub fn declPtrConst(ip: *const InternPool, index: Module.Decl.Index) *const Module.Decl { | 7604 | pub fn declPtrConst(ip: *const InternPool, index: DeclIndex) *const Module.Decl { |
| 7562 | return ip.allocated_decls.at(@intFromEnum(index)); | 7605 | return ip.allocated_decls.at(@intFromEnum(index)); |
| 7563 | } | 7606 | } |
| 7564 | 7607 | ||
| 7565 | pub fn namespacePtr(ip: *InternPool, index: Module.Namespace.Index) *Module.Namespace { | 7608 | pub fn namespacePtr(ip: *InternPool, index: NamespaceIndex) *Module.Namespace { |
| 7566 | return ip.allocated_namespaces.at(@intFromEnum(index)); | 7609 | return ip.allocated_namespaces.at(@intFromEnum(index)); |
| 7567 | } | 7610 | } |
| 7568 | 7611 | ||
| ... | @@ -7570,7 +7613,7 @@ pub fn createDecl( | ... | @@ -7570,7 +7613,7 @@ pub fn createDecl( |
| 7570 | ip: *InternPool, | 7613 | ip: *InternPool, |
| 7571 | gpa: Allocator, | 7614 | gpa: Allocator, |
| 7572 | initialization: Module.Decl, | 7615 | initialization: Module.Decl, |
| 7573 | ) Allocator.Error!Module.Decl.Index { | 7616 | ) Allocator.Error!DeclIndex { |
| 7574 | if (ip.decls_free_list.popOrNull()) |index| { | 7617 | if (ip.decls_free_list.popOrNull()) |index| { |
| 7575 | ip.allocated_decls.at(@intFromEnum(index)).* = initialization; | 7618 | ip.allocated_decls.at(@intFromEnum(index)).* = initialization; |
| 7576 | return index; | 7619 | return index; |
| ... | @@ -7580,7 +7623,7 @@ pub fn createDecl( | ... | @@ -7580,7 +7623,7 @@ pub fn createDecl( |
| 7580 | return @enumFromInt(ip.allocated_decls.len - 1); | 7623 | return @enumFromInt(ip.allocated_decls.len - 1); |
| 7581 | } | 7624 | } |
| 7582 | 7625 | ||
| 7583 | pub fn destroyDecl(ip: *InternPool, gpa: Allocator, index: Module.Decl.Index) void { | 7626 | pub fn destroyDecl(ip: *InternPool, gpa: Allocator, index: DeclIndex) void { |
| 7584 | ip.declPtr(index).* = undefined; | 7627 | ip.declPtr(index).* = undefined; |
| 7585 | ip.decls_free_list.append(gpa, index) catch { | 7628 | ip.decls_free_list.append(gpa, index) catch { |
| 7586 | // In order to keep `destroyDecl` a non-fallible function, we ignore memory | 7629 | // In order to keep `destroyDecl` a non-fallible function, we ignore memory |
| ... | @@ -7592,7 +7635,7 @@ pub fn createNamespace( | ... | @@ -7592,7 +7635,7 @@ pub fn createNamespace( |
| 7592 | ip: *InternPool, | 7635 | ip: *InternPool, |
| 7593 | gpa: Allocator, | 7636 | gpa: Allocator, |
| 7594 | initialization: Module.Namespace, | 7637 | initialization: Module.Namespace, |
| 7595 | ) Allocator.Error!Module.Namespace.Index { | 7638 | ) Allocator.Error!NamespaceIndex { |
| 7596 | if (ip.namespaces_free_list.popOrNull()) |index| { | 7639 | if (ip.namespaces_free_list.popOrNull()) |index| { |
| 7597 | ip.allocated_namespaces.at(@intFromEnum(index)).* = initialization; | 7640 | ip.allocated_namespaces.at(@intFromEnum(index)).* = initialization; |
| 7598 | return index; | 7641 | return index; |
| ... | @@ -7602,7 +7645,7 @@ pub fn createNamespace( | ... | @@ -7602,7 +7645,7 @@ pub fn createNamespace( |
| 7602 | return @enumFromInt(ip.allocated_namespaces.len - 1); | 7645 | return @enumFromInt(ip.allocated_namespaces.len - 1); |
| 7603 | } | 7646 | } |
| 7604 | 7647 | ||
| 7605 | pub fn destroyNamespace(ip: *InternPool, gpa: Allocator, index: Module.Namespace.Index) void { | 7648 | pub fn destroyNamespace(ip: *InternPool, gpa: Allocator, index: NamespaceIndex) void { |
| 7606 | ip.namespacePtr(index).* = .{ | 7649 | ip.namespacePtr(index).* = .{ |
| 7607 | .parent = undefined, | 7650 | .parent = undefined, |
| 7608 | .file_scope = undefined, | 7651 | .file_scope = undefined, |
| ... | @@ -7984,7 +8027,7 @@ pub fn isVariable(ip: *const InternPool, val: Index) bool { | ... | @@ -7984,7 +8027,7 @@ pub fn isVariable(ip: *const InternPool, val: Index) bool { |
| 7984 | return ip.items.items(.tag)[@intFromEnum(val)] == .variable; | 8027 | return ip.items.items(.tag)[@intFromEnum(val)] == .variable; |
| 7985 | } | 8028 | } |
| 7986 | 8029 | ||
| 7987 | pub fn getBackingDecl(ip: *const InternPool, val: Index) Module.Decl.OptionalIndex { | 8030 | pub fn getBackingDecl(ip: *const InternPool, val: Index) OptionalDeclIndex { |
| 7988 | var base = @intFromEnum(val); | 8031 | var base = @intFromEnum(val); |
| 7989 | while (true) { | 8032 | while (true) { |
| 7990 | switch (ip.items.items(.tag)[base]) { | 8033 | switch (ip.items.items(.tag)[base]) { |
| ... | @@ -8358,7 +8401,7 @@ pub fn funcDeclInfo(ip: *const InternPool, i: Index) Key.Func { | ... | @@ -8358,7 +8401,7 @@ pub fn funcDeclInfo(ip: *const InternPool, i: Index) Key.Func { |
| 8358 | return extraFuncDecl(ip, datas[@intFromEnum(i)]); | 8401 | return extraFuncDecl(ip, datas[@intFromEnum(i)]); |
| 8359 | } | 8402 | } |
| 8360 | 8403 | ||
| 8361 | pub fn funcDeclOwner(ip: *const InternPool, i: Index) Module.Decl.Index { | 8404 | pub fn funcDeclOwner(ip: *const InternPool, i: Index) DeclIndex { |
| 8362 | return funcDeclInfo(ip, i).owner_decl; | 8405 | return funcDeclInfo(ip, i).owner_decl; |
| 8363 | } | 8406 | } |
| 8364 | 8407 | ||
| ... | @@ -8424,7 +8467,7 @@ pub fn anonStructFieldsLen(ip: *const InternPool, i: Index) u32 { | ... | @@ -8424,7 +8467,7 @@ pub fn anonStructFieldsLen(ip: *const InternPool, i: Index) u32 { |
| 8424 | } | 8467 | } |
| 8425 | 8468 | ||
| 8426 | /// Asserts the type is a struct. | 8469 | /// Asserts the type is a struct. |
| 8427 | pub fn structDecl(ip: *const InternPool, i: Index) Module.Decl.OptionalIndex { | 8470 | pub fn structDecl(ip: *const InternPool, i: Index) OptionalDeclIndex { |
| 8428 | return switch (ip.indexToKey(i)) { | 8471 | return switch (ip.indexToKey(i)) { |
| 8429 | .struct_type => |t| t.decl, | 8472 | .struct_type => |t| t.decl, |
| 8430 | else => unreachable, | 8473 | else => unreachable, |
src/Module.zig+4-42| ... | @@ -464,27 +464,8 @@ pub const Decl = struct { | ... | @@ -464,27 +464,8 @@ pub const Decl = struct { |
| 464 | anon, | 464 | anon, |
| 465 | }; | 465 | }; |
| 466 | 466 | ||
| 467 | pub const Index = enum(u32) { | 467 | const Index = InternPool.DeclIndex; |
| 468 | _, | 468 | const OptionalIndex = InternPool.OptionalDeclIndex; |
| 469 | |||
| 470 | pub fn toOptional(i: Index) OptionalIndex { | ||
| 471 | return @as(OptionalIndex, @enumFromInt(@intFromEnum(i))); | ||
| 472 | } | ||
| 473 | }; | ||
| 474 | |||
| 475 | pub const OptionalIndex = enum(u32) { | ||
| 476 | none = std.math.maxInt(u32), | ||
| 477 | _, | ||
| 478 | |||
| 479 | pub fn init(oi: ?Index) OptionalIndex { | ||
| 480 | return @as(OptionalIndex, @enumFromInt(@intFromEnum(oi orelse return .none))); | ||
| 481 | } | ||
| 482 | |||
| 483 | pub fn unwrap(oi: OptionalIndex) ?Index { | ||
| 484 | if (oi == .none) return null; | ||
| 485 | return @as(Index, @enumFromInt(@intFromEnum(oi))); | ||
| 486 | } | ||
| 487 | }; | ||
| 488 | 469 | ||
| 489 | pub const DepsTable = std.AutoArrayHashMapUnmanaged(Decl.Index, DepType); | 470 | pub const DepsTable = std.AutoArrayHashMapUnmanaged(Decl.Index, DepType); |
| 490 | 471 | ||
| ... | @@ -828,27 +809,8 @@ pub const Namespace = struct { | ... | @@ -828,27 +809,8 @@ pub const Namespace = struct { |
| 828 | /// Value is whether the usingnamespace decl is marked `pub`. | 809 | /// Value is whether the usingnamespace decl is marked `pub`. |
| 829 | usingnamespace_set: std.AutoHashMapUnmanaged(Decl.Index, bool) = .{}, | 810 | usingnamespace_set: std.AutoHashMapUnmanaged(Decl.Index, bool) = .{}, |
| 830 | 811 | ||
| 831 | pub const Index = enum(u32) { | 812 | const Index = InternPool.NamespaceIndex; |
| 832 | _, | 813 | const OptionalIndex = InternPool.OptionalNamespaceIndex; |
| 833 | |||
| 834 | pub fn toOptional(i: Index) OptionalIndex { | ||
| 835 | return @as(OptionalIndex, @enumFromInt(@intFromEnum(i))); | ||
| 836 | } | ||
| 837 | }; | ||
| 838 | |||
| 839 | pub const OptionalIndex = enum(u32) { | ||
| 840 | none = std.math.maxInt(u32), | ||
| 841 | _, | ||
| 842 | |||
| 843 | pub fn init(oi: ?Index) OptionalIndex { | ||
| 844 | return @as(OptionalIndex, @enumFromInt(@intFromEnum(oi orelse return .none))); | ||
| 845 | } | ||
| 846 | |||
| 847 | pub fn unwrap(oi: OptionalIndex) ?Index { | ||
| 848 | if (oi == .none) return null; | ||
| 849 | return @as(Index, @enumFromInt(@intFromEnum(oi))); | ||
| 850 | } | ||
| 851 | }; | ||
| 852 | 814 | ||
| 853 | const DeclContext = struct { | 815 | const DeclContext = struct { |
| 854 | module: *Module, | 816 | module: *Module, |
src/Sema.zig+36-36| ... | @@ -20,7 +20,7 @@ inst_map: InstMap = .{}, | ... | @@ -20,7 +20,7 @@ inst_map: InstMap = .{}, |
| 20 | /// and `src_decl` of `Block` is the `Decl` of the callee. | 20 | /// and `src_decl` of `Block` is the `Decl` of the callee. |
| 21 | /// This `Decl` owns the arena memory of this `Sema`. | 21 | /// This `Decl` owns the arena memory of this `Sema`. |
| 22 | owner_decl: *Decl, | 22 | owner_decl: *Decl, |
| 23 | owner_decl_index: Decl.Index, | 23 | owner_decl_index: InternPool.DeclIndex, |
| 24 | /// For an inline or comptime function call, this will be the root parent function | 24 | /// For an inline or comptime function call, this will be the root parent function |
| 25 | /// which contains the callsite. Corresponds to `owner_decl`. | 25 | /// which contains the callsite. Corresponds to `owner_decl`. |
| 26 | /// This could be `none`, a `func_decl`, or a `func_instance`. | 26 | /// This could be `none`, a `func_decl`, or a `func_instance`. |
| ... | @@ -54,7 +54,7 @@ comptime_break_inst: Zir.Inst.Index = undefined, | ... | @@ -54,7 +54,7 @@ comptime_break_inst: Zir.Inst.Index = undefined, |
| 54 | /// access to the source location set by the previous instruction which did | 54 | /// access to the source location set by the previous instruction which did |
| 55 | /// contain a mapped source location. | 55 | /// contain a mapped source location. |
| 56 | src: LazySrcLoc = .{ .token_offset = 0 }, | 56 | src: LazySrcLoc = .{ .token_offset = 0 }, |
| 57 | decl_val_table: std.AutoHashMapUnmanaged(Decl.Index, Air.Inst.Ref) = .{}, | 57 | decl_val_table: std.AutoHashMapUnmanaged(InternPool.DeclIndex, Air.Inst.Ref) = .{}, |
| 58 | /// When doing a generic function instantiation, this array collects a value | 58 | /// When doing a generic function instantiation, this array collects a value |
| 59 | /// for each parameter of the generic owner. `none` for non-comptime parameters. | 59 | /// for each parameter of the generic owner. `none` for non-comptime parameters. |
| 60 | /// This is a separate array from `block.params` so that it can be passed | 60 | /// This is a separate array from `block.params` so that it can be passed |
| ... | @@ -71,7 +71,7 @@ generic_owner: InternPool.Index = .none, | ... | @@ -71,7 +71,7 @@ generic_owner: InternPool.Index = .none, |
| 71 | /// declaration site. | 71 | /// declaration site. |
| 72 | generic_call_src: LazySrcLoc = .unneeded, | 72 | generic_call_src: LazySrcLoc = .unneeded, |
| 73 | /// Corresponds to `generic_call_src`. | 73 | /// Corresponds to `generic_call_src`. |
| 74 | generic_call_decl: Decl.OptionalIndex = .none, | 74 | generic_call_decl: InternPool.OptionalDeclIndex = .none, |
| 75 | /// The key is types that must be fully resolved prior to machine code | 75 | /// The key is types that must be fully resolved prior to machine code |
| 76 | /// generation pass. Types are added to this set when resolving them | 76 | /// generation pass. Types are added to this set when resolving them |
| 77 | /// immediately could cause a dependency loop, but they do need to be resolved | 77 | /// immediately could cause a dependency loop, but they do need to be resolved |
| ... | @@ -101,7 +101,7 @@ unresolved_inferred_allocs: std.AutoHashMapUnmanaged(Air.Inst.Index, InferredAll | ... | @@ -101,7 +101,7 @@ unresolved_inferred_allocs: std.AutoHashMapUnmanaged(Air.Inst.Index, InferredAll |
| 101 | /// TODO: this is a workaround for memory bugs triggered by the removal of | 101 | /// TODO: this is a workaround for memory bugs triggered by the removal of |
| 102 | /// Decl.value_arena. A better solution needs to be found. Probably this will | 102 | /// Decl.value_arena. A better solution needs to be found. Probably this will |
| 103 | /// involve transitioning comptime-mutable memory away from using Decls at all. | 103 | /// involve transitioning comptime-mutable memory away from using Decls at all. |
| 104 | comptime_mutable_decls: *std.ArrayList(Decl.Index), | 104 | comptime_mutable_decls: *std.ArrayList(InternPool.DeclIndex), |
| 105 | 105 | ||
| 106 | /// This is populated when `@setAlignStack` occurs so that if there is a duplicate | 106 | /// This is populated when `@setAlignStack` occurs so that if there is a duplicate |
| 107 | /// one encountered, the conflicting source location can be shown. | 107 | /// one encountered, the conflicting source location can be shown. |
| ... | @@ -323,7 +323,7 @@ pub const Block = struct { | ... | @@ -323,7 +323,7 @@ pub const Block = struct { |
| 323 | sema: *Sema, | 323 | sema: *Sema, |
| 324 | /// The namespace to use for lookups from this source block | 324 | /// The namespace to use for lookups from this source block |
| 325 | /// When analyzing fields, this is different from src_decl.src_namespace. | 325 | /// When analyzing fields, this is different from src_decl.src_namespace. |
| 326 | namespace: Namespace.Index, | 326 | namespace: InternPool.NamespaceIndex, |
| 327 | /// The AIR instructions generated for this block. | 327 | /// The AIR instructions generated for this block. |
| 328 | instructions: std.ArrayListUnmanaged(Air.Inst.Index), | 328 | instructions: std.ArrayListUnmanaged(Air.Inst.Index), |
| 329 | // `param` instructions are collected here to be used by the `func` instruction. | 329 | // `param` instructions are collected here to be used by the `func` instruction. |
| ... | @@ -345,7 +345,7 @@ pub const Block = struct { | ... | @@ -345,7 +345,7 @@ pub const Block = struct { |
| 345 | /// This Decl is the Decl according to the Zig source code corresponding to this Block. | 345 | /// This Decl is the Decl according to the Zig source code corresponding to this Block. |
| 346 | /// This can vary during inline or comptime function calls. See `Sema.owner_decl` | 346 | /// This can vary during inline or comptime function calls. See `Sema.owner_decl` |
| 347 | /// for the one that will be the same for all Block instances. | 347 | /// for the one that will be the same for all Block instances. |
| 348 | src_decl: Decl.Index, | 348 | src_decl: InternPool.DeclIndex, |
| 349 | /// Non zero if a non-inline loop or a runtime conditional have been encountered. | 349 | /// Non zero if a non-inline loop or a runtime conditional have been encountered. |
| 350 | /// Stores to comptime variables are only allowed when var.runtime_index <= runtime_index. | 350 | /// Stores to comptime variables are only allowed when var.runtime_index <= runtime_index. |
| 351 | runtime_index: Value.RuntimeIndex = .zero, | 351 | runtime_index: Value.RuntimeIndex = .zero, |
| ... | @@ -800,7 +800,7 @@ pub const Block = struct { | ... | @@ -800,7 +800,7 @@ pub const Block = struct { |
| 800 | } | 800 | } |
| 801 | 801 | ||
| 802 | /// `alignment` value of 0 means to use ABI alignment. | 802 | /// `alignment` value of 0 means to use ABI alignment. |
| 803 | pub fn finish(wad: *WipAnonDecl, ty: Type, val: Value, alignment: Alignment) !Decl.Index { | 803 | pub fn finish(wad: *WipAnonDecl, ty: Type, val: Value, alignment: Alignment) !InternPool.DeclIndex { |
| 804 | const sema = wad.block.sema; | 804 | const sema = wad.block.sema; |
| 805 | // Do this ahead of time because `createAnonymousDecl` depends on calling | 805 | // Do this ahead of time because `createAnonymousDecl` depends on calling |
| 806 | // `type.hasRuntimeBits()`. | 806 | // `type.hasRuntimeBits()`. |
| ... | @@ -2505,7 +2505,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.ErrorMsg) | ... | @@ -2505,7 +2505,7 @@ fn failWithOwnedErrorMsg(sema: *Sema, block: ?*Block, err_msg: *Module.ErrorMsg) |
| 2505 | defer reference_stack.deinit(); | 2505 | defer reference_stack.deinit(); |
| 2506 | 2506 | ||
| 2507 | // Avoid infinite loops. | 2507 | // Avoid infinite loops. |
| 2508 | var seen = std.AutoHashMap(Decl.Index, void).init(gpa); | 2508 | var seen = std.AutoHashMap(InternPool.DeclIndex, void).init(gpa); |
| 2509 | defer seen.deinit(); | 2509 | defer seen.deinit(); |
| 2510 | 2510 | ||
| 2511 | while (mod.reference_table.get(referenced_by)) |ref| { | 2511 | while (mod.reference_table.get(referenced_by)) |ref| { |
| ... | @@ -2652,8 +2652,8 @@ fn analyzeAsInt( | ... | @@ -2652,8 +2652,8 @@ fn analyzeAsInt( |
| 2652 | 2652 | ||
| 2653 | pub fn getStructType( | 2653 | pub fn getStructType( |
| 2654 | sema: *Sema, | 2654 | sema: *Sema, |
| 2655 | decl: Module.Decl.Index, | 2655 | decl: InternPool.DeclIndex, |
| 2656 | namespace: Module.Namespace.Index, | 2656 | namespace: InternPool.NamespaceIndex, |
| 2657 | zir_index: Zir.Inst.Index, | 2657 | zir_index: Zir.Inst.Index, |
| 2658 | ) !InternPool.Index { | 2658 | ) !InternPool.Index { |
| 2659 | const mod = sema.mod; | 2659 | const mod = sema.mod; |
| ... | @@ -2768,7 +2768,7 @@ fn createAnonymousDeclTypeNamed( | ... | @@ -2768,7 +2768,7 @@ fn createAnonymousDeclTypeNamed( |
| 2768 | name_strategy: Zir.Inst.NameStrategy, | 2768 | name_strategy: Zir.Inst.NameStrategy, |
| 2769 | anon_prefix: []const u8, | 2769 | anon_prefix: []const u8, |
| 2770 | inst: ?Zir.Inst.Index, | 2770 | inst: ?Zir.Inst.Index, |
| 2771 | ) !Decl.Index { | 2771 | ) !InternPool.DeclIndex { |
| 2772 | const mod = sema.mod; | 2772 | const mod = sema.mod; |
| 2773 | const ip = &mod.intern_pool; | 2773 | const ip = &mod.intern_pool; |
| 2774 | const gpa = sema.gpa; | 2774 | const gpa = sema.gpa; |
| ... | @@ -6065,7 +6065,7 @@ pub fn analyzeExport( | ... | @@ -6065,7 +6065,7 @@ pub fn analyzeExport( |
| 6065 | block: *Block, | 6065 | block: *Block, |
| 6066 | src: LazySrcLoc, | 6066 | src: LazySrcLoc, |
| 6067 | options: Module.Export.Options, | 6067 | options: Module.Export.Options, |
| 6068 | exported_decl_index: Decl.Index, | 6068 | exported_decl_index: InternPool.DeclIndex, |
| 6069 | ) !void { | 6069 | ) !void { |
| 6070 | const gpa = sema.gpa; | 6070 | const gpa = sema.gpa; |
| 6071 | const mod = sema.mod; | 6071 | const mod = sema.mod; |
| ... | @@ -6380,7 +6380,7 @@ fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air | ... | @@ -6380,7 +6380,7 @@ fn zirDeclVal(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 6380 | return sema.analyzeDeclVal(block, src, decl); | 6380 | return sema.analyzeDeclVal(block, src, decl); |
| 6381 | } | 6381 | } |
| 6382 | 6382 | ||
| 6383 | fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: InternPool.NullTerminatedString) !Decl.Index { | 6383 | fn lookupIdentifier(sema: *Sema, block: *Block, src: LazySrcLoc, name: InternPool.NullTerminatedString) !InternPool.DeclIndex { |
| 6384 | const mod = sema.mod; | 6384 | const mod = sema.mod; |
| 6385 | var namespace = block.namespace; | 6385 | var namespace = block.namespace; |
| 6386 | while (true) { | 6386 | while (true) { |
| ... | @@ -6398,10 +6398,10 @@ fn lookupInNamespace( | ... | @@ -6398,10 +6398,10 @@ fn lookupInNamespace( |
| 6398 | sema: *Sema, | 6398 | sema: *Sema, |
| 6399 | block: *Block, | 6399 | block: *Block, |
| 6400 | src: LazySrcLoc, | 6400 | src: LazySrcLoc, |
| 6401 | namespace_index: Namespace.Index, | 6401 | namespace_index: InternPool.NamespaceIndex, |
| 6402 | ident_name: InternPool.NullTerminatedString, | 6402 | ident_name: InternPool.NullTerminatedString, |
| 6403 | observe_usingnamespace: bool, | 6403 | observe_usingnamespace: bool, |
| 6404 | ) CompileError!?Decl.Index { | 6404 | ) CompileError!?InternPool.DeclIndex { |
| 6405 | const mod = sema.mod; | 6405 | const mod = sema.mod; |
| 6406 | 6406 | ||
| 6407 | const namespace = mod.namespacePtr(namespace_index); | 6407 | const namespace = mod.namespacePtr(namespace_index); |
| ... | @@ -6419,7 +6419,7 @@ fn lookupInNamespace( | ... | @@ -6419,7 +6419,7 @@ fn lookupInNamespace( |
| 6419 | defer checked_namespaces.deinit(gpa); | 6419 | defer checked_namespaces.deinit(gpa); |
| 6420 | 6420 | ||
| 6421 | // Keep track of name conflicts for error notes. | 6421 | // Keep track of name conflicts for error notes. |
| 6422 | var candidates: std.ArrayListUnmanaged(Decl.Index) = .{}; | 6422 | var candidates: std.ArrayListUnmanaged(InternPool.DeclIndex) = .{}; |
| 6423 | defer candidates.deinit(gpa); | 6423 | defer candidates.deinit(gpa); |
| 6424 | 6424 | ||
| 6425 | try checked_namespaces.put(gpa, namespace, namespace.file_scope == src_file); | 6425 | try checked_namespaces.put(gpa, namespace, namespace.file_scope == src_file); |
| ... | @@ -7034,7 +7034,7 @@ const InlineCallSema = struct { | ... | @@ -7034,7 +7034,7 @@ const InlineCallSema = struct { |
| 7034 | other_error_return_trace_index_on_fn_entry: Air.Inst.Ref, | 7034 | other_error_return_trace_index_on_fn_entry: Air.Inst.Ref, |
| 7035 | other_generic_owner: InternPool.Index, | 7035 | other_generic_owner: InternPool.Index, |
| 7036 | other_generic_call_src: LazySrcLoc, | 7036 | other_generic_call_src: LazySrcLoc, |
| 7037 | other_generic_call_decl: Decl.OptionalIndex, | 7037 | other_generic_call_decl: InternPool.OptionalDeclIndex, |
| 7038 | 7038 | ||
| 7039 | /// Sema should currently be set up for the caller (i.e. unchanged yet). This init will not | 7039 | /// Sema should currently be set up for the caller (i.e. unchanged yet). This init will not |
| 7040 | /// change that. The other parameters contain data for the callee Sema. The other modified | 7040 | /// change that. The other parameters contain data for the callee Sema. The other modified |
| ... | @@ -7104,7 +7104,7 @@ const InlineCallSema = struct { | ... | @@ -7104,7 +7104,7 @@ const InlineCallSema = struct { |
| 7104 | std.mem.swap(InstMap, &ics.sema.inst_map, &ics.other_inst_map); | 7104 | std.mem.swap(InstMap, &ics.sema.inst_map, &ics.other_inst_map); |
| 7105 | std.mem.swap(InternPool.Index, &ics.sema.generic_owner, &ics.other_generic_owner); | 7105 | std.mem.swap(InternPool.Index, &ics.sema.generic_owner, &ics.other_generic_owner); |
| 7106 | std.mem.swap(LazySrcLoc, &ics.sema.generic_call_src, &ics.other_generic_call_src); | 7106 | std.mem.swap(LazySrcLoc, &ics.sema.generic_call_src, &ics.other_generic_call_src); |
| 7107 | std.mem.swap(Decl.OptionalIndex, &ics.sema.generic_call_decl, &ics.other_generic_call_decl); | 7107 | std.mem.swap(InternPool.OptionalDeclIndex, &ics.sema.generic_call_decl, &ics.other_generic_call_decl); |
| 7108 | std.mem.swap(Air.Inst.Ref, &ics.sema.error_return_trace_index_on_fn_entry, &ics.other_error_return_trace_index_on_fn_entry); | 7108 | std.mem.swap(Air.Inst.Ref, &ics.sema.error_return_trace_index_on_fn_entry, &ics.other_error_return_trace_index_on_fn_entry); |
| 7109 | // zig fmt: on | 7109 | // zig fmt: on |
| 7110 | } | 7110 | } |
| ... | @@ -17825,7 +17825,7 @@ fn typeInfoDecls( | ... | @@ -17825,7 +17825,7 @@ fn typeInfoDecls( |
| 17825 | block: *Block, | 17825 | block: *Block, |
| 17826 | src: LazySrcLoc, | 17826 | src: LazySrcLoc, |
| 17827 | type_info_ty: Type, | 17827 | type_info_ty: Type, |
| 17828 | opt_namespace: Module.Namespace.OptionalIndex, | 17828 | opt_namespace: InternPool.OptionalNamespaceIndex, |
| 17829 | ) CompileError!InternPool.Index { | 17829 | ) CompileError!InternPool.Index { |
| 17830 | const mod = sema.mod; | 17830 | const mod = sema.mod; |
| 17831 | const gpa = sema.gpa; | 17831 | const gpa = sema.gpa; |
| ... | @@ -25760,7 +25760,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { | ... | @@ -25760,7 +25760,7 @@ fn prepareSimplePanic(sema: *Sema, block: *Block) !void { |
| 25760 | /// Backends depend on panic decls being available when lowering safety-checked | 25760 | /// Backends depend on panic decls being available when lowering safety-checked |
| 25761 | /// instructions. This function ensures the panic function will be available to | 25761 | /// instructions. This function ensures the panic function will be available to |
| 25762 | /// be called during that time. | 25762 | /// be called during that time. |
| 25763 | fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !Module.Decl.Index { | 25763 | fn preparePanicId(sema: *Sema, block: *Block, panic_id: Module.PanicId) !InternPool.DeclIndex { |
| 25764 | const mod = sema.mod; | 25764 | const mod = sema.mod; |
| 25765 | const gpa = sema.gpa; | 25765 | const gpa = sema.gpa; |
| 25766 | if (mod.panic_messages[@intFromEnum(panic_id)].unwrap()) |x| return x; | 25766 | if (mod.panic_messages[@intFromEnum(panic_id)].unwrap()) |x| return x; |
| ... | @@ -26685,9 +26685,9 @@ fn namespaceLookup( | ... | @@ -26685,9 +26685,9 @@ fn namespaceLookup( |
| 26685 | sema: *Sema, | 26685 | sema: *Sema, |
| 26686 | block: *Block, | 26686 | block: *Block, |
| 26687 | src: LazySrcLoc, | 26687 | src: LazySrcLoc, |
| 26688 | namespace: Namespace.Index, | 26688 | namespace: InternPool.NamespaceIndex, |
| 26689 | decl_name: InternPool.NullTerminatedString, | 26689 | decl_name: InternPool.NullTerminatedString, |
| 26690 | ) CompileError!?Decl.Index { | 26690 | ) CompileError!?InternPool.DeclIndex { |
| 26691 | const mod = sema.mod; | 26691 | const mod = sema.mod; |
| 26692 | const gpa = sema.gpa; | 26692 | const gpa = sema.gpa; |
| 26693 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { | 26693 | if (try sema.lookupInNamespace(block, src, namespace, decl_name, true)) |decl_index| { |
| ... | @@ -26712,7 +26712,7 @@ fn namespaceLookupRef( | ... | @@ -26712,7 +26712,7 @@ fn namespaceLookupRef( |
| 26712 | sema: *Sema, | 26712 | sema: *Sema, |
| 26713 | block: *Block, | 26713 | block: *Block, |
| 26714 | src: LazySrcLoc, | 26714 | src: LazySrcLoc, |
| 26715 | namespace: Namespace.Index, | 26715 | namespace: InternPool.NamespaceIndex, |
| 26716 | decl_name: InternPool.NullTerminatedString, | 26716 | decl_name: InternPool.NullTerminatedString, |
| 26717 | ) CompileError!?Air.Inst.Ref { | 26717 | ) CompileError!?Air.Inst.Ref { |
| 26718 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; | 26718 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; |
| ... | @@ -26724,7 +26724,7 @@ fn namespaceLookupVal( | ... | @@ -26724,7 +26724,7 @@ fn namespaceLookupVal( |
| 26724 | sema: *Sema, | 26724 | sema: *Sema, |
| 26725 | block: *Block, | 26725 | block: *Block, |
| 26726 | src: LazySrcLoc, | 26726 | src: LazySrcLoc, |
| 26727 | namespace: Namespace.Index, | 26727 | namespace: InternPool.NamespaceIndex, |
| 26728 | decl_name: InternPool.NullTerminatedString, | 26728 | decl_name: InternPool.NullTerminatedString, |
| 26729 | ) CompileError!?Air.Inst.Ref { | 26729 | ) CompileError!?Air.Inst.Ref { |
| 26730 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; | 26730 | const decl = (try sema.namespaceLookup(block, src, namespace, decl_name)) orelse return null; |
| ... | @@ -31589,7 +31589,7 @@ fn analyzeDeclVal( | ... | @@ -31589,7 +31589,7 @@ fn analyzeDeclVal( |
| 31589 | sema: *Sema, | 31589 | sema: *Sema, |
| 31590 | block: *Block, | 31590 | block: *Block, |
| 31591 | src: LazySrcLoc, | 31591 | src: LazySrcLoc, |
| 31592 | decl_index: Decl.Index, | 31592 | decl_index: InternPool.DeclIndex, |
| 31593 | ) CompileError!Air.Inst.Ref { | 31593 | ) CompileError!Air.Inst.Ref { |
| 31594 | try sema.addReferencedBy(block, src, decl_index); | 31594 | try sema.addReferencedBy(block, src, decl_index); |
| 31595 | if (sema.decl_val_table.get(decl_index)) |result| { | 31595 | if (sema.decl_val_table.get(decl_index)) |result| { |
| ... | @@ -31609,7 +31609,7 @@ fn addReferencedBy( | ... | @@ -31609,7 +31609,7 @@ fn addReferencedBy( |
| 31609 | sema: *Sema, | 31609 | sema: *Sema, |
| 31610 | block: *Block, | 31610 | block: *Block, |
| 31611 | src: LazySrcLoc, | 31611 | src: LazySrcLoc, |
| 31612 | decl_index: Decl.Index, | 31612 | decl_index: InternPool.DeclIndex, |
| 31613 | ) !void { | 31613 | ) !void { |
| 31614 | if (sema.mod.comp.reference_trace == 0) return; | 31614 | if (sema.mod.comp.reference_trace == 0) return; |
| 31615 | if (src == .unneeded) { | 31615 | if (src == .unneeded) { |
| ... | @@ -31626,7 +31626,7 @@ fn addReferencedBy( | ... | @@ -31626,7 +31626,7 @@ fn addReferencedBy( |
| 31626 | }); | 31626 | }); |
| 31627 | } | 31627 | } |
| 31628 | 31628 | ||
| 31629 | fn ensureDeclAnalyzed(sema: *Sema, decl_index: Decl.Index) CompileError!void { | 31629 | fn ensureDeclAnalyzed(sema: *Sema, decl_index: InternPool.DeclIndex) CompileError!void { |
| 31630 | const mod = sema.mod; | 31630 | const mod = sema.mod; |
| 31631 | const ip = &mod.intern_pool; | 31631 | const ip = &mod.intern_pool; |
| 31632 | const decl = mod.declPtr(decl_index); | 31632 | const decl = mod.declPtr(decl_index); |
| ... | @@ -31670,7 +31670,7 @@ fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { | ... | @@ -31670,7 +31670,7 @@ fn optRefValue(sema: *Sema, opt_val: ?Value) !Value { |
| 31670 | } }))); | 31670 | } }))); |
| 31671 | } | 31671 | } |
| 31672 | 31672 | ||
| 31673 | fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref { | 31673 | fn analyzeDeclRef(sema: *Sema, decl_index: InternPool.DeclIndex) CompileError!Air.Inst.Ref { |
| 31674 | return sema.analyzeDeclRefInner(decl_index, true); | 31674 | return sema.analyzeDeclRefInner(decl_index, true); |
| 31675 | } | 31675 | } |
| 31676 | 31676 | ||
| ... | @@ -31678,7 +31678,7 @@ fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref | ... | @@ -31678,7 +31678,7 @@ fn analyzeDeclRef(sema: *Sema, decl_index: Decl.Index) CompileError!Air.Inst.Ref |
| 31678 | /// only triggers analysis for function bodies if `analyze_fn_body` is true. If it's possible for a | 31678 | /// only triggers analysis for function bodies if `analyze_fn_body` is true. If it's possible for a |
| 31679 | /// decl_ref to end up in runtime code, the function body must be analyzed: `analyzeDeclRef` wraps | 31679 | /// decl_ref to end up in runtime code, the function body must be analyzed: `analyzeDeclRef` wraps |
| 31680 | /// this function with `analyze_fn_body` set to true. | 31680 | /// this function with `analyze_fn_body` set to true. |
| 31681 | fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: bool) CompileError!Air.Inst.Ref { | 31681 | fn analyzeDeclRefInner(sema: *Sema, decl_index: InternPool.DeclIndex, analyze_fn_body: bool) CompileError!Air.Inst.Ref { |
| 31682 | const mod = sema.mod; | 31682 | const mod = sema.mod; |
| 31683 | try sema.ensureDeclAnalyzed(decl_index); | 31683 | try sema.ensureDeclAnalyzed(decl_index); |
| 31684 | 31684 | ||
| ... | @@ -31701,7 +31701,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: boo | ... | @@ -31701,7 +31701,7 @@ fn analyzeDeclRefInner(sema: *Sema, decl_index: Decl.Index, analyze_fn_body: boo |
| 31701 | } }))); | 31701 | } }))); |
| 31702 | } | 31702 | } |
| 31703 | 31703 | ||
| 31704 | fn maybeQueueFuncBodyAnalysis(sema: *Sema, decl_index: Decl.Index) !void { | 31704 | fn maybeQueueFuncBodyAnalysis(sema: *Sema, decl_index: InternPool.DeclIndex) !void { |
| 31705 | const mod = sema.mod; | 31705 | const mod = sema.mod; |
| 31706 | const decl = mod.declPtr(decl_index); | 31706 | const decl = mod.declPtr(decl_index); |
| 31707 | const tv = try decl.typedValue(); | 31707 | const tv = try decl.typedValue(); |
| ... | @@ -34861,7 +34861,7 @@ fn semaBackingIntType(mod: *Module, struct_type: InternPool.Key.StructType) Comp | ... | @@ -34861,7 +34861,7 @@ fn semaBackingIntType(mod: *Module, struct_type: InternPool.Key.StructType) Comp |
| 34861 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); | 34861 | var analysis_arena = std.heap.ArenaAllocator.init(gpa); |
| 34862 | defer analysis_arena.deinit(); | 34862 | defer analysis_arena.deinit(); |
| 34863 | 34863 | ||
| 34864 | var comptime_mutable_decls = std.ArrayList(Decl.Index).init(gpa); | 34864 | var comptime_mutable_decls = std.ArrayList(InternPool.DeclIndex).init(gpa); |
| 34865 | defer comptime_mutable_decls.deinit(); | 34865 | defer comptime_mutable_decls.deinit(); |
| 34866 | 34866 | ||
| 34867 | var sema: Sema = .{ | 34867 | var sema: Sema = .{ |
| ... | @@ -35683,7 +35683,7 @@ fn semaStructFields( | ... | @@ -35683,7 +35683,7 @@ fn semaStructFields( |
| 35683 | }, | 35683 | }, |
| 35684 | }; | 35684 | }; |
| 35685 | 35685 | ||
| 35686 | var comptime_mutable_decls = std.ArrayList(Decl.Index).init(gpa); | 35686 | var comptime_mutable_decls = std.ArrayList(InternPool.DeclIndex).init(gpa); |
| 35687 | defer comptime_mutable_decls.deinit(); | 35687 | defer comptime_mutable_decls.deinit(); |
| 35688 | 35688 | ||
| 35689 | var sema: Sema = .{ | 35689 | var sema: Sema = .{ |
| ... | @@ -35949,7 +35949,7 @@ fn semaStructFieldInits( | ... | @@ -35949,7 +35949,7 @@ fn semaStructFieldInits( |
| 35949 | const zir_index = struct_type.zir_index; | 35949 | const zir_index = struct_type.zir_index; |
| 35950 | const fields_len, const small, var extra_index = structZirInfo(zir, zir_index); | 35950 | const fields_len, const small, var extra_index = structZirInfo(zir, zir_index); |
| 35951 | 35951 | ||
| 35952 | var comptime_mutable_decls = std.ArrayList(Decl.Index).init(gpa); | 35952 | var comptime_mutable_decls = std.ArrayList(InternPool.DeclIndex).init(gpa); |
| 35953 | defer comptime_mutable_decls.deinit(); | 35953 | defer comptime_mutable_decls.deinit(); |
| 35954 | 35954 | ||
| 35955 | var sema: Sema = .{ | 35955 | var sema: Sema = .{ |
| ... | @@ -36133,7 +36133,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un | ... | @@ -36133,7 +36133,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Key.Un |
| 36133 | 36133 | ||
| 36134 | const decl = mod.declPtr(decl_index); | 36134 | const decl = mod.declPtr(decl_index); |
| 36135 | 36135 | ||
| 36136 | var comptime_mutable_decls = std.ArrayList(Decl.Index).init(gpa); | 36136 | var comptime_mutable_decls = std.ArrayList(InternPool.DeclIndex).init(gpa); |
| 36137 | defer comptime_mutable_decls.deinit(); | 36137 | defer comptime_mutable_decls.deinit(); |
| 36138 | 36138 | ||
| 36139 | var sema: Sema = .{ | 36139 | var sema: Sema = .{ |
| ... | @@ -36561,7 +36561,7 @@ fn generateUnionTagTypeSimple( | ... | @@ -36561,7 +36561,7 @@ fn generateUnionTagTypeSimple( |
| 36561 | sema: *Sema, | 36561 | sema: *Sema, |
| 36562 | block: *Block, | 36562 | block: *Block, |
| 36563 | enum_field_names: []const InternPool.NullTerminatedString, | 36563 | enum_field_names: []const InternPool.NullTerminatedString, |
| 36564 | maybe_decl_index: Module.Decl.OptionalIndex, | 36564 | maybe_decl_index: InternPool.OptionalDeclIndex, |
| 36565 | ) !InternPool.Index { | 36565 | ) !InternPool.Index { |
| 36566 | const mod = sema.mod; | 36566 | const mod = sema.mod; |
| 36567 | const ip = &mod.intern_pool; | 36567 | const ip = &mod.intern_pool; |
| ... | @@ -36630,7 +36630,7 @@ fn getBuiltin(sema: *Sema, name: []const u8) CompileError!Air.Inst.Ref { | ... | @@ -36630,7 +36630,7 @@ fn getBuiltin(sema: *Sema, name: []const u8) CompileError!Air.Inst.Ref { |
| 36630 | return sema.analyzeDeclVal(&block, src, decl_index); | 36630 | return sema.analyzeDeclVal(&block, src, decl_index); |
| 36631 | } | 36631 | } |
| 36632 | 36632 | ||
| 36633 | fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!Module.Decl.Index { | 36633 | fn getBuiltinDecl(sema: *Sema, block: *Block, name: []const u8) CompileError!InternPool.DeclIndex { |
| 36634 | const gpa = sema.gpa; | 36634 | const gpa = sema.gpa; |
| 36635 | 36635 | ||
| 36636 | const src = LazySrcLoc.nodeOffset(0); | 36636 | const src = LazySrcLoc.nodeOffset(0); |
src/Zir.zig-3| ... | @@ -21,9 +21,6 @@ const Ast = std.zig.Ast; | ... | @@ -21,9 +21,6 @@ const Ast = std.zig.Ast; |
| 21 | 21 | ||
| 22 | const InternPool = @import("InternPool.zig"); | 22 | const InternPool = @import("InternPool.zig"); |
| 23 | const Zir = @This(); | 23 | const Zir = @This(); |
| 24 | const Type = @import("type.zig").Type; | ||
| 25 | const Value = @import("value.zig").Value; | ||
| 26 | const TypedValue = @import("TypedValue.zig"); | ||
| 27 | const Module = @import("Module.zig"); | 24 | const Module = @import("Module.zig"); |
| 28 | const LazySrcLoc = Module.LazySrcLoc; | 25 | const LazySrcLoc = Module.LazySrcLoc; |
| 29 | 26 |
src/arch/aarch64/CodeGen.zig+1-1| ... | @@ -52,7 +52,7 @@ bin_file: *link.File, | ... | @@ -52,7 +52,7 @@ bin_file: *link.File, |
| 52 | debug_output: DebugInfoOutput, | 52 | debug_output: DebugInfoOutput, |
| 53 | target: *const std.Target, | 53 | target: *const std.Target, |
| 54 | func_index: InternPool.Index, | 54 | func_index: InternPool.Index, |
| 55 | owner_decl: Module.Decl.Index, | 55 | owner_decl: InternPool.DeclIndex, |
| 56 | err_msg: ?*ErrorMsg, | 56 | err_msg: ?*ErrorMsg, |
| 57 | args: []MCValue, | 57 | args: []MCValue, |
| 58 | ret_mcv: MCValue, | 58 | ret_mcv: MCValue, |
src/arch/wasm/CodeGen.zig+4-4| ... | @@ -643,7 +643,7 @@ const CodeGen = @This(); | ... | @@ -643,7 +643,7 @@ const CodeGen = @This(); |
| 643 | /// Reference to the function declaration the code | 643 | /// Reference to the function declaration the code |
| 644 | /// section belongs to | 644 | /// section belongs to |
| 645 | decl: *Decl, | 645 | decl: *Decl, |
| 646 | decl_index: Decl.Index, | 646 | decl_index: InternPool.DeclIndex, |
| 647 | /// Current block depth. Used to calculate the relative difference between a break | 647 | /// Current block depth. Used to calculate the relative difference between a break |
| 648 | /// and block | 648 | /// and block |
| 649 | block_depth: u32 = 0, | 649 | block_depth: u32 = 0, |
| ... | @@ -2194,7 +2194,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif | ... | @@ -2194,7 +2194,7 @@ fn airCall(func: *CodeGen, inst: Air.Inst.Index, modifier: std.builtin.CallModif |
| 2194 | const fn_info = mod.typeToFunc(fn_ty).?; | 2194 | const fn_info = mod.typeToFunc(fn_ty).?; |
| 2195 | const first_param_sret = firstParamSRet(fn_info.cc, Type.fromInterned(fn_info.return_type), mod); | 2195 | const first_param_sret = firstParamSRet(fn_info.cc, Type.fromInterned(fn_info.return_type), mod); |
| 2196 | 2196 | ||
| 2197 | const callee: ?Decl.Index = blk: { | 2197 | const callee: ?InternPool.DeclIndex = blk: { |
| 2198 | const func_val = (try func.air.value(pl_op.operand, mod)) orelse break :blk null; | 2198 | const func_val = (try func.air.value(pl_op.operand, mod)) orelse break :blk null; |
| 2199 | 2199 | ||
| 2200 | if (func_val.getFunction(mod)) |function| { | 2200 | if (func_val.getFunction(mod)) |function| { |
| ... | @@ -3131,7 +3131,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue | ... | @@ -3131,7 +3131,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue |
| 3131 | } | 3131 | } |
| 3132 | } | 3132 | } |
| 3133 | 3133 | ||
| 3134 | fn lowerParentPtrDecl(func: *CodeGen, ptr_val: Value, decl_index: Module.Decl.Index, offset: u32) InnerError!WValue { | 3134 | fn lowerParentPtrDecl(func: *CodeGen, ptr_val: Value, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue { |
| 3135 | const mod = func.bin_file.base.options.module.?; | 3135 | const mod = func.bin_file.base.options.module.?; |
| 3136 | const decl = mod.declPtr(decl_index); | 3136 | const decl = mod.declPtr(decl_index); |
| 3137 | try mod.markDeclAlive(decl); | 3137 | try mod.markDeclAlive(decl); |
| ... | @@ -3171,7 +3171,7 @@ fn lowerAnonDeclRef( | ... | @@ -3171,7 +3171,7 @@ fn lowerAnonDeclRef( |
| 3171 | } else return WValue{ .memory_offset = .{ .pointer = target_sym_index, .offset = offset } }; | 3171 | } else return WValue{ .memory_offset = .{ .pointer = target_sym_index, .offset = offset } }; |
| 3172 | } | 3172 | } |
| 3173 | 3173 | ||
| 3174 | fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: Module.Decl.Index, offset: u32) InnerError!WValue { | 3174 | fn lowerDeclRefValue(func: *CodeGen, tv: TypedValue, decl_index: InternPool.DeclIndex, offset: u32) InnerError!WValue { |
| 3175 | const mod = func.bin_file.base.options.module.?; | 3175 | const mod = func.bin_file.base.options.module.?; |
| 3176 | if (tv.ty.isSlice(mod)) { | 3176 | if (tv.ty.isSlice(mod)) { |
| 3177 | return WValue{ .memory = try func.bin_file.lowerUnnamedConst(tv, decl_index) }; | 3177 | return WValue{ .memory = try func.bin_file.lowerUnnamedConst(tv, decl_index) }; |
src/arch/wasm/Emit.zig+2-1| ... | @@ -6,6 +6,7 @@ const std = @import("std"); | ... | @@ -6,6 +6,7 @@ const std = @import("std"); |
| 6 | const Mir = @import("Mir.zig"); | 6 | const Mir = @import("Mir.zig"); |
| 7 | const link = @import("../../link.zig"); | 7 | const link = @import("../../link.zig"); |
| 8 | const Module = @import("../../Module.zig"); | 8 | const Module = @import("../../Module.zig"); |
| 9 | const InternPool = @import("../../InternPool.zig"); | ||
| 9 | const codegen = @import("../../codegen.zig"); | 10 | const codegen = @import("../../codegen.zig"); |
| 10 | const leb128 = std.leb; | 11 | const leb128 = std.leb; |
| 11 | 12 | ||
| ... | @@ -21,7 +22,7 @@ code: *std.ArrayList(u8), | ... | @@ -21,7 +22,7 @@ code: *std.ArrayList(u8), |
| 21 | /// List of allocated locals. | 22 | /// List of allocated locals. |
| 22 | locals: []const u8, | 23 | locals: []const u8, |
| 23 | /// The declaration that code is being generated for. | 24 | /// The declaration that code is being generated for. |
| 24 | decl_index: Module.Decl.Index, | 25 | decl_index: InternPool.DeclIndex, |
| 25 | 26 | ||
| 26 | // Debug information | 27 | // Debug information |
| 27 | /// Holds the debug information for this emission | 28 | /// Holds the debug information for this emission |
src/arch/x86_64/CodeGen.zig+3-3| ... | @@ -121,7 +121,7 @@ const Owner = union(enum) { | ... | @@ -121,7 +121,7 @@ const Owner = union(enum) { |
| 121 | func_index: InternPool.Index, | 121 | func_index: InternPool.Index, |
| 122 | lazy_sym: link.File.LazySymbol, | 122 | lazy_sym: link.File.LazySymbol, |
| 123 | 123 | ||
| 124 | fn getDecl(owner: Owner, mod: *Module) Module.Decl.Index { | 124 | fn getDecl(owner: Owner, mod: *Module) InternPool.DeclIndex { |
| 125 | return switch (owner) { | 125 | return switch (owner) { |
| 126 | .func_index => |func_index| mod.funcOwnerDeclIndex(func_index), | 126 | .func_index => |func_index| mod.funcOwnerDeclIndex(func_index), |
| 127 | .lazy_sym => |lazy_sym| lazy_sym.ty.getOwnerDecl(mod), | 127 | .lazy_sym => |lazy_sym| lazy_sym.ty.getOwnerDecl(mod), |
| ... | @@ -1048,7 +1048,7 @@ pub fn generateLazy( | ... | @@ -1048,7 +1048,7 @@ pub fn generateLazy( |
| 1048 | 1048 | ||
| 1049 | const FormatDeclData = struct { | 1049 | const FormatDeclData = struct { |
| 1050 | mod: *Module, | 1050 | mod: *Module, |
| 1051 | decl_index: Module.Decl.Index, | 1051 | decl_index: InternPool.DeclIndex, |
| 1052 | }; | 1052 | }; |
| 1053 | fn formatDecl( | 1053 | fn formatDecl( |
| 1054 | data: FormatDeclData, | 1054 | data: FormatDeclData, |
| ... | @@ -1058,7 +1058,7 @@ fn formatDecl( | ... | @@ -1058,7 +1058,7 @@ fn formatDecl( |
| 1058 | ) @TypeOf(writer).Error!void { | 1058 | ) @TypeOf(writer).Error!void { |
| 1059 | try data.mod.declPtr(data.decl_index).renderFullyQualifiedName(data.mod, writer); | 1059 | try data.mod.declPtr(data.decl_index).renderFullyQualifiedName(data.mod, writer); |
| 1060 | } | 1060 | } |
| 1061 | fn fmtDecl(self: *Self, decl_index: Module.Decl.Index) std.fmt.Formatter(formatDecl) { | 1061 | fn fmtDecl(self: *Self, decl_index: InternPool.DeclIndex) std.fmt.Formatter(formatDecl) { |
| 1062 | return .{ .data = .{ | 1062 | return .{ .data = .{ |
| 1063 | .mod = self.bin_file.options.module.?, | 1063 | .mod = self.bin_file.options.module.?, |
| 1064 | .decl_index = decl_index, | 1064 | .decl_index = decl_index, |
src/codegen.zig+4-4| ... | @@ -757,7 +757,7 @@ fn lowerAnonDeclRef( | ... | @@ -757,7 +757,7 @@ fn lowerAnonDeclRef( |
| 757 | fn lowerDeclRef( | 757 | fn lowerDeclRef( |
| 758 | bin_file: *link.File, | 758 | bin_file: *link.File, |
| 759 | src_loc: Module.SrcLoc, | 759 | src_loc: Module.SrcLoc, |
| 760 | decl_index: Module.Decl.Index, | 760 | decl_index: InternPool.DeclIndex, |
| 761 | code: *std.ArrayList(u8), | 761 | code: *std.ArrayList(u8), |
| 762 | debug_output: DebugInfoOutput, | 762 | debug_output: DebugInfoOutput, |
| 763 | reloc_info: RelocInfo, | 763 | reloc_info: RelocInfo, |
| ... | @@ -853,7 +853,7 @@ fn genDeclRef( | ... | @@ -853,7 +853,7 @@ fn genDeclRef( |
| 853 | bin_file: *link.File, | 853 | bin_file: *link.File, |
| 854 | src_loc: Module.SrcLoc, | 854 | src_loc: Module.SrcLoc, |
| 855 | tv: TypedValue, | 855 | tv: TypedValue, |
| 856 | ptr_decl_index: Module.Decl.Index, | 856 | ptr_decl_index: InternPool.DeclIndex, |
| 857 | ) CodeGenError!GenResult { | 857 | ) CodeGenError!GenResult { |
| 858 | const mod = bin_file.options.module.?; | 858 | const mod = bin_file.options.module.?; |
| 859 | log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) }); | 859 | log.debug("genDeclRef: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) }); |
| ... | @@ -959,7 +959,7 @@ fn genUnnamedConst( | ... | @@ -959,7 +959,7 @@ fn genUnnamedConst( |
| 959 | bin_file: *link.File, | 959 | bin_file: *link.File, |
| 960 | src_loc: Module.SrcLoc, | 960 | src_loc: Module.SrcLoc, |
| 961 | tv: TypedValue, | 961 | tv: TypedValue, |
| 962 | owner_decl_index: Module.Decl.Index, | 962 | owner_decl_index: InternPool.DeclIndex, |
| 963 | ) CodeGenError!GenResult { | 963 | ) CodeGenError!GenResult { |
| 964 | const mod = bin_file.options.module.?; | 964 | const mod = bin_file.options.module.?; |
| 965 | log.debug("genUnnamedConst: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) }); | 965 | log.debug("genUnnamedConst: ty = {}, val = {}", .{ tv.ty.fmt(mod), tv.val.fmtValue(tv.ty, mod) }); |
| ... | @@ -987,7 +987,7 @@ pub fn genTypedValue( | ... | @@ -987,7 +987,7 @@ pub fn genTypedValue( |
| 987 | bin_file: *link.File, | 987 | bin_file: *link.File, |
| 988 | src_loc: Module.SrcLoc, | 988 | src_loc: Module.SrcLoc, |
| 989 | arg_tv: TypedValue, | 989 | arg_tv: TypedValue, |
| 990 | owner_decl_index: Module.Decl.Index, | 990 | owner_decl_index: InternPool.DeclIndex, |
| 991 | ) CodeGenError!GenResult { | 991 | ) CodeGenError!GenResult { |
| 992 | const mod = bin_file.options.module.?; | 992 | const mod = bin_file.options.module.?; |
| 993 | const typed_value = arg_tv; | 993 | const typed_value = arg_tv; |
src/codegen/c.zig+10-10| ... | @@ -39,8 +39,8 @@ pub const CValue = union(enum) { | ... | @@ -39,8 +39,8 @@ pub const CValue = union(enum) { |
| 39 | /// Index into a tuple's fields | 39 | /// Index into a tuple's fields |
| 40 | field: usize, | 40 | field: usize, |
| 41 | /// By-value | 41 | /// By-value |
| 42 | decl: Decl.Index, | 42 | decl: InternPool.DeclIndex, |
| 43 | decl_ref: Decl.Index, | 43 | decl_ref: InternPool.DeclIndex, |
| 44 | /// An undefined value (cannot be dereferenced) | 44 | /// An undefined value (cannot be dereferenced) |
| 45 | undef: Type, | 45 | undef: Type, |
| 46 | /// Render the slice as an identifier (using fmtIdent) | 46 | /// Render the slice as an identifier (using fmtIdent) |
| ... | @@ -57,9 +57,9 @@ const BlockData = struct { | ... | @@ -57,9 +57,9 @@ const BlockData = struct { |
| 57 | pub const CValueMap = std.AutoHashMap(Air.Inst.Ref, CValue); | 57 | pub const CValueMap = std.AutoHashMap(Air.Inst.Ref, CValue); |
| 58 | 58 | ||
| 59 | pub const LazyFnKey = union(enum) { | 59 | pub const LazyFnKey = union(enum) { |
| 60 | tag_name: Decl.Index, | 60 | tag_name: InternPool.DeclIndex, |
| 61 | never_tail: Decl.Index, | 61 | never_tail: InternPool.DeclIndex, |
| 62 | never_inline: Decl.Index, | 62 | never_inline: InternPool.DeclIndex, |
| 63 | }; | 63 | }; |
| 64 | pub const LazyFnValue = struct { | 64 | pub const LazyFnValue = struct { |
| 65 | fn_name: []const u8, | 65 | fn_name: []const u8, |
| ... | @@ -534,7 +534,7 @@ pub const DeclGen = struct { | ... | @@ -534,7 +534,7 @@ pub const DeclGen = struct { |
| 534 | aligned_anon_decls: std.AutoArrayHashMapUnmanaged(InternPool.Index, Alignment), | 534 | aligned_anon_decls: std.AutoArrayHashMapUnmanaged(InternPool.Index, Alignment), |
| 535 | 535 | ||
| 536 | pub const Pass = union(enum) { | 536 | pub const Pass = union(enum) { |
| 537 | decl: Decl.Index, | 537 | decl: InternPool.DeclIndex, |
| 538 | anon: InternPool.Index, | 538 | anon: InternPool.Index, |
| 539 | flush, | 539 | flush, |
| 540 | }; | 540 | }; |
| ... | @@ -624,7 +624,7 @@ pub const DeclGen = struct { | ... | @@ -624,7 +624,7 @@ pub const DeclGen = struct { |
| 624 | writer: anytype, | 624 | writer: anytype, |
| 625 | ty: Type, | 625 | ty: Type, |
| 626 | val: Value, | 626 | val: Value, |
| 627 | decl_index: Decl.Index, | 627 | decl_index: InternPool.DeclIndex, |
| 628 | location: ValueRenderLocation, | 628 | location: ValueRenderLocation, |
| 629 | ) error{ OutOfMemory, AnalysisFail }!void { | 629 | ) error{ OutOfMemory, AnalysisFail }!void { |
| 630 | const mod = dg.module; | 630 | const mod = dg.module; |
| ... | @@ -1585,7 +1585,7 @@ pub const DeclGen = struct { | ... | @@ -1585,7 +1585,7 @@ pub const DeclGen = struct { |
| 1585 | fn renderFunctionSignature( | 1585 | fn renderFunctionSignature( |
| 1586 | dg: *DeclGen, | 1586 | dg: *DeclGen, |
| 1587 | w: anytype, | 1587 | w: anytype, |
| 1588 | fn_decl_index: Decl.Index, | 1588 | fn_decl_index: InternPool.DeclIndex, |
| 1589 | kind: CType.Kind, | 1589 | kind: CType.Kind, |
| 1590 | name: union(enum) { | 1590 | name: union(enum) { |
| 1591 | export_index: u32, | 1591 | export_index: u32, |
| ... | @@ -1926,7 +1926,7 @@ pub const DeclGen = struct { | ... | @@ -1926,7 +1926,7 @@ pub const DeclGen = struct { |
| 1926 | try dg.writeCValue(writer, member); | 1926 | try dg.writeCValue(writer, member); |
| 1927 | } | 1927 | } |
| 1928 | 1928 | ||
| 1929 | fn renderFwdDecl(dg: *DeclGen, decl_index: Decl.Index, variable: InternPool.Key.Variable) !void { | 1929 | fn renderFwdDecl(dg: *DeclGen, decl_index: InternPool.DeclIndex, variable: InternPool.Key.Variable) !void { |
| 1930 | const decl = dg.module.declPtr(decl_index); | 1930 | const decl = dg.module.declPtr(decl_index); |
| 1931 | const fwd = dg.fwd_decl.writer(); | 1931 | const fwd = dg.fwd_decl.writer(); |
| 1932 | const is_global = dg.declIsGlobal(.{ .ty = decl.ty, .val = decl.val }) or variable.is_extern; | 1932 | const is_global = dg.declIsGlobal(.{ .ty = decl.ty, .val = decl.val }) or variable.is_extern; |
| ... | @@ -1948,7 +1948,7 @@ pub const DeclGen = struct { | ... | @@ -1948,7 +1948,7 @@ pub const DeclGen = struct { |
| 1948 | try fwd.writeAll(";\n"); | 1948 | try fwd.writeAll(";\n"); |
| 1949 | } | 1949 | } |
| 1950 | 1950 | ||
| 1951 | fn renderDeclName(dg: *DeclGen, writer: anytype, decl_index: Decl.Index, export_index: u32) !void { | 1951 | fn renderDeclName(dg: *DeclGen, writer: anytype, decl_index: InternPool.DeclIndex, export_index: u32) !void { |
| 1952 | const mod = dg.module; | 1952 | const mod = dg.module; |
| 1953 | const decl = mod.declPtr(decl_index); | 1953 | const decl = mod.declPtr(decl_index); |
| 1954 | try mod.markDeclAlive(decl); | 1954 | try mod.markDeclAlive(decl); |
src/codegen/c/type.zig+3-2| ... | @@ -7,6 +7,7 @@ const Target = std.Target; | ... | @@ -7,6 +7,7 @@ const Target = std.Target; |
| 7 | 7 | ||
| 8 | const Alignment = @import("../../InternPool.zig").Alignment; | 8 | const Alignment = @import("../../InternPool.zig").Alignment; |
| 9 | const Module = @import("../../Module.zig"); | 9 | const Module = @import("../../Module.zig"); |
| 10 | const InternPool = @import("../../InternPool.zig"); | ||
| 10 | const Type = @import("../../type.zig").Type; | 11 | const Type = @import("../../type.zig").Type; |
| 11 | 12 | ||
| 12 | pub const CType = extern union { | 13 | pub const CType = extern union { |
| ... | @@ -238,7 +239,7 @@ pub const CType = extern union { | ... | @@ -238,7 +239,7 @@ pub const CType = extern union { |
| 238 | 239 | ||
| 239 | pub const FwdDecl = struct { | 240 | pub const FwdDecl = struct { |
| 240 | base: Payload, | 241 | base: Payload, |
| 241 | data: Module.Decl.Index, | 242 | data: InternPool.DeclIndex, |
| 242 | }; | 243 | }; |
| 243 | 244 | ||
| 244 | pub const Fields = struct { | 245 | pub const Fields = struct { |
| ... | @@ -257,7 +258,7 @@ pub const CType = extern union { | ... | @@ -257,7 +258,7 @@ pub const CType = extern union { |
| 257 | base: Payload, | 258 | base: Payload, |
| 258 | data: struct { | 259 | data: struct { |
| 259 | fields: Fields.Data, | 260 | fields: Fields.Data, |
| 260 | owner_decl: Module.Decl.Index, | 261 | owner_decl: InternPool.DeclIndex, |
| 261 | id: u32, | 262 | id: u32, |
| 262 | }, | 263 | }, |
| 263 | }; | 264 | }; |
src/codegen/llvm.zig+12-12| ... | @@ -809,11 +809,11 @@ pub const Object = struct { | ... | @@ -809,11 +809,11 @@ pub const Object = struct { |
| 809 | /// version of the name and incorrectly get function not found in the llvm module. | 809 | /// version of the name and incorrectly get function not found in the llvm module. |
| 810 | /// * it works for functions not all globals. | 810 | /// * it works for functions not all globals. |
| 811 | /// Therefore, this table keeps track of the mapping. | 811 | /// Therefore, this table keeps track of the mapping. |
| 812 | decl_map: std.AutoHashMapUnmanaged(Module.Decl.Index, Builder.Global.Index), | 812 | decl_map: std.AutoHashMapUnmanaged(InternPool.DeclIndex, Builder.Global.Index), |
| 813 | /// Same deal as `decl_map` but for anonymous declarations, which are always global constants. | 813 | /// Same deal as `decl_map` but for anonymous declarations, which are always global constants. |
| 814 | anon_decl_map: std.AutoHashMapUnmanaged(InternPool.Index, Builder.Global.Index), | 814 | anon_decl_map: std.AutoHashMapUnmanaged(InternPool.Index, Builder.Global.Index), |
| 815 | /// Serves the same purpose as `decl_map` but only used for the `is_named_enum_value` instruction. | 815 | /// Serves the same purpose as `decl_map` but only used for the `is_named_enum_value` instruction. |
| 816 | named_enum_map: std.AutoHashMapUnmanaged(Module.Decl.Index, Builder.Function.Index), | 816 | named_enum_map: std.AutoHashMapUnmanaged(InternPool.DeclIndex, Builder.Function.Index), |
| 817 | /// Maps Zig types to LLVM types. The table memory is backed by the GPA of | 817 | /// Maps Zig types to LLVM types. The table memory is backed by the GPA of |
| 818 | /// the compiler. | 818 | /// the compiler. |
| 819 | /// TODO when InternPool garbage collection is implemented, this map needs | 819 | /// TODO when InternPool garbage collection is implemented, this map needs |
| ... | @@ -827,7 +827,7 @@ pub const Object = struct { | ... | @@ -827,7 +827,7 @@ pub const Object = struct { |
| 827 | /// This map is usually very close to empty. It tracks only the cases when a | 827 | /// This map is usually very close to empty. It tracks only the cases when a |
| 828 | /// second extern Decl could not be emitted with the correct name due to a | 828 | /// second extern Decl could not be emitted with the correct name due to a |
| 829 | /// name collision. | 829 | /// name collision. |
| 830 | extern_collisions: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, void), | 830 | extern_collisions: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, void), |
| 831 | 831 | ||
| 832 | /// Memoizes a null `?usize` value. | 832 | /// Memoizes a null `?usize` value. |
| 833 | null_opt_usize: Builder.Constant, | 833 | null_opt_usize: Builder.Constant, |
| ... | @@ -1660,7 +1660,7 @@ pub const Object = struct { | ... | @@ -1660,7 +1660,7 @@ pub const Object = struct { |
| 1660 | try o.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); | 1660 | try o.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); |
| 1661 | } | 1661 | } |
| 1662 | 1662 | ||
| 1663 | pub fn updateDecl(self: *Object, module: *Module, decl_index: Module.Decl.Index) !void { | 1663 | pub fn updateDecl(self: *Object, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1664 | const decl = module.declPtr(decl_index); | 1664 | const decl = module.declPtr(decl_index); |
| 1665 | var dg: DeclGen = .{ | 1665 | var dg: DeclGen = .{ |
| 1666 | .object = self, | 1666 | .object = self, |
| ... | @@ -1893,7 +1893,7 @@ pub const Object = struct { | ... | @@ -1893,7 +1893,7 @@ pub const Object = struct { |
| 1893 | } | 1893 | } |
| 1894 | } | 1894 | } |
| 1895 | 1895 | ||
| 1896 | pub fn freeDecl(self: *Object, decl_index: Module.Decl.Index) void { | 1896 | pub fn freeDecl(self: *Object, decl_index: InternPool.DeclIndex) void { |
| 1897 | const global = self.decl_map.get(decl_index) orelse return; | 1897 | const global = self.decl_map.get(decl_index) orelse return; |
| 1898 | global.delete(&self.builder); | 1898 | global.delete(&self.builder); |
| 1899 | } | 1899 | } |
| ... | @@ -2860,7 +2860,7 @@ pub const Object = struct { | ... | @@ -2860,7 +2860,7 @@ pub const Object = struct { |
| 2860 | } | 2860 | } |
| 2861 | } | 2861 | } |
| 2862 | 2862 | ||
| 2863 | fn namespaceToDebugScope(o: *Object, namespace_index: Module.Namespace.Index) !*llvm.DIScope { | 2863 | fn namespaceToDebugScope(o: *Object, namespace_index: InternPool.NamespaceIndex) !*llvm.DIScope { |
| 2864 | const mod = o.module; | 2864 | const mod = o.module; |
| 2865 | const namespace = mod.namespacePtr(namespace_index); | 2865 | const namespace = mod.namespacePtr(namespace_index); |
| 2866 | if (namespace.parent == .none) { | 2866 | if (namespace.parent == .none) { |
| ... | @@ -2874,7 +2874,7 @@ pub const Object = struct { | ... | @@ -2874,7 +2874,7 @@ pub const Object = struct { |
| 2874 | /// This is to be used instead of void for debug info types, to avoid tripping | 2874 | /// This is to be used instead of void for debug info types, to avoid tripping |
| 2875 | /// Assertion `!isa<DIType>(Scope) && "shouldn't make a namespace scope for a type"' | 2875 | /// Assertion `!isa<DIType>(Scope) && "shouldn't make a namespace scope for a type"' |
| 2876 | /// when targeting CodeView (Windows). | 2876 | /// when targeting CodeView (Windows). |
| 2877 | fn makeEmptyNamespaceDIType(o: *Object, decl_index: Module.Decl.Index) !*llvm.DIType { | 2877 | fn makeEmptyNamespaceDIType(o: *Object, decl_index: InternPool.DeclIndex) !*llvm.DIType { |
| 2878 | const mod = o.module; | 2878 | const mod = o.module; |
| 2879 | const decl = mod.declPtr(decl_index); | 2879 | const decl = mod.declPtr(decl_index); |
| 2880 | const fields: [0]*llvm.DIType = .{}; | 2880 | const fields: [0]*llvm.DIType = .{}; |
| ... | @@ -2932,7 +2932,7 @@ pub const Object = struct { | ... | @@ -2932,7 +2932,7 @@ pub const Object = struct { |
| 2932 | /// completed, so if any attributes rely on that, they must be done in updateFunc, not here. | 2932 | /// completed, so if any attributes rely on that, they must be done in updateFunc, not here. |
| 2933 | fn resolveLlvmFunction( | 2933 | fn resolveLlvmFunction( |
| 2934 | o: *Object, | 2934 | o: *Object, |
| 2935 | decl_index: Module.Decl.Index, | 2935 | decl_index: InternPool.DeclIndex, |
| 2936 | ) Allocator.Error!Builder.Function.Index { | 2936 | ) Allocator.Error!Builder.Function.Index { |
| 2937 | const mod = o.module; | 2937 | const mod = o.module; |
| 2938 | const ip = &mod.intern_pool; | 2938 | const ip = &mod.intern_pool; |
| ... | @@ -3152,7 +3152,7 @@ pub const Object = struct { | ... | @@ -3152,7 +3152,7 @@ pub const Object = struct { |
| 3152 | 3152 | ||
| 3153 | fn resolveGlobalDecl( | 3153 | fn resolveGlobalDecl( |
| 3154 | o: *Object, | 3154 | o: *Object, |
| 3155 | decl_index: Module.Decl.Index, | 3155 | decl_index: InternPool.DeclIndex, |
| 3156 | ) Allocator.Error!Builder.Variable.Index { | 3156 | ) Allocator.Error!Builder.Variable.Index { |
| 3157 | const gop = try o.decl_map.getOrPut(o.gpa, decl_index); | 3157 | const gop = try o.decl_map.getOrPut(o.gpa, decl_index); |
| 3158 | if (gop.found_existing) return gop.value_ptr.ptr(&o.builder).kind.variable; | 3158 | if (gop.found_existing) return gop.value_ptr.ptr(&o.builder).kind.variable; |
| ... | @@ -4330,7 +4330,7 @@ pub const Object = struct { | ... | @@ -4330,7 +4330,7 @@ pub const Object = struct { |
| 4330 | return o.builder.bigIntConst(try o.builder.intType(ty.intInfo(mod).bits), bigint); | 4330 | return o.builder.bigIntConst(try o.builder.intType(ty.intInfo(mod).bits), bigint); |
| 4331 | } | 4331 | } |
| 4332 | 4332 | ||
| 4333 | fn lowerParentPtrDecl(o: *Object, decl_index: Module.Decl.Index) Allocator.Error!Builder.Constant { | 4333 | fn lowerParentPtrDecl(o: *Object, decl_index: InternPool.DeclIndex) Allocator.Error!Builder.Constant { |
| 4334 | const mod = o.module; | 4334 | const mod = o.module; |
| 4335 | const decl = mod.declPtr(decl_index); | 4335 | const decl = mod.declPtr(decl_index); |
| 4336 | try mod.markDeclAlive(decl); | 4336 | try mod.markDeclAlive(decl); |
| ... | @@ -4505,7 +4505,7 @@ pub const Object = struct { | ... | @@ -4505,7 +4505,7 @@ pub const Object = struct { |
| 4505 | } else .unneeded, llvm_val, try o.lowerType(ptr_ty)); | 4505 | } else .unneeded, llvm_val, try o.lowerType(ptr_ty)); |
| 4506 | } | 4506 | } |
| 4507 | 4507 | ||
| 4508 | fn lowerDeclRefValue(o: *Object, ty: Type, decl_index: Module.Decl.Index) Allocator.Error!Builder.Constant { | 4508 | fn lowerDeclRefValue(o: *Object, ty: Type, decl_index: InternPool.DeclIndex) Allocator.Error!Builder.Constant { |
| 4509 | const mod = o.module; | 4509 | const mod = o.module; |
| 4510 | 4510 | ||
| 4511 | // In the case of something like: | 4511 | // In the case of something like: |
| ... | @@ -4653,7 +4653,7 @@ pub const Object = struct { | ... | @@ -4653,7 +4653,7 @@ pub const Object = struct { |
| 4653 | pub const DeclGen = struct { | 4653 | pub const DeclGen = struct { |
| 4654 | object: *Object, | 4654 | object: *Object, |
| 4655 | decl: *Module.Decl, | 4655 | decl: *Module.Decl, |
| 4656 | decl_index: Module.Decl.Index, | 4656 | decl_index: InternPool.DeclIndex, |
| 4657 | err_msg: ?*Module.ErrorMsg, | 4657 | err_msg: ?*Module.ErrorMsg, |
| 4658 | 4658 | ||
| 4659 | fn todo(dg: *DeclGen, comptime format: []const u8, args: anytype) Error { | 4659 | fn todo(dg: *DeclGen, comptime format: []const u8, args: anytype) Error { |
src/codegen/spirv.zig+6-6| ... | @@ -156,7 +156,7 @@ pub const Object = struct { | ... | @@ -156,7 +156,7 @@ pub const Object = struct { |
| 156 | 156 | ||
| 157 | /// The Zig module that this object file is generated for. | 157 | /// The Zig module that this object file is generated for. |
| 158 | /// A map of Zig decl indices to SPIR-V decl indices. | 158 | /// A map of Zig decl indices to SPIR-V decl indices. |
| 159 | decl_link: std.AutoHashMapUnmanaged(Decl.Index, SpvModule.Decl.Index) = .{}, | 159 | decl_link: std.AutoHashMapUnmanaged(InternPool.DeclIndex, SpvModule.Decl.Index) = .{}, |
| 160 | 160 | ||
| 161 | /// A map of Zig InternPool indices for anonymous decls to SPIR-V decl indices. | 161 | /// A map of Zig InternPool indices for anonymous decls to SPIR-V decl indices. |
| 162 | anon_decl_link: std.AutoHashMapUnmanaged(struct { InternPool.Index, StorageClass }, SpvModule.Decl.Index) = .{}, | 162 | anon_decl_link: std.AutoHashMapUnmanaged(struct { InternPool.Index, StorageClass }, SpvModule.Decl.Index) = .{}, |
| ... | @@ -187,7 +187,7 @@ pub const Object = struct { | ... | @@ -187,7 +187,7 @@ pub const Object = struct { |
| 187 | fn genDecl( | 187 | fn genDecl( |
| 188 | self: *Object, | 188 | self: *Object, |
| 189 | mod: *Module, | 189 | mod: *Module, |
| 190 | decl_index: Decl.Index, | 190 | decl_index: InternPool.DeclIndex, |
| 191 | air: Air, | 191 | air: Air, |
| 192 | liveness: Liveness, | 192 | liveness: Liveness, |
| 193 | ) !void { | 193 | ) !void { |
| ... | @@ -247,14 +247,14 @@ pub const Object = struct { | ... | @@ -247,14 +247,14 @@ pub const Object = struct { |
| 247 | pub fn updateDecl( | 247 | pub fn updateDecl( |
| 248 | self: *Object, | 248 | self: *Object, |
| 249 | mod: *Module, | 249 | mod: *Module, |
| 250 | decl_index: Decl.Index, | 250 | decl_index: InternPool.DeclIndex, |
| 251 | ) !void { | 251 | ) !void { |
| 252 | try self.genDecl(mod, decl_index, undefined, undefined); | 252 | try self.genDecl(mod, decl_index, undefined, undefined); |
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | /// Fetch or allocate a result id for decl index. This function also marks the decl as alive. | 255 | /// Fetch or allocate a result id for decl index. This function also marks the decl as alive. |
| 256 | /// Note: Function does not actually generate the decl, it just allocates an index. | 256 | /// Note: Function does not actually generate the decl, it just allocates an index. |
| 257 | pub fn resolveDecl(self: *Object, mod: *Module, decl_index: Decl.Index) !SpvModule.Decl.Index { | 257 | pub fn resolveDecl(self: *Object, mod: *Module, decl_index: InternPool.DeclIndex) !SpvModule.Decl.Index { |
| 258 | const decl = mod.declPtr(decl_index); | 258 | const decl = mod.declPtr(decl_index); |
| 259 | try mod.markDeclAlive(decl); | 259 | try mod.markDeclAlive(decl); |
| 260 | 260 | ||
| ... | @@ -289,7 +289,7 @@ const DeclGen = struct { | ... | @@ -289,7 +289,7 @@ const DeclGen = struct { |
| 289 | spv: *SpvModule, | 289 | spv: *SpvModule, |
| 290 | 290 | ||
| 291 | /// The decl we are currently generating code for. | 291 | /// The decl we are currently generating code for. |
| 292 | decl_index: Decl.Index, | 292 | decl_index: InternPool.DeclIndex, |
| 293 | 293 | ||
| 294 | /// The intermediate code of the declaration we are currently generating. Note: If | 294 | /// The intermediate code of the declaration we are currently generating. Note: If |
| 295 | /// the declaration is not a function, this value will be undefined! | 295 | /// the declaration is not a function, this value will be undefined! |
| ... | @@ -1115,7 +1115,7 @@ const DeclGen = struct { | ... | @@ -1115,7 +1115,7 @@ const DeclGen = struct { |
| 1115 | } | 1115 | } |
| 1116 | } | 1116 | } |
| 1117 | 1117 | ||
| 1118 | fn constantDeclRef(self: *DeclGen, ty: Type, decl_index: Decl.Index) !IdRef { | 1118 | fn constantDeclRef(self: *DeclGen, ty: Type, decl_index: InternPool.DeclIndex) !IdRef { |
| 1119 | const mod = self.module; | 1119 | const mod = self.module; |
| 1120 | const ty_ref = try self.resolveType(ty, .direct); | 1120 | const ty_ref = try self.resolveType(ty, .direct); |
| 1121 | const ty_id = self.typeId(ty_ref); | 1121 | const ty_id = self.typeId(ty_ref); |
src/link.zig+9-9| ... | @@ -552,7 +552,7 @@ pub const File = struct { | ... | @@ -552,7 +552,7 @@ pub const File = struct { |
| 552 | /// Called from within the CodeGen to lower a local variable instantion as an unnamed | 552 | /// Called from within the CodeGen to lower a local variable instantion as an unnamed |
| 553 | /// constant. Returns the symbol index of the lowered constant in the read-only section | 553 | /// constant. Returns the symbol index of the lowered constant in the read-only section |
| 554 | /// of the final binary. | 554 | /// of the final binary. |
| 555 | pub fn lowerUnnamedConst(base: *File, tv: TypedValue, decl_index: Module.Decl.Index) UpdateDeclError!u32 { | 555 | pub fn lowerUnnamedConst(base: *File, tv: TypedValue, decl_index: InternPool.DeclIndex) UpdateDeclError!u32 { |
| 556 | if (build_options.only_c) @compileError("unreachable"); | 556 | if (build_options.only_c) @compileError("unreachable"); |
| 557 | switch (base.tag) { | 557 | switch (base.tag) { |
| 558 | // zig fmt: off | 558 | // zig fmt: off |
| ... | @@ -591,7 +591,7 @@ pub const File = struct { | ... | @@ -591,7 +591,7 @@ pub const File = struct { |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | /// May be called before or after updateExports for any given Decl. | 593 | /// May be called before or after updateExports for any given Decl. |
| 594 | pub fn updateDecl(base: *File, module: *Module, decl_index: Module.Decl.Index) UpdateDeclError!void { | 594 | pub fn updateDecl(base: *File, module: *Module, decl_index: InternPool.DeclIndex) UpdateDeclError!void { |
| 595 | const decl = module.declPtr(decl_index); | 595 | const decl = module.declPtr(decl_index); |
| 596 | assert(decl.has_tv); | 596 | assert(decl.has_tv); |
| 597 | if (build_options.only_c) { | 597 | if (build_options.only_c) { |
| ... | @@ -632,7 +632,7 @@ pub const File = struct { | ... | @@ -632,7 +632,7 @@ pub const File = struct { |
| 632 | } | 632 | } |
| 633 | } | 633 | } |
| 634 | 634 | ||
| 635 | pub fn updateDeclLineNumber(base: *File, module: *Module, decl_index: Module.Decl.Index) UpdateDeclError!void { | 635 | pub fn updateDeclLineNumber(base: *File, module: *Module, decl_index: InternPool.DeclIndex) UpdateDeclError!void { |
| 636 | const decl = module.declPtr(decl_index); | 636 | const decl = module.declPtr(decl_index); |
| 637 | assert(decl.has_tv); | 637 | assert(decl.has_tv); |
| 638 | if (build_options.only_c) { | 638 | if (build_options.only_c) { |
| ... | @@ -849,7 +849,7 @@ pub const File = struct { | ... | @@ -849,7 +849,7 @@ pub const File = struct { |
| 849 | } | 849 | } |
| 850 | 850 | ||
| 851 | /// Called when a Decl is deleted from the Module. | 851 | /// Called when a Decl is deleted from the Module. |
| 852 | pub fn freeDecl(base: *File, decl_index: Module.Decl.Index) void { | 852 | pub fn freeDecl(base: *File, decl_index: InternPool.DeclIndex) void { |
| 853 | if (build_options.only_c) { | 853 | if (build_options.only_c) { |
| 854 | assert(base.tag == .c); | 854 | assert(base.tag == .c); |
| 855 | return @fieldParentPtr(C, "base", base).freeDecl(decl_index); | 855 | return @fieldParentPtr(C, "base", base).freeDecl(decl_index); |
| ... | @@ -928,7 +928,7 @@ pub const File = struct { | ... | @@ -928,7 +928,7 @@ pub const File = struct { |
| 928 | /// `Decl`'s address was not yet resolved, or the containing atom gets moved in virtual memory. | 928 | /// `Decl`'s address was not yet resolved, or the containing atom gets moved in virtual memory. |
| 929 | /// May be called before or after updateFunc/updateDecl therefore it is up to the linker to allocate | 929 | /// May be called before or after updateFunc/updateDecl therefore it is up to the linker to allocate |
| 930 | /// the block/atom. | 930 | /// the block/atom. |
| 931 | pub fn getDeclVAddr(base: *File, decl_index: Module.Decl.Index, reloc_info: RelocInfo) !u64 { | 931 | pub fn getDeclVAddr(base: *File, decl_index: InternPool.DeclIndex, reloc_info: RelocInfo) !u64 { |
| 932 | if (build_options.only_c) unreachable; | 932 | if (build_options.only_c) unreachable; |
| 933 | switch (base.tag) { | 933 | switch (base.tag) { |
| 934 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl_index, reloc_info), | 934 | .coff => return @fieldParentPtr(Coff, "base", base).getDeclVAddr(decl_index, reloc_info), |
| ... | @@ -972,7 +972,7 @@ pub const File = struct { | ... | @@ -972,7 +972,7 @@ pub const File = struct { |
| 972 | } | 972 | } |
| 973 | } | 973 | } |
| 974 | 974 | ||
| 975 | pub fn deleteDeclExport(base: *File, decl_index: Module.Decl.Index, name: InternPool.NullTerminatedString) !void { | 975 | pub fn deleteDeclExport(base: *File, decl_index: InternPool.DeclIndex, name: InternPool.NullTerminatedString) !void { |
| 976 | if (build_options.only_c) unreachable; | 976 | if (build_options.only_c) unreachable; |
| 977 | switch (base.tag) { | 977 | switch (base.tag) { |
| 978 | .coff => return @fieldParentPtr(Coff, "base", base).deleteDeclExport(decl_index, name), | 978 | .coff => return @fieldParentPtr(Coff, "base", base).deleteDeclExport(decl_index, name), |
| ... | @@ -1225,15 +1225,15 @@ pub const File = struct { | ... | @@ -1225,15 +1225,15 @@ pub const File = struct { |
| 1225 | kind: Kind, | 1225 | kind: Kind, |
| 1226 | ty: Type, | 1226 | ty: Type, |
| 1227 | 1227 | ||
| 1228 | pub fn initDecl(kind: Kind, decl: ?Module.Decl.Index, mod: *Module) LazySymbol { | 1228 | pub fn initDecl(kind: Kind, decl: ?InternPool.DeclIndex, mod: *Module) LazySymbol { |
| 1229 | return .{ .kind = kind, .ty = if (decl) |decl_index| | 1229 | return .{ .kind = kind, .ty = if (decl) |decl_index| |
| 1230 | mod.declPtr(decl_index).val.toType() | 1230 | mod.declPtr(decl_index).val.toType() |
| 1231 | else | 1231 | else |
| 1232 | Type.anyerror }; | 1232 | Type.anyerror }; |
| 1233 | } | 1233 | } |
| 1234 | 1234 | ||
| 1235 | pub fn getDecl(self: LazySymbol, mod: *Module) Module.Decl.OptionalIndex { | 1235 | pub fn getDecl(self: LazySymbol, mod: *Module) InternPool.OptionalDeclIndex { |
| 1236 | return Module.Decl.OptionalIndex.init(self.ty.getOwnerDeclOrNull(mod)); | 1236 | return InternPool.OptionalDeclIndex.init(self.ty.getOwnerDeclOrNull(mod)); |
| 1237 | } | 1237 | } |
| 1238 | }; | 1238 | }; |
| 1239 | 1239 |
src/link/C.zig+4-4| ... | @@ -24,7 +24,7 @@ base: link.File, | ... | @@ -24,7 +24,7 @@ base: link.File, |
| 24 | /// This linker backend does not try to incrementally link output C source code. | 24 | /// This linker backend does not try to incrementally link output C source code. |
| 25 | /// Instead, it tracks all declarations in this table, and iterates over it | 25 | /// Instead, it tracks all declarations in this table, and iterates over it |
| 26 | /// in the flush function, stitching pre-rendered pieces of C code together. | 26 | /// in the flush function, stitching pre-rendered pieces of C code together. |
| 27 | decl_table: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclBlock) = .{}, | 27 | decl_table: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclBlock) = .{}, |
| 28 | /// All the string bytes of rendered C code, all squished into one array. | 28 | /// All the string bytes of rendered C code, all squished into one array. |
| 29 | /// While in progress, a separate buffer is used, and then when finished, the | 29 | /// While in progress, a separate buffer is used, and then when finished, the |
| 30 | /// buffer is copied into this one. | 30 | /// buffer is copied into this one. |
| ... | @@ -138,7 +138,7 @@ pub fn deinit(self: *C) void { | ... | @@ -138,7 +138,7 @@ pub fn deinit(self: *C) void { |
| 138 | self.code_buf.deinit(gpa); | 138 | self.code_buf.deinit(gpa); |
| 139 | } | 139 | } |
| 140 | 140 | ||
| 141 | pub fn freeDecl(self: *C, decl_index: Module.Decl.Index) void { | 141 | pub fn freeDecl(self: *C, decl_index: InternPool.DeclIndex) void { |
| 142 | const gpa = self.base.allocator; | 142 | const gpa = self.base.allocator; |
| 143 | if (self.decl_table.fetchSwapRemove(decl_index)) |kv| { | 143 | if (self.decl_table.fetchSwapRemove(decl_index)) |kv| { |
| 144 | var decl_block = kv.value; | 144 | var decl_block = kv.value; |
| ... | @@ -279,7 +279,7 @@ fn updateAnonDecl(self: *C, module: *Module, i: usize) !void { | ... | @@ -279,7 +279,7 @@ fn updateAnonDecl(self: *C, module: *Module, i: usize) !void { |
| 279 | }; | 279 | }; |
| 280 | } | 280 | } |
| 281 | 281 | ||
| 282 | pub fn updateDecl(self: *C, module: *Module, decl_index: Module.Decl.Index) !void { | 282 | pub fn updateDecl(self: *C, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 283 | const tracy = trace(@src()); | 283 | const tracy = trace(@src()); |
| 284 | defer tracy.end(); | 284 | defer tracy.end(); |
| 285 | 285 | ||
| ... | @@ -337,7 +337,7 @@ pub fn updateDecl(self: *C, module: *Module, decl_index: Module.Decl.Index) !voi | ... | @@ -337,7 +337,7 @@ pub fn updateDecl(self: *C, module: *Module, decl_index: Module.Decl.Index) !voi |
| 337 | gop.value_ptr.fwd_decl = try self.addString(object.dg.fwd_decl.items); | 337 | gop.value_ptr.fwd_decl = try self.addString(object.dg.fwd_decl.items); |
| 338 | } | 338 | } |
| 339 | 339 | ||
| 340 | pub fn updateDeclLineNumber(self: *C, module: *Module, decl_index: Module.Decl.Index) !void { | 340 | pub fn updateDeclLineNumber(self: *C, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 341 | // The C backend does not have the ability to fix line numbers without re-generating | 341 | // The C backend does not have the ability to fix line numbers without re-generating |
| 342 | // the entire Decl. | 342 | // the entire Decl. |
| 343 | _ = self; | 343 | _ = self; |
src/link/Coff.zig+13-13| ... | @@ -109,11 +109,11 @@ const HotUpdateState = struct { | ... | @@ -109,11 +109,11 @@ const HotUpdateState = struct { |
| 109 | loaded_base_address: ?std.os.windows.HMODULE = null, | 109 | loaded_base_address: ?std.os.windows.HMODULE = null, |
| 110 | }; | 110 | }; |
| 111 | 111 | ||
| 112 | const DeclTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclMetadata); | 112 | const DeclTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata); |
| 113 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); | 113 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); |
| 114 | const RelocTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation)); | 114 | const RelocTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation)); |
| 115 | const BaseRelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32)); | 115 | const BaseRelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32)); |
| 116 | const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index)); | 116 | const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index)); |
| 117 | 117 | ||
| 118 | const default_file_alignment: u16 = 0x200; | 118 | const default_file_alignment: u16 = 0x200; |
| 119 | const default_size_of_stack_reserve: u32 = 0x1000000; | 119 | const default_size_of_stack_reserve: u32 = 0x1000000; |
| ... | @@ -144,7 +144,7 @@ const Section = struct { | ... | @@ -144,7 +144,7 @@ const Section = struct { |
| 144 | free_list: std.ArrayListUnmanaged(Atom.Index) = .{}, | 144 | free_list: std.ArrayListUnmanaged(Atom.Index) = .{}, |
| 145 | }; | 145 | }; |
| 146 | 146 | ||
| 147 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata); | 147 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata); |
| 148 | 148 | ||
| 149 | const LazySymbolMetadata = struct { | 149 | const LazySymbolMetadata = struct { |
| 150 | const State = enum { unused, pending_flush, flushed }; | 150 | const State = enum { unused, pending_flush, flushed }; |
| ... | @@ -1087,7 +1087,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air: | ... | @@ -1087,7 +1087,7 @@ pub fn updateFunc(self: *Coff, mod: *Module, func_index: InternPool.Index, air: |
| 1087 | return self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); | 1087 | return self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); |
| 1088 | } | 1088 | } |
| 1089 | 1089 | ||
| 1090 | pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: Module.Decl.Index) !u32 { | 1090 | pub fn lowerUnnamedConst(self: *Coff, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 { |
| 1091 | const gpa = self.base.allocator; | 1091 | const gpa = self.base.allocator; |
| 1092 | const mod = self.base.options.module.?; | 1092 | const mod = self.base.options.module.?; |
| 1093 | const decl = mod.declPtr(decl_index); | 1093 | const decl = mod.declPtr(decl_index); |
| ... | @@ -1157,7 +1157,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment: | ... | @@ -1157,7 +1157,7 @@ fn lowerConst(self: *Coff, name: []const u8, tv: TypedValue, required_alignment: |
| 1157 | pub fn updateDecl( | 1157 | pub fn updateDecl( |
| 1158 | self: *Coff, | 1158 | self: *Coff, |
| 1159 | mod: *Module, | 1159 | mod: *Module, |
| 1160 | decl_index: Module.Decl.Index, | 1160 | decl_index: InternPool.DeclIndex, |
| 1161 | ) link.File.UpdateDeclError!void { | 1161 | ) link.File.UpdateDeclError!void { |
| 1162 | if (build_options.skip_non_native and builtin.object_format != .coff) { | 1162 | if (build_options.skip_non_native and builtin.object_format != .coff) { |
| 1163 | @panic("Attempted to compile for object format that was disabled by build configuration"); | 1163 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| ... | @@ -1302,7 +1302,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Coff, sym: link.File.LazySymbol) !Ato | ... | @@ -1302,7 +1302,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *Coff, sym: link.File.LazySymbol) !Ato |
| 1302 | return atom; | 1302 | return atom; |
| 1303 | } | 1303 | } |
| 1304 | 1304 | ||
| 1305 | pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: Module.Decl.Index) !Atom.Index { | 1305 | pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: InternPool.DeclIndex) !Atom.Index { |
| 1306 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); | 1306 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); |
| 1307 | if (!gop.found_existing) { | 1307 | if (!gop.found_existing) { |
| 1308 | gop.value_ptr.* = .{ | 1308 | gop.value_ptr.* = .{ |
| ... | @@ -1314,7 +1314,7 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: Module.Decl.Index) !Atom. | ... | @@ -1314,7 +1314,7 @@ pub fn getOrCreateAtomForDecl(self: *Coff, decl_index: Module.Decl.Index) !Atom. |
| 1314 | return gop.value_ptr.atom; | 1314 | return gop.value_ptr.atom; |
| 1315 | } | 1315 | } |
| 1316 | 1316 | ||
| 1317 | fn getDeclOutputSection(self: *Coff, decl_index: Module.Decl.Index) u16 { | 1317 | fn getDeclOutputSection(self: *Coff, decl_index: InternPool.DeclIndex) u16 { |
| 1318 | const decl = self.base.options.module.?.declPtr(decl_index); | 1318 | const decl = self.base.options.module.?.declPtr(decl_index); |
| 1319 | const ty = decl.ty; | 1319 | const ty = decl.ty; |
| 1320 | const mod = self.base.options.module.?; | 1320 | const mod = self.base.options.module.?; |
| ... | @@ -1340,7 +1340,7 @@ fn getDeclOutputSection(self: *Coff, decl_index: Module.Decl.Index) u16 { | ... | @@ -1340,7 +1340,7 @@ fn getDeclOutputSection(self: *Coff, decl_index: Module.Decl.Index) u16 { |
| 1340 | return index; | 1340 | return index; |
| 1341 | } | 1341 | } |
| 1342 | 1342 | ||
| 1343 | fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, complex_type: coff.ComplexType) !void { | 1343 | fn updateDeclCode(self: *Coff, decl_index: InternPool.DeclIndex, code: []u8, complex_type: coff.ComplexType) !void { |
| 1344 | const mod = self.base.options.module.?; | 1344 | const mod = self.base.options.module.?; |
| 1345 | const decl = mod.declPtr(decl_index); | 1345 | const decl = mod.declPtr(decl_index); |
| 1346 | 1346 | ||
| ... | @@ -1398,7 +1398,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple | ... | @@ -1398,7 +1398,7 @@ fn updateDeclCode(self: *Coff, decl_index: Module.Decl.Index, code: []u8, comple |
| 1398 | try self.writeAtom(atom_index, code); | 1398 | try self.writeAtom(atom_index, code); |
| 1399 | } | 1399 | } |
| 1400 | 1400 | ||
| 1401 | fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void { | 1401 | fn freeUnnamedConsts(self: *Coff, decl_index: InternPool.DeclIndex) void { |
| 1402 | const gpa = self.base.allocator; | 1402 | const gpa = self.base.allocator; |
| 1403 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; | 1403 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; |
| 1404 | for (unnamed_consts.items) |atom_index| { | 1404 | for (unnamed_consts.items) |atom_index| { |
| ... | @@ -1407,7 +1407,7 @@ fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void { | ... | @@ -1407,7 +1407,7 @@ fn freeUnnamedConsts(self: *Coff, decl_index: Module.Decl.Index) void { |
| 1407 | unnamed_consts.clearAndFree(gpa); | 1407 | unnamed_consts.clearAndFree(gpa); |
| 1408 | } | 1408 | } |
| 1409 | 1409 | ||
| 1410 | pub fn freeDecl(self: *Coff, decl_index: Module.Decl.Index) void { | 1410 | pub fn freeDecl(self: *Coff, decl_index: InternPool.DeclIndex) void { |
| 1411 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); | 1411 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); |
| 1412 | 1412 | ||
| 1413 | const mod = self.base.options.module.?; | 1413 | const mod = self.base.options.module.?; |
| ... | @@ -1563,7 +1563,7 @@ pub fn updateExports( | ... | @@ -1563,7 +1563,7 @@ pub fn updateExports( |
| 1563 | 1563 | ||
| 1564 | pub fn deleteDeclExport( | 1564 | pub fn deleteDeclExport( |
| 1565 | self: *Coff, | 1565 | self: *Coff, |
| 1566 | decl_index: Module.Decl.Index, | 1566 | decl_index: InternPool.DeclIndex, |
| 1567 | name_ip: InternPool.NullTerminatedString, | 1567 | name_ip: InternPool.NullTerminatedString, |
| 1568 | ) void { | 1568 | ) void { |
| 1569 | if (self.llvm_object) |_| return; | 1569 | if (self.llvm_object) |_| return; |
| ... | @@ -1766,7 +1766,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod | ... | @@ -1766,7 +1766,7 @@ pub fn flushModule(self: *Coff, comp: *Compilation, prog_node: *std.Progress.Nod |
| 1766 | assert(!self.imports_count_dirty); | 1766 | assert(!self.imports_count_dirty); |
| 1767 | } | 1767 | } |
| 1768 | 1768 | ||
| 1769 | pub fn getDeclVAddr(self: *Coff, decl_index: Module.Decl.Index, reloc_info: link.File.RelocInfo) !u64 { | 1769 | pub fn getDeclVAddr(self: *Coff, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 { |
| 1770 | assert(self.llvm_object == null); | 1770 | assert(self.llvm_object == null); |
| 1771 | 1771 | ||
| 1772 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); | 1772 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); |
| ... | @@ -1882,7 +1882,7 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name_name: ?[]const u8 | ... | @@ -1882,7 +1882,7 @@ pub fn getGlobalSymbol(self: *Coff, name: []const u8, lib_name_name: ?[]const u8 |
| 1882 | return global_index; | 1882 | return global_index; |
| 1883 | } | 1883 | } |
| 1884 | 1884 | ||
| 1885 | pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl_index: Module.Decl.Index) !void { | 1885 | pub fn updateDeclLineNumber(self: *Coff, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1886 | _ = self; | 1886 | _ = self; |
| 1887 | _ = module; | 1887 | _ = module; |
| 1888 | _ = decl_index; | 1888 | _ = decl_index; |
src/link/Dwarf.zig+9-9| ... | @@ -35,7 +35,7 @@ di_files: std.AutoArrayHashMapUnmanaged(*const Module.File, void) = .{}, | ... | @@ -35,7 +35,7 @@ di_files: std.AutoArrayHashMapUnmanaged(*const Module.File, void) = .{}, |
| 35 | 35 | ||
| 36 | global_abbrev_relocs: std.ArrayListUnmanaged(AbbrevRelocation) = .{}, | 36 | global_abbrev_relocs: std.ArrayListUnmanaged(AbbrevRelocation) = .{}, |
| 37 | 37 | ||
| 38 | const AtomTable = std.AutoHashMapUnmanaged(Module.Decl.Index, Atom.Index); | 38 | const AtomTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, Atom.Index); |
| 39 | 39 | ||
| 40 | const Atom = struct { | 40 | const Atom = struct { |
| 41 | /// Offset into .debug_info pointing to the tag for this Decl, or | 41 | /// Offset into .debug_info pointing to the tag for this Decl, or |
| ... | @@ -555,7 +555,7 @@ pub const DeclState = struct { | ... | @@ -555,7 +555,7 @@ pub const DeclState = struct { |
| 555 | self: *DeclState, | 555 | self: *DeclState, |
| 556 | name: [:0]const u8, | 556 | name: [:0]const u8, |
| 557 | ty: Type, | 557 | ty: Type, |
| 558 | owner_decl: Module.Decl.Index, | 558 | owner_decl: InternPool.DeclIndex, |
| 559 | loc: DbgInfoLoc, | 559 | loc: DbgInfoLoc, |
| 560 | ) error{OutOfMemory}!void { | 560 | ) error{OutOfMemory}!void { |
| 561 | const dbg_info = &self.dbg_info; | 561 | const dbg_info = &self.dbg_info; |
| ... | @@ -669,7 +669,7 @@ pub const DeclState = struct { | ... | @@ -669,7 +669,7 @@ pub const DeclState = struct { |
| 669 | self: *DeclState, | 669 | self: *DeclState, |
| 670 | name: [:0]const u8, | 670 | name: [:0]const u8, |
| 671 | ty: Type, | 671 | ty: Type, |
| 672 | owner_decl: Module.Decl.Index, | 672 | owner_decl: InternPool.DeclIndex, |
| 673 | is_ptr: bool, | 673 | is_ptr: bool, |
| 674 | loc: DbgInfoLoc, | 674 | loc: DbgInfoLoc, |
| 675 | ) error{OutOfMemory}!void { | 675 | ) error{OutOfMemory}!void { |
| ... | @@ -1073,7 +1073,7 @@ pub fn deinit(self: *Dwarf) void { | ... | @@ -1073,7 +1073,7 @@ pub fn deinit(self: *Dwarf) void { |
| 1073 | 1073 | ||
| 1074 | /// Initializes Decl's state and its matching output buffers. | 1074 | /// Initializes Decl's state and its matching output buffers. |
| 1075 | /// Call this before `commitDeclState`. | 1075 | /// Call this before `commitDeclState`. |
| 1076 | pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !DeclState { | 1076 | pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !DeclState { |
| 1077 | const tracy = trace(@src()); | 1077 | const tracy = trace(@src()); |
| 1078 | defer tracy.end(); | 1078 | defer tracy.end(); |
| 1079 | 1079 | ||
| ... | @@ -1191,7 +1191,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) | ... | @@ -1191,7 +1191,7 @@ pub fn initDeclState(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) |
| 1191 | pub fn commitDeclState( | 1191 | pub fn commitDeclState( |
| 1192 | self: *Dwarf, | 1192 | self: *Dwarf, |
| 1193 | mod: *Module, | 1193 | mod: *Module, |
| 1194 | decl_index: Module.Decl.Index, | 1194 | decl_index: InternPool.DeclIndex, |
| 1195 | sym_addr: u64, | 1195 | sym_addr: u64, |
| 1196 | sym_size: u64, | 1196 | sym_size: u64, |
| 1197 | decl_state: *DeclState, | 1197 | decl_state: *DeclState, |
| ... | @@ -1640,7 +1640,7 @@ fn writeDeclDebugInfo(self: *Dwarf, atom_index: Atom.Index, dbg_info_buf: []cons | ... | @@ -1640,7 +1640,7 @@ fn writeDeclDebugInfo(self: *Dwarf, atom_index: Atom.Index, dbg_info_buf: []cons |
| 1640 | } | 1640 | } |
| 1641 | } | 1641 | } |
| 1642 | 1642 | ||
| 1643 | pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !void { | 1643 | pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1644 | const tracy = trace(@src()); | 1644 | const tracy = trace(@src()); |
| 1645 | defer tracy.end(); | 1645 | defer tracy.end(); |
| 1646 | 1646 | ||
| ... | @@ -1682,7 +1682,7 @@ pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: Module.Decl. | ... | @@ -1682,7 +1682,7 @@ pub fn updateDeclLineNumber(self: *Dwarf, mod: *Module, decl_index: Module.Decl. |
| 1682 | } | 1682 | } |
| 1683 | } | 1683 | } |
| 1684 | 1684 | ||
| 1685 | pub fn freeDecl(self: *Dwarf, decl_index: Module.Decl.Index) void { | 1685 | pub fn freeDecl(self: *Dwarf, decl_index: InternPool.DeclIndex) void { |
| 1686 | const gpa = self.allocator; | 1686 | const gpa = self.allocator; |
| 1687 | 1687 | ||
| 1688 | // Free SrcFn atom | 1688 | // Free SrcFn atom |
| ... | @@ -2627,7 +2627,7 @@ pub fn flushModule(self: *Dwarf, module: *Module) !void { | ... | @@ -2627,7 +2627,7 @@ pub fn flushModule(self: *Dwarf, module: *Module) !void { |
| 2627 | } | 2627 | } |
| 2628 | } | 2628 | } |
| 2629 | 2629 | ||
| 2630 | fn addDIFile(self: *Dwarf, mod: *Module, decl_index: Module.Decl.Index) !u28 { | 2630 | fn addDIFile(self: *Dwarf, mod: *Module, decl_index: InternPool.DeclIndex) !u28 { |
| 2631 | const decl = mod.declPtr(decl_index); | 2631 | const decl = mod.declPtr(decl_index); |
| 2632 | const file_scope = decl.getFileScope(mod); | 2632 | const file_scope = decl.getFileScope(mod); |
| 2633 | const gop = try self.di_files.getOrPut(self.allocator, file_scope); | 2633 | const gop = try self.di_files.getOrPut(self.allocator, file_scope); |
| ... | @@ -2771,7 +2771,7 @@ fn createAtom(self: *Dwarf, comptime kind: Kind) !Atom.Index { | ... | @@ -2771,7 +2771,7 @@ fn createAtom(self: *Dwarf, comptime kind: Kind) !Atom.Index { |
| 2771 | return index; | 2771 | return index; |
| 2772 | } | 2772 | } |
| 2773 | 2773 | ||
| 2774 | fn getOrCreateAtomForDecl(self: *Dwarf, comptime kind: Kind, decl_index: Module.Decl.Index) !Atom.Index { | 2774 | fn getOrCreateAtomForDecl(self: *Dwarf, comptime kind: Kind, decl_index: InternPool.DeclIndex) !Atom.Index { |
| 2775 | switch (kind) { | 2775 | switch (kind) { |
| 2776 | .src_fn => { | 2776 | .src_fn => { |
| 2777 | const gop = try self.src_fn_decls.getOrPut(self.allocator, decl_index); | 2777 | const gop = try self.src_fn_decls.getOrPut(self.allocator, decl_index); |
src/link/Elf.zig+6-6| ... | @@ -400,7 +400,7 @@ pub fn deinit(self: *Elf) void { | ... | @@ -400,7 +400,7 @@ pub fn deinit(self: *Elf) void { |
| 400 | self.comdat_group_sections.deinit(gpa); | 400 | self.comdat_group_sections.deinit(gpa); |
| 401 | } | 401 | } |
| 402 | 402 | ||
| 403 | pub fn getDeclVAddr(self: *Elf, decl_index: Module.Decl.Index, reloc_info: link.File.RelocInfo) !u64 { | 403 | pub fn getDeclVAddr(self: *Elf, decl_index: InternPool.DeclIndex, reloc_info: link.File.RelocInfo) !u64 { |
| 404 | assert(self.llvm_object == null); | 404 | assert(self.llvm_object == null); |
| 405 | return self.zigObjectPtr().?.getDeclVAddr(self, decl_index, reloc_info); | 405 | return self.zigObjectPtr().?.getDeclVAddr(self, decl_index, reloc_info); |
| 406 | } | 406 | } |
| ... | @@ -3127,7 +3127,7 @@ fn writeElfHeader(self: *Elf) !void { | ... | @@ -3127,7 +3127,7 @@ fn writeElfHeader(self: *Elf) !void { |
| 3127 | try self.base.file.?.pwriteAll(hdr_buf[0..index], 0); | 3127 | try self.base.file.?.pwriteAll(hdr_buf[0..index], 0); |
| 3128 | } | 3128 | } |
| 3129 | 3129 | ||
| 3130 | pub fn freeDecl(self: *Elf, decl_index: Module.Decl.Index) void { | 3130 | pub fn freeDecl(self: *Elf, decl_index: InternPool.DeclIndex) void { |
| 3131 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); | 3131 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); |
| 3132 | return self.zigObjectPtr().?.freeDecl(self, decl_index); | 3132 | return self.zigObjectPtr().?.freeDecl(self, decl_index); |
| 3133 | } | 3133 | } |
| ... | @@ -3143,7 +3143,7 @@ pub fn updateFunc(self: *Elf, mod: *Module, func_index: InternPool.Index, air: A | ... | @@ -3143,7 +3143,7 @@ pub fn updateFunc(self: *Elf, mod: *Module, func_index: InternPool.Index, air: A |
| 3143 | pub fn updateDecl( | 3143 | pub fn updateDecl( |
| 3144 | self: *Elf, | 3144 | self: *Elf, |
| 3145 | mod: *Module, | 3145 | mod: *Module, |
| 3146 | decl_index: Module.Decl.Index, | 3146 | decl_index: InternPool.DeclIndex, |
| 3147 | ) link.File.UpdateDeclError!void { | 3147 | ) link.File.UpdateDeclError!void { |
| 3148 | if (build_options.skip_non_native and builtin.object_format != .elf) { | 3148 | if (build_options.skip_non_native and builtin.object_format != .elf) { |
| 3149 | @panic("Attempted to compile for object format that was disabled by build configuration"); | 3149 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| ... | @@ -3152,7 +3152,7 @@ pub fn updateDecl( | ... | @@ -3152,7 +3152,7 @@ pub fn updateDecl( |
| 3152 | return self.zigObjectPtr().?.updateDecl(self, mod, decl_index); | 3152 | return self.zigObjectPtr().?.updateDecl(self, mod, decl_index); |
| 3153 | } | 3153 | } |
| 3154 | 3154 | ||
| 3155 | pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: Module.Decl.Index) !u32 { | 3155 | pub fn lowerUnnamedConst(self: *Elf, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 { |
| 3156 | return self.zigObjectPtr().?.lowerUnnamedConst(self, typed_value, decl_index); | 3156 | return self.zigObjectPtr().?.lowerUnnamedConst(self, typed_value, decl_index); |
| 3157 | } | 3157 | } |
| 3158 | 3158 | ||
| ... | @@ -3170,14 +3170,14 @@ pub fn updateExports( | ... | @@ -3170,14 +3170,14 @@ pub fn updateExports( |
| 3170 | return self.zigObjectPtr().?.updateExports(self, mod, exported, exports); | 3170 | return self.zigObjectPtr().?.updateExports(self, mod, exported, exports); |
| 3171 | } | 3171 | } |
| 3172 | 3172 | ||
| 3173 | pub fn updateDeclLineNumber(self: *Elf, mod: *Module, decl_index: Module.Decl.Index) !void { | 3173 | pub fn updateDeclLineNumber(self: *Elf, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 3174 | if (self.llvm_object) |_| return; | 3174 | if (self.llvm_object) |_| return; |
| 3175 | return self.zigObjectPtr().?.updateDeclLineNumber(mod, decl_index); | 3175 | return self.zigObjectPtr().?.updateDeclLineNumber(mod, decl_index); |
| 3176 | } | 3176 | } |
| 3177 | 3177 | ||
| 3178 | pub fn deleteDeclExport( | 3178 | pub fn deleteDeclExport( |
| 3179 | self: *Elf, | 3179 | self: *Elf, |
| 3180 | decl_index: Module.Decl.Index, | 3180 | decl_index: InternPool.DeclIndex, |
| 3181 | name: InternPool.NullTerminatedString, | 3181 | name: InternPool.NullTerminatedString, |
| 3182 | ) void { | 3182 | ) void { |
| 3183 | if (self.llvm_object) |_| return; | 3183 | if (self.llvm_object) |_| return; |
src/link/Elf/ZigObject.zig+13-13| ... | @@ -618,7 +618,7 @@ pub fn codeAlloc(self: ZigObject, elf_file: *Elf, atom_index: Atom.Index) ![]u8 | ... | @@ -618,7 +618,7 @@ pub fn codeAlloc(self: ZigObject, elf_file: *Elf, atom_index: Atom.Index) ![]u8 |
| 618 | pub fn getDeclVAddr( | 618 | pub fn getDeclVAddr( |
| 619 | self: *ZigObject, | 619 | self: *ZigObject, |
| 620 | elf_file: *Elf, | 620 | elf_file: *Elf, |
| 621 | decl_index: Module.Decl.Index, | 621 | decl_index: InternPool.DeclIndex, |
| 622 | reloc_info: link.File.RelocInfo, | 622 | reloc_info: link.File.RelocInfo, |
| 623 | ) !u64 { | 623 | ) !u64 { |
| 624 | const this_sym_index = try self.getOrCreateMetadataForDecl(elf_file, decl_index); | 624 | const this_sym_index = try self.getOrCreateMetadataForDecl(elf_file, decl_index); |
| ... | @@ -741,7 +741,7 @@ pub fn getOrCreateMetadataForLazySymbol( | ... | @@ -741,7 +741,7 @@ pub fn getOrCreateMetadataForLazySymbol( |
| 741 | return symbol_index; | 741 | return symbol_index; |
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | fn freeUnnamedConsts(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) void { | 744 | fn freeUnnamedConsts(self: *ZigObject, elf_file: *Elf, decl_index: InternPool.DeclIndex) void { |
| 745 | const unnamed_consts = self.unnamed_consts.getPtr(decl_index) orelse return; | 745 | const unnamed_consts = self.unnamed_consts.getPtr(decl_index) orelse return; |
| 746 | for (unnamed_consts.items) |sym_index| { | 746 | for (unnamed_consts.items) |sym_index| { |
| 747 | self.freeDeclMetadata(elf_file, sym_index); | 747 | self.freeDeclMetadata(elf_file, sym_index); |
| ... | @@ -759,7 +759,7 @@ fn freeDeclMetadata(self: *ZigObject, elf_file: *Elf, sym_index: Symbol.Index) v | ... | @@ -759,7 +759,7 @@ fn freeDeclMetadata(self: *ZigObject, elf_file: *Elf, sym_index: Symbol.Index) v |
| 759 | // TODO free GOT entry here | 759 | // TODO free GOT entry here |
| 760 | } | 760 | } |
| 761 | 761 | ||
| 762 | pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) void { | 762 | pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: InternPool.DeclIndex) void { |
| 763 | const mod = elf_file.base.options.module.?; | 763 | const mod = elf_file.base.options.module.?; |
| 764 | const decl = mod.declPtr(decl_index); | 764 | const decl = mod.declPtr(decl_index); |
| 765 | 765 | ||
| ... | @@ -781,7 +781,7 @@ pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) | ... | @@ -781,7 +781,7 @@ pub fn freeDecl(self: *ZigObject, elf_file: *Elf, decl_index: Module.Decl.Index) |
| 781 | pub fn getOrCreateMetadataForDecl( | 781 | pub fn getOrCreateMetadataForDecl( |
| 782 | self: *ZigObject, | 782 | self: *ZigObject, |
| 783 | elf_file: *Elf, | 783 | elf_file: *Elf, |
| 784 | decl_index: Module.Decl.Index, | 784 | decl_index: InternPool.DeclIndex, |
| 785 | ) !Symbol.Index { | 785 | ) !Symbol.Index { |
| 786 | const gop = try self.decls.getOrPut(elf_file.base.allocator, decl_index); | 786 | const gop = try self.decls.getOrPut(elf_file.base.allocator, decl_index); |
| 787 | if (!gop.found_existing) { | 787 | if (!gop.found_existing) { |
| ... | @@ -857,7 +857,7 @@ fn getDeclShdrIndex( | ... | @@ -857,7 +857,7 @@ fn getDeclShdrIndex( |
| 857 | fn updateDeclCode( | 857 | fn updateDeclCode( |
| 858 | self: *ZigObject, | 858 | self: *ZigObject, |
| 859 | elf_file: *Elf, | 859 | elf_file: *Elf, |
| 860 | decl_index: Module.Decl.Index, | 860 | decl_index: InternPool.DeclIndex, |
| 861 | sym_index: Symbol.Index, | 861 | sym_index: Symbol.Index, |
| 862 | shdr_index: u16, | 862 | shdr_index: u16, |
| 863 | code: []const u8, | 863 | code: []const u8, |
| ... | @@ -956,7 +956,7 @@ fn updateDeclCode( | ... | @@ -956,7 +956,7 @@ fn updateDeclCode( |
| 956 | fn updateTlv( | 956 | fn updateTlv( |
| 957 | self: *ZigObject, | 957 | self: *ZigObject, |
| 958 | elf_file: *Elf, | 958 | elf_file: *Elf, |
| 959 | decl_index: Module.Decl.Index, | 959 | decl_index: InternPool.DeclIndex, |
| 960 | sym_index: Symbol.Index, | 960 | sym_index: Symbol.Index, |
| 961 | shndx: u16, | 961 | shndx: u16, |
| 962 | code: []const u8, | 962 | code: []const u8, |
| ... | @@ -1083,7 +1083,7 @@ pub fn updateDecl( | ... | @@ -1083,7 +1083,7 @@ pub fn updateDecl( |
| 1083 | self: *ZigObject, | 1083 | self: *ZigObject, |
| 1084 | elf_file: *Elf, | 1084 | elf_file: *Elf, |
| 1085 | mod: *Module, | 1085 | mod: *Module, |
| 1086 | decl_index: Module.Decl.Index, | 1086 | decl_index: InternPool.DeclIndex, |
| 1087 | ) link.File.UpdateDeclError!void { | 1087 | ) link.File.UpdateDeclError!void { |
| 1088 | const tracy = trace(@src()); | 1088 | const tracy = trace(@src()); |
| 1089 | defer tracy.end(); | 1089 | defer tracy.end(); |
| ... | @@ -1249,7 +1249,7 @@ pub fn lowerUnnamedConst( | ... | @@ -1249,7 +1249,7 @@ pub fn lowerUnnamedConst( |
| 1249 | self: *ZigObject, | 1249 | self: *ZigObject, |
| 1250 | elf_file: *Elf, | 1250 | elf_file: *Elf, |
| 1251 | typed_value: TypedValue, | 1251 | typed_value: TypedValue, |
| 1252 | decl_index: Module.Decl.Index, | 1252 | decl_index: InternPool.DeclIndex, |
| 1253 | ) !u32 { | 1253 | ) !u32 { |
| 1254 | const gpa = elf_file.base.allocator; | 1254 | const gpa = elf_file.base.allocator; |
| 1255 | const mod = elf_file.base.options.module.?; | 1255 | const mod = elf_file.base.options.module.?; |
| ... | @@ -1435,7 +1435,7 @@ pub fn updateExports( | ... | @@ -1435,7 +1435,7 @@ pub fn updateExports( |
| 1435 | pub fn updateDeclLineNumber( | 1435 | pub fn updateDeclLineNumber( |
| 1436 | self: *ZigObject, | 1436 | self: *ZigObject, |
| 1437 | mod: *Module, | 1437 | mod: *Module, |
| 1438 | decl_index: Module.Decl.Index, | 1438 | decl_index: InternPool.DeclIndex, |
| 1439 | ) !void { | 1439 | ) !void { |
| 1440 | const tracy = trace(@src()); | 1440 | const tracy = trace(@src()); |
| 1441 | defer tracy.end(); | 1441 | defer tracy.end(); |
| ... | @@ -1453,7 +1453,7 @@ pub fn updateDeclLineNumber( | ... | @@ -1453,7 +1453,7 @@ pub fn updateDeclLineNumber( |
| 1453 | pub fn deleteDeclExport( | 1453 | pub fn deleteDeclExport( |
| 1454 | self: *ZigObject, | 1454 | self: *ZigObject, |
| 1455 | elf_file: *Elf, | 1455 | elf_file: *Elf, |
| 1456 | decl_index: Module.Decl.Index, | 1456 | decl_index: InternPool.DeclIndex, |
| 1457 | name: InternPool.NullTerminatedString, | 1457 | name: InternPool.NullTerminatedString, |
| 1458 | ) void { | 1458 | ) void { |
| 1459 | const metadata = self.decls.getPtr(decl_index) orelse return; | 1459 | const metadata = self.decls.getPtr(decl_index) orelse return; |
| ... | @@ -1584,10 +1584,10 @@ const TlsVariable = struct { | ... | @@ -1584,10 +1584,10 @@ const TlsVariable = struct { |
| 1584 | }; | 1584 | }; |
| 1585 | 1585 | ||
| 1586 | const AtomList = std.ArrayListUnmanaged(Atom.Index); | 1586 | const AtomList = std.ArrayListUnmanaged(Atom.Index); |
| 1587 | const UnnamedConstTable = std.AutoHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Symbol.Index)); | 1587 | const UnnamedConstTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Symbol.Index)); |
| 1588 | const DeclTable = std.AutoHashMapUnmanaged(Module.Decl.Index, DeclMetadata); | 1588 | const DeclTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata); |
| 1589 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); | 1589 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); |
| 1590 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata); | 1590 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata); |
| 1591 | const TlsTable = std.AutoArrayHashMapUnmanaged(Atom.Index, TlsVariable); | 1591 | const TlsTable = std.AutoArrayHashMapUnmanaged(Atom.Index, TlsVariable); |
| 1592 | 1592 | ||
| 1593 | const assert = std.debug.assert; | 1593 | const assert = std.debug.assert; |
src/link/MachO.zig+14-14| ... | @@ -2278,7 +2278,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air: | ... | @@ -2278,7 +2278,7 @@ pub fn updateFunc(self: *MachO, mod: *Module, func_index: InternPool.Index, air: |
| 2278 | try self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); | 2278 | try self.updateExports(mod, .{ .decl_index = decl_index }, mod.getDeclExports(decl_index)); |
| 2279 | } | 2279 | } |
| 2280 | 2280 | ||
| 2281 | pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: Module.Decl.Index) !u32 { | 2281 | pub fn lowerUnnamedConst(self: *MachO, typed_value: TypedValue, decl_index: InternPool.DeclIndex) !u32 { |
| 2282 | const gpa = self.base.allocator; | 2282 | const gpa = self.base.allocator; |
| 2283 | const mod = self.base.options.module.?; | 2283 | const mod = self.base.options.module.?; |
| 2284 | const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index); | 2284 | const gop = try self.unnamed_const_atoms.getOrPut(gpa, decl_index); |
| ... | @@ -2358,7 +2358,7 @@ fn lowerConst( | ... | @@ -2358,7 +2358,7 @@ fn lowerConst( |
| 2358 | return .{ .ok = atom_index }; | 2358 | return .{ .ok = atom_index }; |
| 2359 | } | 2359 | } |
| 2360 | 2360 | ||
| 2361 | pub fn updateDecl(self: *MachO, mod: *Module, decl_index: Module.Decl.Index) !void { | 2361 | pub fn updateDecl(self: *MachO, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 2362 | if (build_options.skip_non_native and builtin.object_format != .macho) { | 2362 | if (build_options.skip_non_native and builtin.object_format != .macho) { |
| 2363 | @panic("Attempted to compile for object format that was disabled by build configuration"); | 2363 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| 2364 | } | 2364 | } |
| ... | @@ -2544,7 +2544,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.In | ... | @@ -2544,7 +2544,7 @@ pub fn getOrCreateAtomForLazySymbol(self: *MachO, sym: File.LazySymbol) !Atom.In |
| 2544 | return atom; | 2544 | return atom; |
| 2545 | } | 2545 | } |
| 2546 | 2546 | ||
| 2547 | fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.Decl.Index) !void { | 2547 | fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 2548 | const mod = self.base.options.module.?; | 2548 | const mod = self.base.options.module.?; |
| 2549 | // Lowering a TLV on macOS involves two stages: | 2549 | // Lowering a TLV on macOS involves two stages: |
| 2550 | // 1. first we lower the initializer into appopriate section (__thread_data or __thread_bss) | 2550 | // 1. first we lower the initializer into appopriate section (__thread_data or __thread_bss) |
| ... | @@ -2639,7 +2639,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D | ... | @@ -2639,7 +2639,7 @@ fn updateThreadlocalVariable(self: *MachO, module: *Module, decl_index: Module.D |
| 2639 | self.markRelocsDirtyByTarget(init_atom_sym_loc); | 2639 | self.markRelocsDirtyByTarget(init_atom_sym_loc); |
| 2640 | } | 2640 | } |
| 2641 | 2641 | ||
| 2642 | pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: Module.Decl.Index) !Atom.Index { | 2642 | pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: InternPool.DeclIndex) !Atom.Index { |
| 2643 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); | 2643 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); |
| 2644 | if (!gop.found_existing) { | 2644 | if (!gop.found_existing) { |
| 2645 | const sym_index = try self.allocateSymbol(); | 2645 | const sym_index = try self.allocateSymbol(); |
| ... | @@ -2654,7 +2654,7 @@ pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: Module.Decl.Index) !Atom | ... | @@ -2654,7 +2654,7 @@ pub fn getOrCreateAtomForDecl(self: *MachO, decl_index: Module.Decl.Index) !Atom |
| 2654 | return gop.value_ptr.atom; | 2654 | return gop.value_ptr.atom; |
| 2655 | } | 2655 | } |
| 2656 | 2656 | ||
| 2657 | fn getDeclOutputSection(self: *MachO, decl_index: Module.Decl.Index) u8 { | 2657 | fn getDeclOutputSection(self: *MachO, decl_index: InternPool.DeclIndex) u8 { |
| 2658 | const decl = self.base.options.module.?.declPtr(decl_index); | 2658 | const decl = self.base.options.module.?.declPtr(decl_index); |
| 2659 | const ty = decl.ty; | 2659 | const ty = decl.ty; |
| 2660 | const val = decl.val; | 2660 | const val = decl.val; |
| ... | @@ -2693,7 +2693,7 @@ fn getDeclOutputSection(self: *MachO, decl_index: Module.Decl.Index) u8 { | ... | @@ -2693,7 +2693,7 @@ fn getDeclOutputSection(self: *MachO, decl_index: Module.Decl.Index) u8 { |
| 2693 | return sect_id; | 2693 | return sect_id; |
| 2694 | } | 2694 | } |
| 2695 | 2695 | ||
| 2696 | fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64 { | 2696 | fn updateDeclCode(self: *MachO, decl_index: InternPool.DeclIndex, code: []u8) !u64 { |
| 2697 | const gpa = self.base.allocator; | 2697 | const gpa = self.base.allocator; |
| 2698 | const mod = self.base.options.module.?; | 2698 | const mod = self.base.options.module.?; |
| 2699 | const decl = mod.declPtr(decl_index); | 2699 | const decl = mod.declPtr(decl_index); |
| ... | @@ -2764,7 +2764,7 @@ fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64 | ... | @@ -2764,7 +2764,7 @@ fn updateDeclCode(self: *MachO, decl_index: Module.Decl.Index, code: []u8) !u64 |
| 2764 | return atom.getSymbol(self).n_value; | 2764 | return atom.getSymbol(self).n_value; |
| 2765 | } | 2765 | } |
| 2766 | 2766 | ||
| 2767 | pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: Module.Decl.Index) !void { | 2767 | pub fn updateDeclLineNumber(self: *MachO, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 2768 | if (self.d_sym) |*d_sym| { | 2768 | if (self.d_sym) |*d_sym| { |
| 2769 | try d_sym.dwarf.updateDeclLineNumber(module, decl_index); | 2769 | try d_sym.dwarf.updateDeclLineNumber(module, decl_index); |
| 2770 | } | 2770 | } |
| ... | @@ -2906,7 +2906,7 @@ pub fn updateExports( | ... | @@ -2906,7 +2906,7 @@ pub fn updateExports( |
| 2906 | 2906 | ||
| 2907 | pub fn deleteDeclExport( | 2907 | pub fn deleteDeclExport( |
| 2908 | self: *MachO, | 2908 | self: *MachO, |
| 2909 | decl_index: Module.Decl.Index, | 2909 | decl_index: InternPool.DeclIndex, |
| 2910 | name: InternPool.NullTerminatedString, | 2910 | name: InternPool.NullTerminatedString, |
| 2911 | ) Allocator.Error!void { | 2911 | ) Allocator.Error!void { |
| 2912 | if (self.llvm_object) |_| return; | 2912 | if (self.llvm_object) |_| return; |
| ... | @@ -2940,7 +2940,7 @@ pub fn deleteDeclExport( | ... | @@ -2940,7 +2940,7 @@ pub fn deleteDeclExport( |
| 2940 | sym_index.* = 0; | 2940 | sym_index.* = 0; |
| 2941 | } | 2941 | } |
| 2942 | 2942 | ||
| 2943 | fn freeUnnamedConsts(self: *MachO, decl_index: Module.Decl.Index) void { | 2943 | fn freeUnnamedConsts(self: *MachO, decl_index: InternPool.DeclIndex) void { |
| 2944 | const gpa = self.base.allocator; | 2944 | const gpa = self.base.allocator; |
| 2945 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; | 2945 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; |
| 2946 | for (unnamed_consts.items) |atom| { | 2946 | for (unnamed_consts.items) |atom| { |
| ... | @@ -2949,7 +2949,7 @@ fn freeUnnamedConsts(self: *MachO, decl_index: Module.Decl.Index) void { | ... | @@ -2949,7 +2949,7 @@ fn freeUnnamedConsts(self: *MachO, decl_index: Module.Decl.Index) void { |
| 2949 | unnamed_consts.clearAndFree(gpa); | 2949 | unnamed_consts.clearAndFree(gpa); |
| 2950 | } | 2950 | } |
| 2951 | 2951 | ||
| 2952 | pub fn freeDecl(self: *MachO, decl_index: Module.Decl.Index) void { | 2952 | pub fn freeDecl(self: *MachO, decl_index: InternPool.DeclIndex) void { |
| 2953 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); | 2953 | if (self.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); |
| 2954 | const mod = self.base.options.module.?; | 2954 | const mod = self.base.options.module.?; |
| 2955 | const decl = mod.declPtr(decl_index); | 2955 | const decl = mod.declPtr(decl_index); |
| ... | @@ -2968,7 +2968,7 @@ pub fn freeDecl(self: *MachO, decl_index: Module.Decl.Index) void { | ... | @@ -2968,7 +2968,7 @@ pub fn freeDecl(self: *MachO, decl_index: Module.Decl.Index) void { |
| 2968 | } | 2968 | } |
| 2969 | } | 2969 | } |
| 2970 | 2970 | ||
| 2971 | pub fn getDeclVAddr(self: *MachO, decl_index: Module.Decl.Index, reloc_info: File.RelocInfo) !u64 { | 2971 | pub fn getDeclVAddr(self: *MachO, decl_index: InternPool.DeclIndex, reloc_info: File.RelocInfo) !u64 { |
| 2972 | assert(self.llvm_object == null); | 2972 | assert(self.llvm_object == null); |
| 2973 | 2973 | ||
| 2974 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); | 2974 | const this_atom_index = try self.getOrCreateAtomForDecl(decl_index); |
| ... | @@ -5667,7 +5667,7 @@ const is_hot_update_compatible = switch (builtin.target.os.tag) { | ... | @@ -5667,7 +5667,7 @@ const is_hot_update_compatible = switch (builtin.target.os.tag) { |
| 5667 | else => false, | 5667 | else => false, |
| 5668 | }; | 5668 | }; |
| 5669 | 5669 | ||
| 5670 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata); | 5670 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata); |
| 5671 | 5671 | ||
| 5672 | const LazySymbolMetadata = struct { | 5672 | const LazySymbolMetadata = struct { |
| 5673 | const State = enum { unused, pending_flush, flushed }; | 5673 | const State = enum { unused, pending_flush, flushed }; |
| ... | @@ -5701,10 +5701,10 @@ const DeclMetadata = struct { | ... | @@ -5701,10 +5701,10 @@ const DeclMetadata = struct { |
| 5701 | } | 5701 | } |
| 5702 | }; | 5702 | }; |
| 5703 | 5703 | ||
| 5704 | const DeclTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, DeclMetadata); | 5704 | const DeclTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata); |
| 5705 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); | 5705 | const AnonDeclTable = std.AutoHashMapUnmanaged(InternPool.Index, DeclMetadata); |
| 5706 | const BindingTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Atom.Binding)); | 5706 | const BindingTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Atom.Binding)); |
| 5707 | const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index)); | 5707 | const UnnamedConstTable = std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index)); |
| 5708 | const RebaseTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32)); | 5708 | const RebaseTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(u32)); |
| 5709 | const RelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation)); | 5709 | const RelocationTable = std.AutoArrayHashMapUnmanaged(Atom.Index, std.ArrayListUnmanaged(Relocation)); |
| 5710 | const ActionTable = std.AutoHashMapUnmanaged(u32, RelocFlags); | 5710 | const ActionTable = std.AutoHashMapUnmanaged(u32, RelocFlags); |
src/link/NvPtx.zig+2-2| ... | @@ -70,7 +70,7 @@ pub fn updateFunc(self: *NvPtx, module: *Module, func_index: InternPool.Index, a | ... | @@ -70,7 +70,7 @@ pub fn updateFunc(self: *NvPtx, module: *Module, func_index: InternPool.Index, a |
| 70 | try self.llvm_object.updateFunc(module, func_index, air, liveness); | 70 | try self.llvm_object.updateFunc(module, func_index, air, liveness); |
| 71 | } | 71 | } |
| 72 | 72 | ||
| 73 | pub fn updateDecl(self: *NvPtx, module: *Module, decl_index: Module.Decl.Index) !void { | 73 | pub fn updateDecl(self: *NvPtx, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 74 | return self.llvm_object.updateDecl(module, decl_index); | 74 | return self.llvm_object.updateDecl(module, decl_index); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| ... | @@ -86,7 +86,7 @@ pub fn updateExports( | ... | @@ -86,7 +86,7 @@ pub fn updateExports( |
| 86 | return self.llvm_object.updateExports(module, exported, exports); | 86 | return self.llvm_object.updateExports(module, exported, exports); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | pub fn freeDecl(self: *NvPtx, decl_index: Module.Decl.Index) void { | 89 | pub fn freeDecl(self: *NvPtx, decl_index: InternPool.DeclIndex) void { |
| 90 | return self.llvm_object.freeDecl(decl_index); | 90 | return self.llvm_object.freeDecl(decl_index); |
| 91 | } | 91 | } |
| 92 | 92 |
src/link/Plan9.zig+16-16| ... | @@ -56,10 +56,10 @@ path_arena: std.heap.ArenaAllocator, | ... | @@ -56,10 +56,10 @@ path_arena: std.heap.ArenaAllocator, |
| 56 | /// If we group the decls by file, it makes it really easy to do this (put the symbol in the correct place) | 56 | /// If we group the decls by file, it makes it really easy to do this (put the symbol in the correct place) |
| 57 | fn_decl_table: std.AutoArrayHashMapUnmanaged( | 57 | fn_decl_table: std.AutoArrayHashMapUnmanaged( |
| 58 | *Module.File, | 58 | *Module.File, |
| 59 | struct { sym_index: u32, functions: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, FnDeclOutput) = .{} }, | 59 | struct { sym_index: u32, functions: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, FnDeclOutput) = .{} }, |
| 60 | ) = .{}, | 60 | ) = .{}, |
| 61 | /// the code is modified when relocated, so that is why it is mutable | 61 | /// the code is modified when relocated, so that is why it is mutable |
| 62 | data_decl_table: std.AutoArrayHashMapUnmanaged(Module.Decl.Index, []u8) = .{}, | 62 | data_decl_table: std.AutoArrayHashMapUnmanaged(InternPool.DeclIndex, []u8) = .{}, |
| 63 | 63 | ||
| 64 | /// Table of unnamed constants associated with a parent `Decl`. | 64 | /// Table of unnamed constants associated with a parent `Decl`. |
| 65 | /// We store them here so that we can free the constants whenever the `Decl` | 65 | /// We store them here so that we can free the constants whenever the `Decl` |
| ... | @@ -102,7 +102,7 @@ got_index_free_list: std.ArrayListUnmanaged(usize) = .{}, | ... | @@ -102,7 +102,7 @@ got_index_free_list: std.ArrayListUnmanaged(usize) = .{}, |
| 102 | syms_index_free_list: std.ArrayListUnmanaged(usize) = .{}, | 102 | syms_index_free_list: std.ArrayListUnmanaged(usize) = .{}, |
| 103 | 103 | ||
| 104 | atoms: std.ArrayListUnmanaged(Atom) = .{}, | 104 | atoms: std.ArrayListUnmanaged(Atom) = .{}, |
| 105 | decls: std.AutoHashMapUnmanaged(Module.Decl.Index, DeclMetadata) = .{}, | 105 | decls: std.AutoHashMapUnmanaged(InternPool.DeclIndex, DeclMetadata) = .{}, |
| 106 | 106 | ||
| 107 | /// Indices of the three "special" symbols into atoms | 107 | /// Indices of the three "special" symbols into atoms |
| 108 | etext_edata_end_atom_indices: [3]?Atom.Index = .{ null, null, null }, | 108 | etext_edata_end_atom_indices: [3]?Atom.Index = .{ null, null, null }, |
| ... | @@ -129,9 +129,9 @@ const Bases = struct { | ... | @@ -129,9 +129,9 @@ const Bases = struct { |
| 129 | data: u64, | 129 | data: u64, |
| 130 | }; | 130 | }; |
| 131 | 131 | ||
| 132 | const UnnamedConstTable = std.AutoHashMapUnmanaged(Module.Decl.Index, std.ArrayListUnmanaged(Atom.Index)); | 132 | const UnnamedConstTable = std.AutoHashMapUnmanaged(InternPool.DeclIndex, std.ArrayListUnmanaged(Atom.Index)); |
| 133 | 133 | ||
| 134 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(Module.Decl.OptionalIndex, LazySymbolMetadata); | 134 | const LazySymbolTable = std.AutoArrayHashMapUnmanaged(InternPool.OptionalDeclIndex, LazySymbolMetadata); |
| 135 | 135 | ||
| 136 | const LazySymbolMetadata = struct { | 136 | const LazySymbolMetadata = struct { |
| 137 | const State = enum { unused, pending_flush, flushed }; | 137 | const State = enum { unused, pending_flush, flushed }; |
| ... | @@ -168,7 +168,7 @@ pub const Atom = struct { | ... | @@ -168,7 +168,7 @@ pub const Atom = struct { |
| 168 | code_ptr: ?[*]u8, | 168 | code_ptr: ?[*]u8, |
| 169 | other: union { | 169 | other: union { |
| 170 | code_len: usize, | 170 | code_len: usize, |
| 171 | decl_index: Module.Decl.Index, | 171 | decl_index: InternPool.DeclIndex, |
| 172 | }, | 172 | }, |
| 173 | fn fromSlice(slice: []u8) CodePtr { | 173 | fn fromSlice(slice: []u8) CodePtr { |
| 174 | return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } }; | 174 | return .{ .code_ptr = slice.ptr, .other = .{ .code_len = slice.len } }; |
| ... | @@ -322,7 +322,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 { | ... | @@ -322,7 +322,7 @@ pub fn createEmpty(gpa: Allocator, options: link.Options) !*Plan9 { |
| 322 | return self; | 322 | return self; |
| 323 | } | 323 | } |
| 324 | 324 | ||
| 325 | fn putFn(self: *Plan9, decl_index: Module.Decl.Index, out: FnDeclOutput) !void { | 325 | fn putFn(self: *Plan9, decl_index: InternPool.DeclIndex, out: FnDeclOutput) !void { |
| 326 | const gpa = self.base.allocator; | 326 | const gpa = self.base.allocator; |
| 327 | const mod = self.base.options.module.?; | 327 | const mod = self.base.options.module.?; |
| 328 | const decl = mod.declPtr(decl_index); | 328 | const decl = mod.declPtr(decl_index); |
| ... | @@ -447,7 +447,7 @@ pub fn updateFunc(self: *Plan9, mod: *Module, func_index: InternPool.Index, air: | ... | @@ -447,7 +447,7 @@ pub fn updateFunc(self: *Plan9, mod: *Module, func_index: InternPool.Index, air: |
| 447 | return self.updateFinish(decl_index); | 447 | return self.updateFinish(decl_index); |
| 448 | } | 448 | } |
| 449 | 449 | ||
| 450 | pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.Index) !u32 { | 450 | pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 { |
| 451 | _ = try self.seeDecl(decl_index); | 451 | _ = try self.seeDecl(decl_index); |
| 452 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); | 452 | var code_buffer = std.ArrayList(u8).init(self.base.allocator); |
| 453 | defer code_buffer.deinit(); | 453 | defer code_buffer.deinit(); |
| ... | @@ -508,7 +508,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I | ... | @@ -508,7 +508,7 @@ pub fn lowerUnnamedConst(self: *Plan9, tv: TypedValue, decl_index: Module.Decl.I |
| 508 | return new_atom_idx; | 508 | return new_atom_idx; |
| 509 | } | 509 | } |
| 510 | 510 | ||
| 511 | pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !void { | 511 | pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 512 | const decl = mod.declPtr(decl_index); | 512 | const decl = mod.declPtr(decl_index); |
| 513 | 513 | ||
| 514 | if (decl.isExtern(mod)) { | 514 | if (decl.isExtern(mod)) { |
| ... | @@ -544,7 +544,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !vo | ... | @@ -544,7 +544,7 @@ pub fn updateDecl(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !vo |
| 544 | return self.updateFinish(decl_index); | 544 | return self.updateFinish(decl_index); |
| 545 | } | 545 | } |
| 546 | /// called at the end of update{Decl,Func} | 546 | /// called at the end of update{Decl,Func} |
| 547 | fn updateFinish(self: *Plan9, decl_index: Module.Decl.Index) !void { | 547 | fn updateFinish(self: *Plan9, decl_index: InternPool.DeclIndex) !void { |
| 548 | const mod = self.base.options.module.?; | 548 | const mod = self.base.options.module.?; |
| 549 | const decl = mod.declPtr(decl_index); | 549 | const decl = mod.declPtr(decl_index); |
| 550 | const is_fn = (decl.ty.zigTypeTag(mod) == .Fn); | 550 | const is_fn = (decl.ty.zigTypeTag(mod) == .Fn); |
| ... | @@ -982,7 +982,7 @@ pub fn flushModule(self: *Plan9, comp: *Compilation, prog_node: *std.Progress.No | ... | @@ -982,7 +982,7 @@ pub fn flushModule(self: *Plan9, comp: *Compilation, prog_node: *std.Progress.No |
| 982 | fn addDeclExports( | 982 | fn addDeclExports( |
| 983 | self: *Plan9, | 983 | self: *Plan9, |
| 984 | mod: *Module, | 984 | mod: *Module, |
| 985 | decl_index: Module.Decl.Index, | 985 | decl_index: InternPool.DeclIndex, |
| 986 | exports: []const *Module.Export, | 986 | exports: []const *Module.Export, |
| 987 | ) !void { | 987 | ) !void { |
| 988 | const metadata = self.decls.getPtr(decl_index).?; | 988 | const metadata = self.decls.getPtr(decl_index).?; |
| ... | @@ -1017,7 +1017,7 @@ fn addDeclExports( | ... | @@ -1017,7 +1017,7 @@ fn addDeclExports( |
| 1017 | } | 1017 | } |
| 1018 | } | 1018 | } |
| 1019 | 1019 | ||
| 1020 | pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void { | 1020 | pub fn freeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) void { |
| 1021 | // TODO audit the lifetimes of decls table entries. It's possible to get | 1021 | // TODO audit the lifetimes of decls table entries. It's possible to get |
| 1022 | // freeDecl without any updateDecl in between. | 1022 | // freeDecl without any updateDecl in between. |
| 1023 | // However that is planned to change, see the TODO comment in Module.zig | 1023 | // However that is planned to change, see the TODO comment in Module.zig |
| ... | @@ -1063,7 +1063,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void { | ... | @@ -1063,7 +1063,7 @@ pub fn freeDecl(self: *Plan9, decl_index: Module.Decl.Index) void { |
| 1063 | assert(self.relocs.remove(atom_index)); | 1063 | assert(self.relocs.remove(atom_index)); |
| 1064 | } | 1064 | } |
| 1065 | } | 1065 | } |
| 1066 | fn freeUnnamedConsts(self: *Plan9, decl_index: Module.Decl.Index) void { | 1066 | fn freeUnnamedConsts(self: *Plan9, decl_index: InternPool.DeclIndex) void { |
| 1067 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; | 1067 | const unnamed_consts = self.unnamed_const_atoms.getPtr(decl_index) orelse return; |
| 1068 | for (unnamed_consts.items) |atom_idx| { | 1068 | for (unnamed_consts.items) |atom_idx| { |
| 1069 | const atom = self.getAtom(atom_idx); | 1069 | const atom = self.getAtom(atom_idx); |
| ... | @@ -1088,7 +1088,7 @@ fn createAtom(self: *Plan9) !Atom.Index { | ... | @@ -1088,7 +1088,7 @@ fn createAtom(self: *Plan9) !Atom.Index { |
| 1088 | return index; | 1088 | return index; |
| 1089 | } | 1089 | } |
| 1090 | 1090 | ||
| 1091 | pub fn seeDecl(self: *Plan9, decl_index: Module.Decl.Index) !Atom.Index { | 1091 | pub fn seeDecl(self: *Plan9, decl_index: InternPool.DeclIndex) !Atom.Index { |
| 1092 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); | 1092 | const gop = try self.decls.getOrPut(self.base.allocator, decl_index); |
| 1093 | if (!gop.found_existing) { | 1093 | if (!gop.found_existing) { |
| 1094 | const index = try self.createAtom(); | 1094 | const index = try self.createAtom(); |
| ... | @@ -1428,7 +1428,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { | ... | @@ -1428,7 +1428,7 @@ pub fn writeSyms(self: *Plan9, buf: *std.ArrayList(u8)) !void { |
| 1428 | } | 1428 | } |
| 1429 | 1429 | ||
| 1430 | /// Must be called only after a successful call to `updateDecl`. | 1430 | /// Must be called only after a successful call to `updateDecl`. |
| 1431 | pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: Module.Decl.Index) !void { | 1431 | pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1432 | _ = self; | 1432 | _ = self; |
| 1433 | _ = mod; | 1433 | _ = mod; |
| 1434 | _ = decl_index; | 1434 | _ = decl_index; |
| ... | @@ -1436,7 +1436,7 @@ pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: Module.Decl. | ... | @@ -1436,7 +1436,7 @@ pub fn updateDeclLineNumber(self: *Plan9, mod: *Module, decl_index: Module.Decl. |
| 1436 | 1436 | ||
| 1437 | pub fn getDeclVAddr( | 1437 | pub fn getDeclVAddr( |
| 1438 | self: *Plan9, | 1438 | self: *Plan9, |
| 1439 | decl_index: Module.Decl.Index, | 1439 | decl_index: InternPool.DeclIndex, |
| 1440 | reloc_info: link.File.RelocInfo, | 1440 | reloc_info: link.File.RelocInfo, |
| 1441 | ) !u64 { | 1441 | ) !u64 { |
| 1442 | const mod = self.base.options.module.?; | 1442 | const mod = self.base.options.module.?; |
src/link/SpirV.zig+2-2| ... | @@ -109,7 +109,7 @@ pub fn updateFunc(self: *SpirV, module: *Module, func_index: InternPool.Index, a | ... | @@ -109,7 +109,7 @@ pub fn updateFunc(self: *SpirV, module: *Module, func_index: InternPool.Index, a |
| 109 | try self.object.updateFunc(module, func_index, air, liveness); | 109 | try self.object.updateFunc(module, func_index, air, liveness); |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | pub fn updateDecl(self: *SpirV, module: *Module, decl_index: Module.Decl.Index) !void { | 112 | pub fn updateDecl(self: *SpirV, module: *Module, decl_index: InternPool.DeclIndex) !void { |
| 113 | if (build_options.skip_non_native) { | 113 | if (build_options.skip_non_native) { |
| 114 | @panic("Attempted to compile for architecture that was disabled by build configuration"); | 114 | @panic("Attempted to compile for architecture that was disabled by build configuration"); |
| 115 | } | 115 | } |
| ... | @@ -144,7 +144,7 @@ pub fn updateExports( | ... | @@ -144,7 +144,7 @@ pub fn updateExports( |
| 144 | // TODO: Export regular functions, variables, etc using Linkage attributes. | 144 | // TODO: Export regular functions, variables, etc using Linkage attributes. |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | pub fn freeDecl(self: *SpirV, decl_index: Module.Decl.Index) void { | 147 | pub fn freeDecl(self: *SpirV, decl_index: InternPool.DeclIndex) void { |
| 148 | _ = self; | 148 | _ = self; |
| 149 | _ = decl_index; | 149 | _ = decl_index; |
| 150 | } | 150 | } |
src/link/Wasm.zig+11-11| ... | @@ -48,7 +48,7 @@ llvm_object: ?*LlvmObject = null, | ... | @@ -48,7 +48,7 @@ llvm_object: ?*LlvmObject = null, |
| 48 | host_name: []const u8 = "env", | 48 | host_name: []const u8 = "env", |
| 49 | /// List of all `Decl` that are currently alive. | 49 | /// List of all `Decl` that are currently alive. |
| 50 | /// Each index maps to the corresponding `Atom.Index`. | 50 | /// Each index maps to the corresponding `Atom.Index`. |
| 51 | decls: std.AutoHashMapUnmanaged(Module.Decl.Index, Atom.Index) = .{}, | 51 | decls: std.AutoHashMapUnmanaged(InternPool.DeclIndex, Atom.Index) = .{}, |
| 52 | /// Mapping between an `Atom` and its type index representing the Wasm | 52 | /// Mapping between an `Atom` and its type index representing the Wasm |
| 53 | /// type of the function signature. | 53 | /// type of the function signature. |
| 54 | atom_types: std.AutoHashMapUnmanaged(Atom.Index, u32) = .{}, | 54 | atom_types: std.AutoHashMapUnmanaged(Atom.Index, u32) = .{}, |
| ... | @@ -598,10 +598,10 @@ fn parseObjectFile(wasm: *Wasm, path: []const u8) !bool { | ... | @@ -598,10 +598,10 @@ fn parseObjectFile(wasm: *Wasm, path: []const u8) !bool { |
| 598 | return true; | 598 | return true; |
| 599 | } | 599 | } |
| 600 | 600 | ||
| 601 | /// For a given `Module.Decl.Index` returns its corresponding `Atom.Index`. | 601 | /// For a given `InternPool.DeclIndex` returns its corresponding `Atom.Index`. |
| 602 | /// When the index was not found, a new `Atom` will be created, and its index will be returned. | 602 | /// When the index was not found, a new `Atom` will be created, and its index will be returned. |
| 603 | /// The newly created Atom is empty with default fields as specified by `Atom.empty`. | 603 | /// The newly created Atom is empty with default fields as specified by `Atom.empty`. |
| 604 | pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: Module.Decl.Index) !Atom.Index { | 604 | pub fn getOrCreateAtomForDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) !Atom.Index { |
| 605 | const gop = try wasm.decls.getOrPut(wasm.base.allocator, decl_index); | 605 | const gop = try wasm.decls.getOrPut(wasm.base.allocator, decl_index); |
| 606 | if (!gop.found_existing) { | 606 | if (!gop.found_existing) { |
| 607 | const atom_index = try wasm.createAtom(); | 607 | const atom_index = try wasm.createAtom(); |
| ... | @@ -1427,7 +1427,7 @@ pub fn updateFunc(wasm: *Wasm, mod: *Module, func_index: InternPool.Index, air: | ... | @@ -1427,7 +1427,7 @@ pub fn updateFunc(wasm: *Wasm, mod: *Module, func_index: InternPool.Index, air: |
| 1427 | 1427 | ||
| 1428 | // Generate code for the Decl, storing it in memory to be later written to | 1428 | // Generate code for the Decl, storing it in memory to be later written to |
| 1429 | // the file on flush(). | 1429 | // the file on flush(). |
| 1430 | pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !void { | 1430 | pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1431 | if (build_options.skip_non_native and builtin.object_format != .wasm) { | 1431 | if (build_options.skip_non_native and builtin.object_format != .wasm) { |
| 1432 | @panic("Attempted to compile for object format that was disabled by build configuration"); | 1432 | @panic("Attempted to compile for object format that was disabled by build configuration"); |
| 1433 | } | 1433 | } |
| ... | @@ -1479,7 +1479,7 @@ pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !voi | ... | @@ -1479,7 +1479,7 @@ pub fn updateDecl(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !voi |
| 1479 | return wasm.finishUpdateDecl(decl_index, code, .data); | 1479 | return wasm.finishUpdateDecl(decl_index, code, .data); |
| 1480 | } | 1480 | } |
| 1481 | 1481 | ||
| 1482 | pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.Index) !void { | 1482 | pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: InternPool.DeclIndex) !void { |
| 1483 | if (wasm.llvm_object) |_| return; | 1483 | if (wasm.llvm_object) |_| return; |
| 1484 | if (wasm.dwarf) |*dw| { | 1484 | if (wasm.dwarf) |*dw| { |
| 1485 | const tracy = trace(@src()); | 1485 | const tracy = trace(@src()); |
| ... | @@ -1493,7 +1493,7 @@ pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.I | ... | @@ -1493,7 +1493,7 @@ pub fn updateDeclLineNumber(wasm: *Wasm, mod: *Module, decl_index: Module.Decl.I |
| 1493 | } | 1493 | } |
| 1494 | } | 1494 | } |
| 1495 | 1495 | ||
| 1496 | fn finishUpdateDecl(wasm: *Wasm, decl_index: Module.Decl.Index, code: []const u8, symbol_tag: Symbol.Tag) !void { | 1496 | fn finishUpdateDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex, code: []const u8, symbol_tag: Symbol.Tag) !void { |
| 1497 | const mod = wasm.base.options.module.?; | 1497 | const mod = wasm.base.options.module.?; |
| 1498 | const decl = mod.declPtr(decl_index); | 1498 | const decl = mod.declPtr(decl_index); |
| 1499 | const atom_index = wasm.decls.get(decl_index).?; | 1499 | const atom_index = wasm.decls.get(decl_index).?; |
| ... | @@ -1556,7 +1556,7 @@ fn getFunctionSignature(wasm: *const Wasm, loc: SymbolLoc) std.wasm.Type { | ... | @@ -1556,7 +1556,7 @@ fn getFunctionSignature(wasm: *const Wasm, loc: SymbolLoc) std.wasm.Type { |
| 1556 | /// Lowers a constant typed value to a local symbol and atom. | 1556 | /// Lowers a constant typed value to a local symbol and atom. |
| 1557 | /// Returns the symbol index of the local | 1557 | /// Returns the symbol index of the local |
| 1558 | /// The given `decl` is the parent decl whom owns the constant. | 1558 | /// The given `decl` is the parent decl whom owns the constant. |
| 1559 | pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: Module.Decl.Index) !u32 { | 1559 | pub fn lowerUnnamedConst(wasm: *Wasm, tv: TypedValue, decl_index: InternPool.DeclIndex) !u32 { |
| 1560 | const mod = wasm.base.options.module.?; | 1560 | const mod = wasm.base.options.module.?; |
| 1561 | assert(tv.ty.zigTypeTag(mod) != .Fn); // cannot create local symbols for functions | 1561 | assert(tv.ty.zigTypeTag(mod) != .Fn); // cannot create local symbols for functions |
| 1562 | const decl = mod.declPtr(decl_index); | 1562 | const decl = mod.declPtr(decl_index); |
| ... | @@ -1672,7 +1672,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3 | ... | @@ -1672,7 +1672,7 @@ pub fn getGlobalSymbol(wasm: *Wasm, name: []const u8, lib_name: ?[]const u8) !u3 |
| 1672 | /// Returns the given pointer address | 1672 | /// Returns the given pointer address |
| 1673 | pub fn getDeclVAddr( | 1673 | pub fn getDeclVAddr( |
| 1674 | wasm: *Wasm, | 1674 | wasm: *Wasm, |
| 1675 | decl_index: Module.Decl.Index, | 1675 | decl_index: InternPool.DeclIndex, |
| 1676 | reloc_info: link.File.RelocInfo, | 1676 | reloc_info: link.File.RelocInfo, |
| 1677 | ) !u64 { | 1677 | ) !u64 { |
| 1678 | const mod = wasm.base.options.module.?; | 1678 | const mod = wasm.base.options.module.?; |
| ... | @@ -1780,7 +1780,7 @@ pub fn getAnonDeclVAddr(wasm: *Wasm, decl_val: InternPool.Index, reloc_info: lin | ... | @@ -1780,7 +1780,7 @@ pub fn getAnonDeclVAddr(wasm: *Wasm, decl_val: InternPool.Index, reloc_info: lin |
| 1780 | return target_symbol_index; | 1780 | return target_symbol_index; |
| 1781 | } | 1781 | } |
| 1782 | 1782 | ||
| 1783 | pub fn deleteDeclExport(wasm: *Wasm, decl_index: Module.Decl.Index) void { | 1783 | pub fn deleteDeclExport(wasm: *Wasm, decl_index: InternPool.DeclIndex) void { |
| 1784 | if (wasm.llvm_object) |_| return; | 1784 | if (wasm.llvm_object) |_| return; |
| 1785 | const atom_index = wasm.decls.get(decl_index) orelse return; | 1785 | const atom_index = wasm.decls.get(decl_index) orelse return; |
| 1786 | const sym_index = wasm.getAtom(atom_index).sym_index; | 1786 | const sym_index = wasm.getAtom(atom_index).sym_index; |
| ... | @@ -1923,7 +1923,7 @@ pub fn updateExports( | ... | @@ -1923,7 +1923,7 @@ pub fn updateExports( |
| 1923 | } | 1923 | } |
| 1924 | } | 1924 | } |
| 1925 | 1925 | ||
| 1926 | pub fn freeDecl(wasm: *Wasm, decl_index: Module.Decl.Index) void { | 1926 | pub fn freeDecl(wasm: *Wasm, decl_index: InternPool.DeclIndex) void { |
| 1927 | if (wasm.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); | 1927 | if (wasm.llvm_object) |llvm_object| return llvm_object.freeDecl(decl_index); |
| 1928 | const mod = wasm.base.options.module.?; | 1928 | const mod = wasm.base.options.module.?; |
| 1929 | const decl = mod.declPtr(decl_index); | 1929 | const decl = mod.declPtr(decl_index); |
| ... | @@ -5012,7 +5012,7 @@ pub fn putOrGetFuncType(wasm: *Wasm, func_type: std.wasm.Type) !u32 { | ... | @@ -5012,7 +5012,7 @@ pub fn putOrGetFuncType(wasm: *Wasm, func_type: std.wasm.Type) !u32 { |
| 5012 | /// For the given `decl_index`, stores the corresponding type representing the function signature. | 5012 | /// For the given `decl_index`, stores the corresponding type representing the function signature. |
| 5013 | /// Asserts declaration has an associated `Atom`. | 5013 | /// Asserts declaration has an associated `Atom`. |
| 5014 | /// Returns the index into the list of types. | 5014 | /// Returns the index into the list of types. |
| 5015 | pub fn storeDeclType(wasm: *Wasm, decl_index: Module.Decl.Index, func_type: std.wasm.Type) !u32 { | 5015 | pub fn storeDeclType(wasm: *Wasm, decl_index: InternPool.DeclIndex, func_type: std.wasm.Type) !u32 { |
| 5016 | const atom_index = wasm.decls.get(decl_index).?; | 5016 | const atom_index = wasm.decls.get(decl_index).?; |
| 5017 | const index = try wasm.putOrGetFuncType(func_type); | 5017 | const index = try wasm.putOrGetFuncType(func_type); |
| 5018 | try wasm.atom_types.put(wasm.base.allocator, atom_index, index); | 5018 | try wasm.atom_types.put(wasm.base.allocator, atom_index, index); |
src/type.zig+3-3| ... | @@ -2778,7 +2778,7 @@ pub const Type = struct { | ... | @@ -2778,7 +2778,7 @@ pub const Type = struct { |
| 2778 | } | 2778 | } |
| 2779 | 2779 | ||
| 2780 | /// Returns null if the type has no namespace. | 2780 | /// Returns null if the type has no namespace. |
| 2781 | pub fn getNamespaceIndex(ty: Type, mod: *Module) Module.Namespace.OptionalIndex { | 2781 | pub fn getNamespaceIndex(ty: Type, mod: *Module) InternPool.OptionalNamespaceIndex { |
| 2782 | return switch (mod.intern_pool.indexToKey(ty.toIntern())) { | 2782 | return switch (mod.intern_pool.indexToKey(ty.toIntern())) { |
| 2783 | .opaque_type => |opaque_type| opaque_type.namespace.toOptional(), | 2783 | .opaque_type => |opaque_type| opaque_type.namespace.toOptional(), |
| 2784 | .struct_type => |struct_type| struct_type.namespace, | 2784 | .struct_type => |struct_type| struct_type.namespace, |
| ... | @@ -3123,11 +3123,11 @@ pub const Type = struct { | ... | @@ -3123,11 +3123,11 @@ pub const Type = struct { |
| 3123 | }; | 3123 | }; |
| 3124 | } | 3124 | } |
| 3125 | 3125 | ||
| 3126 | pub fn getOwnerDecl(ty: Type, mod: *Module) Module.Decl.Index { | 3126 | pub fn getOwnerDecl(ty: Type, mod: *Module) InternPool.DeclIndex { |
| 3127 | return ty.getOwnerDeclOrNull(mod) orelse unreachable; | 3127 | return ty.getOwnerDeclOrNull(mod) orelse unreachable; |
| 3128 | } | 3128 | } |
| 3129 | 3129 | ||
| 3130 | pub fn getOwnerDeclOrNull(ty: Type, mod: *Module) ?Module.Decl.Index { | 3130 | pub fn getOwnerDeclOrNull(ty: Type, mod: *Module) ?InternPool.DeclIndex { |
| 3131 | return switch (mod.intern_pool.indexToKey(ty.toIntern())) { | 3131 | return switch (mod.intern_pool.indexToKey(ty.toIntern())) { |
| 3132 | .struct_type => |struct_type| struct_type.decl.unwrap(), | 3132 | .struct_type => |struct_type| struct_type.decl.unwrap(), |
| 3133 | .union_type => |union_type| union_type.decl, | 3133 | .union_type => |union_type| union_type.decl, |
src/value.zig+1-1| ... | @@ -1556,7 +1556,7 @@ pub const Value = struct { | ... | @@ -1556,7 +1556,7 @@ pub const Value = struct { |
| 1556 | /// Gets the decl referenced by this pointer. If the pointer does not point | 1556 | /// Gets the decl referenced by this pointer. If the pointer does not point |
| 1557 | /// to a decl, or if it points to some part of a decl (like field_ptr or element_ptr), | 1557 | /// to a decl, or if it points to some part of a decl (like field_ptr or element_ptr), |
| 1558 | /// this function returns null. | 1558 | /// this function returns null. |
| 1559 | pub fn pointerDecl(val: Value, mod: *Module) ?Module.Decl.Index { | 1559 | pub fn pointerDecl(val: Value, mod: *Module) ?InternPool.DeclIndex { |
| 1560 | return switch (mod.intern_pool.indexToKey(val.toIntern())) { | 1560 | return switch (mod.intern_pool.indexToKey(val.toIntern())) { |
| 1561 | .variable => |variable| variable.decl, | 1561 | .variable => |variable| variable.decl, |
| 1562 | .extern_func => |extern_func| extern_func.decl, | 1562 | .extern_func => |extern_func| extern_func.decl, |