Fixing bugs ...
authorHamed <hamed.gorjiara@gmail.com>
Mon, 11 Sep 2017 20:29:28 +0000 (13:29 -0700)
committerHamed <hamed.gorjiara@gmail.com>
Mon, 11 Sep 2017 20:29:28 +0000 (13:29 -0700)
src/AST/boolean.cc
src/AST/table.cc
src/Serialize/deserializer.cc
src/Serialize/serializer.cc
src/csolver.cc

index 565e0ef..8a6f0d3 100644 (file)
@@ -114,6 +114,7 @@ void BooleanOrder::serialize(Serializer* serializer){
                return;
        serializer->addObject(this);
        order->serialize(serializer);
+       
        serializer->mywrite(&type, sizeof(ASTNodeType));
        BooleanOrder* This = this;
        serializer->mywrite(&This, sizeof(BooleanOrder*));
@@ -144,7 +145,7 @@ void BooleanPredicate::serialize(Serializer* serializer){
                Element *input = inputs.get(i);
                serializer->mywrite(&input, sizeof(Element *));
        }
-       Boolean* undefStat = undefStatus.getRaw();
+       Boolean* undefStat = undefStatus!= BooleanEdge(NULL)?undefStatus.getRaw() : NULL;
        serializer->mywrite(&undefStat, sizeof(Boolean*));
 }
 
index 4ce6270..828cd79 100644 (file)
@@ -71,7 +71,8 @@ void Table::serialize(Serializer* serializer){
                Set* domain = domains.get(i);
                domain->serialize(serializer);
        }
-       range->serialize(serializer);
+       if(range!= NULL)
+               range->serialize(serializer);
        
        ASTNodeType type = TABLETYPE;   
        serializer->mywrite(&type, sizeof(ASTNodeType));
@@ -91,7 +92,6 @@ void Table::serialize(Serializer* serializer){
                serializer->mywrite(&entry->output, sizeof(uint64_t));
                serializer->mywrite(&entry->inputSize, sizeof(uint));
                serializer->mywrite(entry->inputs, sizeof(uint64_t) * entry->inputSize);
-               ASSERT(0);
        }
 }
 
index 2b431de..0e6839d 100644 (file)
@@ -110,14 +110,14 @@ void Deserializer::deserializeBooleanVar(){
 void Deserializer::deserializeBooleanOrder(){
        BooleanOrder* bo_ptr;
        myread(&bo_ptr, sizeof(BooleanOrder*));
-       Order* optr;
-       myread(&optr, sizeof(Order*));
+       Order* order;
+       myread(&order, sizeof(Order*));
+       ASSERT(map.contains(order));
+       order  = (Order*) map.get(order);
        uint64_t first;
        myread(&first, sizeof(uint64_t));
        uint64_t second;
        myread(&second, sizeof(uint64_t));
-       ASSERT(map.contains(optr));
-       Order* order  = (Order*) map.get(optr);
        map.put(bo_ptr, solver->orderConstraint(order, first, second).getBoolean());
 }
 
@@ -191,13 +191,17 @@ void Deserializer::deserializeBooleanPredicate(){
        
        Boolean* stat_ptr;
        myread(&stat_ptr, sizeof(Boolean *));
-       BooleanEdge tmp(stat_ptr);
-       bool isNegated = tmp.isNegated();
-       ASSERT(map.contains(tmp.getBoolean()));
-       stat_ptr = (Boolean*) map.get(tmp.getBoolean());
-       BooleanEdge res(stat_ptr);
-       BooleanEdge undefStatus = isNegated?res.negate():res;
-       
+       BooleanEdge undefStatus;
+       if(stat_ptr != NULL){
+               BooleanEdge tmp(stat_ptr);
+               bool isNegated = tmp.isNegated();
+               ASSERT(map.contains(tmp.getBoolean()));
+               stat_ptr = (Boolean*) map.get(tmp.getBoolean());
+               BooleanEdge res(stat_ptr);
+               undefStatus = isNegated?res.negate():res;
+       } else {
+               undefStatus = NULL;
+       }
        map.put(bp_ptr, solver->applyPredicateTable(predicate, members.expose(), size, undefStatus).getBoolean());
 }
 
@@ -248,8 +252,10 @@ void Deserializer::deserializeTable(){
        }
        Set* range;
        myread(&range, sizeof(Set*));
-       ASSERT(map.contains(range));
-       range = (Set*) map.get(range);
+       if(range != NULL){
+               ASSERT(map.contains(range));
+               range = (Set*) map.get(range);
+       }
        Table* table = solver->createTable(domains.expose(), size, range);
        myread(&size, sizeof(uint));
        for(uint i=0; i<size; i++){
@@ -260,7 +266,6 @@ void Deserializer::deserializeTable(){
                Vector<uint64_t> inputs;
                inputs.setSize(inputSize);
                myread(inputs.expose(), sizeof(uint64_t)*inputSize);
-               ASSERT(0);
                table->addNewTableEntry(inputs.expose(), inputSize, output);
        }
        
index 524f9ee..96e81aa 100644 (file)
@@ -31,6 +31,8 @@ void Serializer::mywrite(const void *__buf, size_t __n){
 
 
 void serializeBooleanEdge(Serializer* serializer, BooleanEdge be){
+       if(be == BooleanEdge(NULL))
+               return;
        be.getBoolean()->serialize(serializer);
        ASTNodeType type = BOOLEANEDGE;
        serializer->mywrite(&type, sizeof(ASTNodeType));
index ce749b1..0eebb17 100644 (file)
@@ -228,7 +228,7 @@ BooleanEdge CSolver::getBooleanFalse() {
 }
 
 BooleanEdge CSolver::applyPredicate(Predicate *predicate, Element **inputs, uint numInputs) {
-       return applyPredicateTable(predicate, inputs, numInputs, NULL);
+       return applyPredicateTable(predicate, inputs, numInputs, BooleanEdge(NULL));
 }
 
 BooleanEdge CSolver::applyPredicateTable(Predicate *predicate, Element **inputs, uint numInputs, BooleanEdge undefinedStatus) {