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:
@@ -4,76 +4,98 @@
|
||||
|
||||
#include <sstream>
|
||||
#include "EvalValue.hpp"
|
||||
namespace Porygon::Evaluation {
|
||||
class NumericEvalValue : public EvalValue {
|
||||
|
||||
class NumericEvalValue : public EvalValue{
|
||||
virtual const long GetIntegerValue() const = 0;
|
||||
|
||||
virtual const long GetIntegerValue() const = 0;
|
||||
virtual const double GetFloatValue() const = 0;
|
||||
virtual const double GetFloatValue() const = 0;
|
||||
|
||||
public:
|
||||
virtual const bool IsFloat() const = 0;
|
||||
public:
|
||||
virtual const bool IsFloat() const = 0;
|
||||
|
||||
const TypeClass GetTypeClass() const final{
|
||||
return TypeClass ::Number;
|
||||
}
|
||||
const TypeClass GetTypeClass() const final {
|
||||
return TypeClass::Number;
|
||||
}
|
||||
|
||||
const shared_ptr<NumericEvalValue> operator +(const shared_ptr<NumericEvalValue>& b) const;
|
||||
const shared_ptr<NumericEvalValue> operator -(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const shared_ptr<NumericEvalValue> operator *(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const shared_ptr<NumericEvalValue> operator /(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const shared_ptr<BooleanEvalValue> operator <(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const shared_ptr<BooleanEvalValue> operator <=(const shared_ptr<NumericEvalValue>& b)const ;
|
||||
const shared_ptr<BooleanEvalValue> operator >(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const shared_ptr<BooleanEvalValue> operator >=(const shared_ptr<NumericEvalValue>& b) const ;
|
||||
const bool operator ==(EvalValue* b) const final;
|
||||
};
|
||||
const shared_ptr<NumericEvalValue> operator+(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
class IntegerEvalValue : public NumericEvalValue{
|
||||
const long _value;
|
||||
const long GetIntegerValue() const final{return _value;}
|
||||
const double GetFloatValue() const final{ throw EvaluationException("Attempting to retrieve float from int eval value."); }
|
||||
public:
|
||||
explicit IntegerEvalValue(long value) :_value(value){
|
||||
}
|
||||
const bool IsFloat() const final{
|
||||
return false;
|
||||
}
|
||||
const shared_ptr<NumericEvalValue> operator-(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const long EvaluateInteger() const final{
|
||||
return _value;
|
||||
}
|
||||
const shared_ptr<NumericEvalValue> operator*(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final{
|
||||
return make_shared<IntegerEvalValue>(_value);
|
||||
}
|
||||
const shared_ptr<NumericEvalValue> operator/(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const std::size_t GetHashCode() const final{
|
||||
return std::hash<long>{}(_value);
|
||||
}
|
||||
};
|
||||
const shared_ptr<BooleanEvalValue> operator<(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
class FloatEvalValue : public NumericEvalValue{
|
||||
const double _value;
|
||||
const long GetIntegerValue() const final{ throw EvaluationException("Attempting to retrieve float from int eval value."); }
|
||||
const double GetFloatValue() const final{return _value;}
|
||||
public:
|
||||
explicit FloatEvalValue(double value) :_value(value){
|
||||
}
|
||||
const bool IsFloat() const final{
|
||||
return true;
|
||||
}
|
||||
const shared_ptr<BooleanEvalValue> operator<=(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const double EvaluateFloat() const final{
|
||||
return _value;
|
||||
}
|
||||
const shared_ptr<BooleanEvalValue> operator>(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final{
|
||||
return make_shared<FloatEvalValue>(_value);
|
||||
}
|
||||
const shared_ptr<BooleanEvalValue> operator>=(const shared_ptr<NumericEvalValue> &b) const;
|
||||
|
||||
const std::size_t GetHashCode() const final{
|
||||
return std::hash<double >{}(_value);
|
||||
}
|
||||
};
|
||||
const bool operator==(EvalValue *b) const final;
|
||||
};
|
||||
|
||||
class IntegerEvalValue : public NumericEvalValue {
|
||||
const long _value;
|
||||
|
||||
const long GetIntegerValue() const final { return _value; }
|
||||
|
||||
const double GetFloatValue() const final {
|
||||
throw EvaluationException("Attempting to retrieve float from int eval value.");
|
||||
}
|
||||
|
||||
public:
|
||||
explicit IntegerEvalValue(long value) : _value(value) {
|
||||
}
|
||||
|
||||
const bool IsFloat() const final {
|
||||
return false;
|
||||
}
|
||||
|
||||
const long EvaluateInteger() const final {
|
||||
return _value;
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<IntegerEvalValue>(_value);
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
return std::hash<long>{}(_value);
|
||||
}
|
||||
};
|
||||
|
||||
class FloatEvalValue : public NumericEvalValue {
|
||||
const double _value;
|
||||
|
||||
const long GetIntegerValue() const final {
|
||||
throw EvaluationException("Attempting to retrieve float from int eval value.");
|
||||
}
|
||||
|
||||
const double GetFloatValue() const final { return _value; }
|
||||
|
||||
public:
|
||||
explicit FloatEvalValue(double value) : _value(value) {
|
||||
}
|
||||
|
||||
const bool IsFloat() const final {
|
||||
return true;
|
||||
}
|
||||
|
||||
const double EvaluateFloat() const final {
|
||||
return _value;
|
||||
}
|
||||
|
||||
const shared_ptr<EvalValue> Clone() const final {
|
||||
return make_shared<FloatEvalValue>(_value);
|
||||
}
|
||||
|
||||
const std::size_t GetHashCode() const final {
|
||||
return std::hash<double>{}(_value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#endif //PORYGONLANG_NUMERICEVALVALUE_HPP
|
||||
|
||||
Reference in New Issue
Block a user