Added equality operation for eval values

This commit is contained in:
2019-05-25 13:57:43 +02:00
parent 4a4a71ca73
commit d6a6e116fe
5 changed files with 85 additions and 1 deletions

View File

@@ -11,6 +11,12 @@ public:
virtual ~EvalValue() = default;
virtual ScriptType* GetType() = 0;
virtual bool operator ==(EvalValue* b) = 0;
virtual bool operator !=(EvalValue*b){
return ! (this->operator==(b));
}
virtual long EvaluateInteger(){
throw EvaluationException("Can't evaluate this EvalValue as integer.");
}
@@ -45,6 +51,12 @@ public:
bool EvaluateBool() final{
return _value;
}
bool operator ==(EvalValue* b) final{
if (b->GetType()->GetClass() != TypeClass::Bool)
return false;
return this->EvaluateBool() == b->EvaluateBool();
};
};
#endif //PORYGONLANG_EVALVALUE_HPP