コード例 #1
0
void
SgTypedefDeclaration::fixupCopy_symbols(SgNode* copy, SgCopyHelp & help) const
   {
#if DEBUG_FIXUP_COPY
     printf ("Inside of SgTypedefDeclaration::fixupCopy_symbols() for typedef name = %s = %p = %s copy = %p \n",this->get_name().str(),this,this->class_name().c_str(),copy);
#endif

     printf ("Inside of SgTypedefDeclaration::fixupCopy_symbols() for typedef name = %s = %p = %s copy = %p \n",this->get_name().str(),this,this->class_name().c_str(),copy);

  // Call the base class fixupCopy member function
     SgDeclarationStatement::fixupCopy_symbols(copy,help);

  // DQ (10/14/2007): Handle the case of a type defined in the base type of the typedef (similar problem for SgVariableDeclaration).
     if (this->get_typedefBaseTypeContainsDefiningDeclaration() == true)
        {
          SgTypedefDeclaration* typedefDeclaration_copy = isSgTypedefDeclaration(copy);
          ROSE_ASSERT(typedefDeclaration_copy != NULL);

          ROSE_ASSERT(typedefDeclaration_copy->get_typedefBaseTypeContainsDefiningDeclaration() == true);
          SgDeclarationStatement* baseTypeDeclaration_original = this->get_baseTypeDefiningDeclaration();
          SgDeclarationStatement* baseTypeDeclaration_copy     = typedefDeclaration_copy->get_baseTypeDefiningDeclaration();
          ROSE_ASSERT(baseTypeDeclaration_original != NULL);
          ROSE_ASSERT(baseTypeDeclaration_copy != NULL);

          printf ("In SgTypedefDeclaration::fixupCopy_symbols(): calling baseTypeDeclaration_original->fixupCopy_symbols(baseTypeDeclaration_copy = %p) \n",baseTypeDeclaration_copy);

          baseTypeDeclaration_original->fixupCopy_symbols(baseTypeDeclaration_copy,help);

          printf ("DONE: In SgTypedefDeclaration::fixupCopy_symbols(): calling baseTypeDeclaration_original->fixupCopy_symbols(baseTypeDeclaration_copy = %p) \n",baseTypeDeclaration_copy);
        }

     printf ("Leaving SgTypedefDeclaration::fixupCopy_symbols() for typedef name = %s = %p = %s copy = %p \n",this->get_name().str(),this,this->class_name().c_str(),copy);
   }
コード例 #2
0
ファイル: helpFunctions.C プロジェクト: 8l/rose
/*
 * The function
 *    findTypedefFromTypeName()
 * takes as a first parameter a vector<SgNode*> where SgNode*
 * is SgScopeStatement*, and as a second parameter it akes
 * a typename. It returns a unique instance of a typedef
 * corresponding to the typename in the scope. If it has
 * not found a corresponding typename it returns 0
* 
 *
 */
SgTypedefDeclaration *
findTypedefFromTypeName (SgNodePtrVector nodeVector, const string sageName)
{
  typedef SgNodePtrVector::iterator nodeIterator;
  vector < SgNode * >tempNodeList, typedefDeclarationList,
    foundClassDeclarations;
  ROSE_ASSERT (sageName.length () > 0);

  for (nodeIterator i = nodeVector.begin (); i != nodeVector.end (); ++i)
    {
      ROSE_ASSERT (isSgScopeStatement (*i) != NULL);

      typedefDeclarationList =
	NodeQuery::querySubTree (*i,
				 NodeQuery::TypedefDeclarations,
				 NodeQuery::ChildrenOnly);

      vector < SgNode * >::iterator j;

      for (j = typedefDeclarationList.begin ();
	   j != typedefDeclarationList.end (); ++j)
	{
	  // Take an action on each typedef declarations: generate a list of variable declarations
	  ROSE_ASSERT ((*j) != NULL);

	  // list<SgNode*> variableDeclarationList = NodeQuery::getTypeDefDeclarations(astNode,NodeQuery::ChildrenOnly);

	  SgTypedefDeclaration *typedefDeclaration =
	    isSgTypedefDeclaration (*j);
	  ROSE_ASSERT (typedefDeclaration != NULL);

	  string typeName = typedefDeclaration->get_name ().str ();

	  if (typeName == sageName)
	    return typedefDeclaration;
	}
    }

  return NULL;
}
コード例 #3
0
ファイル: helpFunctions.C プロジェクト: 8l/rose
	/* 
	 * 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 SgFile *sageFile = isSgFile (sageFilePtrList[i]);
		    ROSE_ASSERT (sageFile != NULL);
                    if(isSgSourceFile(sageFile) == NULL )
                       continue;
		    SgGlobal *sageGlobal = isSgSourceFile(sageFile)->get_globalScope ();
		    ROSE_ASSERT (sageGlobal != NULL);

		    SgTypedefDeclaration* typedefDeclaration;
		    
		    //Find all TypedefdefDeclarations in current global scope.
		   vector < SgNode * > typedefDeclarationList =
		      NodeQuery::querySubTree (sageGlobal,
					       NodeQuery::TypedefDeclarations);

		   unique(typedefDeclarationList.begin(),typedefDeclarationList.end());

		   //Iterate over all SgTypedefDeclarations in current global scope,
		   //and find corresponding SgType*.
		   for (vector < 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 */