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