source: libcfa/prototypes.awk @ ad17ba6a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since ad17ba6a was 643a2e1, checked in by Peter A. Buhr <pabuhr@…>, 10 years ago

deal with newer built

  • Property mode set to 100644
File size: 4.4 KB
RevLine 
[2c2242c]1BEGIN {
2    FS = "("
[ad8e062]3    # order so string search is longest string
[2c2242c]4    types[0]  = "UINTMAX";                      vtypes[0]  = "unsigned long int"
5    types[1]  = "UINT16";                       vtypes[1]  = "short int"
6    types[2]  = "UINT32";                       vtypes[2]  = "int"
7    types[3]  = "UINT64";                       vtypes[3]  = "long long int"
8    types[4]  = "UINT";                         vtypes[4]  = "unsigned int"
9    types[5]  = "INTMAX";                       vtypes[5]  = "long int"
10    types[6]  = "INTPTR";                       vtypes[6]  = "int *"
11    types[7]  = "WINT";                         vtypes[7]  = "unsigned int"
12    types[8]  = "INT";                          vtypes[8]  = "int"
13    types[9]  = "ULONGLONG";                    vtypes[9]  = "unsigned long long"
14    types[10] = "ULONG";                        vtypes[10] = "unsigned long"
15    types[11] = "UNSIGNED";                     vtypes[11] = "unsigned"
16    types[12] = "COMPLEX_LONGDOUBLE";           vtypes[12] = "_Complex long double"
17    types[13] = "COMPLEX_DOUBLE";               vtypes[13] = "_Complex double"
18    types[14] = "COMPLEX_FLOAT";                vtypes[14] = "_Complex float"
19    types[15] = "LONGDOUBLEPTR";                vtypes[15] = "long double *"
20    types[16] = "LONGDOUBLE";                   vtypes[16] = "long double"
21    types[17] = "LONGLONG";                     vtypes[17] = "long long"
22    types[18] = "LONG";                         vtypes[18] = "long"
23    types[19] = "DFLOAT32";                     vtypes[19] = "_Decimal32"
24    types[20] = "DFLOAT64";                     vtypes[20] = "_Decimal64"
25    types[21] = "DFLOAT128";                    vtypes[21] = "_Decimal128"
26    types[22] = "DOUBLEPTR";                    vtypes[22] = "double *"
27    types[23] = "DOUBLE";                       vtypes[23] = "double"
28    types[24] = "FLOATPTR";                     vtypes[24] = "float *"
29    types[25] = "FLOAT";                        vtypes[25] = "float"
30    types[26] = "CONST_PTR";                    vtypes[26] = "const void *"
31    types[27] = "CONST_STRING";                 vtypes[27] = "const char *"
32    types[28] = "PTR_FN_VOID_VAR_PTR_SIZE";     vtypes[28] = ""
33    types[29] = "PTR_CONST_STRING";             vtypes[29] = "char *const"
34    types[30] = "PTRMODE_PTR";                  vtypes[30] = ""
35    types[31] = "PTRPTR";                       vtypes[31] = "void **"
36    types[32] = "PTR";                          vtypes[32] = "void *"
37    types[33] = "VOID";                         vtypes[33] = "void"
38    types[34] = "STRING";                       vtypes[34] = "char *"
39    types[35] = "FILEPTR";                      vtypes[35] = "struct _IO_FILE *"
40    types[36] = "SIZE";                         vtypes[36] = "unsigned long"
41    types[37] = "VAR";                          vtypes[37] = "..."
42    types[38] = "VALIST_ARG";                   vtypes[38] = "void **"
43    types[39] = "VALIST_REF";                   vtypes[39] = "void **"
44    types[40] = "UNWINDWORD";                   vtypes[40] = "void *"
45    types[41] = "WORD";                         vtypes[41] = ""
46    types[42] = "SSIZE";                        vtypes[42] = "long int"
47    types[43] = "PID";                          vtypes[43] = "int"
48    N = 44
[ad8e062]49} # BEGIN
[2c2242c]50
51/^BT_/ { prototypes[$1] = $1 }
52
53END {
54    printf( "#define DEF_BUILTIN(ENUM, NAME, CLASS, TYPE, LIBTYPE, BOTH_P, FALLBACK_P, NONANSI_P, ATTRS, IMPLICIT, COND) TYPE(NAME)\n" );
55    printf( "#define FUNC_SIMPLE(RETURN, NAME, ARGS...) RETURN NAME(ARGS);\n" );
56    printf( "#define BT_LAST(NAME) FUNC_SIMPLE(void, NAME)\n\n" );
57
[ad8e062]58    # generate C types for macros names
[2c2242c]59    for ( i = 0; i < N; i += 1 ) {
60        printf( "#define BT_%s %s\n", types[i], vtypes[i] )
[ad8e062]61    } # for
[2c2242c]62    printf( "\n" )
63
64    for ( prototype in prototypes ) {
65        if ( index( "BT_LAST", prototype ) == 1 ) {
66            continue
[ad8e062]67        } # if
68
[643a2e1]69        printf( "#define %s(NAME) FUNC_SIMPLE(", prototype )
70
[ad8e062]71        if ( sub( "BT_FN_", "", prototype ) == 0 ) {
[643a2e1]72            printf( "\n********** BAD MACRO NAME \"%s\" **********\n", prototype )
73            exit 0
[ad8e062]74        } # if
75
76        # generate function return type as macro
77        for ( t = 0; t < N; t += 1 ) {                  # find longest match
[2c2242c]78            type = types[t];
[ad8e062]79            if ( index( prototype, type ) == 1 ) {      # found match
[2c2242c]80                printf( "BT_%s, NAME", type )
[ad8e062]81                sub( type, "", prototype )
[2c2242c]82                break;
[ad8e062]83            } # if
84        } # for
85
86        # generate function parameter types as macro
87        if ( index( prototype, "VAR" ) != 2 ) {         # C-style empty parameters ?
88            for ( p = 0; length( prototype ) > 0; p += 1 ) { # until all parameters types are removed
89                sub( "_", "", prototype)                # remove "_"
[2c2242c]90                printf( ", ", type )
91                temp = prototype
[ad8e062]92                for ( t = 0; t < N; t += 1 ) {          # find longest match
[2c2242c]93                    type = types[t];
[ad8e062]94                    if ( index( prototype, type ) == 1 ) { # found match
[2c2242c]95                        printf( "BT_%s", type )
[ad8e062]96                        sub( type, "", prototype )
[2c2242c]97                        break;
98                    } # if
99                } # for
[ad8e062]100                if ( temp == prototype ) {              # no match found for parameter in macro table
101                    printf( "\n********** MISSING TYPE \"%s\" **********\n", prototype )
[2c2242c]102                    exit 0
103                } # if
104            } # for
105        } # if
106        printf( ")\n" )
[ad8e062]107    } # for
[2c2242c]108
[ad8e062]109    # extras
[2c2242c]110    printf( "\n#include \"builtins.def\"\n\n" );
111    printf( "typedef void ** __builtin_va_list;\n" );
112    printf( "extern const char *__PRETTY_FUNCTION__;\n" );
113    printf( "typedef int wchar_t;\n" );
[ad8e062]114} # END
Note: See TracBrowser for help on using the repository browser.