Changeset 1e6ea4e1
- Timestamp:
- Jun 9, 2019, 6:18:41 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 61c7239
- Parents:
- 46438e4
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/prelude/prototypes.awk
r46438e4 r1e6ea4e1 10 10 # Created On : Sat May 16 07:57:37 2015 11 11 # Last Modified By : Peter A. Buhr 12 # Last Modified On : T ue Jul 5 14:32:52 201613 # Update Count : 3 212 # Last Modified On : Thu Jun 6 20:46:28 2019 13 # Update Count : 34 14 14 # 15 15 … … 18 18 BEGIN { 19 19 FS = "[( )]" 20 21 22 types[i+=1] = "BOOL";vtypes[i] = "_Bool"23 types[i+=1] = "UINTMAX";vtypes[i] = "unsigned long int"24 types[i+=1] = "UINT16";vtypes[i] = "short int"25 types[i+=1] = "UINT32";vtypes[i] = "int"26 types[i+=1] = "UINT64";vtypes[i] = "long long int"27 types[i+=1] = "UINT";vtypes[i] = "unsigned int"28 types[i+=1] = "INTMAX";vtypes[i] = "long int"29 types[i+=1] = "INTPTR";vtypes[i] = "int *"30 types[i+=1] = "WINT";vtypes[i] = "unsigned int"31 types[i+=1] = "INT";vtypes[i] = "int"32 types[i+=1] = "ULONGLONG";vtypes[i] = "unsigned long long"33 types[i+=1] = "ULONG";vtypes[i] = "unsigned long"34 types[i+=1] = "UNSIGNED";vtypes[i] = "unsigned"35 types[i+=1] = "COMPLEX_LONGDOUBLE";vtypes[i] = "_Complex long double"36 types[i+=1] = "COMPLEX_DOUBLE";vtypes[i] = "_Complex double"37 types[i+=1] = "COMPLEX_FLOAT";vtypes[i] = "_Complex float"38 types[i+=1] = "LONGDOUBLEPTR";vtypes[i] = "long double *"39 types[i+=1] = "LONGDOUBLE";vtypes[i] = "long double"40 types[i+=1] = "LONGLONG";vtypes[i] = "long long"41 types[i+=1] = "LONG";vtypes[i] = "long"42 types[i+=1] = "DFLOAT32";vtypes[i] = "__Unsupported"43 types[i+=1] = "DFLOAT64";vtypes[i] = "__Unsupported"44 types[i+=1] = "DFLOAT128";vtypes[i] = "__Unsupported"45 types[i+=1] = "DOUBLEPTR";vtypes[i] = "double *"46 types[i+=1] = "DOUBLE";vtypes[i] = "double"47 types[i+=1] = "FLOATPTR";vtypes[i] = "float *"48 types[i+=1] = "FLOAT128X";vtypes[i] = "__Unsupported"49 types[i+=1] = "FLOAT128";vtypes[i] = "__Unsupported"50 types[i+=1] = "FLOAT64X";vtypes[i] = "__Unsupported"51 types[i+=1] = "FLOAT64";vtypes[i] = "__Unsupported"52 types[i+=1] = "FLOAT32X";vtypes[i] = "__Unsupported"53 types[i+=1] = "FLOAT32";vtypes[i] = "__Unsupported"54 types[i+=1] = "FLOAT16";vtypes[i] = "__Unsupported"55 types[i+=1] = "FLOAT";vtypes[i] = "float"56 types[i+=1] = "CONST_VPTR";vtypes[i] = "const volatile void *"57 types[i+=1] = "CONST_PTR";vtypes[i] = "const void *"58 types[i+=1] = "CONST_STRING";vtypes[i] = "const char *"59 types[i+=1] = "CONST_TM_PTR";vtypes[i] = "const struct tm *"60 61 types[i+=1] = "PTR_CONST_STRING";vtypes[i] = "char *const"62 types[i+=1] = "PTRMODE_PTR";vtypes[i] = ""63 types[i+=1] = "PTRPTR";vtypes[i] = "void **"64 types[i+=1] = "VPTR";vtypes[i] = "volatile void *"65 types[i+=1] = "PTR";vtypes[i] = "void *"66 types[i+=1] = "VOID";vtypes[i] = "void"67 types[i+=1] = "STRING";vtypes[i] = "char *"68 types[i+=1] = "FILEPTR";vtypes[i] = "struct _IO_FILE *"69 types[i+=1] = "SIZE";vtypes[i] = "unsigned long"70 types[i+=1] = "VAR";vtypes[i] = "..."71 types[i+=1] = "VALIST_ARG";vtypes[i] = "__builtin_va_list"72 types[i+=1] = "VALIST_REF";vtypes[i] = "__builtin_va_list"73 types[i+=1] = "UNWINDWORD";vtypes[i] = "void *"74 types[i+=1] = "WORD";vtypes[i] = ""75 types[i+=1] = "SSIZE";vtypes[i] = "long int"76 types[i+=1] = "PID";vtypes[i] = "int"77 types[i+=1] = "I16";vtypes[i] = "__int128"78 types[i+=1] = "I8";vtypes[i] = "long long int"79 types[i+=1] = "I4";vtypes[i] = "int"80 types[i+=1] = "I2";vtypes[i] = "short"81 types[i+=1] = "I1";vtypes[i] = "char"82 20 # order so string search is longest string 21 i=-1 22 types[i+=1] = "BOOL"; vtypes[i] = "_Bool" 23 types[i+=1] = "UINTMAX"; vtypes[i] = "unsigned long int" 24 types[i+=1] = "UINT16"; vtypes[i] = "short int" 25 types[i+=1] = "UINT32"; vtypes[i] = "int" 26 types[i+=1] = "UINT64"; vtypes[i] = "long long int" 27 types[i+=1] = "UINT"; vtypes[i] = "unsigned int" 28 types[i+=1] = "INTMAX"; vtypes[i] = "long int" 29 types[i+=1] = "INTPTR"; vtypes[i] = "int *" 30 types[i+=1] = "WINT"; vtypes[i] = "unsigned int" 31 types[i+=1] = "INT"; vtypes[i] = "int" 32 types[i+=1] = "ULONGLONG"; vtypes[i] = "unsigned long long" 33 types[i+=1] = "ULONG"; vtypes[i] = "unsigned long" 34 types[i+=1] = "UNSIGNED"; vtypes[i] = "unsigned" 35 types[i+=1] = "COMPLEX_LONGDOUBLE"; vtypes[i] = "_Complex long double" 36 types[i+=1] = "COMPLEX_DOUBLE"; vtypes[i] = "_Complex double" 37 types[i+=1] = "COMPLEX_FLOAT"; vtypes[i] = "_Complex float" 38 types[i+=1] = "LONGDOUBLEPTR"; vtypes[i] = "long double *" 39 types[i+=1] = "LONGDOUBLE"; vtypes[i] = "long double" 40 types[i+=1] = "LONGLONG"; vtypes[i] = "long long" 41 types[i+=1] = "LONG"; vtypes[i] = "long" 42 types[i+=1] = "DFLOAT32"; vtypes[i] = "__Unsupported" 43 types[i+=1] = "DFLOAT64"; vtypes[i] = "__Unsupported" 44 types[i+=1] = "DFLOAT128"; vtypes[i] = "__Unsupported" 45 types[i+=1] = "DOUBLEPTR"; vtypes[i] = "double *" 46 types[i+=1] = "DOUBLE"; vtypes[i] = "double" 47 types[i+=1] = "FLOATPTR"; vtypes[i] = "float *" 48 types[i+=1] = "FLOAT128X"; vtypes[i] = "__Unsupported" 49 types[i+=1] = "FLOAT128"; vtypes[i] = "__Unsupported" 50 types[i+=1] = "FLOAT64X"; vtypes[i] = "__Unsupported" 51 types[i+=1] = "FLOAT64"; vtypes[i] = "__Unsupported" 52 types[i+=1] = "FLOAT32X"; vtypes[i] = "__Unsupported" 53 types[i+=1] = "FLOAT32"; vtypes[i] = "__Unsupported" 54 types[i+=1] = "FLOAT16"; vtypes[i] = "__Unsupported" 55 types[i+=1] = "FLOAT"; vtypes[i] = "float" 56 types[i+=1] = "CONST_VPTR"; vtypes[i] = "const volatile void *" 57 types[i+=1] = "CONST_PTR"; vtypes[i] = "const void *" 58 types[i+=1] = "CONST_STRING"; vtypes[i] = "const char *" 59 types[i+=1] = "CONST_TM_PTR"; vtypes[i] = "const struct tm *" 60 types[i+=1] = "PTR_FN_VOID_VAR_PTR_SIZE"; vtypes[i] = "" 61 types[i+=1] = "PTR_CONST_STRING"; vtypes[i] = "char *const" 62 types[i+=1] = "PTRMODE_PTR"; vtypes[i] = "" 63 types[i+=1] = "PTRPTR"; vtypes[i] = "void **" 64 types[i+=1] = "VPTR"; vtypes[i] = "volatile void *" 65 types[i+=1] = "PTR"; vtypes[i] = "void *" 66 types[i+=1] = "VOID"; vtypes[i] = "void" 67 types[i+=1] = "STRING"; vtypes[i] = "char *" 68 types[i+=1] = "FILEPTR"; vtypes[i] = "struct _IO_FILE *" 69 types[i+=1] = "SIZE"; vtypes[i] = "unsigned long" 70 types[i+=1] = "VAR"; vtypes[i] = "..." 71 types[i+=1] = "VALIST_ARG"; vtypes[i] = "__builtin_va_list" 72 types[i+=1] = "VALIST_REF"; vtypes[i] = "__builtin_va_list" 73 types[i+=1] = "UNWINDWORD"; vtypes[i] = "void *" 74 types[i+=1] = "WORD"; vtypes[i] = "" 75 types[i+=1] = "SSIZE"; vtypes[i] = "long int" 76 types[i+=1] = "PID"; vtypes[i] = "int" 77 types[i+=1] = "I16"; vtypes[i] = "__int128" 78 types[i+=1] = "I8"; vtypes[i] = "long long int" 79 types[i+=1] = "I4"; vtypes[i] = "int" 80 types[i+=1] = "I2"; vtypes[i] = "short" 81 types[i+=1] = "I1"; vtypes[i] = "char" 82 N = i + 1 83 83 } # BEGIN 84 84 85 85 /BT_FN/ { 86 87 88 89 90 86 for (i = 1; i <= NF; i++) { 87 if( match($i, "BT_FN") != 0 ) { 88 prototypes[$i] = $i 89 } 90 } 91 91 } 92 92 93 93 END { 94 95 96 94 printf( "#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT, COND) TYPE(NAME)\n" ); 95 printf( "#define FUNC_SIMPLE(RETURN, NAME, ARGS...) RETURN NAME(ARGS);\n" ); 96 printf( "#define BT_LAST(NAME) FUNC_SIMPLE(void, NAME)\n\n" ); 97 97 98 99 98 # generate C types for macros names 99 for ( i = 0; i < N; i += 1 ) { 100 100 printf( "#define BT_%s %s\n", types[i], vtypes[i] ) 101 102 101 } # for 102 printf( "\n" ) 103 103 104 105 106 107 108 104 for ( prototype in prototypes ) { 105 # printf( "//\"%s\"\n", prototype ) 106 if ( index( "BT_LAST", prototype ) == 1 ) { 107 continue 108 } # if 109 109 110 110 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype ) 111 111 112 113 114 115 112 if ( sub( "BT_FN_", "", prototype ) == 0 ) { 113 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype ) 114 exit 0 115 } # if 116 116 117 118 119 120 121 122 123 124 125 117 # generate function return type as macro 118 for ( t = 0; t < N; t += 1 ) { # find longest match 119 type = types[t]; 120 if ( index( prototype, type ) == 1 ) { # found match 121 printf( "BT_%s, NAME", type ) 122 sub( type, "", prototype ) 123 break; 124 } # if 125 } # for 126 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 127 # generate function parameter types as macro 128 if ( index( prototype, "VAR" ) != 2 ) { # C-style empty parameters ? 129 for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed 130 sub( "_", "", prototype) # remove "_" 131 printf( ", ", type ) 132 temp = prototype 133 for ( t = 0; t < N; t += 1 ) { # find longest match 134 type = types[t]; 135 if ( index( prototype, type ) == 1 ) { # found match 136 printf( "BT_%s", type ) 137 sub( type, "", prototype ) 138 break; 139 } # if 140 } # for 141 if ( temp == prototype ) { # no match found for parameter in macro table 142 printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype ) 143 exit 0 144 } # if 145 } # for 146 } # if 147 printf( ")\n" ) 148 } # for 149 149 150 150 # extras … … 152 152 printf( "\n#include \"sync-builtins.cf\"\n\n" ); 153 153 printf( "extern const char *__PRETTY_FUNCTION__;\n" ); 154 printf( "float _Complex __builtin_complex( float, float );\n" ); 155 printf( "double _Complex __builtin_complex( double, double );\n" ); 156 printf( "long double _Complex __builtin_complex( long double, long double );\n" ); 154 157 } # END 155 158
Note: See TracChangeset
for help on using the changeset viewer.