Merge branch 'master' of ssh://demsky.eecs.uci.edu/home/git/constraint_compiler into...
authorHamed <hamed.gorjiara@gmail.com>
Wed, 20 Sep 2017 21:29:52 +0000 (14:29 -0700)
committerHamed <hamed.gorjiara@gmail.com>
Wed, 20 Sep 2017 21:29:52 +0000 (14:29 -0700)
src/AST/iterator.cc
src/AST/set.cc
src/ASTAnalyses/Encoding/encodinggraph.cc

index 2a18889..2b0dea4 100644 (file)
@@ -72,7 +72,7 @@ ElementIterator::ElementIterator(CSolver *_solver) :
        bit(_solver),
        base(NULL),
        baseindex(0) {
-       
+       updateNext();
 }
 
 ElementIterator::~ElementIterator() {
@@ -100,7 +100,8 @@ void ElementIterator::updateNext() {
                                        if (discovered.add(e)) {
                                                element.push(e);
                                                index.push(0);
-                                       }
+                                       } else
+                                               continue;
                                }
                        } else {
                                if (bit.hasNext()) {
index bd1b3d6..d3801f8 100644 (file)
@@ -40,12 +40,12 @@ bool Set::exists(uint64_t element) {
                        uint middle=(low+high)/2;
                        uint64_t val=members->get(middle);
                        if (element < val) {
-                               high=middle;
-                               if (middle==low)
+                               high=middle-1;
+                               if (middle<=low)
                                        return false;
                        } else if (element > val) {
-                               low=middle;
-                               if (middle==high)
+                               low=middle+1;
+                               if (middle>=high)
                                        return false;
                        } else {
                                return true;
index 9231ad6..6589976 100644 (file)
@@ -63,13 +63,16 @@ void EncodingGraph::encode() {
                        ElementEncoding *encoding=e->getElementEncoding();
                        if (encoding->getElementEncodingType() == ELEM_UNASSIGNED) {
                                EncodingNode *n = getNode(e);
-                               ASSERT(n != NULL);
+                               if (n == NULL)
+                                       continue;
                                ElementEncodingType encodetype=n->getEncoding();
                                encoding->setElementEncodingType(encodetype);
                                if (encodetype == UNARY || encodetype == ONEHOT) {
                                        encoding->encodingArrayInitialization();
                                } else if (encodetype == BINARYINDEX) {
                                        EncodingSubGraph * subgraph = graphMap.get(n);
+                                       if (subgraph == NULL)
+                                               continue;
                                        uint encodingSize = subgraph->getEncodingSize(n);
                                        uint paddedSize = encoding->getSizeEncodingArray(encodingSize);
                                        encoding->allocInUseArrayElement(paddedSize);