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