Пример #1
0
//========================================================================================
// R201 program
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_Program(Program * program)
{
   Sg_File_Info * start = NULL;
   SgUntypedGlobalScope * scope = NULL;
   SgUntypedFunctionDeclaration * decl = NULL;
   SgUntypedDeclarationList * declList = NULL;

   // set up the global program scope
   //
   scope = new SgUntypedGlobalScope(start);
   scope->set_declaration_list(new SgUntypedDeclarationList(start));  
   scope->set_statement_list(new SgUntypedStatementList(start));  
   scope->set_function_list(new SgUntypedFunctionDeclarationList(start));  

   SgUntypedFile * file = new SgUntypedFile(start);
   file->set_scope(scope);
   declList = file->get_scope()->get_declaration_list();

   // StartCommentBlock (ignore for now)
   //

   // ProgramUnit
   //
   std::vector<ProgramUnit*>* unitList = program->getProgramUnitList();
   for (int i = 0; i < unitList->size(); i++) {
      decl = dynamic_cast<SgUntypedFunctionDeclaration*>(unitList->at(i)->getPayload());  assert(decl);
      declList->get_decl_list().push_back(decl);
   }

   program->setPayload(file);
   
   printf("build_Program: ..................... %lu\n", declList->get_decl_list().size());

}
Пример #2
0
//========================================================================================
// R201 program
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_Program(Program * program)
{
#ifdef TODO_ROSE
   Sg_File_Info * start = NULL;
   SgUntypedGlobalScope * scope = NULL;
   SgUntypedDeclarationStatement * decl = NULL;
   SgUntypedDeclarationList * declList = NULL;

   // set up the global program scope
   //
   scope = new SgUntypedGlobalScope(start);
   scope->set_declaration_list(new SgUntypedDeclarationList(start));  
   scope->set_statement_list(new SgUntypedStatementList(start));  
   scope->set_function_list(new SgUntypedFunctionDeclarationList(start));  

   SgUntypedFile * file = new SgUntypedFile(start);
   file->set_scope(scope);
   declList = file->get_scope()->get_declaration_list();

   // StartCommentBlock (ignore for now)
   //

   // ProgramUnit
   //
   std::vector<ProgramUnit*>* unitList = program->getProgramUnitList();
   for (int i = 0; i < unitList->size(); i++) {
      decl = dynamic_cast<SgUntypedDeclarationStatement*>(unitList->at(i)->getPayload());  assert(decl);
      declList->get_decl_list().push_back(decl);
   }

   program->setPayload(file);
   
#ifdef OFP_BUILD_DEBUG
   printf("build_Program: ..................... %lu\n", declList->get_decl_list().size());
#endif
#else
   printf ("UntypedASTBuilder::build_Program(): calling ROSE build functions \n");

   SgUntypedDeclarationList* declaration_list      = NULL;
   SgUntypedStatementList* statement_list          = NULL;
   SgUntypedFunctionDeclarationList* function_list = NULL;

   SgUntypedGlobalScope* globalScope = SageBuilder::buildUntypedGlobalScope(declaration_list,statement_list,function_list);

   SgUntypedFile* file = SageBuilder::buildUntypedFile(globalScope);

   program->setPayload(file);
#endif
}