Added logical and and or binary operations

This commit is contained in:
2019-05-25 13:30:20 +02:00
parent ce3be6a039
commit 4a4a71ca73
5 changed files with 140 additions and 7 deletions

View File

@@ -30,4 +30,26 @@ NumericEvalValue* Evaluator::EvaluateIntegerBinary(BoundBinaryExpression *expres
delete leftValue;
delete rightValue;
return result;
}
BooleanEvalValue* Evaluator::EvaluateBooleanBinary(BoundBinaryExpression* expression){
switch (expression->GetOperation()){
case BoundBinaryOperation::Equality:break;
case BoundBinaryOperation::LogicalAnd:
{
BooleanEvalValue* leftValue = this -> EvaluateBoolExpression(expression->GetLeft());
if (!leftValue->EvaluateBool()) return leftValue;
delete leftValue;
BooleanEvalValue* rightValue = this -> EvaluateBoolExpression(expression->GetRight());
return rightValue;
}
case BoundBinaryOperation::LogicalOr:
{
BooleanEvalValue* leftValue = this -> EvaluateBoolExpression(expression->GetLeft());
if (leftValue->EvaluateBool()) return leftValue;
delete leftValue;
BooleanEvalValue* rightValue = this -> EvaluateBoolExpression(expression->GetRight());
return rightValue;
}
}
}