extern void f_TypeDelPointer( Type_t Type ) { Oper_t Oper; if( Type == 0 ) { f_InternalError( 33 ); return; } if( Type->s_unknown ) return; if( Type->Declarator ) { if(( Oper = (Oper_t) d_ElemFirst( Type->Declarator->ListOper ))) { if( Oper->type == POINTER_STAR || Oper->type == POINTER_AMPERSAND ) { f_ListRemoveFirst( Type->Declarator->ListOper ); f_OperDestroy( Oper ); } } } }
static void TemplateArgList( char *pname ) { int i = 1; TokenStep( 1 ); strcat( pname, "<" ); while( i > 0 ) { switch( Token( 0 )) { case '>': i--; break; case '<': i++; break; case 0: f_InternalError( 71 ); i = 0; break; } f_Strcat( pname, TokenIdent( 0 )); TokenStep( 1 ); } return; }
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; }
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; } } }