add logical or and logical and

This commit is contained in:
r4
2021-12-23 21:42:09 +01:00
parent d67008cfbf
commit 6bdc4e3210
8 changed files with 53 additions and 9 deletions

View File

@@ -65,6 +65,18 @@ Value eval_binary(IRInstr instr, const Value *lhs, const Value *rhs) {
.type.kind = TypeBool,
.Bool = res,
};
case IRAnd:
return (Value){
.type.kind = TypeBool,
.Bool = is_nonzero(lhs) && is_nonzero(rhs),
};
break;
case IROr:
return (Value){
.type.kind = TypeBool,
.Bool = is_nonzero(lhs) || is_nonzero(rhs),
};
break;
default:
ASSERT_UNREACHED();
}