[poincare] In rulegen, do not sort children of non-commutative nodes!!

Change-Id: Ibe228f400e688a17aeff4721fe6e77ab4bca1373
This commit is contained in:
Émilie Feral
2017-10-02 14:14:16 +02:00
parent 1a000540fa
commit d4e5f60b5c
2 changed files with 11 additions and 1 deletions

View File

@@ -186,6 +186,9 @@ void Node::sort() {
for (Node * child : *m_children) {
child->sort();
}
if (!isCommutative()) {
return;
}
for (int i = m_children->size()-1; i > 0; i--) {
bool isSorted = true;
for (int j = 0; j < m_children->size()-1; j++) {
@@ -200,6 +203,13 @@ void Node::sort() {
}
}
bool Node::isCommutative() {
if (m_name->compare("Addition") == 0 || m_name->compare("Multiplication") == 0) {
return true;
}
return false;
}
#if 0
std::string Node::generateSelectorConstructor(Rule * context) {

View File

@@ -30,7 +30,7 @@ public:
private:
int selectorCaptureIndexInRule(Rule * rule);
int selectorIndexInRule(Rule * rule);
bool isCommutative();
/*
int generateTree(bool selector, Rule * context, int index, int indentationLevel);
std::string generateSelectorConstructor(Rule * context);