コード例 #1
0
ファイル: cp_type.c プロジェクト: mildrock/dummy
static Declaration_t f_TypeCastToDeclaration( Type_t Type )
{
   Declaration_t Declaration;

   Declaration = f_DeclarationCreate( DECLARATION_ARGUMENT );

   Declaration->fct_specifier  = Type->fct_specifier;
   Declaration->s_ellipsis     = Type->s_ellipsis;
   Declaration->s_const        = Type->s_const;
   Declaration->s_volatile     = Type->s_volatile;
   Declaration->s_char         = Type->s_char;
   Declaration->s_short        = Type->s_short;
   Declaration->s_int          = Type->s_int;
   Declaration->s_long         = Type->s_long;
   Declaration->s_signed       = Type->s_signed;
   Declaration->s_unsigned     = Type->s_unsigned;
   Declaration->s_float        = Type->s_float;
   Declaration->s_double       = Type->s_double;
   Declaration->s_bool         = Type->s_bool;
   Declaration->s_void         = Type->s_void;
   Declaration->Name           = Type->Name;
   Declaration->Class          = Type->Class;
   Declaration->Enum           = Type->Enum;

   if( Type->Declarator )
   {
      f_ListAddLast( &Declaration->ListDeclarator, (Elem_t) Type->Declarator );
   }

   Type->Name       = 0;
   Type->Class      = 0;
   Type->Enum       = 0;
   Type->Declarator = 0;

   f_TypeDestroy( Type );

   return Declaration;
}
コード例 #2
0
ファイル: cp_statement.c プロジェクト: AndresGG/sn-8.4
extern Boolean_t f_CompoundStatement( char *types, char *names )
{
   int retval;

/* printf( "Compund Statement: (%s) (%s)\n", types, names ); */

   if( SymtabVariable == 0 )
   {
      SymtabVariable = SymtabCreate((void (*)(void*)) f_TypeDestroy );
   }

   if( SymtabClass == 0 )
   {
      SymtabClass = SymtabCreate((void (*)(void*)) f_ClassDestroy );
   }

   if( types && names )
   {
      /* feldolgozzuk a fuggveny argumentum listat */

      char *my_types, *types_beg, *types_end;
      char *my_names, *names_beg, *names_end;
      int iBreak;

      my_types = SN_StrDup( types );
      my_names = SN_StrDup( names );

      types_beg = my_types;
      names_beg = my_names;
      iBreak = False;

      while( ! iBreak )
      {
         if(( types_end = my_strchr( types_beg, ',' ))) { *types_end = 0; }
         else                                           { iBreak = True; }

         if(( names_end = my_strchr( names_beg, ',' ))) { *names_end = 0; }
         else                                           { iBreak = True; }

         if( *names_beg && types_beg[0] != '.' )
         {
            Type_t Type;

            Type = f_TypeFromString( types_beg );

            if( Type == 0 )
            {
/* 24.02.97 rigo */
/* int DEFUN(_IO_fflush, (fp), register _IO_FILE *fp ){} eseten elofordul */
/*             f_InternalError( 61 ); */
               Type = f_TypeCreateInt();
            }

            if( Type->Declarator == 0 )
            {
               Type->Declarator = f_DeclaratorCreate();
               Type->Declarator->Name = f_NameCreate( names_beg );
            }
            else
            {
               if( Type->Declarator->Name )
               {
                  f_InternalError( 62 );
               }
               else
               {
                  Type->Declarator->Name = f_NameCreate( names_beg );
               }
            }

            /* felodjuk az esetleges typedef-eket */
            Type = f_TypeBasic( Type, start_lineno_g - 1 );

            if( SymtabInsert( SymtabVariable
                            , Type->Declarator->Name->pcName
                            , (void *) Type
                            , niveauComp ))
            {
#ifdef SYMTAB_TRACE
               char acType[10000];  /* old: 1000 */

               f_TypeToString( Type, acType, 1 );
               printf( "argument type: %s ----- name: %s\n"
                     , acType
                     , Type->Declarator->Name->pcName
                     );
#endif
            }
            else
            {
               f_TypeDestroy( Type );
            }
         }

         if( ! iBreak )
         {
            types_beg = types_end + 1;
            names_beg = names_end + 1;
         }
      }

      ckfree( my_names );
      ckfree( my_types );
   }

   retval = compound_statement();

#ifdef SYMTAB_TRACE
   printf( "vor Clear\n" );
   SymtabPrint( SymtabVariable, 0 );
#endif

   SymtabClear( SymtabVariable );
   SymtabClear( SymtabClass    );

#ifdef SYMTAB_TRACE
   printf( "after Clear\n" );
   SymtabPrint( SymtabVariable, 0 );
#endif

   return retval;
}
コード例 #3
0
ファイル: cp_typename.c プロジェクト: mildrock/dummy
extern Type_t f_TypeName( char *pcTerminator )
{
   Type_t Type = f_TypeCreate();
   int iTypeSpec = 0;
   Save();
   niveau++;

/*    printf( "TypeName\n" ); */

   while( True )
   {
      switch( token( 0 ))
      {
      case SN_CLASS      :
      case SN_STRUCT     :
      case SN_UNION      :
         iTypeSpec++;
         if(( Type->Class = f_Class()) == 0 )
         {
            f_TypeDestroy( Type );
            niveau--;
            Restore();
            return 0;
         }
         break;

      case SN_ENUM       :
         iTypeSpec++;
         if(( Type->Enum = f_Enum()) == 0 )
         {
            f_TypeDestroy( Type );
            niveau--;
            Restore();
            return 0;
         }
         break;

      case SN_CHAR       : Type->s_char     = True; goto type;
      case SN_SHORT      : Type->s_short    = True; goto type;
      case SN_INT        : Type->s_int      = True; goto type;
      case SN_LONG       : Type->s_long     = True; goto type;
      case SN_SIGNED     : Type->s_signed   = True; goto type;
      case SN_UNSIGNED   : Type->s_unsigned = True; goto type;
      case SN_FLOAT      : Type->s_float    = True; goto type;
      case SN_DOUBLE     : Type->s_double   = True; goto type;
      case SN_BOOL       : Type->s_bool     = True; goto type;
      case SN_VOID       : Type->s_void     = True; goto type;
      case SN_CONST      : Type->s_const    = True; goto type;
      case SN_VOLATILE   : Type->s_volatile = True; goto type;
type:
         iTypeSpec++;
         step( 1 );
         break;

      default:
         if( iTypeSpec == 0 )
         {
            if(( Type->Name = f_CompleteClassName()))
            {
               iTypeSpec++;
               break;
            }
            else
            {
               f_TypeDestroy( Type );
               niveau--;
               Restore();
               return 0;
            }
         }
         else
         {
            if(( Type->Declarator = f_AbstractDeclarator()))
            {
               niveau--;
               return Type;
            }

            if( Type->Name == 0 )
            {
               if(( Type->Name = f_CompleteClassName()))
               {
                  iTypeSpec++;
                  break;
               }
            }

/* ha a kovetkezo token identifier, akkor nem ures abstract declaratorral van
** dolgunk, hanem atlependo identifier-ral ( peldaul: far )
*/
            if( token( 0 ) == SN_IDENTIFIER )   /* 22.02.97 rigo */
            {
               step( 1 );
               break;
            }
            
            niveau--;
            return Type;   /* empty abstract_declarator */
         }
      }
   }
}
コード例 #4
0
ファイル: cp_typename.c プロジェクト: mildrock/dummy
extern Type_t f_ConversionTypeName( void )
{
   Type_t Type = f_TypeCreate();
   int iTypeSpec = 0;
   Save();
   niveau++;

/*    printf( "ConversionTypeName\n" ); */

   while( True )
   {
      switch( token( 0 ))
      {
      case SN_CLASS      :
      case SN_STRUCT     :
      case SN_UNION      :
         iTypeSpec++;
         if(( Type->Class = f_Class()) == 0 )
         {
            f_TypeDestroy( Type );
            niveau--;
            Restore();
            return 0;
         }
         break;

      case SN_ENUM       :
         iTypeSpec++;
         if(( Type->Enum = f_Enum()) == 0 )
         {
            f_TypeDestroy( Type );
            niveau--;
            Restore();
            return 0;
         }
         break;

      case SN_CHAR       : Type->s_char     = True; goto type;
      case SN_SHORT      : Type->s_short    = True; goto type;
      case SN_INT        : Type->s_int      = True; goto type;
      case SN_LONG       : Type->s_long     = True; goto type;
      case SN_SIGNED     : Type->s_signed   = True; goto type;
      case SN_UNSIGNED   : Type->s_unsigned = True; goto type;
      case SN_FLOAT      : Type->s_float    = True; goto type;
      case SN_DOUBLE     : Type->s_double   = True; goto type;
      case SN_BOOL       : Type->s_bool     = True; goto type;
      case SN_VOID       : Type->s_void     = True; goto type;
      case SN_CONST      : Type->s_const    = True; goto type;
      case SN_VOLATILE   : Type->s_volatile = True; goto type;
type:
         iTypeSpec++;
         step( 1 );
         break;

      default:
         if( iTypeSpec == 0 )
         {
            if(( Type->Name = f_CompleteClassName()))
            {
               iTypeSpec++;
               break;
            }
            else
            {
               f_TypeDestroy( Type );
               niveau--;
               Restore();
               return 0;
            }
         }
         else
         {
            if(( Type->Declarator = f_ConversionDeclarator()))
            {
               niveau--;
               return Type;
            }

            if( Type->Name == 0 )
            {
               if(( Type->Name = f_CompleteClassName()))
               {
                  iTypeSpec++;
                  break;
               }
            }

            niveau--;
            return Type;   /* empty conversion_declarator */
         }
      }
   }
}
コード例 #5
0
ファイル: cp_type.c プロジェクト: mildrock/dummy
static Type_t TypeName( void )
{
   Type_t Type;
   Declarator_t Declarator;
   int bFirst = True;

/* printf( "TypeName: {%s}\n", pcLex ); */

   if( Token( 0 ) == '(' )
   {
      TokenStep( 1 );
      Type = TypeName();
      TokenStep( 1 );
      return Type;
   }

   Type = f_TypeCreate();

   while( True )
   {
      int t = Token( 0 );

/*    printf( "token: %d %s {%s}\n", t, TokenIdent( 0 ), pcLex ); */

      switch( t )
      {
      case SN_CONST     : Type->s_const       = True      ; goto label_1;
      case SN_VOLATILE  : Type->s_volatile    = True      ; goto label_1;
      case SN_INLINE    : Type->fct_specifier = SN_INLINE ; goto label_1;
      case SN_VIRTUAL   : Type->fct_specifier = SN_VIRTUAL; goto label_1;
label_1:
         TokenStep( 1 );
         break;

      case SN_STRUCT    : TokenStep( 1 ); break;
      case SN_UNION     : TokenStep( 1 ); break;
      case SN_CLASS     : TokenStep( 1 ); break;
      case SN_ENUM      : TokenStep( 1 ); break;
      case SN_CHAR      : Type->s_char        = True   ; goto label;
      case SN_SHORT     : Type->s_short       = True   ; goto label;
      case SN_INT       : Type->s_int         = True   ; goto label;
      case SN_LONG      : Type->s_long        = True   ; goto label;
      case SN_FLOAT     : Type->s_float       = True   ; goto label;
      case SN_DOUBLE    : Type->s_double      = True   ; goto label;
      case SN_BOOL      : Type->s_bool        = True   ; goto label;
      case SN_VOID      : Type->s_void        = True   ; goto label;
      case SN_SIGNED    : Type->s_signed      = True   ; goto label;
      case SN_UNSIGNED  : Type->s_unsigned    = True   ; goto label;
label:
         bFirst = False;
         TokenStep( 1 );
         break;

      case SN_IDENTIFIER:
         if( bFirst )
         {
            Type->Name = CompleteClassName();
/*          printf( "After complete class name: %d\n", Token( 0 ));*/
            bFirst = False;
         }
         else
         {
            if(( Declarator = AbstractDeclarator()) == 0 )
            {
               Name_t Name = CompleteClassName();

               if( Type->Name == 0 )
               {
                  Type->Name = Name;
               }
               else
               {
                  f_NameDestroy( Name );
               }
               bFirst = False;
            }
            else
            {
               if( Type->Declarator == 0 )
               {
                  Type->Declarator = Declarator;
               }
               else
               {
                  f_DeclaratorDestroy( Declarator );
               }
               return Type;
            }
         }
         break;

      case '*':
      case '&':
      case SN_CLCL:
      case '[':
      case '(':
         if( bFirst )
         {
#ifdef TEST
            f_InternalError( 55 );
#endif
            f_TypeDestroy( Type );
            return 0;
         }
         if(( Declarator = AbstractDeclarator()) == 0 )
         {
            f_InternalError( 56 );
            f_TypeDestroy( Type );
            return 0;
         }
         else
         {
            if( Type->Declarator == 0 )
            {
               Type->Declarator = Declarator;
            }
            else
            {
               f_DeclaratorDestroy( Declarator );
            }
         }
         return Type;

      default:
         if( bFirst )
         {
            f_TypeDestroy( Type );
            return 0;
         }
         return Type;
      }
   }
}