本文整理汇总了C++中Sg_File_Info::get_file_id方法的典型用法代码示例。如果您正苦于以下问题:C++ Sg_File_Info::get_file_id方法的具体用法?C++ Sg_File_Info::get_file_id怎么用?C++ Sg_File_Info::get_file_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sg_File_Info
的用法示例。
在下文中一共展示了Sg_File_Info::get_file_id方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
FindSmallestStatementsInh
FindSmallestStatements::evaluateInheritedAttribute(SgNode* n, FindSmallestStatementsInh inheritedAttribute)
{
//If the node should be consired as a topmost node
if(inheritedAttribute.inSubtreeOfStatement == false && isSgLocatedNode(n))
{
Sg_File_Info* thisNodePos = n->get_file_info();
#if 0
std::string pos;
thisNodePos->display(pos);
std::cerr << "************************\n";
std::cerr << "NodePosDisp " << n->class_name() << pos << std::endl;
std::cerr << "************************\n";
#endif
//If positions are the same add to list of statements
switch(n->variantT())
{
case V_SgExprStatement:
std::cout << "Skipping this node" << std::endl;
break;
default:
{
if( macroCallInfo->get_file_id() == thisNodePos->get_file_id() &&
macroCallInfo->get_line() == thisNodePos->get_line() &&
macroCallInfo->get_col() == thisNodePos->get_col()
)
{
if( find_all == false )
inheritedAttribute.inSubtreeOfStatement = true;
matchingCalls.push_back(n);
}
break;
}
}
}
return inheritedAttribute;
}
示例2: preOrderVisit
void PreAndPostOrderTraversal::preOrderVisit(SgNode* n) {
SgFunctionDeclaration * dec = isSgFunctionDeclaration(n);
if (dec != NULL) {
cout << "Found function declaration " << dec->get_name().getString();
Sg_File_Info * start = dec->get_startOfConstruct();
Sg_File_Info * end = dec->get_endOfConstruct();
if(start->isCompilerGenerated()) {
cout << ", which is compiler-generated" << endl;
} else {
cout << " in file " << start->get_raw_filename() << ", " << start->get_file_id() << " from line " <<
start->get_line() << ", col " << start->get_col() << " to line " <<
end->get_line() << ", col " << end->get_col() << endl;
}
SgFunctionType * type = dec->get_type();
SgType * retType = type->get_return_type();
cout << "Return type: " << retType->unparseToString() << endl;
SgFunctionParameterList * params = dec->get_parameterList();
SgInitializedNamePtrList & ptrList = params->get_args();
if(!ptrList.empty()) {
cout << "Parameter types: ";
for(SgInitializedNamePtrList::iterator j = ptrList.begin(); j != ptrList.end(); j++) {
SgType * pType = (*j)->get_type();
cout << pType->unparseToString() << " ";
}
cout << endl;
}
cout << "Linkage: " << dec->get_linkage() << endl;
cout << endl;
}
SgFunctionDefinition * def = isSgFunctionDefinition(n);
if (def != NULL) {
cout << "Found function definition " << def->get_declaration()->get_name().getString();
Sg_File_Info * start = def->get_startOfConstruct();
Sg_File_Info * end = def->get_endOfConstruct();
if(start->isCompilerGenerated()) {
cout << ", which is compiler-generated" << endl;
} else {
cout << " in file " << start->get_raw_filename() << " from line " << start->get_line() << ", col " << start->get_col() << " to line " << end->get_line() << ", col " << end->get_col() << endl;
SgBasicBlock * body = def->get_body();
Sg_File_Info * bodyStart = body->get_startOfConstruct();
Sg_File_Info * bodyEnd = body->get_endOfConstruct();
cout << "Function body from line " << bodyStart->get_line() << ", col " << bodyStart->get_col() << " to line " << bodyEnd->get_line() << ", col " << bodyEnd->get_col() << endl;
}
cout << endl;
}
}
示例3: setProject
void RoseFileComboBox::setProject(SgProject * proj)
{
clear(); //delete all combobox entries
project=proj;
if(project==NULL)
return;
//Add Entries to the combobox
for(int i=0; i < project->numberOfFiles(); i++)
{
Sg_File_Info * fi = (*project)[i]->get_file_info();
QFileInfo qFi;
QVariant fileId (fi->get_file_id());
qFi.setFile(fi->get_filenameString().c_str());
if(dispOnlyFilename)
addItem(qFi.fileName(),-1);
else
addItem(qFi.filePath(),-1);
std::map< int, std::string > map = fi->get_fileidtoname_map();
typedef std::map<int,std::string>::iterator MapIter;
for( MapIter iter = map.begin(); iter != map.end(); ++iter )
{
qFi.setFile( iter->second.c_str());
QString dispString;
if(dispOnlyFilename)
dispString=qFi.fileName();
else
dispString=qFi.filePath();
addItem(QString(" ")+dispString,iter->first);
}
}
}
示例4: InheritedAttribute
InheritedAttribute
visitorTraversal::evaluateInheritedAttribute(SgNode* n, InheritedAttribute inheritedAttribute)
{
Sg_File_Info* s = n->get_startOfConstruct();
Sg_File_Info* e = n->get_endOfConstruct();
Sg_File_Info* f = n->get_file_info();
for(int x=0; x < inheritedAttribute.depth; ++x) {
printf(" ");
}
if(s != NULL && e != NULL && !isSgLabelStatement(n)) {
printf ("%s (%d, %d, %d)->(%d, %d): %s",n->sage_class_name(),s->get_file_id()+1,s->get_raw_line(),s->get_raw_col(),e->get_raw_line(),e->get_raw_col(), verbose ? n->unparseToString().c_str() : "" );
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
SgExprStatement * exprStmt = isSgExprStatement(n);
if(exprStmt != NULL) {
printf(" [expr type: %s]", exprStmt->get_expression()->sage_class_name());
SgFunctionCallExp * fcall = isSgFunctionCallExp(exprStmt->get_expression());
if(fcall != NULL) {
SgExpression * funcExpr = fcall->get_function();
if(funcExpr != NULL) {
printf(" [function expr: %s]", funcExpr->class_name().c_str());
}
SgFunctionDeclaration * fdecl = fcall->getAssociatedFunctionDeclaration();
if(fdecl != NULL) {
printf(" [called function: %s]", fdecl->get_name().str());
}
}
}
if(isSgFunctionDeclaration(n)) {
printf(" [declares function: %s]", isSgFunctionDeclaration(n)->get_name().str());
}
SgStatement * sgStmt = isSgStatement(n);
if(sgStmt != NULL) {
printf(" [scope: %s, %p]", sgStmt->get_scope()->sage_class_name(), sgStmt->get_scope());
}
//SgLabelStatement * lblStmt = isSgLabelStatement(n);
//if(lblStmt != NULL) {
// SgStatement * lblStmt2 = lblStmt->get_statement();
//}
} else if (f != NULL) {
SgInitializedName * iname = isSgInitializedName(n);
if(iname != NULL) {
SgType* inameType = iname->get_type();
printf("%s (%d, %d, %d): %s [type: %s", n->sage_class_name(),f->get_file_id()+1,f->get_raw_line(),f->get_raw_col(),n->unparseToString().c_str(),inameType->class_name().c_str());
SgDeclarationStatement * ds = isSgDeclarationStatement(iname->get_parent());
if(ds != NULL) {
if(ds->get_declarationModifier().get_storageModifier().isStatic()) {
printf(" static");
}
}
SgArrayType * art = isSgArrayType(iname->get_type());
if(art != NULL) {
printf(" %d", art->get_rank());
}
printf("]");
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
} else {
printf("%s (%d, %d, %d): %s", n->sage_class_name(),f->get_file_id()+1,f->get_raw_line(),f->get_raw_col(), verbose ? n->unparseToString().c_str() : "");
}
} else {
printf("%s : %s", n->sage_class_name(), verbose ? n->unparseToString().c_str() : "");
if(isSgAsmDwarfConstruct(n)) {
printf(" [DWARF construct name: %s]", isSgAsmDwarfConstruct(n)->get_name().c_str());
}
}
printf(" succ# %lu", n->get_numberOfTraversalSuccessors());
printf("\n");
return InheritedAttribute(inheritedAttribute.depth+1);
}
示例5: mergeFunctionTypeSymbolTables
void
mergeStaticASTFileInformation(vector<AstFileSpecificInfo*> & AstFileInfoArray)
{
// Take care of merging the function type table first.
vector<SgFunctionTypeTable*> functionTableArray;
for (size_t i = 0; i < AstFileInfoArray.size(); ++i)
{
functionTableArray.push_back(AstFileInfoArray[i]->functionTable);
}
// Merge the function tables from each AST.
SgFunctionTypeTable* globalFunctionTypeTable = mergeFunctionTypeSymbolTables (functionTableArray);
ROSE_ASSERT(globalFunctionTypeTable != NULL);
map<int,std::string> mergedFileidtoname_map;
map<std::string,int> mergedNametofileid_map;
map<int,int> mergedFileidtoid_map;
// Now merge the file name maps (static information in Sg_File_Info).
// int maxFilenameIndex = 0;
// int minFilenameIndex = 100000000;
for (size_t index = 0; index < AstFileInfoArray.size(); index++)
{
map<int,std::string> & fileidtoname_map = AstFileInfoArray[index]->fileidtoname_map;
// Build a new map of all the possible file names
for (std::map<int,std::string>::iterator i = fileidtoname_map.begin(); i != fileidtoname_map.end(); i++)
{
// printf ("id = %d name = %s \n",i->first,i->second.c_str());
if (mergedNametofileid_map.count(i->second) == 0)
{
int returnValue = (int)mergedNametofileid_map.size();
#if 0
printf ("Adding new name to merged maps id = %d name = %s will use new id = %d \n",i->first,i->second.c_str(),returnValue);
#endif
mergedNametofileid_map[i->second] = returnValue;
mergedFileidtoname_map[returnValue] = i->second;
// We still need the mapping of old ids to new ids for each AST file.
mergedFileidtoid_map [i->first] = returnValue;
}
}
#if 0
printf ("Resetting memory pool entries (%d,%d) \n",AstFileInfoArray[index]->baseOfASTFileInfo,AstFileInfoArray[index]->boundOfASTFileInfo);
#endif
// Now iterate over the memory pool of Sg_File _Info objects so that we can reset the file ids.
for (int i = AstFileInfoArray[index]->baseOfASTFileInfo; i < AstFileInfoArray[index]->boundOfASTFileInfo; i++)
{
// Set each id to the new id as specified in mergedFileidtoid_map
// printf ("Accessing the %d = %lu entry of the Sg_File_Info memory pool. \n",i,(unsigned long) i);
// printf ("Memory pool size = %lu \n",AST_FILE_IO::getAccumulatedPoolSizeOfNewAst(V_Sg_File_Info));
// Compute the postion of the indexed Sg_File_Info object in the memory pool.
unsigned long localIndex = i;
unsigned long positionInPool = localIndex % Sg_File_Info_CLASS_ALLOCATION_POOL_SIZE ;
unsigned long memoryBlock = (localIndex - positionInPool) / Sg_File_Info_CLASS_ALLOCATION_POOL_SIZE;
Sg_File_Info* fileInfo = &(((Sg_File_Info*)(Sg_File_Info_Memory_Block_List[memoryBlock]))[positionInPool]);
// $CLASSNAME* $CLASSNAME_getPointerFromGlobalIndex ( unsigned long globalIndex )
// Sg_File_Info* fileInfo = Sg_File_Info_getPointerFromGlobalIndex((unsigned long) i + 1);
ROSE_ASSERT(fileInfo != NULL);
int oldFileId = fileInfo->get_file_id();
int newFileId = mergedFileidtoid_map[oldFileId];
// Only reset those file ids that are associated with valid file names.
// Values less than zero indicate file name classifications.
if (oldFileId >= 0 && oldFileId != newFileId)
{
#if 0
printf ("Accessing the %d Exchanging old file id = %d for new file id = %d \n",i,oldFileId,newFileId);
#endif
fileInfo->set_file_id ( newFileId );
}
}
}
// Now reset the static maps to use the new mapping.
Sg_File_Info::get_nametofileid_map() = mergedNametofileid_map;
Sg_File_Info::get_fileidtoname_map() = mergedFileidtoname_map;
// DQ (6/21/2010): Fixup the support for builtin types stored as static data in the SgType derived classes.
// FixupbuiltinTypes(AST_FILE_IO::getAst(i),AST_FILE_IO::getAst(i));
printf ("In mergeStaticASTFileInformation: SgTypeUnsignedInt::p_builtin_type = %p \n",SgTypeUnsignedInt::createType());
// Note that GNU g++ 4.2.x allows us to reference "index" out of scope!
// printf ("maxFilenameIndex = %d minFilenameIndex = %d \n",maxFilenameIndex,minFilenameIndex);
}