From 01b94f85439ce4457722f21dff2fcfc798e5d72f Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Fri, 13 Mar 2020 16:55:57 +0100 Subject: [PATCH] [poincare/unit] Units homogeneity is already handled in each Expression subclass specifically if needed or generically in defaultHandleUnitsInChildren --- poincare/include/poincare/unit.h | 2 -- poincare/src/unit.cpp | 30 ------------------------------ 2 files changed, 32 deletions(-) diff --git a/poincare/include/poincare/unit.h b/poincare/include/poincare/unit.h index f3b662e7d..1b809fab3 100644 --- a/poincare/include/poincare/unit.h +++ b/poincare/include/poincare/unit.h @@ -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); }; diff --git a/poincare/src/unit.cpp b/poincare/src/unit.cpp index 7c7a141cf..dfe857004 100644 --- a/poincare/src/unit.cpp +++ b/poincare/src/unit.cpp @@ -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(node());