Beispiel #1
0
//========================================================================================
// R1103 end-program-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_EndProgramStmt(EndProgramStmt * endProgramStmt)
{
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = new SgUntypedNamedStatement(start);
   stmt->set_statement_enum(SgToken::FORTRAN_END_PROGRAM);

   if (endProgramStmt->getLabel())       stmt->set_label_string  (endProgramStmt->getLabel()->getValue());
   if (endProgramStmt->getProgramName()) stmt->set_statement_name(endProgramStmt->getProgramName()->getIdent()->getValue());

   endProgramStmt->setPayload(stmt);
}
Beispiel #2
0
//========================================================================================
// R1233 subroutine-subprogram
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_SubroutineSubprogram(SubroutineSubprogram * subroutineSubprogram)
{
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = NULL;
   SgUntypedDeclarationList* sgDeclList = NULL;
   SgUntypedStatementList* sgStmtList = NULL;
   SgUntypedSubroutineDeclaration * subroutine = NULL;

   // SubroutineStmt
   //
   if (subroutineSubprogram->getSubroutineStmt()) {
      subroutine = dynamic_cast<SgUntypedSubroutineDeclaration*>(subroutineSubprogram->getSubroutineStmt()->getPayload());
      assert(subroutine);
   }

   printf("build_MainSubroutine label: ........ %s\n", subroutine->get_label_string().c_str());
   printf("             begin name: ........... %s\n", subroutine->get_name().c_str());

   // SpecificationPart
   //
   SpecificationPart * specPart = subroutineSubprogram->getSpecificationPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   subroutine->get_scope()->set_declaration_list(sgDeclList);

   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());

   // ExecutionPart
   //
   ExecutionPart * execPart = subroutineSubprogram->getExecutionPart();
   sgStmtList = dynamic_cast<SgUntypedStatementList*>(execPart->givePayload());  assert(sgStmtList);
   subroutine->get_scope()->set_statement_list(sgStmtList);

   printf("         exec_list_size: ........... %lu\n", sgStmtList->get_stmt_list().size());

   // InternalSubprogramPart
   //
   InternalSubprogramPart * isubPart = subroutineSubprogram->getInternalSubprogramPart();
   if (isubPart) {
      SgUntypedFunctionDeclarationList* sgFuncList;
      sgFuncList = dynamic_cast<SgUntypedFunctionDeclarationList*>(isubPart->givePayload());  assert(sgFuncList);
      subroutine->get_scope()->set_function_list(sgFuncList);
   }

   // EndSubroutineStmt
   //
   stmt = dynamic_cast<SgUntypedNamedStatement*>(subroutineSubprogram->getEndSubroutineStmt()->getPayload());  assert(stmt);
   subroutine->set_end_statement(stmt);

   printf("              end label: ........... %s\n", stmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", stmt->get_statement_name().c_str());

   subroutineSubprogram->setPayload(subroutine);
}
//========================================================================================
// R1106 end-module-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_EndModuleStmt(EndModuleStmt* endModuleStmt)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = new SgUntypedNamedStatement(start);
   stmt->set_statement_enum(SgToken::FORTRAN_END_MODULE);

   if (endModuleStmt->getLabel())       stmt->set_label_string  (endModuleStmt->getLabel()->getValue());
   if (endModuleStmt->getModuleName()) stmt->set_statement_name(endModuleStmt->getModuleName()->getIdent()->getValue());

   endModuleStmt->setPayload(stmt);
#endif
}
Beispiel #4
0
//========================================================================================
// R1236 end-subroutine-stmt
//----------------------------------------------------------------------------------------
void  UntypedASTBuilder::build_EndSubroutineStmt(EndSubroutineStmt * endSubroutineStmt)
{
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = new SgUntypedNamedStatement(start);
   stmt->set_statement_enum(SgToken::FORTRAN_END_SUBROUTINE);

   if (endSubroutineStmt->getLabel()) {
      stmt->set_label_string  (endSubroutineStmt->getLabel()->getValue());
   }
   if (endSubroutineStmt->getSubroutineName()) {
      stmt->set_statement_name(endSubroutineStmt->getSubroutineName()->getIdent()->getValue());
   }

   endSubroutineStmt->setPayload(stmt);
}
//========================================================================================
// R1232 end-function-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_EndFunctionStmt(EndFunctionStmt* endFunctionStmt)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = new SgUntypedNamedStatement(start);
   stmt->set_statement_enum(SgToken::FORTRAN_END_FUNCTION);

   if (endFunctionStmt->getLabel()) {
      stmt->set_label_string  (endFunctionStmt->getLabel()->getValue());
   }
   if (endFunctionStmt->getFunctionName()) {
      stmt->set_statement_name(endFunctionStmt->getFunctionName()->getIdent()->getValue());
   }

   endFunctionStmt->setPayload(stmt);
#endif
}
//========================================================================================
// R1239 end-mp-subprogram-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_EndMpSubprogramStmt(EndMpSubprogramStmt* endMpSubprogramStmt)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = new SgUntypedNamedStatement(start);
   stmt->set_statement_enum(SgToken::FORTRAN_END_MP_SUBPROGRAM);

   if (endMpSubprogramStmt->getLabel()) {
      stmt->set_label_string  (endMpSubprogramStmt->getLabel()->getValue());
   }
   if (endMpSubprogramStmt->getProcedureName()) {
      stmt->set_statement_name(endMpSubprogramStmt->getProcedureName()->getIdent()->getValue());
   }

   endMpSubprogramStmt->setPayload(stmt);
#endif
}
Beispiel #7
0
//========================================================================================
// R1101 main-program
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_MainProgram(MainProgram * mainProgram)
{
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = NULL;
   SgUntypedDeclarationList* sgDeclList = NULL;
   SgUntypedStatementList* sgStmtList = NULL;
   SgUntypedProgramHeaderDeclaration * program = NULL;

   // ProgramStmt
   //
   if (mainProgram->getProgramStmt()) {
      program = dynamic_cast<SgUntypedProgramHeaderDeclaration*>(mainProgram->getProgramStmt()->getPayload());  assert(program);
   }
   else {
      // no optional ProgramStmt
      SgUntypedFunctionScope * scope = new SgUntypedFunctionScope(NULL);
      scope->set_declaration_list(new SgUntypedDeclarationList(NULL));  
      scope->set_statement_list(new SgUntypedStatementList(NULL));  
      scope->set_function_list(new SgUntypedFunctionDeclarationList(NULL));  

      program = new SgUntypedProgramHeaderDeclaration(NULL, "");
      program->set_statement_enum(SgToken::FORTRAN_PROGRAM);
      program->set_scope(scope);
   }

   printf("build_MainProgram label: ........... %s\n", program->get_label_string().c_str());
   printf("             begin name: ........... %s\n", program->get_name().c_str());

   // SpecificationPart
   //
   SpecificationPart * specPart = mainProgram->getSpecificationPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   program->get_scope()->set_declaration_list(sgDeclList);

   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());

   // ExecutionPart
   //
   ExecutionPart * execPart = mainProgram->getExecutionPart();
   sgStmtList = dynamic_cast<SgUntypedStatementList*>(execPart->givePayload());  assert(sgStmtList);
   program->get_scope()->set_statement_list(sgStmtList);

   printf("         exec_list_size: ........... %lu\n", sgStmtList->get_stmt_list().size());

   // InternalSubprogramPart
   //
   InternalSubprogramPart * isubPart = mainProgram->getInternalSubprogramPart();
   if (isubPart) {
      SgUntypedFunctionDeclarationList* sgFuncList;
      sgFuncList = dynamic_cast<SgUntypedFunctionDeclarationList*>(isubPart->givePayload());  assert(sgFuncList);
      program->get_scope()->set_function_list(sgFuncList);
   }

   // EndProgramStmt
   //
   stmt = dynamic_cast<SgUntypedNamedStatement*>(mainProgram->getEndProgramStmt()->getPayload());  assert(stmt);
   program->set_end_statement(stmt);

   printf("              end label: ........... %s\n", stmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", stmt->get_statement_name().c_str());

   mainProgram->setPayload(program);
}
//========================================================================================
// R1233 subroutine-subprogram
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_SubroutineSubprogram(SubroutineSubprogram * subroutineSubprogram)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = NULL;
   SgUntypedDeclarationList* sgDeclList = NULL;
   SgUntypedStatementList* sgStmtList = NULL;
   SgUntypedSubroutineDeclaration * subroutine = NULL;

   // SubroutineStmt
   //
   subroutine = dynamic_cast<SgUntypedSubroutineDeclaration*>(subroutineSubprogram->getSubroutineStmt()->getPayload());
   assert(subroutine);
   start = subroutine->get_startOfConstruct();
   subroutine->set_scope(new SgUntypedFunctionScope(start));

#ifdef OFP_BUILD_DEBUG
   printf("build_Subroutine  label: ........... %s\n", subroutine->get_label_string().c_str());
   printf("             begin name: ........... %s\n", subroutine->get_name().c_str());
#endif

   // InitialSpecPart
   //
   InitialSpecPart * specPart = subroutineSubprogram->getInitialSpecPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   subroutine->get_scope()->set_declaration_list(sgDeclList);

#ifdef OFP_BUILD_DEBUG
   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());
#endif

   // SpecAndExecPart
   //
   SpecAndExecPart * execPart = subroutineSubprogram->getSpecAndExecPart();
   sgStmtList = dynamic_cast<SgUntypedStatementList*>(execPart->givePayload());  assert(sgStmtList);
   subroutine->get_scope()->set_statement_list(sgStmtList);

#ifdef OFP_BUILD_DEBUG
   printf("         exec_list_size: ........... %lu\n", sgStmtList->get_stmt_list().size());
#endif

   // InternalSubprogramPart
   //
   InternalSubprogramPart * isubPart = subroutineSubprogram->getInternalSubprogramPart();
   if (isubPart) {
      SgUntypedFunctionDeclarationList* sgFuncList;
      sgFuncList = dynamic_cast<SgUntypedFunctionDeclarationList*>(isubPart->givePayload());  assert(sgFuncList);
      subroutine->get_scope()->set_function_list(sgFuncList);
   }
   else {
      subroutine->get_scope()->set_function_list(new SgUntypedFunctionDeclarationList(NULL));  
   }

   // EndSubroutineStmt
   //
   stmt = dynamic_cast<SgUntypedNamedStatement*>(subroutineSubprogram->getEndSubroutineStmt()->getPayload());  assert(stmt);
   subroutine->set_end_statement(stmt);

#ifdef OFP_BUILD_DEBUG
   printf("              end label: ........... %s\n", stmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", stmt->get_statement_name().c_str());
#endif

   subroutineSubprogram->setPayload(subroutine);
#endif
}
//========================================================================================
// R1227 function-subprogram
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_FunctionSubprogram(FunctionSubprogram* functionSubprogram)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = NULL;
   SgUntypedDeclarationList* sgDeclList = NULL;
   SgUntypedStatementList* sgStmtList = NULL;
   SgUntypedFunctionDeclaration * function = NULL;

   // FunctionStmt
   //
   function = dynamic_cast<SgUntypedFunctionDeclaration*>(functionSubprogram->getFunctionStmt()->getPayload());
   assert(function);
   start = function->get_startOfConstruct();
   function->set_scope(new SgUntypedFunctionScope(start));
#if UNPARSER_AVAILABLE
   function->set_has_unparse(true);
#endif

#ifdef OFP_BUILD_DEBUG
   printf("build_Function    label: ........... %s\n", function->get_label_string().c_str());
   printf("             begin name: ........... %s\n", function->get_name().c_str());
#endif

   // InitialSpecPart
   //
   InitialSpecPart * specPart = functionSubprogram->getInitialSpecPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   function->get_scope()->set_declaration_list(sgDeclList);

#ifdef OFP_BUILD_DEBUG
   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());
#endif

   // SpecAndExecPart
   //
   SpecAndExecPart * execPart = functionSubprogram->getSpecAndExecPart();
   sgStmtList = dynamic_cast<SgUntypedStatementList*>(execPart->givePayload());  assert(sgStmtList);
   function->get_scope()->set_statement_list(sgStmtList);

#ifdef OFP_BUILD_DEBUG
   printf("         exec_list_size: ........... %lu\n", sgStmtList->get_stmt_list().size());
#endif

   // InternalSubprogramPart
   //
   InternalSubprogramPart * isubPart = functionSubprogram->getInternalSubprogramPart();
   if (isubPart) {
      SgUntypedFunctionDeclarationList* sgFuncList;
      sgFuncList = dynamic_cast<SgUntypedFunctionDeclarationList*>(isubPart->givePayload());  assert(sgFuncList);
      function->get_scope()->set_function_list(sgFuncList);
   }
   else {
      function->get_scope()->set_function_list(new SgUntypedFunctionDeclarationList(NULL));
   }

   // EndFunctionStmt
   //
   stmt = dynamic_cast<SgUntypedNamedStatement*>(functionSubprogram->getEndFunctionStmt()->getPayload());  assert(stmt);
   function->set_end_statement(stmt);

#ifdef OFP_BUILD_DEBUG
   printf("              end label: ........... %s\n", stmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", stmt->get_statement_name().c_str());
#endif

   functionSubprogram->setPayload(function);
#endif
}
//========================================================================================
// R1104 module
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_Module(Module* module)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * endStmt = NULL;
   SgUntypedDeclarationList * sgDeclList = NULL;
   SgUntypedModuleDeclaration * sgModule = NULL;

   // ModuleStmt
   //
   sgModule = dynamic_cast<SgUntypedModuleDeclaration*>(module->getModuleStmt()->getPayload());  assert(sgModule);
   start = sgModule->get_startOfConstruct();
   sgModule->set_scope(new SgUntypedModuleScope(start));
#if UNPARSER_AVAILABLE
   sgModule->set_has_unparse(true);
#endif

#ifdef OFP_BUILD_DEBUG
   printf("build_Module label: ................ %s\n", sgModule->get_label_string().c_str());
#if 0
// DQ (9/10/2014): Need to add name data member for SgUntypedModuleDeclaration.
   printf("             begin name: ........... %s\n", sgModule->get_name().c_str());
#endif
#endif

   // SpecificationPart
   //
   SpecificationPart * specPart = module->getSpecificationPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   sgModule->get_scope()->set_declaration_list(sgDeclList);

#ifdef OFP_BUILD_DEBUG
   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());
#endif

   // ModuleSubprogramPart
   //
   ModuleSubprogramPart * msubPart = module->getModuleSubprogramPart();
   if (msubPart) {
      SgUntypedScope * msubScope = dynamic_cast<SgUntypedScope*>(msubPart->givePayload());  assert(msubScope);
      sgModule->get_scope()->set_statement_list(msubScope->get_statement_list());
      sgModule->get_scope()->set_function_list (msubScope->get_function_list());
   }
   else {
      sgModule->get_scope()->set_statement_list(new SgUntypedStatementList(NULL));
      sgModule->get_scope()->set_function_list (new SgUntypedFunctionDeclarationList(NULL));
   }

   // EndModuleStmt
   //
   endStmt = dynamic_cast<SgUntypedNamedStatement*>(module->getEndModuleStmt()->getPayload());  assert(endStmt);
   sgModule->set_end_statement(endStmt);

#ifdef OFP_BUILD_DEBUG
   printf("              end label: ........... %s\n", endStmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", endStmt->get_statement_name().c_str());
#endif

   module->setPayload(sgModule);
#endif
}
//========================================================================================
// R1101 main-program
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_MainProgram(MainProgram * mainProgram)
{
#ifdef TODO_ROSE
   Sg_File_Info * start = NULL;
   SgUntypedNamedStatement * stmt = NULL;
   SgUntypedDeclarationList* sgDeclList = NULL;
   SgUntypedStatementList* sgStmtList = NULL;
   SgUntypedProgramHeaderDeclaration * program = NULL;

   // ProgramStmt
   //
   if (mainProgram->getProgramStmt()) {
      program = dynamic_cast<SgUntypedProgramHeaderDeclaration*>(mainProgram->getProgramStmt()->getPayload());  assert(program);
   }
   else {
      // no optional ProgramStmt
      program = new SgUntypedProgramHeaderDeclaration(NULL, "");
      program->set_statement_enum(SgToken::FORTRAN_PROGRAM);
   }
   program->set_scope(new SgUntypedFunctionScope(start));
#if UNPARSER_AVAILABLE
   program->set_has_unparse(true);
#endif

#ifdef OFP_BUILD_DEBUG
   printf("build_MainProgram label: ........... %s\n", program->get_label_string().c_str());
   printf("             begin name: ........... %s\n", program->get_name().c_str());
#endif

   // InitialSpecPart
   //
   InitialSpecPart * specPart = mainProgram->getInitialSpecPart();
   sgDeclList = dynamic_cast<SgUntypedDeclarationList*>(specPart->givePayload());  assert(sgDeclList);
   program->get_scope()->set_declaration_list(sgDeclList);

#ifdef OFP_BUILD_DEBUG
   printf("         spec_list_size: ........... %lu\n", sgDeclList->get_decl_list().size());
#endif

   // SpecAndExecPart
   //
   SpecAndExecPart * execPart = mainProgram->getSpecAndExecPart();
   sgStmtList = dynamic_cast<SgUntypedStatementList*>(execPart->givePayload());  assert(sgStmtList);
   program->get_scope()->set_statement_list(sgStmtList);

#ifdef OFP_BUILD_DEBUG
   printf("         exec_list_size: ........... %lu\n", sgStmtList->get_stmt_list().size());
#endif

   // InternalSubprogramPart
   //
   InternalSubprogramPart * isubPart = mainProgram->getInternalSubprogramPart();
   if (isubPart) {
      SgUntypedScope * isubScope = dynamic_cast<SgUntypedScope*>(isubPart->givePayload());  assert(isubScope);
      SgUntypedStatementList * sgStmtList = isubScope->get_statement_list();
      SgUntypedFunctionDeclarationList * sgFuncList = isubScope->get_function_list();

      // has one contains stmt
      SgUntypedStatement * contains = sgStmtList->get_stmt_list().front();
      program->get_scope()->get_statement_list()->get_stmt_list().push_back(contains);
      program->get_scope()->set_function_list(sgFuncList);
      sgStmtList->get_stmt_list().clear();
   }
   else {
      program->get_scope()->set_function_list(new SgUntypedFunctionDeclarationList(NULL));
   }

   // EndProgramStmt
   //
   stmt = dynamic_cast<SgUntypedNamedStatement*>(mainProgram->getEndProgramStmt()->getPayload());  assert(stmt);
   program->set_end_statement(stmt);

#ifdef OFP_BUILD_DEBUG
   printf("              end label: ........... %s\n", stmt->get_label_string().c_str());
   printf("              end  name: ........... %s\n", stmt->get_statement_name().c_str());
#endif

   mainProgram->setPayload(program);
#else
   printf ("UntypedASTBuilder::build_MainProgram(): commented out! \n");
#endif
}