Changeset ad8e062
- Timestamp:
- Jan 25, 2015, 11:41:35 AM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
- Children:
- 643a2e1
- Parents:
- 9df2dd5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prototypes.awk
r9df2dd5 rad8e062 1 1 BEGIN { 2 2 FS = "(" 3 # order so string search is longest string 3 4 types[0] = "UINTMAX"; vtypes[0] = "unsigned long int" 4 5 types[1] = "UINT16"; vtypes[1] = "short int" … … 46 47 types[43] = "PID"; vtypes[43] = "int" 47 48 N = 44 48 } 49 } # BEGIN 49 50 50 51 /^BT_/ { prototypes[$1] = $1 } … … 55 56 printf( "#define BT_LAST(NAME) FUNC_SIMPLE(void, NAME)\n\n" ); 56 57 58 # generate C types for macros names 57 59 for ( i = 0; i < N; i += 1 ) { 58 60 printf( "#define BT_%s %s\n", types[i], vtypes[i] ) 59 } 61 } # for 60 62 printf( "\n" ) 61 63 … … 63 65 if ( index( "BT_LAST", prototype ) == 1 ) { 64 66 continue 65 } 67 } # if 68 69 if ( sub( "BT_FN_", "", prototype ) == 0 ) { 70 if ( sub( "BT_", "", prototype ) == 0 ) { 71 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype ) 72 exit 0 73 } #if 74 } # if 75 66 76 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype ) 67 68 if ( sub( "BT_FN_", "", prototype) == 0 ) 69 if ( sub( "BT_", "", prototype) == 0 ) { 70 printf( "\n********** BAD MACRO NAME **********\n" ) 71 exit 0 72 } 73 for ( t = 0; t < N; t += 1 ) { 77 78 # generate function return type as macro 79 for ( t = 0; t < N; t += 1 ) { # find longest match 74 80 type = types[t]; 75 if ( index( prototype, type ) == 1 ) { 81 if ( index( prototype, type ) == 1 ) { # found match 76 82 printf( "BT_%s, NAME", type ) 77 sub( type, "", prototype )83 sub( type, "", prototype ) 78 84 break; 79 } 80 } 81 if ( index( prototype, "VAR" ) != 2 ) { 82 for ( p = 0; length( prototype ) > 0; p += 1 ) { 83 sub( "_", "", prototype) 85 } # if 86 } # for 87 88 # generate function parameter types as macro 89 if ( index( prototype, "VAR" ) != 2 ) { # C-style empty parameters ? 90 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed 91 sub( "_", "", prototype) # remove "_" 84 92 printf( ", ", type ) 85 93 temp = prototype 86 for ( t = 0; t < N; t += 1 ) { 94 for ( t = 0; t < N; t += 1 ) { # find longest match 87 95 type = types[t]; 88 if ( index( prototype, type ) == 1 ) { 96 if ( index( prototype, type ) == 1 ) { # found match 89 97 printf( "BT_%s", type ) 90 sub( type, "", prototype )98 sub( type, "", prototype ) 91 99 break; 92 100 } # if 93 101 } # for 94 if ( temp == prototype ) { 95 printf( "\n********** MISSING TYPE **********\n")102 if ( temp == prototype ) { # no match found for parameter in macro table 103 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype ) 96 104 exit 0 97 105 } # if … … 99 107 } # if 100 108 printf( ")\n" ) 101 } 109 } # for 102 110 111 # extras 103 112 printf( "\n#include \"builtins.def\"\n\n" ); 104 113 printf( "typedef void ** __builtin_va_list;\n" ); 105 114 printf( "extern const char *__PRETTY_FUNCTION__;\n" ); 106 115 printf( "typedef int wchar_t;\n" ); 107 } 116 } # END
Note: See TracChangeset
for help on using the changeset viewer.