本文整理汇总了C++中SgStatement::setTransformation方法的典型用法代码示例。如果您正苦于以下问题:C++ SgStatement::setTransformation方法的具体用法?C++ SgStatement::setTransformation怎么用?C++ SgStatement::setTransformation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgStatement
的用法示例。
在下文中一共展示了SgStatement::setTransformation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: returnAttribute
//.........这里部分代码省略.........
// printf ("currentStatement = %p = %s \n",currentStatement,currentStatement->class_name().c_str());
printf ("currentStatement = %s \n",currentStatement->class_name().c_str());
printf (" --- currentStatement->isTransformation() = %s \n",currentStatement->isTransformation() ? "true" : "false");
}
#endif
// We have to test for a macro exapansion (will only work on statement level grainularity where parent statement has child statements).
bool all_children_have_token_info = true;
for (size_t i = 0; i < synthesizedAttributeList.size(); i++)
{
SgStatement* statement = isSgStatement(synthesizedAttributeList[i].node);
if (statement != NULL)
{
#if 0
// printf ("(child) statement = %p = %s \n",statement,statement->class_name().c_str());
printf ("(child) statement = %s \n",statement->class_name().c_str());
printf (" --- statement->isTransformation() = %s \n",statement->isTransformation() ? "true" : "false");
printf (" --- statement->get_containsTransformation() = %s \n",statement->get_containsTransformation() ? "true" : "false");
#endif
// DQ (11/8/2015): We might need to also check the surrounding white space as well (except that I think this is set later).
if (tokenStreamSequenceMap.find(statement) != tokenStreamSequenceMap.end())
{
// If we have a token mapping then we don't have to do anything.
TokenStreamSequenceToNodeMapping* mapping = tokenStreamSequenceMap[statement];
ROSE_ASSERT(mapping != NULL);
}
else
{
#if 0
// printf ("Parent statement = %p = %s No token stream information found for child statement = %p = %s \n",
// currentStatement,currentStatement->class_name().c_str(),statement,statement->class_name().c_str());
printf ("Parent statement = %s No token stream information found for child statement = %s \n",
currentStatement->class_name().c_str(),statement->class_name().c_str());
printf (" --- at line: %d \n",statement->get_file_info()->get_line());
// When this is a function declaration, try to understand more about it.
SgFunctionDeclaration* functionDeclaration = isSgFunctionDeclaration(statement);
if (functionDeclaration != NULL)
{
printf (" --- functionDeclaration name = %s \n",functionDeclaration->get_name().str());
}
#endif
all_children_have_token_info = false;
}
}
}
if (currentStatement != NULL && all_children_have_token_info == false)
{
#if 0
// printf ("*** Found case of statement marked as containing a transforamtion, but all children without token info (detected a macro expansion): currentStatement = %p = %s \n",currentStatement,currentStatement->class_name().c_str());
printf ("*** Found case of statement marked as containing a transforamtion, but all children without token info (detected a macro expansion): currentStatement = %s \n",currentStatement->class_name().c_str());
#endif
// DQ (11/9/2015): Added support for specific scopes where we don't want them the be
// unparsed from the token stream when children of them are transformed.
// DQ (11/8/2015): I think that this should not apply to a SgBasicBlock (for example see
// tests/roseTests/astInterfaceTests/inputmoveDeclarationToInnermostScope_test2015_94.C).
// The reason is that a block is not the same sort for compound statement as a SgForStatement.
// if (isSgBasicBlock(currentStatement) == NULL)
bool current_statement_is_allowed_to_have_statements_with_unmapped_token_sequences =
( (isSgGlobal(currentStatement) != NULL) ||
(isSgBasicBlock(currentStatement) != NULL) ||
// (isSgEnumDefinition(currentStatement) != NULL) ||
(isSgClassDefinition(currentStatement) != NULL) );
if (current_statement_is_allowed_to_have_statements_with_unmapped_token_sequences == false)
{
// Mark as a transformation instead of containing a transformation.
currentStatement->setTransformation();
// We also need to mark this too!
currentStatement->setOutputInCodeGeneration();
// And reset this to NOT contain a transformation.
currentStatement->set_containsTransformation(false);
#if 0
printf ("Exiting as a test! \n");
ROSE_ASSERT(false);
#endif
}
else
{
#if 0
// printf ("This currentStatement = %p = %s is allowed to have a child without a token sequence mapping \n",currentStatement,currentStatement->class_name().c_str());
printf ("This currentStatement = %s is allowed to have a child without a token sequence mapping \n",currentStatement->class_name().c_str());
#endif
}
}
#if 0
// Debugging code.
if (isSgForStatement(n) != NULL)
{
printf ("Exiting as a test! \n");
ROSE_ASSERT(false);
}
#endif
}
return returnAttribute;
}
开发者ID:brushington,项目名称:rose-develop,代码行数:101,代码来源:detectMacroExpansionsToBeUnparsedAsAstTransformations.C