diff options
Diffstat (limited to 'src-self-hosted/Module.zig')
| -rw-r--r-- | src-self-hosted/Module.zig | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src-self-hosted/Module.zig b/src-self-hosted/Module.zig index 82029c1e9f..dd4e8fea1e 100644 --- a/src-self-hosted/Module.zig +++ b/src-self-hosted/Module.zig @@ -2570,7 +2570,18 @@ pub fn analyzeIsNull( operand: *Inst, invert_logic: bool, ) InnerError!*Inst { - return self.fail(scope, src, "TODO implement analysis of isnull and isnotnull", .{}); + if (operand.value()) |opt_val| { + const is_null = opt_val.isNull(); + const bool_value = if (invert_logic) !is_null else is_null; + return self.constBool(scope, src, bool_value); + } + const b = try self.requireRuntimeBlock(scope, src); + const inst_tag: Inst.Tag = if (invert_logic) .isnonnull else .isnull; + return self.addUnOp(b, src, Type.initTag(.bool), inst_tag, operand); +} + +pub fn analyzeIsErr(self: *Module, scope: *Scope, src: usize, operand: *Inst) InnerError!*Inst { + return self.fail(scope, src, "TODO implement analysis of iserr", .{}); } /// Asserts that lhs and rhs types are both numeric. |
