Dont evaluate right hand side of Logical Or if left hand is true.

This commit is contained in:
Deukhoofd 2019-09-22 16:30:56 +02:00
parent 256244eabb
commit 7bca80092d
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 4 additions and 0 deletions

View File

@ -291,6 +291,10 @@ namespace Porygon::Evaluation {
if (!leftValue->EvaluateBool())
return new BooleanEvalValue(false);
}
else if (operation == BoundBinaryOperation::LogicalOr) {
if (leftValue->EvaluateBool())
return new BooleanEvalValue(true);
}
auto rightValue = this -> EvaluateExpression(expression->GetRight());
if (operation == BoundBinaryOperation::Equality){
return new BooleanEvalValue(leftValue->operator==(rightValue.Get()));