Bug fix for serializing Boolean Const ...
authorHamed Gorjiara <hgorjiar@uci.edu>
Thu, 4 Oct 2018 22:01:25 +0000 (15:01 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Thu, 4 Oct 2018 22:01:25 +0000 (15:01 -0700)
src/AST/boolean.cc
src/AST/boolean.h
src/Serialize/deserializer.cc
src/Serialize/deserializer.h

index 647f548..e63549e 100644 (file)
@@ -116,6 +116,16 @@ void BooleanVar::serialize(Serializer *serializer) {
        serializer->mywrite(&vtype, sizeof(VarType));
 }
 
+void BooleanConst::serialize(Serializer *serializer) {
+       if (serializer->isSerialized(this))
+               return;
+       serializer->addObject(this);
+       serializer->mywrite(&type, sizeof(ASTNodeType));
+       BooleanConst *This = this;
+       serializer->mywrite(&This, sizeof(BooleanConst *));
+       serializer->mywrite(&istrue, sizeof(bool));
+}
+
 void BooleanVar::print() {
        model_print("BooleanVar<%p>\n", this);
 }
index 77dc244..dd1b580 100644 (file)
@@ -35,7 +35,7 @@ public:
        Boolean *clone(CSolver *solver, CloneMap *map);
        bool isTrue() {return istrue;}
        bool isFalse() {return !istrue;}
-       void serialize(Serializer *serializer ) {};
+       void serialize(Serializer *serializer );
        virtual void print();
        bool istrue;
        CMEMALLOC;
index 2c4d7bb..548619f 100644 (file)
@@ -76,6 +76,9 @@ CSolver *Deserializer::deserialize() {
                case BOOLEANVAR:
                        deserializeBooleanVar();
                        break;
+               case BOOLCONST:
+                       deserializeBooleanConst();
+                       break;
                case ORDERCONST:
                        deserializeBooleanOrder();
                        break;
@@ -145,6 +148,15 @@ void Deserializer::deserializeBooleanVar() {
        map.put(b, solver->getBooleanVar(vtype).getBoolean());
 }
 
+void Deserializer::deserializeBooleanConst() {
+       BooleanVar *b;
+       myread(&b, sizeof(BooleanVar *));
+       bool istrue;
+       myread(&istrue, sizeof(bool));
+       map.put(b, istrue?solver->getBooleanTrue().getBoolean():
+                       solver->getBooleanFalse().getBoolean());
+}
+
 void Deserializer::deserializeBooleanOrder() {
        BooleanOrder *bo_ptr;
        myread(&bo_ptr, sizeof(BooleanOrder *));
index c56911d..81baeef 100644 (file)
@@ -26,6 +26,7 @@ private:
        ssize_t myread (void *__buf, size_t __nbytes);
        void deserializeBooleanEdge();
        void deserializeBooleanVar();
+       void deserializeBooleanConst();
        void deserializeBooleanOrder();
        void deserializeOrder();
        void deserializeSet();