mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-21 06:40:37 +01:00
[poincare] Change default immediate simplify
Change-Id: I427b3b6d50bc47bf3fe2d64df263d40f9ecf79e0
This commit is contained in:
@@ -135,7 +135,7 @@ public:
|
||||
static void simplifyAndBeautify(Expression ** expressionAddress);
|
||||
Expression * simplify();
|
||||
// TODO: should be virtual pure
|
||||
virtual Expression * immediateSimplify() { return this; };// = 0;
|
||||
virtual Expression * immediateSimplify();
|
||||
virtual Expression * immediateBeautify() { return this; };
|
||||
|
||||
/* Evaluation Engine
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <poincare/list_data.h>
|
||||
#include <poincare/matrix_data.h>
|
||||
#include <poincare/evaluation.h>
|
||||
#include <poincare/undefined.h>
|
||||
#include <cmath>
|
||||
#include "expression_parser.hpp"
|
||||
#include "expression_lexer.hpp"
|
||||
@@ -78,6 +79,7 @@ public:
|
||||
}
|
||||
Expression * clone() const override { return nullptr; }
|
||||
Type type() const override { return Expression::Type::Undefined; }
|
||||
Expression * immediateSimplify() override { return this; }
|
||||
ExpressionLayout * privateCreateLayout(FloatDisplayMode floatDisplayMode, ComplexFormat complexFormat) const override {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -112,6 +114,15 @@ void Expression::beautify(Expression ** expressionAddress) {
|
||||
}
|
||||
}
|
||||
|
||||
Expression * Expression::immediateSimplify() {
|
||||
for (int i = 0; i< numberOfOperands(); i++) {
|
||||
if (operand(i)->type() == Type::Undefined) {
|
||||
return replaceWith(new Undefined(), true);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
bool Expression::hasAncestor(const Expression * e) const {
|
||||
assert(m_parent != this);
|
||||
if (m_parent == e) {
|
||||
|
||||
@@ -218,7 +218,7 @@ Expression * Power::immediateSimplify() {
|
||||
Multiplication * m = new Multiplication(multOperands, 2, false);
|
||||
simplifyRationalRationalPower(p1, static_cast<Rational *>((Expression *)p1->operand(0)), static_cast<Rational *>((Expression *)(p1->operand(1)->operand(0))));
|
||||
replaceWith(m, true);
|
||||
return immediateSimplify();
|
||||
return m->immediateSimplify();
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
Reference in New Issue
Block a user