当前位置: 首页>>代码示例>>C++>>正文


C++ SgProject::numberOfFiles方法代码示例

本文整理汇总了C++中SgProject::numberOfFiles方法的典型用法代码示例。如果您正苦于以下问题:C++ SgProject::numberOfFiles方法的具体用法?C++ SgProject::numberOfFiles怎么用?C++ SgProject::numberOfFiles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SgProject的用法示例。


在下文中一共展示了SgProject::numberOfFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: storeProjectState

void ProjectManager::storeProjectState()
{
    QSettings s;

    s.remove("LoadedProjects");


    s.beginGroup("LoadedProjects");

    s.beginWriteArray("Projects");

    for(int p=0; p<rootNode->childrenCount(); p++)
    {
        ProjectNode * projNode =  dynamic_cast<ProjectNode*>(rootNode->child(p));

        s.setArrayIndex(p);
        s.setValue("Name",projNode->getName());

        SgProject * sgProj =  projNode->getSgProject();

        s.beginWriteArray("files");
        for(int i=0; i < sgProj->numberOfFiles(); i++)
        {
            QString name = (*sgProj)[i]->getFileName().c_str();
            s.setArrayIndex(i);
            s.setValue("name",name);
        }
        s.endArray();
    }

    s.endArray(); //Projects


    s.endGroup();
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:35,代码来源:Project.cpp

示例2: main

int main(int argc, char ** argv) {
  std::vector<std::string> args(argv, argv + argc);

#if defined(TILEK_ACCELERATOR)
#  if defined(TILEK_TARGET_OPENCL)
  args.push_back("-DSKIP_OPENCL_SPECIFIC_DEFINITION");
#  endif
#endif

  SgProject * project = new SgProject(args);
  assert(project->numberOfFiles() == 1);

  SgSourceFile * source_file = isSgSourceFile(project->get_fileList()[0]);
  assert(source_file != NULL);

  std::string filename = source_file->get_sourceFileNameWithoutPath();
  std::string basename = filename.substr(0, filename.find_last_of('.'));

  KLT::DLX::Compiler< ::DLX::TileK::language_t, ::KLT::TileK::Generator> compiler(project, KLT_PATH, TILEK_PATH, basename);

//  MFB::api_t * api = compiler.getDriver().getAPI();
//  dump_api(api);

  compiler.compile(project);

  project->unparse();

  return 0;
}
开发者ID:8l,项目名称:rose,代码行数:29,代码来源:tilek.cpp

示例3: main

int main ( unsigned argc,  char * argv[] )
{
    string sInputFile, sOutputFile;
    ofstream outputFile;

    // for debugging only switch between persistentand "pointer" handles
    // (pointers are faster, persistent are easier to debug
    bool p_h=FALSE; 
    //    p_h = TRUE;

    // read in command line arguments
    // usage: CtoOA inputFile
    if(argc < 2) { usage(argv[0]); return 1; }
    sInputFile  = argv[1];
    //sOutputFile = argv[2];

    // load the Sage project, open the output file, and construct the
    // code generator (which outputs .oa notation to the file)
    SgProject * sageProject = frontend((int)argc, &argv[0]);
    //outputFile.open(sOutputFile.c_str());

    // debug output
    //AstPDFGeneration pdftest;
    //pdftest.generateInputFiles(sageProject);
    //AstDOTGeneration dottest;
    //dottest.generateInputFiles(sageProject);
    
    // Loop over every file.   BW 4/13/06
    int filenum = sageProject->numberOfFiles();
    for (int i = 0; i < filenum; ++i) 
    {

        SgFile &sageFile = sageProject->get_file(i);
        SgGlobal *root = sageFile.get_root();

        // Loop through every function in the file of this project.
        std::vector<SgNode*> nodeArray;
        OA::OA_ptr<SageIRInterface> irInterface; 
        irInterface = new SageIRInterface(sageProject, &nodeArray, p_h);
        OA::OA_ptr<SageIRProcIterator> procIter;
	// Do not process include files, e.g., iostream.h.
	bool excludeInputFiles = true;
        procIter = new SageIRProcIterator(sageProject, irInterface, excludeInputFiles);

        for (; procIter->isValid(); ++(*procIter) ) 
	{
            // output notation for this function
	    outputNotation(procIter->current(), irInterface, std::cout);
	}
    }     

    return 0;
}
开发者ID:BackupTheBerlios,项目名称:useoa-rose-svn,代码行数:53,代码来源:CtoOA.cpp

示例4: sageProject

int
main ( int argc,  char * argv[] )
   {

     if (argc <= 1) {
         PrintUsage(argv[0]);
         return -1;
     }

     SgProject sageProject ( (int)argc,argv);

     SageInterface::changeAllBodiesToBlocks(&sageProject);

    CmdOptions::GetInstance()->SetOptions(argc, argv);

   int filenum = sageProject.numberOfFiles();
   for (int i = 0; i < filenum; ++i) {
      SgSourceFile* sageFile = isSgSourceFile(sageProject.get_fileList()[i]);
      ROSE_ASSERT(sageFile != NULL);

      TestCFGWrap::AnalysisDomain t = UseOA(argc, argv)? TestCFGWrap::OA : TestCFGWrap::ROSE;
      string filename = sageFile->getFileName();

#if 0 // Test harness uses stdout rather than a temporary file
      string txtname = filename.substr(filename.rfind('/')+1) + ".outx"; 
      TestCFGWrap_Text txtop(t,txtname);
#else
      TestCFGWrap_Stdout txtop(t);
#endif
      //string dotname = string(strrchr(sageFile.getFileName(),'/')+1) + ".dot";
      string dotname = filename.substr(filename.rfind('/')+1) + ".dot";
      TestCFGWrap_DOT dotop(t);
     SgGlobal *root = sageFile->get_globalScope();
     SgDeclarationStatementPtrList& declList = root->get_declarations ();
     for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
          SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
          if (func == 0)
             continue;
          SgFunctionDefinition *defn = func->get_definition();
          if (defn == 0)
             continue;
          SgNode* stmts = defn;
          if (GenerateDOT(argc, argv)) {
             dotop(stmts, dotname);
          }
          else {
             txtop(stmts);
          }
     }
   }

  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:53,代码来源:CFGTest.C

示例5: sageProject

int
main ( int argc,  char * argv[] )
   {

     if (argc <= 1) {
         PrintUsage(argv[0]);
         return -1;
     }

     SgProject sageProject ( (int)argc,argv);
     SageInterface::changeAllBodiesToBlocks(&sageProject);
    CmdOptions::GetInstance()->SetOptions(argc, argv);


   int filenum = sageProject.numberOfFiles();
   for (int i = 0; i < filenum; ++i) {
     SgSourceFile* sageFile = isSgSourceFile(sageProject.get_fileList()[i]);
     ROSE_ASSERT(sageFile != NULL);
     SgGlobal *root = sageFile->get_globalScope();
     SgDeclarationStatementPtrList& declList = root->get_declarations ();
     for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
          SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
          if (func == 0)
             continue;
          SgFunctionDefinition *defn = func->get_definition();
          if (defn == 0)
             continue;
          SgBasicBlock *stmts = defn->get_body();  
          AstInterfaceImpl scope(stmts);
          AstInterface fa(&scope);
          StmtVarAliasCollect alias;
          alias(fa, AstNodePtrImpl(defn));
          if (GenerateDOT(argc, argv)) {
             string name = string(strrchr(sageFile->getFileName().c_str(),'/')+1) + ".dot";
             TestDUWrap_DOT op(alias);
             op(fa, defn, name);
          }
          else {
             string name = string(strrchr(sageFile->getFileName().c_str(),'/')+1) + ".outx";
#if 0   // Test harness uses stdout now rather than a temporary file [Robb P. Matzke 2013-02-25]
             TestDUWrap_Text op(alias,name);
#else
             TestDUWrap_Stdout op(alias);
#endif
             op(fa, defn);
          }
     }
   }

  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:51,代码来源:DataFlowTest.C

示例6: sageProject

int
main ( int argc,  char * argv[] )
   {
int a;
     if (argc <= 1) {
         PrintUsage(argv[0]);
         return -1;
     }
	DEBUG_ICFG = 1;
	DEBUG_STMT = 0;

    SgProject sageProject ( argc,argv);
    SageInterface::changeAllBodiesToBlocks(&sageProject);
    CmdOptions::GetInstance()->SetOptions(argc, argv);


  // TestPtrAnal op;
  //
   ptr_Anal_ICFG_Creator op;
   int filenum = sageProject.numberOfFiles();
   for (int i = 0; i < filenum; ++i) {
     SgFile &sageFile = sageProject.get_file(i);
     SgGlobal *root = sageFile.get_root();
     AstInterfaceImpl scope(root);
     AstInterface fa(&scope);
     SgDeclarationStatementPtrList& declList = root->get_declarations ();
     for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
          SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
          if (func == 0)
             continue;
          SgFunctionDefinition *defn = func->get_definition();
          if (defn == 0)
             continue;
          op(fa, defn);
     }
   }
   op.draw("out.jpg");
  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:39,代码来源:PtrAnalTest2.C

示例7: sageProject

int
main ( int argc,  char * argv[] )
   {

     if (argc <= 1) {
         PrintUsage(argv[0]);
         return -1;
     }

    SgProject sageProject ( argc,argv);
    SageInterface::changeAllLoopBodiesToBlocks(&sageProject);
    CmdOptions::GetInstance()->SetOptions(argc, argv);


   TestPtrAnal op;
   int filenum = sageProject.numberOfFiles();
   for (int i = 0; i < filenum; ++i) {

     SgSourceFile* sageFile = isSgSourceFile(sageProject.get_fileList()[i]);
     ROSE_ASSERT(sageFile != NULL);
     SgGlobal *root = sageFile->get_globalScope();

     AstInterfaceImpl scope(root);
     AstInterface fa(&scope);
     SgDeclarationStatementPtrList& declList = root->get_declarations ();
     for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) {
          SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
          if (func == 0)
             continue;
          SgFunctionDefinition *defn = func->get_definition();
          if (defn == 0)
             continue;
          op(fa, defn);
     }
   }
  return 0;
}
开发者ID:faizurahman,项目名称:rose,代码行数:37,代码来源:PtrAnalTest.C

示例8: anal

int
main ( int argc,  char * argv[] )
{
  //init_poet();  // initialize poet

  if (argc <= 1) {
      PrintUsage(argv[0]);
      return -1;
  }

#ifdef USE_OMEGA
  std::stringstream buffer;
  buffer << argv[argc-1] << std::endl;
  DepStats.SetFileName(buffer.str());
#endif

  vector<string> argvList(argv, argv + argc);
  CmdOptions::GetInstance()->SetOptions(argvList);

  ArrayAnnotation* array_annot = ArrayAnnotation::get_inst();
  array_annot->register_annot();

  //OperatorSideEffectAnnotation* funcAnnot=OperatorSideEffectAnnotation::get_inst();
  //funcAnnot->register_annot();
  LoopTransformInterface::set_sideEffectInfo(array_annot);

  ArrayInterface anal(*array_annot);
  LoopTransformInterface::set_arrayInfo(&anal);

  ReadAnnotation::get_inst()->read();
  if (DebugAnnot()) {
   // funcAnnot->Dump();
    array_annot->Dump();
  }

  AssumeNoAlias aliasInfo;
  LoopTransformInterface::set_aliasInfo(&aliasInfo);

  LoopTransformInterface::cmdline_configure(argvList);

  SgProject *sageProject = new SgProject ( argvList);
  FixFileInfo(sageProject);

  // DQ (11/19/2013): Added AST consistency tests.
     AstTests::runAllTests(sageProject);

  int filenum = sageProject->numberOfFiles();
  for (int i = 0; i < filenum; ++i) {

  // DQ (11/19/2013): Added AST consistency tests.
     AstTests::runAllTests(sageProject);

    SgSourceFile* sageFile = isSgSourceFile(sageProject->get_fileList()[i]);
    ROSE_ASSERT(sageFile != NULL);

    std::string fname = sageFile->get_file_info()->get_raw_filename();
    fname=fname.substr(fname.find_last_of('/')+1);

    AutoTuningInterface tuning(fname);

    LoopTransformInterface::set_tuningInterface(&tuning);
    SgGlobal *root = sageFile->get_globalScope();
    ROSE_ASSERT(root != NULL);

    SgDeclarationStatementPtrList declList = root->get_declarations ();

 // DQ (11/19/2013): Added AST consistency tests.
    AstTests::runAllTests(sageProject);

    for (SgDeclarationStatementPtrList::iterator p = declList.begin(); p != declList.end(); ++p) 
    {
      SgFunctionDeclaration *func = isSgFunctionDeclaration(*p);
      if (func == 0) continue;
      SgFunctionDefinition *defn = func->get_definition();
      if (defn == 0) continue;
      SgBasicBlock *stmts = defn->get_body();  
      AstInterfaceImpl scope(stmts);

   // DQ (11/19/2013): Added AST consistency tests.
      AstTests::runAllTests(sageProject);

   // DQ (11/19/2013): Added AST consistency tests.
      AstTests::runAllTests(sageProject);

      LoopTransformInterface::TransformTraverse(scope,AstNodePtrImpl(stmts));

#if 0
   // DQ (11/19/2013): Added AST consistency tests (this fails).
      AstTests::runAllTests(sageProject);
#endif
    }
    tuning.GenOutput();

#if 0
  // DQ (11/19/2013): Added AST consistency tests (this fails).
     AstTests::runAllTests(sageProject);
#endif
  }

//   if (CmdOptions::GetInstance()->HasOption("-fd")) {
//.........这里部分代码省略.........
开发者ID:matzke1,项目名称:rose-develop,代码行数:101,代码来源:LoopProcessor.C

示例9: main

int main( int argc, char * argv[] ) 
   {

     std::vector<std::string> newArgv(argv,argv+argc);
     newArgv.push_back("-rose:wave");

     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include/g++_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include/gcc_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include-staging/g++_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include-staging/gcc_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/usr/include/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/tests/CompileTest/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<builtin>");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<built-in>");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<builltin>");


  // Build the AST used by ROSE
     SgProject* project = frontend(newArgv);
     ROSE_ASSERT(project != NULL);


  // Run internal consistency tests on AST
     AstTests::runAllTests(project);


     // Assume that there is only one file
     std::string filename;
     for(int i = 0 ; i < project->numberOfFiles(); i++)
     {
       SgSourceFile* file = isSgSourceFile(&project->get_file(i));
       if( file != NULL)
         filename = file->getFileName();

     };

     ROSE_ASSERT(filename != "");

     filename+=".out";
     filename = StringUtility::stripPathFromFileName(filename);


     //Output the macro diretives to the file
     ofstream myfile;
     myfile.open (filename.c_str());

     ROSE_ASSERT(myfile.is_open());
     std::cout << "Outputing to the file " << filename << std::endl;



     backend(project);
     print_out_all_macros(myfile, project);
  // Insert your own manipulation of the AST here...

  // Generate source code from AST and call the vendor's compiler
     return backend(project);
   }
开发者ID:billhoffman,项目名称:rose-develop,代码行数:67,代码来源:testWave.C

示例10: graphViz

int
main(int argc, char** argv)
   {
     ios::sync_with_stdio();                            // Syncs C++ and C I/O subsystems!
     rose::Diagnostics::initialize();                   // because librose doesn't initialize itself until frontend()

     Settings settings;
     std::vector<std::string> roseArgs = parseCommandLine(argc, argv, settings).unreachedArgs();
     roseArgs.insert(roseArgs.begin(), std::string(argv[0])); // not sure why frontend needs this, but it does.
     SgProject* project = frontend(roseArgs);
     ROSE_ASSERT (project != NULL);

  // Internal AST consistancy tests.
     AstTests::runAllTests(project);

     ROSE_ASSERT(project->numberOfFiles() == 2);

     int numberOfNodesInFile_0 = project->get_fileList()[0]->numberOfNodesInSubtree();
     int numberOfNodesInFile_1 = project->get_fileList()[1]->numberOfNodesInSubtree();

     printf ("numberOfNodesInFile_0 = %d \n",numberOfNodesInFile_0);
     printf ("numberOfNodesInFile_1 = %d \n",numberOfNodesInFile_1);

     if (settings.useOldImplementation) {
#if 0
         diff(project->get_fileList()[0],project->get_fileList()[1]);
#else

         vector< vector< SgNode* > > traversalTraceList = generateTraversalTraceList (project->get_fileList()[0],
                                                                                      project->get_fileList()[1],
                                                                                      /* minDepth = 0 */ 0,
                                                                                      /* infinite maxDepth */ -1 );
         printf ("Calling sequenceAlignment()... traversalTraceList.size() = %zu \n",traversalTraceList.size());
         sequenceAlignment  ( traversalTraceList );
         printf ("Done with call to sequenceAlignment() \n");
#endif

         // This method simply prints the edits as a side effect and doesn't return anything useful.
         Sawyer::Stopwatch tedLocalTimer;
         tree_edit_distance (project->get_fileList()[0],project->get_fileList()[1]);
         std::cout <<"local implementation of tree edit distance took " <<tedLocalTimer <<" seconds\n";
     }

     // This stuff uses the new edit distance analysis in librose
     std::cout <<"Using TreeEditDistance from librose:\n";
     EditDistance::TreeEditDistance::Analysis analysis;
     Sawyer::Stopwatch tedRoseTimer;
     analysis.compute(project->get_fileList()[0], project->get_fileList()[1],  // the subtrees to compare
                      project->get_fileList()[0], project->get_fileList()[1]); // their file restrictions
     std::cout <<"librose implementation of tree edit distance took " <<tedRoseTimer <<" seconds\n";
     EditDistance::TreeEditDistance::Edits edits = analysis.edits();
     std::cout <<"  Nodes in source tree: " <<analysis.sourceTreeNodes().size() <<"\n"
               <<"  Nodes in target tree: " <<analysis.targetTreeNodes().size() <<"\n"
               <<"  Number of edits:      " <<edits.size() <<"\n"
               <<"  Total cost of edits:  " <<analysis.cost() <<"\n"
               <<"  Relative cost:        " <<analysis.relativeCost() <<"\n"
               <<"  Individual edits:\n";
     BOOST_FOREACH (const EditDistance::TreeEditDistance::Edit &edit, edits)
         std::cout <<"    " <<edit <<"\n";
     std::ofstream graphViz("output-rose.dot");
     analysis.emitGraphViz(graphViz);
     std::cout <<"librose implementation of tree edit distance + output took " <<tedRoseTimer <<" seconds\n";
   }
开发者ID:JamesLinus,项目名称:rose,代码行数:63,代码来源:astDiff.C

示例11: dir_path

int
main(int argc, char** argv)
   {
     ios::sync_with_stdio();     // Syncs C++ and C I/O subsystems!
	 std::string idaPath = IDA_PRO_PATH;
	 if(idaPath == "")
     {
	   std::cerr << "Error: It is required to configure ROSE with IDA Pro \n";
	   exit(1);
	 }

    std::list<string> tsvDirectories; 


    path dir_path(argv[1]); 
    
    find_tsv_directories(dir_path, tsvDirectories);


    std::cout << "We have " << tsvDirectories.size() << " files " << std::endl;


    for(std::list<string>::iterator iItr = tsvDirectories.begin();
        iItr != tsvDirectories.end(); ++iItr)
    {

      std::string filename = *iItr;
      std::cout << "now doing " << filename << std::endl;
      std::vector<char*> newArgs;
      newArgs.push_back(strdup("-rose:read_executable_file_format_only"));
      newArgs.push_back(strdup(filename.c_str()));


      //for(int i =0; i < argc ; ++i)
      //  newArgs.push_back(strdup(argv[i]));

      SgProject* project = frontend( newArgs.size(), &newArgs[0] );

      ROSE_ASSERT (project != NULL);
      std::cout << "A" << std::endl;

      //Files will only exist for executables
      for(int i =0; i < project->numberOfFiles(); ++i)
      {
        SgFile* file = (*project)[i];
        std::cout << "B" << std::endl;

        if( isSgBinaryComposite(file) ){
          std::string filename = file->getFileName(); 

          std::cout << "B " << filename << std::endl;
          boost::filesystem::path path(filename);
          path = boost::filesystem::system_complete(path);
          std::string directory      = path.directory_string();
          std::string filenameString = path.root_name();


          std::string s = filename;
          string s_filename = StringUtility::stripPathFromFileName(s);
          string s_path     = StringUtility::getPathFromFileName(s);

          string s_nosuffix = s_filename.substr(0,s_filename.find_first_of(".") );
          printf ("s = %s s_filename = %s \n",s.c_str(),s_filename.c_str());
          printf ("s = %s s_path     = %s \n",s.c_str(),s_path.c_str());
          printf ("s = %s s_nosuffix = %s \n",s.c_str(),s_nosuffix.c_str());

          {
            //Need to create .idb first since that is the only way
            //to enable IDA analysis of the binaries

            ostringstream ostr;
            ostr << idaPath+"/idal";
            ostr << " -B ";
            ostr << filename.c_str();
            ostr << " -o"+s_path+"/"+s_nosuffix+".idb";

            std::cout << ostr.str() << std::endl;
            system(ostr.str().c_str());
          }

          {
            //Create .sql


            ostringstream ostr;
            ostr << idaPath+"/idal ";
            ostr << " -OIDAPython:" + idaPath + "/ida2sql.py ";
            ostr << s_path+"/"+s_nosuffix+".idb";
            //ostr << " -o"+filename+".sql";
            std::cout << ostr.str() << std::endl;
            system(ostr.str().c_str());

          }

          {
            //create -tsv directory which is the supported format in ROSE
            ostringstream ostr;
            ostr << " mv " + s_path+"/"+s_nosuffix+ ".sql " + filename + ".sql; "; 
            ostr << " cd " + s_path+";";
            ostr << " tclsh ";
//.........这里部分代码省略.........
开发者ID:billhoffman,项目名称:rose-develop,代码行数:101,代码来源:runIDA.C

示例12: main

int main( int argc, char * argv[] ) {
    
    if(argc < 3){
        Usage(argc, argv);
    }
    
    char * roseTraceFile = argv[1];
    FILE * roseTraceFilePtr;
    
    if(!(roseTraceFilePtr = fopen(roseTraceFile, "rb"))){
        fprintf(stderr, "\n Failed to read TraceFile %s",roseTraceFile);
        exit(-1);
    }

    FILE * roseProjectDBFilePtr;
    const char * roseProjectDBFile = argv[2];
    // Open the DB file... Don't need lock for reading.
    if(!(roseProjectDBFilePtr = fopen(roseProjectDBFile, "r"))){
        fprintf(stderr, "\n Failed to read roseDBFile %s", roseProjectDBFile);
        exit(-1);
    }
    
    char fileName[PATH_MAX];
    // Read DB file and assign file Ids
    while(fgets(fileName, PATH_MAX, roseProjectDBFilePtr)){
        // kill \n
        fileName[strlen(fileName)-1] = '\0';
        idToFile.push_back(string(fileName));
    }
    fclose(roseProjectDBFilePtr);
    
    
    
    // Read all trace records from the trace
    uint64_t traceId;
    boost::unordered_map<uint64_t, SgNode*>::iterator it;
    std::set<uint64_t> fileSet;
    
    vector<uint64_t> traceRecordVector;
    
    
    while(fread(&traceId, sizeof(uint64_t), 1, roseTraceFilePtr)){
        uint32_t fileId = traceId >> 32;
        if (fileId > idToFile.size()) {
            cout<<"\n"<< std::hex << traceId << " MISSING FILE!!!! id" << std::hex << fileId;
            traceRecordVector.push_back(NULL);
        } else {
            // If we have not seen this file, add it to teh set of files we want to open
            if(fileSet.find(fileId) == fileSet.end()){
                fileSet.insert(fileId);
            }
            traceRecordVector.push_back(traceId);
        }
    }
    fclose(roseTraceFilePtr);
    
    // Now build AST for each file in the set.
    
    
    for(std::set<uint64_t>::iterator it = fileSet.begin(), e = fileSet.end(); it != e; it++) {
        // prepare args.
        
        uint32_t fileId = *it;
        int numArgs = argc - 2 + 1; // -2 becoz we remove the trace and DB file. +1 because we add the source file.
        char * arguments[numArgs];
        for(int i = 3 ; i < numArgs - 1; i++){
            arguments[i] = argv[i];
        }
        arguments[0] = argv[0];
        arguments[numArgs-1] = (char *) idToFile[fileId].c_str();
        
        // Generate the ROSE AST.
        SgProject* project = frontend(numArgs, arguments);
        // AST consistency tests (optional for users, but this enforces more of our tests)
        AstTests::runAllTests(project);
        
        // Build node to trace id map.
        for(int i = 0 ; i < project->numberOfFiles(); i++) {
            SgFile & file = project->get_file(i);
            IdToNodeMapper mapper(&file, string(roseProjectDBFile));
        }
    }
    
    // Now, print the mapping from trace id to its SgNode
    
    for( vector<uint64_t>::iterator it = traceRecordVector.begin(), e = traceRecordVector.end(); it != e; it++){
        uint64_t traceId = *it;
        uint32_t fileId = traceId >> 32;
        SgNode * curSgNode = idToNodeMap[traceId];
        if(idToNodeMap.find(traceId) != idToNodeMap.end())
            cout <<"\n" << std::hex << traceId << idToFile[fileId] << ":" << std::hex << curSgNode << ":" << curSgNode->class_name();
        else
            cout <<"\n" << std::hex << traceId << "HAS NO MAPPING!!!";
    }
    
    return 0;
    
}
开发者ID:matzke1,项目名称:rose-develop,代码行数:98,代码来源:RoseCommonPathToSgNodeMapper.C

示例13: main

int main(int argc, char** argv)
   {
  // DQ (9/1/2006): Introduce tracking of performance of ROSE at the top most level.
     TimingPerformance timer_main ("Compass performance (main): time (sec) = ",true);

     std::ios::sync_with_stdio();     // Syncs C++ and C I/O subsystems!

     if (SgProject::get_verbose() > 0)
          printf ("In compassMain.C: main() \n");

     Rose_STL_Container<std::string> commandLineArray = CommandlineProcessing::generateArgListFromArgcArgv (argc,argv);

     Compass::commandLineProcessing(commandLineArray);

  // Read the Compass parameter file (contains input data for all checkers)
  // This has been moved ahead of the parsing of the AST so that it is more 
  // obvious when it is a problem.
     Compass::Parameters params(Compass::findParameterFile());

#ifdef ROSE_MPI
     // Initialize MPI if needed...
     // need to do this to make test cases pass with MPI. 
     /* setup MPI */
     MPI_Init(&argc, &argv);
     MPI_Comm_rank(MPI_COMM_WORLD, &Compass::my_rank);
     MPI_Comm_size(MPI_COMM_WORLD, &Compass::processes);
#endif

  // Use a modified commandline that inserts specific additional options
  // to the ROSE frontend to make use with Compass more appropriate.
  // SgProject* project = frontend(argc,argv);
     SgProject* project = frontend(commandLineArray);


#ifdef HAVE_SQLITE3

     std::vector<bool> was_modified;

     //Determine if any file has been modified since the last run. If so, rerun
     //the compass checkers. The first run will always run the compass checkers.
     for (int i = 0; i < project->numberOfFiles(); ++i)
     {
       // In each file find all declarations in global scope
       SgSourceFile* sageFile = isSgSourceFile(project->get_fileList()[i]);
       std::string filename   = sageFile->getFileName();

       struct stat file_info;
       
       if ( stat(filename.c_str(), &file_info) != 0 )
         {
           std::cerr << "Error: Can not determine last modification time of file " << filename 
                     << std::endl;
       }else{

         std::string last_modified = boost::lexical_cast<std::string>(file_info.st_mtime);
         try {

           /* Read in from database here */
           sqlite3x::sqlite3_command cmd(Compass::con, "SELECT last_modified from file_last_modified where filename=\""+filename+ "\"" );

           sqlite3x::sqlite3_reader r = cmd.executereader();


           while (r.read()) {
             std::string last_modified_in_db = r.getstring(0);
             was_modified.push_back( (last_modified_in_db == last_modified) ? false : true );

           }

         } catch (std::exception& e) {std::cerr << "Exception: " << e.what() << std::endl;}

         //Update last modified time in database
         try{
           sqlite3x::sqlite3_command cmd(Compass::con,"DELETE from file_last_modified where filename=\""+filename+ "\"");
           cmd.executenonquery();
         } catch (std::exception& e) {std::cerr << "Exception: " << e.what() << std::endl;}

         try{
           sqlite3x::sqlite3_command cmd(Compass::con,"INSERT into file_last_modified(filename, last_modified) VALUES(?,?)");
           cmd.bind(1,filename);
           cmd.bind(2,last_modified);

           cmd.executenonquery();
         } catch (std::exception& e) {std::cerr << "Exception: " << e.what() << std::endl;}

                  
       };


     }

     //Continue processign iff at least one file was modified
     if( ( find(was_modified.begin(), was_modified.end(), true) != was_modified.end() )
         ||  (was_modified.size() == 0) )
     {
       //Delete violation entries that correspond to this file
       for (int i = 0; i < project->numberOfFiles(); ++i)
       {
         // In each file find all declarations in global scope
         SgSourceFile* sageFile = isSgSourceFile(project->get_fileList()[i]);
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:compassMain.C

示例14: printf

void
TransformationSupport::getTransformationOptions ( SgNode* astNode, list<OptionDeclaration> & generatedList, string identifingTypeName )
   {
  // This function searches for variables of type ScopeBasedTransformationOptimization.  Variables
  // of type ScopeBasedTransformationOptimization are used to communicate optimizations from the
  // application to the preprocessor. If called from a project or file object it traverses down to
  // the global scope of the file and searches only the global scope, if called from and other
  // location within the AST it searches the current scope and then traverses the parent nodes to
  // find all enclosing scopes until in reaches the global scope.  At each scope it searches for
  // variables of type ScopeBasedTransformationOptimization.

  // printf ("######################### START OF TRANSFORMATION OPTION QUERY ######################## \n");

     ROSE_ASSERT (astNode != NULL);
     ROSE_ASSERT (identifingTypeName.c_str() != NULL);

#if 0
     printf ("In getTransformationOptions(): astNode->sage_class_name() = %s generatedList.size() = %d \n",
          astNode->sage_class_name(),generatedList.size());
     SgLocatedNode* locatedNode = isSgLocatedNode(astNode);
     if (locatedNode != NULL)
        {
          printf ("          locatedNode->get_file_info()->get_filename() = %s \n",locatedNode->get_file_info()->get_filename());
          printf ("          locatedNode->get_file_info()->get_line() = %d \n",locatedNode->get_file_info()->get_line());
        }
#endif

     switch (astNode->variant())
        {
          case ProjectTag:
             {
               SgProject* project = isSgProject(astNode);
               ROSE_ASSERT (project != NULL);

           //! Loop through all the files in the project and call the mainTransform function for each file
               int i = 0;
               for (i=0; i < project->numberOfFiles(); i++)
                  {
                    SgFile* file = &(project->get_file(i));

                 // printf ("Calling Query::traverse(SgFile,QueryFunctionType,QueryAssemblyFunctionType) \n");
                    getTransformationOptions ( file, generatedList, identifingTypeName );
                  }
               break;
             }

          case SourceFileTag:
             {
               SgSourceFile* file = isSgSourceFile(astNode);
               ROSE_ASSERT (file != NULL);
               SgGlobal* globalScope = file->get_globalScope();
               ROSE_ASSERT (globalScope != NULL);
               ROSE_ASSERT (isSgGlobal(globalScope) != NULL);
               getTransformationOptions ( globalScope, generatedList, identifingTypeName );
               break;
             }

       // Global Scope
          case GLOBAL_STMT:
             {
               SgGlobal* globalScope = isSgGlobal(astNode);
               ROSE_ASSERT (globalScope != NULL);

               SgSymbolTable* symbolTable = globalScope->get_symbol_table();
               ROSE_ASSERT (symbolTable != NULL);
               getTransformationOptions ( symbolTable, generatedList, identifingTypeName );

            // printf ("Processed global scope, exiting .. \n");
            // ROSE_ABORT();
               break;
             }

          case SymbolTableTag:
             {
            // List the variable in each scope
            // printf ("List all the variables in this symbol table! \n");
               SgSymbolTable* symbolTable = isSgSymbolTable(astNode);
               ROSE_ASSERT (symbolTable != NULL);

               bool foundTransformationOptimizationSpecifier = false;

            // printf ("Now print out the information in the symbol table for this scope: \n");
            // symbolTable->print();

#if 0
            // I don't know when a SymbolTable is given a name!
               printf ("SymbolTable has a name = %s \n",
                    (symbolTable->get_no_name()) ? "NO: it has no name" : "YES: it does have a name");
               if (!symbolTable->get_no_name())
                    printf ("SymbolTable name = %s \n",symbolTable->get_name().str());
                 else
                    ROSE_ASSERT (symbolTable->get_name().str() == NULL);
#endif

               if (symbolTable->get_table() != NULL)
                  {
                    SgSymbolTable::hash_iterator i = symbolTable->get_table()->begin();
                    int counter = 0;
                    while (i != symbolTable->get_table()->end())
                       {
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:options.C

示例15: main

int main( int argc, char * argv[] )
   {

     {
       std::vector<std::string> newArgv(argv,argv+argc);
       newArgv.push_back("-rose:skip_rose");
       SgProject* project = frontend(newArgv);
       backend(project);

     }
     std::vector<std::string> newArgv(argv,argv+argc);
     newArgv.push_back("-rose:wave");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include/g++_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include/gcc_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include-staging/g++_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/include-staging/gcc_HEADERS/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/usr/include/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("/tests/CompileTest/");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<builtin>");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<built-in>");
     newArgv.push_back("-rose:excludePath");
     newArgv.push_back("<builltin>");



  // Build the AST used by ROSE
     SgProject* project = frontend(newArgv);
     ROSE_ASSERT(project != NULL);

  // Build a list of functions within the AST
     AnalyzeMacroCalls* macroCalls = new AnalyzeMacroCalls(project, false, std::cerr);

  // Assume that there is only one file
     std::string filename;
     for(int i = 0 ; i < project->numberOfFiles(); i++)
     {
       SgSourceFile* file = isSgSourceFile(&project->get_file(i));
       if( file != NULL)
         filename = file->getFileName();

     };

     ROSE_ASSERT(filename != "");

     filename+=".out";
     filename = StringUtility::stripPathFromFileName(filename);

     ofstream myfile;
     myfile.open (filename.c_str());

     ROSE_ASSERT(myfile.is_open());
     std::cout << "Outputing to the file " << filename << std::endl;


     macroCalls->print_out_all_macros(myfile);
     //     return backend(project);
     myfile.close();

   }
开发者ID:8l,项目名称:rose,代码行数:67,代码来源:testPruning.C


注:本文中的SgProject::numberOfFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。