Added namespaces to most classes, general cleanup
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -8,77 +8,83 @@
|
||||
#include <sstream>
|
||||
#include <memory>
|
||||
|
||||
class EvalValue{
|
||||
public:
|
||||
EvalValue() = default;
|
||||
virtual ~EvalValue() = default;
|
||||
virtual const TypeClass GetTypeClass() const = 0;
|
||||
namespace Porygon::Evaluation {
|
||||
class EvalValue {
|
||||
public:
|
||||
EvalValue() = default;
|
||||
|
||||
virtual const bool operator ==(EvalValue* b) const = 0;
|
||||
virtual ~EvalValue() = default;
|
||||
|
||||
virtual const bool operator !=(EvalValue*b) const{
|
||||
return ! (this->operator==(b));
|
||||
}
|
||||
virtual const TypeClass GetTypeClass() const = 0;
|
||||
|
||||
virtual const shared_ptr<EvalValue> Clone() const = 0;
|
||||
virtual const bool operator==(EvalValue *b) const = 0;
|
||||
|
||||
virtual const long EvaluateInteger() const{
|
||||
throw EvaluationException("Can't evaluate this EvalValue as integer.");
|
||||
}
|
||||
virtual const double EvaluateFloat() const{
|
||||
throw EvaluationException("Can't evaluate this EvalValue as float.");
|
||||
}
|
||||
virtual const bool EvaluateBool() const{
|
||||
throw EvaluationException("Can't evaluate this EvalValue as bool.");
|
||||
}
|
||||
virtual const std::u16string* EvaluateString() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as string.");
|
||||
}
|
||||
virtual const bool operator!=(EvalValue *b) const {
|
||||
return !(this->operator==(b));
|
||||
}
|
||||
|
||||
virtual const std::size_t GetHashCode() const = 0;
|
||||
virtual const shared_ptr<EvalValue> Clone() const = 0;
|
||||
|
||||
virtual const shared_ptr<EvalValue> IndexValue(EvalValue* val) const{
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
virtual const long EvaluateInteger() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as integer.");
|
||||
}
|
||||
|
||||
virtual const shared_ptr<EvalValue> IndexValue(uint32_t hash) const{
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
virtual const double EvaluateFloat() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as float.");
|
||||
}
|
||||
|
||||
virtual void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue>& value) const{
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
};
|
||||
virtual const bool EvaluateBool() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as bool.");
|
||||
}
|
||||
|
||||
class BooleanEvalValue : public EvalValue{
|
||||
const bool _value;
|
||||
public:
|
||||
explicit BooleanEvalValue(bool val)
|
||||
: _value(val)
|
||||
{
|
||||
}
|
||||
virtual const std::u16string *EvaluateString() const {
|
||||
throw EvaluationException("Can't evaluate this EvalValue as string.");
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final{
|
||||
return make_shared<BooleanEvalValue>(_value);
|
||||
}
|
||||
virtual const std::size_t GetHashCode() const = 0;
|
||||
|
||||
const TypeClass GetTypeClass() const final{
|
||||
return TypeClass ::Bool;
|
||||
}
|
||||
virtual const shared_ptr<EvalValue> IndexValue(EvalValue *val) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
|
||||
const bool EvaluateBool() const final{
|
||||
return _value;
|
||||
}
|
||||
virtual const shared_ptr<EvalValue> IndexValue(uint32_t hash) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
|
||||
const bool operator ==(EvalValue* b) const final{
|
||||
if (b->GetTypeClass() != TypeClass::Bool)
|
||||
return false;
|
||||
return this->EvaluateBool() == b->EvaluateBool();
|
||||
virtual void SetIndexValue(EvalValue *key, const shared_ptr<EvalValue> &value) const {
|
||||
throw EvaluationException("Can't index this EvalValue");
|
||||
}
|
||||
};
|
||||
|
||||
const std::size_t GetHashCode() const final{
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
class BooleanEvalValue : public EvalValue {
|
||||
const bool _value;
|
||||
public:
|
||||
explicit BooleanEvalValue(bool val)
|
||||
: _value(val) {
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<BooleanEvalValue>(_value);
|
||||
}
|
||||
|
||||
const TypeClass GetTypeClass() const final {
|
||||
return TypeClass::Bool;
|
||||
}
|
||||
|
||||
const bool EvaluateBool() const final {
|
||||
return _value;
|
||||
}
|
||||
|
||||
const bool operator==(EvalValue *b) const final {
|
||||
if (b->GetTypeClass() != TypeClass::Bool)
|
||||
return false;
|
||||
return this->EvaluateBool() == b->EvaluateBool();
|
||||
};
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_EVALVALUE_HPP
|
||||
|
||||
Reference in New Issue
Block a user