History

tccpp: reorder some tokens

... and make future reordering possibly easier related to 9a6ee577f6165dccfde424732bfc6f16f1e2811b

grischka committed 12 years ago

Commit 0ac8aaa1 parent 10750872 files · +56 −21Browse files

Unified · Split

2 files
  1. tcc.h +18 −15
  2. tccpp.c +38 −6
tcc.h+18−15
@@ -783,35 +783,38 @@ struct TCCState { · 782 unmodified lines
783783
784784 #define TOK_LAND 0xa0
785785 #define TOK_LOR 0xa1
786−
787786 #define TOK_DEC 0xa2
788787 #define TOK_MID 0xa3 /* inc/dec, to void constant */
789788 #define TOK_INC 0xa4
790789 #define TOK_UDIV 0xb0 /* unsigned division */
791790 #define TOK_UMOD 0xb1 /* unsigned modulo */
792791 #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 */
803810 #define TOK_UMULL 0xc2 /* unsigned 32x32 -> 64 mul */
804811 #define TOK_ADDC1 0xc3 /* add with carry generation */
805812 #define TOK_ADDC2 0xc4 /* add with carry use */
806813 #define TOK_SUBC1 0xc5 /* add with carry generation */
807814 #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 */
811815 #define TOK_ARROW 0xcb
812816 #define TOK_DOTS 0xcc /* three dots */
813817 #define TOK_SHR 0xcd /* unsigned shift right */
814−#define TOK_PPNUM 0xce /* preprocessor number */
815818 #define TOK_NOSUBST 0xcf /* means following token has already been pp'd */
816819
817820 #define TOK_SHL 0x01 /* shift left */
tccpp.c+38−6
@@ -70,8 +70,33 @@ static const char tcc_keywords[] = · 69 unmodified lines
7070
7171 /* WARNING: the content of this string encodes token numbers */
7272 static const unsigned char tok_two_chars[] =
73+/* outdated -- gr
7374 "<=\236>=\235!=\225&&\240||\241++\244--\242==\224<<\1>>\2+=\253"
7475 "-=\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+};
75100
76101 struct macro_level {
77102 struct macro_level *prev;
@@ -255,21 +280,19 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 177 unmodified lines
255280 static char buf[STRING_MAX_SIZE + 1];
256281 static CString cstr_buf;
257282 CString *cstr;
258− CValue cval;
259283 char *p;
260284 int i, len;
261285
262− if (!cv) {
263− cval.ull = 0;
264− cv = &cval;
265− }
266−
267286 /* NOTE: to go faster, we give a fixed buffer for small strings */
268287 cstr_reset(&cstr_buf);
269288 cstr_buf.data = buf;
270289 cstr_buf.size_allocated = sizeof(buf);
271290 p = buf;
272291
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+
273296 switch(v) {
274297 case TOK_CINT:
275298 case TOK_CUINT:
@@ -317,6 +340,15 @@ ST_FUNC char *get_tok_str(int v, CValue *cv) · 41 unmodified lines
317340 cstr_ccat(&cstr_buf, '\"');
318341 cstr_ccat(&cstr_buf, '\0');
319342 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+
320352 case TOK_LT:
321353 v = '<';
322354 goto addv;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t