| ... | ... | @@ -2287,19 +2287,6 @@ fn resolveValueResolveLazy(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value |
| 2287 | 2287 | return try sema.resolveLazyValue((try sema.resolveValue(inst)) orelse return null); |
| 2288 | 2288 | } |
| 2289 | 2289 | |
| 2290 | | /// Like `resolveValue`, but any pointer value which does not correspond |
| 2291 | | /// to a comptime-known integer (e.g. a decl pointer) returns `null`. |
| 2292 | | /// Lazy values are recursively resolved. |
| 2293 | | fn resolveValueIntable(sema: *Sema, inst: Air.Inst.Ref) CompileError!?Value { |
| 2294 | | const val = (try sema.resolveValue(inst)) orelse return null; |
| 2295 | | if (sema.pt.zcu.intern_pool.getBackingAddrTag(val.toIntern())) |addr| switch (addr) { |
| 2296 | | .nav, .uav, .comptime_alloc, .comptime_field => return null, |
| 2297 | | .int => {}, |
| 2298 | | .eu_payload, .opt_payload, .arr_elem, .field => unreachable, |
| 2299 | | }; |
| 2300 | | return try sema.resolveLazyValue(val); |
| 2301 | | } |
| 2302 | | |
| 2303 | 2290 | /// Value Tag may be `undef` or `variable`. |
| 2304 | 2291 | pub fn resolveFinalDeclValue( |
| 2305 | 2292 | sema: *Sema, |
| ... | ... | @@ -10144,14 +10131,19 @@ fn zirIntFromPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError! |
| 10144 | 10131 | } |
| 10145 | 10132 | const len = if (is_vector) operand_ty.vectorLen(zcu) else undefined; |
| 10146 | 10133 | const dest_ty: Type = if (is_vector) try pt.vectorType(.{ .child = .usize_type, .len = len }) else .usize; |
| 10147 | | if (try sema.resolveValueIntable(operand)) |operand_val| ct: { |
| 10134 | |
| 10135 | if (try sema.resolveValue(operand)) |operand_val| ct: { |
| 10148 | 10136 | if (!is_vector) { |
| 10149 | 10137 | if (operand_val.isUndef(zcu)) { |
| 10150 | 10138 | return Air.internedToRef((try pt.undefValue(Type.usize)).toIntern()); |
| 10151 | 10139 | } |
| 10140 | const addr = try operand_val.getUnsignedIntSema(pt) orelse { |
| 10141 | // Wasn't an integer pointer. This is a runtime operation. |
| 10142 | break :ct; |
| 10143 | }; |
| 10152 | 10144 | return Air.internedToRef((try pt.intValue( |
| 10153 | 10145 | Type.usize, |
| 10154 | | (try operand_val.toUnsignedIntSema(pt)), |
| 10146 | addr, |
| 10155 | 10147 | )).toIntern()); |
| 10156 | 10148 | } |
| 10157 | 10149 | const new_elems = try sema.arena.alloc(InternPool.Index, len); |