mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-18 21:30:38 +01:00
Poincare: Expression::isIdenticalTo
Change-Id: I4a28b5b771efc5a00f49aeaa725c264e87e96c88
This commit is contained in:
@@ -29,7 +29,7 @@ class Expression {
|
||||
|
||||
/* identicalTo means strictly the same tree. For example, 3+5 is NOT identi-
|
||||
* cal to 5+3. Those are equal, but not identical. */
|
||||
//virtual bool identicalTo(Expression * e);
|
||||
bool isIdenticalTo(Expression * e);
|
||||
Expression * simplify();
|
||||
|
||||
virtual Type type() = 0;
|
||||
|
||||
@@ -43,3 +43,14 @@ Expression * Expression::simplify() {
|
||||
return result;
|
||||
}
|
||||
|
||||
bool Expression::isIdenticalTo(Expression * e) {
|
||||
if (e->type() != this->type() || e->numberOfOperands() != this->numberOfOperands()) {
|
||||
return false;
|
||||
}
|
||||
for (int i=0; i<this->numberOfOperands(); i++) {
|
||||
if (!e->operand(i)->isIdenticalTo(this->operand(i))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user