mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-20 14:20:39 +01:00
[poincare] Fix Parenthesis
This commit is contained in:
@@ -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<float> approximate(SinglePrecision p, Context& context, Preferences::AngleUnit angleUnit) const override { return templatedApproximate<float>(context, angleUnit); }
|
||||
@@ -35,9 +35,10 @@ private:
|
||||
template<typename T> Evaluation<T> templatedApproximate(Context& context, Preferences::AngleUnit angleUnit) const;
|
||||
};
|
||||
|
||||
class ParenthesisReference : public Expression {
|
||||
class Parenthesis : public Expression {
|
||||
public:
|
||||
ParenthesisReference(Expression exp) : Expression(TreePool::sharedPool()->createTreeNode<ParenthesisNode>()) {
|
||||
Parenthesis(const ParenthesisNode * n) : Expression(n) {}
|
||||
Parenthesis(Expression exp) : Expression(TreePool::sharedPool()->createTreeNode<ParenthesisNode>()) {
|
||||
replaceChildAtIndexInPlace(0, exp);
|
||||
}
|
||||
// Expression
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <poincare/parenthesis.h>
|
||||
#include <poincare/allocation_failure_expression_node.h>
|
||||
#include <assert.h>
|
||||
#include <poincare/serialization_helper.h>
|
||||
|
||||
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<ParenthesisNode *>(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<T> 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);
|
||||
|
||||
Reference in New Issue
Block a user