本文整理汇总了C++中SgScopeStatement::lookup_var_symbol方法的典型用法代码示例。如果您正苦于以下问题:C++ SgScopeStatement::lookup_var_symbol方法的具体用法?C++ SgScopeStatement::lookup_var_symbol怎么用?C++ SgScopeStatement::lookup_var_symbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgScopeStatement
的用法示例。
在下文中一共展示了SgScopeStatement::lookup_var_symbol方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: local_var_name
/*!
* \brief Creates an assignment to "pack" a local variable back into
* an outlined-function parameter that has been passed as a pointer
* value.
*
* This routine takes the original "unpack" definition, of the form
*
* TYPE local_unpack_var = *outlined_func_arg;
* int i = *(int *)(__out_argv[1]); // parameter wrapping case
*
* and creates the "re-pack" assignment expression,
*
* *outlined_func_arg = local_unpack_var
* *(int *)(__out_argv[1]) =i; // parameter wrapping case
*
* C++ variables of reference types do not need this step.
*/
static
SgAssignOp *
createPackExpr (SgInitializedName* local_unpack_def)
{
if (!Outliner::temp_variable)
{
if (is_C_language()) //skip for pointer dereferencing used in C language
return NULL;
}
// reference types do not need copy the value back in any cases
if (isSgReferenceType (local_unpack_def->get_type ()))
return NULL;
if (local_unpack_def
&& !isReadOnlyType (local_unpack_def->get_type ()))
// && !isSgReferenceType (local_unpack_def->get_type ()))
{
SgName local_var_name (local_unpack_def->get_name ());
SgAssignInitializer* local_var_init =
isSgAssignInitializer (local_unpack_def->get_initializer ());
ROSE_ASSERT (local_var_init);
// Create the LHS, which derefs the function argument, by
// copying the original dereference expression.
//
SgPointerDerefExp* param_deref_unpack =
isSgPointerDerefExp (local_var_init->get_operand_i ());
if (param_deref_unpack == NULL)
{
cout<<"packing statement is:"<<local_unpack_def->get_declaration()->unparseToString()<<endl;
cout<<"local unpacking stmt's initializer's operand has non-pointer deferencing type:"<<local_var_init->get_operand_i ()->class_name()<<endl;
ROSE_ASSERT (param_deref_unpack);
}
SgPointerDerefExp* param_deref_pack = isSgPointerDerefExp (ASTtools::deepCopy (param_deref_unpack));
ROSE_ASSERT (param_deref_pack);
// Create the RHS, which references the local variable.
SgScopeStatement* scope = local_unpack_def->get_scope ();
ROSE_ASSERT (scope);
SgVariableSymbol* local_var_sym =
scope->lookup_var_symbol (local_var_name);
ROSE_ASSERT (local_var_sym);
SgVarRefExp* local_var_ref = SageBuilder::buildVarRefExp (local_var_sym);
ROSE_ASSERT (local_var_ref);
// Assemble the final assignment expression.
return SageBuilder::buildAssignOp (param_deref_pack, local_var_ref);
}
return 0;
}