add logical or and logical and

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

No files matched your search

+12
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();
}