aboutsummaryrefslogtreecommitdiff
path: root/src-self-hosted/Module.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-08-26 19:53:49 -0700
committerAndrew Kelley <andrew@ziglang.org>2020-08-26 19:53:49 -0700
commit5fed721290cc7ecf396b7815f830e1fabe8b4711 (patch)
tree851e5f39cdfd916c395e405d29ddad056c29d5df /src-self-hosted/Module.zig
parent7d0bb0774e957e81fee7240d410944a0a56c303d (diff)
parentb0995cb9f9540a6d463dcc2722cb3b8918a61e8e (diff)
downloadzig-5fed721290cc7ecf396b7815f830e1fabe8b4711.tar.gz
zig-5fed721290cc7ecf396b7815f830e1fabe8b4711.zip
Merge branch 'Vexu-stage2'
closes #6175
Diffstat (limited to 'src-self-hosted/Module.zig')
-rw-r--r--src-self-hosted/Module.zig13
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.