public:
+ bool checkInvariant()
+ {
+ // Symbols have no children.
+ if (n.GetKind() == SYMBOL)
+ {
+ assert(children.size() ==0);
+ }
+
+ // all my parents have me as a child.
+ for (ParentsType::iterator it = parents.begin(); it != parents.end() ; it++)
+ {
+ vector<MutableASTNode *>::iterator it2 = (*it)->children.begin();
+ bool found = false;
+ for (;it2!= (*it)->children.end();it2++)
+ {
+ assert (*it2 != NULL);
+ if (*it2 == this)
+ found = true;
+ }
+ assert(found);
+ }
+
+ for (int i = 0; i < children.size(); i++)
+ {
+ // call check on all the children.
+ children[i]->checkInvariant();
+
+ // all my children have me as a parent.
+ assert (children[i]->parents.find(this) != children[i]->parents.end());
+ }
+
+ return true; // ignored.
+ }
+
+
+
MutableASTNode& getParent()
{
assert (parents.size() == 1);
removeChildren(vars); // ignore the result
children.clear();
children.insert(children.begin(), newN->children.begin(), newN->children.end());
+ for (int i = 0; i < children.size(); i++)
+ children[i]->parents.insert(this);
+
propagateUpDirty();
+ assert(newN->parents.size() == 0); // we don't copy 'em in you see.
+ newN->removeChildren(vars);
}
result = topLevel_other(result, simplifier);
+ // There should be no unapplied substitutions.
+ assert(result == simplifier->applySubstitutionMap(result));
+
// It is idempotent if there are no big ANDS (we have a special hack), and,
// if we don't introduced any new "disjoint extracts."
}
else // One side is a variable. The other is anything.
{
- bool varOnLHS = (var == children[0]);
+ bool varOnLHS = (var == children[0]);
// All the ASTNode vars need to map to their existing MutableASTNodes. So we collect all the variables
vector<MutableASTNode*> vars;
n= nf->CreateNode(OR, v, nf->CreateNode(EQ, mutable_children[1]->toASTNode(nf), c1));
else
n= nf->CreateNode(AND, v, nf->CreateNode(NOT,nf->CreateNode(EQ, mutable_children[1]->toASTNode(nf), c1)));
- }
+ }
else
{
rhs = nf->CreateTerm(ITE, width, v, smallestNumber, biggestNumber);
else
n= nf->CreateNode(AND, v, nf->CreateNode(NOT,nf->CreateNode(EQ, mutable_children[0]->toASTNode(nf), c2)));
}
-
replace(var, rhs);
MutableASTNode *newN = MutableASTNode::build(n,create);
muteParent.replaceWithAnotherNode(newN);
+ assert(muteParent.checkInvariant());
}
}
break;