Merging with branch master
authorHamed <hamed.gorjiara@gmail.com>
Fri, 8 Sep 2017 21:15:09 +0000 (14:15 -0700)
committerHamed <hamed.gorjiara@gmail.com>
Fri, 8 Sep 2017 21:15:09 +0000 (14:15 -0700)
1  2 
src/Makefile
src/Serialize/deserializer.cc
src/Test/buildconstraintstest.cc
src/csolver.cc

diff --cc src/Makefile
@@@ -4,16 -4,16 +4,16 @@@ PHONY += directorie
  MKDIR_P = mkdir -p
  OBJ_DIR = bin
  
- CPP_SOURCES := $(wildcard *.cc) $(wildcard AST/*.cc) $(wildcard ASTTransform/*.cc) $(wildcard Translator/*.cc) $(wildcard ASTAnalyses/*.cc) $(wildcard Tuner/*.cc) $(wildcard Collections/*.cc) $(wildcard Backend/*.cc) $(wildcard Encoders/*.cc) $(wildcard Serialize/*.cc)
 -CPP_SOURCES := $(wildcard *.cc) $(wildcard AST/*.cc) $(wildcard ASTTransform/*.cc) $(wildcard Translator/*.cc) $(wildcard ASTAnalyses/*.cc) $(wildcard ASTAnalyses/Order/*.cc) $(wildcard ASTAnalyses/Encoding/*.cc) $(wildcard ASTAnalyses/Polarity/*.cc) $(wildcard Tuner/*.cc) $(wildcard Collections/*.cc) $(wildcard Backend/*.cc) $(wildcard Encoders/*.cc)
++CPP_SOURCES := $(wildcard *.cc) $(wildcard AST/*.cc) $(wildcard ASTTransform/*.cc) $(wildcard Translator/*.cc) $(wildcard ASTAnalyses/*.cc) $(wildcard ASTAnalyses/Order/*.cc) $(wildcard ASTAnalyses/Encoding/*.cc) $(wildcard ASTAnalyses/Polarity/*.cc) $(wildcard Tuner/*.cc) $(wildcard Collections/*.cc) $(wildcard Backend/*.cc) $(wildcard Encoders/*.cc) $(wildcard Serialize/*.cc)
  
- C_SOURCES := $(wildcard *.c) $(wildcard AST/*.c) $(wildcard ASTTransform/*.c) $(wildcard Translator/*.c) $(wildcard ASTAnalyses/*.c) $(wildcard Tuner/*.c) $(wildcard Collections/*.c) $(wildcard Backend/*.c) $(wildcard Encoders/*.c) $(wildcard Serialize/*.c)
 -C_SOURCES := $(wildcard *.c) $(wildcard AST/*.c) $(wildcard ASTTransform/*.c) $(wildcard Translator/*.c) $(wildcard ASTAnalyses/*.c) $(wildcard ASTAnalyses/Order/*.c) $(wildcard ASTAnalyses/Encoding/*.c) $(wildcard ASTAnalyses/Polarity/*.c) $(wildcard Tuner/*.c) $(wildcard Collections/*.c) $(wildcard Backend/*.c) $(wildcard Encoders/*.c)
++C_SOURCES := $(wildcard *.c) $(wildcard AST/*.c) $(wildcard ASTTransform/*.c) $(wildcard Translator/*.c) $(wildcard ASTAnalyses/*.c) $(wildcard ASTAnalyses/Order/*.c) $(wildcard ASTAnalyses/Encoding/*.c) $(wildcard ASTAnalyses/Polarity/*.c) $(wildcard Tuner/*.c) $(wildcard Collections/*.c) $(wildcard Backend/*.c) $(wildcard Encoders/*.c) $(wildcard Serialize/*.c)
  
- HEADERS := $(wildcard *.h) $(wildcard AST/*.h) $(wildcard ASTTransform/*.h) $(wildcard Translator/*.h) $(wildcard ASTAnalyses/*.h) $(wildcard Tuner/*.h) $(wildcard Collections/*.h) $(wildcard Backend/*.h) $(wildcard Encoders/*.h) $(wildcard Serialize/*.h)
 -HEADERS := $(wildcard *.h) $(wildcard AST/*.h) $(wildcard ASTTransform/*.h) $(wildcard Translator/*.h) $(wildcard ASTAnalyses/*.h) $(wildcard ASTAnalyses/Order/*.h) $(wildcard ASTAnalyses/Encoding/*.h) $(wildcard ASTAnalyses/Polarity/*.h) $(wildcard Tuner/*.h) $(wildcard Collections/*.h) $(wildcard Backend/*.h) $(wildcard Encoders/*.h)
++HEADERS := $(wildcard *.h) $(wildcard AST/*.h) $(wildcard ASTTransform/*.h) $(wildcard Translator/*.h) $(wildcard ASTAnalyses/*.h) $(wildcard ASTAnalyses/Order/*.h) $(wildcard ASTAnalyses/Encoding/*.h) $(wildcard ASTAnalyses/Polarity/*.h) $(wildcard Tuner/*.h) $(wildcard Collections/*.h) $(wildcard Backend/*.h) $(wildcard Encoders/*.h) $(wildcard Serialize/*.h)
  
  OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
  
  CFLAGS := -Wall -g -O0
- CFLAGS += -IAST -IASTTransform -IASTAnalyses -ITranslator -ICollections -IBackend -I. -IEncoders -ITuner -ISerialize
 -CFLAGS += -IAST -IASTTransform -IASTAnalyses -IASTAnalyses/Polarity -IASTAnalyses/Order -IASTAnalyses/Encoding -ITranslator -ICollections -IBackend -I. -IEncoders -ITuner
++CFLAGS += -IAST -IASTTransform -IASTAnalyses -IASTAnalyses/Polarity -IASTAnalyses/Order -IASTAnalyses/Encoding -ITranslator -ICollections -IBackend -I. -IEncoders -ITuner -ISerialize
  LDFLAGS := -ldl -lrt -rdynamic
  SHARED := -shared
  
index 163bd19,0000000..bf97cbb
mode 100644,000000..100644
--- /dev/null
@@@ -1,83 -1,0 +1,86 @@@
 +
 +/* 
 + * File:   deserializer.cc
 + * Author: hamed
 + * 
 + * Created on September 7, 2017, 6:08 PM
 + */
 +
 +#include "deserializer.h"
 +#include "csolver.h"
 +#include "unistd.h"
 +#include "fcntl.h"
 +
 +Deserializer::Deserializer(const char* file):
 +      solver(new CSolver())
 +{
 +      filedesc = open(file, O_RDONLY);
 + 
 +      if (filedesc < 0) {
 +              exit(-1);
 +      }
 +}
 +
 +Deserializer::~Deserializer() {
 +      delete solver;
 +}
 +
 +ssize_t Deserializer::myread(void* __buf, size_t __nbytes){
 +      ssize_t t = read (filedesc, __buf, __nbytes);
 +      write (1, __buf, __nbytes);
 +      model_print("read\n");
 +      return t;
 +}
 +
 +CSolver * Deserializer::deserialize(){
 +      ASTNodeType nodeType;
 +      while(myread(&nodeType, sizeof(ASTNodeType) ) >0){
 +              switch(nodeType){
 +                      case BOOLEANEDGE:
 +                              deserializeBooleanEdge();
 +                              break;
 +                      case BOOLEANVAR:
 +                              deserializeBooleanVar();
 +                              break;
++                      case ORDERCONST:
++                              deserializeBooleanOrder();
++                              break;
 +                      default:
 +                              ASSERT(0);
 +              }
 +      }
 +      return solver;
 +}
 +
 +void Deserializer::deserializeBooleanEdge(){
 +      Boolean *b;
 +      myread(&b, sizeof(Boolean*));
 +      BooleanEdge tmp(b);
 +      bool isNegated = tmp.isNegated();
 +      ASSERT(map.contains(tmp.getBoolean()));
 +      b = (Boolean*) map.get(tmp.getBoolean());
 +      BooleanEdge res(b);
 +      solver->addConstraint(isNegated?res.negate():res);
 +}
 +
 +void Deserializer::deserializeBooleanVar(){
 +      BooleanVar *b;
 +      myread(&b, sizeof(BooleanVar*));
 +      VarType vtype;
 +      myread(&vtype, sizeof(VarType));
 +      map.put(b, solver->getBooleanVar(vtype).getBoolean());
 +}
 +
 +void Deserializer::deserializeBooleanOrder(){
 +      BooleanOrder* bo_ptr;
 +      myread(&bo_ptr, sizeof(BooleanOrder*));
 +      Order* optr;
 +      myread(&optr, sizeof(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());
 +}
diff --cc src/csolver.cc
Simple merge