//========================================================================================
// R501 type-declaration-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_TypeDeclarationStmt(TypeDeclarationStmt * typeDeclarationStmt)
{
#if 0
   Sg_File_Info * start = NULL;
   SgUntypedType * type  = NULL;
   SgUntypedVariableDeclaration * stmt = NULL;
   SgUntypedInitializedNameList * parameters = NULL;

   // DeclarationTypeSpec 
   //
   type = isSgUntypedType(typeDeclarationStmt->getDeclarationTypeSpec()->getPayload());
   start = type->get_startOfConstruct();

   stmt = new SgUntypedVariableDeclaration(start, type);
#if UNPARSER_AVAILABLE
   stmt->set_has_unparse(true);
#endif

   if (typeDeclarationStmt->getLabel()) stmt->set_label_string(typeDeclarationStmt->getLabel()->getValue());
   stmt->set_parameters(new SgUntypedInitializedNameList(start));

#ifdef OFP_BUILD_DEBUG
   printf("build_TypeDeclarationStmt: .........\n");
#endif

   // OptAttrSpecList
   //TODO-CER- implement
   //

   // EntityDeclList
   //
   std::vector<EntityDecl*>* declList = typeDeclarationStmt->getEntityDeclList()->getEntityDeclList();

   //TODO-CER-2014.3.7 should this be variables or parameters?
#ifdef OFP_BUILD_DEBUG
   printf("               parameters: ......... ");
#endif
   parameters = stmt->get_parameters();
   for (unsigned int i = 0; i < declList->size(); i++) {
      std::string name = declList->at(i)->getObjectName()->getIdent()->getName();
      parameters->get_name_list().push_back(new SgUntypedInitializedName(start, type, name));
#ifdef OFP_BUILD_DEBUG
      printf("%s ", name.c_str());
#endif
   }
#ifdef OFP_BUILD_DEBUG
   printf("\n");
#endif

   typeDeclarationStmt->setPayload(stmt);
#endif
}
Exemple #2
0
//========================================================================================
// R501 type-declaration-stmt
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_TypeDeclarationStmt(TypeDeclarationStmt * typeDeclarationStmt)
{
   Sg_File_Info * start = NULL;
   SgUntypedType * type  = NULL;
   SgUntypedVariableDeclaration * stmt = NULL;
   SgUntypedInitializedNameList * parameters = NULL;

   // DeclarationTypeSpec 
   //
   type = isSgUntypedType(typeDeclarationStmt->getDeclarationTypeSpec()->getPayload());
   start = type->get_startOfConstruct();

   stmt = new SgUntypedVariableDeclaration(start, type);
   if (typeDeclarationStmt->getLabel()) stmt->set_label_string(typeDeclarationStmt->getLabel()->getValue());
   stmt->set_parameters(new SgUntypedInitializedNameList(start));

   printf("build_TypeDeclarationStmt: .........\n");

   // OptAttrSpecList
   //TODO-CER- implement
   //

   // EntityDeclList
   //
   std::vector<EntityDecl*>* declList = typeDeclarationStmt->getEntityDeclList()->getEntityDeclList();

#ifdef NOT_NEEDED
   if (declSpec->getOptionType() == DeclarationTypeSpec::DeclarationTypeSpec_ITS) {
      IntrinsicTypeSpec* ispec = declSpec->getIntrinsicTypeSpec();
      if (ispec->getOptionType() == IntrinsicTypeSpec::IntrinsicTypeSpec_INT) {
         type = new SgUntypedType(start, false); 
         //TODO - set intrinsic type (FORTRAN_INTEGER)
         printf("                type_spec: ......... INTEGER\n");
      }
   }
#endif

   //TODO-CER-2014.3.7 should this be variables or parameters?
   printf("               parameters: ......... ");
   parameters = stmt->get_parameters();
   for (int i = 0; i < declList->size(); i++) {
      std::string name = declList->at(i)->getObjectName()->getIdent()->getName();
      parameters->get_name_list().push_back(new SgUntypedInitializedName(start, type, name));
      printf("%s ", name.c_str());
   }
   printf("\n");

   typeDeclarationStmt->setPayload(stmt);
}