1 #include "encodinggraph.h"
6 EncodingGraph::EncodingGraph(CSolver * _solver) :
12 void EncodingGraph::buildGraph() {
13 ElementIterator it(solver);
15 Element * e = it.next();
29 void EncodingGraph::processElement(Element *e) {
30 uint size=e->parents.getSize();
31 for(uint i=0;i<size;i++) {
32 ASTNode * n = e->parents.get(i);
35 processPredicate((BooleanPredicate *)n);
38 processFunction((ElementFunction *)n);
46 void EncodingGraph::processFunction(ElementFunction *ef) {
47 Function *f=ef->getFunction();
48 if (f->type==OPERATORFUNC) {
49 FunctionOperator *fo=(FunctionOperator*)f;
54 void EncodingGraph::processPredicate(BooleanPredicate *b) {
58 EncodingNode * EncodingGraph::createNode(Element *e) {
59 Set *s = e->getRange();
60 EncodingNode *n = encodingMap.get(s);
62 n = new EncodingNode(s);
63 encodingMap.put(s, n);
69 void EncodingNode::addElement(Element *e) {
73 EncodingEdge::EncodingEdge(EncodingNode *_l, EncodingNode *_r) :
80 EncodingEdge::EncodingEdge(EncodingNode *_left, EncodingNode *_right, EncodingNode *_dst) :
87 uint hashEncodingEdge(EncodingEdge *edge) {
88 uintptr_t hash=(((uintptr_t) edge->left) >> 2) ^ (((uintptr_t)edge->right) >> 4) ^ (((uintptr_t)edge->dst) >> 6);
92 bool equalsEncodingEdge(EncodingEdge *e1, EncodingEdge *e2) {
93 return e1->left == e2->left && e1->right == e2->right && e1->dst == e2->dst;