Exemple #1
0
map<string, set<string> > CompilerOutputParser::collectIncludedFilesMap() {

    SgFilePtrList inputFileList = projectNode -> get_fileList();

    for (SgFilePtrList::const_iterator it = inputFileList.begin(); it != inputFileList.end(); it++) {
        processFile(*it, false);
    }
    return includedFilesMap;
}
void IncludedFilesUnparser::initializeFilesToUnparse() {
    //All modified files have to be unparsed.
    filesToUnparse = modifiedFiles;
    
    //All input files are also unparsed by default.
    SgFilePtrList inputFilesList = projectNode -> get_fileList();
    for (SgFilePtrList::const_iterator inputFilePtr = inputFilesList.begin(); inputFilePtr != inputFilesList.end(); inputFilePtr++) {
        filesToUnparse.insert(FileHelper::normalizePath((*inputFilePtr) -> getFileName())); //normalize just in case it is not normalized by default as expected
    }
}
Exemple #3
0
	/* 
	 * 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 */	
Exemple #4
0
/*
 *  The function
 *      findScope()
 *  takes as a parameter a SgNode* which is a SgStatement*. It returns a SgNodePtrVector of all
 *  preceding scopes the SgStatement is in.
 *
 */
SgNodePtrVector
findScopes (SgNode * astNode)
{
  ROSE_ASSERT (isSgStatement (astNode));

  SgNodePtrVector returnVector;
  SgScopeStatement *currentScope;

  if (isSgScopeStatement (astNode))
    {
      currentScope = isSgScopeStatement (astNode);
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (astNode);
    }
  else
    {
      SgStatement *sageStatement = isSgStatement (astNode);
      ROSE_ASSERT (sageStatement != NULL);
      currentScope = sageStatement->get_scope ();
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (currentScope);
    }

  while (currentScope->variantT () != V_SgGlobal)
    {
      currentScope = currentScope->get_scope ();
      ROSE_ASSERT (currentScope != NULL);
      returnVector.push_back (currentScope);
    }

  //Must also include the Global Scopes of the other files in the project
  if (currentScope->variantT () == V_SgGlobal)
    {
      SgFile *sageFile = isSgFile ((currentScope)->get_parent ());
      ROSE_ASSERT (sageFile != NULL);
      SgProject *sageProject = isSgProject (sageFile->get_parent ());
      ROSE_ASSERT (sageProject != NULL);

      //Get a list of all files in the current project
      const SgFilePtrList sageFilePtrList = sageProject->get_fileList ();

      //Iterate over the list of files to find all Global Scopes
      SgNodePtrVector globalScopes;
      for (unsigned int i = 0; i < sageFilePtrList.size (); i += 1)
	{
	  const SgFile *sageFile = isSgFile (sageFilePtrList[i]);
	  ROSE_ASSERT (sageFile != NULL);

          if( isSgSourceFile(sageFile) != NULL )
          {
	  SgGlobal *sageGlobal = isSgSourceFile(sageFile)->get_globalScope ();
	  ROSE_ASSERT (sageGlobal != NULL);

	  returnVector.push_back (sageGlobal);
          }
	}
    }


  return returnVector;
};