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