[poincare] Change name and API of containType

Change-Id: I57617c13a810400a13de774b0abc23db9adf9d15
This commit is contained in:
Émilie Feral
2017-10-30 18:04:52 +01:00
parent dbddba007e
commit 8fefc092b1
2 changed files with 5 additions and 4 deletions

View File

@@ -148,7 +148,8 @@ public:
/* Simplification */
static void simplify(Expression ** expressionAddress, Context & context, AngleUnit angleUnit = AngleUnit::Default);
bool containType(Type type) const;
typedef bool (*ExpressionTest)(const Expression * e);
bool recursivelyMatches(ExpressionTest test) const;
/* Evaluation Engine
* The function evaluate creates a new expression and thus mallocs memory.

View File

@@ -95,12 +95,12 @@ Expression * Expression::deepBeautify(Context & context, AngleUnit angleUnit) {
return e;
}
bool Expression::containType(Type t) const {
if (type() == t) {
bool Expression::recursivelyMatches(ExpressionTest test) const {
if (test(this)) {
return true;
}
for (int i = 0; i < numberOfOperands(); i++) {
if (operand(i)->containType(t)) {
if (test(operand(i))) {
return true;
}
}