Even better exception handling when we can't index an evalvalue
This commit is contained in:
parent
2e1bdcf3a4
commit
d8c67f2dde
|
@ -67,9 +67,9 @@ namespace Porygon::Evaluation {
|
|||
}
|
||||
|
||||
[[nodiscard]]
|
||||
virtual const EvalValue* IndexValue(uint32_t hash) const {
|
||||
virtual const EvalValue* IndexValue(const Utilities::HashedString* hash) const {
|
||||
std::stringstream err;
|
||||
err << "Can't index this EvalValue: " << ToString() << " with key hash: " << hash;
|
||||
err << "Can't index this EvalValue: " << ToString() << " with key hash: " << hash->GetDebugString();
|
||||
throw EvaluationException(err.str());
|
||||
}
|
||||
|
||||
|
|
|
@ -50,8 +50,8 @@ namespace Porygon::Evaluation {
|
|||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline EvalValue* IndexValue(uint32_t hash) const final {
|
||||
return this->_table->at(hash - 1)-> Clone();
|
||||
inline EvalValue* IndexValue(const Utilities::HashedString* hash) const final {
|
||||
return this->_table->at(hash->GetHash() - 1)-> Clone();
|
||||
}
|
||||
|
||||
inline void SetIndexValue(const EvalValue *key, const EvalValue* value) const final {
|
||||
|
|
|
@ -54,8 +54,8 @@ namespace Porygon::Evaluation {
|
|||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline EvalValue* IndexValue(uint32_t hash) const final {
|
||||
return this->_table->at(Utilities::HashedString::CreateLookup(hash))->Clone();
|
||||
inline EvalValue* IndexValue(const Utilities::HashedString* hash) const final {
|
||||
return this->_table->at(*hash)->Clone();
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
|
|
|
@ -372,7 +372,7 @@ namespace Porygon::Evaluation {
|
|||
|
||||
EvalValuePointer Evaluator::EvaluatePeriodIndexExpression(const BoundExpression *expression) {
|
||||
auto indexExpression = (BoundPeriodIndexExpression *) expression;
|
||||
auto index = indexExpression->GetIndex()->GetHash();
|
||||
auto index = indexExpression->GetIndex();
|
||||
auto indexable = this->EvaluateExpression(indexExpression->GetIndexableExpression());
|
||||
return indexable->IndexValue(index);
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ namespace Porygon::UserData {
|
|||
}
|
||||
|
||||
[[nodiscard]]
|
||||
inline const EvalValue* IndexValue(uint32_t hash) const final {
|
||||
auto field = _userData->Get()->GetField(hash);
|
||||
inline const EvalValue* IndexValue(const Utilities::HashedString* hash) const final {
|
||||
auto field = _userData->Get()->GetField(hash->GetHash());
|
||||
return field->Get(_obj);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue