| ... | @@ -2142,13 +2142,10 @@ pub const Inst = struct { | ... | @@ -2142,13 +2142,10 @@ pub const Inst = struct { |
| 2142 | /// ZIR is structured so that the outermost "main" struct of any file | 2142 | /// ZIR is structured so that the outermost "main" struct of any file |
| 2143 | /// is always at index 0. | 2143 | /// is always at index 0. |
| 2144 | main_struct_inst = 0, | 2144 | main_struct_inst = 0, |
| 2145 | ref_start_index = static_len, | | |
| 2146 | _, | 2145 | _, |
| 2147 | | 2146 | |
| 2148 | pub const static_len = 124; | | |
| 2149 | | | |
| 2150 | pub fn toRef(i: Index) Inst.Ref { | 2147 | pub fn toRef(i: Index) Inst.Ref { |
| 2151 | return @enumFromInt(@intFromEnum(Index.ref_start_index) + @intFromEnum(i)); | 2148 | return @enumFromInt(Ref.static_len + @intFromEnum(i)); |
| 2152 | } | 2149 | } |
| 2153 | | 2150 | |
| 2154 | pub fn toOptional(i: Index) OptionalIndex { | 2151 | pub fn toOptional(i: Index) OptionalIndex { |
| ... | @@ -2160,7 +2157,6 @@ pub const Inst = struct { | ... | @@ -2160,7 +2157,6 @@ pub const Inst = struct { |
| 2160 | /// ZIR is structured so that the outermost "main" struct of any file | 2157 | /// ZIR is structured so that the outermost "main" struct of any file |
| 2161 | /// is always at index 0. | 2158 | /// is always at index 0. |
| 2162 | main_struct_inst = 0, | 2159 | main_struct_inst = 0, |
| 2163 | ref_start_index = Index.static_len, | | |
| 2164 | none = std.math.maxInt(u32), | 2160 | none = std.math.maxInt(u32), |
| 2165 | _, | 2161 | _, |
| 2166 | | 2162 | |
| ... | @@ -2309,11 +2305,13 @@ pub const Inst = struct { | ... | @@ -2309,11 +2305,13 @@ pub const Inst = struct { |
| 2309 | | 2305 | |
| 2310 | _, | 2306 | _, |
| 2311 | | 2307 | |
| | 2308 | pub const static_len = @typeInfo(@This()).@"enum".fields.len - 1; |
| | 2309 | |
| 2312 | pub fn toIndex(inst: Ref) ?Index { | 2310 | pub fn toIndex(inst: Ref) ?Index { |
| 2313 | assert(inst != .none); | 2311 | assert(inst != .none); |
| 2314 | const ref_int = @intFromEnum(inst); | 2312 | const ref_int = @intFromEnum(inst); |
| 2315 | if (ref_int >= @intFromEnum(Index.ref_start_index)) { | 2313 | if (ref_int >= static_len) { |
| 2316 | return @enumFromInt(ref_int - @intFromEnum(Index.ref_start_index)); | 2314 | return @enumFromInt(ref_int - static_len); |
| 2317 | } else { | 2315 | } else { |
| 2318 | return null; | 2316 | return null; |
| 2319 | } | 2317 | } |