Adding a new testcase ... -Shows bugs that need to be fixed
authorHamed Gorjiara <hgorjiar@uci.edu>
Mon, 23 Oct 2017 10:30:13 +0000 (03:30 -0700)
committerHamed Gorjiara <hgorjiar@uci.edu>
Mon, 23 Oct 2017 10:30:13 +0000 (03:30 -0700)
src/Test/deserializer.cc [new file with mode: 0644]
src/csolver.cc
src/csolver.h

diff --git a/src/Test/deserializer.cc b/src/Test/deserializer.cc
new file mode 100644 (file)
index 0000000..85fffc3
--- /dev/null
@@ -0,0 +1,13 @@
+#include "csolver.h"
+
+
+int main(int argc, char ** argv){
+       if(argc != 2){
+               printf("You only specify the name of the file ...");
+               exit(-1);       
+       }
+       CSolver* solver = CSolver::deserialize(argv[1]);
+       solver->printConstraints();
+       return 1;
+               
+}
index 8132991..624160e 100644 (file)
@@ -49,8 +49,6 @@ CSolver::~CSolver() {
        size = allElements.getSize();
        for (uint i = 0; i < size; i++) {
                 Element* el = allElements.get(i);
-                model_print("deleting ...%u", i);
-                ASSERT(el != NULL);
                delete el;
        }
 
@@ -90,22 +88,21 @@ CSolver *CSolver::clone() {
        return copy;
 }
 
+CSolver* CSolver::deserialize(const char * file){
+       model_print("deserializing ...\n");
+       Deserializer deserializer(file);
+       return deserializer.deserialize();
+}
+
 void CSolver::serialize() {
        model_print("serializing ...\n");
-       {
-               Serializer serializer("dump");
-               SetIteratorBooleanEdge *it = getConstraints();
-               while (it->hasNext()) {
-                       BooleanEdge b = it->next();
-                       serializeBooleanEdge(&serializer, b);
-               }
-               delete it;
+       Serializer serializer("dump");
+       SetIteratorBooleanEdge *it = getConstraints();
+       while (it->hasNext()) {
+               BooleanEdge b = it->next();
+               serializeBooleanEdge(&serializer, b);
        }
-//     model_print("deserializing ...\n");
-//     {
-//             Deserializer deserializer("dump");
-//             deserializer.deserialize();
-//     }
+       delete it;
 }
 
 Set *CSolver::createSet(VarType type, uint64_t *elements, uint numelements) {
@@ -151,7 +148,6 @@ void CSolver::finalizeMutableSet(MutableSet *set) {
 
 Element *CSolver::getElementVar(Set *set) {
        Element *element = new ElementSet(set);
-        model_println("%%%%ElementVar:%u", allElements.getSize());
        allElements.push(element);
        return element;
 }
@@ -168,7 +164,6 @@ Element *CSolver::getElementConst(VarType type, uint64_t value) {
        Element *e = elemMap.get(element);
        if (e == NULL) {
                allSets.push(set);
-                model_println("%%%%ElementConst:%u", allElements.getSize());
                allElements.push(element);
                elemMap.put(element, element);
                return element;
@@ -184,7 +179,6 @@ Element *CSolver::applyFunction(Function *function, Element **array, uint numArr
        Element *e = elemMap.get(element);
        if (e == NULL) {
                element->updateParents();
-                model_println("%%%%ElementFunction:%u", allElements.getSize());
                allElements.push(element);
                elemMap.put(element, element);
                return element;
index 15d5b45..aa44a02 100644 (file)
@@ -151,6 +151,7 @@ public:
        void replaceBooleanWithBoolean(BooleanEdge oldb, BooleanEdge newb);
        CSolver *clone();
        void serialize();
+       static CSolver* deserialize(const char * file);
        void autoTune(uint budget);
 
        void setTuner(Tuner *_tuner) { tuner = _tuner; }