Added equality operation for eval values
This commit is contained in:
@@ -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");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user