This commit is contained in:
@@ -21,46 +21,58 @@ namespace Porygon::Evaluation {
|
||||
|
||||
virtual ~EvalValue() = default;
|
||||
|
||||
virtual const TypeClass GetTypeClass() const = 0;
|
||||
[[nodiscard]]
|
||||
virtual TypeClass GetTypeClass() const = 0;
|
||||
|
||||
virtual const bool operator==(EvalValue *b) const = 0;
|
||||
[[nodiscard]]
|
||||
virtual bool operator==(const EvalValue *b) const = 0;
|
||||
|
||||
virtual const bool operator!=(EvalValue *b) const {
|
||||
[[nodiscard]]
|
||||
virtual bool operator!=(const EvalValue *b) const {
|
||||
return !(this->operator==(b));
|
||||
}
|
||||
|
||||
virtual const shared_ptr<EvalValue> Clone() const = 0;
|
||||
[[nodiscard]]
|
||||
virtual shared_ptr<const EvalValue> Clone() const = 0;
|
||||
|
||||
virtual const long EvaluateInteger() const {
|
||||
[[nodiscard]]
|
||||
virtual long EvaluateInteger() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as integer.");
|
||||
}
|
||||
|
||||
virtual const double EvaluateFloat() const {
|
||||
[[nodiscard]]
|
||||
virtual double EvaluateFloat() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as float.");
|
||||
}
|
||||
|
||||
virtual const bool EvaluateBool() const {
|
||||
[[nodiscard]]
|
||||
virtual bool EvaluateBool() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as bool.");
|
||||
}
|
||||
|
||||
virtual const std::u16string EvaluateString() const {
|
||||
[[nodiscard]]
|
||||
virtual std::u16string EvaluateString() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as string.");
|
||||
}
|
||||
|
||||
virtual const std::size_t GetHashCode() const = 0;
|
||||
[[nodiscard]]
|
||||
virtual std::size_t GetHashCode() const = 0;
|
||||
|
||||
virtual const shared_ptr<EvalValue> IndexValue(EvalValue *val) const {
|
||||
[[nodiscard]]
|
||||
virtual shared_ptr<const EvalValue> IndexValue(const EvalValue *val) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
|
||||
virtual const shared_ptr<EvalValue> IndexValue(uint32_t hash) const {
|
||||
[[nodiscard]]
|
||||
virtual shared_ptr<const EvalValue> IndexValue(uint32_t hash) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
|
||||
virtual void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const {
|
||||
virtual void SetIndexValue(const EvalValue *key, const shared_ptr<const EvalValue> &value) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
|
||||
[[nodiscard]]
|
||||
virtual Iterator * GetKeyIterator() const{
|
||||
throw EvaluationException("Can't iterate over this EvalValue");
|
||||
}
|
||||
@@ -73,25 +85,30 @@ namespace Porygon::Evaluation {
|
||||
: _value(val) {
|
||||
}
|
||||
|
||||
inline const shared_ptr<EvalValue> Clone() const final {
|
||||
[[nodiscard]]
|
||||
inline shared_ptr<const EvalValue> Clone() const final {
|
||||
return make_shared<BooleanEvalValue>(_value);
|
||||
}
|
||||
|
||||
inline const TypeClass GetTypeClass() const final {
|
||||
[[nodiscard]]
|
||||
inline TypeClass GetTypeClass() const final {
|
||||
return TypeClass::Bool;
|
||||
}
|
||||
|
||||
inline const bool EvaluateBool() const final {
|
||||
[[nodiscard]]
|
||||
inline bool EvaluateBool() const final {
|
||||
return _value;
|
||||
}
|
||||
|
||||
const bool operator==(EvalValue *b) const final {
|
||||
[[nodiscard]]
|
||||
bool operator==(const EvalValue *b) const final {
|
||||
if (b->GetTypeClass() != TypeClass::Bool)
|
||||
return false;
|
||||
return this->EvaluateBool() == b->EvaluateBool();
|
||||
};
|
||||
|
||||
inline const std::size_t GetHashCode() const final {
|
||||
[[nodiscard]]
|
||||
inline std::size_t GetHashCode() const final {
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user