Fixes and improvements for new table system
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
6c6d977000
commit
24923deed0
|
@ -53,7 +53,7 @@ namespace Porygon::Evaluation {
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline EvalValue* IndexValue(const EvalValue *val) const final {
|
inline EvalValue* IndexValue(const EvalValue *val) const final {
|
||||||
const auto stringKey = val->EvaluateString();
|
const auto stringKey = val->GetHashCode();
|
||||||
return this->_table->at(Utilities::HashedString::CreateLookup(stringKey))->Clone();
|
return this->_table->at(Utilities::HashedString::CreateLookup(stringKey))->Clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -407,8 +407,7 @@ namespace Porygon::Evaluation {
|
||||||
auto values = new map<Utilities::HashedString, EvalValuePointer>();
|
auto values = new map<Utilities::HashedString, EvalValuePointer>();
|
||||||
for (size_t i = 0; i < valueExpressions->size(); i++) {
|
for (size_t i = 0; i < valueExpressions->size(); i++) {
|
||||||
auto val = this->EvaluateExpression(valueExpressions->at(i));
|
auto val = this->EvaluateExpression(valueExpressions->at(i));
|
||||||
auto k = Utilities::StringUtils::IntToString(i + 1);
|
auto s = Utilities::HashedString::CreateLookup(i + 1);
|
||||||
auto s = Utilities::HashedString(new u16string(k));
|
|
||||||
values->insert({s, val});
|
values->insert({s, val});
|
||||||
}
|
}
|
||||||
auto valuesPointer = shared_ptr<map<Utilities::HashedString, EvalValuePointer>>(values);
|
auto valuesPointer = shared_ptr<map<Utilities::HashedString, EvalValuePointer>>(values);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "NumericalKeyIterator.hpp"
|
#include "NumericalKeyIterator.hpp"
|
||||||
|
|
||||||
const Porygon::Evaluation::EvalValue *Porygon::Evaluation::NumericalKeyIterator::GetCurrent() {
|
const Porygon::Evaluation::EvalValue *Porygon::Evaluation::NumericalKeyIterator::GetCurrent() {
|
||||||
auto s = *_iterator->first.GetString();
|
auto s = _iterator->first.GetHash();
|
||||||
return new NumericEvalValue(Utilities::StringUtils::ParseInteger(s));
|
return new NumericEvalValue(static_cast<int64_t >(s));
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,18 @@ table.foo = 500
|
||||||
delete script;
|
delete script;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE( "Dynamic numerical table size", "[integration]" ) {
|
||||||
|
Script* script = Script::Create(
|
||||||
|
R"(
|
||||||
|
table = {}
|
||||||
|
table[1] = 500
|
||||||
|
return table[1]
|
||||||
|
)");
|
||||||
|
REQUIRE(!script->Diagnostics -> HasErrors());
|
||||||
|
auto result = script->Evaluate();
|
||||||
|
CHECK(result -> EvaluateInteger() == 500);
|
||||||
|
delete script;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue