Added logical and and or binary operations
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user