stage2: astgen catch

This commit is contained in:
Vexu
2020-08-26 12:34:41 +03:00
committed by Andrew Kelley
parent bf014d529a
commit fb28349349
4 changed files with 120 additions and 22 deletions

View File

@@ -2570,7 +2570,17 @@ 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();
return self.constBool(scope, src, invert_logic);
}
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.