Fixes for return statement, make Evaluate function on script return value
Some checks reported errors
continuous-integration/drone/push Build was killed
Some checks reported errors
continuous-integration/drone/push Build was killed
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user