本文整理汇总了C++中SgStatement::insert_statement方法的典型用法代码示例。如果您正苦于以下问题:C++ SgStatement::insert_statement方法的具体用法?C++ SgStatement::insert_statement怎么用?C++ SgStatement::insert_statement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgStatement
的用法示例。
在下文中一共展示了SgStatement::insert_statement方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSgStatement
//.........这里部分代码省略.........
newDecl->initVarDeclaration = initVarDeclaration;
newDecl->assignment = assignStmt;
newDecl->name = name;
nonInitVarDeclaration->set_parent( stm->get_parent() );
isSgVariableDeclaration( nonInitVarDeclaration )->set_definingDeclaration( isSgVariableDeclaration( nonInitVarDeclaration ) );
assignStmt->set_parent( stm->get_parent() );
declarations.push_back( newDecl );
} // end for
} // end if fct calls in crt stmt > 1
SgScopeStatement *scope = stm->get_scope();
ROSE_ASSERT ( scope );
// insert function bindings to variables; each 'declaration' structure in the list
// corresponds to one function call
for ( DeclarationPtrList::iterator i = declarations.begin(); i != declarations.end(); i++ )
{
Declaration *d = *i;
ROSE_ASSERT ( d && d->assignment && d->nonInitVarDeclaration );
// if the current statement is a for-loop, we insert Declarations before & in the loop body, depending on the case
if ( forStm )
{
SgStatement *parentScope = isSgStatement( stm->get_scope() );
SgBasicBlock *body = SageInterface::ensureBasicBlockAsBodyOfFor(forStm);
ROSE_ASSERT ( !inForTest.empty() && body && parentScope );
// SgStatementPtrList &list = body->get_statements();
// if function call is in loop condition, we add initialized variable before the loop and at its end
// hoist initialized variable declarations outside the loop
if ( inForTest.front() )
{
ROSE_ASSERT ( d->initVarDeclaration );
parentScope->insert_statement( stm, d->initVarDeclaration );
// set the scope of the initializedName
SgInitializedName *initName = isSgVariableDeclaration( d->initVarDeclaration )->get_decl_item( d->name );
ROSE_ASSERT ( initName );
initName->set_scope( isSgScopeStatement( parentScope ) );
ROSE_ASSERT ( initName->get_scope() );
}
// function call is in loop post increment so add noninitialized variable decls above the loop
else
{
parentScope->insert_statement( stm, d->nonInitVarDeclaration );
// set the scope of the initializedName
SgInitializedName *initName = isSgVariableDeclaration( d->nonInitVarDeclaration )->get_decl_item( d->name );
ROSE_ASSERT ( initName );
initName->set_scope( isSgScopeStatement( parentScope ) );
ROSE_ASSERT ( initName->get_scope() );
}
// in a for-loop, always insert assignments at the end of the loop
body->get_statements().push_back( d->assignment );
d->assignment->set_parent( body );
// remove marker
inForTest.pop_front();
}
else
{
// look at the type of the enclosing scope
switch ( scope->variantT() )
{