diff --git a/poincare/include/poincare/simplification_root.h b/poincare/include/poincare/simplification_root.h new file mode 100644 index 000000000..7f19bfb0c --- /dev/null +++ b/poincare/include/poincare/simplification_root.h @@ -0,0 +1,34 @@ +#ifndef POINCARE_SIMPLIFICATION_ROOT_H +#define POINCARE_SIMPLIFICATION_ROOT_H + +#include + +namespace Poincare { + +class SimplificationRoot : public StaticHierarchy<1> { +public: + SimplificationRoot(Expression * e) : StaticHierarchy<1>(&e, false) { + e->setParent(this); + } + ~SimplificationRoot() { + detachOperand(operand(0)); + /* We don't want to clone the expression provided at construction. + * So we don't want it to be deleted when we're destroyed (parent destructor). */ + } + 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; + } + Evaluation * privateEvaluate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { + return nullptr; + } + Evaluation * privateEvaluate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { + return nullptr; + } +}; + +} + +#endif diff --git a/poincare/src/expression.cpp b/poincare/src/expression.cpp index 377097204..0900fc19e 100644 --- a/poincare/src/expression.cpp +++ b/poincare/src/expression.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include "expression_parser.hpp" #include "expression_lexer.hpp" @@ -67,30 +68,6 @@ ExpressionLayout * Expression::createLayout(FloatDisplayMode floatDisplayMode, C } } -class SimplificationRoot : public StaticHierarchy<1> { -public: - SimplificationRoot(Expression * e) : StaticHierarchy<1>(&e, false) { - e->setParent(this); - } - ~SimplificationRoot() { - detachOperand(operand(0)); - /* We don't want to clone the expression provided at construction. - * So we don't want it to be deleted when we're destroyed (parent destructor). */ - } - 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; - } - Evaluation * privateEvaluate(SinglePrecision p, Context& context, AngleUnit angleUnit) const override { - return nullptr; - } - Evaluation * privateEvaluate(DoublePrecision p, Context& context, AngleUnit angleUnit) const override { - return nullptr; - } -}; - void Expression::simplifyAndBeautify(Expression ** expressionAddress) { SimplificationRoot root(*expressionAddress); root.simplify();