| ... | ... | @@ -2131,19 +2131,20 @@ pub const Value = struct { |
| 2131 | 2131 | } |
| 2132 | 2132 | |
| 2133 | 2133 | /// Asserts the value is not undefined and not unreachable. |
| 2134 | | /// Integer value 0 is considered null because of C pointers. |
| 2134 | /// C pointers with an integer value of 0 are also considered null. |
| 2135 | 2135 | pub fn isNull(val: Value, mod: *Module) bool { |
| 2136 | 2136 | return switch (val.toIntern()) { |
| 2137 | 2137 | .undef => unreachable, |
| 2138 | 2138 | .unreachable_value => unreachable, |
| 2139 | | |
| 2140 | 2139 | .null_value => true, |
| 2141 | | |
| 2142 | 2140 | else => return switch (mod.intern_pool.indexToKey(val.toIntern())) { |
| 2143 | 2141 | .undef => unreachable, |
| 2144 | | .int => { |
| 2145 | | var buf: BigIntSpace = undefined; |
| 2146 | | return val.toBigInt(&buf, mod).eqZero(); |
| 2142 | .ptr => |ptr| switch (ptr.addr) { |
| 2143 | .int => { |
| 2144 | var buf: BigIntSpace = undefined; |
| 2145 | return val.toBigInt(&buf, mod).eqZero(); |
| 2146 | }, |
| 2147 | else => false, |
| 2147 | 2148 | }, |
| 2148 | 2149 | .opt => |opt| opt.val == .none, |
| 2149 | 2150 | else => false, |