Add the isCommutative method to expression.

Change-Id: I657df96c5e24168ecd04470252549ed84eb2cfe3
This commit is contained in:
Felix Raimundo
2016-04-04 17:45:08 +02:00
parent b7a1bb9cdb
commit ac29d1e9aa
4 changed files with 11 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ class CommutativeOperation : public Expression {
int numberOfOperands() override;
float approximate(Context& context) override;
ExpressionLayout * createLayout() override;
bool isCommutative() override;
protected:
virtual float operateApproximatevelyOn(float a, float b) = 0;
virtual char operatorChar() = 0;

View File

@@ -40,6 +40,7 @@ class Expression {
Expression * simplify();
virtual Type type() = 0;
virtual bool isCommutative();
virtual float approximate(Context& context) = 0;
};

View File

@@ -57,3 +57,8 @@ ExpressionLayout * CommutativeOperation::createLayout() {
}
return new HorizontalLayout(children_layouts, number_of_children);
}
bool CommutativeOperation::isCommutative() {
return true;
}

View File

@@ -63,3 +63,7 @@ bool Expression::valueEquals(Expression * e) {
* -riden. */
return true;
}
bool Expression::isCommutative() {
return false;
}