本文整理汇总了C++中ASTNodeSet::end方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNodeSet::end方法的具体用法?C++ ASTNodeSet::end怎么用?C++ ASTNodeSet::end使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNodeSet
的用法示例。
在下文中一共展示了ASTNodeSet::end方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
bool
ConstantBitPropagation::checkAtFixedPoint(const ASTNode& n, ASTNodeSet & visited)
{
if (status == CONFLICT)
return true; // can't do anything.
if (visited.find(n) != visited.end())
return true;
visited.insert(n);
// get the current for the children.
vector<FixedBits> childrenFixedBits;
childrenFixedBits.reserve(n.GetChildren().size());
// get a copy of the current fixing from the cache.
for (unsigned i = 0; i < n.GetChildren().size(); i++)
{
childrenFixedBits.push_back(*getCurrentFixedBits(n[i]));
}
FixedBits current = *getCurrentFixedBits(n);
FixedBits newBits = *getUpdatedFixedBits(n);
assert(FixedBits::equals(newBits, current));
for (int i = 0; i < n.Degree(); i++)
{
if (!FixedBits::equals(*getUpdatedFixedBits(n[i]),
childrenFixedBits[i]))
{
cerr << "Not fixed point";
assert(false);
}
checkAtFixedPoint(n[i], visited);
}
return true;
}
示例2: 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);
}
}
}
示例3: printSMTLIB1VarDeclsToStream
void printSMTLIB1VarDeclsToStream(ASTNodeSet& symbols, ostream& os)
{
for (ASTNodeSet::const_iterator i = symbols.begin(), iend = symbols.end(); i
!= iend; i++)
{
const BEEV::ASTNode& a = *i;
// Should be a symbol.
assert(a.GetKind()== SYMBOL);
switch (a.GetType())
{
case BEEV::BITVECTOR_TYPE:
os << ":extrafuns (( ";
a.nodeprint(os);
os << " BitVec[" << a.GetValueWidth() << "]";
os << " ))" << endl;
break;
case BEEV::ARRAY_TYPE:
os << ":extrafuns (( ";
a.nodeprint(os);
os << " Array[" << a.GetIndexWidth();
os << ":" << a.GetValueWidth() << "] ))" << endl;
break;
case BEEV::BOOLEAN_TYPE:
os << ":extrapreds (( ";
a.nodeprint(os);
os << "))" << endl;
break;
default:
BEEV::FatalError("printVarDeclsToStream: Unsupported type",a);
break;
}
}
} //printVarDeclsToStream
示例4: printVarDeclsToStream
void printVarDeclsToStream(ASTNodeSet& symbols, ostream& os)
{
for (ASTNodeSet::const_iterator i = symbols.begin(), iend = symbols.end();
i != iend; i++)
{
const stp::ASTNode& a = *i;
os << "(declare-fun ";
// Should be a symbol.
assert(a.GetKind() == SYMBOL);
os << "|";
a.nodeprint(os);
os << "|";
switch (a.GetType())
{
case stp::BITVECTOR_TYPE:
os << " () (";
os << "_ BitVec " << a.GetValueWidth() << ")";
break;
case stp::ARRAY_TYPE:
os << " () (";
os << "Array (_ BitVec " << a.GetIndexWidth() << ") (_ BitVec "
<< a.GetValueWidth() << ") )";
break;
case stp::BOOLEAN_TYPE:
os << " () Bool ";
break;
default:
stp::FatalError("printVarDeclsToStream: Unsupported type", a);
break;
}
os << ")\n";
}
} // printVarDeclsToStream
示例5: if
/** Internal function to print in lisp format. Assume newline
and indentation printed already before first line. Recursive
calls will have newline & indent, though */
ostream& Lisp_Print1(ostream& os, const ASTNode& n, int indentation)
{
if (!n.IsDefined())
{
os << "<undefined>";
return os;
}
Kind kind = n.GetKind();
// FIXME: figure out how to avoid symbols with same names as kinds.
// if (kind == READ) {
// const ASTVec &children = GetChildren();
// children[0].LispPrint1(os, indentation);
// os << "[" << children[1] << "]";
// } else
if (kind == BOOLEXTRACT)
{
const ASTVec& children = n.GetChildren();
// child 0 is a symbol. Print without the NodeNum.
os << n.GetNodeNum() << ":";
children[0].nodeprint(os, true);
os << "{";
children[1].nodeprint(os, true);
os << "}";
}
else if (kind == NOT)
{
const ASTVec& children = n.GetChildren();
os << n.GetNodeNum() << ":";
os << "(NOT ";
Lisp_Print1(os, children[0], indentation);
os << ")";
}
else if (n.Degree() == 0)
{
// Symbol or a kind with no children print as index:NAME if shared,
// even if they have been printed before.
os << n.GetNodeNum() << ":";
n.nodeprint(os, true);
// os << "(" << _int_node_ptr->_ref_count << ")";
// os << "{" << GetValueWidth() << "}";
}
else if (Lisp_AlreadyPrintedSet.find(n) != Lisp_AlreadyPrintedSet.end())
{
// print non-symbols as "[index]" if seen before.
os << "[" << n.GetNodeNum() << "]";
// << "(" << _int_node_ptr->_ref_count << ")";
}
else
{
Lisp_AlreadyPrintedSet.insert(n);
const ASTVec& children = n.GetChildren();
os << n.GetNodeNum() << ":"
//<< "(" << _int_node_ptr->_ref_count << ")"
<< "(" << kind << " ";
// os << "{" << GetValueWidth() << "}";
ASTVec::const_iterator iend = children.end();
for (ASTVec::const_iterator i = children.begin(); i != iend; i++)
{
Lisp_Print_indent(os, *i, indentation + 2);
}
os << ")";
}
return os;
}
示例6: 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;
*/
//.........这里部分代码省略.........
示例7: GDL_Print1
void GDL_Print1(ostream& os, const ASTNode& n, hash_set<int>* alreadyOutput,
string (*annotate)(const ASTNode&))
{
// check if this node has already been printed. If so return.
if (alreadyOutput->find(n.GetNodeNum()) != alreadyOutput->end())
return;
alreadyOutput->insert(n.GetNodeNum());
os << "node: { title:\"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 << annotate(n);
os << "\"}" << endl;
// print the edges to each child.
const ASTVec ch = n.GetChildren();
const ASTVec::const_iterator itend = ch.end();
// If a node has the child 'TRUE' twice, we only want to output one TRUE node.
ASTNodeSet constantOutput;
int i = 0;
for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
std::stringstream label;
if (!isCommutative(n.GetKind()))
label << " label:\"" << i << "\"";
if (it->isConstant())
{
std::stringstream ss;
ss << n.GetNodeNum() << "_" << it->GetNodeNum();
if (constantOutput.end() == constantOutput.find(*it))
{
os << "node: { title:\"n";
os << ss.str() << "\" label: \"";
if (it->GetType() == BEEV::BOOLEAN_TYPE)
os << _kind_names[it->GetKind()];
else
outputBitVec(*it, os);
os << "\"}" << endl;
constantOutput.insert(*it);
}
os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
<< "n" << ss.str() << "\"" << label.str() << "}" << endl;
}
else
os << "edge: { source:\"n" << n.GetNodeNum() << "\" target: \""
<< "n" << it->GetNodeNum() << "\"" << label.str() << "}" << endl;
i++;
}
// print each of the children.
for (ASTVec::const_iterator it = ch.begin(); it < itend; it++)
{
if (!it->isConstant())
GDL_Print1(os, *it, alreadyOutput, annotate);
}
}