本文整理汇总了C++中ASTVec类的典型用法代码示例。如果您正苦于以下问题:C++ ASTVec类的具体用法?C++ ASTVec怎么用?C++ ASTVec使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ASTVec类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateSimpXor
ASTNode STPMgr::CreateSimpXor(const ASTNode& form1, const ASTNode& form2)
{
ASTVec children;
children.push_back(form1);
children.push_back(form2);
return CreateSimpXor(children);
}
示例2: searchTerm
bool PropagateEqualities::searchTerm(const ASTNode& lhs, const ASTNode& rhs)
{
const unsigned width = lhs.GetValueWidth();
if (lhs == rhs)
return true;
if (lhs.GetKind() == SYMBOL)
return simp->UpdateSubstitutionMap(lhs, rhs); // checks whether it's been
// solved for, or if the RHS
// contains the LHS.
if (lhs.GetKind() == BVUMINUS)
return searchTerm(lhs[0], nf->CreateTerm(BVUMINUS, width, rhs));
if (lhs.GetKind() == BVNEG)
return searchTerm(lhs[0], nf->CreateTerm(BVNEG, width, rhs));
if (lhs.GetKind() == BVXOR || lhs.GetKind() == BVPLUS)
for (size_t i = 0; i < lhs.Degree(); i++)
{
ASTVec others;
for (size_t j = 0; j < lhs.Degree(); j++)
if (j != i)
others.push_back(lhs[j]);
ASTNode new_rhs;
if (lhs.GetKind() == BVXOR)
{
others.push_back(rhs);
assert(others.size() > 1);
new_rhs = nf->CreateTerm(lhs.GetKind(), width, others);
}
else if (lhs.GetKind() == BVPLUS)
{
if (others.size() > 1)
new_rhs = nf->CreateTerm(BVPLUS, width, others);
else
new_rhs = others[0];
new_rhs = nf->CreateTerm(BVUMINUS, width, new_rhs);
new_rhs = nf->CreateTerm(BVPLUS, width, new_rhs, rhs);
}
else
FatalError("sdafasfsdf2q3234423");
bool result = searchTerm(lhs[i], new_rhs);
if (result)
return true;
}
if (lhs.Degree() == 2 && lhs.GetKind() == BVMULT && lhs[0].isConstant() &&
simp->BVConstIsOdd(lhs[0]))
return searchTerm(lhs[1],
nf->CreateTerm(BVMULT, width,
simp->MultiplicativeInverse(lhs[0]), rhs));
return false;
}
示例3: if
// Does some simple caching of prior results.
void
Cpp_interface::checkSat(const ASTVec & assertionsSMT2)
{
if (ignoreCheckSatRequest)
return;
bm.GetRunTimes()->stop(RunTimes::Parsing);
checkInvariant();
assert(assertionsSMT2.size() == cache.size());
Entry& last_run = cache.back();
if ((last_run.node_number != assertionsSMT2.back().GetNodeNum()) && (last_run.result == SOLVER_SATISFIABLE))
{
// extra asserts might have been added to it,
// flipping from sat to unsat. But never from unsat to sat.
last_run.result = SOLVER_UNDECIDED;
}
// We might have run this query before, or it might already be shown to be unsat. If it was sat,
// we've stored the result (but not the model), so we can shortcut and return what we know.
if (!((last_run.result == SOLVER_SATISFIABLE) || last_run.result == SOLVER_UNSATISFIABLE))
{
resetSolver();
ASTNode query;
if (assertionsSMT2.size() > 1)
query = nf->CreateNode(AND, assertionsSMT2);
else if (assertionsSMT2.size() == 1)
query = assertionsSMT2[0];
else
query = bm.ASTTrue;
SOLVER_RETURN_TYPE last_result = GlobalSTP->TopLevelSTP(query, bm.ASTFalse);
// Store away the answer. Might be timeout, or error though..
last_run = Entry(last_result);
last_run.node_number = assertionsSMT2.back().GetNodeNum();
// It's satisfiable, so everything beneath it is satisfiable too.
if (last_result == SOLVER_SATISFIABLE)
{
for (int i = 0; i < cache.size(); i++)
{
assert(cache[i].result != SOLVER_UNSATISFIABLE);
cache[i].result = SOLVER_SATISFIABLE;
}
}
}
if (bm.UserFlags.quick_statistics_flag)
{
bm.GetRunTimes()->print();
}
(GlobalSTP->tosat)->PrintOutput(last_run.result);
bm.GetRunTimes()->start(RunTimes::Parsing);
}
示例4: CreateSimpAndOr
ASTNode STPMgr::CreateSimpAndOr(bool IsAnd,
const ASTNode& form1, const ASTNode& form2)
{
ASTVec children;
children.push_back(form1);
children.push_back(form2);
return CreateSimpAndOr(IsAnd, children);
}
示例5: CreateSimpForm
ASTNode STPMgr::CreateSimpForm(Kind kind, const ASTNode& child0)
{
ASTVec children;
//child_stack.clear(); // could just reset top pointer.
children.push_back(child0);
//child_stack.push_back(child0);
return CreateSimpForm(kind, children);
//return CreateSimpForm(kind, child_stack);
}
示例6: checkChildrenAreBV
void checkChildrenAreBV(const ASTVec& v, const ASTNode&n) {
for (ASTVec::const_iterator it = v.begin(), itend = v.end(); it != itend; it++)
if (BITVECTOR_TYPE != it->GetType()) {
cerr << "The type is: " << it->GetType() << endl;
FatalError(
"BVTypeCheck:ChildNodes of bitvector-terms must be bitvectors\n",
n);
}
}
示例7: CreateNode
ASTNode NodeFactory::CreateNode(Kind kind, const ASTNode& child0,
const ASTVec & back_children)
{
ASTVec front_children;
front_children.reserve(1 + back_children.size());
front_children.push_back(child0);
front_children.insert(front_children.end(), back_children.begin(),
back_children.end());
return CreateNode(kind, front_children);
}
示例8: GetAsserts
void STPMgr::printAssertsToStream(ostream& os)
{
ASTVec v = GetAsserts();
for (ASTVec::iterator i = v.begin(), iend = v.end(); i != iend; i++)
{
ASTNode q = *i;
os << "ASSERT( ";
q.PL_Print(os, this);
os << ");" << endl;
}
}
示例9: GetAsserts
void STPMgr::printAssertsToStream(ostream &os, int simplify_print) {
ASTVec v = GetAsserts();
for(ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++) {
//Begin_RemoveWrites = true; ASTNode q = (simplify_print == 1) ?
//SimplifyFormula_TopLevel(*i,false) : *i; q = (simplify_print
//== 1) ? SimplifyFormula_TopLevel(q,false) : q;
ASTNode q = *i;
//Begin_RemoveWrites = false;
os << "ASSERT( ";
q.PL_Print(os);
os << ");" << endl;
}
}
示例10: CreateArrayTerm
ASTNode NodeFactory::CreateArrayTerm(Kind kind, unsigned int index, unsigned int width,
const ASTNode& child0, const ASTNode& child1, const ASTNode& child2,
const ASTVec &children)
{
ASTVec child;
child.reserve(children.size() + 3);
child.push_back(child0);
child.push_back(child1);
child.push_back(child2);
child.insert(child.end(), children.begin(), children.end());
return CreateArrayTerm(kind, index, width, child);
}
示例11: FlattenKind
void FlattenKind(const Kind k, const ASTVec &children, ASTVec & flat_children)
{
ASTVec::const_iterator ch_end = children.end();
for (ASTVec::const_iterator it = children.begin(); it != ch_end; it++)
{
Kind ck = it->GetKind();
if (k == ck)
{
FlattenKind(k,it->GetChildren(), flat_children);
}
else
{
flat_children.push_back(*it);
}
}
}
示例12: print_STPInput_Back
void print_STPInput_Back(const ASTNode& query) {
// Determine the symbols in the query and asserts.
ASTNodeSet visited;
ASTNodeSet symbols;
buildListOfSymbols(query, visited, symbols);
ASTVec v = (BEEV::GlobalSTP->bm)->GetAsserts();
for(ASTVec::iterator i=v.begin(),iend=v.end();i!=iend;i++)
buildListOfSymbols(*i, visited, symbols);
(BEEV::GlobalSTP->bm)->printVarDeclsToStream(cout, symbols);
(BEEV::GlobalSTP->bm)->printAssertsToStream(cout,0);
cout << "QUERY(";
query.PL_Print(cout);
cout << ");\n";
} //end of print_STPInput_Back()
示例13: searchXOR
bool PropagateEqualities::searchXOR(const ASTNode& lhs, const ASTNode& rhs)
{
Kind k = lhs.GetKind();
if (lhs == rhs)
return true;
if (k == SYMBOL)
return simp->UpdateSubstitutionMap(
lhs, rhs); // checks whether it's been solved for or loops.
if (k == NOT)
return searchXOR(lhs[0], nf->CreateNode(NOT, rhs));
bool result = false;
if (k == XOR)
for (size_t i = 0; i < lhs.Degree(); i++)
{
ASTVec others;
for (size_t j = 0; j < lhs.Degree(); j++)
if (j != i)
others.push_back(lhs[j]);
others.push_back(rhs);
assert(others.size() > 1);
ASTNode new_rhs = nf->CreateNode(XOR, others);
result = searchXOR(lhs[i], new_rhs);
if (result)
return result;
}
if (k == EQ && lhs[0].GetValueWidth() == 1)
{
bool result =
searchTerm(lhs[0], nf->CreateTerm(ITE, 1, rhs, lhs[1],
nf->CreateTerm(BVNEG, 1, lhs[1])));
if (!result)
result =
searchTerm(lhs[1], nf->CreateTerm(ITE, 1, rhs, lhs[0],
nf->CreateTerm(BVNEG, 1, lhs[0])));
}
return result;
}
示例14: Dot_Print1
void Dot_Print1(ostream &os, const ASTNode n, hash_set<int> *alreadyOutput)
{
// check if this node has already been printed. If so return.
if (alreadyOutput->find(n.GetNodeNum()) != alreadyOutput->end())
return;
alreadyOutput->insert(n.GetNodeNum());
os << "n" << n.GetNodeNum() << "[label =\"";
switch (n.GetKind())
{
case SYMBOL:
n.nodeprint(os);
break;
case BITVECTOR:
case BVCONST:
outputBitVec(n, os);
break;
default:
os << _kind_names[n.GetKind()];
}
os << "\"];" << endl;
// print the edges to each child.
ASTVec ch = n.GetChildren();
ASTVec::iterator itend = ch.end();
int i = 0;
for (ASTVec::iterator it = ch.begin(); it < itend; it++)
{
os << "n" << n.GetNodeNum()
<< " -> " << "n"
<< it->GetNodeNum()
<< "[label=" << i++
<< "];" << endl;
}
// print each of the children.
for (ASTVec::iterator it = ch.begin(); it < itend; it++)
{
Dot_Print1(os, *it, alreadyOutput);
}
}
示例15: FlattenKindNoDuplicates
/* Maintains a set of nodes that have already been seen. So that deeply shared
* AND,OR operations are not
* flattened multiple times.
*/
void FlattenKindNoDuplicates(const Kind k, const ASTVec& children,
ASTVec& flat_children,
ASTNodeSet& alreadyFlattened)
{
const ASTVec::const_iterator ch_end = children.end();
for (ASTVec::const_iterator it = children.begin(); it != ch_end; it++)
{
const Kind ck = it->GetKind();
if (k == ck)
{
if (alreadyFlattened.find(*it) == alreadyFlattened.end())
{
alreadyFlattened.insert(*it);
FlattenKindNoDuplicates(k, it->GetChildren(), flat_children,
alreadyFlattened);
}
}
else
{
flat_children.push_back(*it);
}
}
}