[poincare/unit] Units homogeneity is already handled in each Expression subclass

specifically if needed or generically in defaultHandleUnitsInChildren
This commit is contained in:
Ruben Dashyan
2020-03-13 16:55:57 +01:00
committed by Émilie Feral
parent 7ef28a93bc
commit 01b94f8543
2 changed files with 0 additions and 32 deletions

View File

@@ -166,7 +166,6 @@ public:
// Simplification
Expression shallowReduce(ReductionContext reductionContext) override;
Expression shallowBeautify(ReductionContext reductionContext) override;
LayoutShape leftLayoutShape() const override { return LayoutShape::OneLetter; } // TODO
const Dimension * dimension() const { return m_dimension; }
@@ -728,7 +727,6 @@ public:
// Simplification
Expression shallowReduce(ExpressionNode::ReductionContext reductionContext);
Expression shallowBeautify(ExpressionNode::ReductionContext reductionContext);
void chooseBestMultipleForValue(double & value, const int exponent, ExpressionNode::ReductionContext reductionContext);
};

View File

@@ -214,10 +214,6 @@ Expression UnitNode::shallowReduce(ReductionContext reductionContext) {
return Unit(this).shallowReduce(reductionContext);
}
Expression UnitNode::shallowBeautify(ReductionContext reductionContext) {
return Unit(this).shallowBeautify(reductionContext);
}
constexpr const Unit::Prefix
Unit::PicoPrefix,
Unit::NanoPrefix,
@@ -317,32 +313,6 @@ Expression Unit::shallowReduce(ExpressionNode::ReductionContext reductionContext
return result;
}
Expression Unit::shallowBeautify(ExpressionNode::ReductionContext reductionContext) {
Expression ancestor = parent();
if (!ancestor.isUninitialized() && ancestor.type() == ExpressionNode::Type::Power) {
ancestor = ancestor.parent();
}
/* Check homogeneity: at this point, ancestor must be
* - either uninitialized
* - or a Multiplication whose parent is uninitialized.
*/
if (!ancestor.isUninitialized() && ancestor.type() == ExpressionNode::Type::Multiplication) {
ancestor = ancestor.parent();
}
if (!ancestor.isUninitialized() && ancestor.type() == ExpressionNode::Type::Opposite) {
ancestor = ancestor.parent();
}
if (ancestor.isUninitialized()) {
return *this;
}
/* If the latter checks are not successfully passed, then the function
* returns replaceWithUndefinedInPlace.
* TODO Something else should be returned in order to report a more
* specific error. For instance: inhomogeneous expression.
*/
return replaceWithUndefinedInPlace();
}
void Unit::chooseBestMultipleForValue(double & value, const int exponent, ExpressionNode::ReductionContext reductionContext) {
assert(value != 0 && !std::isnan(value) && !std::isinf(value) && exponent != 0);
UnitNode * unitNode = static_cast<UnitNode *>(node());