Reworked handling of numerical key tables to make iteration over keys actual numerics, instead of strings
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-27 14:02:31 +02:00
parent d86e9ba8ae
commit 9727c9365e
8 changed files with 121 additions and 11 deletions

View File

@@ -11,6 +11,7 @@
#include "../TableScriptType.hpp"
#include "../UserData/UserDataFunction.hpp"
#include "../Utilities/StringUtils.hpp"
#include "EvalValues/NumericalTableEvalValue.hpp"
using namespace std;
using namespace Porygon::Binder;
@@ -417,14 +418,13 @@ namespace Porygon::Evaluation {
const shared_ptr<EvalValue> Evaluator::EvaluateNumericTableExpression(const BoundExpression *expression) {
auto tableExpression = (BoundNumericalTableExpression *) expression;
auto valueExpressions = tableExpression->GetExpressions();
auto values = new map<Utilities::HashedString, shared_ptr<EvalValue>>();
auto values = new vector<shared_ptr<EvalValue>>(valueExpressions->size());
for (int i = 0; i < valueExpressions->size(); i++) {
auto val = this->EvaluateExpression(valueExpressions->at(i));
auto key = new u16string(Utilities::StringUtils::IntToString(i + 1));
values->insert({Utilities::HashedString(key), val});
values->at(i) = val;
}
auto valuesPointer = shared_ptr<map<Utilities::HashedString, shared_ptr<EvalValue>>>(values);
return make_shared<TableEvalValue>(valuesPointer);
auto valuesPointer = shared_ptr<vector<shared_ptr<EvalValue>>>(values);
return make_shared<NumericalTableEvalValue>(valuesPointer);
}
const shared_ptr<EvalValue> Evaluator::EvaluateComplexTableExpression(const BoundExpression *expression) {