Removed LastValue variable, as it can be better emulated with basic return values

This commit is contained in:
2019-07-27 10:51:24 +02:00
parent 8b80b5789d
commit 268f6b59fb
10 changed files with 111 additions and 161 deletions

View File

@@ -10,16 +10,20 @@
#include "../TableScriptType.hpp"
#include "../UserData/UserDataFunction.hpp"
#include "EvalValues/NumericalTableEvalValue.hpp"
#include "../Utilities/Random.hpp"
using namespace std;
using namespace Porygon::Binder;
namespace Porygon::Evaluation {
const EvalValue *Evaluator::Evaluate(const BoundScriptStatement *statement) {
shared_ptr<const EvalValue> Evaluator::Evaluate(const BoundScriptStatement *statement) {
this->_evaluationScope = make_shared<EvaluationScope>(this->_scriptVariables);
auto statements = statement->GetStatements();
if (statements -> size() == 1 && statements->at(0)->GetKind() == BoundStatementKind::Expression){
auto expStatement = (BoundExpressionStatement*) statements -> at(0);
return this -> EvaluateExpression(expStatement -> GetExpression());
}
EvaluateBlockStatement(statement);
return this->_returnValue.get();
return this->_returnValue;
}
void Evaluator::EvaluateStatement(const BoundStatement *statement) {
@@ -67,8 +71,7 @@ namespace Porygon::Evaluation {
}
void Evaluator::EvaluateExpressionStatement(const BoundExpressionStatement *statement) {
// Save new value
this->_lastValue = this->EvaluateExpression(statement->GetExpression());
this->EvaluateExpression(statement->GetExpression());
}
void Evaluator::EvaluateAssignmentStatement(const BoundAssignmentStatement *statement) {