mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[poincare/unit] Units homogeneity is already handled in each Expression subclass
specifically if needed or generically in defaultHandleUnitsInChildren
This commit is contained in:
committed by
Émilie Feral
parent
7ef28a93bc
commit
01b94f8543
@@ -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);
|
||||
};
|
||||
|
||||
|
||||
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user