Require explicit inequality as well as equality operators on evalvalues

This commit is contained in:
Deukhoofd 2019-09-07 13:28:25 +02:00
parent d8c67f2dde
commit fab2c9eabd
Signed by: Deukhoofd
GPG Key ID: ADF2E9256009EDCE
9 changed files with 38 additions and 3 deletions

View File

@ -29,9 +29,7 @@ namespace Porygon::Evaluation {
virtual bool operator==(const EvalValue *b) const = 0;
[[nodiscard]]
virtual bool operator!=(const EvalValue *b) const {
return !(this->operator==(b));
}
virtual bool operator!=(const EvalValue *b) const = 0;
[[nodiscard]]
virtual EvalValue* Clone() const = 0;
@ -135,6 +133,10 @@ namespace Porygon::Evaluation {
return this->EvaluateBool() == b->EvaluateBool();
};
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline std::size_t GetHashCode() const final {
return _value;

View File

@ -14,6 +14,10 @@ namespace Porygon::Evaluation{
return b->GetTypeClass() == TypeClass ::Nil;
}
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline EvalValue* Clone() const final{
return new NilEvalValue();

View File

@ -30,6 +30,10 @@ namespace Porygon::Evaluation {
bool operator==(const EvalValue *b) const final;
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]] EvalValue *Clone() const override;
[[nodiscard]] size_t GetHashCode() const override;
[[nodiscard]] EvalValue* Cast(shared_ptr<const ScriptType> castType) const final;

View File

@ -38,6 +38,10 @@ namespace Porygon::Evaluation {
return this->_hash == b->GetHashCode();
}
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline EvalValue* Clone() const final {
return new NumericalTableEvalValue(_table, _hash);

View File

@ -82,6 +82,10 @@ namespace Porygon::Evaluation {
return this->_hash == ((GenericFunctionEvalValue *) b)->_hash;
};
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
inline std::size_t GetHashCode() const final {
return _hash;
}

View File

@ -32,6 +32,10 @@ namespace Porygon::Evaluation {
return this->_hash == b->GetHashCode();
};
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline u16string EvaluateString() const final {
return *_value.get();

View File

@ -42,6 +42,10 @@ namespace Porygon::Evaluation {
return this->_hash == b->GetHashCode();
}
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline EvalValue* Clone() const final {
return new TableEvalValue(_table, _hash);

View File

@ -60,6 +60,10 @@ namespace Porygon::UserData {
return b->GetHashCode() == _hash;
}
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]] EvalValue* Clone() const final{
return new UserDataCollectionValue(_type, _helper, _hash);
}

View File

@ -37,6 +37,10 @@ namespace Porygon::UserData {
return _obj == ((UserDataValue *) b)->_obj;
}
bool operator!=(const EvalValue *b) const override {
return !operator==(b);
}
[[nodiscard]]
inline Evaluation::EvalValue* Clone() const final {
auto ud = _userData->Get();
@ -78,6 +82,7 @@ namespace Porygon::UserData {
EvalValue* Cast(shared_ptr<const ScriptType> castType) const final{
return _userData->Get()->Cast(_obj, castType.get());
}
};
}