Changeset 8d6155e9 for src/prelude/prototypes.awk
- Timestamp:
- Feb 2, 2017, 4:39:39 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 0c82fec4
- Parents:
- 7d6639d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/prelude/prototypes.awk
r7d6639d r8d6155e9 17 17 18 18 BEGIN { 19 FS = "("19 FS = "[( )]" 20 20 # order so string search is longest string 21 types[0] = "UINTMAX"; vtypes[0] = "unsigned long int" 22 types[1] = "UINT16"; vtypes[1] = "short int" 23 types[2] = "UINT32"; vtypes[2] = "int" 24 types[3] = "UINT64"; vtypes[3] = "long long int" 25 types[4] = "UINT"; vtypes[4] = "unsigned int" 26 types[5] = "INTMAX"; vtypes[5] = "long int" 27 types[6] = "INTPTR"; vtypes[6] = "int *" 28 types[7] = "WINT"; vtypes[7] = "unsigned int" 29 types[8] = "INT"; vtypes[8] = "int" 30 types[9] = "ULONGLONG"; vtypes[9] = "unsigned long long" 31 types[10] = "ULONG"; vtypes[10] = "unsigned long" 32 types[11] = "UNSIGNED"; vtypes[11] = "unsigned" 33 types[12] = "COMPLEX_LONGDOUBLE"; vtypes[12] = "_Complex long double" 34 types[13] = "COMPLEX_DOUBLE"; vtypes[13] = "_Complex double" 35 types[14] = "COMPLEX_FLOAT"; vtypes[14] = "_Complex float" 36 types[15] = "LONGDOUBLEPTR"; vtypes[15] = "long double *" 37 types[16] = "LONGDOUBLE"; vtypes[16] = "long double" 38 types[17] = "LONGLONG"; vtypes[17] = "long long" 39 types[18] = "LONG"; vtypes[18] = "long" 40 types[19] = "DFLOAT32"; vtypes[19] = "_Decimal32" 41 types[20] = "DFLOAT64"; vtypes[20] = "_Decimal64" 42 types[21] = "DFLOAT128"; vtypes[21] = "_Decimal128" 43 types[22] = "DOUBLEPTR"; vtypes[22] = "double *" 44 types[23] = "DOUBLE"; vtypes[23] = "double" 45 types[24] = "FLOATPTR"; vtypes[24] = "float *" 46 types[25] = "FLOAT"; vtypes[25] = "float" 47 types[26] = "CONST_PTR"; vtypes[26] = "const void *" 48 types[27] = "CONST_STRING"; vtypes[27] = "const char *" 49 types[28] = "PTR_FN_VOID_VAR_PTR_SIZE"; vtypes[28] = "" 50 types[29] = "PTR_CONST_STRING"; vtypes[29] = "char *const" 51 types[30] = "PTRMODE_PTR"; vtypes[30] = "" 52 types[31] = "PTRPTR"; vtypes[31] = "void **" 53 types[32] = "PTR"; vtypes[32] = "void *" 54 types[33] = "VOID"; vtypes[33] = "void" 55 types[34] = "STRING"; vtypes[34] = "char *" 56 types[35] = "FILEPTR"; vtypes[35] = "struct _IO_FILE *" 57 types[36] = "SIZE"; vtypes[36] = "unsigned long" 58 types[37] = "VAR"; vtypes[37] = "..." 59 types[38] = "VALIST_ARG"; vtypes[38] = "__builtin_va_list" 60 types[39] = "VALIST_REF"; vtypes[39] = "__builtin_va_list" 61 types[40] = "UNWINDWORD"; vtypes[40] = "void *" 62 types[41] = "WORD"; vtypes[41] = "" 63 types[42] = "SSIZE"; vtypes[42] = "long int" 64 types[43] = "PID"; vtypes[43] = "int" 65 N = 44 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 66 83 } # BEGIN 67 84 68 /^BT_/ { prototypes[$1] = $1 } 85 /BT_FN/ { 86 for (i = 1; i <= NF; i++) { 87 if( match($i, "BT_FN") != 0 ) { 88 prototypes[$i] = $i 89 } 90 } 91 } 69 92 70 93 END { … … 80 103 81 104 for ( prototype in prototypes ) { 82 if ( index( "BT_LAST", prototype ) == 1 ) { 83 continue 84 } # if 105 # printf( "//\"%s\"\n", prototype ) 106 if ( index( "BT_LAST", prototype ) == 1 ) { 107 continue 108 } # if 85 109 86 110 printf( "#define %s(NAME) FUNC_SIMPLE(", prototype ) 87 111 88 89 90 91 112 if ( sub( "BT_FN_", "", prototype ) == 0 ) { 113 printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype ) 114 exit 0 115 } # if 92 116 93 94 95 96 97 98 99 100 101 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 102 126 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 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" ) 124 148 } # for 125 149
Note: See TracChangeset
for help on using the changeset viewer.