/* * The function * queryNodeAnonymousTypedefClassDeclaration() * is a NodeQuery which finds all Anonymous Typedefs is the scope. */ NodeQuerySynthesizedAttributeType NodeQuery::queryNodeAnonymousTypedefClassDeclaration(SgNode* node) { NodeQuerySynthesizedAttributeType returnList; ROSE_ASSERT( node != NULL ); SgTypedefDeclaration* sageTypedefDeclaration = isSgTypedefDeclaration(node); if (sageTypedefDeclaration != NULL) if(isSgClassType(sageTypedefDeclaration->get_base_type())) { SgClassType* sageClassType = isSgClassType(sageTypedefDeclaration->get_base_type()); SgClassDeclaration* sageClassDeclaration = isSgClassDeclaration(sageClassType->get_declaration()); ROSE_ASSERT(sageClassDeclaration != NULL); returnList.push_back(sageClassDeclaration); } return returnList; } /* End function:queryNodeCLassDeclarationFromName() */
/* * The function: * buildTypedefTranslationTable() * takes as a parameter a SgProject*. It will return a map<SgTypedefDeclaration*, SgType*> * where the idea is that all SgTypedefDeclaration* are unique, and therefore it is * possible to create a map with it's corresponding type for easy access. */ map< SgTypedefDeclaration*, SgType*> typeInterpreter::buildTypedefTranslationTable(SgProject* project){ ROSE_ASSERT (project != NULL); const SgFilePtrList& sageFilePtrList = project->get_fileList (); //Iterate over all global scopes in the all the files the project spans. for (unsigned int i = 0; i < sageFilePtrList.size (); i += 1) { const SgSourceFile *sageFile = isSgSourceFile (sageFilePtrList[i]); ROSE_ASSERT (sageFile != NULL); SgGlobal *sageGlobal = sageFile->get_globalScope(); ROSE_ASSERT (sageGlobal != NULL); SgTypedefDeclaration* typedefDeclaration; //Find all TypedefdefDeclarations in current global scope. Rose_STL_Container< SgNode * > typedefDeclarationList = NodeQuery::querySubTree (sageGlobal, NodeQuery::TypedefDeclarations); // DQ (9/26/2007): Moved from std::list to std::vector uniformly within ROSE. printf ("Commented out unique() member function since it is not in std::vector class \n"); // typedefDeclarationList.unique(); //Iterate over all SgTypedefDeclarations in current global scope, //and find corresponding SgType*. for (Rose_STL_Container< SgNode * >::iterator typedefDeclarationElm = typedefDeclarationList.begin (); typedefDeclarationElm != typedefDeclarationList.end (); ++typedefDeclarationElm) { typedefDeclaration = isSgTypedefDeclaration (*typedefDeclarationElm); ROSE_ASSERT (typedefDeclaration != NULL); //We only register a typedef once ROSE_ASSERT (typedefTranslationTable.find (typedefDeclaration) == typedefTranslationTable.end ()); SgType* typedefBaseType = typedefDeclaration->get_base_type(); ROSE_ASSERT(typedefBaseType != NULL ); SgType* baseType = typedefBaseType->findBaseType(); //If the SgTypedefDeclarations has a base type which is of SgTypedefType, find a //SgType* which is not of type SgTypedefType. That is the corresponging SgType*. while(isSgTypedefType(baseType) != NULL) baseType = isSgTypedefType(baseType)->get_base_type(); /* cout << "The name of the typedef is:" << typedefDeclaration->get_name().str() ; string baseName = TransformationSupport::getTypeName(baseType); cout << " The correpsonding basetype is:" << baseName << endl; if(isSgClassType(baseType) == NULL) cout << "It is NOT a CLASS TYPE." << endl; */ ROSE_ASSERT( baseType != NULL ); typedefTranslationTable[typedefDeclaration] = baseType; } } return typedefTranslationTable; } /* End method: buildTypedefTranslationTable */