Beispiel #1
0
 void STPMgr::printVarDeclsToStream(ostream &os, ASTNodeSet& ListOfDeclaredVars) {
   for(ASTNodeSet::iterator
         i = ListOfDeclaredVars.begin(),iend=ListOfDeclaredVars.end();
       i!=iend;i++) 
     {
       BEEV::ASTNode a = *i;
       switch(a.GetType()) {
       case BEEV::BITVECTOR_TYPE:
         a.PL_Print(os);
         os << " : BITVECTOR(" << a.GetValueWidth() << ");" << endl;
         break;
       case BEEV::ARRAY_TYPE:
         a.PL_Print(os);
         os << " : ARRAY " << "BITVECTOR(" << a.GetIndexWidth() << ") OF ";
         os << "BITVECTOR(" << a.GetValueWidth() << ");" << endl;
         break;
       case BEEV::BOOLEAN_TYPE:
         a.PL_Print(os);
         os << " : BOOLEAN;" << endl;
         break;
       default:
         BEEV::FatalError("vc_printDeclsToStream: Unsupported type",a);
         break;
       }
     }
 } //printVarDeclsToStream
Beispiel #2
0
void vc_printQueryStateToBuffer(VC vc, Expr e, char **buf, unsigned long *len, int simplify_print){
  assert(vc);
  assert(e);
  assert(buf);
  assert(len);
  bmstar b = (bmstar)vc;

  // formate the state of the query
  stringstream os;
  vc_printVarDeclsToStream(vc, os);
  os << "%----------------------------------------------------" << endl;
  vc_printAssertsToStream(vc, os, simplify_print);
  os << "%----------------------------------------------------" << endl;
  os << "QUERY( ";
  b->Begin_RemoveWrites = true;
  BEEV::ASTNode q = (simplify_print == 1) ? b->SimplifyFormula_TopLevel(*((nodestar)e),false) : *(nodestar)e;
  b->Begin_RemoveWrites = false;    
  q.PL_Print(os);
  os << " );" << endl;

  // convert to a c buffer
  string s = os.str();
  const char *cstr = s.c_str();
  unsigned long size = s.size() + 1; // number of chars + terminating null
  *buf = (char *)malloc(size);
  if (!(*buf)) {
    fprintf(stderr, "malloc(%lu) failed.", size);
    assert(*buf);
  }
  *len = size;
  memcpy(*buf, cstr, size);
}
Beispiel #3
0
// Expr I/O
void vc_printExpr(VC vc, Expr e) {
  //do not print in lisp mode
  //bmstar b = (bmstar)vc;
  BEEV::ASTNode q = (*(nodestar)e);
  //   b->Begin_RemoveWrites = true;
  //   BEEV::ASTNode q = b->SimplifyFormula_TopLevel(*((nodestar)e),false);
  //   b->Begin_RemoveWrites = false;    
  q.PL_Print(cout);
}
Beispiel #4
0
void vc_printQuery(VC vc){
  ostream& os = std::cout;
  bmstar b = (bmstar)vc;
  os << "QUERY(";
  //b->Begin_RemoveWrites = true;
  //BEEV::ASTNode q = b->SimplifyFormula_TopLevel(b->GetQuery(),false);
  BEEV::ASTNode q = b->GetQuery();
  //b->Begin_RemoveWrites = false;    
  q.PL_Print(os);
  // b->GetQuery().PL_Print(os);
  os << ");" << endl;
}
Beispiel #5
0
static void vc_printAssertsToStream(VC vc, ostream &os, int simplify_print) {
  bmstar b = (bmstar)vc;
  BEEV::ASTVec v = b->GetAsserts();
  for(BEEV::ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++) {
    b->Begin_RemoveWrites = true;
    BEEV::ASTNode q = (simplify_print == 1) ? b->SimplifyFormula_TopLevel(*i,false) : *i;
    q = (simplify_print == 1) ? b->SimplifyFormula_TopLevel(q,false) : q;
    b->Begin_RemoveWrites = false;
    os << "ASSERT( ";
    q.PL_Print(os);
    os << ");" << endl;
  }
}
Beispiel #6
0
void vc_printExprToBuffer(VC vc, Expr e, char **buf, unsigned long * len) {
  stringstream os;
  //bmstar b = (bmstar)vc;
  BEEV::ASTNode q = *((nodestar)e);
  // b->Begin_RemoveWrites = true;
  //   BEEV::ASTNode q = b->SimplifyFormula_TopLevel(*((nodestar)e),false);
  //   b->Begin_RemoveWrites = false;    
  q.PL_Print(os);
  //((nodestar)e)->PL_Print(os);
  string s = os.str();
  const char * cstr = s.c_str();
  unsigned long size = s.size() + 1; // number of chars + terminating null
  *buf = (char *)malloc(size);
  *len = size;
  memcpy(*buf, cstr, size);
}