SymbolicExpr::VisitAction preVisit(const SymbolicExpr::Ptr &node) { if (!seen.insert(getRawPointer(node)).second) return SymbolicExpr::TRUNCATE; // already processed this subexpression if (SymbolicExpr::LeafPtr leaf = node->isLeafNode()) { if (leaf->isVariable()) { if (defns->find(leaf->nameId()) == defns->end()) { defns->insert(leaf->nameId()); yices_type bvtype = yices_mk_bitvector_type(self->context, leaf->nBits()); ASSERT_not_null(bvtype); std::string name = "v" + StringUtility::numberToString(leaf->nameId()); yices_var_decl vdecl __attribute__((unused)) = yices_mk_var_decl(self->context, name.c_str(), bvtype); ASSERT_not_null(vdecl); } } else if (leaf->isMemory()) { if (defns->find(leaf->nameId()) == defns->end()) { defns->insert(leaf->nameId()); yices_type domain = yices_mk_bitvector_type(self->context, leaf->domainWidth()); yices_type range = yices_mk_bitvector_type(self->context, leaf->nBits()); yices_type ftype = yices_mk_function_type(self->context, &domain, 1, range); ASSERT_not_null(ftype); std::string name = "m" + StringUtility::numberToString(leaf->nameId()); yices_var_decl vdecl __attribute__((unused)) = yices_mk_var_decl(self->context, name.c_str(), ftype); ASSERT_not_null(vdecl); } } } return SymbolicExpr::CONTINUE; }
SymbolicExpr::VisitAction preVisit(const SymbolicExpr::Ptr &node) { if (!seen.insert(getRawPointer(node)).second) return SymbolicExpr::TRUNCATE; // already processed this subexpression if (SymbolicExpr::LeafPtr leaf = node->isLeafNode()) { if (leaf->isVariable()) { if (defns->find(leaf->nameId())==defns->end()) { defns->insert(leaf->nameId()); o <<"\n"; if (!leaf->comment().empty()) o <<StringUtility::prefixLines(leaf->comment(), "; ") <<"\n"; o <<"(define v" <<leaf->nameId() <<"::" <<get_typename(leaf) <<")\n"; } } else if (leaf->isMemory()) { if (defns->find(leaf->nameId())==defns->end()) { defns->insert(leaf->nameId()); o <<"\n"; if (!leaf->comment().empty()) o <<StringUtility::prefixLines(leaf->comment(), "; ") <<"\n"; o <<"(define m" <<leaf->nameId() <<"::" <<get_typename(leaf) <<")\n"; } } } return SymbolicExpr::CONTINUE; }