Mark evalValues as const
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2019-06-17 17:43:54 +02:00
parent d91caa7f32
commit 21d3329c55
14 changed files with 204 additions and 215 deletions

View File

@@ -7,73 +7,71 @@
class NumericEvalValue : public EvalValue{
virtual long GetIntegerValue() = 0;
virtual double GetFloatValue() = 0;
virtual const long GetIntegerValue() const = 0;
virtual const double GetFloatValue() const = 0;
public:
virtual const bool IsFloat() = 0;
virtual const bool IsFloat() const = 0;
const TypeClass GetTypeClass() final{
const TypeClass GetTypeClass() const final{
return TypeClass ::Number;
}
NumericEvalValue* operator +(NumericEvalValue* b);
NumericEvalValue* operator -(NumericEvalValue* b);
NumericEvalValue* operator *(NumericEvalValue* b);
NumericEvalValue* operator /(NumericEvalValue* b);
BooleanEvalValue* operator <(NumericEvalValue* b);
BooleanEvalValue* operator <=(NumericEvalValue* b);
BooleanEvalValue* operator >(NumericEvalValue* b);
BooleanEvalValue* operator >=(NumericEvalValue* b);
bool operator ==(EvalValue* b) final;
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;
};
class IntegerEvalValue : public NumericEvalValue{
long _value;
long GetIntegerValue() final{return _value;}
double GetFloatValue() final{ throw EvaluationException("Attempting to retrieve float from int eval value."); }
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;
explicit IntegerEvalValue(long value) :_value(value){
}
const bool IsFloat() final{
const bool IsFloat() const final{
return false;
}
long EvaluateInteger() const final{
const long EvaluateInteger() const final{
return _value;
}
shared_ptr<EvalValue> Clone() final{
const shared_ptr<EvalValue> Clone() const final{
return make_shared<IntegerEvalValue>(_value);
}
std::size_t GetHashCode() final{
const std::size_t GetHashCode() const final{
return std::hash<long>{}(_value);
}
};
class FloatEvalValue : public NumericEvalValue{
double _value;
long GetIntegerValue() final{ throw EvaluationException("Attempting to retrieve float from int eval value."); }
double GetFloatValue() final{return _value;}
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;
explicit FloatEvalValue(double value) :_value(value){
}
const bool IsFloat() final{
const bool IsFloat() const final{
return true;
}
double EvaluateFloat() const final{
const double EvaluateFloat() const final{
return _value;
}
shared_ptr<EvalValue> Clone() final{
const shared_ptr<EvalValue> Clone() const final{
return make_shared<FloatEvalValue>(_value);
}
std::size_t GetHashCode() final{
const std::size_t GetHashCode() const final{
return std::hash<double >{}(_value);
}
};