本文整理汇总了C++中ASTVec::push_back方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTVec::push_back方法的具体用法?C++ ASTVec::push_back怎么用?C++ ASTVec::push_back使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTVec
的用法示例。
在下文中一共展示了ASTVec::push_back方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: CreateSimpForm
ASTNode STPMgr::CreateSimpForm(Kind kind,
const ASTNode& child0, const ASTNode& child1)
{
ASTVec children;
//child_stack.clear(); // could just reset top pointer.
children.push_back(child0);
//child_stack.push_back(child0);
children.push_back(child1);
//child_stack.push_back(child1);
return CreateSimpForm(kind, children);
//return CreateSimpForm(kind, child_stack);
}
示例4: CreateSimpXor
ASTNode STPMgr::CreateSimpXor(const ASTNode& form1, const ASTNode& form2)
{
ASTVec children;
children.push_back(form1);
children.push_back(form2);
return CreateSimpXor(children);
}
示例5: 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;
}
示例6: 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);
}
示例7: 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);
}
}
}
示例8: 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);
}
}
}
示例9: TopLevelSTPAux
//UserGuided abstraction refinement
SOLVER_RETURN_TYPE
STP::
UserGuided_AbsRefine(SATSolver& NewSolver,
const ASTNode& original_input)
{
ASTVec v = bm->GetAsserts_WithKey(0);
if(v.empty())
{
FatalError("UserGuided_AbsRefine: Something is seriously wrong."\
"The input set is empty");
}
ASTNode sureAddInput =
(v.size() == 1) ? v[0] : bm->CreateNode(AND, v);
SOLVER_RETURN_TYPE res = SOLVER_UNDECIDED;
res = TopLevelSTPAux(NewSolver, sureAddInput, original_input);
if(SOLVER_UNDECIDED != res)
{
return res;
}
//Do refinement here
if(AND != original_input.GetKind())
{
FatalError("UserGuided_AbsRefine: The input must be an AND");
}
ASTVec RefineFormulasVec;
ASTVec RemainingFormulasVec;
ASTNode asttrue = bm->CreateNode(TRUE);
ASTNode astfalse = bm->CreateNode(FALSE);
for(int count=0; count < bm->UserFlags.num_absrefine; count++)
{
RemainingFormulasVec.clear();
RemainingFormulasVec.push_back(asttrue);
RefineFormulasVec.clear();
RefineFormulasVec.push_back(asttrue);
ASTVec InputKids = original_input.GetChildren();
for(ASTVec::iterator it = InputKids.begin(), itend = InputKids.end();
it!=itend;it++)
{
Ctr_Example->ClearComputeFormulaMap();
if(astfalse == Ctr_Example->ComputeFormulaUsingModel(*it))
{
RefineFormulasVec.push_back(*it);
}
else
{
RemainingFormulasVec.push_back(*it);
}
}
ASTNode RefineFormulas =
(RefineFormulasVec.size() == 1) ?
RefineFormulasVec[0] : bm->CreateNode(AND, RefineFormulasVec);
res = TopLevelSTPAux(NewSolver, RefineFormulas, original_input);
if(SOLVER_UNDECIDED != res)
{
return res;
}
}
ASTNode RemainingFormulas =
(RemainingFormulasVec.size() == 1) ?
RemainingFormulasVec[0] : bm->CreateNode(AND, RemainingFormulasVec);
res = TopLevelSTPAux(NewSolver, RemainingFormulas, original_input);
if(SOLVER_UNDECIDED != res)
{
return res;
}
FatalError("TopLevelSTPAux: reached the end without proper conclusion:"
"either a divide by zero in the input or a bug in STP");
return SOLVER_ERROR;
} //End of UserGuided_AbsRefine()
示例10: CreateSimpFormITE
// FIXME: How do I know whether ITE is a formula or not?
ASTNode STPMgr::CreateSimpFormITE(const ASTNode& child0,
const ASTNode& child1,
const ASTNode& child2)
{
ASTNode retval;
if (_trace_simpbool)
{
cout << "========" << endl
<< "CreateSimpFormITE "
<< child0 << child1 << child2 << endl;
}
if (ASTTrue == child0)
{
retval = child1;
}
else if (ASTFalse == child0)
{
retval = child2;
}
else if (child1 == child2)
{
retval = child1;
}
// ITE(x, TRUE, y ) == x OR y
else if (ASTTrue == child1)
{
retval = CreateSimpAndOr(0, child0, child2);
}
// ITE(x, FALSE, y ) == (!x AND y)
else if (ASTFalse == child1)
{
retval = CreateSimpAndOr(1, CreateSimpNot(child0), child2);
}
// ITE(x, y, TRUE ) == (!x OR y)
else if (ASTTrue == child2)
{
retval = CreateSimpAndOr(0, CreateSimpNot(child0), child1);
}
// ITE(x, y, FALSE ) == (x AND y)
else if (ASTFalse == child2)
{
retval = CreateSimpAndOr(1, child0, child1);
}
else
{
ASTNode left = CreateNode(AND, child0, child1);
ASTNode right = CreateNode(AND, CreateNode(NOT,child0), child2);
ASTVec c;
c.push_back(left);
c.push_back(right);
retval = CreateSimpXor(c);
}
if (_trace_simpbool)
{
cout << "returns " << retval << endl;
}
return retval;
}
示例11: if
ASTNode
RemoveUnconstrained::topLevel_other(const ASTNode &n, Simplifier *simplifier)
{
if (n.GetKind() == SYMBOL)
return n; // top level is an unconstrained symbol/.
simplifier_convenient = simplifier;
ASTNodeSet noCheck; // We don't want to check some expensive nodes over and over again.
vector<MutableASTNode*> variable_array;
MutableASTNode* topMutable = MutableASTNode::build(n);
vector<MutableASTNode*> extracts;
topMutable->getDisjointExtractVariables(extracts);
if (extracts.size() > 0)
{
splitExtractOnly(extracts);
}
topMutable->getAllUnconstrainedVariables(variable_array);
for (int i =0; i < variable_array.size() ; i++)
{
// Don't make this is a reference. If the vector gets resized, it will point to
// memory that no longer contains the object.
MutableASTNode& muteNode = *variable_array[i];
const ASTNode var = muteNode.n;
assert(var.GetKind() == SYMBOL);
if (!muteNode.isUnconstrained())
continue;
MutableASTNode& muteParent = muteNode.getParent();
if (noCheck.find(muteParent.n) != noCheck.end())
{
continue;
}
vector <MutableASTNode*> mutable_children = muteParent.children;
//nb. The children might be dirty. i.e. not have substitutions written through them yet.
ASTVec children;
children.reserve(mutable_children.size());
for (int j = 0; j <mutable_children.size(); j++ )
children.push_back(mutable_children[j]->n);
const size_t numberOfChildren = children.size();
const Kind kind = muteNode.getParent().n.GetKind();
unsigned width = muteNode.getParent().n.GetValueWidth();
unsigned indexWidth = muteNode.getParent().n.GetIndexWidth();
ASTNode other;
MutableASTNode* muteOther;
if(numberOfChildren == 2)
{
if (children[0] != var)
{
other = children[0];
muteOther = mutable_children[0];
}
else
{
other = children[1];
muteOther = mutable_children[1];
}
if (kind != AND && kind != OR && kind != BVOR && kind != BVAND)
if (other == var)
continue; // Most rules don't like duplicate variables.
}
else
{
if (kind != AND && kind != OR && kind != BVOR && kind != BVAND)
{
int found = 0;
for (int i = 0; i < numberOfChildren; i++)
{
if (children[i] == var)
found++;
}
if (found != 1)
continue; // Most rules don't like duplicate variables.
}
}
/*
cout << i << " " << kind << " " << variable_array.size() << " " << mutable_children.size() << endl;
cout << "children[0]" << children[0] << endl;
cout << "children[1]" << children[1] << endl;
cout << muteParent.n << endl;
*/
//.........这里部分代码省略.........
示例12: propagate
//.........这里部分代码省略.........
a[1][0][1].GetKind() == SYMBOL)
{
const ASTNode& symbol = a[1][0][1];
const ASTNode newN = nf->CreateTerm(
ITE, 1, a[0], a[1][0][0], nf->CreateTerm(BVNEG, 1, a[1][0][0]));
if (simp->UpdateSolverMap(symbol, newN))
{
assert(false);
output = ASTTrue;
}
}
else if (a[0].GetKind() == EQ && a[0][0].GetValueWidth() == 1 &&
a[0][1].GetKind() == SYMBOL)
{
// XOR ((= 1 v) ... )
const ASTNode& symbol = a[0][1];
const ASTNode newN = nf->CreateTerm(
ITE, 1, a[1], nf->CreateTerm(BVNEG, 1, a[0][0]), a[0][0]);
if (simp->UpdateSolverMap(symbol, newN))
{
assert(false);
output = ASTTrue;
}
}
else if (a[1].GetKind() == EQ && a[1][0].GetValueWidth() == 1 &&
a[1][1].GetKind() == SYMBOL)
{
const ASTNode& symbol = a[1][1];
const ASTNode newN = nf->CreateTerm(
ITE, 1, a[0], nf->CreateTerm(BVNEG, 1, a[1][0]), a[1][0]);
if (simp->UpdateSolverMap(symbol, newN))
{
assert(false);
output = ASTTrue;
}
}
else
return output;
}
else
{
ASTNode symbol, rhs;
if (to == 1)
{
symbol = a[0];
rhs = a[1];
}
else
{
symbol = a[1];
rhs = a[0];
}
assert(symbol.GetKind() == SYMBOL);
if (simp->UpdateSolverMap(symbol, nf->CreateNode(NOT, rhs)))
{
assert(false);
output = ASTTrue;
}
}
#endif
}
else if (AND == k)
{
const ASTVec& c = a.GetChildren();
ASTVec o;
o.reserve(c.size());
for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend;
it++)
{
if (always_true)
simp->UpdateAlwaysTrueFormSet(*it);
ASTNode aaa = propagate(*it, at);
if (ASTTrue != aaa)
{
if (ASTFalse == aaa)
return ASTFalse;
else
o.push_back(aaa);
}
}
if (o.size() == 0)
output = ASTTrue;
else if (o.size() == 1)
output = o[0];
else if (o != c)
output = nf->CreateNode(AND, o);
else
output = a;
}
return output;
}
示例13: TransformTerm
ASTNode ArrayTransformer::TransformTerm(const ASTNode& term)
{
assert(TransformMap != NULL);
const Kind k = term.GetKind();
if (!is_Term_kind(k))
FatalError("TransformTerm: Illegal kind: You have input a nonterm:", term,
k);
ASTNodeMap::const_iterator iter;
if ((iter = TransformMap->find(term)) != TransformMap->end())
return iter->second;
ASTNode result;
switch (k)
{
case SYMBOL:
case BVCONST:
{
result = term;
break;
}
case WRITE:
FatalError("TransformTerm: this kind is not supported", term);
break;
case READ:
result = TransformArrayRead(term);
break;
case ITE:
{
ASTNode cond = term[0];
ASTNode thn = term[1];
ASTNode els = term[2];
cond = TransformFormula(cond);
if (ASTTrue == cond)
result = TransformTerm(thn);
else if (ASTFalse == cond)
result = TransformTerm(els);
else
{
thn = TransformTerm(thn);
els = TransformTerm(els);
if (bm->UserFlags.optimize_flag)
result = simp->CreateSimplifiedTermITE(cond, thn, els);
else
result = nf->CreateTerm(ITE, thn.GetValueWidth(), cond, thn, els);
}
assert(result.GetIndexWidth() == term.GetIndexWidth());
break;
}
default:
{
const ASTVec& c = term.GetChildren();
ASTVec::const_iterator it = c.begin();
ASTVec::const_iterator itend = c.end();
const unsigned width = term.GetValueWidth();
const unsigned indexwidth = term.GetIndexWidth();
ASTVec o;
o.reserve(c.size());
for (; it != itend; it++)
{
o.push_back(TransformTerm(*it));
}
if (c != o)
{
result = nf->CreateArrayTerm(k, indexwidth, width, o);
}
else
result = term;
}
break;
}
if (term.Degree() > 0)
(*TransformMap)[term] = result;
if (term.GetValueWidth() != result.GetValueWidth())
FatalError("TransformTerm: "
"result and input terms are of different length",
result);
if (term.GetIndexWidth() != result.GetIndexWidth())
{
std::cerr << "TransformTerm: input term is : " << term << std::endl;
FatalError("TransformTerm: "
"result & input terms have different index length",
result);
}
return result;
}
示例14: TransformFormula
/********************************************************
* TransformFormula()
*
* Get rid of DIV/MODs, ARRAY read/writes, FOR constructs
********************************************************/
ASTNode ArrayTransformer::TransformFormula(const ASTNode& simpleForm)
{
assert(TransformMap != NULL);
const Kind k = simpleForm.GetKind();
if (!(is_Form_kind(k) && BOOLEAN_TYPE == simpleForm.GetType()))
{
// FIXME: "You have inputted a NON-formula"?
FatalError("TransformFormula:"
"You have input a NON-formula",
simpleForm);
}
ASTNodeMap::const_iterator iter;
if ((iter = TransformMap->find(simpleForm)) != TransformMap->end())
return iter->second;
ASTNode result;
switch (k)
{
case TRUE:
case FALSE:
{
result = simpleForm;
break;
}
case NOT:
{
ASTVec c;
c.push_back(TransformFormula(simpleForm[0]));
result = nf->CreateNode(NOT, c);
break;
}
case BOOLEXTRACT:
{
ASTVec c;
c.push_back(TransformTerm(simpleForm[0]));
c.push_back(simpleForm[1]);
result = nf->CreateNode(BOOLEXTRACT, c);
break;
}
case BVLT:
case BVLE:
case BVGT:
case BVGE:
case BVSLT:
case BVSLE:
case BVSGT:
case BVSGE:
{
ASTVec c;
c.push_back(TransformTerm(simpleForm[0]));
c.push_back(TransformTerm(simpleForm[1]));
result = nf->CreateNode(k, c);
break;
}
case EQ:
{
ASTNode term1 = TransformTerm(simpleForm[0]);
ASTNode term2 = TransformTerm(simpleForm[1]);
if (bm->UserFlags.optimize_flag)
result = simp->CreateSimplifiedEQ(term1, term2);
else
result = nf->CreateNode(EQ, term1, term2);
break;
}
case AND: // These could shortcut. Not sure if the extra effort is
// justified.
case OR:
case NAND:
case NOR:
case IFF:
case XOR:
case ITE:
case IMPLIES:
{
ASTVec vec;
vec.reserve(simpleForm.Degree());
for (ASTVec::const_iterator it = simpleForm.begin(),
itend = simpleForm.end();
it != itend; it++)
{
vec.push_back(TransformFormula(*it));
}
result = nf->CreateNode(k, vec);
break;
}
case PARAMBOOL:
{
// If the parameteric boolean variable is of the form
// VAR(const), then convert it into a Boolean variable of the
// form "VAR(const)".
//.........这里部分代码省略.........
示例15: TransformTerm
ASTNode ArrayTransformer::TransformTerm(const ASTNode& term)
{
assert(TransformMap != NULL);
const Kind k = term.GetKind();
if (!is_Term_kind(k))
FatalError("TransformTerm: Illegal kind: You have input a nonterm:",
term, k);
ASTNodeMap::const_iterator iter;
if ((iter = TransformMap->find(term)) != TransformMap->end())
return iter->second;
ASTNode result;
switch (k)
{
case SYMBOL:
case BVCONST:
{
result = term;
break;
}
case WRITE:
FatalError("TransformTerm: this kind is not supported", term);
break;
case READ:
result = TransformArrayRead(term);
break;
case ITE:
{
ASTNode cond = term[0];
ASTNode thn = term[1];
ASTNode els = term[2];
cond = TransformFormula(cond);
if (ASTTrue == cond)
result = TransformTerm(thn);
else if (ASTFalse == cond)
result = TransformTerm(els);
else
{
thn = TransformTerm(thn);
els = TransformTerm(els);
result = simp->CreateSimplifiedTermITE(cond, thn, els);
}
assert(result.GetIndexWidth() ==term.GetIndexWidth());
break;
}
default:
{
const ASTVec& c = term.GetChildren();
ASTVec::const_iterator it = c.begin();
ASTVec::const_iterator itend = c.end();
const unsigned width = term.GetValueWidth();
const unsigned indexwidth = term.GetIndexWidth();
ASTVec o;
o.reserve(c.size());
for (; it != itend; it++)
{
o.push_back(TransformTerm(*it));
}
if (c!=o)
{
result = nf->CreateArrayTerm(k,indexwidth, width, o);
}
else
result = term;
const Kind k = result.GetKind();
if (BVDIV == k
|| BVMOD == k
|| SBVDIV == k
|| SBVREM == k
|| SBVMOD == k)
{
// I had this as a reference, but that was wrong. Because
// "result" gets over-written in the next block, result[1], may
// get a reference count of zero, so be garbage collected.
const ASTNode bottom = result[1];
if (SBVDIV == result.GetKind()
|| SBVREM == result.GetKind()
|| SBVMOD == result.GetKind())
{
result = TranslateSignedDivModRem(result);
}
if (bm->UserFlags.division_by_zero_returns_one_flag)
{
// This is a difficult rule to introduce in other
// places because it's recursive. i.e. result is
// embedded unchanged inside the result.
unsigned inputValueWidth = result.GetValueWidth();
ASTNode zero = bm->CreateZeroConst(inputValueWidth);
ASTNode one = bm->CreateOneConst(inputValueWidth);
result =
nf->CreateTerm(ITE, inputValueWidth,
nf->CreateNode(EQ, zero, bottom),
//.........这里部分代码省略.........