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;
|
||||
}
|
||||
|
||||
|
||||
@@ -47,6 +47,7 @@ class Evaluator {
|
||||
shared_ptr<EvalValue> EvaluateFunctionCallExpression(BoundExpression *expression);
|
||||
shared_ptr<EvalValue> EvaluateIndexExpression(BoundExpression* expression);
|
||||
shared_ptr<EvalValue> EvaluateNumericTableExpression(BoundExpression* expression);
|
||||
shared_ptr<EvalValue> EvaluateComplexTableExpression(BoundExpression *expression);
|
||||
|
||||
shared_ptr<EvalValue> GetVariable(BoundVariableExpression *expression);
|
||||
public:
|
||||
@@ -57,14 +58,13 @@ public:
|
||||
_evaluationScope = nullptr;
|
||||
}
|
||||
|
||||
void Evaluate(BoundScriptStatement* statement);
|
||||
EvalValue* Evaluate(BoundScriptStatement* statement);
|
||||
shared_ptr<EvalValue> EvaluateFunction(ScriptFunctionEvalValue* func, vector<EvalValue*> parameters);
|
||||
|
||||
EvalValue* GetLastValue(){
|
||||
return _lastValue.get();
|
||||
}
|
||||
|
||||
shared_ptr<EvalValue> EvaluateComplexTableExpression(BoundExpression *expression);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user