... and make future reordering possibly easier related to 9a6ee577f6165dccfde424732bfc6f16f1e2811b
Unified · Split
| @@ -783,35 +783,38 @@ struct TCCState { · 782 unmodified lines | ||
| 783 | 783 | |
| 784 | 784 | #define TOK_LAND 0xa0 |
| 785 | 785 | #define TOK_LOR 0xa1 |
| 786 | − | |
| 787 | 786 | #define TOK_DEC 0xa2 |
| 788 | 787 | #define TOK_MID 0xa3 /* inc/dec, to void constant */ |
| 789 | 788 | #define TOK_INC 0xa4 |
| 790 | 789 | #define TOK_UDIV 0xb0 /* unsigned division */ |
| 791 | 790 | #define TOK_UMOD 0xb1 /* unsigned modulo */ |
| 792 | 791 | #define TOK_PDIV 0xb2 /* fast division with undefined rounding for pointers */ |
| 793 | −#define TOK_CINT 0xb3 /* number in tokc */ | |
| 794 | −#define TOK_CCHAR 0xb4 /* char constant in tokc */ | |
| 795 | −#define TOK_STR 0xb5 /* pointer to string in tokc */ | |
| 796 | −#define TOK_TWOSHARPS 0xb6 /* ## preprocessing token */ | |
| 797 | −#define TOK_LCHAR 0xb7 | |
| 798 | −#define TOK_LSTR 0xb8 | |
| 799 | −#define TOK_CFLOAT 0xb9 /* float constant */ | |
| 800 | −#define TOK_LINENUM 0xba /* line number info */ | |
| 801 | −#define TOK_CDOUBLE 0xc0 /* double constant */ | |
| 802 | −#define TOK_CLDOUBLE 0xc1 /* long double constant */ | |
| 792 | + | |
| 793 | +/* tokens that carry values (in additional token string space / tokc) --> */ | |
| 794 | +#define TOK_CCHAR 0xb3 /* char constant in tokc */ | |
| 795 | +#define TOK_LCHAR 0xb4 | |
| 796 | +#define TOK_CINT 0xb5 /* number in tokc */ | |
| 797 | +#define TOK_CUINT 0xb6 /* unsigned int constant */ | |
| 798 | +#define TOK_CLLONG 0xb7 /* long long constant */ | |
| 799 | +#define TOK_CULLONG 0xb8 /* unsigned long long constant */ | |
| 800 | +#define TOK_STR 0xb9 /* pointer to string in tokc */ | |
| 801 | +#define TOK_LSTR 0xba | |
| 802 | +#define TOK_CFLOAT 0xbb /* float constant */ | |
| 803 | +#define TOK_CDOUBLE 0xbc /* double constant */ | |
| 804 | +#define TOK_CLDOUBLE 0xbd /* long double constant */ | |
| 805 | +#define TOK_PPNUM 0xbe /* preprocessor number */ | |
| 806 | +#define TOK_LINENUM 0xbf /* line number info */ | |
| 807 | +/* <-- */ | |
| 808 | + | |
| 809 | +#define TOK_TWOSHARPS 0xc0 /* ## preprocessing token */ | |
| 803 | 810 | #define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */ |
| 804 | 811 | #define TOK_ADDC1 0xc3 /* add with carry generation */ |
| 805 | 812 | #define TOK_ADDC2 0xc4 /* add with carry use */ |
| 806 | 813 | #define TOK_SUBC1 0xc5 /* add with carry generation */ |
| 807 | 814 | #define TOK_SUBC2 0xc6 /* add with carry use */ |
| 808 | −#define TOK_CUINT 0xc8 /* unsigned int constant */ | |
| 809 | −#define TOK_CLLONG 0xc9 /* long long constant */ | |
| 810 | −#define TOK_CULLONG 0xca /* unsigned long long constant */ | |
| 811 | 815 | #define TOK_ARROW 0xcb |
| 812 | 816 | #define TOK_DOTS 0xcc /* three dots */ |
| 813 | 817 | #define TOK_SHR 0xcd /* unsigned shift right */ |
| 814 | −#define TOK_PPNUM 0xce /* preprocessor number */ | |
| 815 | 818 | #define TOK_NOSUBST 0xcf /* means following token has already been pp'd */ |
| 816 | 819 | |
| 817 | 820 | #define TOK_SHL 0x01 /* shift left */ |
| @@ -70,8 +70,33 @@ static const char tcc_keywords[] = · 69 unmodified lines | ||
| 70 | 70 | |
| 71 | 71 | /* WARNING: the content of this string encodes token numbers */ |
| 72 | 72 | static const unsigned char tok_two_chars[] = |
| 73 | +/* outdated -- gr | |
| 73 | 74 | "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253" |
| 74 | 75 | "-=\255*=\252/=\257%=\245&=\246^=\336|=\374->\313..\250##\266"; |
| 76 | +*/{ | |
| 77 | + '<','=', TOK_LE, | |
| 78 | + '>','=', TOK_GE, | |
| 79 | + '!','=', TOK_NE, | |
| 80 | + '&','&', TOK_LAND, | |
| 81 | + '|','|', TOK_LOR, | |
| 82 | + '+','+', TOK_INC, | |
| 83 | + '-','-', TOK_DEC, | |
| 84 | + '=','=', TOK_EQ, | |
| 85 | + '<','<', TOK_SHL, | |
| 86 | + '>','>', TOK_SHR, | |
| 87 | + '+','=', TOK_A_ADD, | |
| 88 | + '-','=', TOK_A_SUB, | |
| 89 | + '*','=', TOK_A_MUL, | |
| 90 | + '/','=', TOK_A_DIV, | |
| 91 | + '%','=', TOK_A_MOD, | |
| 92 | + '&','=', TOK_A_AND, | |
| 93 | + '^','=', TOK_A_XOR, | |
| 94 | + '|','=', TOK_A_OR, | |
| 95 | + '-','>', TOK_ARROW, | |
| 96 | + '.','.', 0xa8, // C++ token ? | |
| 97 | + '#','#', TOK_TWOSHARPS, | |
| 98 | + 0 | |
| 99 | +}; | |
| 75 | 100 | |
| 76 | 101 | struct macro_level { |
| 77 | 102 | struct macro_level *prev; |
| @@ -255,21 +280,19 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 177 unmodified lines | ||
| 255 | 280 | static char buf[STRING_MAX_SIZE + 1]; |
| 256 | 281 | static CString cstr_buf; |
| 257 | 282 | CString *cstr; |
| 258 | − CValue cval; | |
| 259 | 283 | char *p; |
| 260 | 284 | int i, len; |
| 261 | 285 | |
| 262 | − if (!cv) { | |
| 263 | − cval.ull = 0; | |
| 264 | − cv = &cval; | |
| 265 | − } | |
| 266 | − | |
| 267 | 286 | /* NOTE: to go faster, we give a fixed buffer for small strings */ |
| 268 | 287 | cstr_reset(&cstr_buf); |
| 269 | 288 | cstr_buf.data = buf; |
| 270 | 289 | cstr_buf.size_allocated = sizeof(buf); |
| 271 | 290 | p = buf; |
| 272 | 291 | |
| 292 | +/* just an explanation, should never happen: | |
| 293 | + if (v <= TOK_LINENUM && v >= TOK_CINT && cv == NULL) | |
| 294 | + tcc_error("internal error: get_tok_str"); */ | |
| 295 | + | |
| 273 | 296 | switch(v) { |
| 274 | 297 | case TOK_CINT: |
| 275 | 298 | case TOK_CUINT: |
| @@ -317,6 +340,15 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 41 unmodified lines | ||
| 317 | 340 | cstr_ccat(&cstr_buf, '\"'); |
| 318 | 341 | cstr_ccat(&cstr_buf, '\0'); |
| 319 | 342 | break; |
| 343 | + | |
| 344 | + case TOK_CFLOAT: | |
| 345 | + case TOK_CDOUBLE: | |
| 346 | + case TOK_CLDOUBLE: | |
| 347 | + case TOK_LINENUM: | |
| 348 | + return NULL; /* should not happen */ | |
| 349 | + | |
| 350 | + /* above tokens have value, the ones below don't */ | |
| 351 | + | |
| 320 | 352 | case TOK_LT: |
| 321 | 353 | v = '<'; |
| 322 | 354 | goto addv; |