本文整理汇总了C++中SgName::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ SgName::getString方法的具体用法?C++ SgName::getString怎么用?C++ SgName::getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SgName
的用法示例。
在下文中一共展示了SgName::getString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: SgName
SgName
mangleTemplate (const SgName& templ_name,
const SgTemplateArgumentPtrList& templ_args,
const SgScopeStatement* scope)
{
string mangled_name = mangleTemplateToString(templ_name.getString(),templ_args,scope);
// printf ("In mangleTemplate(): mangled_name = %s \n",mangled_name.c_str());
return SgName (mangled_name.c_str());
}
示例3: isSgSourceFile
ScopExtractor::ScopExtractor(SgProject* project, PolyRoseOptions& polyopts)
{
// this->project = project;
this->polyoptions = polyopts;
isVerbose = ! polyopts.getQuiet();
if (isVerbose)
std::cout << "[PolyOpt] Using generic scop extractor" << std::endl;
SgFilePtrList& file_list = project->get_fileList();
SgFilePtrList::const_iterator file_iter;
// Iterate on all files of the project.
for (file_iter = file_list.begin(); file_iter != file_list.end(); file_iter++)
{
SgSourceFile* file = isSgSourceFile(*file_iter);
if (polyoptions.getScVerboseLevel())
cout << "[Extr] File: " << file->getFileName() << endl;
SgNodePtrList funcDefnList =
NodeQuery::querySubTree(file, V_SgFunctionDefinition);
SgNodePtrList::const_iterator iter;
// Iterate on all function defined in a file.
for (iter = funcDefnList.begin(); iter != funcDefnList.end(); ++iter)
{
SgFunctionDefinition *fun = isSgFunctionDefinition(*iter);
if (!fun)
{
cout << "[Extr] Warning: Expected SgFunctionDefinition in " <<
file->getFileName() << endl;
continue; // with the next function definition
}
SgName name = fun->get_declaration()->get_name();
if (polyoptions.getScVerboseLevel())
cout << "[Extr] Function: " << name.getString() << endl;
SgBasicBlock* body = fun->get_body();
// Ensure the function is a candidate (no (unsafe) function
// calls).
if (assertFunctionIsCandidate(project, body))
{
// Proceed recursively, bottom up.
inspectBottomUpFunctionBody(project, body);
}
}
}
if (isVerbose)
std::cout << "[ScopExtraction] Generic: done" << std::endl;
}
示例4: DCL01_C
/**
* Do not reuse variable names in subscopes
*/
bool DCL01_C( const SgNode *node ) {
const SgInitializedName *varInitName = isSgInitializedName(node);
if (!varInitName)
return false;
const SgName varName = varInitName->get_name();
const SgScopeStatement *varScope = varInitName->get_scope();
assert(varScope);
while(!isSgGlobal(varScope)) {
varScope = varScope->get_scope();
if(varScope->symbol_exists(varName)) {
print_error(node, "DCL01-C", ("Do not reuse variable names in subscopes: " + varName.getString()).c_str(), true);
return true;
}
}
return false;
}
示例5: isSgFunctionDefinition
/**
* Create scops for a sub-tree.
*
*/
void
ScopExtractor::extractScops(SgNode* root)
{
if (isVerbose)
std::cout << "[PolyOpt] Using generic scop extractor" << std::endl;
SgNodePtrList funcDefnList =
NodeQuery::querySubTree(root, V_SgFunctionDefinition);
SgNodePtrList::const_iterator iter;
// Iterate on all functions defined in a sub-tree.
for (iter = funcDefnList.begin(); iter != funcDefnList.end(); ++iter)
{
SgFunctionDefinition *fun = isSgFunctionDefinition(*iter);
if (!fun)
{
cout << "[Extr] Warning: Expected SgFunctionDefinition" << endl;
continue; // with the next function definition
}
SgName name = fun->get_declaration()->get_name();
if (polyoptions.getScVerboseLevel())
cout << "[Extr] Function: " << name.getString() << endl;
SgBasicBlock* body = fun->get_body();
// Ensure the function is a candidate (no (unsafe) function
// calls).
if (assertFunctionIsCandidate(NULL, body))
{
// Proceed recursively, bottom up.
inspectBottomUpFunctionBody(NULL, body);
}
}
// If no function is defined in the subtree, simply process it
// as-is.
if (funcDefnList.size() == 0)
if (assertFunctionIsCandidate(NULL, root))
// Proceed recursively, bottom up.
inspectBottomUpFunctionBody(NULL, root);
if (isVerbose)
std::cout << "[ScopExtraction] Generic: done" << std::endl;
}
示例6: 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 ( ",");
}
//.........这里部分代码省略.........
示例7: getFunctionName
/*
* returns string of functions name
*/
string MigrationOutliner::getFunctionName(SgFunctionDeclaration *func){
const SgName name = func->get_name();
return name.getString();
}//end getFunctionName
示例8: initializeVariable
std::string initializeVariable(SgInitializedName* initName) {
//if array type we need to get the index expression
std::string index_expression_string;
std::stringstream nameStringStream;
SgName initNameName = initName->get_qualified_name();
SgSymbol* initNameSym = initName->search_for_symbol_from_symbol_table();
if (variablesOfNameX.find(initNameName.getString()) == variablesOfNameX.end()) {
nameStringStream << initNameName.getString() << "_0";
variablesOfNameX[initNameName.getString()] = 1;
}
else {
int occurrence = variablesOfNameX[initNameName.getString()];
nameStringStream << initNameName.getString() << "_" << occurrence;
variablesOfNameX[initNameName.getString()] = occurrence+1;
}
SymbolToZ3[initNameSym] = nameStringStream.str();
SymbolToInstances[initNameSym] = 0;
SgType* initNameType = initName->get_type();
std::string typeZ3;
if (initNameType->isIntegerType()) {
typeZ3 = "Int";
}
else if (initNameType->isFloatType()) {
typeZ3 = "Real";
}
else if (isSgArrayType(initNameType)) {
SgArrayType* arrTyp = isSgArrayType(initNameType);
ROSE_ASSERT(arrTyp != NULL);
SgType* underlying_type = arrTyp->get_base_type();
std::string array_typeZ3;
if (underlying_type->isIntegerType()) {
array_typeZ3 = "Int";
}
else if (underlying_type->isFloatType()) {
array_typeZ3 = "Real";
}
else {
std::cout << "unknown underlying type of array!" << std::endl;
std::cout << underlying_type->class_name() << std::endl;
ROSE_ASSERT(false);
}
SgExpression* ind = arrTyp->get_index();
std::stringstream arrStr;
index_expression_string = getSgExpressionString(ind);
typeZ3 = "(Array Int " + array_typeZ3 + ")";
}
else if (isSgClassType(initNameType)) {
std::cout << "structs are not yet implemented" << std::endl;
ROSE_ASSERT(false);
}
else if (isSgPointerType(initNameType)) {
std::cout << "pointers are not yet implemented" << std::endl;
ROSE_ASSERT(false);
}
else if (isSgEnumType(initNameType)) {
SgEnumType* et = isSgEnumType(initNameType);
SgEnumDeclaration* enum_d = isSgEnumDeclaration(et->getAssociatedDeclaration());
getSgDeclarationStatement(enum_d);
typeZ3 = et->get_name().getString();
}
else {
std::cout << "unknown type: " << initNameType->class_name() << std::endl;
ROSE_ASSERT(false);
}
std::string name = nameStringStream.str() + "_0";
std::stringstream streamZ3;
if (isSgArrayType(initNameType)) {
streamZ3 << "(declare-const " << name << " " << typeZ3 << ")";
streamZ3 << "\n(declare-fun " << name << "_len () Int)";
streamZ3 << "\n(assert (= " << name << "_len " << index_expression_string << "))";
#ifdef ARRAY_TEST
std::cout << "arrStream: " << streamZ3.str() << std::endl;
#endif
}
else if (isSgEnumType(initNameType)) {
streamZ3 << "(declare-const " << name << " " << typeZ3 << ")";
}
else {
streamZ3 << "(declare-fun " << name << " () " << typeZ3 << ")";
}
return streamZ3.str();
}