Implements return statement
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-07 15:23:13 +02:00
parent f143e526ab
commit f4a3918947
12 changed files with 145 additions and 18 deletions

View File

@@ -15,7 +15,8 @@
using namespace std;
class Evaluator {
shared_ptr<EvalValue> _result;
shared_ptr<EvalValue> _returnValue;
bool _hasReturned;
shared_ptr<EvalValue> _lastValue;
Script* _scriptData;
@@ -26,6 +27,7 @@ class Evaluator {
void EvaluateExpressionStatement(BoundExpressionStatement* statement);
void EvaluateAssignmentStatement(BoundAssignmentStatement* statement);
void EvaluateFunctionDeclarationStatement(BoundFunctionDeclarationStatement *statement);
void EvaluateReturnStatement(BoundReturnStatement *statement);
shared_ptr<EvalValue> EvaluateExpression(BoundExpression* expression);
shared_ptr<NumericEvalValue> EvaluateIntegerExpression(BoundExpression* expression);
@@ -47,6 +49,8 @@ class Evaluator {
public:
explicit Evaluator(Script* script){
_scriptData = script;
_hasReturned = false;
_returnValue = nullptr;
_evaluationScope = nullptr;
}
@@ -55,7 +59,7 @@ public:
}
void Evaluate(BoundScriptStatement* statement);
EvalValue* EvaluateFunction(ScriptFunctionEvalValue* func, vector<EvalValue*> parameters);
shared_ptr<EvalValue> EvaluateFunction(ScriptFunctionEvalValue* func, vector<EvalValue*> parameters);
EvalValue* GetLastValue(){
return _lastValue.get();