source: libcfa/prototypes.awk @ 6e952ec

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 6e952ec was 2c2242c, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

deal with newer built

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