//========================================================================================
// R407 int-literal-constant
//----------------------------------------------------------------------------------------
void UntypedASTBuilder::build_IntLiteralConstant(IntLiteralConstant * intLiteralConstant)
{
#if 0
   OFP::KindParam * kindParam = intLiteralConstant->getKindParam();

   SgUntypedValueExpression * expr = dynamic_cast<SgUntypedValueExpression*>(intLiteralConstant->getPayload());
   SgUntypedType * type = expr->get_type();
   type->set_is_literal(true);
   type->set_is_constant(true);
   //TODO-DQ-2014.3.7 ok for a type to have a keyword
   //type->set_keyword(SgToken::FORTRAN_INTEGER);

   if (kindParam) {
      SgUntypedValueExpression* kind = dynamic_cast<SgUntypedValueExpression*>(kindParam->getPayload());
      type->set_type_kind(kind);
   }

#ifdef OFP_BUILD_DEBUG
   printf("build_IntLiteralConstant ........... ");
#if UNPARSER_AVAILABLE
   unparser->unparseExpr(expr);  printf("\n");
#endif
#endif
#endif
}
//========================================================================================
// 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
}
Example #3
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);
}