54 lines
1.8 KiB
C++
54 lines
1.8 KiB
C++
#include "TableEvalValue.hpp"
|
|
#include "../Iterator/SimpleKeyIterator.hpp"
|
|
#include "NumericEvalValue.hpp"
|
|
#include "../Iterator/NumericalKeyIterator.hpp"
|
|
|
|
namespace Porygon::Evaluation {
|
|
Porygon::Evaluation::Iterator *Porygon::Evaluation::TableEvalValue::GetKeyIterator() const {
|
|
return new TableKeyIterator(this);
|
|
}
|
|
|
|
Porygon::Evaluation::EvalValue *
|
|
Porygon::Evaluation::TableEvalValue::UnaryOperation(Porygon::Binder::BoundUnaryOperation operation) const {
|
|
if (operation == Porygon::Binder::BoundUnaryOperation::Count) {
|
|
return new NumericEvalValue(static_cast<int64_t>(this->_table->size()));
|
|
}
|
|
return EvalValue::UnaryOperation(operation);
|
|
}
|
|
|
|
void Porygon::Evaluation::TableEvalValue::SetIndexValue(const Porygon::Utilities::HashedString *key,
|
|
const Porygon::Evaluation::EvalValue *value) const {
|
|
auto insert = _table->insert({*key, value});
|
|
if (!insert.second) {
|
|
_table->at(*key).ClearAssign(value);
|
|
}
|
|
|
|
}
|
|
|
|
Porygon::Evaluation::Iterator *Porygon::Evaluation::NumericTableEvalValue::GetKeyIterator() const {
|
|
return new NumericalKeyIterator(this);
|
|
}
|
|
|
|
Porygon::Evaluation::EvalValue *Porygon::Evaluation::NumericTableEvalValue::Clone() const {
|
|
return new NumericTableEvalValue(_table, _hash);
|
|
}
|
|
|
|
extern "C"{
|
|
TableScriptType::TableType GetTableType(TableEvalValue* table){
|
|
return table->GetTableType();
|
|
}
|
|
|
|
size_t GetTableLength(TableEvalValue* table){
|
|
return table->GetLength();
|
|
}
|
|
|
|
EvalValue* IndexTableHash(TableEvalValue* table, uint32_t hash){
|
|
return table->IndexValue(hash);
|
|
}
|
|
|
|
EvalValue* IndexTableObj(TableEvalValue* table, EvalValue* key){
|
|
return table->IndexValue(key->GetHashCode());
|
|
}
|
|
|
|
}
|
|
} |