Fixed right hand in Logical And operation being evaluated when left hand was false
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2019-09-07 13:52:44 +02:00
parent fab2c9eabd
commit bd054b1077
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
1 changed files with 8 additions and 4 deletions

View File

@ -267,13 +267,17 @@ namespace Porygon::Evaluation {
}
EvalValuePointer Evaluator::EvaluateBinary(const BoundBinaryExpression *expression){
auto leftValue = this -> EvaluateExpression(expression->GetLeft());
auto rightValue = this -> EvaluateExpression(expression->GetRight());
auto operation = expression->GetOperation();
auto leftValue = this -> EvaluateExpression(expression->GetLeft());
if (operation == BoundBinaryOperation::LogicalAnd){
if (!leftValue->EvaluateBool())
return new BooleanEvalValue(false);
}
auto rightValue = this -> EvaluateExpression(expression->GetRight());
if (operation == BoundBinaryOperation::Equality){
return new BooleanEvalValue(leftValue == rightValue);
return new BooleanEvalValue(leftValue->operator==(rightValue.Get()));
} else if (operation == BoundBinaryOperation::Inequality){
return new BooleanEvalValue(leftValue != rightValue);
return new BooleanEvalValue(leftValue->operator!=(rightValue.Get()));
}
return leftValue->BinaryOperation(operation, rightValue.Get());
}