当前位置: 首页>>代码示例>>C++>>正文


C++ SgScopeStatement::getStatementList方法代码示例

本文整理汇总了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;
	}
开发者ID:8l,项目名称:rose,代码行数:82,代码来源:analyzePath.cpp


注:本文中的SgScopeStatement::getStatementList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。