本文整理汇总了C++中ASTNode::GetChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ ASTNode::GetChildren方法的具体用法?C++ ASTNode::GetChildren怎么用?C++ ASTNode::GetChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ASTNode
的用法示例。
在下文中一共展示了ASTNode::GetChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: convertFormulaToCNFNegOR
void CNFMgr::convertFormulaToCNFNegOR(const ASTNode& varphi,
ClauseList* defs)
{
//****************************************
// (neg) OR ~> UNION NOT
//****************************************
ASTVec::const_iterator it = varphi.GetChildren().begin();
convertFormulaToCNF(*it, defs);
ClauseList* psi = ClauseList::COPY(*(info[*it]->clausesneg));
reduceMemoryFootprintNeg(*it);
for (it++; it != varphi.GetChildren().end(); it++) {
convertFormulaToCNF(*it, defs);
CNFInfo* x = info[*it];
if (sharesNeg(*x) != 1) {
ClauseList::INPLACE_UNION(psi, *(x->clausesneg));
reduceMemoryFootprintNeg(*it);
} else {
// If this is the only use of "clausesneg", no reason to make a copy.
psi->insert(x->clausesneg);
// Copied from reduceMemoryFootprintNeg
delete x->clausesneg;
x->clausesneg = NULL;
if (x->clausespos == NULL) {
delete x;
info.erase(*it);
}
}
}
info[varphi]->clausesneg = psi;
} //End of convertFormulaToCNFNegOR()
示例2: convertFormulaToCNFPosAND
void CNFMgr::convertFormulaToCNFPosAND(const ASTNode& varphi,
ClauseList* defs) {
//****************************************
// (pos) AND ~> UNION
//****************************************
ASTVec::const_iterator it = varphi.GetChildren().begin();
convertFormulaToCNF(*it, defs);
ClauseList* psi = ClauseList::COPY(*(info[*it]->clausespos));
for (it++; it != varphi.GetChildren().end(); it++) {
convertFormulaToCNF(*it, defs);
CNFInfo* x = info[*it];
if (sharesPos(*x) == 1) {
psi->insert(x->clausespos);
delete (x->clausespos);
x->clausespos = NULL;
if (x->clausesneg == NULL) {
delete x;
info.erase(*it);
}
} else {
ClauseList::INPLACE_UNION(psi, *(x->clausespos));
reduceMemoryFootprintPos(*it);
}
}
if (renameAllSiblings)
{
assert(((unsigned)psi->size()) == varphi.GetChildren().size());
}
info[varphi]->clausespos = psi;
} //End of convertFormulaToCNFPosAND()
示例3: main
int main()
{
AbstractSyntaxTree AST;
ASTNode Root;
Root.name = "Root";
Root.type = "Node";
Root.startLineCount = 1;
Root.endLineCount = 0;
AST.SetRoot(&Root);
ASTNode N1;
N1.name = "Node 1";
N1.type = "Node";
N1.startLineCount = 1;
N1.endLineCount = 0;
Root.GetChildren().push_back(&N1);
ASTNode N2;
N2.name = "Node 2";
N2.type = "Node";
N2.startLineCount = 1;
N2.endLineCount = 0;
N1.GetChildren().push_back(&N2);
ASTNode N3;
N3.name = "Node 3";
N3.type = "Node";
N3.startLineCount = 1;
N3.endLineCount = 0;
Root.GetChildren().push_back(&N3);
AST.TreeWalk(AST.GetRoot());
}
示例4: convertFormulaToCNFPosPred
void CNFMgr::convertFormulaToCNFPosPred(const ASTNode& varphi,
ClauseList* defs)
{
ASTVec psis;
ASTVec::const_iterator it = varphi.GetChildren().begin();
for (; it != varphi.GetChildren().end(); it++)
{
convertTermForCNF(*it, defs);
psis.push_back(*(info[*it]->termforcnf));
}
info[varphi]->clausespos =
SINGLETON(bm->CreateNode(varphi.GetKind(), psis));
} //End of convertFormulaToCNFPosPred()
示例5: convertFormulaToCNFNegAND
void CNFMgr::convertFormulaToCNFNegAND(const ASTNode& varphi,
ClauseList* defs)
{
bool renamesibs = false;
ClauseList* clauses;
ClauseList* psi;
ClauseList* oldpsi;
//****************************************
// (neg) AND ~> PRODUCT NOT
//****************************************
ASTVec::const_iterator it = varphi.GetChildren().begin();
convertFormulaToCNF(*it, defs);
clauses = info[*it]->clausesneg;
if (clauses->size() > 1)
{
renamesibs = true;
}
psi = ClauseList::COPY(*clauses);
reduceMemoryFootprintNeg(*it);
for (it++; it != varphi.GetChildren().end(); it++)
{
if (renamesibs)
{
setDoSibRenamingNeg(*(info[*it]));
}
convertFormulaToCNF(*it, defs);
clauses = info[*it]->clausesneg;
if (clauses->size() > 1)
{
renamesibs = true;
}
if (clauses->size() ==1)
psi->INPLACE_PRODUCT(*clauses);
else
{
oldpsi = psi;
psi = ClauseList::PRODUCT(*psi, *clauses);
DELETE(oldpsi);
}
reduceMemoryFootprintNeg(*it);
}
info[varphi]->clausesneg = psi;
} //End of convertFormulaToCNFNegAND()
示例6: LetizeNode
void LetizeNode(const ASTNode& n, ASTNodeSet& PLPrintNodeSet, bool smtlib1)
{
const Kind kind = n.GetKind();
if (kind == SYMBOL || kind == BVCONST || kind == FALSE || kind == TRUE)
return;
const ASTVec& c = n.GetChildren();
for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend;
it++)
{
const ASTNode& ccc = *it;
const Kind k = ccc.GetKind();
if (k == SYMBOL || k == BVCONST || k == FALSE || k == TRUE)
continue;
if (PLPrintNodeSet.find(ccc) == PLPrintNodeSet.end())
{
// If branch: if *it is not in NodeSet then,
//
// 1. add it to NodeSet
//
// 2. Letize its childNodes
PLPrintNodeSet.insert(ccc);
LetizeNode(ccc, PLPrintNodeSet, smtlib1);
}
else
{
// 0. Else branch: Node has been seen before
//
// 1. Check if the node has a corresponding letvar in the
// 1. NodeLetVarMap.
//
// 2. if no, then create a new var and add it to the
// 2. NodeLetVarMap
if ((!smtlib1 || ccc.GetType() == BITVECTOR_TYPE) &&
NodeLetVarMap.find(ccc) == NodeLetVarMap.end())
{
// Create a new symbol. Get some name. if it conflicts with a
// declared name, too bad.
int sz = NodeLetVarMap.size();
std::ostringstream oss;
oss << "?let_k_" << sz;
ASTNode CurrentSymbol = n.GetSTPMgr()->CreateSymbol(
oss.str().c_str(), n.GetIndexWidth(), n.GetValueWidth());
/* If for some reason the variable being created here is
* already declared by the user then the printed output will
* not be a legal input to the system. too bad. I refuse to
* check for this. [Vijay is the author of this comment.]
*/
NodeLetVarMap[ccc] = CurrentSymbol;
std::pair<ASTNode, ASTNode> node_letvar_pair(CurrentSymbol, ccc);
NodeLetVarVec.push_back(node_letvar_pair);
}
}
}
} // end of LetizeNode()
示例7: FindNode
// Method to find a particular node in tree. Returns its parent
ASTNode* AbstractSyntaxTree::FindNode(ASTNode* FindIt)
{
if (this->Root == NULL)
return NULL;
// Maintaining a stack to traverse the Tree in DFS manner (non-recursive)
std::stack<ASTNode*> DFSStack;
// Maintaining a set of nodes which have been visited during traversal
std::set<ASTNode*> Visited;
DFSStack.push(this->Root);
Visited.insert(this->Root);
std::vector<ASTNode*> Children;
while (!DFSStack.empty())
{
ASTNode* Top = DFSStack.top();
DFSStack.pop();
if ((*FindIt).IfEqual(*Top))
return Top;
Children = Top->GetChildren();
for (ASTNode* child : Children)
{
if (Visited.find(child) == Visited.end())
{
DFSStack.push(child);
Visited.insert(child);
}
}
}
return NULL;
}
示例8: if
void outputBitVecSMTLIB2(const ASTNode n, ostream& os)
{
const Kind k = n.GetKind();
const ASTVec &c = n.GetChildren();
ASTNode op;
if (BITVECTOR == k)
{
op = c[0];
}
else if (BVCONST == k)
{
op = n;
}
else
FatalError("nsadfsdaf");
// CONSTANTBV::BitVector_to_Dec returns a signed representation by default.
// Prepend with zero to convert to unsigned.
os << "(_ bv";
CBV unsign = CONSTANTBV::BitVector_Concat(
n.GetSTPMgr()->CreateZeroConst(1).GetBVConst(), op.GetBVConst());
unsigned char * str = CONSTANTBV::BitVector_to_Dec(unsign);
CONSTANTBV::BitVector_Destroy(unsign);
os << str << " " << op.GetValueWidth() << ")";
CONSTANTBV::BitVector_Dispose(str);
}
示例9: assertTransformPostConditions
// Check that the transformations have occurred.
void ArrayTransformer::assertTransformPostConditions(const ASTNode& term,
ASTNodeSet& visited)
{
// I haven't measure whether this is the quickest way to do it?
std::pair<ASTNodeSet::iterator, bool> p = visited.insert(term);
if (!p.second)
return;
const Kind k = term.GetKind();
// Check the array reads / writes have been removed
assert(READ != k);
assert(WRITE != k);
// There should be no nodes left of type array.
assert(0 == term.GetIndexWidth());
const ASTVec& c = term.GetChildren();
ASTVec::const_iterator it = c.begin();
const ASTVec::const_iterator itend = c.end();
for (; it != itend; it++)
{
assertTransformPostConditions(*it, visited);
}
}
示例10: CreateSimpNot
ASTNode STPMgr::CreateSimpNot(const ASTNode& form)
{
Kind k = form.GetKind();
switch (k)
{
case FALSE:
{
return ASTTrue;
}
case TRUE:
{
return ASTFalse;
}
case NOT:
{
return form[0];
} // NOT NOT cancellation
case XOR:
{
// Push negation down in this case.
// FIXME: Separate pre-pass to push negation down?
// CreateSimp should be local, and this isn't.
// It isn't memoized. Arg.
ASTVec children = form.GetChildren();
children[0] = CreateSimpNot(children[0]);
return CreateSimpXor(children);
}
default:
{
return CreateNode(NOT, form);
//return CreateNode(XOR, ASTTrue, form);
}
}
}
示例11: convertFormulaToCNFNegXOR
void CNFMgr::convertFormulaToCNFNegXOR(const ASTNode& varphi,
ClauseList* defs)
{
//#ifdef FALSE
#if defined CRYPTOMINISAT__2
CNFInfo * xx = info[varphi];
if(NULL != xx
&& sharesPos(*xx) > 0
&& sharesNeg(*xx) > 0)
{
return;
}
ASTVec::const_iterator it = varphi.GetChildren().begin();
ClausePtr xor_clause = new vector<const ASTNode*>();
for (; it != varphi.GetChildren().end(); it++)
{
convertFormulaToCNF(*it, defs); // make pos and neg clause set
//Creating a new variable name for each of the children of the
//XOR node doRenamingPos(*it, defs);
//doRenamingPos(*it, defs);
doRenamingNeg(*it, defs);
xor_clause->insert(xor_clause->end(),
((*(info[*it]->clausespos)).asList()->front())->begin(),
((*(info[*it]->clausespos)).asList()->front())->end());
}
doRenamingPosXor(varphi);
//ClauseList* psi = convertFormulaToCNFPosXORAux(varphi, 0, defs);
//info[varphi]->clausespos = psi;
ASTNode varXorNode = GetNodeFrom_SINGLETON(info[varphi]->clausespos);
ASTNode NotVarXorNode = bm->CreateNode(NOT, varXorNode);
xor_clause->push_back(ASTNodeToASTNodePtr(NotVarXorNode));
clausesxor->push_back(xor_clause);
ASTVec::const_iterator it2 = varphi.GetChildren().begin();
for (; it2 != varphi.GetChildren().end(); it2++) {
reduceMemoryFootprintPos(*it2);
reduceMemoryFootprintNeg(*it2);
}
#else
ASTVec::const_iterator it = varphi.GetChildren().begin();
for (; it != varphi.GetChildren().end(); it++)
{
convertFormulaToCNF(*it, defs); // make pos and neg clause sets
}
ClauseList* psi = convertFormulaToCNFNegXORAux(varphi, 0, defs);
info[varphi]->clausesneg = psi;
ASTVec::const_iterator it2 = varphi.GetChildren().begin();
for (; it2 != varphi.GetChildren().end(); it2++) {
reduceMemoryFootprintPos(*it2);
reduceMemoryFootprintNeg(*it2);
}
#endif
} //End of convertFormulaToCNFNegXOR()
示例12: scanTerm
void CNFMgr::scanTerm(const ASTNode& varphi)
{
CNFInfo* x;
//########################################
// step 1, get the info associated with this node
//########################################
if (info.find(varphi) == info.end())
{
x = new CNFInfo();
info[varphi] = x;
}
else
{
x = info[varphi];
}
//########################################
// step 2, need two hits because of term ITEs.
//########################################
if (sharesPos(*x) == 2)
{
return;
}
//########################################
// step 3, set appropriate data fields, always rename
// term ITEs
//########################################
incrementSharesPos(*x);
setIsTerm(*x);
//########################################
// step 4, recurse over children
//########################################
if (varphi.isAtom())
{
return;
}
else if (varphi.isITE())
{
scanFormula(varphi[0], true, false);
scanFormula(varphi[0], false, false);
scanTerm(varphi[1]);
scanTerm(varphi[2]);
}
else
{
for (unsigned int i = 0; i < varphi.GetChildren().size(); i++)
{
scanTerm(varphi[i]);
}
}
}//End of scanterm()
示例13: convertTermForCNF
void CNFMgr::convertTermForCNF(const ASTNode& varphi, ClauseList* defs)
{
CNFInfo* x = info[varphi];
//########################################
// step 1, done if we've already visited
//########################################
if (x->termforcnf != NULL)
{
return;
}
//########################################
// step 2, ITE's always get renamed
//########################################
if (varphi.isITE())
{
x->termforcnf = doRenameITE(varphi, defs);
reduceMemoryFootprintPos(varphi[0]);
reduceMemoryFootprintNeg(varphi[0]);
}
else if (varphi.isAtom())
{
x->termforcnf = ASTNodeToASTNodePtr(varphi);
}
else
{
ASTVec psis;
ASTVec::const_iterator it = varphi.GetChildren().begin();
for (; it != varphi.GetChildren().end(); it++)
{
convertTermForCNF(*it, defs);
psis.push_back(*(info[*it]->termforcnf));
}
ASTNode psi = bm->CreateNode(varphi.GetKind(), psis);
psi.SetValueWidth(varphi.GetValueWidth());
psi.SetIndexWidth(varphi.GetIndexWidth());
x->termforcnf = ASTNodeToASTNodePtr(psi);
}
} //End of convertTermForCNF()
示例14: convertFormulaToCNFNegNAND
void CNFMgr::convertFormulaToCNFNegNAND(const ASTNode& varphi,
ClauseList* defs)
{
//****************************************
// (neg) NAND ~> UNION
//****************************************
ASTVec::const_iterator it = varphi.GetChildren().begin();
convertFormulaToCNF(*it, defs);
ClauseList* psi = ClauseList::COPY(*(info[*it]->clausespos));
reduceMemoryFootprintPos(*it);
for (it++; it != varphi.GetChildren().end(); it++)
{
convertFormulaToCNF(*it, defs);
ClauseList::INPLACE_UNION(psi, *(info[*it]->clausespos));
reduceMemoryFootprintPos(*it);
}
info[varphi]->clausespos = psi;
} //End of convertFormulaToCNFNegNAND()
示例15: BVTypeCheckRecursive
// If there is a lot of sharing in the graph, this will take a long
// time. it doesn't mark subgraphs as already having been
// typechecked.
bool BVTypeCheckRecursive(const ASTNode& n)
{
const ASTVec& c = n.GetChildren();
BVTypeCheck(n);
for (ASTVec::const_iterator it = c.begin(), itend = c.end(); it != itend; it++)
BVTypeCheckRecursive(*it);
return true;
}