Fixes for return statement, make Evaluate function on script return value
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2019-06-12 18:45:47 +02:00
parent 3477ddd18c
commit 22149d9243
7 changed files with 31 additions and 16 deletions

View File

@@ -11,9 +11,10 @@
using namespace std;
void Evaluator::Evaluate(BoundScriptStatement *statement) {
EvalValue* Evaluator::Evaluate(BoundScriptStatement *statement) {
this->_evaluationScope = make_shared<EvaluationScope>(this->_scriptData->_scriptVariables, statement->GetDeepestScope());
EvaluateBlockStatement(statement, false);
return this -> _returnValue.get();
}
void Evaluator::EvaluateStatement(BoundStatement *statement) {
@@ -73,11 +74,12 @@ void Evaluator::EvaluateFunctionDeclarationStatement(BoundFunctionDeclarationSta
void Evaluator::EvaluateReturnStatement(BoundReturnStatement* statement){
auto expression = statement->GetExpression();
this->_hasReturned = true;
if (expression == nullptr){
this->_hasReturned = true;
return;
}
auto value = this -> EvaluateExpression(expression);
this->_hasReturned = true;
this -> _returnValue = value;
}