Support for length unary operator
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "NumericalTableEvalValue.hpp"
|
||||
#include "../Iterator/NumericalKeyIterator.hpp"
|
||||
#include "../../Utilities/Random.hpp"
|
||||
|
||||
inline Porygon::Evaluation::Iterator *Porygon::Evaluation::NumericalTableEvalValue::GetKeyIterator() const {
|
||||
return new NumericalKeyIterator(this);
|
||||
@@ -7,6 +8,14 @@ inline Porygon::Evaluation::Iterator *Porygon::Evaluation::NumericalTableEvalVal
|
||||
|
||||
Porygon::Evaluation::NumericalTableEvalValue::NumericalTableEvalValue(shared_ptr<vector<EvalValuePointer>> table) :
|
||||
_table(std::move(table)),
|
||||
_hash(rand())
|
||||
_hash(Utilities::Random::Get())
|
||||
{
|
||||
}
|
||||
|
||||
Porygon::Evaluation::EvalValue *
|
||||
Porygon::Evaluation::NumericalTableEvalValue::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);
|
||||
}
|
||||
|
||||
@@ -69,7 +69,9 @@ namespace Porygon::Evaluation {
|
||||
[[nodiscard]]
|
||||
inline shared_ptr<vector<EvalValuePointer>> GetTable() const{
|
||||
return _table;
|
||||
};
|
||||
}
|
||||
|
||||
EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <string>
|
||||
#include "EvalValue.hpp"
|
||||
#include "NumericEvalValue.hpp"
|
||||
#include "../../Utilities/HashedString.hpp"
|
||||
|
||||
using namespace std;
|
||||
@@ -68,6 +69,13 @@ namespace Porygon::Evaluation {
|
||||
auto str = stringStream.str();
|
||||
return new StringEvalValue(str);
|
||||
}
|
||||
|
||||
[[nodiscard]] EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override {
|
||||
if (operation == Binder::BoundUnaryOperation ::Count){
|
||||
return new NumericEvalValue(static_cast<int64_t >(_value->size()));
|
||||
}
|
||||
return EvalValue::UnaryOperation(operation);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,15 @@
|
||||
#include "TableEvalValue.hpp"
|
||||
#include "../Iterator/SimpleKeyIterator.hpp"
|
||||
#include "NumericEvalValue.hpp"
|
||||
|
||||
inline 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);
|
||||
}
|
||||
|
||||
@@ -83,7 +83,9 @@ namespace Porygon::Evaluation {
|
||||
[[nodiscard]]
|
||||
inline _Rb_tree_const_iterator<pair<const Utilities::HashedString, EvalValuePointer>> GetTableIteratorEnd() const{
|
||||
return _table->cend();
|
||||
};
|
||||
}
|
||||
|
||||
EvalValue *UnaryOperation(Binder::BoundUnaryOperation operation) const override;;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user