Fix annoying build warnings
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
82c82ae93d
commit
586dd994e2
|
@ -176,37 +176,4 @@ namespace Porygon::Evaluation {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
EvalValue *FloatEvalValue::BinaryOperation(Binder::BoundBinaryOperation operation, const EvalValue *b) const {
|
|
||||||
auto right = dynamic_cast<const NumericEvalValue*>(b);
|
|
||||||
if (right->IsFloat()){
|
|
||||||
auto rightVal = right->EvaluateFloat();
|
|
||||||
switch (operation){
|
|
||||||
case Binder::BoundBinaryOperation::Addition: return new FloatEvalValue(_value + rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Subtraction: return new FloatEvalValue(_value - rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Multiplication: return new FloatEvalValue(_value * rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Division: return new FloatEvalValue(_value / rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::LessThan: return new BooleanEvalValue(_value < rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::LessThanEquals: return new BooleanEvalValue(_value <= rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::GreaterThan: return new BooleanEvalValue(_value > rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::GreaterThanEquals: return new BooleanEvalValue(_value >= rightVal);
|
|
||||||
default:
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
} else{
|
|
||||||
auto rightVal = right->EvaluateInteger();
|
|
||||||
switch (operation){
|
|
||||||
case Binder::BoundBinaryOperation::Addition: return new IntegerEvalValue((long)_value + rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Subtraction: return new IntegerEvalValue((long)_value - rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Multiplication: return new IntegerEvalValue((long)_value * rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::Division: return new IntegerEvalValue((long)_value / rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::LessThan: return new BooleanEvalValue(_value < rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::LessThanEquals: return new BooleanEvalValue(_value <= rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::GreaterThan: return new BooleanEvalValue(_value > rightVal);
|
|
||||||
case Binder::BoundBinaryOperation::GreaterThanEquals: return new BooleanEvalValue(_value >= rightVal);
|
|
||||||
default:
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -133,7 +133,46 @@ namespace Porygon::Evaluation {
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
inline EvalValue* BinaryOperation(Binder::BoundBinaryOperation operation, const EvalValue* b) const final;
|
inline EvalValue* BinaryOperation(Binder::BoundBinaryOperation operation, const EvalValue* b) const final{
|
||||||
|
auto right = dynamic_cast<const NumericEvalValue*>(b);
|
||||||
|
if (right->IsFloat()){
|
||||||
|
auto rightVal = right->EvaluateFloat();
|
||||||
|
switch (operation){
|
||||||
|
case Binder::BoundBinaryOperation::Addition: return new FloatEvalValue(_value + rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Subtraction: return new FloatEvalValue(_value - rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Multiplication: return new FloatEvalValue(_value * rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Division: return new FloatEvalValue(_value / rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::LessThan: return new BooleanEvalValue(_value < rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::LessThanEquals: return new BooleanEvalValue(_value <= rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::GreaterThan: return new BooleanEvalValue(_value > rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::GreaterThanEquals: return new BooleanEvalValue(_value >= rightVal);
|
||||||
|
default:
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
auto rightVal = right->EvaluateInteger();
|
||||||
|
switch (operation) {
|
||||||
|
case Binder::BoundBinaryOperation::Addition:
|
||||||
|
return new IntegerEvalValue((long) _value + rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Subtraction:
|
||||||
|
return new IntegerEvalValue((long) _value - rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Multiplication:
|
||||||
|
return new IntegerEvalValue((long) _value * rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::Division:
|
||||||
|
return new IntegerEvalValue((long) _value / rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::LessThan:
|
||||||
|
return new BooleanEvalValue(_value < rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::LessThanEquals:
|
||||||
|
return new BooleanEvalValue(_value <= rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::GreaterThan:
|
||||||
|
return new BooleanEvalValue(_value > rightVal);
|
||||||
|
case Binder::BoundBinaryOperation::GreaterThanEquals:
|
||||||
|
return new BooleanEvalValue(_value >= rightVal);
|
||||||
|
default:
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[[nodiscard]]
|
[[nodiscard]]
|
||||||
EvalValue* UnaryOperation(Binder::BoundUnaryOperation operation) const final{
|
EvalValue* UnaryOperation(Binder::BoundUnaryOperation operation) const final{
|
||||||
|
|
Loading…
Reference in New Issue