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]]
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -407,8 +407,7 @@ namespace Porygon::Evaluation {
|
|||
auto values = new map<Utilities::HashedString, EvalValuePointer>();
|
||||
for (size_t i = 0; i < valueExpressions->size(); i++) {
|
||||
auto val = this->EvaluateExpression(valueExpressions->at(i));
|
||||
auto k = Utilities::StringUtils::IntToString(i + 1);
|
||||
auto s = Utilities::HashedString(new u16string(k));
|
||||
auto s = Utilities::HashedString::CreateLookup(i + 1);
|
||||
values->insert({s, val});
|
||||
}
|
||||
auto valuesPointer = shared_ptr<map<Utilities::HashedString, EvalValuePointer>>(values);
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "NumericalKeyIterator.hpp"
|
||||
|
||||
const Porygon::Evaluation::EvalValue *Porygon::Evaluation::NumericalKeyIterator::GetCurrent() {
|
||||
auto s = *_iterator->first.GetString();
|
||||
return new NumericEvalValue(Utilities::StringUtils::ParseInteger(s));
|
||||
auto s = _iterator->first.GetHash();
|
||||
return new NumericEvalValue(static_cast<int64_t >(s));
|
||||
}
|
||||
|
|
|
@ -98,6 +98,18 @@ table.foo = 500
|
|||
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
|
||||
|
|
Loading…
Reference in New Issue