[poincare] Expression::ExpressionWithoutSymbol does not take into

account SystemSymbol (UnknownX)
This commit is contained in:
Émilie Feral
2018-11-15 17:34:58 +01:00
parent 140ccbfa77
commit acdb4ca357
3 changed files with 5 additions and 0 deletions

View File

@@ -70,6 +70,7 @@ public:
return Expression();
}
// Symbol properties
bool isSystemSymbol() const { return name()[0] == SpecialSymbols::UnknownX && name()[1] == 0; }
static bool isSeriesSymbol(const char * c);
static bool isRegressionSymbol(const char * c);
bool matches(ExpressionTest test, Context & context) const;

View File

@@ -226,6 +226,7 @@ void Expression::defaultSetChildrenInPlace(Expression other) {
bool Expression::hasReplaceableSymbols(Context & context) const {
return recursivelyMatches([](const Expression e, Context & context, bool replaceSymbols) {
return (e.type() == ExpressionNode::Type::Symbol
&& !static_cast<const Symbol &>(e).isSystemSymbol()
&& !context.expressionForSymbol(static_cast<const Symbol &>(e)).isUninitialized())
|| (e.type() == ExpressionNode::Type::Function
&& !context.expressionForSymbol(static_cast<const Function &>(e)).isUninitialized());

View File

@@ -204,6 +204,9 @@ int Symbol::getPolynomialCoefficients(Context & context, const char * symbolName
}
Expression Symbol::replaceReplaceableSymbols(Context & context) {
if (isSystemSymbol()) {
return *this;
}
Expression e = context.expressionForSymbol(*this);
if (e.isUninitialized()) {
return *this;