本文整理汇总了C++中SgName::str方法的典型用法代码示例。如果您正苦于以下问题:C++ SgName::str方法的具体用法?C++ SgName::str怎么用?C++ SgName::str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgName
的用法示例。
在下文中一共展示了SgName::str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: isSgName
NodeQuerySynthesizedAttributeType NodeQuery::queryNodeClassDeclarationFromName(SgNode* node, SgNode* nameNode){
NodeQuerySynthesizedAttributeType returnList;
ROSE_ASSERT( nameNode != NULL );
ROSE_ASSERT( node != NULL );
//finds the name which should be matched to
SgName* sageName = isSgName(nameNode);
ROSE_ASSERT( sageName != NULL );
std::string nameToMatch = sageName->str();
ROSE_ASSERT( nameToMatch.length() > 0 );
SgClassDeclaration *sageClassDeclaration = isSgClassDeclaration (node);
if (sageClassDeclaration != NULL)
{
std::string name = sageClassDeclaration->get_name ().str ();
if( name == nameToMatch )
returnList.push_back(node);
}
return returnList;
} /* End function:queryNodeCLassDeclarationFromName() */
示例2: n_mangled
SgName
mangleFunctionName (const SgName& n, const SgName& ret_type_name )
{
string s_mangled = mangleFunctionNameToString (n.getString (),
ret_type_name.str ());
SgName n_mangled (s_mangled.c_str ());
return n_mangled;
}
示例3: isSgVariableDeclaration
void
Unparse_Jovial::unparseVarDecl(SgStatement* stmt, SgInitializedName* initializedName, SgUnparse_Info& info)
{
SgName name = initializedName->get_name();
SgType* type = initializedName->get_type();
SgInitializer* init = initializedName->get_initializer();
ROSE_ASSERT(type);
SgVariableDeclaration* variableDeclaration = isSgVariableDeclaration(stmt);
ROSE_ASSERT(variableDeclaration != NULL);
#if 0
if (variableDeclaration->get_declarationModifier().get_typeModifier().isStatic() == true)
{
curprint("STATIC ");
}
#endif
switch (type->variantT())
{
case V_SgArrayType:
curprint("TABLE ");
curprint(name.str());
break;
default:
curprint("ITEM ");
curprint(name.str());
curprint(" ");
}
unparseType(type, info);
if (init != NULL)
{
curprint(" = ");
SgInitializer* initializer = isSgInitializer(init);
ROSE_ASSERT(initializer != NULL);
// TODO
// unparseExpression(initializer, info);
}
curprint(" ;\n");
}
示例4: isSgName
NodeQuerySynthesizedAttributeType
queryNodeClassDeclarationFromTypedefName (SgNode * astNode,
SgNode * nameNode)
{
NodeQuerySynthesizedAttributeType returnList;
ROSE_ASSERT (nameNode != NULL);
ROSE_ASSERT (nameNode != NULL);
//finds the name which should be matched to
SgName *sageName = isSgName (nameNode);
ROSE_ASSERT (sageName != NULL);
string nameToMatch = sageName->str ();
ROSE_ASSERT (nameToMatch.length () > 0);
if (isSgType (astNode) != NULL)
{
/*SgTypedefType* sageTypedefType = isSgTypedefType(astNode);
string name = TransformationSupport::getTypeName(sageTypedefType);
ROSE_ASSERT( nameToMatch.length() > 0 );
cout << nameToMatch << endl; */
#ifdef DEBUG_CGRAPHPP
cout << TransformationSupport::getTypeName (isSgType (astNode)) << endl;
#endif
if (TransformationSupport::getTypeName (isSgType (astNode)) ==
nameToMatch)
{
returnList.push_back (astNode);
}
/*
if(nameToMatch == name){
SgClassDeclaration *sageClassDeclaration = isSgClassDeclaration (sageTypedefType->get_declaration());
ROSE_ASSERT( sageClassDeclaration != NULL );
returnList.push_back(sageClassDeclaration);
}*/
}
return returnList;
}
示例5: myTimerFunctionStart
void
SimpleInstrumentation::visit ( SgNode* astNode )
{
// Demonstrate and test append mechanism for statements
// printf ("In assemblyFunction(): astNode->sage_class_name() = %s \n",astNode->sage_class_name());
if (isSgFunctionDeclaration(astNode) != NULL)
{
// printf ("Found a function declaration \n");
SgFunctionDeclaration* functionDeclarationStatement = isSgFunctionDeclaration(astNode);
SgName sageName = functionDeclarationStatement->get_name();
string functionNameString = sageName.str();
// Make sure this is the "main" function before we insert new code
if (functionNameString == "main")
{
string globalDeclarations = "int k;";
string functionSource = "";
string localDeclarations = "\
void myTimerFunctionStart(void) \n\
{ \n\
int xyzVariable; \n\
} \n\n\
示例6: isSgVariableDeclaration
//-----------------------------------------------------------------------------------
// int UnparseOrigFormat::special_cases
//
// Handles and calculates the length to subtract from the total number of spaces
// to indent. The column information returned from a declaration is designated
// at the name. Thus, the length of the type must be found to subtract from the
// column number of the name.
//-----------------------------------------------------------------------------------
int
UnparseOrigFormat::special_cases(SgLocatedNode* node)
{
// column length to subtract
int subcol = 0;
if (isSgVariableDeclaration(node))
{
SgVariableDeclaration* vardecl_stmt = isSgVariableDeclaration(node);
assert(vardecl_stmt != NULL);
SgInitializedNamePtrList initname_list = vardecl_stmt->get_variables();
// SgInitializedNamePtrList::const_iterator iter = initname_list.begin();
SgInitializedNamePtrList::iterator iter = initname_list.begin();
if (iter != initname_list.end())
{
ROSE_ASSERT ((*iter) != NULL);
SgType* tmp_type = (*iter)->get_type();
assert(tmp_type != NULL);
// adding one since there's a space in between the type and name
subcol += get_type_len(tmp_type) + 1;
}
}
else
{
if (isSgMemberFunctionDeclaration(node))
{
SgMemberFunctionDeclaration* mfuncdecl_stmt = isSgMemberFunctionDeclaration(node);
assert(mfuncdecl_stmt != NULL);
SgType* rtype = NULL;
if ( !( mfuncdecl_stmt->get_specialFunctionModifier().isConstructor() ||
mfuncdecl_stmt->get_specialFunctionModifier().isDestructor() ||
mfuncdecl_stmt->get_specialFunctionModifier().isConversion() ) )
{
// this means that the function has a return type, so calculate the length of this type
if (mfuncdecl_stmt->get_orig_return_type())
rtype = mfuncdecl_stmt->get_orig_return_type();
else
rtype = mfuncdecl_stmt->get_type()->get_return_type();
subcol += get_type_len(rtype) + 1;
}
if ( !isSgClassDefinition(mfuncdecl_stmt->get_parent()) )
{
// this means that the function is not in a class structure, so we must get
// the length of the class name <class>::<function name>
SgName scopename;
// DQ (11/17/2004): Interface modified, use get_class_scope() if we want a
// SgClassDefinition, else use get_scope() if we want a SgScopeStatement.
// scopename = mfuncdecl_stmt->get_scope()->get_declaration()->get_qualified_name();
scopename = mfuncdecl_stmt->get_class_scope()->get_declaration()->get_qualified_name();
subcol += strlen(scopename.str()) + 2; // 2 extra spaces from the "::"
}
}
else
{
if (isSgFunctionDeclaration(node))
{
SgFunctionDeclaration* funcdecl_stmt = isSgFunctionDeclaration(node);
assert(funcdecl_stmt != NULL);
SgType* tmp_type = funcdecl_stmt->get_type()->get_return_type();
assert(tmp_type != NULL);
subcol += get_type_len(tmp_type) + 1;
}
else
{
if (isSgClassDeclaration(node))
{
SgClassDeclaration* classdecl_stmt = isSgClassDeclaration(node);
assert(classdecl_stmt != NULL);
subcol += 6; //for "class "
}
else
{
if (isSgCaseOptionStmt(node))
{
SgCaseOptionStmt* case_stmt = isSgCaseOptionStmt(node);
assert(case_stmt != NULL);
subcol += 5; //for "case "
}
else
{
if (isSgLabelStatement(node))
{
SgLabelStatement* label_stmt = isSgLabelStatement(node);
assert(label_stmt != NULL);
// assert(label_stmt->get_label().str() != NULL);
subcol += strlen(label_stmt->get_label().str());
}
else
{
//.........这里部分代码省略.........
示例7: switch
string
AST_Rewrite::AccumulatedDeclarationsAttribute::
generateDeclarationString ( SgDeclarationStatement* declaration ) const
{
// This function generates a string for a declaration. The string is required for
// the intermediate file to make sure that all transformation code will compile
// (since it could depend on declarations defined within the code).
// Details:
// 1) Only record declarations found within the source file (exclude all header files
// since they will be seen when the same header files are included).
// 2) Resort the variable declarations to remove redundent entries.
// WRONG: variable declarations could have dependences upon class declarations!
// 3) Don't sort all declarations since some could have dependences.
// a) class declarations
// b) typedefs
// c) function declarations
// d) template declarations
// e) variable definition???
ROSE_ASSERT (this != NULL);
ROSE_ASSERT ( declaration != NULL );
string declarationString;
// Build a SgUnparse_Info object to represent formatting options for
// this statement (use the default values).
SgUnparse_Info info;
// exclude comments
info.set_SkipComments();
// exclude all CPP directives (since they have already been evaluated by the front-end)
info.set_SkipCPPDirectives();
switch ( declaration->variantT() )
{
// Enum declarations should not skip their definition since
// this is where the constants are declared.
case V_SgEnumDeclaration:
case V_SgVariableDeclaration:
case V_SgTemplateDeclaration:
case V_SgTypedefDeclaration:
// Need to figure out if a forward declaration would work or be
// more conservative and always output the complete class definition.
// turn off output of initializer values
info.set_SkipInitializer();
// output the declaration as a string
declarationString = globalUnparseToString(declaration,&info);
break;
case V_SgClassDeclaration:
// Need to figure out if a forward declaration would work or be
// more conservative and always output the complete class definition.
// turn off the generation of the function definitions only
// (we still want the restof the class definition since these
// define all member data and member functions).
// info.set_SkipClassDefinition();
info.set_SkipFunctionDefinition();
info.set_AddSemiColonAfterDeclaration();
// output the declaration as a string
declarationString = globalUnparseToString(declaration,&info);
break;
// For functions just output the declaration and skip the definition
// (This also avoids the generation of redundent definitions since the
// function we are in when we generate all declarations would be included).
case V_SgMemberFunctionDeclaration:
case V_SgFunctionDeclaration:
{
// turn off the generation of the definition
info.set_SkipFunctionDefinition();
info.set_AddSemiColonAfterDeclaration();
// output the declaration as a string
declarationString = globalUnparseToString(declaration,&info);
break;
}
case V_SgFunctionParameterList:
{
// Handle generation of declaration strings this case differnetly from unparser
// since want to generate declaration strings and not function parameter lists
// (function parameter lists would be delimited by "," while declarations would
// be delimited by ";").
SgFunctionParameterList* parameterListDeclaration = dynamic_cast<SgFunctionParameterList*>(declaration);
ROSE_ASSERT (parameterListDeclaration != NULL);
SgInitializedNameList & argList = parameterListDeclaration->get_args();
SgInitializedNameList::iterator i;
for (i = argList.begin(); i != argList.end(); i++)
{
string typeNameString = (*i).get_type()->unparseToString();
// (9/8/2003) Bug Fix suggested by Nils
// string variableName = (*i).get_name().str();
string variableName;
SgName nodeName = (*i).get_name();
if(nodeName.str() != NULL)
//.........这里部分代码省略.........
示例8: ninfo
void
Unparse_Java::unparseEnumType(SgEnumType* type, SgUnparse_Info& info)
{
SgEnumType* enum_type = isSgEnumType(type);
ROSE_ASSERT(enum_type);
if (info.isTypeSecondPart() == false)
{
SgEnumDeclaration *edecl = isSgEnumDeclaration(enum_type->get_declaration());
SgClassDefinition *cdefn = NULL;
SgNamespaceDefinitionStatement* namespaceDefn = NULL;
ROSE_ASSERT(edecl != NULL);
// Build reference to any possible enclosing scope represented by a SgClassDefinition or SgNamespaceDefinition
// to be used check if name qualification is required.
unp->u_exprStmt->initializeDeclarationsFromParent ( edecl, cdefn, namespaceDefn );
if (info.isTypeFirstPart() == true && info.SkipEnumDefinition() == false)
{
unp->u_exprStmt->unparseAttachedPreprocessingInfo(edecl, info, PreprocessingInfo::before);
}
curprint ( "enum ");
SgNamedType *ptype = NULL;
if (cdefn != NULL)
{
ptype = isSgNamedType(cdefn->get_declaration()->get_type());
}
if (SageInterface::is_C_language() == true || SageInterface::is_C99_language() == true)
{
curprint ( enum_type->get_name().getString() + " ");
}
else
{
// DQ (7/20/2011): Test compilation without the generateNameQualifier() functions.
// The C++ support is more complex and can require qualified names!
// SgName nameQualifier = unp->u_name->generateNameQualifier( edecl , info );
SgName nameQualifier;
// printf ("nameQualifier (from unp->u_name->generateNameQualifier function) = %s \n",nameQualifier.str());
// curprint ( "\n/* nameQualifier (from unp->u_name->generateNameQualifier function) = " + nameQualifier + " */ \n ";
curprint ( nameQualifier.str());
SgName nm = enum_type->get_name();
if (nm.getString() != "")
{
// printf ("Output qualifier of current types to the name = %s \n",nm.str());
curprint ( nm.getString() + " ");
}
}
}
if (info.isTypeFirstPart() == true)
{
// info.display("info before constructing ninfo");
SgUnparse_Info ninfo(info);
// don't skip the semicolon in the output of the statement in the class definition
ninfo.unset_SkipSemiColon();
ninfo.set_isUnsetAccess();
// printf ("info.SkipEnumDefinition() = %s \n",(info.SkipEnumDefinition() == true) ? "true" : "false");
if ( info.SkipEnumDefinition() == false)
{
SgUnparse_Info ninfo(info);
ninfo.set_inEnumDecl();
SgInitializer *tmp_init = NULL;
SgName tmp_name;
SgEnumDeclaration *enum_stmt = isSgEnumDeclaration(enum_type->get_declaration());
ROSE_ASSERT(enum_stmt != NULL);
// This permits support of the empty enum case! "enum x{};"
curprint ( "{");
SgInitializedNamePtrList::iterator p = enum_stmt->get_enumerators().begin();
if (p != enum_stmt->get_enumerators().end())
{
// curprint ( "{";
while (1)
{
unp->u_exprStmt->unparseAttachedPreprocessingInfo(*p, info, PreprocessingInfo::before);
tmp_name=(*p)->get_name();
tmp_init=(*p)->get_initializer();
curprint ( tmp_name.str());
if(tmp_init)
{
curprint ( "=");
unp->u_exprStmt->unparseExpression(tmp_init, ninfo);
}
p++;
if (p != enum_stmt->get_enumerators().end())
{
curprint ( ",");
}
//.........这里部分代码省略.........
示例9: if
string
SIDL_TreeTraversal::generateSIDLFunctionDeclaration(SgFunctionDeclaration* functionDeclarationStatement )
{
ROSE_ASSERT (functionDeclarationStatement != NULL);
ROSE_ASSERT (functionDeclarationStatement->get_file_info() != NULL);
const SgSpecialFunctionModifier &functionModifier = functionDeclarationStatement->get_specialFunctionModifier();
string functionName = functionDeclarationStatement->get_name().str();
string sidlFunctionName ;
if (functionModifier.isConstructor()) {
if (functionDeclarationStatement->get_args().size() == 0) return ""; // skip empty constructor
sidlFunctionName = constructorName;
}
else {
sidlFunctionName = functionName;
}
// We have to force the mangled name to be generated before we access it (else we just get "defaultName")
string mangledFunctionName = functionDeclarationStatement->get_mangled_name().str();
sidlFunctionName = stringifyOperatorWithoutSymbols(sidlFunctionName);
// Get the class name
SgClassDefinition* classDefinition = isSgClassDefinition(functionDeclarationStatement->get_scope());
// DQ (1/7/2004): Modified for make EDG version 3.3 work (member function declarations's normalized by EDG)
if (classDefinition != NULL)
{
SgClassDeclaration* classDeclaration = classDefinition->get_declaration();
string className = classDeclaration->get_name().str();
overloadInformation info = isOverloaded(classDefinition,functionName,mangledFunctionName);
int orderofOverloadedFunction = info.get_order();
// If function is overloaded then append the number indicating the order of appearance in the
// class declaration
if (info.get_count() > 1)
{
vector<SgType*> types = info.get_types();
// SgInitializedNamePtrList &args = functionDeclarationStatement->get_args ();
int size = types.size();
if(size > 0)
{
if(size < 3)
{
sidlFunctionName += "[";
for(vector<SgType*>::iterator i = types.begin(); i!= types.end(); i++)
{
if(i != types.begin()) sidlFunctionName += "_";
if(isSgPointerType(*i) != NULL) sidlFunctionName += "P";
sidlFunctionName += sidlOverloadExtension(TransformationSupport::getTypeName(*i));
}
sidlFunctionName += "]";
}
else
sidlFunctionName += "["+numberToOverloadString(orderofOverloadedFunction)+"]";
}
}
}
else
{
printf ("EDG version 3.3 can return a null pointer to the member function definition \n");
}
SgFunctionType* functionType = functionDeclarationStatement->get_type();
ROSE_ASSERT(functionType != NULL);
// SgType* returnType = functionType->get_return_type();
// ROSE_ASSERT (returnType != NULL);
// string returnTypeName = TransformationSupport::getTypeName(returnType);
// printf ("function has_ellipses %s \n",(functionType->get_has_ellipses() != false) ? "true" : "false");
// showSgFunctionType(cout, functionType, "Called from generateSIDLFunctionDeclaration", 0 );
// printf ("Function return type = %s \n",returnTypeName.c_str());
#if 0
SgTypePtrList & argumentTypeList = functionType->get_arguments();
ROSE_ASSERT (argumentTypeList.size() >= 0);
SgTypePtrList::iterator argumentIterator = argumentTypeList.begin();
for (argumentIterator = argumentTypeList.begin(); argumentIterator != argumentTypeList.end(); argumentIterator++)
{
// showSgType(os,(*argumentIterator), label, depth+1);
string argumentTypeName = TransformationSupport::getTypeName(*argumentIterator);
printf ("-----> argument #%d argumentTypeName = %s \n",argumentCounter++,argumentTypeName.c_str());
}
#endif
//Determine the SIDL parameter passing mechanism (in,out,inout)
SgInitializedNamePtrList & argumentList = functionDeclarationStatement->get_args();
string parameterTypesAndNames;
SgInitializedNamePtrList::iterator i;
unsigned int argumentCounter = 0;
for (i = argumentList.begin(); i != argumentList.end(); i++)
{
SgType* type = (*i)->get_type();
//.........这里部分代码省略.........
示例10: partialRedundancyEliminationOne
//.........这里部分代码省略.........
vector<bool> edge_insert(cfg.graph.edges().size());
// printf ("Intermediate test 2: needToMakeCachevar = %s \n",needToMakeCachevar ? "true" : "false");
EdgeIter j = cfg.graph.edges().begin(), jend = cfg.graph.edges().end();
for (; j != jend; ++j)
{
edge_insert[*j] = !spavout[cfg.graph.source(*j)] && spavin[cfg.graph.target(*j)] && spantin[cfg.graph.target(*j)];
// printf ("edge_insert[*j] = %s \n",edge_insert[*j] ? "true" : "false");
if (edge_insert[*j])
{
needToMakeCachevar = true;
// cerr << "Insert computation of " << expr->unparseToString() << " on edge from "
// << cfg.graph.source(*j) << " to " << cfg.graph.target(*j) << endl;
}
}
// printf ("Before final test: needToMakeCachevar = %s \n",needToMakeCachevar ? "true" : "false");
// Add cache variable if necessary
SgVarRefExp* cachevar = 0;
if (needToMakeCachevar)
{
SgName cachevarname = "cachevar__";
cachevarname << ++SageInterface::gensym_counter;
// printf ("Building variable name = %s \n",cachevarname.str());
SgType* type = expr->get_type();
if (isSgArrayType(type))
type = new SgPointerType(isSgArrayType(type)->get_base_type());
assert (SageInterface::isDefaultConstructible(type));
// FIXME: assert (isAssignable(type));
SgVariableDeclaration* decl = new SgVariableDeclaration(SgNULL_FILE, cachevarname, type, NULL);
decl->set_definingDeclaration(decl);
SgInitializedName* initname = decl->get_variables().back();
// DQ (10/5/2007): Added an assertion.
ROSE_ASSERT(initname != NULL);
decl->addToAttachedPreprocessingInfo(
new PreprocessingInfo(PreprocessingInfo::CplusplusStyleComment,
(string("// Partial redundancy elimination: ") + cachevarname.str() +
" is a cache of " + expr->unparseToString()).c_str(),
"Compiler-Generated in PRE", 0, 0, 0, PreprocessingInfo::before));
SgVariableSymbol* cachevarsym = new SgVariableSymbol(initname);
decl->set_parent(root);
// DQ (10/5/2007): Added scope (suggested by Jeremiah).
initname->set_scope(root);
root->get_statements().insert(root->get_statements().begin(),decl);
root->insert_symbol(cachevarname, cachevarsym);
cachevar = new SgVarRefExp(SgNULL_FILE, cachevarsym);
cachevar->set_endOfConstruct(SgNULL_FILE);
}
// Do expression computation replacements
for (set<SgNode*>::iterator i = replacements.begin(); i != replacements.end(); ++i)
{
ReplaceExpressionWithVarrefVisitor(expr, cachevar).traverse(*i, postorder);
}
示例11: evaluateSynthesizedAttribute
// first visits the VarRef and then creates entry in operandDatabase which is
// useful in expressionStatement transformation. Thus, we replace the VarRef
// at the end of the traversal and insert loops during traversal
ArrayAssignmentStatementQuerySynthesizedAttributeType ArrayAssignmentStatementTransformation::evaluateSynthesizedAttribute(
SgNode* astNode,
ArrayAssignmentStatementQueryInheritedAttributeType arrayAssignmentStatementQueryInheritedData,
SubTreeSynthesizedAttributes synthesizedAttributeList) {
// This function assembles the elements of the input list (a list of char*) to form the output (a single char*)
#if DEBUG
printf ("\n$$$$$ TOP of evaluateSynthesizedAttribute (astNode = %s) (synthesizedAttributeList.size() = %d) \n",
astNode->sage_class_name(),synthesizedAttributeList.size());
//cout << " Ast node string: " << astNode->unparseToString() << endl;
#endif
// Build the return value for this function
ArrayAssignmentStatementQuerySynthesizedAttributeType returnSynthesizedAttribute(astNode);
// Iterator used within several error checking loops (not sure we should declare it here!)
vector<ArrayAssignmentStatementQuerySynthesizedAttributeType>::iterator i;
// Make a reference to the global operand database
OperandDataBaseType & operandDataBase = accumulatorValue.operandDataBase;
// Make sure the data base has been setup properly
ROSE_ASSERT(operandDataBase.transformationOption > ArrayTransformationSupport::UnknownIndexingAccess);
ROSE_ASSERT(operandDataBase.dimension > -1);
// Build up a return string
string returnString = "";
string operatorString;
// Need to handle all unary and binary operators and variables (but not much else)
switch (astNode->variant()) {
case FUNC_CALL: {
// Error checking: Verify that we have a SgFunctionCallExp object
SgFunctionCallExp* functionCallExpression = isSgFunctionCallExp(astNode);
ROSE_ASSERT(functionCallExpression != NULL);
string operatorName = TransformationSupport::getFunctionName(functionCallExpression);
ROSE_ASSERT(operatorName.c_str() != NULL);
string functionTypeName = TransformationSupport::getFunctionTypeName(functionCallExpression);
if ((functionTypeName != "doubleArray") && (functionTypeName != "floatArray") && (functionTypeName
!= "intArray")) {
// Use this query to handle only A++ function call expressions
// printf ("Break out of overloaded operator processing since type = %s is not to be processed \n",functionTypeName.c_str());
break;
} else {
// printf ("Processing overloaded operator of type = %s \n",functionTypeName.c_str());
}
ROSE_ASSERT((functionTypeName == "doubleArray") || (functionTypeName == "floatArray") || (functionTypeName
== "intArray"));
// printf ("CASE FUNC_CALL: Overloaded operator = %s \n",operatorName.c_str());
// Get the number of parameters to this function
SgExprListExp* exprListExp = functionCallExpression->get_args();
ROSE_ASSERT(exprListExp != NULL);
SgExpressionPtrList & expressionPtrList = exprListExp->get_expressions();
int numberOfParameters = expressionPtrList.size();
TransformationSupport::operatorCodeType operatorCodeVariant =
TransformationSupport::classifyOverloadedOperator(operatorName.c_str(), numberOfParameters);
// printf ("CASE FUNC_CALL: numberOfParameters = %d operatorCodeVariant = %d \n",
// numberOfParameters,operatorCodeVariant);
ROSE_ASSERT(operatorName.length() > 0);
// Separating this case into additional cases makes up to some
// extent for using a more specific higher level grammar.
switch (operatorCodeVariant) {
case TransformationSupport::ASSIGN_OPERATOR_CODE: {
vector<ArrayOperandDataBase>::iterator lhs = operandDataBase.arrayOperandList.begin();
vector<ArrayOperandDataBase>::iterator rhs = lhs;
rhs++;
while (rhs != operandDataBase.arrayOperandList.end()) {
// look at the operands on the rhs for a match with the one on the lhs
if ((*lhs).arrayVariableName == (*rhs).arrayVariableName) {
// A loop dependence has been identified
// Mark the synthesized attribute to record
// the loop dependence within this statement
returnSynthesizedAttribute.setLoopDependence(TRUE);
}
rhs++;
}
break;
}
default:
break;
//.........这里部分代码省略.........
示例12: optionSpecification
void
TransformationSupport::getTransformationOptionsFromVariableDeclarationConstructorArguments (
SgVariableDeclaration* variableDeclaration,
list<OptionDeclaration> & returnEnumValueList )
{
ROSE_ASSERT (variableDeclaration != NULL);
SgInitializedNamePtrList & variableList = variableDeclaration->get_variables();
printf ("Inside of getTransformationOptionsFromVariableDeclarationConstructorArguments() \n");
for (SgInitializedNamePtrList::iterator i = variableList.begin(); i != variableList.end(); i++)
{
// We don't care about the name
// SgName & name = (*i).get_name();
ROSE_ASSERT ((*i) != NULL);
// QY 11/10/04 removed named_item in SgInitializedName
// printf ("Processing a variable in the list \n");
// if ((*i)->get_named_item() != NULL)
// {
// ROSE_ASSERT ((*i)->get_named_item() != NULL);
// SgInitializer *initializerOther = (*i)->get_named_item()->get_initializer();
SgInitializer *initializerOther = (*i)->get_initializer();
// This is not always a valid pointer
// ROSE_ASSERT (initializerOther != NULL);
// printf ("Test for initialized in variable \n");
if (initializerOther != NULL)
{
// There are other things we could ask of the initializer
ROSE_ASSERT (initializerOther != NULL);
// printf ("Found a valid initialized in variable \n");
SgConstructorInitializer* constructorInitializer = isSgConstructorInitializer(initializerOther);
ROSE_ASSERT (constructorInitializer != NULL);
SgExprListExp* argumentList = constructorInitializer->get_args();
ROSE_ASSERT (argumentList != NULL);
SgExpressionPtrList & expressionPtrList = argumentList->get_expressions();
ROSE_ASSERT(expressionPtrList.empty() == false);
SgExpressionPtrList::iterator i = expressionPtrList.begin();
ROSE_ASSERT (*i != NULL);
// First value is a char* identifying the option
SgStringVal* charString = isSgStringVal(*i);
ROSE_ASSERT (charString != NULL);
#if 1
string optionString;
string valueString;
int counter = 0;
while (i != expressionPtrList.end())
{
// printf ("Expression List Element #%d of %d (total) (*i)->sage_class_name() = %s \n",
// counter,expressionPtrList.size(),(*i)->sage_class_name());
switch ( (*i)->variant() )
{
case ENUM_VAL:
{
SgEnumVal* enumVal = isSgEnumVal(*i);
ROSE_ASSERT (enumVal != NULL);
// int enumValue = enumVal->get_value();
SgName enumName = enumVal->get_name();
// printf ("Name = %s value = %d \n",enumName.str(),enumValue);
// printf ("Name = %s \n",enumName.str());
string name = enumName.str();
// char* name = rose::stringDuplicate( enumName.str() );
// Put the value at the start of the list so that the list can be processed in
// consecutive order to establish options for consecutive scopes (root to
// child scope). Order is not important if we are only ORing the operands!
// returnEnumValueList.push_front (name);
// returnEnumValueList.push_front (enumValue);
ROSE_ASSERT (counter == 0);
break;
}
case STRING_VAL:
{
// ROSE_ASSERT (counter == 1);
// printf ("Found a SgStringVal expression! \n");
SgStringVal* stringVal = isSgStringVal(*i);
ROSE_ASSERT (stringVal != NULL);
if (counter == 0)
{
optionString = stringVal->get_value();
valueString = "";
// printf ("optionString = %s \n",optionString);
//.........这里部分代码省略.........
示例13: strlen
//-----------------------------------------------------------------------------------
// int UnparseOrigFormat::get_type_len
//
// Auxiliary function used by special_cases to determine the length of
// the given type. This length is then subtracted from the amount to indent.
//-----------------------------------------------------------------------------------
int
UnparseOrigFormat::get_type_len(SgType* type)
{
assert(type != NULL);
switch(type->variant())
{
case T_UNKNOWN: return 0;
case T_CHAR: return 4;
case T_SIGNED_CHAR: return 11;
case T_UNSIGNED_CHAR: return 13;
case T_SHORT: return 5;
case T_SIGNED_SHORT: return 12;
case T_UNSIGNED_SHORT: return 14;
case T_INT: return 3;
case T_SIGNED_INT: return 10;
case T_UNSIGNED_INT: return 12;
case T_LONG: return 4;
case T_SIGNED_LONG: return 11;
case T_UNSIGNED_LONG: return 13;
case T_VOID: return 4;
case T_GLOBAL_VOID: return 11;
case T_WCHAR: return 5;
case T_FLOAT: return 5;
case T_DOUBLE: return 6;
case T_LONG_LONG: return 9;
case T_UNSIGNED_LONG_LONG: return 18;
case T_LONG_DOUBLE: return 11;
case T_STRING: return 6;
case T_BOOL: return 4;
case T_COMPLEX: return 7;
case T_DEFAULT:
{
// (*os) << "T_DEFAULT not implemented" << endl;
// printf ("In Unparser::get_type_len(): T_DEFAULT not implemented (returning 0) \n");
// ROSE_ABORT();
return 0;
break;
}
case T_POINTER:
{
SgPointerType* ptr_type = isSgPointerType(type);
assert(ptr_type != NULL);
return 1 + get_type_len(ptr_type->get_base_type());
}
case T_MEMBER_POINTER:
{
// (*os) << "T_MEMBER_POINTER not implemented" << endl;
cerr << "In Unparser::get_type_len(): T_MEMBER_POINTER not implemented (returning 0)" << endl;
// ROSE_ABORT();
return 0;
break;
}
case T_REFERENCE: { // not sure
SgReferenceType* ref_type = isSgReferenceType(type);
assert(ref_type != NULL);
return 1 + get_type_len(ref_type->get_base_type());
}
case T_NAME: {
cerr << "T_NAME not implemented" << endl;
break;
}
case T_CLASS: {
int length = 0;
SgClassType* class_type = isSgClassType(type);
assert (class_type != NULL);
SgName qn = class_type->get_name();
// We can't force all SgName objects to have a valid string!
// assert (qn.str() != NULL);
if (qn.str() != NULL)
length += strlen(qn.str());
return length;
}
case T_ENUM: {
SgEnumType* enum_type = isSgEnumType(type);
assert (enum_type != NULL);
SgName qn = enum_type->get_name();
return strlen(qn.str());
}
case T_TYPEDEF: {
SgTypedefType* typedef_type = isSgTypedefType(type);
SgName nm = typedef_type->get_name();
return strlen(nm.str());
//.........这里部分代码省略.........
示例14: doFiniteDifferencingOne
// Do finite differencing on one expression within one context. The expression
// must be defined and valid within the entire body of root. The rewrite rules
// are used to simplify expressions. When a variable var is updated from
// old_value to new_value, an expression of the form (var, (old_value,
// new_value)) is created and rewritten. The rewrite rules may either produce
// an arbitrary expression (which will be used as-is) or one of the form (var,
// (something, value)) (which will be changed to (var = value)).
void doFiniteDifferencingOne(SgExpression* e,
SgBasicBlock* root,
RewriteRule* rules)
{
SgStatementPtrList& root_stmts = root->get_statements();
SgStatementPtrList::iterator i;
for (i = root_stmts.begin(); i != root_stmts.end(); ++i)
{
if (expressionComputedIn(e, *i))
break;
}
if (i == root_stmts.end())
return; // Expression is not used within root, so quit
vector<SgVariableSymbol*> used_symbols = SageInterface::getSymbolsUsedInExpression(e);
SgName cachename = "cache_fd__"; cachename << ++SageInterface::gensym_counter;
SgVariableDeclaration* cachedecl = new SgVariableDeclaration(SgNULL_FILE, cachename, e->get_type(),0 /* new SgAssignInitializer(SgNULL_FILE, e) */);
SgInitializedName* cachevar = cachedecl->get_variables().back();
ROSE_ASSERT (cachevar);
root->get_statements().insert(i, cachedecl);
cachedecl->set_parent(root);
cachedecl->set_definingDeclaration(cachedecl);
cachevar->set_scope(root);
SgVariableSymbol* sym = new SgVariableSymbol(cachevar);
root->insert_symbol(cachename, sym);
SgVarRefExp* vr = new SgVarRefExp(SgNULL_FILE, sym);
vr->set_endOfConstruct(SgNULL_FILE);
replaceCopiesOfExpression(e, vr, root);
vector<SgExpression*> modifications_to_used_symbols;
FdFindModifyingStatementsVisitor(used_symbols, modifications_to_used_symbols).go(root);
cachedecl->addToAttachedPreprocessingInfo(
new PreprocessingInfo(PreprocessingInfo::CplusplusStyleComment,(string("// Finite differencing: ") +
cachename.str() + " is a cache of " +
e->unparseToString()).c_str(),"Compiler-Generated in Finite Differencing",0, 0, 0, PreprocessingInfo::before));
if (modifications_to_used_symbols.size() == 0)
{
SgInitializer* cacheinit = new SgAssignInitializer(SgNULL_FILE, e);
e->set_parent(cacheinit);
cachevar->set_initializer(cacheinit);
cacheinit->set_parent(cachevar);
}
else
{
for (unsigned int i = 0; i < modifications_to_used_symbols.size(); ++i)
{
SgExpression* modstmt = modifications_to_used_symbols[i];
#ifdef FD_DEBUG
cout << "Updating cache after " << modstmt->unparseToString() << endl;
#endif
SgExpression* updateCache = 0;
SgVarRefExp* varref = new SgVarRefExp(SgNULL_FILE, sym);
varref->set_endOfConstruct(SgNULL_FILE);
SgTreeCopy tc;
SgExpression* eCopy = isSgExpression(e->copy(tc));
switch (modstmt->variantT())
{
case V_SgAssignOp:
{
SgAssignOp* assignment = isSgAssignOp(modstmt);
assert (assignment);
SgExpression* lhs = assignment->get_lhs_operand();
SgExpression* rhs = assignment->get_rhs_operand();
replaceCopiesOfExpression(lhs, rhs, eCopy);
}
break;
case V_SgPlusAssignOp:
case V_SgMinusAssignOp:
case V_SgAndAssignOp:
case V_SgIorAssignOp:
case V_SgMultAssignOp:
case V_SgDivAssignOp:
case V_SgModAssignOp:
case V_SgXorAssignOp:
case V_SgLshiftAssignOp:
case V_SgRshiftAssignOp:
{
SgBinaryOp* assignment = isSgBinaryOp(modstmt);
assert (assignment);
SgExpression* lhs = assignment->get_lhs_operand();
SgExpression* rhs = assignment->get_rhs_operand();
SgTreeCopy tc;
SgExpression* rhsCopy = isSgExpression(rhs->copy(tc));
SgExpression* newval = 0;
switch (modstmt->variantT())
{
#define DO_OP(op, nonassignment) \
case V_##op: { \
newval = new nonassignment(SgNULL_FILE, lhs, rhsCopy); \
newval->set_endOfConstruct(SgNULL_FILE); \
} \
//.........这里部分代码省略.........
示例15: types
//-----------------------------------------------------------------------------
// Functions required by the tree traversal mechanism
ClasshierarchyInhAttr
ClasshierarchyTraversal::evaluateInheritedAttribute (
SgNode* astNode,
ClasshierarchyInhAttr inheritedAttribute )
{
GlobalDatabaseConnection *gdb; // db connection
//long funcId; // id of a function declaration
Classhierarchy *classhier = getClasshierarchy();
gdb = getDB();
switch(astNode->variantT())
{
case V_SgMemberFunctionDeclaration: {
SgMemberFunctionDeclaration *funcDec = isSgMemberFunctionDeclaration( astNode );
//funcDec = funcDef->get_declaration();
//if(isSgMemberFunctionDeclaration(funcDec)) {
// add to class hierarchy if member function definition
//if(isSgMemberFunctionDeclaration()) {
//cerr << " adding CHvinf for MembFunc " << endl;
SgClassDefinition *classDef = isSgClassDefinition( funcDec->get_scope() );
//assert(classDef);
if(classDef) {
string classname = classDef->get_qualified_name().str();
// get the classhier. vertex
Classhierarchy::dbgVertex chVert = 0; //?? init necessary
bool foundClass = false;
Classhierarchy::dbgVertexIterator chvi,chvend;
boost::tie(chvi,chvend) = boost::vertices( *getClasshierarchy() );
for(; chvi!=chvend; chvi++) {
if( boost::get( vertex_dbg_data, *getClasshierarchy() , *chvi).get_typeName() == classname ) {
chVert = *chvi;
foundClass = true;
}
}
if(foundClass) {
property_map< Classhierarchy::dbgType, boost::vertex_classhierarchy_t>::type chMap = boost::get( boost::vertex_classhierarchy, *getClasshierarchy() );
chMap[ chVert ].defined.insert( funcDec );
//get type?
//cerr << " added! "; // debug
}
}
//}
cerr << " found V_SgMemberFunctionDeclaration done for " <<funcDec->get_mangled_name().str()<< " " << endl; // debug
} break;
case V_SgClassDefinition: {
cerr << " found V_SgClassDef of "; // debug
SgClassDefinition *classDef = isSgClassDefinition( astNode );
assert( classDef );
SgName classname = classDef->get_qualified_name();
// make db entry
long typeId = UNKNOWNID;
typesTableAccess types( gdb );
typesRowdata newtype( typeId, getProjectId(), classname.str() );
typeId = types.retrieveCreateByColumn( &newtype, "typeName", newtype.get_typeName(), newtype.get_projectId() );
cerr << classname.str()<< ", id:" << newtype.get_id() << endl; // debug
//classhier->addNode( newtype, newtype.get_typeName() );
//classhier->insertWithName( newtype, newtype.get_typeName() );
classhier->insertVertex( newtype, newtype.get_typeName() );
SgBaseClassList inherits = classDef->get_inheritances();
for( SgBaseClassList::iterator i=inherits.begin(); i!=inherits.end(); i++) {
SgClassDeclaration *parentDecl = (*i).get_base_class();
cerr << " found inheritance from " ; // debug
assert( parentDecl );
// add new edge
typesRowdata partype( UNKNOWNID, getProjectId(), parentDecl->get_name().str() ); // MANGLE
long parentId = types.retrieveCreateByColumn( &partype, "typeName", partype.get_typeName(), partype.get_projectId() );
cerr << parentDecl->get_name().str() << ", id: " << parentId << endl;
// add to class hierarchy graph, allow only one edge per inheritance
//A classhier->addNode( partype, partype.get_typeName() );
//A classhier->addEdge( newtype, partype, false );
classhier->insertEdge( newtype, partype );
}
} break;
} // switch node type
// Note that we have to use a particular constructor (to pass on context information about source code position).
// This allows the Rewrite mechanism to position new source code relative to the current position using a simple interface.
ClasshierarchyInhAttr returnAttribute(inheritedAttribute,astNode);
// FIXME why not return inheritedAttribute???
return returnAttribute;
}