本文整理汇总了C++中SgScopeStatement::get_parent方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::get_parent方法的具体用法?C++ SgScopeStatement::get_parent怎么用?C++ SgScopeStatement::get_parent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::get_parent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSgStatement
//.........这里部分代码省略.........
// duplicate function call expression, for the initialization declaration and the assignment
SgTreeCopy treeCopy;
SgFunctionCallExp *newExpInit = isSgFunctionCallExp( exp->copy( treeCopy ) );
ROSE_ASSERT ( newExpInit );
SgFunctionCallExp *newExpAssign = isSgFunctionCallExp( exp->copy( treeCopy ) );
ROSE_ASSERT ( newExpAssign );
// variables
Sg_File_Info *initLoc = Sg_File_Info::generateDefaultFileInfoForTransformationNode(),
*nonInitLoc = Sg_File_Info::generateDefaultFileInfoForTransformationNode(),
*assignLoc = Sg_File_Info::generateDefaultFileInfoForTransformationNode();
Declaration *newDecl = new Declaration();
SgStatement *nonInitVarDeclaration, *initVarDeclaration, *assignStmt;
SgExpression *varRefExp;
SgVariableSymbol *varSymbol;
SgAssignOp *assignOp;
SgInitializedName *initName;
bool pointerTypeNeeded = false;
// mark whether to replace inside or outside of ForStatement due to the
// function call being inside the test or the increment for a for-loop statement
// the 'inForTest' list is in 1:1 ordered correpondence with the 'declarations' list
if ( forStm )
{
// SgExpressionRoot
// *testExp = isSgForStatement( astNode )->get_test_expr_root(),
// *incrExp = isSgForStatement( astNode )->get_increment_expr_root();
SgExpression
*testExp = isSgForStatement( astNode )->get_test_expr(),
*incrExp = isSgForStatement( astNode )->get_increment();
SgNode *up = exp;
while ( up && up != testExp && up != incrExp )
up = up->get_parent();
ROSE_ASSERT ( up );
// function call is in the condition of the for-loop
if ( up == testExp )
inForTest.push_back( true );
// function call is in the increment expression
else
{
inForTest.push_back( false );
// for increment expressions we need to be able to reassign the return value
// of the function; if the ret value is a reference, we need to generate a
// pointer of that type (to be able to reassign it later)
if ( isSgReferenceType( expType ) )
pointerTypeNeeded = true;
}
}
// for do-while statements: we need to generate declaration of type pointer to be able to have
// non-assigned references when looping and assign them at the end of the body of the loop
if ( isSgDoWhileStmt( stm->get_parent() ) && isSgReferenceType( expType ) )
pointerTypeNeeded = true;
// we have a function call returning a reference and we can't initialize the variable
// at the point of declaration; we need to define the variable as a pointer
if ( pointerTypeNeeded )
{
// create 'address of' term for function expression, so we can assign it to the pointer
SgAddressOfOp *addressOp = new SgAddressOfOp( assignLoc, newExpAssign, expType );
// create noninitialized declaration
SgType *base = isSgReferenceType( expType )->get_base_type();