#ifndef PORYGONLANG_EVALVALUE_HPP #define PORYGONLANG_EVALVALUE_HPP #include "../../ScriptType.hpp" #include "../EvaluationException.hpp" #include #include #include class EvalValue{ public: EvalValue() = default; virtual ~EvalValue() = default; virtual const TypeClass GetTypeClass() = 0; virtual bool operator ==(EvalValue* b) = 0; virtual bool operator !=(EvalValue*b){ return ! (this->operator==(b)); } virtual shared_ptr Clone() = 0; virtual long EvaluateInteger(){ throw EvaluationException("Can't evaluate this EvalValue as integer."); } virtual double EvaluateFloat(){ throw EvaluationException("Can't evaluate this EvalValue as float."); } virtual bool EvaluateBool(){ throw EvaluationException("Can't evaluate this EvalValue as bool."); } virtual std::string* EvaluateString(){ throw EvaluationException("Can't evaluate this EvalValue as string."); } virtual std::size_t GetHashCode() = 0; virtual shared_ptr IndexValue(EvalValue* val){ throw EvaluationException("Can't index this EvalValue"); } }; class BooleanEvalValue : public EvalValue{ const bool _value; public: explicit BooleanEvalValue(bool val) : _value(val) { } shared_ptr Clone() final{ return make_shared(_value); } const TypeClass GetTypeClass() final{ return TypeClass ::Bool; } bool EvaluateBool() final{ return _value; } bool operator ==(EvalValue* b) final{ if (b->GetTypeClass() != TypeClass::Bool) return false; return this->EvaluateBool() == b->EvaluateBool(); }; std::size_t GetHashCode() final{ return _value; } }; #endif //PORYGONLANG_EVALVALUE_HPP