mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-24 00:00:44 +01:00
[poincare/expression] Use extractUnits instead of hasUnit when possible
This commit is contained in:
committed by
Émilie Feral
parent
f227cd719f
commit
407ce0534c
@@ -350,7 +350,7 @@ Expression Expression::defaultHandleUnitsInChildren() {
|
||||
// Generically, an Expression does not accept any Unit in its children.
|
||||
const int childrenCount = numberOfChildren();
|
||||
for (int i = 0; i < childrenCount; i++) {
|
||||
if (childAtIndex(i).hasUnit()) {
|
||||
if (!childAtIndex(i).extractUnits().isUninitialized()) {
|
||||
return replaceWithUndefinedInPlace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -392,7 +392,7 @@ Expression Power::shallowReduce(ExpressionNode::ReductionContext reductionContex
|
||||
|
||||
// Step 1: Handle the units
|
||||
{
|
||||
if (index.hasUnit()) {
|
||||
if (!index.extractUnits().isUninitialized()) {
|
||||
// There must be no unit in the exponent
|
||||
return replaceWithUndefinedInPlace();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ Expression UnitConvert::shallowReduce(ExpressionNode::ReductionContext reduction
|
||||
// Divide the left member by the new unit
|
||||
Expression division = Division::Builder(childAtIndex(0), finalUnit.clone());
|
||||
division = division.reduce(reductionContext);
|
||||
if (division.hasUnit()) {
|
||||
if (!division.extractUnits().isUninitialized()) {
|
||||
// The left and right members are not homogeneous
|
||||
return replaceWithUndefinedInPlace();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user