Initial work on iterators, rework of variable handling by including actual string
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-06-23 15:58:14 +02:00
parent 1a84661c79
commit 76b8ba3ebc
25 changed files with 185 additions and 78 deletions

View File

@@ -10,6 +10,7 @@
#include "../Binder/BoundExpressions/BoundTableExpression.hpp"
#include "../TableScriptType.hpp"
#include "../UserData/UserDataFunction.hpp"
#include "../Utilities/StringUtils.hpp"
using namespace std;
using namespace Porygon::Binder;
@@ -388,12 +389,13 @@ namespace Porygon::Evaluation {
const shared_ptr<EvalValue> Evaluator::EvaluateNumericTableExpression(const BoundExpression *expression) {
auto tableExpression = (BoundNumericalTableExpression *) expression;
auto valueExpressions = tableExpression->GetExpressions();
auto values = new unordered_map<uint32_t, shared_ptr<EvalValue>>(valueExpressions->size());
auto values = new map<Utilities::HashedString, shared_ptr<EvalValue>>();
for (int i = 0; i < valueExpressions->size(); i++) {
auto val = this->EvaluateExpression(valueExpressions->at(i));
values->insert({i + 1, val});
auto key = Utilities::StringUtils::IntToString(i + 1);
values->insert({Utilities::HashedString(key), val});
}
auto valuesPointer = shared_ptr<unordered_map<uint32_t, shared_ptr<EvalValue>>>(values);
auto valuesPointer = shared_ptr<map<Utilities::HashedString, shared_ptr<EvalValue>>>(values);
return make_shared<TableEvalValue>(valuesPointer);
}
@@ -401,7 +403,7 @@ namespace Porygon::Evaluation {
auto tableExpression = (BoundTableExpression *) expression;
auto type = dynamic_pointer_cast<TableScriptType>(tableExpression->GetType());
auto declaredVars = type->GetValues();
auto variables = make_shared<unordered_map<uint32_t, shared_ptr<EvalValue>>>(declaredVars->size());
auto variables = make_shared<map<Utilities::HashedString, shared_ptr<EvalValue>>>();
for (auto i : *declaredVars) {
variables->insert({i.first, nullptr});
}