Added equality operation for eval values

This commit is contained in:
2019-05-25 13:57:43 +02:00
parent 4a4a71ca73
commit d6a6e116fe
5 changed files with 85 additions and 1 deletions

View File

@@ -34,7 +34,15 @@ NumericEvalValue* Evaluator::EvaluateIntegerBinary(BoundBinaryExpression *expres
BooleanEvalValue* Evaluator::EvaluateBooleanBinary(BoundBinaryExpression* expression){
switch (expression->GetOperation()){
case BoundBinaryOperation::Equality:break;
case BoundBinaryOperation::Equality:
{
EvalValue* leftValue = this -> EvaluateExpression(expression->GetLeft());
EvalValue* rightValue = this -> EvaluateExpression(expression->GetRight());
bool equals = leftValue->operator==(rightValue);
delete leftValue;
delete rightValue;
return new BooleanEvalValue(equals);
}
case BoundBinaryOperation::LogicalAnd:
{
BooleanEvalValue* leftValue = this -> EvaluateBoolExpression(expression->GetLeft());
@@ -51,5 +59,7 @@ BooleanEvalValue* Evaluator::EvaluateBooleanBinary(BoundBinaryExpression* expres
BooleanEvalValue* rightValue = this -> EvaluateBoolExpression(expression->GetRight());
return rightValue;
}
default:
throw EvaluationException("Can't evaluate operation to boolean");
}
}