本文整理汇总了C++中SgScopeStatement::getStatementList方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::getStatementList方法的具体用法?C++ SgScopeStatement::getStatementList怎么用?C++ SgScopeStatement::getStatementList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::getStatementList方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char** argv) {
SgProject* proj = frontend(argc,argv);
fixAllPrefixPostfix(proj);
initializeScopeInformation(proj);
SgFunctionDeclaration* mainDecl = SageInterface::findMain(proj);
SgFunctionDefinition* mainDef = mainDecl->get_definition();
//SageInterface::rebuildSymbolTable(mainDef);
StaticCFG::CFG cfg(mainDef);
SgIncidenceDirectedGraph *g = cfg.getGraph();
PathCollector* pathCollector = new PathCollector(g,&cfg);
std::vector<SgNode*> scopeNodes = NodeQuery::querySubTree(mainDef,V_SgScopeStatement);
std::vector<SgGraphNode*> visited;
std::vector<SgNode*> nodes = NodeQuery::querySubTree(mainDef,V_SgWhileStmt);
std::vector<SgNode*>::iterator node = nodes.begin();
for (; node != nodes.end(); node++) {
SgScopeStatement* scopeOfWhile = SageInterface::getEnclosingScope(*node);
SgStatementPtrList statementsInScope = scopeOfWhile->getStatementList();
SgStatementPtrList::iterator statPtr = statementsInScope.begin();
std::set<SgPragmaDeclaration*> prdecls;
for (; statPtr!=statementsInScope.end();statPtr++) {
if (isSgPragmaDeclaration(*statPtr)) {
prdecls.insert(isSgPragmaDeclaration(*statPtr));
}
}
//SgExprStatement* boundingConditionStatement = isSgExprStatement(isSgWhileStmt(*node)->get_condition());
//SgExpression* boundingCondition = boundingConditionStatement->get_expression();
SgStatement* body = (isSgWhileStmt(*node)->get_body());
std::vector<std::vector<SgGraphNode*> > paths = pathCollector->getPaths();
std::cout << getPrelude() << std::endl;
SgGraphNode* whileStart = cfg.cfgForBeginning(isSgWhileStmt(*node));
SgGraphNode* whileEnd = cfg.cfgForEnd(isSgWhileStmt(*node));
collectPaths(whileStart,whileEnd, pathCollector);
SgGraphNode* whileOut = getWhileEndNode(isSgWhileStmt(*node),pathCollector);
SgGraphNode* bodyStart = cfg.cfgForBeginning(isSgWhileStmt(*node)->get_body());
SgGraphNode* bodyEnd = cfg.cfgForEnd(isSgWhileStmt(*node)->get_body());
pathCollector->clearPaths();
collectPaths(bodyStart,whileOut,pathCollector);
paths.clear();
paths = pathCollector->getPaths();
std::vector<std::vector<SgGraphNode*> >::iterator i = paths.begin();
std::set<SgVariableSymbol*> vars = getVars(pathCollector);
std::string vardecls;
std::string initrule;
std::vector<std::string> rules= getRules(*node,pathCollector, vars, vardecls,initrule);
std::cout << vardecls << std::endl;
for (int i = 0; i < rules.size(); i++) {
std::cout << rules[i] << std::endl;
}
std::set<SgPragmaDeclaration*>::iterator pr = prdecls.begin();
for (; pr != prdecls.end(); pr++) {
std::set<std::string> variables;
std::vector<std::string> s_expressions;
std::string prag_str = get_pragma_string(*pr);
bool initPrag;
/*std::string rhs =*/ translateToS_Expr(prag_str,variables,s_expressions,initPrag);
if (s_expressions.size() > 0) {
std::string queryResult;
if (initPrag) {
queryResult = assumptionPragma(s_expressions,initrule);
}
else {
queryResult = queryPragma(s_expressions,initrule);
}
std::cout << queryResult << std::endl;
}
}
}
backend(proj);
return 0;
}