Make numerical table type countable

This commit is contained in:
Deukhoofd 2019-09-14 13:19:52 +02:00
parent 98b605a18b
commit e89782f921
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
2 changed files with 10 additions and 2 deletions

View File

@ -60,7 +60,11 @@ namespace Porygon::Evaluation {
inline void SetIndexValue(const EvalValue *key, const EvalValue* value) const final { inline void SetIndexValue(const EvalValue *key, const EvalValue* value) const final {
auto index = key->EvaluateInteger(); auto index = key->EvaluateInteger();
this->_table->at(index - 1) = value; index--;
if (this->_table->size() <= index){
this->_table->resize(index);
}
this->_table->at(index) = value;
} }
[[nodiscard]] [[nodiscard]]
@ -71,7 +75,7 @@ namespace Porygon::Evaluation {
return _table; return _table;
} }
EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;; [[nodiscard]] EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;;
}; };
} }

View File

@ -178,6 +178,10 @@ namespace Porygon{
inline shared_ptr<const ScriptType> GetIteratorKeyType() const final{ inline shared_ptr<const ScriptType> GetIteratorKeyType() const final{
return NumericScriptType::AwareInt; return NumericScriptType::AwareInt;
} }
[[nodiscard]] bool IsCountable() const override {
return true;
}
}; };
} }