本文整理汇总了C++中SgStatement::class_name方法的典型用法代码示例。如果您正苦于以下问题:C++ SgStatement::class_name方法的具体用法?C++ SgStatement::class_name怎么用?C++ SgStatement::class_name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgStatement
的用法示例。
在下文中一共展示了SgStatement::class_name方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printf
std::map<SgNode*,PreviousAndNextNodeData*>
computePreviousAndNextNodes(SgGlobal* globalScope, std::vector<FrontierNode*> frontierNodes)
{
// This is an alternative way to compute the previous/next node map using the token/AST unparsing frontier list directly.
std::map<SgNode*,PreviousAndNextNodeData*> previousAndNextNodeMap;
SgStatement* previousNode = globalScope;
SgStatement* previousPreviousNode = globalScope;
for (size_t j = 0; j < frontierNodes.size(); j++)
{
// SgStatement* statement = topAttribute.frontierNodes[j];
// ROSE_ASSERT(statement != NULL);
FrontierNode* frontierNode = frontierNodes[j];
ROSE_ASSERT(frontierNode != NULL);
SgStatement* statement = frontierNode->node;
ROSE_ASSERT(statement != NULL);
#if 0
printf (" (%p = %s) ",statement,statement->class_name().c_str());
#endif
PreviousAndNextNodeData* previousAndNextNodeData = new PreviousAndNextNodeData(previousPreviousNode,statement);
#if 0
printf ("Building previousAndNextNodeData = %p previousPreviousNode = %p = %s previousNode = %p = %s statement = %p = %s \n",
previousAndNextNodeData,previousPreviousNode,previousPreviousNode->class_name().c_str(),
previousNode,previousNode->class_name().c_str(),statement,statement->class_name().c_str());
#endif
// Insert a element into the map for the current IR node being traversed.
if (previousNode != NULL)
{
#if 0
printf ("Insert previousAndNextNodeData = %p into previousAndNextNodeMap \n",previousAndNextNodeData);
#endif
previousAndNextNodeMap.insert(std::pair<SgNode*,PreviousAndNextNodeData*>(previousNode,previousAndNextNodeData));
}
else
{
printf ("WARNING: previousNode == NULL: j = %" PRIuPTR " can't insert entry into previousAndNextNodeMap: statement = %p = %s \n",j,statement,statement->class_name().c_str());
}
previousPreviousNode = previousNode;
previousNode = statement;
}
// Handle the last frontier IR node
if (frontierNodes.empty() == false)
{
PreviousAndNextNodeData* previousAndNextNodeData = new PreviousAndNextNodeData(previousPreviousNode,globalScope);
// Insert a element into the map for the current IR node being traversed.
previousAndNextNodeMap.insert(std::pair<SgNode*,PreviousAndNextNodeData*>(previousNode,previousAndNextNodeData));
}
return previousAndNextNodeMap;
}
示例2: visit
void visitorTraversal::visit(SgNode* n)
{
// There are three types ir IR nodes that can be queried for scope:
// - SgStatement, and
// - SgInitializedName
SgStatement* statement = isSgStatement(n);
if (statement != NULL)
{
SgScopeStatement* scope = statement->get_scope();
ROSE_ASSERT(scope != NULL);
printf ("SgStatement = %12p = %30s has scope = %12p = %s (total number = %d) \n",
statement,statement->class_name().c_str(),
scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
}
SgInitializedName* initializedName = isSgInitializedName(n);
if (initializedName != NULL)
{
SgScopeStatement* scope = initializedName->get_scope();
ROSE_ASSERT(scope != NULL);
printf ("SgInitializedName = %12p = %30s has scope = %12p = %s (total number = %d)\n",
initializedName,initializedName->get_name().str(),
scope,scope->class_name().c_str(),(int)scope->numberOfNodes());
}
}
示例3: getIfConds
void getIfConds(SgIfStmt* fixIf, SgScopeStatement* parentScope) {
SgStatement* conditional = fixIf->get_conditional();
if (isSgExprStatement(conditional)) {
SgExpression* expr = isSgExprStatement(conditional)->get_expression();
std::pair<SgVariableDeclaration*, SgExpression*> pr = SageInterface::createTempVariableForExpression(expr,isSgScopeStatement(fixIf),true);
SgInitializedNamePtrList lptr = pr.first->get_variables();
//std::cout << "lprt size: " << lptr.size() << std::endl;
ROSE_ASSERT(lptr.size() <= 1);
SgVarRefExp* varRef = SageBuilder::buildVarRefExp(pr.first);
SgIntVal* iv = SageBuilder::buildIntVal(0);
SgNotEqualOp* nop = SageBuilder::buildNotEqualOp(isSgExpression(varRef),isSgExpression(iv));
SgExprStatement* ses = SageBuilder::buildExprStatement(isSgExpression(nop));
SageInterface::replaceStatement(conditional,ses);
//SageInterface::moveVariableDeclaration(pr.first, parentScope);
// SageInterface::appendStatement(pr.first, parentScope);
SageInterface::insertStatementBefore(fixIf,pr.first);
std::cout << "conditional type: " << conditional->class_name() << std::endl;
}
return;
}
示例4: isSgFile
void
visitorTraversal::visit(SgNode* n)
{
SgFile* file = isSgFile(n);
if (file != NULL)
{
filename = file->get_sourceFileNameWithPath();
}
// On each statement node and output it's position.
SgStatement* statement = isSgStatement(n);
bool outputStatement = (statement != NULL) ? true : false;
// Check for the statement to exist in the input source file
outputStatement = outputStatement && (statement->get_file_info()->get_filenameString() == filename);
// Skip SgGlobal IR nodes
outputStatement = outputStatement && (isSgGlobal(statement) == NULL);
if (outputStatement == true)
{
AttachedPreprocessingInfoType* comments = statement->getAttachedPreprocessingInfo();
if (comments != NULL)
{
// printf ("Found attached comments (to IR node at %p of type: %s): \n",statement,statement->class_name().c_str());
// int counter = 0;
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
#if 0
printf (" Attached Comment #%d in file %s (relativePosition=%s): classification %s :\n%s\n",
counter++,(*i)->get_file_info()->get_filenameString().c_str(),
((*i)->getRelativePosition() == PreprocessingInfo::before) ? "before" : "after",
PreprocessingInfo::directiveTypeName((*i)->getTypeOfDirective()).c_str(),
(*i)->getString().c_str());
#endif
// Mark comments and CPP directives a few different colors.
int startingLineNumber = (*i)->get_file_info()->get_line();
int startingColumnNumber = (*i)->get_file_info()->get_col();
// Subtract 1 from number of lines to avoid over counting the current line.
int endingLineNumber = startingLineNumber + ((*i)->getNumberOfLines() - 1);
int endingColumnNumber = (*i)->getColumnNumberOfEndOfString();
string color = directiveTypeColor((*i)->getTypeOfDirective());
#if 0
printf ("%d,%d,%s,%d,%d\n",startingLineNumber,startingColumnNumber,color.c_str(),endingLineNumber,endingColumnNumber);
#endif
dataFile << startingLineNumber << "," << startingColumnNumber << "," << color << "," << endingLineNumber << "," << endingColumnNumber << endl;
}
}
else
{
// printf ("No attached comments (at %p of type: %s): \n",statement,statement->sage_class_name());
}
ROSE_ASSERT(statement->get_startOfConstruct() != NULL);
int startingLineNumber = statement->get_startOfConstruct()->get_line();
int startingColumnNumber = statement->get_startOfConstruct()->get_col();
if (statement->get_endOfConstruct() == NULL)
{
printf ("Error: statement->get_endOfConstruct() == NULL (statement = %p = %s) \n",statement,statement->class_name().c_str());
}
ROSE_ASSERT(statement->get_endOfConstruct() != NULL);
int endingLineNumber = statement->get_endOfConstruct()->get_line();
int endingColumnNumber = statement->get_endOfConstruct()->get_col();
// Catch errors (likely compiler generate IR node or NULL file)
if (endingLineNumber == 0)
{
endingLineNumber = startingLineNumber;
endingColumnNumber = startingColumnNumber;
}
#if 0
// Mark all statements blue
string color = "blue";
if (isSgScopeStatement(statement) != NULL)
color = "red";
#else
string color = nodeColor(statement);
#endif
#if 0
printf ("%d,%d,%s,%d,%d %s = %p \n",startingLineNumber,startingColumnNumber,color.c_str(),endingLineNumber,endingColumnNumber,statement->class_name().c_str(),statement);
#endif
dataFile << startingLineNumber << "," << startingColumnNumber << "," << color << "," << endingLineNumber << "," << endingColumnNumber << endl;
}
// On each statement node and output it's position.
SgExpression* expression = isSgExpression(n);
bool outputExpression = (expression != NULL) ? true : false;
// Check for the statement to exist in the input source file
outputExpression = outputExpression && (expression->get_file_info()->get_filenameString() == filename);
//.........这里部分代码省略.........
示例5: returnAttribute
DetectMacroExpansionsToBeUnparsedAsAstTransformationsSynthesizedAttribute
DetectMacroExpansionsToBeUnparsedAsAstTransformations::evaluateSynthesizedAttribute (
SgNode* n,
DetectMacroExpansionsToBeUnparsedAsAstTransformationsInheritedAttribute inheritedAttribute,
SubTreeSynthesizedAttributes synthesizedAttributeList )
{
DetectMacroExpansionsToBeUnparsedAsAstTransformationsSynthesizedAttribute returnAttribute(n);
#if 0
printf ("In (Detect Transformations in Macro Expansions) evaluateSynthesizedAttribute(): n = %s n->get_containsTransformation() = %s \n",n->class_name().c_str(),n->get_containsTransformation() ? "true" : "false");
#endif
// DQ (11/8/2015): This has to be moved to after the tokenStreamSequenceMap has been setup since we need that to determine if
// IR nodes have a token mapping or not (subparts of macros expansions will not and we need this infor to recognize parts of
// the AST that are associated with macro expansions.
// DQ (11/8/2015): If this has been marked as containing a transformation then check if there is token info for each of the children.
// If there is not token info for each of the children then this currentStatement (e.g. n) must be marked as a transformation.
// This case happens when a transformation is done to a child of a statement that is part of a macro. In this case the parent will
// have token information which is the macro call, but since there is a transformation, we have to unparse the fully expanded form
// of the macro (from the AST), so the whole subtree must be unparsed. NOTE: this case might be more complex if multiple statements
// are associated with a macro (so that there is not a single root of the subtree. I need to build an example of this to better
// understand if there is a problem and if so just what would be the best solution. It will b at least an iterative refinement of
// this specific problem. See tests/roseTests/astInterfaceTests/inputmoveDeclarationToInnermostScope_test2015_135.C for an example
// of this problem.
if (n->get_containsTransformation() == true)
{
#if 0
printf ("Found case of statement marked as containing a transforamtion \n");
#endif
SgStatement* currentStatement = isSgStatement(n);
#if 0
if (currentStatement != NULL)
{
// 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)
{
//.........这里部分代码省略.........
开发者ID:brushington,项目名称:rose-develop,代码行数:101,代码来源:detectMacroExpansionsToBeUnparsedAsAstTransformations.C
示例6: doFiniteDifferencingOne
//.........这里部分代码省略.........
}
assert (newval);
replaceCopiesOfExpression(lhs, newval, eCopy);
}
break;
case V_SgPlusPlusOp:
{
SgExpression* lhs = isSgPlusPlusOp(modstmt)->get_operand();
SgIntVal* one = new SgIntVal(SgNULL_FILE, 1);
one->set_endOfConstruct(SgNULL_FILE);
SgAddOp* add = new SgAddOp(SgNULL_FILE, lhs, one);
add->set_endOfConstruct(SgNULL_FILE);
lhs->set_parent(add);
one->set_parent(add);
replaceCopiesOfExpression(lhs,add,eCopy);
}
break;
case V_SgMinusMinusOp:
{
SgExpression* lhs = isSgMinusMinusOp(modstmt)->get_operand();
SgIntVal* one = new SgIntVal(SgNULL_FILE, 1);
one->set_endOfConstruct(SgNULL_FILE);
SgSubtractOp* sub = new SgSubtractOp(SgNULL_FILE, lhs, one);
sub->set_endOfConstruct(SgNULL_FILE);
lhs->set_parent(sub);
one->set_parent(sub);
replaceCopiesOfExpression(lhs,sub,eCopy);
}
break;
default:
cerr << modstmt->sage_class_name() << endl;
assert (false);
break;
}
#ifdef FD_DEBUG
cout << "e is " << e->unparseToString() << endl;
cout << "eCopy is " << eCopy->unparseToString() << endl;
#endif
updateCache = doFdVariableUpdate(rules, varref, e, eCopy);
#ifdef FD_DEBUG
cout << "updateCache is " << updateCache->unparseToString() << endl;
#endif
if (updateCache)
{
ROSE_ASSERT(modstmt != NULL);
SgNode* ifp = modstmt->get_parent();
SgCommaOpExp* comma = new SgCommaOpExp(SgNULL_FILE, updateCache, modstmt);
modstmt->set_parent(comma);
updateCache->set_parent(comma);
if (ifp == NULL)
{
printf ("modstmt->get_parent() == NULL modstmt = %p = %s \n",modstmt,modstmt->class_name().c_str());
modstmt->get_startOfConstruct()->display("modstmt->get_parent() == NULL: debug");
}
ROSE_ASSERT(ifp != NULL);
#ifdef FD_DEBUG
cout << "New expression is " << comma->unparseToString() << endl;
cout << "IFP is " << ifp->sage_class_name() << ": " << ifp->unparseToString() << endl;
#endif
if (isSgExpression(ifp))
{
示例7: switch
void
FixupSelfReferentialMacrosInAST::visit ( SgNode* node )
{
// DQ (3/11/2006): Set NULL pointers where we would like to have none.
// printf ("In FixupSelfReferentialMacrosInAST::visit(): node = %s \n",node->class_name().c_str());
ROSE_ASSERT(node != NULL);
switch (node->variantT())
{
case V_SgInitializedName:
{
SgInitializedName* initializedName = isSgInitializedName(node);
ROSE_ASSERT(initializedName != NULL);
SgType* type = initializedName->get_type()->stripType();
SgClassType* classType = isSgClassType(type);
if (classType != NULL)
{
SgClassDeclaration* targetClassDeclaration = isSgClassDeclaration(classType->get_declaration());
SgName className = targetClassDeclaration->get_name();
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Found a class declaration name = %s \n",className.str());
// For sudo_exec_pty.c also look for siginfo
if (className == "sigaction" || className == "siginfo")
{
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Found a sigaction type \n");
// Note we could also check that the declaration came from a known header file.
SgStatement* associatedStatement = isSgStatement(initializedName->get_parent());
if (associatedStatement != NULL)
{
// Add a macro to undefine the "#define sa_handler __sigaction_handler.sa_handler" macro.
// printf ("In FixupSelfReferentialMacrosInAST::visit(): Add a macro to undefine the macro #define sa_handler __sigaction_handler.sa_handler \n");
// PreprocessingInfo* macro = new PreprocessingInfo(DirectiveType, const std::string & inputString,const std::string & filenameString, int line_no , int col_no,int nol, RelativePositionType relPos );
PreprocessingInfo::DirectiveType directiveType = PreprocessingInfo::CpreprocessorUndefDeclaration;
// We are puting out all macros anytime we see either type. This might be too much...
// From the sigaction.h file (included by signal.h):
addMacro(associatedStatement,"#undef sa_handler\n",directiveType);
addMacro(associatedStatement,"#undef sa_sigaction\n",directiveType);
// From the siginfo.h file (included by signal.h):
addMacro(associatedStatement,"#undef si_pid\n", directiveType);
addMacro(associatedStatement,"#undef si_uid\n", directiveType);
addMacro(associatedStatement,"#undef si_timerid\n",directiveType);
addMacro(associatedStatement,"#undef si_overrun\n",directiveType);
addMacro(associatedStatement,"#undef si_status\n", directiveType);
addMacro(associatedStatement,"#undef si_utime\n", directiveType);
addMacro(associatedStatement,"#undef si_stime\n", directiveType);
addMacro(associatedStatement,"#undef si_value\n", directiveType);
addMacro(associatedStatement,"#undef si_int\n", directiveType);
addMacro(associatedStatement,"#undef si_ptr\n", directiveType);
addMacro(associatedStatement,"#undef si_addr\n", directiveType);
addMacro(associatedStatement,"#undef si_band\n", directiveType);
addMacro(associatedStatement,"#undef si_fd\n", directiveType);
}
}
}
}
default:
{
// printf ("Not handled in FixupSelfReferentialMacrosInAST::visit(%s) \n",node->class_name().c_str());
}
}
#if 0
// DQ (12/30/2013): Comments and CPP directives have not yet been attached to the AST, so we can't process them here.
// SgLocatedNode* locatedNode = isSgLocatedNode(node);
// if (locatedNode != NULL)
SgStatement* stmt = isSgStatement(node);
if (stmt != NULL)
{
// Find all #define statements and look for self referencing macros
int numberOfComments = -1;
if (stmt->getAttachedPreprocessingInfo() != NULL)
numberOfComments = stmt->getAttachedPreprocessingInfo()->size();
std::string s = std::string(" --- startOfConstruct: file = " ) + stmt->get_startOfConstruct()->get_filenameString()
+ " raw filename = " + stmt->get_startOfConstruct()->get_raw_filename()
+ " raw line = " + StringUtility::numberToString(stmt->get_startOfConstruct()->get_raw_line())
+ " raw column = " + StringUtility::numberToString(stmt->get_startOfConstruct()->get_raw_col())
+ " #comments = " + StringUtility::numberToString(numberOfComments)
+ " \n ";
AttachedPreprocessingInfoType* comments = stmt->getAttachedPreprocessingInfo();
if (comments != NULL)
{
printf ("Found attached comments (at %p of type: %s): \n",stmt,stmt->class_name().c_str());
AttachedPreprocessingInfoType::iterator i;
for (i = comments->begin(); i != comments->end(); i++)
{
ROSE_ASSERT ( (*i) != NULL );
printf (" Attached Comment (relativePosition=%s): %s\n",
//.........这里部分代码省略.........
示例8: myStatementInsert
// Insert a new statement before or after a target statement. If
// allowForInit is true, the new statement can be inserted into the
// initializer of a for statement.
// Needs to be merged
void myStatementInsert ( SgStatement* target, SgStatement* newstmt, bool before, bool allowForInit )
{
ROSE_ASSERT(target != NULL);
ROSE_ASSERT(newstmt != NULL);
#if 0
printf ("In inlining: myStatementInsert(): newstmt = %p = %s \n",newstmt,newstmt->class_name().c_str());
printf ("In inlining: myStatementInsert(): target = %p = %s \n",target,target->class_name().c_str());
#endif
SgStatement* parent = isSgStatement(target->get_parent());
#if 0
if (parent == NULL)
{
ROSE_ASSERT(target->get_file_info() != NULL);
target->get_file_info()->display("problem IR node: debug");
if (target != NULL)
{
// printf ("In inlining: myStatementInsert(): target->get_parent() = %p = %s \n",target->get_parent(),target->get_parent()->class_name().c_str());
printf ("In inlining: myStatementInsert(): target->get_parent() = %p \n",target->get_parent());
}
}
#endif
// cerr << "1: target is a " << target->sage_class_name() << ", target->get_parent() is a " << target->get_parent()->sage_class_name() << endl;
if (isSgIfStmt(parent) && isSgIfStmt(parent)->get_conditional() == target)
{
target = parent;
parent = isSgScopeStatement(target->get_parent());
}
// printf ("allowForInit = %s \n",allowForInit ? "true" : "false");
if (isSgForInitStatement(target->get_parent()) && !allowForInit)
{
target = isSgScopeStatement(target->get_parent()->get_parent());
parent = isSgScopeStatement(target->get_parent());
assert (target);
}
if (isSgSwitchStatement(target->get_parent()) && target == isSgSwitchStatement(target->get_parent())->get_item_selector()) {
target = isSgScopeStatement(target->get_parent()->get_parent());
parent = isSgScopeStatement(target->get_parent());
assert (target);
}
ROSE_ASSERT(target != NULL);
#if 0
// DQ (8/1/2005): This fails because the parent at some point is not set and the unparseToString detects this (likely in qualifier generation)
cerr << "2: target is a " << target->sage_class_name() << ", target->get_parent() is a " << target->get_parent()->sage_class_name() << endl;
ROSE_ASSERT(parent != NULL);
if (parent->get_parent() == NULL)
{
printf ("Found null parent of %p = %s \n",parent,parent->class_name().c_str());
}
ROSE_ASSERT(parent->get_parent() != NULL);
cerr << "2: parent is a " << parent->sage_class_name() << ", parent->get_parent() is a " << parent->get_parent()->sage_class_name() << endl;
// cerr << "2: target is " << target->unparseToString() << ", target->get_parent() is " << target->get_parent()->unparseToString() << endl;
#endif
ROSE_ASSERT (parent);
SgStatementPtrList* siblings_ptr;
if (isSgForInitStatement(target->get_parent()))
{
siblings_ptr = &isSgForInitStatement(target->get_parent())->get_init_stmt();
}
else
{
assert (parent);
if (isSgScopeStatement(parent))
{
ROSE_ASSERT(parent != NULL);
siblings_ptr = &isSgScopeStatement(parent)->getStatementList();
parent = isSgStatement(target->get_parent()); // getStatementList might have changed it when parent was a loop or something similar
ROSE_ASSERT (parent);
}
else
{
assert (!"Bad parent type");
}
}
ROSE_ASSERT(siblings_ptr != NULL);
ROSE_ASSERT(target != NULL);
SgStatementPtrList& siblings = *siblings_ptr;
SgStatementPtrList::iterator stmt_iter = std::find(siblings.begin(), siblings.end(), target);
ROSE_ASSERT (stmt_iter != siblings.end());
if (!before)
++stmt_iter;
newstmt->set_parent(parent);
siblings.insert(stmt_iter, newstmt);
}
示例9: printf
FrontierDetectionForTokenStreamMapping_InheritedAttribute
FrontierDetectionForTokenStreamMapping::evaluateInheritedAttribute(SgNode* n, FrontierDetectionForTokenStreamMapping_InheritedAttribute inheritedAttribute)
{
static int random_counter = 0;
#if 1
// Ignore IR nodes that are front-end specific (declarations of builtin functions, etc.).
if (n->get_file_info()->isFrontendSpecific() == false)
{
printf ("In FrontierDetectionForTokenStreamMapping::evaluateInheritedAttribute(): n = %p = %s \n",n,n->class_name().c_str());
// Count the IR nodes traversed so that we can make a subset transformations.
random_counter++;
}
#endif
FrontierDetectionForTokenStreamMapping_InheritedAttribute returnAttribute;
SgStatement* statement = isSgStatement(n);
// if (statement != NULL && random_counter > 30 && random_counter < 40)
if (statement != NULL)
{
string name = "token_frontier";
string options = "color=\"blue\"";
if (random_counter > 30 && random_counter < 40)
{
printf ("In FrontierDetectionForTokenStreamMapping::evaluateInheritedAttribute(): Mark this statement as a transformation: random_counter = %d statement = %p = %s \n",random_counter,statement,statement->class_name().c_str());
options = "color=\"red\"";
returnAttribute.containsFrontier = true;
}
// AstAttribute::AttributeNodeInfo* attribute = new FrontierDetectionForTokenStreamMappingAttribute ( (SgNode*) n, name, options);
AstAttribute* attribute = new FrontierDetectionForTokenStreamMappingAttribute ( (SgNode*) n, name, options);
statement->setAttribute(name,attribute);
}
// return FrontierDetectionForTokenStreamMapping_InheritedAttribute();
return returnAttribute;
}