mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 06:40:37 +01:00
[poincare] Add an assertion in deepReduce/ deepBeautify, this must have
a parent Change-Id: Ia23be0c62734811923133793dd5bee0859b64ca8
This commit is contained in:
@@ -126,18 +126,19 @@ void Expression::Simplify(Expression ** expressionAddress, Context & context, An
|
||||
angleUnit = Preferences::sharedPreferences()->angleUnit();
|
||||
}
|
||||
SimplificationRoot root(*expressionAddress);
|
||||
root.deepReduce(context, angleUnit);
|
||||
root.deepBeautify(context, angleUnit);
|
||||
root.editableOperand(0)->deepReduce(context, angleUnit);
|
||||
root.editableOperand(0)->deepBeautify(context, angleUnit);
|
||||
*expressionAddress = root.editableOperand(0);
|
||||
}
|
||||
|
||||
void Expression::Reduce(Expression ** expressionAddress, Context & context, AngleUnit angleUnit) {
|
||||
SimplificationRoot root(*expressionAddress);
|
||||
root.deepReduce(context, angleUnit);
|
||||
root.editableOperand(0)->deepReduce(context, angleUnit);
|
||||
*expressionAddress = root.editableOperand(0);
|
||||
}
|
||||
|
||||
Expression * Expression::deepReduce(Context & context, AngleUnit angleUnit) {
|
||||
assert(parent() != nullptr);
|
||||
for (int i = 0; i < numberOfOperands(); i++) {
|
||||
if ((editableOperand(i))->deepReduce(context, angleUnit)->type() == Type::Undefined && this->type() != Type::SimplificationRoot) {
|
||||
return replaceWith(new Undefined(), true);
|
||||
@@ -147,6 +148,7 @@ Expression * Expression::deepReduce(Context & context, AngleUnit angleUnit) {
|
||||
}
|
||||
|
||||
Expression * Expression::deepBeautify(Context & context, AngleUnit angleUnit) {
|
||||
assert(parent() != nullptr);
|
||||
Expression * e = shallowBeautify(context, angleUnit);
|
||||
for (int i = 0; i < e->numberOfOperands(); i++) {
|
||||
e->editableOperand(i)->deepBeautify(context, angleUnit);
|
||||
|
||||
@@ -44,7 +44,7 @@ void Hierarchy::replaceOperand(const Expression * oldOperand, Expression * newOp
|
||||
Expression ** op = const_cast<Expression **>(operands());
|
||||
for (int i=0; i<numberOfOperands(); i++) {
|
||||
if (op[i] == oldOperand) {
|
||||
if (oldOperand != nullptr) {
|
||||
if (oldOperand != nullptr && oldOperand->parent() == this) {
|
||||
const_cast<Expression *>(oldOperand)->setParent(nullptr);
|
||||
}
|
||||
if (deleteOldOperand) {
|
||||
|
||||
Reference in New Issue
Block a user