Implements string evaluation and concat
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "EvaluationException.hpp"
|
||||
#include "Evaluator.hpp"
|
||||
#include "EvalValues/NumericEvalValue.hpp"
|
||||
#include "EvalValues/StringEvalValue.hpp"
|
||||
|
||||
NumericEvalValue* Evaluator::EvaluateIntegerBinary(BoundBinaryExpression *expression) {
|
||||
NumericEvalValue* leftValue = this -> EvaluateIntegerExpression(expression->GetLeft());
|
||||
@@ -71,4 +72,17 @@ BooleanEvalValue* Evaluator::EvaluateBooleanBinary(BoundBinaryExpression* expres
|
||||
default:
|
||||
throw EvaluationException("Can't evaluate operation to boolean");
|
||||
}
|
||||
}
|
||||
|
||||
StringEvalValue* Evaluator::EvaluateStringBinary(BoundBinaryExpression* expression){
|
||||
if (expression->GetOperation() != BoundBinaryOperation::Concatenation)
|
||||
throw;
|
||||
std::ostringstream strs;
|
||||
auto left = this -> EvaluateStringExpression(expression->GetLeft());
|
||||
strs << left->EvaluateString();
|
||||
delete left;
|
||||
auto right = this -> EvaluateExpression(expression->GetRight());
|
||||
strs << right->EvaluateString();
|
||||
delete right;
|
||||
return new StringEvalValue(strs.str());
|
||||
}
|
||||
Reference in New Issue
Block a user