mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-26 01:00:50 +01:00
[poincare] Expression::reduce is a private method. Expression is friend
with the right classes
This commit is contained in:
@@ -45,9 +45,7 @@ public:
|
||||
private:
|
||||
// Layout
|
||||
bool needsParenthesesWithParent(const SerializationHelperInterface * parentNode) const override;
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return LayoutHelper::Infix(Expression(this), floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
LayoutRef createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override;
|
||||
int serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const override {
|
||||
return SerializationHelper::Infix(this, buffer, bufferSize, floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
@@ -13,11 +13,13 @@ namespace Poincare {
|
||||
class Context;
|
||||
|
||||
class Expression : public TreeByValue {
|
||||
friend class AdditionNode;
|
||||
friend class ExpressionNode;
|
||||
friend class MultiplicationNode;
|
||||
friend class NAryExpressionNode;
|
||||
friend class SubtractionNode;
|
||||
friend class Multiplication;
|
||||
friend class Subtraction;
|
||||
friend class Addition;
|
||||
friend class Opposite;
|
||||
friend class Symbol;
|
||||
friend class Decimal;
|
||||
public:
|
||||
/* Constructor & Destructor */
|
||||
Expression() : Expression(nullptr) {}
|
||||
@@ -106,7 +108,6 @@ public:
|
||||
/* Simplification */
|
||||
static Expression ParseAndSimplify(const char * text, Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression simplify(Context & context, Preferences::AngleUnit angleUnit);
|
||||
Expression deepReduce(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
/* Approximation Helper */
|
||||
template<typename U> Expression approximate(Context& context, Preferences::AngleUnit angleUnit, Preferences::Preferences::ComplexFormat complexFormat) const;
|
||||
@@ -126,14 +127,14 @@ public:
|
||||
|
||||
protected:
|
||||
Expression(const ExpressionNode * n) : TreeByValue(n) {}
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
private:
|
||||
/* Properties */
|
||||
int getPolynomialCoefficients(char symbolName, Expression coefficients[], Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
/* Simplification */
|
||||
Expression shallowReduce(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
Expression deepReduce(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
Expression shallowBeautify(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
Expression deepBeautify(Context & context, Preferences::AngleUnit angleUnit) const;
|
||||
|
||||
|
||||
@@ -53,6 +53,10 @@ bool AdditionNode::needsParenthesesWithParent(const SerializationHelperInterface
|
||||
return static_cast<const ExpressionNode *>(parentNode)->isOfType(types, 6);
|
||||
}
|
||||
|
||||
LayoutRef AdditionNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutHelper::Infix(Addition(this), floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
// Simplication
|
||||
|
||||
Expression AdditionNode::shallowReduce(Context& context, Preferences::AngleUnit angleUnit) const {
|
||||
|
||||
@@ -129,7 +129,7 @@ bool MultiplicationNode::needsParenthesesWithParent(const SerializationHelperInt
|
||||
|
||||
LayoutRef MultiplicationNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
const char middleDotString[] = {Ion::Charset::MiddleDot, 0};
|
||||
return LayoutHelper::Infix(Expression(this), floatDisplayMode, numberOfSignificantDigits, middleDotString);
|
||||
return LayoutHelper::Infix(Multiplication(this), floatDisplayMode, numberOfSignificantDigits, middleDotString);
|
||||
}
|
||||
|
||||
int MultiplicationNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
|
||||
@@ -35,7 +35,7 @@ bool SubtractionNode::needsParenthesesWithParent(const SerializationHelperInterf
|
||||
}
|
||||
|
||||
LayoutRef SubtractionNode::createLayout(Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
return LayoutHelper::Infix(Expression(this), floatDisplayMode, numberOfSignificantDigits, name());
|
||||
return LayoutHelper::Infix(Subtraction(this), floatDisplayMode, numberOfSignificantDigits, name());
|
||||
}
|
||||
|
||||
int SubtractionNode::serialize(char * buffer, int bufferSize, Preferences::PrintFloatMode floatDisplayMode, int numberOfSignificantDigits) const {
|
||||
|
||||
Reference in New Issue
Block a user