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


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

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


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

示例1: main

int main (int argc, char* argv[]) {
  // Main Function for default example ROSE Preprocessor
  // This is an example of a preprocessor that can be built with ROSE

  // Build the project object (AST) which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
  SgProject* sageProject = frontend(argc,argv);

  simpleIndexFiniteDifferencing(sageProject);

  FixSgProject(*sageProject);

  // partialRedundancyElimination(sageProject);

  // AstPDFGeneration().generateInputFiles(sageProject);

  // Generate the final C++ source code from the potentially modified SAGE AST
  sageProject->unparse();

  // What remains is to run the specified compiler (typically the C++ compiler) using 
  // the generated output file (unparsed and transformed application code) to generate
  // an object file.
  // int finalCombinedExitStatus = sageProject->compileOutput();

  // return exit code from complilation of generated (unparsed) code
  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:27,代码来源:finiteDifferencingTest.C

示例2: sageProject

int
main ( int argc, char * argv[] )
   {
  // Main Function for default example ROSE Preprocessor
  // This is an example of a preprocessor that can be built with ROSE
  // This example tests the ROSE infrastructure

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

  // Declare usage (if incorrect number of inputs):
     if (argc == 1)
        {
       // Print usage and exit with exit status == 1
          Rose::usage (1);
        }

  // Build the project object which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
     SgProject sageProject (argc,argv);

  // Warnings from EDG processing are OK but not errors
  //   ROSE_ASSERT (EDG_FrontEndErrorCode <= 3);

  // cout << "EDG/SAGE Processing DONE! (manipulate AST with ROSE ...) " << endl;

  // DQ (10/17/2004): Added internal testing of AST
     AstTests::runAllTests(&sageProject);

     SIDL_TreeTraversal treeTraversal(chooseConstructor(&sageProject));

     MethodSearchVisitor treeVisitor(&sageProject);
     treeVisitor.traverseInputFiles(&sageProject, preorder);

  // Ignore the return value since we don't need it
     treeTraversal.traverseInputFiles(&sageProject);
     AstDOTGeneration dotgen;
     dotgen.generateInputFiles(&sageProject, AstDOTGeneration::PREORDER);

     cout << "ROSE Processing DONE! (no need to call unparse or backend C++ compiler ...) " << endl;

#if 0
  // DQ (10/17/2004): This seems to be a problem, some sort of infinit loop is generated in the unparser!
  // the test code has been transfrered to another location for internal testing.  for now this should
  // be commented out.  It is not required for Babel Processing. This is now fixed!

  // Generate the final C++ source code from the potentially modified SAGE AST
  // sageProject.set_verbose(true);
     sageProject.unparse();
#endif

  // Later we want to call babel to process the generated SIDL file and generate the imple files which 
  // we will process as part of the next phase of work to completely automate the process.
     int finalCombinedExitStatus = 0;

     printf ("Program Compiled Normally (exit status = %d)! \n\n\n\n",finalCombinedExitStatus);

  // either of these will work similarly
  // exit (finalCombinedExitStatus);
     return finalCombinedExitStatus;
   }
开发者ID:matzke1,项目名称:rose-develop,代码行数:60,代码来源:babelPreprocessor.C

示例3: main

int main (int argc, char* argv[])
   {
  // Main Function for default example ROSE Preprocessor
  // This is an example of a preprocessor that can be built with ROSE

  // Build the project object (AST) which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
     vector<string> argvList(argv, argv + argc);
     VectorCmdOptions::GetInstance()->SetOptions(argvList);
     SgProject* sageProject = frontend(argvList);
  // FixSgProject(sageProject);

  // AstTests::runAllTests(const_cast<SgProject*>(project));
     AstTests::runAllTests(sageProject);

     PRE::partialRedundancyElimination(sageProject);

  // AstPDFGeneration().generateInputFiles(sageProject);

     AstTests::runAllTests(sageProject);

  // AstPDFGeneration().generateInputFiles(sageProject);

  // Generate the final C++ source code from the potentially modified SAGE AST
     sageProject->unparse();

  // What remains is to run the specified compiler (typically the C++ compiler) using 
  // the generated output file (unparsed and transformed application code) to generate
  // an object file.
  // int finalCombinedExitStatus = sageProject.compileOutput();

  // return exit code from complilation of generated (unparsed) code
     return 0;
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:34,代码来源:preTest.C

示例4: 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

示例5: main

int main ( int argc, char* argv[] ) {
	SgProject * project = frontend ( argc , argv ) ;
	
	Rose_STL_Container<SgNode*> pragma_decls = NodeQuery::querySubTree(project, V_SgPragmaDeclaration);
	Rose_STL_Container<SgNode*>::iterator it;
	for (it = pragma_decls.begin(); it != pragma_decls.end(); it++) {
		SgPragmaDeclaration * pragma_decl = isSgPragmaDeclaration(*it);
		
		try {
			PolyhedricAnnotation::parse(pragma_decl);
		}
		catch (Exception::ExceptionBase & e) {
			e.print(std::cerr);
			continue;
		}
		
		PolyhedricAnnotation::PragmaPolyhedralProgram & polyhedral_program =
				PolyhedricAnnotation::getPolyhedralProgram<SgPragmaDeclaration, SgExprStatement, RoseVariable>(pragma_decl);
		
		Scheduling::PragmaSchedule schedule(polyhedral_program, 0);
		CodeGeneration::generateAndReplace(schedule);
	}
	
	project->unparse();
	
	return 0;
}
开发者ID:8l,项目名称:rose,代码行数:27,代码来源:code-generation.cpp

示例6: myTraversal

int
main( int argc, char * argv[] )
   {
  // This test code demonstrates the differences between an ordinary 
  // SgTopDownBottomUpProcessing traversal and a traversal using the 
  // AST Rewrite Mechanism.

  // DQ (4/6/2017): This will not fail if we skip calling ROSE_INITIALIZE (but
  // any warning message using the message looging feature in ROSE will fail).
     ROSE_INITIALIZE;

     ios::sync_with_stdio();     // Syncs C++ and C I/O subsystems!
     if (argc == 1)
        {
       // Print usage and exit with exit status == 1
          rose::usage (1);
        }

  // Build the project object which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
     int EDG_FrontEndErrorCode = 0;
     SgProject* sageProject = new SgProject(argc,argv,EDG_FrontEndErrorCode); 

  // Warnings from EDG processing are OK but not errors
     ROSE_ASSERT (EDG_FrontEndErrorCode <= 3);

     cout << "EDG/SAGE Processing DONE! (manipulate with ROSE ...) " << endl;

  // Output the source code file (as represented by the SAGE AST) as a PDF file (with bookmarks)
     AstPDFGeneration pdftest;
     pdftest.generateInputFiles(sageProject);

  // Build the inherited attribute
     MyInheritedAttribute inheritedAttribute;

  // The traversal uses the AST rewrite mechanism which requires the SgProject object to retrive the
  // command line for compilation of the intermeditate files (from strings to AST fragments) before
  // patching them into the application's AST.
     MyTraversal myTraversal(*sageProject);

  // Call the traversal starting at the sageProject node of the AST
     myTraversal.traverseInputFiles(sageProject,inheritedAttribute);

  // Generate the final C++ source code from the potentially modified SAGE AST
     sageProject->unparse();

     cout << "Generation of final source code (unparsing) DONE! (compile ...) " << endl;

  // What remains is to run the specified compiler (typically the C++ compiler) using 
  // the generated output file (unparsed and transformed application code) to generate
  // an object file.
     int finalCombinedExitStatus = sageProject->compileOutput();
     printf ("Program Compiled Normally (exit status = %d)! \n\n\n\n",finalCombinedExitStatus);
     return finalCombinedExitStatus;
   }
开发者ID:ian-bertolacci,项目名称:rose-develop,代码行数:55,代码来源:AstTraversalTranslator.C

示例7: main

int main(int argc, char *argv[]){
  
  SgProject* sgproject = frontend(argc, argv);
  // SgProject *sgproject_copy = static_cast<SgProject*>(sgproject->copy(SgTREE_COPY)); 
  // This copy of the sgproject fails due to the copy function of the SgFile fails (aborts)
  
  SgFile &file = sgproject->get_file(0);
  // SgFile *file_copy = static_cast<SgFile*>(file.copy(SgTREE_COPY));
  // Calling the copy function of SgFile fails:
  // Before aborting the execution, the following error message is displayed:
  // "This is the default constructor, use SgFile (argc,argv) instead"
  
  SgGlobal *root = file.get_root();
  SgGlobal *root_copy = static_cast<SgGlobal*>(root->copy(SgTREE_COPY));
  // Copying the SgGlobal object is OK
  
  // removing the return statement...from the copy!
  list<SgNode*> returnstmt_list = NodeQuery::querySubTree(root_copy, V_SgReturnStmt);
  SgStatement* stmt = isSgStatement(*returnstmt_list.begin());
  LowLevelRewrite::remove(stmt);
  
  sgproject->unparse();  // should output unmodified sgproject and it does. The deep copy
                         // mechanism works for the SgGlobal object. 

  // moving the output file to a new file, so that we can unparse the sgproject again without
  // overwriting the results
  char *outputfile = file.get_unparse_output_filename();
  string move = "mv " + string(outputfile) + " orig_" + string(outputfile); 
  system(move.c_str());

  // want to output modified sgproject
  file.set_root(root_copy);
  //sgproject->set_file(file);
  sgproject->unparse(); // or use: file.unparse();?
  
  // Unparsing the sgproject after adding the root_copy to the file-object (I want
  // to unparse the modified copy...), gives me an error message:
  //  /home/hauge2/ROSE/src/backend/unparser/unparse_stmt.C:1047: void Unparser::unparseFuncDefnStmt(SgStatement*, SgUnparse_Info&): Assertion `funcdefn_stmt->get_declaration() != __null' failed.
  
  return 0;
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:41,代码来源:test2005_21.C

示例8: main

int main(int argc, char *argv[])
{
        SgProject *project = frontend(argc, argv);
        SlicingInfo si=SlicingInfo();
        si.traverse(project, preorder);

        SystemDependenceGraph * sdg=new SystemDependenceGraph();
        sdg->parseProject(project);

        CreateSliceSet sliceSet(sdg,si.getSlicingTargets());
        CreateSlice cs(sliceSet.computeSliceSet());

        cs.traverse(project);
        project->unparse();     
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:15,代码来源:slice.C

示例9: main

int main( int argc, char * argv[] ) 
   {
     CommandlineProcessing::addCppSourceFileSuffix("docs")
     CommandlineProcessing::addCppSourceFileSuffix("h");

  // Build the AST used by ROSE
     SgProject* sageProject = frontend(argc,argv);

     Doxygen::annotate(sageProject);

     OrganizeAllComments oac;
     oac.traverse(sageProject, preorder);

  // Generate source code from AST and call the vendor's compiler
     sageProject->unparse();
   }
开发者ID:8l,项目名称:rose,代码行数:16,代码来源:testParser10.C

示例10: main

int main(int argc, char* argv[])
{
    /* Processing cmd line args */
	vector<string> argvList(argv, argv+argc);
	UpcLibrary::processOptions(argvList);

    /* Parse the input file */
    SgProject* proj = frontend(argc, argv);

    /* collect all upc_forall stmts */
    vector<SgUpcForAllStatement*> forall_stmts =
        SageInterface::querySubTree<SgUpcForAllStatement>(proj);

    /* translate upc_forall stmts to normal c */
    foreach (SgUpcForAllStatement* forall_stmt, forall_stmts)
        SageInterface::replaceStatement(forall_stmt, translate_from_upc(forall_stmt));

    /* collect all for_stmts */
    vector<SgForStatement*> for_stmts =
        SageInterface::querySubTree<SgForStatement>(proj);

	/* Normalize C99-style for (int i=x, ...) to C89-style: int i; for(i=x, ...) */
    foreach (SgForStatement* for_stmt, for_stmts)
		SageInterface::normalizeForLoopInitDeclaration(for_stmt);

    /* Filter out the inner loops in each nest */
    vector<SgForStatement*> nests;
    foreach (SgForStatement* for_stmt, for_stmts)
        if (isOuterLoop(for_stmt))
            nests.push_back(for_stmt);

    /* optimize each nest */
    foreach (SgForStatement* nest, nests)
        optimize(nest);

    /* replace upc affinity expressions */
    foreach (SgForStatement* for_stmt, for_stmts)
        SageInterface::replaceStatement(for_stmt, translate_to_upc(for_stmt));

    proj->unparse();
    return 0;
}
开发者ID:mbdriscoll,项目名称:upctr,代码行数:42,代码来源:upctr.C

示例11: main

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

  //this adds -rose:openmp:ast_only -linearize args
  MintOptions::setInternalCommandLineArgs(argc, argv);
  
  vector<string> argvList(argv, argv + argc);

  MintOptions::GetInstance()->SetMintOptions(argvList);

  //isCFileNameSuffix ();

  //call the front end with -rose:openmp:ast_only and
  //then call the lowering explicitly

  SgProject *project = frontend (argc, argv);

  //currently we only handle single input file 
  SgSourceFile* file = isSgSourceFile(project->get_fileList()[0]);
  
  MintTools::setOutputFileName(isSgFile(file));

  //insert cuda header files. is there any? 
  MintCudaMidend::insertHeaders(project);

  //Now we have the AST and search for Mint pragmas
  MintCudaMidend::lowerMinttoCuda(file);

  if(MintOptions::GetInstance()->linearize()){
    cout << "  INFO:Mint: flattening the array accesses" << endl;  
    MintArrayInterface::linearizeArrays(file);
  }


  cout << "  INFO:Mint: calling ROSE backend" << endl;
  project->unparse();
  //return backend(project);

  cout << endl <<"  INFO:Mint: Good Job. Translation is done!" << endl << endl;

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

示例12: main

int main( int argc, char * argv[] ) 
   {
     vector<string> argvList(argv, argv + argc);

     CommandlineProcessing::addCppSourceFileSuffix("docs");
     CommandlineProcessing::addCppSourceFileSuffix("h");

     Doxygen::parseCommandLine(argvList);

  // Build the AST used by ROSE
     SgProject* sageProject = frontend(argvList);

     Doxygen::annotate(sageProject);

     Doxygen::correctAllComments(sageProject);

  // Generate source code from AST
     Doxygen::unparse(sageProject);
     sageProject->unparse();
   }
开发者ID:8l,项目名称:rose,代码行数:20,代码来源:correctAllComments.C

示例13: main

int main (int argc, char* argv[])
   {
  // Main Function for default example ROSE Preprocessor
  // This is an example of a preprocessor that can be built with ROSE

  // Build the project object (AST) which we will fill up with multiple files and use as a
  // handle for all processing of the AST(s) associated with one or more source files.
     SgProject* sageProject = frontend(argc,argv);

  // DQ (7/20/2004): Added internal consistancy tests on AST
     AstTests::runAllTests(sageProject);

  // This is not needed here
  // FixSgProject(sageProject);

     bool changed = true;
     int  count   = 0;

  /* Inline one call at a time until all have been inlined.  Loops on recursive code. */
     while (changed)
        {
          changed = false;
          calls_to_inline.clear();
          FindCallsVisitor().traverseInputFiles(sageProject, preorder);

          for (std::vector<SgFunctionCallExp*>::iterator i = calls_to_inline.begin(); i != calls_to_inline.end(); ++i)
             {
            // cout << (*i)->unparseToString() << endl;
            // generateAstGraph(sageProject, 400000);
               if (doInline(*i))
                  {
                    changed = true;
                 // AstTests::runAllTests(sageProject);
                    break;
                  }
             }
          ++count;
#if 0
          sageProject.unparse();
#endif
       // To prevent infinite loops
          if (count == 10)
             {
               break;
             }
        }

#if 1

  // Rename each variable declaration
     renameVariables(sageProject);

#if 1
  // Fold up blocks
     flattenBlocks(sageProject);

  // Clean up inliner-generated code
     cleanupInlinedCode(sageProject);
#endif

  // Change members to public
     changeAllMembersToPublic(sageProject);

  // AstPDFGeneration().generateInputFiles(sageProject);
  // AstDOTGeneration().generateInputFiles(sageProject);
#endif

     AstTests::runAllTests(sageProject);

#if 0
  // Output an optional graph of the AST (just the tree, when active)
     printf ("Generating a dot file... (ROSE Release Note: turn off output of dot files before committing code) \n");
     generateDOT (*sageProject );
     // generateAstGraph(project, 2000);
#endif

#if 1
  // Output an optional graph of the AST (the whole graph, of bounded complexity, when active)
     const int MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH = 8000;
     generateAstGraph(sageProject,MAX_NUMBER_OF_IR_NODES_TO_GRAPH_FOR_WHOLE_GRAPH);
#endif


     return backend(sageProject);
   }
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:85,代码来源:inlineEverything.C

示例14: main


//.........这里部分代码省略.........
      option_prefix=args["prefix"].as<string>().c_str();
    }

    if (args.count("trace")) {
      option_trace=true;
    }
    if(args.count("stats")) {
      option_stats=true;
    }
    if(args.count("rd-analysis")) {
      option_rd_analysis=true;
    }
    if(args.count("lv-analysis")) {
      option_lv_analysis=true;
    }
    if(args.count("interval-analysis")) {
      option_interval_analysis=true;
    }
    if(args.count("ud-analysis")) {
      option_rd_analysis=true; // required
      option_ud_analysis=true;
    }
    if(args.count("rose-rd-analysis")) {
      option_rose_rd_analysis=true;
    }
    if(args.count("fi-constanalysis")) {
      option_fi_constanalysis=true;
    }
    if (args.count("csv-fi-constanalysis")) {
      csvConstResultFileName=args["csv-fi-constanalysis"].as<string>().c_str();
      option_fi_constanalysis=true;
    }
    if(args.count("at-analysis")) {
      option_at_analysis=true;
    }
    // clean up string-options in argv
    for (int i=1; i<argc; ++i) {
      if (string(argv[i]) == "--prefix" 
          || string(argv[i]) == "--csv-const-result"
          ) {
        // do not confuse ROSE frontend
        argv[i] = strdup("");
        assert(i+1<argc);
        argv[i+1] = strdup("");
      }
    }

    cout << "INIT: Parsing and creating AST."<<endl;
    boolOptions.registerOption("semantic-fold",false); // temporary
    boolOptions.registerOption("post-semantic-fold",false); // temporary
    SgProject* root = frontend(argc,argv);
    //  AstTests::runAllTests(root);

   if(option_stats) {
      SPRAY::ProgramStatistics::printBasicCodeInfo(root);
    }

  cout<<"STATUS: computing variableid mapping"<<endl;
  VariableIdMapping variableIdMapping;
  if (args.count("print-varidmapping-array")) {
    variableIdMapping.setModeVariableIdForEachArrayElement(true);
  }
  variableIdMapping.computeVariableSymbolMapping(root);
  cout<<"VariableIdMapping size: "<<variableIdMapping.getVariableIdSet().size()<<endl;
  Labeler* labeler=new Labeler(root);
  //cout<<"Labelling:\n"<<labeler->toString()<<endl;

#if 0
  IOLabeler* iolabeler=new IOLabeler(root,&variableIdMapping);
  //cout<<"IOLabelling:\n"<<iolabeler->toString()<<endl;
#endif

  if (args.count("print-varidmapping")||args.count("print-varidmapping-array")) {
    variableIdMapping.toStream(cout);
  }

  runAnalyses(root, labeler, &variableIdMapping);

  cout << "INFO: generating annotated source code."<<endl;
  root->unparse(0,0);

  if(option_rose_rd_analysis) {
    Experimental::RoseRDAnalysis::generateRoseRDDotFiles(labeler,root);
  }

  cout<< "STATUS: finished."<<endl;

  // main function try-catch
  } catch(char* str) {
    cerr << "*Exception raised: " << str << endl;
    return 1;
  } catch(const char* str) {
    cerr << "Exception raised: " << str << endl;
    return 1;
  } catch(string str) {
    cerr << "Exception raised: " << str << endl;
    return 1;
  }
  return 0;
}
开发者ID:iN3O,项目名称:edg4x-rose,代码行数:101,代码来源:analyterix.C

示例15: main

int main(int argc,char ** argv)
{
	SgProject *project = frontend(argc, argv);
	VisPromelaAST * debugPromelaAst=new VisPromelaAST(project);
	cout <<"reverting mpi"<<endl;
	revertMPIDefinitions(project);
	
	announceStep(1,0,"Identify modelchecking targets");
	//! step1: Identify modelchecking targets
	PromelaMarker initialMarker;
	initialMarker.traverse(project, preorder);
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.inital_marking.dot");		
	// since the next step is creating a slice, we must identify all statements which are modelchekcing targets so that we have a valid slice
	SlicingInfo si=SlicingInfo();
	// it might be better to use the AST-Attributes as a method for containing this information, but right now the pragma is sufficient
	si.setSliceTargetString(string("SPIN_TARGET"));
	si.traverse(project, preorder);


	announceStep(2,0,"Create abstractions using sdg and other means");
	// create the sdg
	SystemDependenceGraph * sdg=new SystemDependenceGraph();
	sdg->parseProject(project);
	//TODO: at this point one would implement abstractions, because they alter the code in such a way, that slicing might be able to remove additional statements, which otherwihse would not be removed
	

	announceStep(3,0,"Slice program to reduce state-space and\n\t eliminate dead code from abstractions");
	//! Step2: Slice program to reduce towards abstraction and goal
		
	// create the set of nodes, that are in the slice, in terms of the sdg
	CreateSliceSet sliceSet(sdg,si.getSlicingTargets());

	// using the set of statements that are within the slice construct an unnamed CreateSlice-class and slice the project
	CreateSlice(sliceSet.computeSliceSet()).traverse(project);
	
	// since now the ast is substantially different from the previouse version the sdg is not valid anymore
	delete(sdg);

	//DEVEL: output the sliced statement-graph
	debugPromelaAst->generate(string((*(project->get_fileList ()->begin()))->getFileName())+".SPIN.sliced.dot");		
	//DEVEL: run-ast-consistancy-test to enshure a valid ast
	AstTests::runAllTests(project);


	announceStep(4,1,"Perform sanity-check for non-transformable code like scanf and parameterinput  argc and argv");
	//TODO: implement the sanitiy-checks
	

	announceStep(4,2,"Identify Process and Thread functions and mark them as PROMELA-Procs");
	// find process functions,like main and thread-functions.
	// For this version of the transformation only main is valid, 
	// but later on threadfunctions might also work. Therefore the
	// a vector is used to store the main function
	vector<SgFunctionDefinition*> procFuncVec=findProcessFunctions(project);
	// mark those function declarations,definitions and main-basic block to enshure proper promela-output
	for (int i=0;i<procFuncVec.size();i++)
	{
		cout <<"\t*marking function for promela-output: "<<procFuncVec[i]->get_declaration()->get_name().getString()<<endl;
		// mark the function body for transformation
		markForPromelaTransformation(procFuncVec[i]);
		// force the first SgBasicBlock to be converted to promela!!!!!
		markForPromelaTransformation(procFuncVec[i]->get_body () );
		//CI (04/16/2007): This is currently not necessary
		if (isSgFile(procFuncVec[i]->get_parent()->get_parent()->get_parent()))
		{
			cout <<"marking file"<<endl;
			markForPromelaTransformation(procFuncVec[i]->get_parent()->get_parent()->get_parent());
		}
	}
	
	
	announceStep(4,3,"Identify functions using global variables and add them to the inlining list");
	vector<SgVariableDeclaration *> globalVarDeclVec;
	vector<SgFunctionDefinition *> functionsToInline;
	std::map<SgNode*,bool> functionToInlineMap;
	
	//TODO: search in each functions for uses of a global variable, if the function contains a use, mark it and continue with the next function
	list<SgNode*> sgGlobalList=NodeQuery::querySubTree(project,V_SgGlobal);	
	for (list<SgNode*>::iterator sgGlobalIt=sgGlobalList.begin();sgGlobalIt!=sgGlobalList.end();sgGlobalIt++)	
	{
		// iterate over this scope without recursing and find all variabledeclarations ...
		SgDeclarationStatementPtrList globalDeclList=isSgGlobal(*sgGlobalIt)->get_declarations ();
		for (SgDeclarationStatementPtrList::iterator it=globalDeclList.begin();it!=globalDeclList.end();it++)
		{
			if (isSgVariableDeclaration(*it))
			{
				cout <<"\t\t*found VarDecl:"<<(*it)->unparseToString()<<endl;
				//TODO:	check if its from a header and if it is used..
				globalVarDeclVec.push_back(isSgVariableDeclaration(*it));
			}
		}		
	}
	
	// remove MPI-Symbols form the globals	
	vector<SgVariableDeclaration *> globalVarDeclVecTmp;
	for (int i=0;i<globalVarDeclVec.size();i++)
	{
		// if the current declaration is an mpi declaration, remove it from the global list (it is from a header, and will be directly supported in spin
		if (isNodeMPI(globalVarDeclVec[i]))
		{
//.........这里部分代码省略.........
开发者ID:8l,项目名称:rose,代码行数:101,代码来源:CtoPromelaTransformation.C


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