diff --git a/poincare/include/poincare/parenthesis.h b/poincare/include/poincare/parenthesis.h index 0dec079eb..c6e17edae 100644 --- a/poincare/include/poincare/parenthesis.h +++ b/poincare/include/poincare/parenthesis.h @@ -26,7 +26,7 @@ public: LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override; // Simplification - Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) override; + Expression shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const override; // Approximation Evaluation approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return templatedApproximate(context, angleUnit); } @@ -35,9 +35,10 @@ private: template Evaluation templatedApproximate(Context& context, Preferences::AngleUnit angleUnit) const; }; -class ParenthesisReference : public Expression { +class Parenthesis : public Expression { public: - ParenthesisReference(Expression exp) : Expression(TreePool::sharedPool()->createTreeNode()) { + Parenthesis(const ParenthesisNode * n) : Expression(n) {} + Parenthesis(Expression exp) : Expression(TreePool::sharedPool()->createTreeNode()) { replaceChildAtIndexInPlace(0, exp); } // Expression diff --git a/poincare/src/parenthesis.cpp b/poincare/src/parenthesis.cpp index 9e3fa338e..0053d9100 100644 --- a/poincare/src/parenthesis.cpp +++ b/poincare/src/parenthesis.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include namespace Poincare { @@ -18,7 +18,7 @@ LayoutRef ParenthesisNode::createLayout(Preferences::PrintFloatMode floatDisplay } int ParenthesisNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const { - return SerializationHelper::Prefix(Parenthesis(const_cast(this)), buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, ""); + return SerializationHelper::Prefix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, ""); } Expression ParenthesisNode::shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const { @@ -32,7 +32,7 @@ Evaluation ParenthesisNode::templatedApproximate(Context& context, Preference Expression Parenthesis::shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const { Expression e = Expression::shallowReduce(context, angleUnit); - if (e != *this) { + if (e.isUndefinedOrAllocationFailure()) { return e; } return childAtIndex(0);