* jcf-io.c (find_class): Use saw_java_source to determine when to
[official-gcc.git] / gcc / java / parse.c
blob0d0f964714de840f3bdb20f757b300cedc5d2c41
2 /* A Bison parser, made from gcc/java/parse.y
3 by GNU Bison version 1.25
4 */
6 #define YYBISON 1 /* Identify Bison output. */
8 #define yyparse java_parse
9 #define yylex java_lex
10 #define yyerror java_error
11 #define yylval java_lval
12 #define yychar java_char
13 #define yydebug java_debug
14 #define yynerrs java_nerrs
15 #define PLUS_TK 258
16 #define MINUS_TK 259
17 #define MULT_TK 260
18 #define DIV_TK 261
19 #define REM_TK 262
20 #define LS_TK 263
21 #define SRS_TK 264
22 #define ZRS_TK 265
23 #define AND_TK 266
24 #define XOR_TK 267
25 #define OR_TK 268
26 #define BOOL_AND_TK 269
27 #define BOOL_OR_TK 270
28 #define EQ_TK 271
29 #define NEQ_TK 272
30 #define GT_TK 273
31 #define GTE_TK 274
32 #define LT_TK 275
33 #define LTE_TK 276
34 #define PLUS_ASSIGN_TK 277
35 #define MINUS_ASSIGN_TK 278
36 #define MULT_ASSIGN_TK 279
37 #define DIV_ASSIGN_TK 280
38 #define REM_ASSIGN_TK 281
39 #define LS_ASSIGN_TK 282
40 #define SRS_ASSIGN_TK 283
41 #define ZRS_ASSIGN_TK 284
42 #define AND_ASSIGN_TK 285
43 #define XOR_ASSIGN_TK 286
44 #define OR_ASSIGN_TK 287
45 #define PUBLIC_TK 288
46 #define PRIVATE_TK 289
47 #define PROTECTED_TK 290
48 #define STATIC_TK 291
49 #define FINAL_TK 292
50 #define SYNCHRONIZED_TK 293
51 #define VOLATILE_TK 294
52 #define TRANSIENT_TK 295
53 #define NATIVE_TK 296
54 #define PAD_TK 297
55 #define ABSTRACT_TK 298
56 #define MODIFIER_TK 299
57 #define DECR_TK 300
58 #define INCR_TK 301
59 #define DEFAULT_TK 302
60 #define IF_TK 303
61 #define THROW_TK 304
62 #define BOOLEAN_TK 305
63 #define DO_TK 306
64 #define IMPLEMENTS_TK 307
65 #define THROWS_TK 308
66 #define BREAK_TK 309
67 #define IMPORT_TK 310
68 #define ELSE_TK 311
69 #define INSTANCEOF_TK 312
70 #define RETURN_TK 313
71 #define VOID_TK 314
72 #define CATCH_TK 315
73 #define INTERFACE_TK 316
74 #define CASE_TK 317
75 #define EXTENDS_TK 318
76 #define FINALLY_TK 319
77 #define SUPER_TK 320
78 #define WHILE_TK 321
79 #define CLASS_TK 322
80 #define SWITCH_TK 323
81 #define CONST_TK 324
82 #define TRY_TK 325
83 #define FOR_TK 326
84 #define NEW_TK 327
85 #define CONTINUE_TK 328
86 #define GOTO_TK 329
87 #define PACKAGE_TK 330
88 #define THIS_TK 331
89 #define BYTE_TK 332
90 #define SHORT_TK 333
91 #define INT_TK 334
92 #define LONG_TK 335
93 #define CHAR_TK 336
94 #define INTEGRAL_TK 337
95 #define FLOAT_TK 338
96 #define DOUBLE_TK 339
97 #define FP_TK 340
98 #define ID_TK 341
99 #define REL_QM_TK 342
100 #define REL_CL_TK 343
101 #define NOT_TK 344
102 #define NEG_TK 345
103 #define ASSIGN_ANY_TK 346
104 #define ASSIGN_TK 347
105 #define OP_TK 348
106 #define CP_TK 349
107 #define OCB_TK 350
108 #define CCB_TK 351
109 #define OSB_TK 352
110 #define CSB_TK 353
111 #define SC_TK 354
112 #define C_TK 355
113 #define DOT_TK 356
114 #define STRING_LIT_TK 357
115 #define CHAR_LIT_TK 358
116 #define INT_LIT_TK 359
117 #define FP_LIT_TK 360
118 #define TRUE_TK 361
119 #define FALSE_TK 362
120 #define BOOL_LIT_TK 363
121 #define NULL_TK 364
123 #line 49 "gcc/java/parse.y"
125 #include <stdio.h>
126 #include <stdlib.h>
127 #include <string.h>
128 #include <dirent.h>
129 #ifdef __STDC__
130 #include <stdarg.h>
131 #else
132 #include <varargs.h>
133 #endif
135 #include "config.h"
136 #include "tree.h"
137 #include "rtl.h"
138 #include "obstack.h"
139 #include "toplev.h"
140 #include "flags.h"
141 #include "java-tree.h"
142 #include "jcf.h"
143 #include "lex.h"
144 #include "parse.h"
145 #include "zipfile.h"
147 /* Number of error found so far. */
148 int java_error_count;
149 /* Number of warning found so far. */
150 int java_warning_count;
152 /* The current parser context */
153 static struct parser_ctxt *ctxp;
155 /* List of things that were anlyzed for which code will be generated */
156 static struct parser_ctxt *ctxp_for_generation = NULL;
158 /* binop_lookup maps token to tree_code. It is used where binary
159 operations are involved and required by the parser. RDIV_EXPR
160 covers both integral/floating point division. The code is changed
161 once the type of both operator is worked out. */
163 static enum tree_code binop_lookup[19] =
165 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
166 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
167 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
168 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
169 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
171 #define BINOP_LOOKUP(VALUE) \
172 binop_lookup [((VALUE) - PLUS_TK)% \
173 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
175 /* Fake WFL used to report error message. It is initialized once if
176 needed and reused with it's location information is overriden. */
177 static tree wfl_operator = NULL_TREE;
179 /* The "$L" identifier we use to create labels. */
180 static tree label_id = NULL_TREE;
182 /* The "StringBuffer" identifier used for the String `+' operator. */
183 static tree wfl_string_buffer = NULL_TREE;
185 /* The "append" identifier used for String `+' operator. */
186 static tree wfl_append = NULL_TREE;
188 /* The "toString" identifier used for String `+' operator. */
189 static tree wfl_to_string = NULL_TREE;
191 #line 117 "gcc/java/parse.y"
192 typedef union {
193 tree node;
194 int sub_token;
195 struct {
196 int token;
197 int location;
198 } operator;
199 int value;
200 } YYSTYPE;
201 #ifndef YYDEBUG
202 #define YYDEBUG 1
203 #endif
205 #include <stdio.h>
207 #ifndef __cplusplus
208 #ifndef __STDC__
209 #define const
210 #endif
211 #endif
215 #define YYFINAL 775
216 #define YYFLAG -32768
217 #define YYNTBASE 110
219 #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 262)
221 static const char yytranslate[] = { 0,
222 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
223 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
224 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
225 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
226 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
227 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
228 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
229 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
230 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
231 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
232 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
233 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
234 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
235 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
236 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
237 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
238 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
239 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
240 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
241 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
242 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
243 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
244 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
245 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
246 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
247 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
248 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
249 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
250 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
251 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
252 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
253 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
254 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
255 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
256 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
257 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
258 106, 107, 108, 109
261 #if YYDEBUG != 0
262 static const short yyprhs[] = { 0,
263 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
264 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
265 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
266 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
267 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
268 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
269 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
270 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
271 229, 231, 233, 235, 237, 239, 241, 245, 250, 252,
272 256, 260, 262, 266, 270, 275, 277, 281, 284, 288,
273 292, 294, 296, 297, 301, 304, 308, 312, 317, 322,
274 325, 329, 332, 336, 339, 343, 348, 352, 356, 360,
275 362, 366, 370, 373, 377, 380, 384, 385, 388, 391,
276 393, 397, 401, 403, 406, 408, 411, 415, 417, 421,
277 426, 431, 437, 441, 446, 449, 453, 457, 462, 467,
278 473, 481, 488, 490, 492, 493, 498, 499, 505, 506,
279 512, 513, 520, 524, 529, 532, 536, 539, 543, 546,
280 550, 552, 555, 557, 559, 561, 563, 565, 568, 571,
281 574, 578, 582, 587, 589, 593, 597, 600, 601, 606,
282 608, 611, 613, 615, 617, 620, 623, 627, 629, 631,
283 633, 635, 637, 639, 641, 643, 645, 647, 649, 651,
284 653, 655, 657, 659, 661, 663, 665, 667, 669, 671,
285 673, 676, 679, 682, 685, 688, 691, 694, 697, 701,
286 706, 711, 717, 722, 728, 735, 743, 750, 752, 754,
287 756, 758, 760, 762, 764, 770, 773, 777, 782, 790,
288 798, 801, 806, 809, 813, 819, 822, 826, 830, 835,
289 837, 840, 843, 845, 847, 850, 854, 857, 860, 864,
290 867, 872, 875, 878, 882, 887, 890, 892, 900, 908,
291 915, 919, 925, 930, 938, 945, 948, 951, 955, 958,
292 959, 961, 963, 966, 967, 969, 971, 975, 979, 982,
293 986, 989, 993, 996, 1000, 1003, 1007, 1010, 1014, 1017,
294 1021, 1025, 1028, 1032, 1038, 1044, 1047, 1052, 1056, 1058,
295 1062, 1066, 1071, 1074, 1076, 1079, 1082, 1087, 1090, 1094,
296 1099, 1102, 1105, 1107, 1109, 1111, 1113, 1117, 1119, 1121,
297 1123, 1125, 1129, 1133, 1137, 1141, 1145, 1149, 1153, 1157,
298 1163, 1168, 1175, 1181, 1186, 1192, 1198, 1205, 1209, 1213,
299 1218, 1224, 1227, 1231, 1235, 1239, 1241, 1245, 1249, 1253,
300 1257, 1262, 1267, 1272, 1277, 1281, 1285, 1287, 1290, 1294,
301 1298, 1301, 1304, 1308, 1312, 1316, 1320, 1323, 1327, 1332,
302 1338, 1345, 1351, 1358, 1363, 1368, 1373, 1378, 1382, 1387,
303 1391, 1396, 1398, 1400, 1402, 1404, 1407, 1410, 1412, 1414,
304 1417, 1420, 1422, 1425, 1428, 1431, 1434, 1437, 1440, 1442,
305 1445, 1448, 1450, 1453, 1456, 1462, 1467, 1472, 1478, 1483,
306 1486, 1492, 1497, 1503, 1505, 1509, 1513, 1517, 1521, 1525,
307 1529, 1531, 1535, 1539, 1543, 1547, 1549, 1553, 1557, 1561,
308 1565, 1569, 1573, 1575, 1579, 1583, 1587, 1591, 1595, 1599,
309 1603, 1607, 1611, 1615, 1617, 1621, 1625, 1629, 1633, 1635,
310 1639, 1643, 1645, 1649, 1653, 1655, 1659, 1663, 1665, 1669,
311 1673, 1675, 1679, 1683, 1685, 1691, 1696, 1700, 1706, 1708,
312 1710, 1714, 1718, 1720, 1722, 1724, 1726, 1728, 1730
315 static const short yyrhs[] = { 123,
316 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
317 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
318 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
319 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
320 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
321 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
322 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
323 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
324 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
325 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
326 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
327 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
328 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
329 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
330 163, 0, 99, 0, 1, 0, 44, 0, 131, 44,
331 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
332 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
333 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
334 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
335 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
336 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
337 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
338 0, 139, 140, 0, 141, 0, 156, 0, 158, 0,
339 176, 0, 142, 0, 147, 0, 132, 0, 163, 0,
340 112, 143, 99, 0, 131, 112, 143, 99, 0, 144,
341 0, 143, 100, 144, 0, 143, 100, 1, 0, 145,
342 0, 145, 92, 146, 0, 145, 92, 1, 0, 145,
343 92, 146, 1, 0, 122, 0, 145, 97, 98, 0,
344 122, 1, 0, 145, 97, 1, 0, 145, 98, 1,
345 0, 260, 0, 174, 0, 0, 149, 148, 155, 0,
346 149, 1, 0, 112, 150, 153, 0, 59, 150, 153,
347 0, 131, 112, 150, 153, 0, 131, 59, 150, 153,
348 0, 112, 1, 0, 131, 112, 1, 0, 59, 1,
349 0, 131, 59, 1, 0, 131, 1, 0, 122, 93,
350 94, 0, 122, 93, 151, 94, 0, 150, 97, 98,
351 0, 122, 93, 1, 0, 150, 97, 1, 0, 152,
352 0, 151, 100, 152, 0, 151, 100, 1, 0, 112,
353 145, 0, 131, 112, 145, 0, 112, 1, 0, 131,
354 112, 1, 0, 0, 53, 154, 0, 53, 1, 0,
355 116, 0, 154, 100, 116, 0, 154, 100, 1, 0,
356 176, 0, 176, 99, 0, 99, 0, 157, 176, 0,
357 157, 176, 99, 0, 44, 0, 159, 153, 160, 0,
358 131, 159, 153, 160, 0, 159, 153, 160, 99, 0,
359 131, 159, 153, 160, 99, 0, 120, 93, 94, 0,
360 120, 93, 151, 94, 0, 95, 96, 0, 95, 161,
361 96, 0, 95, 178, 96, 0, 95, 161, 178, 96,
362 0, 162, 93, 94, 99, 0, 162, 93, 229, 94,
363 99, 0, 119, 101, 65, 93, 229, 94, 99, 0,
364 119, 101, 65, 93, 94, 99, 0, 76, 0, 65,
365 0, 0, 61, 122, 164, 169, 0, 0, 131, 61,
366 122, 165, 169, 0, 0, 61, 122, 168, 166, 169,
367 0, 0, 131, 61, 122, 168, 167, 169, 0, 61,
368 122, 1, 0, 131, 61, 122, 1, 0, 63, 117,
369 0, 168, 100, 117, 0, 63, 1, 0, 168, 100,
370 1, 0, 95, 96, 0, 95, 170, 96, 0, 171,
371 0, 170, 171, 0, 172, 0, 173, 0, 132, 0,
372 163, 0, 142, 0, 149, 99, 0, 149, 1, 0,
373 95, 96, 0, 95, 175, 96, 0, 95, 100, 96,
374 0, 95, 175, 100, 96, 0, 146, 0, 175, 100,
375 146, 0, 175, 100, 1, 0, 95, 96, 0, 0,
376 95, 177, 178, 96, 0, 179, 0, 178, 179, 0,
377 180, 0, 182, 0, 132, 0, 181, 99, 0, 112,
378 143, 0, 131, 112, 143, 0, 184, 0, 187, 0,
379 191, 0, 192, 0, 203, 0, 207, 0, 184, 0,
380 188, 0, 193, 0, 204, 0, 208, 0, 176, 0,
381 185, 0, 189, 0, 194, 0, 206, 0, 214, 0,
382 215, 0, 216, 0, 218, 0, 217, 0, 220, 0,
383 99, 0, 122, 88, 0, 186, 182, 0, 122, 1,
384 0, 186, 183, 0, 190, 99, 0, 1, 99, 0,
385 1, 95, 0, 1, 96, 0, 162, 93, 1, 0,
386 162, 93, 94, 1, 0, 162, 93, 229, 1, 0,
387 162, 93, 229, 94, 1, 0, 119, 101, 65, 1,
388 0, 119, 101, 65, 93, 1, 0, 119, 101, 65,
389 93, 229, 1, 0, 119, 101, 65, 93, 229, 94,
390 1, 0, 119, 101, 65, 93, 94, 1, 0, 257,
391 0, 241, 0, 242, 0, 238, 0, 239, 0, 235,
392 0, 227, 0, 48, 93, 260, 94, 182, 0, 48,
393 1, 0, 48, 93, 1, 0, 48, 93, 260, 1,
394 0, 48, 93, 260, 94, 183, 56, 182, 0, 48,
395 93, 260, 94, 183, 56, 183, 0, 195, 196, 0,
396 68, 93, 260, 94, 0, 68, 1, 0, 68, 93,
397 1, 0, 68, 93, 260, 94, 1, 0, 95, 96,
398 0, 95, 200, 96, 0, 95, 197, 96, 0, 95,
399 197, 200, 96, 0, 198, 0, 197, 198, 0, 199,
400 178, 0, 200, 0, 201, 0, 200, 201, 0, 62,
401 261, 88, 0, 47, 88, 0, 62, 1, 0, 62,
402 261, 1, 0, 47, 1, 0, 66, 93, 260, 94,
403 0, 202, 182, 0, 66, 1, 0, 66, 93, 1,
404 0, 66, 93, 260, 1, 0, 202, 183, 0, 51,
405 0, 205, 182, 66, 93, 260, 94, 99, 0, 210,
406 99, 260, 99, 212, 94, 182, 0, 210, 99, 99,
407 212, 94, 182, 0, 210, 99, 1, 0, 210, 99,
408 260, 99, 1, 0, 210, 99, 99, 1, 0, 210,
409 99, 260, 99, 212, 94, 183, 0, 210, 99, 99,
410 212, 94, 183, 0, 71, 93, 0, 71, 1, 0,
411 71, 93, 1, 0, 209, 211, 0, 0, 213, 0,
412 181, 0, 213, 1, 0, 0, 213, 0, 190, 0,
413 213, 100, 190, 0, 213, 100, 1, 0, 54, 99,
414 0, 54, 122, 99, 0, 54, 1, 0, 54, 122,
415 1, 0, 73, 99, 0, 73, 122, 99, 0, 73,
416 1, 0, 73, 122, 1, 0, 58, 99, 0, 58,
417 260, 99, 0, 58, 1, 0, 58, 260, 1, 0,
418 49, 260, 99, 0, 49, 1, 0, 49, 260, 1,
419 0, 219, 93, 260, 94, 176, 0, 219, 93, 260,
420 94, 1, 0, 219, 1, 0, 219, 93, 1, 94,
421 0, 219, 93, 1, 0, 44, 0, 70, 176, 221,
422 0, 70, 176, 224, 0, 70, 176, 221, 224, 0,
423 70, 1, 0, 222, 0, 221, 222, 0, 223, 176,
424 0, 60, 93, 152, 94, 0, 60, 1, 0, 60,
425 93, 1, 0, 60, 93, 1, 94, 0, 64, 176,
426 0, 64, 1, 0, 226, 0, 230, 0, 111, 0,
427 76, 0, 93, 260, 94, 0, 227, 0, 234, 0,
428 235, 0, 236, 0, 119, 101, 67, 0, 113, 101,
429 67, 0, 59, 101, 67, 0, 119, 101, 76, 0,
430 93, 260, 1, 0, 119, 101, 1, 0, 113, 101,
431 1, 0, 59, 101, 1, 0, 72, 116, 93, 229,
432 94, 0, 72, 116, 93, 94, 0, 72, 116, 93,
433 229, 94, 138, 0, 72, 116, 93, 94, 138, 0,
434 228, 122, 93, 94, 0, 228, 122, 93, 94, 138,
435 0, 228, 122, 93, 229, 94, 0, 228, 122, 93,
436 229, 94, 138, 0, 72, 1, 99, 0, 72, 116,
437 1, 0, 72, 116, 93, 1, 0, 72, 116, 93,
438 229, 1, 0, 228, 1, 0, 228, 122, 1, 0,
439 119, 101, 72, 0, 225, 101, 72, 0, 260, 0,
440 229, 100, 260, 0, 229, 100, 1, 0, 72, 113,
441 231, 0, 72, 115, 231, 0, 72, 113, 231, 233,
442 0, 72, 115, 231, 233, 0, 72, 115, 233, 174,
443 0, 72, 113, 233, 174, 0, 72, 1, 98, 0,
444 72, 1, 97, 0, 232, 0, 231, 232, 0, 97,
445 260, 98, 0, 97, 260, 1, 0, 97, 1, 0,
446 97, 98, 0, 233, 97, 98, 0, 233, 97, 1,
447 0, 225, 101, 122, 0, 65, 101, 122, 0, 65,
448 1, 0, 119, 93, 94, 0, 119, 93, 229, 94,
449 0, 225, 101, 122, 93, 94, 0, 225, 101, 122,
450 93, 229, 94, 0, 65, 101, 122, 93, 94, 0,
451 65, 101, 122, 93, 229, 94, 0, 65, 101, 1,
452 94, 0, 65, 101, 1, 101, 0, 119, 97, 260,
453 98, 0, 226, 97, 260, 98, 0, 119, 97, 1,
454 0, 119, 97, 260, 1, 0, 226, 97, 1, 0,
455 226, 97, 260, 1, 0, 225, 0, 119, 0, 238,
456 0, 239, 0, 237, 46, 0, 237, 45, 0, 241,
457 0, 242, 0, 3, 240, 0, 4, 240, 0, 243,
458 0, 3, 1, 0, 4, 1, 0, 46, 240, 0,
459 46, 1, 0, 45, 240, 0, 45, 1, 0, 237,
460 0, 89, 240, 0, 90, 240, 0, 244, 0, 89,
461 1, 0, 90, 1, 0, 93, 113, 233, 94, 240,
462 0, 93, 113, 94, 240, 0, 93, 260, 94, 243,
463 0, 93, 119, 233, 94, 243, 0, 93, 113, 97,
464 1, 0, 93, 1, 0, 93, 113, 233, 94, 1,
465 0, 93, 113, 94, 1, 0, 93, 119, 233, 94,
466 1, 0, 240, 0, 245, 5, 240, 0, 245, 6,
467 240, 0, 245, 7, 240, 0, 245, 5, 1, 0,
468 245, 6, 1, 0, 245, 7, 1, 0, 245, 0,
469 246, 3, 245, 0, 246, 4, 245, 0, 246, 3,
470 1, 0, 246, 4, 1, 0, 246, 0, 247, 8,
471 246, 0, 247, 9, 246, 0, 247, 10, 246, 0,
472 247, 8, 1, 0, 247, 9, 1, 0, 247, 10,
473 1, 0, 247, 0, 248, 20, 247, 0, 248, 18,
474 247, 0, 248, 21, 247, 0, 248, 19, 247, 0,
475 248, 57, 114, 0, 248, 20, 1, 0, 248, 18,
476 1, 0, 248, 21, 1, 0, 248, 19, 1, 0,
477 248, 57, 1, 0, 248, 0, 249, 16, 248, 0,
478 249, 17, 248, 0, 249, 16, 1, 0, 249, 17,
479 1, 0, 249, 0, 250, 11, 249, 0, 250, 11,
480 1, 0, 250, 0, 251, 12, 250, 0, 251, 12,
481 1, 0, 251, 0, 252, 13, 251, 0, 252, 13,
482 1, 0, 252, 0, 253, 14, 252, 0, 253, 14,
483 1, 0, 253, 0, 254, 15, 253, 0, 254, 15,
484 1, 0, 254, 0, 254, 87, 260, 88, 255, 0,
485 254, 87, 88, 1, 0, 254, 87, 1, 0, 254,
486 87, 260, 88, 1, 0, 255, 0, 257, 0, 258,
487 259, 256, 0, 258, 259, 1, 0, 119, 0, 234,
488 0, 236, 0, 91, 0, 92, 0, 256, 0, 260,
492 #endif
494 #if YYDEBUG != 0
495 static const short yyrline[] = { 0,
496 271, 277, 279, 280, 281, 282, 283, 287, 289, 292,
497 294, 295, 298, 300, 303, 307, 311, 315, 321, 323,
498 325, 327, 332, 334, 337, 341, 346, 351, 353, 354,
499 355, 356, 357, 358, 359, 362, 367, 373, 375, 378,
500 381, 383, 387, 389, 392, 422, 424, 428, 441, 443,
501 447, 453, 454, 456, 466, 471, 486, 490, 493, 496,
502 499, 501, 503, 505, 509, 511, 513, 515, 519, 521,
503 523, 530, 536, 541, 545, 548, 552, 554, 557, 559,
504 560, 561, 565, 567, 568, 570, 575, 578, 588, 591,
505 593, 597, 600, 607, 613, 621, 623, 625, 627, 629,
506 633, 635, 640, 647, 659, 663, 666, 668, 670, 672,
507 674, 676, 678, 680, 687, 690, 692, 697, 699, 703,
508 708, 713, 717, 722, 724, 726, 733, 735, 737, 741,
509 744, 746, 750, 752, 753, 758, 763, 769, 781, 786,
510 792, 797, 806, 808, 811, 813, 814, 815, 819, 821,
511 824, 826, 830, 838, 849, 853, 856, 859, 862, 865,
512 868, 871, 874, 876, 880, 886, 891, 893, 897, 900,
513 904, 906, 909, 911, 912, 914, 918, 922, 928, 933,
514 938, 942, 946, 952, 954, 955, 960, 963, 966, 973,
515 975, 978, 980, 982, 986, 990, 993, 997, 999, 1000,
516 1001, 1002, 1003, 1013, 1015, 1016, 1017, 1018, 1021, 1023,
517 1024, 1025, 1026, 1027, 1028, 1029, 1030, 1031, 1032, 1035,
518 1040, 1051, 1058, 1062, 1073, 1083, 1089, 1095, 1101, 1103,
519 1105, 1107, 1109, 1111, 1113, 1115, 1117, 1121, 1123, 1124,
520 1125, 1126, 1127, 1128, 1131, 1134, 1136, 1138, 1142, 1147,
521 1152, 1160, 1166, 1168, 1170, 1174, 1177, 1179, 1181, 1190,
522 1192, 1199, 1204, 1213, 1215, 1222, 1228, 1233, 1235, 1237,
523 1241, 1249, 1252, 1254, 1256, 1260, 1265, 1274, 1279, 1282,
524 1289, 1291, 1293, 1297, 1300, 1309, 1316, 1318, 1322, 1335,
525 1337, 1343, 1349, 1353, 1355, 1359, 1362, 1364, 1368, 1371,
526 1373, 1375, 1379, 1382, 1384, 1386, 1390, 1393, 1395, 1397,
527 1401, 1407, 1409, 1413, 1420, 1422, 1424, 1426, 1430, 1438,
528 1441, 1443, 1445, 1449, 1451, 1458, 1466, 1483, 1485, 1487,
529 1491, 1497, 1502, 1504, 1507, 1509, 1511, 1513, 1514, 1515,
530 1516, 1520, 1522, 1524, 1529, 1531, 1533, 1535, 1537, 1541,
531 1544, 1549, 1551, 1556, 1557, 1558, 1559, 1560, 1562, 1564,
532 1566, 1568, 1570, 1574, 1576, 1579, 1585, 1590, 1594, 1597,
533 1599, 1601, 1605, 1607, 1609, 1611, 1615, 1618, 1622, 1628,
534 1630, 1638, 1641, 1643, 1647, 1650, 1658, 1662, 1665, 1667,
535 1672, 1677, 1686, 1699, 1701, 1705, 1708, 1710, 1715, 1720,
536 1725, 1732, 1734, 1735, 1736, 1739, 1744, 1749, 1751, 1752,
537 1754, 1756, 1757, 1759, 1763, 1766, 1770, 1773, 1777, 1779,
538 1781, 1783, 1784, 1786, 1790, 1798, 1800, 1802, 1814, 1816,
539 1822, 1824, 1826, 1830, 1832, 1837, 1842, 1847, 1849, 1851,
540 1855, 1857, 1862, 1867, 1869, 1873, 1875, 1880, 1885, 1890,
541 1892, 1894, 1898, 1900, 1905, 1910, 1915, 1920, 1921, 1923,
542 1925, 1927, 1929, 1933, 1935, 1940, 1945, 1947, 1951, 1953,
543 1958, 1962, 1964, 1969, 1973, 1975, 1980, 1984, 1986, 1991,
544 1995, 1997, 2002, 2006, 2008, 2009, 2015, 2017, 2021, 2023,
545 2026, 2029, 2037, 2039, 2040, 2043, 2045, 2048, 2052
547 #endif
550 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
552 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
553 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
554 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
555 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
556 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
557 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
558 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
559 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
560 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
561 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
562 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
563 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
564 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
565 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
566 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
567 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
568 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
569 "class_type","interface_type","array_type","name","simple_name","qualified_name",
570 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
571 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
572 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
573 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
574 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
575 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
576 "method_declarator","formal_parameter_list","formal_parameter","throws","class_type_list",
577 "method_body","static_initializer","static","constructor_declaration","constructor_declarator",
578 "constructor_body","explicit_constructor_invocation","this_or_super","interface_declaration",
579 "@4","@5","@6","@7","extends_interfaces","interface_body","interface_member_declarations",
580 "interface_member_declaration","constant_declaration","abstract_method_declaration",
581 "array_initializer","variable_initializers","block","@8","block_statements",
582 "block_statement","local_variable_declaration_statement","local_variable_declaration",
583 "statement","statement_nsi","statement_without_trailing_substatement","empty_statement",
584 "label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
585 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
586 "switch_statement","switch_expression","switch_block","switch_block_statement_groups",
587 "switch_block_statement_group","group_of_labels","switch_labels","switch_label",
588 "while_expression","while_statement","while_statement_nsi","do_statement_begin",
589 "do_statement","for_statement","for_statement_nsi","for_header","for_begin",
590 "for_init","for_update","statement_expression_list","break_statement","continue_statement",
591 "return_statement","throw_statement","synchronized_statement","synchronized",
592 "try_statement","catches","catch_clause","catch_clause_parameter","finally",
593 "primary","primary_no_new_array","class_instance_creation_expression","something_dot_new",
594 "argument_list","array_creation_expression","dim_exprs","dim_expr","dims","field_access",
595 "method_invocation","array_access","postfix_expression","post_increment_expression",
596 "post_decrement_expression","unary_expression","pre_increment_expression","pre_decrement_expression",
597 "unary_expression_not_plus_minus","cast_expression","multiplicative_expression",
598 "additive_expression","shift_expression","relational_expression","equality_expression",
599 "and_expression","exclusive_or_expression","inclusive_or_expression","conditional_and_expression",
600 "conditional_or_expression","conditional_expression","assignment_expression",
601 "assignment","left_hand_side","assignment_operator","expression","constant_expression", NULL
603 #endif
605 static const short yyr1[] = { 0,
606 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
607 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
608 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
609 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
610 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
611 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
612 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
613 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
614 140, 140, 141, 141, 141, 141, 142, 142, 143, 143,
615 143, 144, 144, 144, 144, 145, 145, 145, 145, 145,
616 146, 146, 148, 147, 147, 149, 149, 149, 149, 149,
617 149, 149, 149, 149, 150, 150, 150, 150, 150, 151,
618 151, 151, 152, 152, 152, 152, 153, 153, 153, 154,
619 154, 154, 155, 155, 155, 156, 156, 157, 158, 158,
620 158, 158, 159, 159, 160, 160, 160, 160, 161, 161,
621 161, 161, 162, 162, 164, 163, 165, 163, 166, 163,
622 167, 163, 163, 163, 168, 168, 168, 168, 169, 169,
623 170, 170, 171, 171, 171, 171, 172, 173, 173, 174,
624 174, 174, 174, 175, 175, 175, 176, 177, 176, 178,
625 178, 179, 179, 179, 180, 181, 181, 182, 182, 182,
626 182, 182, 182, 183, 183, 183, 183, 183, 184, 184,
627 184, 184, 184, 184, 184, 184, 184, 184, 184, 185,
628 186, 187, 187, 188, 189, 189, 189, 189, 189, 189,
629 189, 189, 189, 189, 189, 189, 189, 190, 190, 190,
630 190, 190, 190, 190, 191, 191, 191, 191, 192, 193,
631 194, 195, 195, 195, 195, 196, 196, 196, 196, 197,
632 197, 198, 199, 200, 200, 201, 201, 201, 201, 201,
633 202, 203, 203, 203, 203, 204, 205, 206, 207, 207,
634 207, 207, 207, 208, 208, 209, 209, 209, 210, 211,
635 211, 211, 211, 212, 212, 213, 213, 213, 214, 214,
636 214, 214, 215, 215, 215, 215, 216, 216, 216, 216,
637 217, 217, 217, 218, 218, 218, 218, 218, 219, 220,
638 220, 220, 220, 221, 221, 222, 223, 223, 223, 223,
639 224, 224, 225, 225, 226, 226, 226, 226, 226, 226,
640 226, 226, 226, 226, 226, 226, 226, 226, 226, 227,
641 227, 227, 227, 227, 227, 227, 227, 227, 227, 227,
642 227, 227, 227, 228, 228, 229, 229, 229, 230, 230,
643 230, 230, 230, 230, 230, 230, 231, 231, 232, 232,
644 232, 233, 233, 233, 234, 234, 234, 235, 235, 235,
645 235, 235, 235, 235, 235, 236, 236, 236, 236, 236,
646 236, 237, 237, 237, 237, 238, 239, 240, 240, 240,
647 240, 240, 240, 240, 241, 241, 242, 242, 243, 243,
648 243, 243, 243, 243, 244, 244, 244, 244, 244, 244,
649 244, 244, 244, 245, 245, 245, 245, 245, 245, 245,
650 246, 246, 246, 246, 246, 247, 247, 247, 247, 247,
651 247, 247, 248, 248, 248, 248, 248, 248, 248, 248,
652 248, 248, 248, 249, 249, 249, 249, 249, 250, 250,
653 250, 251, 251, 251, 252, 252, 252, 253, 253, 253,
654 254, 254, 254, 255, 255, 255, 255, 255, 256, 256,
655 257, 257, 258, 258, 258, 259, 259, 260, 261
658 static const short yyr2[] = { 0,
659 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
660 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
661 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
662 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
663 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
664 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
665 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
666 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
667 1, 1, 1, 1, 1, 1, 3, 4, 1, 3,
668 3, 1, 3, 3, 4, 1, 3, 2, 3, 3,
669 1, 1, 0, 3, 2, 3, 3, 4, 4, 2,
670 3, 2, 3, 2, 3, 4, 3, 3, 3, 1,
671 3, 3, 2, 3, 2, 3, 0, 2, 2, 1,
672 3, 3, 1, 2, 1, 2, 3, 1, 3, 4,
673 4, 5, 3, 4, 2, 3, 3, 4, 4, 5,
674 7, 6, 1, 1, 0, 4, 0, 5, 0, 5,
675 0, 6, 3, 4, 2, 3, 2, 3, 2, 3,
676 1, 2, 1, 1, 1, 1, 1, 2, 2, 2,
677 3, 3, 4, 1, 3, 3, 2, 0, 4, 1,
678 2, 1, 1, 1, 2, 2, 3, 1, 1, 1,
679 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
680 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
681 2, 2, 2, 2, 2, 2, 2, 2, 3, 4,
682 4, 5, 4, 5, 6, 7, 6, 1, 1, 1,
683 1, 1, 1, 1, 5, 2, 3, 4, 7, 7,
684 2, 4, 2, 3, 5, 2, 3, 3, 4, 1,
685 2, 2, 1, 1, 2, 3, 2, 2, 3, 2,
686 4, 2, 2, 3, 4, 2, 1, 7, 7, 6,
687 3, 5, 4, 7, 6, 2, 2, 3, 2, 0,
688 1, 1, 2, 0, 1, 1, 3, 3, 2, 3,
689 2, 3, 2, 3, 2, 3, 2, 3, 2, 3,
690 3, 2, 3, 5, 5, 2, 4, 3, 1, 3,
691 3, 4, 2, 1, 2, 2, 4, 2, 3, 4,
692 2, 2, 1, 1, 1, 1, 3, 1, 1, 1,
693 1, 3, 3, 3, 3, 3, 3, 3, 3, 5,
694 4, 6, 5, 4, 5, 5, 6, 3, 3, 4,
695 5, 2, 3, 3, 3, 1, 3, 3, 3, 3,
696 4, 4, 4, 4, 3, 3, 1, 2, 3, 3,
697 2, 2, 3, 3, 3, 3, 2, 3, 4, 5,
698 6, 5, 6, 4, 4, 4, 4, 3, 4, 3,
699 4, 1, 1, 1, 1, 2, 2, 1, 1, 2,
700 2, 1, 2, 2, 2, 2, 2, 2, 1, 2,
701 2, 1, 2, 2, 5, 4, 4, 5, 4, 2,
702 5, 4, 5, 1, 3, 3, 3, 3, 3, 3,
703 1, 3, 3, 3, 3, 1, 3, 3, 3, 3,
704 3, 3, 1, 3, 3, 3, 3, 3, 3, 3,
705 3, 3, 3, 1, 3, 3, 3, 3, 1, 3,
706 3, 1, 3, 3, 1, 3, 3, 1, 3, 3,
707 1, 3, 3, 1, 5, 4, 3, 5, 1, 1,
708 3, 3, 1, 1, 1, 1, 1, 1, 1
711 static const short yydefact[] = { 0,
712 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
713 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
714 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
715 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
716 163, 0, 0, 159, 63, 0, 69, 42, 40, 0,
717 0, 0, 61, 0, 49, 0, 26, 167, 17, 165,
718 15, 0, 156, 0, 0, 68, 16, 0, 0, 59,
719 164, 0, 161, 64, 69, 50, 48, 12, 0, 10,
720 11, 169, 0, 8, 9, 13, 14, 15, 0, 175,
721 177, 0, 176, 0, 171, 173, 174, 168, 166, 160,
722 67, 71, 72, 70, 0, 158, 0, 57, 112, 0,
723 127, 110, 0, 0, 89, 92, 127, 0, 0, 0,
724 114, 0, 0, 179, 178, 170, 172, 0, 0, 60,
725 162, 0, 0, 0, 0, 107, 98, 87, 0, 0,
726 0, 0, 106, 21, 18, 22, 20, 19, 113, 127,
727 111, 0, 127, 74, 73, 55, 188, 75, 23, 0,
728 85, 0, 77, 79, 83, 84, 0, 80, 0, 81,
729 127, 86, 82, 58, 118, 115, 0, 0, 0, 120,
730 129, 130, 128, 119, 117, 91, 0, 90, 94, 0,
731 0, 0, 0, 0, 0, 0, 336, 0, 0, 0,
732 0, 6, 5, 2, 3, 4, 7, 335, 0, 403,
733 0, 102, 402, 333, 338, 0, 334, 339, 340, 341,
734 419, 404, 405, 434, 408, 409, 412, 422, 441, 446,
735 453, 464, 469, 472, 475, 478, 481, 484, 489, 498,
736 490, 0, 101, 99, 97, 100, 109, 88, 108, 187,
737 0, 0, 127, 76, 78, 105, 0, 136, 0, 125,
738 123, 0, 116, 0, 0, 413, 403, 339, 341, 410,
739 414, 411, 418, 417, 416, 415, 0, 387, 0, 0,
740 0, 16, 0, 423, 420, 424, 421, 430, 0, 403,
741 0, 180, 0, 184, 0, 0, 0, 0, 0, 95,
742 0, 0, 362, 0, 407, 406, 0, 0, 0, 0,
743 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
744 0, 0, 0, 0, 0, 0, 0, 496, 497, 0,
745 0, 55, 0, 0, 277, 0, 0, 0, 0, 0,
746 0, 0, 0, 336, 0, 220, 0, 8, 403, 0,
747 0, 194, 0, 209, 0, 190, 192, 0, 193, 198,
748 210, 0, 199, 211, 0, 200, 201, 212, 0, 0,
749 202, 0, 213, 203, 290, 0, 214, 215, 216, 218,
750 217, 0, 219, 244, 243, 0, 241, 242, 239, 240,
751 238, 143, 0, 0, 135, 104, 133, 137, 0, 139,
752 126, 124, 122, 121, 132, 131, 349, 344, 0, 386,
753 376, 375, 358, 0, 369, 377, 0, 370, 0, 359,
754 0, 0, 0, 0, 0, 0, 346, 337, 182, 181,
755 0, 348, 343, 388, 0, 366, 398, 0, 347, 342,
756 364, 345, 365, 385, 400, 0, 363, 0, 438, 435,
757 439, 436, 440, 437, 444, 442, 445, 443, 450, 447,
758 451, 448, 452, 449, 460, 455, 462, 457, 459, 454,
759 461, 456, 463, 0, 458, 467, 465, 468, 466, 471,
760 470, 474, 473, 477, 476, 480, 479, 483, 482, 487,
761 0, 0, 492, 491, 227, 228, 226, 246, 0, 312,
762 0, 301, 299, 0, 309, 307, 0, 273, 0, 253,
763 0, 323, 0, 287, 0, 305, 303, 0, 0, 196,
764 0, 0, 223, 221, 0, 0, 189, 191, 195, 319,
765 403, 222, 225, 0, 251, 272, 0, 403, 0, 292,
766 296, 289, 0, 0, 316, 0, 144, 140, 134, 145,
767 403, 0, 0, 0, 141, 394, 395, 0, 381, 382,
768 0, 378, 371, 0, 374, 372, 373, 360, 351, 0,
769 432, 426, 429, 0, 0, 427, 186, 183, 185, 389,
770 0, 399, 396, 0, 401, 397, 354, 0, 486, 0,
771 247, 0, 313, 311, 302, 300, 310, 308, 274, 0,
772 254, 0, 0, 0, 320, 324, 0, 321, 288, 306,
773 304, 337, 0, 197, 229, 0, 0, 0, 0, 256,
774 0, 260, 0, 263, 264, 0, 293, 0, 281, 0,
775 0, 318, 0, 142, 0, 146, 0, 0, 147, 392,
776 0, 380, 379, 384, 383, 353, 361, 350, 431, 425,
777 433, 428, 368, 367, 390, 0, 355, 356, 488, 485,
778 248, 0, 275, 271, 0, 328, 0, 332, 331, 325,
779 322, 326, 233, 0, 230, 231, 0, 270, 267, 268,
780 499, 0, 258, 261, 263, 0, 257, 265, 0, 298,
781 297, 283, 0, 295, 0, 317, 0, 0, 148, 0,
782 0, 393, 352, 391, 357, 0, 245, 0, 198, 0,
783 205, 206, 0, 207, 208, 0, 255, 329, 0, 234,
784 0, 0, 232, 269, 266, 259, 0, 0, 282, 0,
785 315, 314, 0, 149, 0, 0, 0, 224, 276, 0,
786 330, 327, 237, 235, 0, 0, 280, 0, 0, 0,
787 150, 0, 249, 0, 0, 236, 278, 279, 152, 0,
788 0, 0, 0, 151, 0, 0, 0, 0, 285, 0,
789 250, 284, 0, 0, 0
792 static const short yydefgoto[] = { 773,
793 208, 347, 209, 85, 86, 68, 60, 87, 210, 22,
794 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
795 16, 17, 132, 105, 47, 70, 104, 130, 162, 163,
796 164, 91, 114, 115, 116, 211, 166, 257, 92, 111,
797 179, 180, 136, 183, 396, 168, 169, 170, 171, 400,
798 552, 353, 18, 43, 72, 65, 107, 44, 63, 94,
799 95, 96, 97, 212, 295, 354, 251, 355, 356, 357,
800 358, 359, 708, 360, 361, 362, 363, 711, 364, 365,
801 366, 367, 712, 368, 369, 535, 621, 622, 623, 624,
802 625, 370, 371, 714, 372, 373, 374, 715, 375, 376,
803 542, 693, 694, 377, 378, 379, 380, 381, 382, 383,
804 605, 606, 607, 608, 213, 214, 215, 216, 435, 217,
805 415, 416, 417, 218, 219, 220, 221, 222, 223, 224,
806 225, 226, 227, 228, 229, 230, 231, 232, 233, 234,
807 235, 236, 237, 238, 239, 240, 241, 242, 330, 436,
811 static const short yypact[] = { 427,
812 -32768,-32768, 52, -22, 375, 386,-32768,-32768, 480, 591,
813 675,-32768,-32768,-32768,-32768, 540,-32768,-32768,-32768,-32768,
814 49,-32768,-32768,-32768, 206,-32768, 302,-32768, 70, 662,
815 -32768,-32768, 699, 748,-32768, -22, 389,-32768,-32768, 30,
816 -32768, 433, -57, 112,-32768, 435, 165,-32768,-32768, -22,
817 829, 231,-32768, 370,-32768, 29,-32768,-32768,-32768,-32768,
818 154, 1076,-32768, 439, -57,-32768,-32768, 275, 475,-32768,
819 -32768, -57, 112,-32768, 165,-32768,-32768,-32768, 488,-32768,
820 -32768,-32768, 511, 166,-32768,-32768, 175, -24, 866,-32768,
821 -32768, 111,-32768, 1109,-32768,-32768,-32768,-32768,-32768,-32768,
822 -32768,-32768,-32768, 224, 340,-32768, -57,-32768,-32768, 292,
823 -21,-32768, 355, 457,-32768, 629, -21, 51, 66, 344,
824 -32768, 536, 541,-32768,-32768,-32768,-32768, 561, 1013,-32768,
825 -32768, 340, 697, 569, 69,-32768,-32768,-32768, 593, 2179,
826 74, 490,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -21,
827 -32768, 478, -21,-32768,-32768, 471, 477,-32768, 487, 866,
828 -32768, 1043,-32768,-32768,-32768,-32768, 78,-32768, 493,-32768,
829 537,-32768,-32768,-32768,-32768,-32768, 598, 1186, -40,-32768,
830 -32768,-32768, 506,-32768,-32768,-32768, 516,-32768,-32768, 2926,
831 2991, 3042, 3107, 520, 21, 483,-32768, 3158, 3223, 3274,
832 5288,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 535, 923,
833 18,-32768, 549, 557,-32768, 599,-32768, 534,-32768, 648,
834 760,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 781, 837,
835 808, 776, 833, 661, 670, 692, 702, 11,-32768,-32768,
836 -32768, 767,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
837 1906, 927, 537,-32768,-32768,-32768, 238, 619, 625,-32768,
838 774, 601,-32768, 890, 608,-32768, 658,-32768,-32768,-32768,
839 -32768,-32768,-32768,-32768,-32768,-32768, 35,-32768, 610, 747,
840 635, 635, 287,-32768,-32768,-32768,-32768,-32768, 301, 1014,
841 270,-32768, 639,-32768, 378, 222, 5355, 3339, 789,-32768,
842 13, 3390,-32768, 327,-32768,-32768, 3455, 3506, 3571, 3622,
843 3687, 3738, 3803, 3854, 3919, 3970, 4035, 4086, 595, 4151,
844 4202, 4267, 4318, 4383, 4434, 4499, 2230,-32768,-32768, 4550,
845 739, 339, 345, 4615,-32768, 143, 2295, 77, 357, 402,
846 126, 407, 144, 644, 5587,-32768, -22, 409, 950, 462,
847 1135,-32768, 651,-32768, 1554,-32768,-32768, 669,-32768,-32768,
848 -32768, 1974,-32768,-32768, 673,-32768,-32768,-32768, 689, 1974,
849 -32768, 1974,-32768,-32768, 1361, 677,-32768,-32768,-32768,-32768,
850 -32768, 412,-32768, 485, 656, 760, 834, 848,-32768,-32768,
851 -32768,-32768, 307, 625,-32768,-32768, 703,-32768, 1622, 713,
852 -32768, 774,-32768,-32768,-32768,-32768,-32768,-32768, 323, 706,
853 -32768,-32768,-32768, 2346, 635,-32768, 10, 635, 10,-32768,
854 2411, 4666, 162, 266, 2462, 318,-32768, 5628,-32768,-32768,
855 2114,-32768,-32768,-32768, 373,-32768,-32768, 200,-32768,-32768,
856 -32768,-32768,-32768, 721,-32768, 244,-32768, 5406,-32768,-32768,
857 -32768,-32768,-32768,-32768,-32768, 781,-32768, 781,-32768, 837,
858 -32768, 837,-32768, 837,-32768, 808,-32768, 808,-32768, 808,
859 -32768, 808,-32768, 166,-32768,-32768, 776,-32768, 776,-32768,
860 833,-32768, 661,-32768, 670,-32768, 692,-32768, 702,-32768,
861 825, 744,-32768,-32768,-32768,-32768,-32768,-32768, 4731,-32768,
862 142,-32768,-32768, 145,-32768,-32768, 178,-32768, 4782,-32768,
863 4847,-32768, 479,-32768, 5196,-32768,-32768, 180, 289, 753,
864 2527, 584,-32768,-32768, -22, 2578,-32768,-32768,-32768,-32768,
865 1122,-32768,-32768, 542,-32768,-32768, 800, 1030, 1186,-32768,
866 -32768,-32768, 24, 2643,-32768, 4898,-32768, 775,-32768,-32768,
867 1063, 1702, 784, 1770,-32768,-32768,-32768, 5471,-32768,-32768,
868 249,-32768, 785, 255,-32768, 785,-32768,-32768, 340, 82,
869 -32768,-32768,-32768, 4963, 1176,-32768,-32768,-32768,-32768,-32768,
870 5014,-32768,-32768, 5522,-32768,-32768, 340, 481,-32768, 5079,
871 -32768, 290,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 294,
872 -32768, 790, 429, 139, 479,-32768, 493,-32768,-32768,-32768,
873 -32768,-32768, 430, 753,-32768, 897, 86, 212, 5130,-32768,
874 650,-32768, 1906, 666,-32768, 810,-32768, 5330,-32768, 5221,
875 806, 814, 820,-32768, 919,-32768, 1838, 2694,-32768,-32768,
876 614,-32768,-32768,-32768,-32768,-32768,-32768, 340,-32768,-32768,
877 -32768,-32768,-32768,-32768,-32768, 681,-32768, 340,-32768,-32768,
878 -32768, 2040,-32768,-32768, 273,-32768, 918,-32768,-32768,-32768,
879 -32768,-32768,-32768, 2759,-32768,-32768, 917,-32768,-32768,-32768,
880 -32768, 274,-32768,-32768, 723, 1472,-32768,-32768, 5587,-32768,
881 -32768,-32768, 823, 821, 5263,-32768, 280, 445,-32768, 239,
882 91,-32768,-32768,-32768,-32768, 459,-32768, 867, 868, 2040,
883 -32768,-32768, 2040,-32768,-32768, 827,-32768, 835, 842,-32768,
884 936, 105,-32768,-32768,-32768,-32768, 844, 1974,-32768, 851,
885 -32768,-32768, 2810,-32768, 245, 4731, 1974,-32768,-32768, 2875,
886 -32768,-32768,-32768,-32768, 941, 850,-32768, 1974, 250, 199,
887 -32768, 295,-32768, 5221, 855,-32768,-32768,-32768,-32768, 252,
888 2040, 853, 5263,-32768, 900, 2040, 863, 2040,-32768, 2040,
889 -32768,-32768, 961, 965,-32768
892 static const short yypgoto[] = {-32768,
893 -32768, -49, 6, 647, -13, -124, 309,-32768, -3, -66,
894 -32768, 115,-32768, 956, 700,-32768, 25,-32768,-32768, 623,
895 -25, -20,-32768,-32768, 915, 895,-32768, -130,-32768, 811,
896 -32768, -72, -119, 841, 442, -195,-32768,-32768, 281, -34,
897 722, -263, -106,-32768,-32768,-32768,-32768,-32768, 828, 587,
898 -32768, 586, -48,-32768,-32768,-32768,-32768, 931, -10,-32768,
899 899,-32768,-32768, 127,-32768, -121,-32768, -390, -350,-32768,
900 621, -269, 288, -552,-32768, -502,-32768,-32768,-32768, -363,
901 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 368,-32768, 387,
902 -603, -488,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -427,
903 -32768, -131, 624,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
904 -32768, 405,-32768, 413,-32768,-32768, 94,-32768, -229,-32768,
905 712, 8, -262, 1169, 141, 1189, 269, 316, 438, -175,
906 560, 588, -421,-32768, 590, 574, 916, 592, 685, 696,
907 698, 708, 701,-32768, 441, 695, 690,-32768,-32768, 84,
908 -32768
912 #define YYLAST 5737
915 static const short yytable[] = { 21,
916 404, 174, 29, 152, 528, 294, 576, 173, 554, 182,
917 143, 541, 83, 93, 270, 272, 274, 276, 300, 419,
918 688, 278, 285, 287, 627, 326, 424, 426, 59, 76,
919 55, 134, 67, 31, 56, 407, 89, 62, 61, 123,
920 173, 90, 61, 247, 83, 93, 249, 258, 117, 38,
921 59, 144, 19, 263, 100, 59, 165, 31, 88, 264,
922 61, 106, 159, 20, 259, 61, 146, 84, 89, 184,
923 48, 283, 120, 90, 244, 135, 50, 278, 256, 83,
924 172, 688, 647, 177, 443, 88, 676, 150, 153, 165,
925 88, 676, 532, 159, 84, 159, 131, 327, 20, 84,
926 536, 408, 537, 160, 201, 744, 564, 178, 161, 709,
927 123, 124, 83, 172, 59, 20, -93, -93, 25, 27,
928 67, 279, -291, 628, 61, 88, 512, 77, 262, 88,
929 61, 450, 452, 454, 84, 397, 160, 20, 84, 668,
930 406, 161, 593, 502, 516, 595, 394, 39, 145, 40,
931 52, 54, 563, 652, 57, 566, 88, 709, 88, 710,
932 709, 637, 573, 147, 57, 84, 185, 84, 49, -154,
933 50, 245, -103, 713, 88, 648, -103, 279, 597, 677,
934 610, 581, 282, 84, 735, 581, 267, 267, 267, 267,
935 581, 570, 61, 110, 267, 267, 290, 113, 745, 744,
936 582, 281, 177, 528, 581, 289, 41, 710, 709, 125,
937 710, 64, 678, 709, 177, 709, 69, 709, 588, 513,
938 157, 713, 432, 243, 713, 351, 178, 520, 20, 20,
939 352, 71, 686, 157, 716, 579, 110, 113, 178, 675,
940 594, 503, 517, 596, 585, 723, 572, 349, 88, 642,
941 743, 67, 756, 187, 50, 644, 348, 84, 710, 560,
942 88, 61, 118, 710, 691, 710, 541, 710, 42, 84,
943 427, 119, 713, 717, 724, 101, 598, 713, 611, 713,
944 731, 713, 716, 291, 243, 716, 528, 420, 433, 427,
945 661, 187, 760, 42, 663, 661, 617, 583, 581, 679,
946 -155, 525, 45, 267, 267, 267, 267, 267, 267, 267,
947 267, 267, 267, 267, 267, 88, 267, 267, 267, 267,
948 267, 267, 267, 128, 474, -157, -66, 447, 641, 351,
949 304, 541, 157, 716, 352, 528, 395, 734, 716, -319,
950 716, 586, 716, 751, 384, 498, 643, 88, 759, 539,
951 764, 349, 645, -65, 656, 137, 84, 508, 531, 574,
952 348, 725, 564, 428, 46, 350, 531, -252, 531, -66,
953 74, 538, 99, 351, 157, 26, 187, 103, 352, 421,
954 348, 438, 612, 662, 133, 446, 28, 664, 761, 53,
955 541, 385, 707, 410, 422, 551, -65, 423, 650, 541,
956 547, 296, 510, 719, 348, 614, 264, 514, 701, 167,
957 492, 575, 545, 57, 564, 444, 556, 501, 267, 448,
958 507, -65, 562, 557, 267, 562, -28, 1, 519, 666,
959 673, -319, 46, 58, 129, 66, 155, 499, 646, 98,
960 532, 148, 167, 536, 722, 673, -96, 133, 384, 509,
961 504, -96, -96, -96, -96, 384, 657, 518, 747, 498,
962 20, 187, 523, 384, -65, 384, 580, 753, 384, 350,
963 2, 20, 581, 430, 20, 102, 350, 431, 758, -30,
964 1, 3, 669, 280, 350, 672, 350, 4, 109, 525,
965 246, 707, 384, 5, 511, 385, 747, 561, 753, 515,
966 758, 6, 385, 750, 546, 118, -25, -25, 438, 296,
967 385, 112, 385, 350, 243, 385, 137, 703, 20, 386,
968 20, 667, 674, 2, 20, 7, 351, 705, 351, -338,
969 -338, 352, 78, 352, 3, 88, 149, 733, 603, 385,
970 4, 151, 604, 565, 84, 567, 5, -25, 349, 524,
971 349, 736, -25, -25, -25, 138, 139, 348, -25, 348,
972 20, 154, -25, 730, 80, -138, 387, 81, 20, 181,
973 267, 267, 250, 20, 658, 732, 248, 139, 7, 252,
974 581, -338, 592, 35, 439, -338, 267, 157, 618, 134,
975 -31, 1, 600, 186, 602, 473, 20, 351, 260, 303,
976 36, 401, 352, 619, 438, 265, 37, -96, 405, -96,
977 409, 351, -96, -96, -96, -96, 352, 177, 261, 349,
978 277, 20, 762, 386, -494, -494, 20, 631, 348, 633,
979 386, 767, 32, 349, 2, 296, 57, 620, 386, 187,
980 386, 178, 348, 386, 78, 384, 20, 384, 613, 301,
981 440, 4, 32, 302, 20, 441, 32, 5, 531, 442,
982 351, -34, 1, 88, 654, 352, 350, 386, 350, 20,
983 387, 322, 84, 32, -29, 1, 80, 387, 20, 81,
984 20, 323, 349, 20, 20, 387, 20, 387, 388, 7,
985 387, 348, 385, 20, 385, 20, 618, 175, -32, 1,
986 -340, -340, 681, 402, 324, 2, 531, 702, 30, 531,
987 34, 619, 618, 581, 387, 325, 384, 398, 2, 399,
988 140, 384, 4, 384, 531, 141, 142, 619, 5, 3,
989 384, 414, 51, 531, 429, 4, -153, 350, -495, -495,
990 2, 5, 2, 526, 531, 683, 78, -33, 1, 57,
991 297, 350, -340, 3, 298, 384, -340, 531, 299, 4,
992 7, 687, 531, 385, 531, 5, 531, 529, 385, 618,
993 385, 533, 727, 7, 704, 544, 350, 385, 80, 384,
994 581, 81, 20, 534, 619, 307, 308, 309, 384, 439,
995 176, 2, 388, 315, 316, 317, 318, 7, 558, 388,
996 350, 549, 385, 384, 305, 306, 384, 388, 4, 388,
997 389, 555, 388, 584, 5, 312, 313, 314, 726, 752,
998 386, 384, 386, 755, 350, 589, 385, 350, -35, 1,
999 384, 590, 319, 495, 496, 385, 388, 497, 390, 310,
1000 311, 384, 350, 411, 412, 413, 7, 384, 320, 321,
1001 385, 350, 139, 385, 384, 440, 384, 328, 329, 384,
1002 441, 384, 350, 384, 442, 626, 121, 387, 385, 387,
1003 141, 142, 2, 634, 20, 350, 638, 385, -404, -404,
1004 350, 564, 350, 665, 350, 460, 462, 464, 385, 4,
1005 403, 386, -405, -405, 385, 5, 386, 675, 386, 456,
1006 458, 385, 689, 385, 695, 386, 385, 696, 385, 35,
1007 385, 477, 479, 697, 389, 78, 728, 723, 718, 439,
1008 628, 389, 737, -204, 122, 740, 36, 7, 741, 389,
1009 386, 389, 37, 2, 389, 742, 743, 746, 387, 78,
1010 391, 756, 390, 387, 748, 387, 766, 80, 757, 390,
1011 81, 20, 387, 763, 386, 768, 770, 390, 389, 390,
1012 774, 2, 390, 386, 775, 475, 33, 78, 75, 108,
1013 2, 80, 255, 393, 81, 20, 78, 387, 386, 188,
1014 548, 386, 73, 698, 553, 440, 390, 253, 684, 388,
1015 441, 388, 127, 418, 442, 540, 386, 738, 543, 80,
1016 739, 387, 81, 20, 20, 386, 481, 685, 80, 670,
1017 387, 81, 20, -493, -493, 297, 386, 671, 483, 298,
1018 392, 485, 386, 299, 494, 387, 489, 0, 387, 386,
1019 660, 386, 487, 0, 386, -15, 386, 0, 386, 0,
1020 -493, -493, 297, 387, 391, 0, 521, 0, 765, 0,
1021 522, 391, 387, 769, 0, 771, 156, 772, 0, 391,
1022 388, 391, 78, 387, 391, 388, 0, 388, 0, 387,
1023 0, 79, 0, 4, 388, 0, 387, 0, 387, 5,
1024 0, 387, 0, 387, 0, 387, 156, 0, 391, 0,
1025 0, 0, 78, 0, 80, 0, 0, 81, 20, 388,
1026 0, 79, 0, 4, -493, -493, 297, 157, 158, 5,
1027 425, 389, 0, 389, 299, -15, 0, 0, 0, 2,
1028 -493, -493, 297, 388, 80, 78, 521, 81, 20, 0,
1029 299, 0, 388, 0, 79, 0, 4, 157, 254, 390,
1030 0, 390, 5, 0, 0, 0, 0, 388, -15, 0,
1031 388, 0, 2, -493, -493, 297, 0, 80, 78, 521,
1032 81, 20, 0, 635, 0, 388, 0, 79, 0, 4,
1033 0, 82, 0, 0, 388, 5, 651, 0, 35, 0,
1034 0, 0, 389, 0, 78, 388, 0, 389, 0, 389,
1035 80, 388, 0, 81, 20, 0, 389, 0, 388, 0,
1036 388, 37, 0, 388, 126, 388, 0, 388, 0, 0,
1037 390, 0, -493, -493, 297, 390, 80, 390, 298, 81,
1038 20, 389, 522, 0, 390, 78, 0, 0, 0, 35,
1039 466, 468, 470, 472, 194, 78, 0, 0, 0, 0,
1040 195, 391, 0, 391, 0, 389, 0, 196, 0, 390,
1041 0, 197, 0, 0, 389, 0, 0, 80, 0, 0,
1042 81, 20, 0, 0, 198, 199, 0, 80, 200, 389,
1043 81, 20, 389, 390, 0, 0, 0, 202, 203, 204,
1044 205, 0, 390, 206, 207, 0, 0, 389, 0, 0,
1045 0, 0, 0, 0, 0, 0, 389, 390, 0, 0,
1046 390, 0, 0, 0, 0, 0, 0, 389, 0, 0,
1047 0, 0, 391, 389, 0, 390, 0, 391, 0, 391,
1048 389, 0, 389, 0, 390, 389, 391, 389, 0, 389,
1049 0, 0, 0, 0, 0, 390, 0, 0, 0, 0,
1050 0, 390, 0, 0, 0, 0, 0, 0, 390, 0,
1051 390, 391, 0, 390, 0, 390, 0, 390, 268, 268,
1052 268, 268, 0, 0, 0, 0, 268, 268, 0, 0,
1053 0, 0, 0, 0, 0, 391, 0, 0, 269, 269,
1054 269, 269, 0, 0, 391, 0, 269, 269, 0, 0,
1055 0, 0, 0, 0, 0, 0, 0, 0, 0, 391,
1056 0, 0, 391, 0, 2, 192, 193, 0, 0, 0,
1057 78, 0, 0, 0, 0, 0, 0, 391, 0, 194,
1058 0, 0, 0, 0, 0, 195, 391, 0, 0, 0,
1059 0, 0, 196, 0, 0, 0, 197, 391, 0, 0,
1060 0, 0, 80, 391, 0, 81, 20, 0, 0, 0,
1061 391, 0, 391, 345, 0, 391, 0, 391, 0, 391,
1062 0, 0, 202, 203, 204, 205, 0, 0, 206, 207,
1063 0, 0, 331, 0, 0, 268, 268, 268, 268, 268,
1064 268, 268, 268, 268, 268, 268, 268, 0, 268, 268,
1065 268, 268, 268, 268, 268, 269, 269, 269, 269, 269,
1066 269, 269, 269, 269, 269, 269, 269, 0, 269, 269,
1067 269, 269, 269, 269, 269, 332, 192, 193, -262, 333,
1068 334, 78, 335, 0, 0, 336, 0, 0, 0, 337,
1069 194, 0, 0, -262, 0, 0, 338, 339, 5, 340,
1070 0, 341, 342, 196, 343, 0, 0, 344, 0, 0,
1071 0, 0, 0, 80, 331, 0, 81, 20, 0, 0,
1072 0, 0, 0, 0, 345, 0, 157, -262, 0, 0,
1073 346, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1074 207, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1075 268, 0, 0, 0, 0, 0, 268, 332, 192, 193,
1076 0, 333, 334, 78, 335, 0, 0, 336, 0, 0,
1077 269, 337, 194, 0, 0, 0, 269, 0, 338, 339,
1078 5, 340, 331, 341, 342, 196, 343, 0, 0, 344,
1079 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1080 0, 0, 0, 0, 0, 0, 345, 0, 157, 527,
1081 0, 0, 346, 0, 0, 202, 203, 204, 205, 0,
1082 0, 206, 207, 0, 0, 332, 192, 193, 0, 333,
1083 334, 78, 335, 0, 0, 336, 0, 0, 0, 337,
1084 194, 0, 0, 0, 0, 0, 338, 339, 5, 340,
1085 0, 341, 342, 196, 343, 0, 0, 344, 0, 0,
1086 0, 0, 331, 80, 0, 0, 81, 20, 0, 0,
1087 0, 0, 0, 0, 345, 0, 157, 550, 0, 0,
1088 346, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1089 207, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1090 0, 0, 268, 268, 0, 332, 192, 193, 0, 333,
1091 334, 78, 335, 0, 0, 336, 0, 0, 268, 337,
1092 194, 0, 269, 269, 0, 0, 338, 339, 5, 340,
1093 331, 341, 342, 196, 343, 0, 0, 344, 269, 0,
1094 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1095 0, 0, 0, 0, 345, 0, 157, 636, 0, 0,
1096 346, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1097 207, 0, 0, 332, 192, 193, 0, 333, 334, 78,
1098 335, 0, 0, 336, 0, 0, 0, 337, 194, 0,
1099 0, 0, 0, 0, 338, 339, 5, 340, 331, 341,
1100 342, 196, 343, 0, 0, 344, 0, 0, 0, 0,
1101 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1102 0, 0, 345, 0, 157, 639, 0, 0, 346, 0,
1103 0, 202, 203, 204, 205, 0, 0, 206, 207, 0,
1104 0, 332, 192, 193, 0, 333, 334, 78, 335, 0,
1105 0, 336, 0, 0, 0, 337, 194, 0, 0, 0,
1106 0, 0, 338, 339, 5, 340, 331, 341, 342, 196,
1107 343, 0, 0, 344, 0, 0, 0, 0, 0, 80,
1108 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1109 345, 0, 157, 699, 0, 0, 346, 0, 0, 202,
1110 203, 204, 205, 0, 0, 206, 207, 0, 0, 332,
1111 192, 193, 0, 333, 334, 78, 335, 0, 0, 336,
1112 0, 0, 0, 337, 194, 0, 0, 0, 0, 0,
1113 338, 339, 5, 340, 331, 341, 342, 196, 343, 0,
1114 0, 344, 0, 0, 0, 0, 0, 80, 0, 0,
1115 81, 20, 0, 0, 0, 0, 0, 0, 345, 0,
1116 157, 0, 0, 0, 346, 0, 0, 202, 203, 204,
1117 205, 0, 0, 206, 207, 0, 0, 530, 192, 193,
1118 0, 333, 334, 78, 335, 0, 0, 336, 0, 0,
1119 0, 337, 194, 0, 0, 0, 0, 0, 338, 339,
1120 331, 340, 0, 341, 342, 196, 343, 0, 0, 344,
1121 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1122 0, 0, 0, 0, 0, 0, 345, 0, 157, 0,
1123 0, 0, 346, 0, 0, 202, 203, 204, 205, 0,
1124 0, 206, 207, 530, 192, 193, 0, 706, 334, 78,
1125 335, 0, 0, 336, 0, 0, 0, 337, 194, 0,
1126 0, 0, 0, 0, 338, 339, 0, 340, 0, 341,
1127 342, 196, 343, 0, 577, 344, 190, 191, 0, 0,
1128 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1129 0, 0, 345, 0, 157, 0, 0, 0, 346, 0,
1130 0, 202, 203, 204, 205, 0, 0, 206, 207, 0,
1131 0, 0, 0, 0, 0, 0, 0, 0, 192, 193,
1132 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1133 0, 0, 194, 0, 0, 0, 0, 0, 195, 189,
1134 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1135 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1136 0, 0, 198, 199, 0, 0, 200, 0, 201, 578,
1137 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1138 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1139 490, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1140 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1141 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1142 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1143 0, 200, 0, 201, 192, 193, 0, 0, 0, 78,
1144 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1145 0, 0, 0, 0, 195, 505, 0, 190, 191, 0,
1146 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1147 0, 80, 0, 0, 81, 20, 0, 491, 198, 199,
1148 0, 0, 200, 0, 0, 0, 0, 0, 0, 0,
1149 0, 202, 203, 204, 205, 0, 0, 206, 207, 192,
1150 193, 0, 0, 0, 78, 0, 559, 0, 190, 191,
1151 0, 0, 0, 194, 0, 0, 0, 0, 0, 195,
1152 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1153 197, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1154 20, 0, 0, 198, 199, 0, 0, 200, 0, 0,
1155 192, 193, 0, 506, 0, 78, 202, 203, 204, 205,
1156 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1157 195, 568, 0, 190, 191, 0, 0, 196, 0, 0,
1158 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1159 81, 20, 0, 0, 198, 199, 0, 0, 200, 0,
1160 0, 0, 0, 560, 0, 0, 0, 202, 203, 204,
1161 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1162 78, 0, 437, 0, 190, 191, 0, 0, 0, 194,
1163 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1164 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1165 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1166 199, 0, 0, 200, 569, 0, 192, 193, 0, 0,
1167 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1168 194, 0, 0, 0, 0, 0, 195, 437, 0, 190,
1169 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1170 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1171 198, 199, 0, 0, 200, 0, 0, 0, 0, 560,
1172 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1173 207, 192, 193, 0, 0, 0, 78, 0, 615, 0,
1174 190, 191, 0, 0, 0, 194, 0, 0, 0, 0,
1175 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1176 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1177 0, 81, 20, 0, 0, 198, 199, 0, 0, 200,
1178 0, 0, 192, 193, 148, 0, 0, 78, 202, 203,
1179 204, 205, 0, 0, 206, 207, 194, 0, 0, 0,
1180 0, 0, 195, 629, 0, 190, 191, 0, 0, 196,
1181 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1182 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1183 200, 616, 0, 0, 0, 0, 0, 0, 0, 202,
1184 203, 204, 205, 0, 0, 206, 207, 192, 193, 0,
1185 0, 0, 78, 0, 615, 0, 190, 191, 0, 0,
1186 0, 194, 0, 0, 0, 0, 0, 195, 0, 0,
1187 0, 0, 0, 0, 196, 0, 0, 0, 197, 0,
1188 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1189 0, 198, 199, 0, 0, 200, 0, 0, 192, 193,
1190 0, 630, 0, 78, 202, 203, 204, 205, 0, 0,
1191 206, 207, 194, 0, 0, 0, 0, 0, 195, 720,
1192 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1193 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1194 0, 0, 198, 199, 0, 0, 200, 700, 0, 0,
1195 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1196 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1197 720, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1198 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1199 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1200 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1201 0, 200, 721, 0, 192, 193, 0, 0, 0, 78,
1202 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1203 0, 0, 0, 0, 195, 629, 0, 190, 191, 0,
1204 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1205 0, 80, 0, 0, 81, 20, 0, 0, 198, 199,
1206 0, 0, 200, 749, 0, 0, 0, 0, 0, 0,
1207 0, 202, 203, 204, 205, 0, 0, 206, 207, 192,
1208 193, 0, 0, 0, 78, 0, 266, 0, 190, 191,
1209 0, 0, 0, 194, 0, 0, 0, 0, 0, 195,
1210 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1211 197, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1212 20, 0, 0, 198, 199, 0, 0, 200, 0, 0,
1213 192, 193, 0, 754, 0, 78, 202, 203, 204, 205,
1214 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1215 195, 271, 0, 190, 191, 0, 0, 196, 0, 0,
1216 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1217 81, 20, 0, 0, 198, 199, 0, 0, 200, 0,
1218 0, 0, 0, 0, 0, 0, 0, 202, 203, 204,
1219 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1220 78, 0, 273, 0, 190, 191, 0, 0, 0, 194,
1221 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1222 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1223 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1224 199, 0, 0, 200, 0, 0, 192, 193, 0, 0,
1225 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1226 194, 0, 0, 0, 0, 0, 195, 275, 0, 190,
1227 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1228 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1229 198, 199, 0, 0, 200, 0, 0, 0, 0, 0,
1230 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1231 207, 192, 193, 0, 0, 0, 78, 0, 284, 0,
1232 190, 191, 0, 0, 0, 194, 0, 0, 0, 0,
1233 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1234 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1235 0, 81, 20, 0, 0, 198, 199, 0, 0, 200,
1236 0, 0, 192, 193, 0, 0, 0, 78, 202, 203,
1237 204, 205, 0, 0, 206, 207, 194, 0, 0, 0,
1238 0, 0, 195, 286, 0, 190, 191, 0, 0, 196,
1239 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1240 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1241 200, 0, 0, 0, 0, 0, 0, 0, 0, 202,
1242 203, 204, 205, 0, 0, 206, 207, 192, 193, 0,
1243 0, 0, 78, 0, 288, 0, 190, 191, 0, 0,
1244 0, 194, 0, 0, 0, 0, 0, 195, 0, 0,
1245 0, 0, 0, 0, 196, 0, 0, 0, 197, 0,
1246 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1247 0, 198, 199, 0, 0, 200, 0, 0, 192, 193,
1248 0, 0, 0, 78, 202, 203, 204, 205, 0, 0,
1249 206, 207, 194, 0, 0, 0, 0, 0, 195, 437,
1250 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1251 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1252 0, 0, 198, 199, 0, 0, 200, 0, 0, 0,
1253 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1254 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1255 445, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1256 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1257 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1258 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1259 0, 200, 0, 0, 192, 193, 0, 0, 0, 78,
1260 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1261 0, 0, 0, 0, 195, 449, 0, 190, 191, 0,
1262 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1263 0, 80, 0, 0, 81, 20, 0, 0, 198, 199,
1264 0, 0, 200, 0, 0, 0, 0, 0, 0, 0,
1265 0, 202, 203, 204, 205, 0, 0, 206, 207, 192,
1266 193, 0, 0, 0, 78, 0, 451, 0, 190, 191,
1267 0, 0, 0, 194, 0, 0, 0, 0, 0, 195,
1268 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1269 197, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1270 20, 0, 0, 198, 199, 0, 0, 200, 0, 0,
1271 192, 193, 0, 0, 0, 78, 202, 203, 204, 205,
1272 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1273 195, 453, 0, 190, 191, 0, 0, 196, 0, 0,
1274 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1275 81, 20, 0, 0, 198, 199, 0, 0, 200, 0,
1276 0, 0, 0, 0, 0, 0, 0, 202, 203, 204,
1277 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1278 78, 0, 455, 0, 190, 191, 0, 0, 0, 194,
1279 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1280 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1281 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1282 199, 0, 0, 200, 0, 0, 192, 193, 0, 0,
1283 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1284 194, 0, 0, 0, 0, 0, 195, 457, 0, 190,
1285 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1286 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1287 198, 199, 0, 0, 200, 0, 0, 0, 0, 0,
1288 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1289 207, 192, 193, 0, 0, 0, 78, 0, 459, 0,
1290 190, 191, 0, 0, 0, 194, 0, 0, 0, 0,
1291 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1292 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1293 0, 81, 20, 0, 0, 198, 199, 0, 0, 200,
1294 0, 0, 192, 193, 0, 0, 0, 78, 202, 203,
1295 204, 205, 0, 0, 206, 207, 194, 0, 0, 0,
1296 0, 0, 195, 461, 0, 190, 191, 0, 0, 196,
1297 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1298 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1299 200, 0, 0, 0, 0, 0, 0, 0, 0, 202,
1300 203, 204, 205, 0, 0, 206, 207, 192, 193, 0,
1301 0, 0, 78, 0, 463, 0, 190, 191, 0, 0,
1302 0, 194, 0, 0, 0, 0, 0, 195, 0, 0,
1303 0, 0, 0, 0, 196, 0, 0, 0, 197, 0,
1304 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1305 0, 198, 199, 0, 0, 200, 0, 0, 192, 193,
1306 0, 0, 0, 78, 202, 203, 204, 205, 0, 0,
1307 206, 207, 194, 0, 0, 0, 0, 0, 195, 465,
1308 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1309 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1310 0, 0, 198, 199, 0, 0, 200, 0, 0, 0,
1311 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1312 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1313 467, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1314 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1315 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1316 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1317 0, 200, 0, 0, 192, 193, 0, 0, 0, 78,
1318 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1319 0, 0, 0, 0, 195, 469, 0, 190, 191, 0,
1320 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1321 0, 80, 0, 0, 81, 20, 0, 0, 198, 199,
1322 0, 0, 200, 0, 0, 0, 0, 0, 0, 0,
1323 0, 202, 203, 204, 205, 0, 0, 206, 207, 192,
1324 193, 0, 0, 0, 78, 0, 471, 0, 190, 191,
1325 0, 0, 0, 194, 0, 0, 0, 0, 0, 195,
1326 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1327 197, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1328 20, 0, 0, 198, 199, 0, 0, 200, 0, 0,
1329 192, 193, 0, 0, 0, 78, 202, 203, 204, 205,
1330 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1331 195, 476, 0, 190, 191, 0, 0, 196, 0, 0,
1332 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1333 81, 20, 0, 0, 198, 199, 0, 0, 200, 0,
1334 0, 0, 0, 0, 0, 0, 0, 202, 203, 204,
1335 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1336 78, 0, 478, 0, 190, 191, 0, 0, 0, 194,
1337 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1338 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1339 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1340 199, 0, 0, 200, 0, 0, 192, 193, 0, 0,
1341 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1342 194, 0, 0, 0, 0, 0, 195, 480, 0, 190,
1343 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1344 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1345 198, 199, 0, 0, 200, 0, 0, 0, 0, 0,
1346 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1347 207, 192, 193, 0, 0, 0, 78, 0, 482, 0,
1348 190, 191, 0, 0, 0, 194, 0, 0, 0, 0,
1349 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1350 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1351 0, 81, 20, 0, 0, 198, 199, 0, 0, 200,
1352 0, 0, 192, 193, 0, 0, 0, 78, 202, 203,
1353 204, 205, 0, 0, 206, 207, 194, 0, 0, 0,
1354 0, 0, 195, 484, 0, 190, 191, 0, 0, 196,
1355 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1356 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1357 200, 0, 0, 0, 0, 0, 0, 0, 0, 202,
1358 203, 204, 205, 0, 0, 206, 207, 192, 193, 0,
1359 0, 0, 78, 0, 486, 0, 190, 191, 0, 0,
1360 0, 194, 0, 0, 0, 0, 0, 195, 0, 0,
1361 0, 0, 0, 0, 196, 0, 0, 0, 197, 0,
1362 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1363 0, 198, 199, 0, 0, 200, 0, 0, 192, 193,
1364 0, 0, 0, 78, 202, 203, 204, 205, 0, 0,
1365 206, 207, 194, 0, 0, 0, 0, 0, 195, 488,
1366 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1367 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1368 0, 0, 198, 199, 0, 0, 200, 0, 0, 0,
1369 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1370 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1371 493, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1372 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1373 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1374 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1375 0, 200, 0, 0, 192, 193, 0, 0, 0, 78,
1376 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1377 0, 0, 0, 0, 195, 500, 0, 190, 191, 0,
1378 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1379 0, 80, 0, 0, 81, 20, 0, 0, 198, 199,
1380 0, 0, 200, 0, 0, 0, 0, 0, 0, 0,
1381 0, 202, 203, 204, 205, 0, 0, 206, 207, 192,
1382 193, 0, 0, 0, 78, 0, 571, 0, 190, 191,
1383 0, 0, 0, 194, 0, 0, 0, 0, 0, 195,
1384 0, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1385 197, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1386 20, 0, 0, 198, 199, 0, 0, 200, 0, 0,
1387 192, 193, 0, 0, 0, 78, 202, 203, 204, 205,
1388 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1389 195, 591, 0, 190, 191, 0, 0, 196, 0, 0,
1390 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1391 81, 20, 0, 0, 198, 199, 0, 0, 200, 0,
1392 0, 0, 0, 0, 0, 0, 0, 202, 203, 204,
1393 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1394 78, 0, 599, 0, 190, 191, 0, 0, 0, 194,
1395 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1396 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1397 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1398 199, 0, 0, 200, 0, 0, 192, 193, 0, 0,
1399 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1400 194, 0, 0, 0, 0, 0, 195, 601, 0, 190,
1401 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1402 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1403 198, 199, 0, 0, 200, 0, 0, 0, 0, 0,
1404 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1405 207, 192, 193, 0, 0, 0, 78, 0, 632, 0,
1406 190, 191, 0, 0, 0, 194, 0, 0, 0, 0,
1407 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1408 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1409 0, 81, 20, 0, 0, 198, 199, 0, 0, 200,
1410 0, 0, 192, 193, 0, 0, 0, 78, 202, 203,
1411 204, 205, 0, 0, 206, 207, 194, 0, 0, 0,
1412 0, 0, 195, 649, 0, 190, 191, 0, 0, 196,
1413 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1414 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1415 200, 0, 0, 0, 0, 0, 0, 0, 0, 202,
1416 203, 204, 205, 0, 0, 206, 207, 192, 193, 0,
1417 0, 0, 78, 0, 653, 0, 190, 191, 0, 0,
1418 0, 194, 0, 0, 0, 0, 0, 195, 0, 0,
1419 0, 0, 0, 0, 196, 0, 0, 0, 197, 0,
1420 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1421 0, 198, 199, 0, 0, 200, 0, 0, 192, 193,
1422 0, 0, 0, 78, 202, 203, 204, 205, 0, 0,
1423 206, 207, 194, 0, 0, 0, 0, 0, 195, 659,
1424 0, 190, 191, 0, 0, 196, 0, 0, 0, 197,
1425 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1426 0, 0, 198, 199, 0, 0, 200, 0, 0, 0,
1427 0, 0, 0, 0, 0, 202, 203, 204, 205, 0,
1428 0, 206, 207, 192, 193, 0, 0, 0, 78, 0,
1429 680, 0, 190, 191, 0, 0, 0, 194, 0, 0,
1430 0, 0, 0, 195, 0, 0, 0, 0, 0, 0,
1431 196, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1432 80, 0, 0, 81, 20, 0, 0, 198, 199, 0,
1433 0, 200, 0, 0, 192, 193, 0, 0, 0, 78,
1434 202, 203, 204, 205, 0, 0, 206, 207, 194, 0,
1435 0, 0, 0, 0, 195, 0, 609, 0, 0, 0,
1436 0, 196, 0, 0, 0, 197, 0, 0, 0, 0,
1437 0, 80, 0, 0, 81, 20, 0, 0, 198, 199,
1438 0, 692, 200, 0, 0, 0, 0, 0, 0, 0,
1439 0, 202, 203, 204, 205, 0, 0, 206, 207, -286,
1440 -286, -286, 0, 0, 0, -286, 0, 0, 0, 0,
1441 0, 0, 0, 0, -286, 0, 0, 0, 0, 0,
1442 -286, 0, 0, 729, 0, 192, 193, -286, 0, 0,
1443 78, -286, 0, 0, 0, 0, 0, -286, 0, 194,
1444 -286, -286, 0, 0, 0, 195, 0, 0, -286, 0,
1445 190, 191, 196, 0, -286, 0, 197, -286, -286, -286,
1446 -286, 0, 80, -286, -286, 81, 20, 192, 193, 0,
1447 0, 0, 78, 345, -294, 0, 0, 0, 0, 0,
1448 0, 194, 202, 203, 204, 205, 0, 195, 206, 207,
1449 690, 0, 192, 193, 196, 0, 0, 78, 197, 0,
1450 0, 0, 0, 0, 80, 0, 194, 81, 20, 0,
1451 0, 0, 195, 0, 0, 345, -294, 190, 191, 196,
1452 0, 0, 0, 197, 202, 203, 204, 205, 0, 80,
1453 206, 207, 81, 20, 192, 193, 198, 199, 0, 78,
1454 200, 0, 201, 292, 0, 0, 0, 293, 194, 202,
1455 203, 204, 205, 0, 195, 206, 207, 0, 0, 192,
1456 193, 196, 0, 0, 78, 197, 0, 0, 190, 191,
1457 0, 80, 0, 194, 81, 20, 0, 0, 0, 195,
1458 0, 0, 345, 0, 0, 0, 196, 0, 0, 0,
1459 197, 202, 203, 204, 205, 0, 80, 206, 207, 81,
1460 20, 0, 0, 198, 199, 0, 0, 200, 434, 0,
1461 192, 193, 0, 0, 0, 78, 202, 203, 204, 205,
1462 0, 0, 206, 207, 194, 0, 0, 0, 0, 0,
1463 195, 0, 0, 190, 191, 0, 0, 196, 0, 0,
1464 0, 197, 0, 0, 0, 0, 0, 80, 0, 0,
1465 81, 20, 0, 0, 198, 199, 0, 0, 200, 587,
1466 0, 0, 0, 0, 0, 0, 0, 202, 203, 204,
1467 205, 0, 0, 206, 207, 192, 193, 0, 0, 0,
1468 78, 0, 0, 0, 190, 191, 0, 0, 0, 194,
1469 0, 0, 0, 0, 0, 195, 0, 0, 0, 0,
1470 0, 0, 196, 0, 0, 0, 197, 0, 0, 0,
1471 0, 0, 80, 0, 0, 81, 20, 0, 0, 198,
1472 199, 0, 0, 200, 640, 0, 192, 193, 0, 0,
1473 0, 78, 202, 203, 204, 205, 0, 0, 206, 207,
1474 194, 0, 0, 0, 0, 0, 195, 0, 0, 190,
1475 191, 0, 0, 196, 0, 0, 0, 197, 0, 0,
1476 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1477 198, 199, 0, 0, 200, 655, 0, 0, 0, 0,
1478 0, 0, 0, 202, 203, 204, 205, 0, 0, 206,
1479 207, 192, 193, 0, 0, 0, 78, 0, 0, 0,
1480 0, 0, 0, 0, 0, 194, 0, 0, 0, 0,
1481 0, 195, 0, 0, 0, 0, 0, 0, 196, 0,
1482 0, 0, 197, 0, 0, 0, 0, 0, 80, 0,
1483 0, 81, 20, 0, 0, 198, 199, 78, 0, 200,
1484 0, 0, 0, 0, 0, 0, 194, 0, 202, 203,
1485 204, 205, 195, 0, 206, 207, 0, 0, 0, 196,
1486 0, 0, 0, 197, 0, 0, 0, 0, 0, 80,
1487 0, 0, 81, 20, 0, 0, 198, 199, 0, 0,
1488 200, 0, 0, 0, 0, 0, 0, 0, 0, 202,
1489 203, 204, 205, 0, 0, 206, 207
1492 static const short yycheck[] = { 3,
1493 264, 132, 6, 123, 355, 201, 428, 129, 399, 134,
1494 117, 375, 62, 62, 190, 191, 192, 193, 1, 282,
1495 624, 1, 198, 199, 1, 15, 289, 290, 42, 1,
1496 1, 53, 46, 9, 5, 1, 62, 95, 42, 89,
1497 162, 62, 46, 150, 94, 94, 153, 169, 83, 1,
1498 64, 1, 1, 94, 65, 69, 129, 33, 62, 100,
1499 64, 72, 129, 86, 171, 69, 1, 62, 94, 1,
1500 1, 196, 97, 94, 1, 97, 101, 1, 1, 129,
1501 129, 685, 1, 133, 72, 89, 1, 122, 123, 162,
1502 94, 1, 362, 160, 89, 162, 107, 87, 86, 94,
1503 370, 67, 372, 129, 95, 1, 97, 133, 129, 662,
1504 160, 1, 162, 162, 128, 86, 99, 100, 4, 5,
1505 134, 101, 99, 100, 128, 129, 1, 99, 178, 133,
1506 134, 307, 308, 309, 129, 257, 162, 86, 133, 1,
1507 265, 162, 1, 1, 1, 1, 253, 99, 98, 101,
1508 36, 37, 415, 575, 40, 418, 160, 710, 162, 662,
1509 713, 552, 1, 98, 50, 160, 98, 162, 99, 93,
1510 101, 98, 95, 662, 178, 94, 99, 101, 1, 94,
1511 1, 100, 196, 178, 94, 100, 190, 191, 192, 193,
1512 100, 421, 196, 79, 198, 199, 200, 83, 94, 1,
1513 1, 196, 252, 554, 100, 200, 1, 710, 761, 99,
1514 713, 100, 1, 766, 264, 768, 52, 770, 448, 341,
1515 95, 710, 1, 140, 713, 251, 252, 347, 86, 86,
1516 251, 1, 623, 95, 662, 431, 122, 123, 264, 1,
1517 99, 99, 99, 99, 1, 1, 422, 251, 252, 1,
1518 1, 265, 1, 139, 101, 1, 251, 252, 761, 98,
1519 264, 265, 97, 766, 628, 768, 630, 770, 63, 264,
1520 1, 97, 761, 1, 1, 1, 99, 766, 99, 768,
1521 1, 770, 710, 200, 201, 713, 637, 1, 67, 1,
1522 1, 177, 94, 63, 1, 1, 526, 98, 100, 88,
1523 95, 351, 1, 307, 308, 309, 310, 311, 312, 313,
1524 314, 315, 316, 317, 318, 319, 320, 321, 322, 323,
1525 324, 325, 326, 100, 319, 95, 52, 1, 558, 355,
1526 216, 695, 95, 761, 355, 686, 99, 99, 766, 1,
1527 768, 98, 770, 99, 251, 1, 98, 351, 99, 375,
1528 99, 355, 98, 52, 584, 1, 351, 1, 362, 94,
1529 355, 88, 97, 94, 63, 251, 370, 95, 372, 95,
1530 1, 375, 64, 399, 95, 1, 262, 69, 399, 93,
1531 375, 298, 94, 94, 93, 302, 1, 94, 94, 1,
1532 754, 251, 662, 279, 94, 399, 95, 97, 574, 763,
1533 94, 101, 1, 667, 399, 525, 100, 1, 638, 129,
1534 327, 94, 1, 299, 97, 301, 94, 334, 422, 93,
1535 337, 52, 415, 101, 428, 418, 0, 1, 345, 1,
1536 1, 93, 63, 1, 95, 1, 128, 93, 569, 1,
1537 710, 98, 162, 713, 674, 1, 92, 93, 355, 93,
1538 336, 97, 98, 99, 100, 362, 587, 343, 728, 1,
1539 86, 347, 1, 370, 95, 372, 94, 737, 375, 355,
1540 44, 86, 100, 96, 86, 1, 362, 100, 748, 0,
1541 1, 55, 604, 1, 370, 607, 372, 61, 1, 539,
1542 1, 761, 399, 67, 93, 355, 766, 414, 768, 93,
1543 770, 75, 362, 733, 93, 97, 45, 46, 425, 101,
1544 370, 1, 372, 399, 431, 375, 1, 648, 86, 251,
1545 86, 93, 93, 44, 86, 99, 552, 658, 554, 45,
1546 46, 552, 50, 554, 55, 539, 1, 93, 60, 399,
1547 61, 1, 64, 417, 539, 419, 67, 86, 552, 88,
1548 554, 93, 91, 92, 93, 99, 100, 552, 97, 554,
1549 86, 1, 101, 695, 82, 95, 251, 85, 86, 1,
1550 574, 575, 96, 86, 94, 697, 99, 100, 99, 93,
1551 100, 97, 499, 44, 1, 101, 590, 95, 47, 53,
1552 0, 1, 509, 1, 511, 1, 86, 623, 1, 1,
1553 61, 1, 623, 62, 521, 100, 67, 92, 1, 94,
1554 1, 637, 97, 98, 99, 100, 637, 667, 177, 623,
1555 101, 86, 754, 355, 91, 92, 86, 544, 623, 546,
1556 362, 763, 10, 637, 44, 101, 522, 96, 370, 525,
1557 372, 667, 637, 375, 50, 552, 86, 554, 65, 101,
1558 67, 61, 30, 97, 86, 72, 34, 67, 662, 76,
1559 686, 0, 1, 667, 581, 686, 552, 399, 554, 86,
1560 355, 11, 667, 51, 0, 1, 82, 362, 86, 85,
1561 86, 12, 686, 86, 86, 370, 86, 372, 251, 99,
1562 375, 686, 552, 86, 554, 86, 47, 1, 0, 1,
1563 45, 46, 619, 262, 13, 44, 710, 94, 9, 713,
1564 11, 62, 47, 100, 399, 14, 623, 99, 44, 95,
1565 92, 628, 61, 630, 728, 97, 98, 62, 67, 55,
1566 637, 97, 33, 737, 96, 61, 93, 623, 91, 92,
1567 44, 67, 44, 93, 748, 96, 50, 0, 1, 635,
1568 93, 637, 97, 55, 97, 662, 101, 761, 101, 61,
1569 99, 96, 766, 623, 768, 67, 770, 99, 628, 47,
1570 630, 99, 689, 99, 94, 99, 662, 637, 82, 686,
1571 100, 85, 86, 95, 62, 5, 6, 7, 695, 1,
1572 94, 44, 355, 18, 19, 20, 21, 99, 93, 362,
1573 686, 99, 662, 710, 45, 46, 713, 370, 61, 372,
1574 251, 99, 375, 93, 67, 8, 9, 10, 96, 736,
1575 552, 728, 554, 740, 710, 1, 686, 713, 0, 1,
1576 737, 88, 57, 95, 96, 695, 399, 99, 251, 3,
1577 4, 748, 728, 97, 98, 99, 99, 754, 16, 17,
1578 710, 737, 100, 713, 761, 67, 763, 91, 92, 766,
1579 72, 768, 748, 770, 76, 66, 1, 552, 728, 554,
1580 97, 98, 44, 99, 86, 761, 93, 737, 45, 46,
1581 766, 97, 768, 94, 770, 312, 313, 314, 748, 61,
1582 1, 623, 45, 46, 754, 67, 628, 1, 630, 310,
1583 311, 761, 93, 763, 99, 637, 766, 94, 768, 44,
1584 770, 320, 321, 94, 355, 50, 94, 1, 1, 1,
1585 100, 362, 56, 56, 59, 99, 61, 99, 94, 370,
1586 662, 372, 67, 44, 375, 94, 1, 94, 623, 50,
1587 251, 1, 355, 628, 94, 630, 94, 82, 99, 362,
1588 85, 86, 637, 99, 686, 56, 94, 370, 399, 372,
1589 0, 44, 375, 695, 0, 319, 11, 50, 54, 75,
1590 44, 82, 162, 252, 85, 86, 50, 662, 710, 139,
1591 394, 713, 52, 65, 399, 67, 399, 160, 621, 552,
1592 72, 554, 94, 282, 76, 375, 728, 710, 375, 82,
1593 713, 686, 85, 86, 86, 737, 322, 621, 82, 605,
1594 695, 85, 86, 91, 92, 93, 748, 605, 323, 97,
1595 94, 324, 754, 101, 330, 710, 326, -1, 713, 761,
1596 590, 763, 325, -1, 766, 86, 768, -1, 770, -1,
1597 91, 92, 93, 728, 355, -1, 97, -1, 761, -1,
1598 101, 362, 737, 766, -1, 768, 44, 770, -1, 370,
1599 623, 372, 50, 748, 375, 628, -1, 630, -1, 754,
1600 -1, 59, -1, 61, 637, -1, 761, -1, 763, 67,
1601 -1, 766, -1, 768, -1, 770, 44, -1, 399, -1,
1602 -1, -1, 50, -1, 82, -1, -1, 85, 86, 662,
1603 -1, 59, -1, 61, 91, 92, 93, 95, 96, 67,
1604 97, 552, -1, 554, 101, 86, -1, -1, -1, 44,
1605 91, 92, 93, 686, 82, 50, 97, 85, 86, -1,
1606 101, -1, 695, -1, 59, -1, 61, 95, 96, 552,
1607 -1, 554, 67, -1, -1, -1, -1, 710, 86, -1,
1608 713, -1, 44, 91, 92, 93, -1, 82, 50, 97,
1609 85, 86, -1, 101, -1, 728, -1, 59, -1, 61,
1610 -1, 96, -1, -1, 737, 67, 1, -1, 44, -1,
1611 -1, -1, 623, -1, 50, 748, -1, 628, -1, 630,
1612 82, 754, -1, 85, 86, -1, 637, -1, 761, -1,
1613 763, 67, -1, 766, 96, 768, -1, 770, -1, -1,
1614 623, -1, 91, 92, 93, 628, 82, 630, 97, 85,
1615 86, 662, 101, -1, 637, 50, -1, -1, -1, 44,
1616 315, 316, 317, 318, 59, 50, -1, -1, -1, -1,
1617 65, 552, -1, 554, -1, 686, -1, 72, -1, 662,
1618 -1, 76, -1, -1, 695, -1, -1, 82, -1, -1,
1619 85, 86, -1, -1, 89, 90, -1, 82, 93, 710,
1620 85, 86, 713, 686, -1, -1, -1, 102, 103, 104,
1621 105, -1, 695, 108, 109, -1, -1, 728, -1, -1,
1622 -1, -1, -1, -1, -1, -1, 737, 710, -1, -1,
1623 713, -1, -1, -1, -1, -1, -1, 748, -1, -1,
1624 -1, -1, 623, 754, -1, 728, -1, 628, -1, 630,
1625 761, -1, 763, -1, 737, 766, 637, 768, -1, 770,
1626 -1, -1, -1, -1, -1, 748, -1, -1, -1, -1,
1627 -1, 754, -1, -1, -1, -1, -1, -1, 761, -1,
1628 763, 662, -1, 766, -1, 768, -1, 770, 190, 191,
1629 192, 193, -1, -1, -1, -1, 198, 199, -1, -1,
1630 -1, -1, -1, -1, -1, 686, -1, -1, 190, 191,
1631 192, 193, -1, -1, 695, -1, 198, 199, -1, -1,
1632 -1, -1, -1, -1, -1, -1, -1, -1, -1, 710,
1633 -1, -1, 713, -1, 44, 45, 46, -1, -1, -1,
1634 50, -1, -1, -1, -1, -1, -1, 728, -1, 59,
1635 -1, -1, -1, -1, -1, 65, 737, -1, -1, -1,
1636 -1, -1, 72, -1, -1, -1, 76, 748, -1, -1,
1637 -1, -1, 82, 754, -1, 85, 86, -1, -1, -1,
1638 761, -1, 763, 93, -1, 766, -1, 768, -1, 770,
1639 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1640 -1, -1, 1, -1, -1, 307, 308, 309, 310, 311,
1641 312, 313, 314, 315, 316, 317, 318, -1, 320, 321,
1642 322, 323, 324, 325, 326, 307, 308, 309, 310, 311,
1643 312, 313, 314, 315, 316, 317, 318, -1, 320, 321,
1644 322, 323, 324, 325, 326, 44, 45, 46, 47, 48,
1645 49, 50, 51, -1, -1, 54, -1, -1, -1, 58,
1646 59, -1, -1, 62, -1, -1, 65, 66, 67, 68,
1647 -1, 70, 71, 72, 73, -1, -1, 76, -1, -1,
1648 -1, -1, -1, 82, 1, -1, 85, 86, -1, -1,
1649 -1, -1, -1, -1, 93, -1, 95, 96, -1, -1,
1650 99, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1651 109, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1652 422, -1, -1, -1, -1, -1, 428, 44, 45, 46,
1653 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1654 422, 58, 59, -1, -1, -1, 428, -1, 65, 66,
1655 67, 68, 1, 70, 71, 72, 73, -1, -1, 76,
1656 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1657 -1, -1, -1, -1, -1, -1, 93, -1, 95, 96,
1658 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1659 -1, 108, 109, -1, -1, 44, 45, 46, -1, 48,
1660 49, 50, 51, -1, -1, 54, -1, -1, -1, 58,
1661 59, -1, -1, -1, -1, -1, 65, 66, 67, 68,
1662 -1, 70, 71, 72, 73, -1, -1, 76, -1, -1,
1663 -1, -1, 1, 82, -1, -1, 85, 86, -1, -1,
1664 -1, -1, -1, -1, 93, -1, 95, 96, -1, -1,
1665 99, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1666 109, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1667 -1, -1, 574, 575, -1, 44, 45, 46, -1, 48,
1668 49, 50, 51, -1, -1, 54, -1, -1, 590, 58,
1669 59, -1, 574, 575, -1, -1, 65, 66, 67, 68,
1670 1, 70, 71, 72, 73, -1, -1, 76, 590, -1,
1671 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1672 -1, -1, -1, -1, 93, -1, 95, 96, -1, -1,
1673 99, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1674 109, -1, -1, 44, 45, 46, -1, 48, 49, 50,
1675 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
1676 -1, -1, -1, -1, 65, 66, 67, 68, 1, 70,
1677 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1678 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1679 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
1680 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1681 -1, 44, 45, 46, -1, 48, 49, 50, 51, -1,
1682 -1, 54, -1, -1, -1, 58, 59, -1, -1, -1,
1683 -1, -1, 65, 66, 67, 68, 1, 70, 71, 72,
1684 73, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1685 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
1686 93, -1, 95, 96, -1, -1, 99, -1, -1, 102,
1687 103, 104, 105, -1, -1, 108, 109, -1, -1, 44,
1688 45, 46, -1, 48, 49, 50, 51, -1, -1, 54,
1689 -1, -1, -1, 58, 59, -1, -1, -1, -1, -1,
1690 65, 66, 67, 68, 1, 70, 71, 72, 73, -1,
1691 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1692 85, 86, -1, -1, -1, -1, -1, -1, 93, -1,
1693 95, -1, -1, -1, 99, -1, -1, 102, 103, 104,
1694 105, -1, -1, 108, 109, -1, -1, 44, 45, 46,
1695 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1696 -1, 58, 59, -1, -1, -1, -1, -1, 65, 66,
1697 1, 68, -1, 70, 71, 72, 73, -1, -1, 76,
1698 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1699 -1, -1, -1, -1, -1, -1, 93, -1, 95, -1,
1700 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1701 -1, 108, 109, 44, 45, 46, -1, 48, 49, 50,
1702 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
1703 -1, -1, -1, -1, 65, 66, -1, 68, -1, 70,
1704 71, 72, 73, -1, 1, 76, 3, 4, -1, -1,
1705 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1706 -1, -1, 93, -1, 95, -1, -1, -1, 99, -1,
1707 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1708 -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,
1709 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
1710 -1, -1, 59, -1, -1, -1, -1, -1, 65, 1,
1711 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
1712 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1713 -1, -1, 89, 90, -1, -1, 93, -1, 95, 96,
1714 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
1715 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
1716 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
1717 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
1718 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1719 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1720 -1, 93, -1, 95, 45, 46, -1, -1, -1, 50,
1721 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
1722 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
1723 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1724 -1, 82, -1, -1, 85, 86, -1, 88, 89, 90,
1725 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
1726 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
1727 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
1728 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
1729 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
1730 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1731 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1732 45, 46, -1, 99, -1, 50, 102, 103, 104, 105,
1733 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
1734 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
1735 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1736 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1737 -1, -1, -1, 98, -1, -1, -1, 102, 103, 104,
1738 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
1739 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
1740 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
1741 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1742 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1743 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
1744 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
1745 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
1746 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1747 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1748 89, 90, -1, -1, 93, -1, -1, -1, -1, 98,
1749 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1750 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
1751 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
1752 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1753 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1754 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1755 -1, -1, 45, 46, 98, -1, -1, 50, 102, 103,
1756 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
1757 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
1758 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1759 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1760 93, 94, -1, -1, -1, -1, -1, -1, -1, 102,
1761 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
1762 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
1763 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
1764 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
1765 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1766 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
1767 -1, 99, -1, 50, 102, 103, 104, 105, -1, -1,
1768 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
1769 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
1770 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1771 -1, -1, 89, 90, -1, -1, 93, 94, -1, -1,
1772 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
1773 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
1774 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
1775 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
1776 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1777 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1778 -1, 93, 94, -1, 45, 46, -1, -1, -1, 50,
1779 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
1780 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
1781 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1782 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1783 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
1784 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
1785 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
1786 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
1787 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
1788 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1789 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1790 45, 46, -1, 99, -1, 50, 102, 103, 104, 105,
1791 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
1792 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
1793 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1794 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1795 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
1796 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
1797 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
1798 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
1799 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1800 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1801 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
1802 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
1803 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
1804 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1805 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1806 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
1807 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1808 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
1809 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
1810 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1811 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1812 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1813 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
1814 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
1815 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
1816 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1817 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1818 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
1819 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
1820 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
1821 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
1822 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
1823 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1824 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
1825 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
1826 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
1827 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
1828 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1829 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
1830 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
1831 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
1832 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
1833 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
1834 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1835 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1836 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
1837 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
1838 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
1839 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1840 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1841 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
1842 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
1843 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
1844 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
1845 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
1846 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1847 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1848 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
1849 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
1850 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
1851 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1852 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1853 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
1854 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
1855 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
1856 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
1857 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1858 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1859 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
1860 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
1861 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
1862 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1863 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1864 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
1865 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1866 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
1867 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
1868 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1869 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1870 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1871 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
1872 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
1873 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
1874 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1875 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1876 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
1877 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
1878 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
1879 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
1880 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
1881 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1882 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
1883 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
1884 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
1885 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
1886 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1887 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
1888 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
1889 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
1890 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
1891 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
1892 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1893 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1894 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
1895 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
1896 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
1897 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1898 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1899 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
1900 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
1901 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
1902 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
1903 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
1904 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1905 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1906 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
1907 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
1908 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
1909 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1910 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1911 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
1912 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
1913 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
1914 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
1915 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1916 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1917 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
1918 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
1919 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
1920 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1921 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1922 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
1923 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1924 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
1925 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
1926 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1927 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1928 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1929 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
1930 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
1931 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
1932 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1933 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1934 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
1935 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
1936 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
1937 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
1938 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
1939 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1940 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
1941 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
1942 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
1943 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
1944 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1945 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
1946 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
1947 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
1948 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
1949 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
1950 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1951 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1952 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
1953 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
1954 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
1955 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1956 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1957 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
1958 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
1959 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
1960 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
1961 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
1962 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1963 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1964 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
1965 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
1966 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
1967 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1968 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1969 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
1970 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
1971 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
1972 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
1973 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1974 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1975 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
1976 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
1977 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
1978 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1979 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1980 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
1981 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
1982 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
1983 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
1984 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1985 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1986 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1987 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
1988 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
1989 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
1990 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1991 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1992 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
1993 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
1994 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
1995 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
1996 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
1997 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1998 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
1999 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2000 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2001 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2002 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2003 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2004 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2005 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2006 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2007 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2008 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2009 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2010 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2011 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2012 -1, -1, -1, -1, 65, -1, 1, -1, -1, -1,
2013 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2014 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2015 -1, 1, 93, -1, -1, -1, -1, -1, -1, -1,
2016 -1, 102, 103, 104, 105, -1, -1, 108, 109, 44,
2017 45, 46, -1, -1, -1, 50, -1, -1, -1, -1,
2018 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2019 65, -1, -1, 1, -1, 45, 46, 72, -1, -1,
2020 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
2021 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
2022 3, 4, 72, -1, 99, -1, 76, 102, 103, 104,
2023 105, -1, 82, 108, 109, 85, 86, 45, 46, -1,
2024 -1, -1, 50, 93, 94, -1, -1, -1, -1, -1,
2025 -1, 59, 102, 103, 104, 105, -1, 65, 108, 109,
2026 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2027 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2028 -1, -1, 65, -1, -1, 93, 94, 3, 4, 72,
2029 -1, -1, -1, 76, 102, 103, 104, 105, -1, 82,
2030 108, 109, 85, 86, 45, 46, 89, 90, -1, 50,
2031 93, -1, 95, 96, -1, -1, -1, 100, 59, 102,
2032 103, 104, 105, -1, 65, 108, 109, -1, -1, 45,
2033 46, 72, -1, -1, 50, 76, -1, -1, 3, 4,
2034 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2035 -1, -1, 93, -1, -1, -1, 72, -1, -1, -1,
2036 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2037 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2038 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2039 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2040 65, -1, -1, 3, 4, -1, -1, 72, -1, -1,
2041 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2042 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
2043 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2044 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2045 50, -1, -1, -1, 3, 4, -1, -1, -1, 59,
2046 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2047 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2048 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2049 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
2050 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2051 59, -1, -1, -1, -1, -1, 65, -1, -1, 3,
2052 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2053 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2054 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2055 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2056 109, 45, 46, -1, -1, -1, 50, -1, -1, -1,
2057 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
2058 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2059 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2060 -1, 85, 86, -1, -1, 89, 90, 50, -1, 93,
2061 -1, -1, -1, -1, -1, -1, 59, -1, 102, 103,
2062 104, 105, 65, -1, 108, 109, -1, -1, -1, 72,
2063 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2064 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2065 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2066 103, 104, 105, -1, -1, 108, 109
2068 #define YYPURE 1
2070 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2071 #line 3 "/x1/java-install/share/bison.simple"
2073 /* Skeleton output parser for bison,
2074 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2076 This program is free software; you can redistribute it and/or modify
2077 it under the terms of the GNU General Public License as published by
2078 the Free Software Foundation; either version 2, or (at your option)
2079 any later version.
2081 This program is distributed in the hope that it will be useful,
2082 but WITHOUT ANY WARRANTY; without even the implied warranty of
2083 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2084 GNU General Public License for more details.
2086 You should have received a copy of the GNU General Public License
2087 along with this program; if not, write to the Free Software
2088 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
2090 /* As a special exception, when this file is copied by Bison into a
2091 Bison output file, you may use that output file without restriction.
2092 This special exception was added by the Free Software Foundation
2093 in version 1.24 of Bison. */
2095 #ifndef alloca
2096 #ifdef __GNUC__
2097 #define alloca __builtin_alloca
2098 #else /* not GNU C. */
2099 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
2100 #include <alloca.h>
2101 #else /* not sparc */
2102 #if defined (MSDOS) && !defined (__TURBOC__)
2103 #include <malloc.h>
2104 #else /* not MSDOS, or __TURBOC__ */
2105 #if defined(_AIX)
2106 #include <malloc.h>
2107 #pragma alloca
2108 #else /* not MSDOS, __TURBOC__, or _AIX */
2109 #ifdef __hpux
2110 #ifdef __cplusplus
2111 extern "C" {
2112 void *alloca (unsigned int);
2114 #else /* not __cplusplus */
2115 void *alloca ();
2116 #endif /* not __cplusplus */
2117 #endif /* __hpux */
2118 #endif /* not _AIX */
2119 #endif /* not MSDOS, or __TURBOC__ */
2120 #endif /* not sparc. */
2121 #endif /* not GNU C. */
2122 #endif /* alloca not defined. */
2124 /* This is the parser code that is written into each bison parser
2125 when the %semantic_parser declaration is not specified in the grammar.
2126 It was written by Richard Stallman by simplifying the hairy parser
2127 used when %semantic_parser is specified. */
2129 /* Note: there must be only one dollar sign in this file.
2130 It is replaced by the list of actions, each action
2131 as one case of the switch. */
2133 #define yyerrok (yyerrstatus = 0)
2134 #define yyclearin (yychar = YYEMPTY)
2135 #define YYEMPTY -2
2136 #define YYEOF 0
2137 #define YYACCEPT return(0)
2138 #define YYABORT return(1)
2139 #define YYERROR goto yyerrlab1
2140 /* Like YYERROR except do call yyerror.
2141 This remains here temporarily to ease the
2142 transition to the new meaning of YYERROR, for GCC.
2143 Once GCC version 2 has supplanted version 1, this can go. */
2144 #define YYFAIL goto yyerrlab
2145 #define YYRECOVERING() (!!yyerrstatus)
2146 #define YYBACKUP(token, value) \
2147 do \
2148 if (yychar == YYEMPTY && yylen == 1) \
2149 { yychar = (token), yylval = (value); \
2150 yychar1 = YYTRANSLATE (yychar); \
2151 YYPOPSTACK; \
2152 goto yybackup; \
2154 else \
2155 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2156 while (0)
2158 #define YYTERROR 1
2159 #define YYERRCODE 256
2161 #ifndef YYPURE
2162 #define YYLEX yylex()
2163 #endif
2165 #ifdef YYPURE
2166 #ifdef YYLSP_NEEDED
2167 #ifdef YYLEX_PARAM
2168 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2169 #else
2170 #define YYLEX yylex(&yylval, &yylloc)
2171 #endif
2172 #else /* not YYLSP_NEEDED */
2173 #ifdef YYLEX_PARAM
2174 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2175 #else
2176 #define YYLEX yylex(&yylval)
2177 #endif
2178 #endif /* not YYLSP_NEEDED */
2179 #endif
2181 /* If nonreentrant, generate the variables here */
2183 #ifndef YYPURE
2185 int yychar; /* the lookahead symbol */
2186 YYSTYPE yylval; /* the semantic value of the */
2187 /* lookahead symbol */
2189 #ifdef YYLSP_NEEDED
2190 YYLTYPE yylloc; /* location data for the lookahead */
2191 /* symbol */
2192 #endif
2194 int yynerrs; /* number of parse errors so far */
2195 #endif /* not YYPURE */
2197 #if YYDEBUG != 0
2198 int yydebug; /* nonzero means print parse trace */
2199 /* Since this is uninitialized, it does not stop multiple parsers
2200 from coexisting. */
2201 #endif
2203 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2205 #ifndef YYINITDEPTH
2206 #define YYINITDEPTH 200
2207 #endif
2209 /* YYMAXDEPTH is the maximum size the stacks can grow to
2210 (effective only if the built-in stack extension method is used). */
2212 #if YYMAXDEPTH == 0
2213 #undef YYMAXDEPTH
2214 #endif
2216 #ifndef YYMAXDEPTH
2217 #define YYMAXDEPTH 10000
2218 #endif
2220 /* Prevent warning if -Wstrict-prototypes. */
2221 #ifdef __GNUC__
2222 int yyparse (void);
2223 #endif
2225 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2226 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2227 #else /* not GNU C or C++ */
2228 #ifndef __cplusplus
2230 /* This is the most reliable way to avoid incompatibilities
2231 in available built-in functions on various systems. */
2232 static void
2233 __yy_memcpy (to, from, count)
2234 char *to;
2235 char *from;
2236 int count;
2238 register char *f = from;
2239 register char *t = to;
2240 register int i = count;
2242 while (i-- > 0)
2243 *t++ = *f++;
2246 #else /* __cplusplus */
2248 /* This is the most reliable way to avoid incompatibilities
2249 in available built-in functions on various systems. */
2250 static void
2251 __yy_memcpy (char *to, char *from, int count)
2253 register char *f = from;
2254 register char *t = to;
2255 register int i = count;
2257 while (i-- > 0)
2258 *t++ = *f++;
2261 #endif
2262 #endif
2264 #line 196 "/x1/java-install/share/bison.simple"
2266 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2267 into yyparse. The argument should have type void *.
2268 It should actually point to an object.
2269 Grammar actions can access the variable by casting it
2270 to the proper pointer type. */
2272 #ifdef YYPARSE_PARAM
2273 #ifdef __cplusplus
2274 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2275 #define YYPARSE_PARAM_DECL
2276 #else /* not __cplusplus */
2277 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2278 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2279 #endif /* not __cplusplus */
2280 #else /* not YYPARSE_PARAM */
2281 #define YYPARSE_PARAM_ARG
2282 #define YYPARSE_PARAM_DECL
2283 #endif /* not YYPARSE_PARAM */
2286 yyparse(YYPARSE_PARAM_ARG)
2287 YYPARSE_PARAM_DECL
2289 register int yystate;
2290 register int yyn;
2291 register short *yyssp;
2292 register YYSTYPE *yyvsp;
2293 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2294 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2296 short yyssa[YYINITDEPTH]; /* the state stack */
2297 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2299 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2300 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2302 #ifdef YYLSP_NEEDED
2303 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2304 YYLTYPE *yyls = yylsa;
2305 YYLTYPE *yylsp;
2307 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2308 #else
2309 #define YYPOPSTACK (yyvsp--, yyssp--)
2310 #endif
2312 int yystacksize = YYINITDEPTH;
2314 #ifdef YYPURE
2315 int yychar;
2316 YYSTYPE yylval;
2317 int yynerrs;
2318 #ifdef YYLSP_NEEDED
2319 YYLTYPE yylloc;
2320 #endif
2321 #endif
2323 YYSTYPE yyval; /* the variable used to return */
2324 /* semantic values from the action */
2325 /* routines */
2327 int yylen;
2329 #if YYDEBUG != 0
2330 if (yydebug)
2331 fprintf(stderr, "Starting parse\n");
2332 #endif
2334 yystate = 0;
2335 yyerrstatus = 0;
2336 yynerrs = 0;
2337 yychar = YYEMPTY; /* Cause a token to be read. */
2339 /* Initialize stack pointers.
2340 Waste one element of value and location stack
2341 so that they stay on the same level as the state stack.
2342 The wasted elements are never initialized. */
2344 yyssp = yyss - 1;
2345 yyvsp = yyvs;
2346 #ifdef YYLSP_NEEDED
2347 yylsp = yyls;
2348 #endif
2350 /* Push a new state, which is found in yystate . */
2351 /* In all cases, when you get here, the value and location stacks
2352 have just been pushed. so pushing a state here evens the stacks. */
2353 yynewstate:
2355 *++yyssp = yystate;
2357 if (yyssp >= yyss + yystacksize - 1)
2359 /* Give user a chance to reallocate the stack */
2360 /* Use copies of these so that the &'s don't force the real ones into memory. */
2361 YYSTYPE *yyvs1 = yyvs;
2362 short *yyss1 = yyss;
2363 #ifdef YYLSP_NEEDED
2364 YYLTYPE *yyls1 = yyls;
2365 #endif
2367 /* Get the current used size of the three stacks, in elements. */
2368 int size = yyssp - yyss + 1;
2370 #ifdef yyoverflow
2371 /* Each stack pointer address is followed by the size of
2372 the data in use in that stack, in bytes. */
2373 #ifdef YYLSP_NEEDED
2374 /* This used to be a conditional around just the two extra args,
2375 but that might be undefined if yyoverflow is a macro. */
2376 yyoverflow("parser stack overflow",
2377 &yyss1, size * sizeof (*yyssp),
2378 &yyvs1, size * sizeof (*yyvsp),
2379 &yyls1, size * sizeof (*yylsp),
2380 &yystacksize);
2381 #else
2382 yyoverflow("parser stack overflow",
2383 &yyss1, size * sizeof (*yyssp),
2384 &yyvs1, size * sizeof (*yyvsp),
2385 &yystacksize);
2386 #endif
2388 yyss = yyss1; yyvs = yyvs1;
2389 #ifdef YYLSP_NEEDED
2390 yyls = yyls1;
2391 #endif
2392 #else /* no yyoverflow */
2393 /* Extend the stack our own way. */
2394 if (yystacksize >= YYMAXDEPTH)
2396 yyerror("parser stack overflow");
2397 return 2;
2399 yystacksize *= 2;
2400 if (yystacksize > YYMAXDEPTH)
2401 yystacksize = YYMAXDEPTH;
2402 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
2403 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
2404 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
2405 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
2406 #ifdef YYLSP_NEEDED
2407 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
2408 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
2409 #endif
2410 #endif /* no yyoverflow */
2412 yyssp = yyss + size - 1;
2413 yyvsp = yyvs + size - 1;
2414 #ifdef YYLSP_NEEDED
2415 yylsp = yyls + size - 1;
2416 #endif
2418 #if YYDEBUG != 0
2419 if (yydebug)
2420 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2421 #endif
2423 if (yyssp >= yyss + yystacksize - 1)
2424 YYABORT;
2427 #if YYDEBUG != 0
2428 if (yydebug)
2429 fprintf(stderr, "Entering state %d\n", yystate);
2430 #endif
2432 goto yybackup;
2433 yybackup:
2435 /* Do appropriate processing given the current state. */
2436 /* Read a lookahead token if we need one and don't already have one. */
2437 /* yyresume: */
2439 /* First try to decide what to do without reference to lookahead token. */
2441 yyn = yypact[yystate];
2442 if (yyn == YYFLAG)
2443 goto yydefault;
2445 /* Not known => get a lookahead token if don't already have one. */
2447 /* yychar is either YYEMPTY or YYEOF
2448 or a valid token in external form. */
2450 if (yychar == YYEMPTY)
2452 #if YYDEBUG != 0
2453 if (yydebug)
2454 fprintf(stderr, "Reading a token: ");
2455 #endif
2456 yychar = YYLEX;
2459 /* Convert token to internal form (in yychar1) for indexing tables with */
2461 if (yychar <= 0) /* This means end of input. */
2463 yychar1 = 0;
2464 yychar = YYEOF; /* Don't call YYLEX any more */
2466 #if YYDEBUG != 0
2467 if (yydebug)
2468 fprintf(stderr, "Now at end of input.\n");
2469 #endif
2471 else
2473 yychar1 = YYTRANSLATE(yychar);
2475 #if YYDEBUG != 0
2476 if (yydebug)
2478 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2479 /* Give the individual parser a way to print the precise meaning
2480 of a token, for further debugging info. */
2481 #ifdef YYPRINT
2482 YYPRINT (stderr, yychar, yylval);
2483 #endif
2484 fprintf (stderr, ")\n");
2486 #endif
2489 yyn += yychar1;
2490 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2491 goto yydefault;
2493 yyn = yytable[yyn];
2495 /* yyn is what to do for this token type in this state.
2496 Negative => reduce, -yyn is rule number.
2497 Positive => shift, yyn is new state.
2498 New state is final state => don't bother to shift,
2499 just return success.
2500 0, or most negative number => error. */
2502 if (yyn < 0)
2504 if (yyn == YYFLAG)
2505 goto yyerrlab;
2506 yyn = -yyn;
2507 goto yyreduce;
2509 else if (yyn == 0)
2510 goto yyerrlab;
2512 if (yyn == YYFINAL)
2513 YYACCEPT;
2515 /* Shift the lookahead token. */
2517 #if YYDEBUG != 0
2518 if (yydebug)
2519 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2520 #endif
2522 /* Discard the token being shifted unless it is eof. */
2523 if (yychar != YYEOF)
2524 yychar = YYEMPTY;
2526 *++yyvsp = yylval;
2527 #ifdef YYLSP_NEEDED
2528 *++yylsp = yylloc;
2529 #endif
2531 /* count tokens shifted since error; after three, turn off error status. */
2532 if (yyerrstatus) yyerrstatus--;
2534 yystate = yyn;
2535 goto yynewstate;
2537 /* Do the default action for the current state. */
2538 yydefault:
2540 yyn = yydefact[yystate];
2541 if (yyn == 0)
2542 goto yyerrlab;
2544 /* Do a reduction. yyn is the number of a rule to reduce with. */
2545 yyreduce:
2546 yylen = yyr2[yyn];
2547 if (yylen > 0)
2548 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2550 #if YYDEBUG != 0
2551 if (yydebug)
2553 int i;
2555 fprintf (stderr, "Reducing via rule %d (line %d), ",
2556 yyn, yyrline[yyn]);
2558 /* Print the symbols being reduced, and their result. */
2559 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2560 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2561 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2563 #endif
2566 switch (yyn) {
2568 case 1:
2569 #line 273 "gcc/java/parse.y"
2571 break;}
2572 case 18:
2573 #line 317 "gcc/java/parse.y"
2575 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2576 CLASS_LOADED_P (yyval.node) = 1;
2578 break;}
2579 case 19:
2580 #line 322 "gcc/java/parse.y"
2581 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2582 break;}
2583 case 20:
2584 #line 324 "gcc/java/parse.y"
2585 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2586 break;}
2587 case 21:
2588 #line 326 "gcc/java/parse.y"
2589 {RULE ("']' expected"); RECOVER;;
2590 break;}
2591 case 22:
2592 #line 328 "gcc/java/parse.y"
2593 {RULE ("']' expected"); RECOVER;;
2594 break;}
2595 case 26:
2596 #line 343 "gcc/java/parse.y"
2597 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2598 break;}
2599 case 28:
2600 #line 352 "gcc/java/parse.y"
2601 {yyval.node = NULL;;
2602 break;}
2603 case 36:
2604 #line 364 "gcc/java/parse.y"
2606 yyval.node = NULL;
2608 break;}
2609 case 37:
2610 #line 368 "gcc/java/parse.y"
2612 yyval.node = NULL;
2614 break;}
2615 case 40:
2616 #line 380 "gcc/java/parse.y"
2617 { ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node); ;
2618 break;}
2619 case 41:
2620 #line 382 "gcc/java/parse.y"
2621 {yyerror ("Missing name"); RECOVER;;
2622 break;}
2623 case 42:
2624 #line 384 "gcc/java/parse.y"
2625 {yyerror ("';' expected"); RECOVER;;
2626 break;}
2627 case 45:
2628 #line 394 "gcc/java/parse.y"
2630 tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2631 int i = IDENTIFIER_LENGTH (name)-1;
2632 char *last = &IDENTIFIER_POINTER (name)[i];
2633 while (last != IDENTIFIER_POINTER (name))
2635 if (last [0] == '.')
2636 break;
2637 last--;
2639 last_name = get_identifier (++last);
2640 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
2642 tree err = find_name_in_single_imports (last_name);
2643 if (err && err != name)
2644 parse_error_context
2645 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
2646 IDENTIFIER_POINTER (name),
2647 IDENTIFIER_POINTER (err));
2649 else
2651 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name) = 1;
2652 node = build_tree_list (yyvsp[-1].node, last_name);
2653 TREE_CHAIN (node) = ctxp->import_list;
2654 ctxp->import_list = node;
2657 break;}
2658 case 46:
2659 #line 423 "gcc/java/parse.y"
2660 {yyerror ("Missing name"); RECOVER;;
2661 break;}
2662 case 47:
2663 #line 425 "gcc/java/parse.y"
2664 {yyerror ("';' expected"); RECOVER;;
2665 break;}
2666 case 48:
2667 #line 430 "gcc/java/parse.y"
2669 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
2670 tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2671 if (!IS_AN_IMPORT_ON_DEMAND_P (name))
2673 read_import_dir (yyvsp[-3].node);
2674 IS_AN_IMPORT_ON_DEMAND_P (name) = 1;
2676 TREE_CHAIN (node) = ctxp->import_demand_list;
2677 ctxp->import_demand_list = node;
2679 break;}
2680 case 49:
2681 #line 442 "gcc/java/parse.y"
2682 {yyerror ("'*' expected"); RECOVER;;
2683 break;}
2684 case 50:
2685 #line 444 "gcc/java/parse.y"
2686 {yyerror ("';' expected"); RECOVER;;
2687 break;}
2688 case 51:
2689 #line 449 "gcc/java/parse.y"
2691 maybe_generate_clinit ();
2692 yyval.node = yyvsp[0].node;
2694 break;}
2695 case 53:
2696 #line 455 "gcc/java/parse.y"
2697 { yyval.node = NULL; ;
2698 break;}
2699 case 54:
2700 #line 457 "gcc/java/parse.y"
2702 YYERROR_NOW;
2703 yyerror ("Class or interface declaration expected");
2705 break;}
2706 case 55:
2707 #line 468 "gcc/java/parse.y"
2709 yyval.value = (1 << yyvsp[0].value);
2711 break;}
2712 case 56:
2713 #line 472 "gcc/java/parse.y"
2715 int acc = (1 << yyvsp[0].value);
2716 if (yyval.value & acc)
2717 parse_error_context
2718 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
2719 java_accstring_lookup (acc));
2720 else
2722 yyval.value |= acc;
2725 break;}
2726 case 57:
2727 #line 488 "gcc/java/parse.y"
2728 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2729 break;}
2730 case 58:
2731 #line 490 "gcc/java/parse.y"
2733 yyval.node = yyvsp[0].node;
2735 break;}
2736 case 59:
2737 #line 494 "gcc/java/parse.y"
2738 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2739 break;}
2740 case 60:
2741 #line 496 "gcc/java/parse.y"
2743 yyval.node = yyvsp[0].node;
2745 break;}
2746 case 61:
2747 #line 500 "gcc/java/parse.y"
2748 {yyerror ("Missing class name"); RECOVER;;
2749 break;}
2750 case 62:
2751 #line 502 "gcc/java/parse.y"
2752 {yyerror ("Missing class name"); RECOVER;;
2753 break;}
2754 case 63:
2755 #line 504 "gcc/java/parse.y"
2756 {if (!ctxp->class_err) yyerror ("'{' expected"); DRECOVER(class1);;
2757 break;}
2758 case 64:
2759 #line 506 "gcc/java/parse.y"
2760 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
2761 break;}
2762 case 65:
2763 #line 510 "gcc/java/parse.y"
2764 { yyval.node = NULL; ;
2765 break;}
2766 case 66:
2767 #line 512 "gcc/java/parse.y"
2768 { yyval.node = yyvsp[0].node; ;
2769 break;}
2770 case 67:
2771 #line 514 "gcc/java/parse.y"
2772 {yyerror ("'{' expected"); ctxp->class_err=1;;
2773 break;}
2774 case 68:
2775 #line 516 "gcc/java/parse.y"
2776 {yyerror ("Missing super class name"); ctxp->class_err=1;;
2777 break;}
2778 case 69:
2779 #line 520 "gcc/java/parse.y"
2780 { yyval.node = NULL_TREE; ;
2781 break;}
2782 case 70:
2783 #line 522 "gcc/java/parse.y"
2784 { yyval.node = yyvsp[0].node; ;
2785 break;}
2786 case 71:
2787 #line 524 "gcc/java/parse.y"
2789 ctxp->class_err=1;
2790 yyerror ("Missing interface name");
2792 break;}
2793 case 72:
2794 #line 532 "gcc/java/parse.y"
2796 ctxp->interface_number = 1;
2797 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
2799 break;}
2800 case 73:
2801 #line 537 "gcc/java/parse.y"
2803 ctxp->interface_number++;
2804 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
2806 break;}
2807 case 74:
2808 #line 542 "gcc/java/parse.y"
2809 {yyerror ("Missing interface name"); RECOVER;;
2810 break;}
2811 case 75:
2812 #line 547 "gcc/java/parse.y"
2813 { yyval.node = ctxp->current_parsed_class; ;
2814 break;}
2815 case 76:
2816 #line 549 "gcc/java/parse.y"
2817 { yyval.node = ctxp->current_parsed_class; ;
2818 break;}
2819 case 82:
2820 #line 562 "gcc/java/parse.y"
2821 { yyval.node = parse_jdk1_1_error ("instance initializer"); ;
2822 break;}
2823 case 85:
2824 #line 569 "gcc/java/parse.y"
2825 { yyval.node = parse_jdk1_1_error ("inner classe declaration"); ;
2826 break;}
2827 case 86:
2828 #line 571 "gcc/java/parse.y"
2829 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
2830 break;}
2831 case 87:
2832 #line 577 "gcc/java/parse.y"
2833 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
2834 break;}
2835 case 88:
2836 #line 579 "gcc/java/parse.y"
2838 check_modifiers
2839 ("Illegal modifier `%s' for field declaration",
2840 yyvsp[-3].value, FIELD_MODIFIERS);
2841 check_modifiers_consistency (yyvsp[-3].value);
2842 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
2844 break;}
2845 case 90:
2846 #line 592 "gcc/java/parse.y"
2847 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
2848 break;}
2849 case 91:
2850 #line 594 "gcc/java/parse.y"
2851 {yyerror ("Missing term"); RECOVER;;
2852 break;}
2853 case 92:
2854 #line 599 "gcc/java/parse.y"
2855 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
2856 break;}
2857 case 93:
2858 #line 601 "gcc/java/parse.y"
2860 if (java_error_count)
2861 yyvsp[0].node = NULL_TREE;
2862 yyval.node = build_tree_list
2863 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
2865 break;}
2866 case 94:
2867 #line 608 "gcc/java/parse.y"
2869 yyerror ("Missing variable initializer");
2870 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
2871 RECOVER;
2873 break;}
2874 case 95:
2875 #line 614 "gcc/java/parse.y"
2877 yyerror ("';' expected");
2878 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2879 RECOVER;
2881 break;}
2882 case 97:
2883 #line 624 "gcc/java/parse.y"
2884 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2885 break;}
2886 case 98:
2887 #line 626 "gcc/java/parse.y"
2888 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
2889 break;}
2890 case 99:
2891 #line 628 "gcc/java/parse.y"
2892 {yyerror ("']' expected"); DRECOVER(vdi);;
2893 break;}
2894 case 100:
2895 #line 630 "gcc/java/parse.y"
2896 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
2897 break;}
2898 case 102:
2899 #line 636 "gcc/java/parse.y"
2900 { yyval.node = NULL; ;
2901 break;}
2902 case 103:
2903 #line 642 "gcc/java/parse.y"
2905 current_function_decl = yyvsp[0].node;
2906 source_start_java_method (current_function_decl);
2908 break;}
2909 case 104:
2910 #line 647 "gcc/java/parse.y"
2912 BLOCK_EXPR_BODY
2913 (DECL_FUNCTION_BODY (current_function_decl)) = yyvsp[0].node;
2914 maybe_absorb_scoping_blocks ();
2915 exit_block (); /* Exit function's body. */
2917 /* Merge last line of the function with first line,
2918 directly in the function decl. It will be used to
2919 emit correct debug info. */
2920 DECL_SOURCE_LINE_MERGE (current_function_decl,
2921 ctxp->last_ccb_indent1);
2923 break;}
2924 case 105:
2925 #line 660 "gcc/java/parse.y"
2926 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
2927 break;}
2928 case 106:
2929 #line 665 "gcc/java/parse.y"
2930 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2931 break;}
2932 case 107:
2933 #line 667 "gcc/java/parse.y"
2934 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
2935 break;}
2936 case 108:
2937 #line 669 "gcc/java/parse.y"
2938 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2939 break;}
2940 case 109:
2941 #line 671 "gcc/java/parse.y"
2942 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
2943 break;}
2944 case 110:
2945 #line 673 "gcc/java/parse.y"
2946 {RECOVER;;
2947 break;}
2948 case 111:
2949 #line 675 "gcc/java/parse.y"
2950 {RECOVER;;
2951 break;}
2952 case 112:
2953 #line 677 "gcc/java/parse.y"
2954 {yyerror ("Identifier expected"); RECOVER;;
2955 break;}
2956 case 113:
2957 #line 679 "gcc/java/parse.y"
2958 {yyerror ("Identifier expected"); RECOVER;;
2959 break;}
2960 case 114:
2961 #line 681 "gcc/java/parse.y"
2963 yyerror ("Invalid method declaration, return type required");
2964 RECOVER;
2966 break;}
2967 case 115:
2968 #line 689 "gcc/java/parse.y"
2969 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
2970 break;}
2971 case 116:
2972 #line 691 "gcc/java/parse.y"
2973 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
2974 break;}
2975 case 117:
2976 #line 693 "gcc/java/parse.y"
2978 /* Issue a warning here: obsolete declaration. FIXME */
2979 yyval.node = NULL; /* FIXME */
2981 break;}
2982 case 118:
2983 #line 698 "gcc/java/parse.y"
2984 {yyerror ("')' expected"); DRECOVER(method_declarator);;
2985 break;}
2986 case 119:
2987 #line 700 "gcc/java/parse.y"
2988 {yyerror ("']' expected"); RECOVER;;
2989 break;}
2990 case 120:
2991 #line 705 "gcc/java/parse.y"
2993 ctxp->formal_parameter_number = 1;
2995 break;}
2996 case 121:
2997 #line 709 "gcc/java/parse.y"
2999 ctxp->formal_parameter_number += 1;
3000 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3002 break;}
3003 case 122:
3004 #line 714 "gcc/java/parse.y"
3005 {yyerror ("Missing formal parameter term"); RECOVER;;
3006 break;}
3007 case 123:
3008 #line 719 "gcc/java/parse.y"
3010 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3012 break;}
3013 case 124:
3014 #line 723 "gcc/java/parse.y"
3015 { yyval.node = parse_jdk1_1_error ("final local"); ;
3016 break;}
3017 case 125:
3018 #line 725 "gcc/java/parse.y"
3019 {yyerror ("Missing identifier"); RECOVER;;
3020 break;}
3021 case 126:
3022 #line 727 "gcc/java/parse.y"
3024 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-2].value));
3025 yyerror ("Missing identifier"); RECOVER;
3027 break;}
3028 case 127:
3029 #line 734 "gcc/java/parse.y"
3030 { yyval.node = NULL_TREE; ;
3031 break;}
3032 case 128:
3033 #line 736 "gcc/java/parse.y"
3034 { yyval.node = yyvsp[0].node; ;
3035 break;}
3036 case 129:
3037 #line 738 "gcc/java/parse.y"
3038 {yyerror ("Missing class type term"); RECOVER;;
3039 break;}
3040 case 130:
3041 #line 743 "gcc/java/parse.y"
3042 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
3043 break;}
3044 case 131:
3045 #line 745 "gcc/java/parse.y"
3046 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node); ;
3047 break;}
3048 case 132:
3049 #line 747 "gcc/java/parse.y"
3050 {yyerror ("Missing class type term"); RECOVER;;
3051 break;}
3052 case 135:
3053 #line 754 "gcc/java/parse.y"
3054 { yyval.node = NULL_TREE; ;
3055 break;}
3056 case 136:
3057 #line 760 "gcc/java/parse.y"
3059 RULE ("STATIC_INITIALIZER");
3061 break;}
3062 case 137:
3063 #line 764 "gcc/java/parse.y"
3065 RULE ("STATIC_INITIALIZER");
3067 break;}
3068 case 138:
3069 #line 771 "gcc/java/parse.y"
3071 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3073 break;}
3074 case 139:
3075 #line 783 "gcc/java/parse.y"
3077 RULE ("CONSTRUCTOR_DECLARATION");
3079 break;}
3080 case 140:
3081 #line 787 "gcc/java/parse.y"
3083 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-3].value));
3084 RULE ("CONSTRUCTOR_DECLARATION (modifier)");
3086 break;}
3087 case 141:
3088 #line 793 "gcc/java/parse.y"
3090 RULE ("CONSTRUCTOR_DECLARATION");
3092 break;}
3093 case 142:
3094 #line 798 "gcc/java/parse.y"
3096 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-4].value));
3097 RULE ("CONSTRUCTOR_DECLARATION (modifier)");
3099 break;}
3100 case 151:
3101 #line 825 "gcc/java/parse.y"
3102 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3103 break;}
3104 case 152:
3105 #line 827 "gcc/java/parse.y"
3106 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3107 break;}
3108 case 153:
3109 #line 832 "gcc/java/parse.y"
3111 tree wfl = build_wfl_node (this_identifier_node,
3112 input_filename, 0, 0);
3113 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3114 yyval.node = wfl;
3116 break;}
3117 case 154:
3118 #line 839 "gcc/java/parse.y"
3120 tree wfl = build_wfl_node (super_identifier_node,
3121 input_filename, 0, 0);
3122 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3123 yyval.node = wfl;
3125 break;}
3126 case 155:
3127 #line 851 "gcc/java/parse.y"
3128 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3129 break;}
3130 case 156:
3131 #line 853 "gcc/java/parse.y"
3133 yyval.node = yyvsp[0].node;
3135 break;}
3136 case 157:
3137 #line 857 "gcc/java/parse.y"
3138 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3139 break;}
3140 case 158:
3141 #line 859 "gcc/java/parse.y"
3143 yyval.node = yyvsp[0].node;
3145 break;}
3146 case 159:
3147 #line 863 "gcc/java/parse.y"
3148 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3149 break;}
3150 case 160:
3151 #line 865 "gcc/java/parse.y"
3153 yyval.node = yyvsp[0].node;
3155 break;}
3156 case 161:
3157 #line 869 "gcc/java/parse.y"
3158 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3159 break;}
3160 case 162:
3161 #line 871 "gcc/java/parse.y"
3163 yyval.node = yyvsp[0].node;
3165 break;}
3166 case 163:
3167 #line 875 "gcc/java/parse.y"
3168 {yyerror ("(here)'{' expected"); RECOVER;;
3169 break;}
3170 case 164:
3171 #line 877 "gcc/java/parse.y"
3172 {yyerror ("(there)'{' expected"); RECOVER;;
3173 break;}
3174 case 165:
3175 #line 882 "gcc/java/parse.y"
3177 ctxp->interface_number = 1;
3178 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3180 break;}
3181 case 166:
3182 #line 887 "gcc/java/parse.y"
3184 ctxp->interface_number++;
3185 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3187 break;}
3188 case 167:
3189 #line 892 "gcc/java/parse.y"
3190 {yyerror ("Invalid interface type"); RECOVER;;
3191 break;}
3192 case 168:
3193 #line 894 "gcc/java/parse.y"
3194 {yyerror ("Missing term"); RECOVER;;
3195 break;}
3196 case 169:
3197 #line 899 "gcc/java/parse.y"
3198 { yyval.node = NULL_TREE; ;
3199 break;}
3200 case 170:
3201 #line 901 "gcc/java/parse.y"
3202 { yyval.node = NULL_TREE; ;
3203 break;}
3204 case 175:
3205 #line 913 "gcc/java/parse.y"
3206 { yyval.node = parse_jdk1_1_error ("inner class declaration"); ;
3207 break;}
3208 case 176:
3209 #line 915 "gcc/java/parse.y"
3210 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
3211 break;}
3212 case 178:
3213 #line 924 "gcc/java/parse.y"
3215 check_abstract_method_header (yyvsp[-1].node);
3216 current_function_decl = NULL_TREE; /* FIXME ? */
3218 break;}
3219 case 179:
3220 #line 929 "gcc/java/parse.y"
3221 {yyerror ("';' expected"); RECOVER;;
3222 break;}
3223 case 180:
3224 #line 935 "gcc/java/parse.y"
3226 RULE ("ARRAY_INITIALIZER (empty)");
3228 break;}
3229 case 181:
3230 #line 939 "gcc/java/parse.y"
3232 RULE ("ARRAY_INITIALIZER (variable)");
3234 break;}
3235 case 182:
3236 #line 943 "gcc/java/parse.y"
3238 RULE ("ARRAY_INITIALIZER (,)");
3240 break;}
3241 case 183:
3242 #line 947 "gcc/java/parse.y"
3244 RULE ("ARRAY_INITIALIZER (variable, ,)");
3246 break;}
3247 case 186:
3248 #line 956 "gcc/java/parse.y"
3249 {yyerror ("Missing term"); RECOVER;;
3250 break;}
3251 case 187:
3252 #line 962 "gcc/java/parse.y"
3253 { yyval.node = size_zero_node; ;
3254 break;}
3255 case 188:
3256 #line 964 "gcc/java/parse.y"
3257 { enter_block (); ;
3258 break;}
3259 case 189:
3260 #line 967 "gcc/java/parse.y"
3262 maybe_absorb_scoping_blocks ();
3263 yyval.node = exit_block ();
3265 break;}
3266 case 193:
3267 #line 981 "gcc/java/parse.y"
3268 { yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3269 break;}
3270 case 194:
3271 #line 983 "gcc/java/parse.y"
3272 { yyval.node = parse_jdk1_1_error ("inner class declaration"); ;
3273 break;}
3274 case 196:
3275 #line 992 "gcc/java/parse.y"
3276 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3277 break;}
3278 case 197:
3279 #line 994 "gcc/java/parse.y"
3280 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3281 break;}
3282 case 203:
3283 #line 1004 "gcc/java/parse.y"
3285 /* If the for loop is unlabeled, we must return the
3286 block it was defined it. It our last chance to
3287 get a hold on it. */
3288 if (!LOOP_HAS_LABEL_P (yyval.node))
3289 yyval.node = exit_block ();
3291 break;}
3292 case 220:
3293 #line 1037 "gcc/java/parse.y"
3294 { yyval.node = size_zero_node; ;
3295 break;}
3296 case 221:
3297 #line 1042 "gcc/java/parse.y"
3299 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3300 EXPR_WFL_NODE (yyvsp[-1].node));
3301 pushlevel (2);
3302 push_labeled_block (yyval.node);
3303 PUSH_LABELED_BLOCK (yyval.node);
3305 break;}
3306 case 222:
3307 #line 1053 "gcc/java/parse.y"
3309 yyval.node = complete_labeled_statement (yyvsp[-1].node, yyvsp[0].node);
3310 pop_labeled_block ();
3311 POP_LABELED_BLOCK ();
3313 break;}
3314 case 223:
3315 #line 1059 "gcc/java/parse.y"
3316 {yyerror ("':' expected"); RECOVER;;
3317 break;}
3318 case 224:
3319 #line 1064 "gcc/java/parse.y"
3321 yyval.node = complete_labeled_statement (yyvsp[-1].node, yyvsp[0].node);
3322 pop_labeled_block ();
3323 POP_LABELED_BLOCK ();
3325 break;}
3326 case 225:
3327 #line 1075 "gcc/java/parse.y"
3329 /* We have a statement. Generate a WFL around it so
3330 we can debug it */
3331 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3332 /* We know we have a statement, so set the debug
3333 info to be eventually generate here. */
3334 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3336 break;}
3337 case 226:
3338 #line 1084 "gcc/java/parse.y"
3340 if (ctxp->prevent_ese != lineno)
3341 yyerror ("Invalid expression statement");
3342 DRECOVER (expr_stmt);
3344 break;}
3345 case 227:
3346 #line 1090 "gcc/java/parse.y"
3348 if (ctxp->prevent_ese != lineno)
3349 yyerror ("Invalid expression statement");
3350 DRECOVER (expr_stmt);
3352 break;}
3353 case 228:
3354 #line 1096 "gcc/java/parse.y"
3356 if (ctxp->prevent_ese != lineno)
3357 yyerror ("Invalid expression statement");
3358 DRECOVER (expr_stmt);
3360 break;}
3361 case 229:
3362 #line 1102 "gcc/java/parse.y"
3363 {yyerror ("')' expected"); RECOVER;;
3364 break;}
3365 case 230:
3366 #line 1104 "gcc/java/parse.y"
3367 {yyerror ("';' expected"); RECOVER;;
3368 break;}
3369 case 231:
3370 #line 1106 "gcc/java/parse.y"
3371 {yyerror ("')' expected"); RECOVER;;
3372 break;}
3373 case 232:
3374 #line 1108 "gcc/java/parse.y"
3375 {yyerror ("';' expected"); RECOVER;;
3376 break;}
3377 case 233:
3378 #line 1110 "gcc/java/parse.y"
3379 {yyerror ("'(' expected"); RECOVER;;
3380 break;}
3381 case 234:
3382 #line 1112 "gcc/java/parse.y"
3383 {yyerror ("')' expected"); RECOVER;;
3384 break;}
3385 case 235:
3386 #line 1114 "gcc/java/parse.y"
3387 {yyerror ("')' expected"); RECOVER;;
3388 break;}
3389 case 236:
3390 #line 1116 "gcc/java/parse.y"
3391 {yyerror ("';' expected"); RECOVER;;
3392 break;}
3393 case 237:
3394 #line 1118 "gcc/java/parse.y"
3395 {yyerror ("';' expected"); RECOVER;;
3396 break;}
3397 case 245:
3398 #line 1133 "gcc/java/parse.y"
3399 { yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node, NULL_TREE); ;
3400 break;}
3401 case 246:
3402 #line 1135 "gcc/java/parse.y"
3403 {yyerror ("'(' expected"); RECOVER;;
3404 break;}
3405 case 247:
3406 #line 1137 "gcc/java/parse.y"
3407 {yyerror ("Missing term"); RECOVER;;
3408 break;}
3409 case 248:
3410 #line 1139 "gcc/java/parse.y"
3411 {yyerror ("')' expected"); RECOVER;;
3412 break;}
3413 case 249:
3414 #line 1144 "gcc/java/parse.y"
3415 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3416 break;}
3417 case 250:
3418 #line 1149 "gcc/java/parse.y"
3419 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3420 break;}
3421 case 251:
3422 #line 1154 "gcc/java/parse.y"
3424 TREE_OPERAND (yyvsp[-1].node, 1) = yyvsp[0].node;
3425 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-1].node), yyvsp[-1].node);
3427 break;}
3428 case 252:
3429 #line 1162 "gcc/java/parse.y"
3431 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3432 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3434 break;}
3435 case 253:
3436 #line 1167 "gcc/java/parse.y"
3437 {yyerror ("'(' expected"); RECOVER;;
3438 break;}
3439 case 254:
3440 #line 1169 "gcc/java/parse.y"
3441 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3442 break;}
3443 case 255:
3444 #line 1171 "gcc/java/parse.y"
3445 {yyerror ("'{' expected"); RECOVER;;
3446 break;}
3447 case 256:
3448 #line 1176 "gcc/java/parse.y"
3449 { yyval.node = NULL_TREE; ;
3450 break;}
3451 case 257:
3452 #line 1178 "gcc/java/parse.y"
3453 { yyval.node = build_tree_list (yyvsp[-1].node, NULL_TREE); ;
3454 break;}
3455 case 258:
3456 #line 1180 "gcc/java/parse.y"
3457 { yyval.node = yyvsp[-1].node; ;
3458 break;}
3459 case 259:
3460 #line 1182 "gcc/java/parse.y"
3462 /* Switch labels alone are empty switch statements */
3463 tree sl = build_tree_list (yyvsp[-1].node, NULL_TREE);
3464 TREE_CHAIN (sl) = yyvsp[-2].node;
3465 yyval.node = sl;
3467 break;}
3468 case 261:
3469 #line 1193 "gcc/java/parse.y"
3471 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
3472 yyval.node = yyvsp[0].node;
3474 break;}
3475 case 262:
3476 #line 1201 "gcc/java/parse.y"
3477 { yyval.node = build_tree_list (yyvsp[-1].node, exit_block ()); ;
3478 break;}
3479 case 263:
3480 #line 1206 "gcc/java/parse.y"
3482 /* All statements attached to this group of cases
3483 will be stored in a block */
3484 enter_block ();
3485 yyval.node = yyvsp[0].node;
3487 break;}
3488 case 265:
3489 #line 1216 "gcc/java/parse.y"
3491 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
3492 yyval.node = yyvsp[0].node;
3494 break;}
3495 case 266:
3496 #line 1224 "gcc/java/parse.y"
3498 yyval.node = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3499 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3501 break;}
3502 case 267:
3503 #line 1229 "gcc/java/parse.y"
3505 yyval.node = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3506 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-1].operator.location;
3508 break;}
3509 case 268:
3510 #line 1234 "gcc/java/parse.y"
3511 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3512 break;}
3513 case 269:
3514 #line 1236 "gcc/java/parse.y"
3515 {yyerror ("':' expected"); RECOVER;;
3516 break;}
3517 case 270:
3518 #line 1238 "gcc/java/parse.y"
3519 {yyerror ("':' expected"); RECOVER;;
3520 break;}
3521 case 271:
3522 #line 1243 "gcc/java/parse.y"
3524 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3525 yyval.node = build_new_loop (body);
3527 break;}
3528 case 272:
3529 #line 1251 "gcc/java/parse.y"
3530 { yyval.node = complete_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3531 break;}
3532 case 273:
3533 #line 1253 "gcc/java/parse.y"
3534 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3535 break;}
3536 case 274:
3537 #line 1255 "gcc/java/parse.y"
3538 {yyerror ("Missing term and ')' expected"); RECOVER;;
3539 break;}
3540 case 275:
3541 #line 1257 "gcc/java/parse.y"
3542 {yyerror ("')' expected"); RECOVER;;
3543 break;}
3544 case 276:
3545 #line 1262 "gcc/java/parse.y"
3546 { yyval.node = complete_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3547 break;}
3548 case 277:
3549 #line 1267 "gcc/java/parse.y"
3551 tree body = build_loop_body (0, NULL_TREE, 1);
3552 yyval.node = build_new_loop (body);
3554 break;}
3555 case 278:
3556 #line 1276 "gcc/java/parse.y"
3557 { yyval.node = complete_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3558 break;}
3559 case 279:
3560 #line 1281 "gcc/java/parse.y"
3561 { yyval.node = complete_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3562 break;}
3563 case 280:
3564 #line 1283 "gcc/java/parse.y"
3566 yyval.node = complete_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3567 /* We have not condition, so we get rid of the EXIT_EXPR */
3568 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3569 size_zero_node;
3571 break;}
3572 case 281:
3573 #line 1290 "gcc/java/parse.y"
3574 {yyerror ("Invalid control expression"); RECOVER;;
3575 break;}
3576 case 282:
3577 #line 1292 "gcc/java/parse.y"
3578 {yyerror ("Invalid update expression"); RECOVER;;
3579 break;}
3580 case 283:
3581 #line 1294 "gcc/java/parse.y"
3582 {yyerror ("Invalid update expression"); RECOVER;;
3583 break;}
3584 case 284:
3585 #line 1299 "gcc/java/parse.y"
3586 { yyval.node = complete_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3587 break;}
3588 case 285:
3589 #line 1301 "gcc/java/parse.y"
3591 yyval.node = complete_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3592 /* We have not condition, so we get rid of the EXIT_EXPR */
3593 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3594 size_zero_node;
3596 break;}
3597 case 286:
3598 #line 1311 "gcc/java/parse.y"
3600 /* This scope defined for local variable that may be
3601 defined within the scope of the for loop */
3602 enter_block ();
3604 break;}
3605 case 287:
3606 #line 1317 "gcc/java/parse.y"
3607 {yyerror ("'(' expected"); DRECOVER(for_1);;
3608 break;}
3609 case 288:
3610 #line 1319 "gcc/java/parse.y"
3611 {yyerror ("Invalid init statement"); RECOVER;;
3612 break;}
3613 case 289:
3614 #line 1324 "gcc/java/parse.y"
3616 /* We now declare the loop body. The loop is
3617 declared as a for loop. */
3618 tree body = build_loop_body (0, NULL_TREE, 0);
3619 yyval.node = build_new_loop (body);
3620 IS_FOR_LOOP_P (yyval.node) = 1;
3621 /* The loop is added to the current block the for
3622 statement is defined within */
3623 java_method_add_stmt (current_function_decl, yyval.node);
3625 break;}
3626 case 290:
3627 #line 1336 "gcc/java/parse.y"
3628 { yyval.node = size_zero_node; ;
3629 break;}
3630 case 291:
3631 #line 1338 "gcc/java/parse.y"
3633 /* Init statement recorded within the previously
3634 defined block scope */
3635 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
3637 break;}
3638 case 292:
3639 #line 1344 "gcc/java/parse.y"
3641 /* Local variable are recorded within the previously
3642 defined block scope */
3643 yyval.node = NULL_TREE;
3645 break;}
3646 case 293:
3647 #line 1350 "gcc/java/parse.y"
3648 {yyerror ("';' expected"); DRECOVER(for_init_1);;
3649 break;}
3650 case 294:
3651 #line 1354 "gcc/java/parse.y"
3652 {yyval.node = size_zero_node;;
3653 break;}
3654 case 295:
3655 #line 1356 "gcc/java/parse.y"
3656 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
3657 break;}
3658 case 296:
3659 #line 1361 "gcc/java/parse.y"
3660 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
3661 break;}
3662 case 297:
3663 #line 1363 "gcc/java/parse.y"
3664 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
3665 break;}
3666 case 298:
3667 #line 1365 "gcc/java/parse.y"
3668 {yyerror ("Missing term"); RECOVER;;
3669 break;}
3670 case 299:
3671 #line 1370 "gcc/java/parse.y"
3672 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
3673 break;}
3674 case 300:
3675 #line 1372 "gcc/java/parse.y"
3676 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
3677 break;}
3678 case 301:
3679 #line 1374 "gcc/java/parse.y"
3680 {yyerror ("Missing term"); RECOVER;;
3681 break;}
3682 case 302:
3683 #line 1376 "gcc/java/parse.y"
3684 {yyerror ("';' expected"); RECOVER;;
3685 break;}
3686 case 303:
3687 #line 1381 "gcc/java/parse.y"
3688 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
3689 break;}
3690 case 304:
3691 #line 1383 "gcc/java/parse.y"
3692 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
3693 break;}
3694 case 305:
3695 #line 1385 "gcc/java/parse.y"
3696 {yyerror ("Missing term"); RECOVER;;
3697 break;}
3698 case 306:
3699 #line 1387 "gcc/java/parse.y"
3700 {yyerror ("';' expected"); RECOVER;;
3701 break;}
3702 case 307:
3703 #line 1392 "gcc/java/parse.y"
3704 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
3705 break;}
3706 case 308:
3707 #line 1394 "gcc/java/parse.y"
3708 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3709 break;}
3710 case 309:
3711 #line 1396 "gcc/java/parse.y"
3712 {yyerror ("Missing term"); RECOVER;;
3713 break;}
3714 case 310:
3715 #line 1398 "gcc/java/parse.y"
3716 {yyerror ("';' expected"); RECOVER;;
3717 break;}
3718 case 311:
3719 #line 1403 "gcc/java/parse.y"
3721 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
3722 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3724 break;}
3725 case 312:
3726 #line 1408 "gcc/java/parse.y"
3727 {yyerror ("Missing term"); RECOVER;;
3728 break;}
3729 case 313:
3730 #line 1410 "gcc/java/parse.y"
3731 {yyerror ("';' expected"); RECOVER;;
3732 break;}
3733 case 314:
3734 #line 1415 "gcc/java/parse.y"
3736 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3737 EXPR_WFL_LINECOL (yyval.node) =
3738 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
3740 break;}
3741 case 315:
3742 #line 1421 "gcc/java/parse.y"
3743 {yyerror ("'{' expected"); RECOVER;;
3744 break;}
3745 case 316:
3746 #line 1423 "gcc/java/parse.y"
3747 {yyerror ("'(' expected"); RECOVER;;
3748 break;}
3749 case 317:
3750 #line 1425 "gcc/java/parse.y"
3751 {yyerror ("Missing term"); RECOVER;;
3752 break;}
3753 case 318:
3754 #line 1427 "gcc/java/parse.y"
3755 {yyerror ("Missing term"); RECOVER;;
3756 break;}
3757 case 319:
3758 #line 1432 "gcc/java/parse.y"
3760 if ((1 << yyvsp[0].value) != ACC_SYNCHRONIZED)
3761 fatal ("synchronized was '%d' - yyparse", (1 << yyvsp[0].value));
3763 break;}
3764 case 320:
3765 #line 1440 "gcc/java/parse.y"
3766 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node, NULL_TREE); ;
3767 break;}
3768 case 321:
3769 #line 1442 "gcc/java/parse.y"
3770 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, NULL_TREE, yyvsp[0].node); ;
3771 break;}
3772 case 322:
3773 #line 1444 "gcc/java/parse.y"
3774 { yyval.node = build_try_statement (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3775 break;}
3776 case 323:
3777 #line 1446 "gcc/java/parse.y"
3778 {yyerror ("'{' expected"); DRECOVER (try_statement);;
3779 break;}
3780 case 325:
3781 #line 1452 "gcc/java/parse.y"
3783 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
3784 yyval.node = yyvsp[0].node;
3786 break;}
3787 case 326:
3788 #line 1460 "gcc/java/parse.y"
3790 java_method_add_stmt (current_function_decl, yyvsp[0].node);
3791 exit_block ();
3792 yyval.node = yyvsp[-1].node;
3794 break;}
3795 case 327:
3796 #line 1468 "gcc/java/parse.y"
3798 /* We add a block to define a scope for
3799 formal_parameter (CCBP). The formal parameter is
3800 declared initialized by the appropriate function
3801 call */
3802 tree ccpb = enter_block ();
3803 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
3804 TREE_PURPOSE (yyvsp[-1].node),
3805 soft_exceptioninfo_call_node);
3806 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
3807 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
3808 init));
3809 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
3810 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
3812 break;}
3813 case 328:
3814 #line 1484 "gcc/java/parse.y"
3815 {yyerror ("'(' expected"); RECOVER;;
3816 break;}
3817 case 329:
3818 #line 1486 "gcc/java/parse.y"
3819 {yyerror ("Missing term or ')' expected"); DRECOVER (2);;
3820 break;}
3821 case 330:
3822 #line 1488 "gcc/java/parse.y"
3823 {yyerror ("')' expected"); DRECOVER (1);;
3824 break;}
3825 case 331:
3826 #line 1493 "gcc/java/parse.y"
3828 yyval.node = build (FINALLY_EXPR, NULL_TREE,
3829 create_label_decl (generate_name ()), yyvsp[0].node);
3831 break;}
3832 case 332:
3833 #line 1498 "gcc/java/parse.y"
3834 {yyerror ("'{' expected"); RECOVER; ;
3835 break;}
3836 case 336:
3837 #line 1510 "gcc/java/parse.y"
3838 { yyval.node = build_this (yyvsp[0].operator.location); ;
3839 break;}
3840 case 337:
3841 #line 1512 "gcc/java/parse.y"
3842 {yyval.node = yyvsp[-1].node;;
3843 break;}
3844 case 342:
3845 #line 1521 "gcc/java/parse.y"
3846 { yyval.node = parse_jdk1_1_error ("class literals"); ;
3847 break;}
3848 case 343:
3849 #line 1523 "gcc/java/parse.y"
3850 { yyval.node = parse_jdk1_1_error ("class literals"); ;
3851 break;}
3852 case 344:
3853 #line 1525 "gcc/java/parse.y"
3854 { yyval.node = parse_jdk1_1_error ("class literals"); ;
3855 break;}
3856 case 345:
3857 #line 1530 "gcc/java/parse.y"
3858 { yyval.node = parse_jdk1_1_error ("class literals"); ;
3859 break;}
3860 case 346:
3861 #line 1532 "gcc/java/parse.y"
3862 {yyerror ("')' expected"); RECOVER;;
3863 break;}
3864 case 347:
3865 #line 1534 "gcc/java/parse.y"
3866 {yyerror ("'class' or 'this' expected" ); RECOVER;;
3867 break;}
3868 case 348:
3869 #line 1536 "gcc/java/parse.y"
3870 {yyerror ("'class' expected" ); RECOVER;;
3871 break;}
3872 case 349:
3873 #line 1538 "gcc/java/parse.y"
3874 {yyerror ("'class' expected" ); RECOVER;;
3875 break;}
3876 case 350:
3877 #line 1543 "gcc/java/parse.y"
3878 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
3879 break;}
3880 case 351:
3881 #line 1545 "gcc/java/parse.y"
3882 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
3883 break;}
3884 case 352:
3885 #line 1550 "gcc/java/parse.y"
3886 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
3887 break;}
3888 case 353:
3889 #line 1552 "gcc/java/parse.y"
3890 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
3891 break;}
3892 case 358:
3893 #line 1561 "gcc/java/parse.y"
3894 {yyerror ("'(' expected"); DRECOVER(new_1);;
3895 break;}
3896 case 359:
3897 #line 1563 "gcc/java/parse.y"
3898 {yyerror ("'(' expected"); RECOVER;;
3899 break;}
3900 case 360:
3901 #line 1565 "gcc/java/parse.y"
3902 {yyerror ("')' or term expected"); RECOVER;;
3903 break;}
3904 case 361:
3905 #line 1567 "gcc/java/parse.y"
3906 {yyerror ("')' expected"); RECOVER;;
3907 break;}
3908 case 362:
3909 #line 1569 "gcc/java/parse.y"
3910 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
3911 break;}
3912 case 363:
3913 #line 1571 "gcc/java/parse.y"
3914 {yyerror ("'(' expected"); RECOVER;;
3915 break;}
3916 case 366:
3917 #line 1581 "gcc/java/parse.y"
3919 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
3920 ctxp->formal_parameter_number = 1;
3922 break;}
3923 case 367:
3924 #line 1586 "gcc/java/parse.y"
3926 ctxp->formal_parameter_number += 1;
3927 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
3929 break;}
3930 case 368:
3931 #line 1591 "gcc/java/parse.y"
3932 {yyerror ("Missing term"); RECOVER;;
3933 break;}
3934 case 369:
3935 #line 1596 "gcc/java/parse.y"
3936 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
3937 break;}
3938 case 370:
3939 #line 1598 "gcc/java/parse.y"
3940 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
3941 break;}
3942 case 371:
3943 #line 1600 "gcc/java/parse.y"
3944 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, ctxp->osb_number); ;
3945 break;}
3946 case 372:
3947 #line 1602 "gcc/java/parse.y"
3948 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, ctxp->osb_number); ;
3949 break;}
3950 case 373:
3951 #line 1606 "gcc/java/parse.y"
3952 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
3953 break;}
3954 case 374:
3955 #line 1608 "gcc/java/parse.y"
3956 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
3957 break;}
3958 case 375:
3959 #line 1610 "gcc/java/parse.y"
3960 {yyerror ("'[' expected"); DRECOVER ("]");;
3961 break;}
3962 case 376:
3963 #line 1612 "gcc/java/parse.y"
3964 {yyerror ("']' expected"); RECOVER;;
3965 break;}
3966 case 377:
3967 #line 1617 "gcc/java/parse.y"
3968 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
3969 break;}
3970 case 378:
3971 #line 1619 "gcc/java/parse.y"
3972 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
3973 break;}
3974 case 379:
3975 #line 1624 "gcc/java/parse.y"
3977 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
3978 yyval.node = yyvsp[-1].node;
3980 break;}
3981 case 380:
3982 #line 1629 "gcc/java/parse.y"
3983 {yyerror ("']' expected"); RECOVER;;
3984 break;}
3985 case 381:
3986 #line 1631 "gcc/java/parse.y"
3988 yyerror ("Missing term");
3989 yyerror ("']' expected");
3990 RECOVER;
3992 break;}
3993 case 382:
3994 #line 1640 "gcc/java/parse.y"
3995 { ctxp->osb_number = 1; ;
3996 break;}
3997 case 383:
3998 #line 1642 "gcc/java/parse.y"
3999 { ctxp->osb_number++; ;
4000 break;}
4001 case 384:
4002 #line 1644 "gcc/java/parse.y"
4003 { yyerror ("']' expected"); RECOVER;;
4004 break;}
4005 case 385:
4006 #line 1649 "gcc/java/parse.y"
4007 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4008 break;}
4009 case 386:
4010 #line 1651 "gcc/java/parse.y"
4012 tree super_wfl =
4013 build_wfl_node (super_identifier_node,
4014 input_filename, 0, 0);
4015 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4016 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4018 break;}
4019 case 387:
4020 #line 1659 "gcc/java/parse.y"
4021 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4022 break;}
4023 case 388:
4024 #line 1664 "gcc/java/parse.y"
4025 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4026 break;}
4027 case 389:
4028 #line 1666 "gcc/java/parse.y"
4029 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4030 break;}
4031 case 390:
4032 #line 1668 "gcc/java/parse.y"
4034 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4035 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4037 break;}
4038 case 391:
4039 #line 1673 "gcc/java/parse.y"
4041 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4042 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4044 break;}
4045 case 392:
4046 #line 1678 "gcc/java/parse.y"
4048 tree invok;
4049 tree wfl = build_wfl_node (super_identifier_node,
4050 input_filename, 0, 0);
4051 EXPR_WFL_LINECOL (wfl) = yyvsp[-4].operator.location;
4052 invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4053 yyval.node = make_qualified_primary (wfl, invok, yyvsp[-3].operator.location);
4055 break;}
4056 case 393:
4057 #line 1687 "gcc/java/parse.y"
4059 tree invok;
4060 tree wfl = build_wfl_node (super_identifier_node,
4061 input_filename, 0, 0);
4062 EXPR_WFL_LINECOL (wfl) = yyvsp[-5].operator.location;
4063 invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4064 yyval.node = make_qualified_primary (wfl, invok, yyvsp[-4].operator.location);
4066 break;}
4067 case 394:
4068 #line 1700 "gcc/java/parse.y"
4069 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4070 break;}
4071 case 395:
4072 #line 1702 "gcc/java/parse.y"
4073 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4074 break;}
4075 case 396:
4076 #line 1707 "gcc/java/parse.y"
4077 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4078 break;}
4079 case 397:
4080 #line 1709 "gcc/java/parse.y"
4081 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4082 break;}
4083 case 398:
4084 #line 1711 "gcc/java/parse.y"
4086 yyerror ("Missing term and ']' expected");
4087 DRECOVER(array_access);
4089 break;}
4090 case 399:
4091 #line 1716 "gcc/java/parse.y"
4093 yyerror ("']' expected");
4094 DRECOVER(array_access);
4096 break;}
4097 case 400:
4098 #line 1721 "gcc/java/parse.y"
4100 yyerror ("Missing term and ']' expected");
4101 DRECOVER(array_access);
4103 break;}
4104 case 401:
4105 #line 1726 "gcc/java/parse.y"
4107 yyerror ("']' expected");
4108 DRECOVER(array_access);
4110 break;}
4111 case 406:
4112 #line 1741 "gcc/java/parse.y"
4113 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4114 break;}
4115 case 407:
4116 #line 1746 "gcc/java/parse.y"
4117 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4118 break;}
4119 case 410:
4120 #line 1753 "gcc/java/parse.y"
4121 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4122 break;}
4123 case 411:
4124 #line 1755 "gcc/java/parse.y"
4125 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4126 break;}
4127 case 413:
4128 #line 1758 "gcc/java/parse.y"
4129 {yyerror ("Missing term"); RECOVER;
4130 break;}
4131 case 414:
4132 #line 1760 "gcc/java/parse.y"
4133 {yyerror ("Missing term"); RECOVER;
4134 break;}
4135 case 415:
4136 #line 1765 "gcc/java/parse.y"
4137 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4138 break;}
4139 case 416:
4140 #line 1767 "gcc/java/parse.y"
4141 {yyerror ("Missing term"); RECOVER;
4142 break;}
4143 case 417:
4144 #line 1772 "gcc/java/parse.y"
4145 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4146 break;}
4147 case 418:
4148 #line 1774 "gcc/java/parse.y"
4149 {yyerror ("Missing term"); RECOVER;
4150 break;}
4151 case 420:
4152 #line 1780 "gcc/java/parse.y"
4153 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4154 break;}
4155 case 421:
4156 #line 1782 "gcc/java/parse.y"
4157 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4158 break;}
4159 case 423:
4160 #line 1785 "gcc/java/parse.y"
4161 {yyerror ("Missing term"); RECOVER;
4162 break;}
4163 case 424:
4164 #line 1787 "gcc/java/parse.y"
4165 {yyerror ("Missing term"); RECOVER;
4166 break;}
4167 case 425:
4168 #line 1792 "gcc/java/parse.y"
4170 tree type = yyvsp[-3].node;
4171 while (ctxp->osb_number--)
4172 type = build_java_array_type (type, -1);
4173 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4175 break;}
4176 case 426:
4177 #line 1799 "gcc/java/parse.y"
4178 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4179 break;}
4180 case 427:
4181 #line 1801 "gcc/java/parse.y"
4182 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4183 break;}
4184 case 428:
4185 #line 1803 "gcc/java/parse.y"
4187 char *ptr;
4188 while (ctxp->osb_number--)
4189 obstack_1grow (&temporary_obstack, '[');
4190 obstack_grow0 (&temporary_obstack,
4191 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4192 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4193 ptr = obstack_finish (&temporary_obstack);
4194 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4195 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4197 break;}
4198 case 429:
4199 #line 1815 "gcc/java/parse.y"
4200 {yyerror ("']' expected, invalid type expression");;
4201 break;}
4202 case 430:
4203 #line 1817 "gcc/java/parse.y"
4205 if (ctxp->prevent_ese != lineno)
4206 yyerror ("Invalid type expression"); RECOVER;
4207 RECOVER;
4209 break;}
4210 case 431:
4211 #line 1823 "gcc/java/parse.y"
4212 {yyerror ("Missing term"); RECOVER;;
4213 break;}
4214 case 432:
4215 #line 1825 "gcc/java/parse.y"
4216 {yyerror ("Missing term"); RECOVER;;
4217 break;}
4218 case 433:
4219 #line 1827 "gcc/java/parse.y"
4220 {yyerror ("Missing term"); RECOVER;;
4221 break;}
4222 case 435:
4223 #line 1833 "gcc/java/parse.y"
4225 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4226 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4228 break;}
4229 case 436:
4230 #line 1838 "gcc/java/parse.y"
4232 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4233 yyvsp[-2].node, yyvsp[0].node);
4235 break;}
4236 case 437:
4237 #line 1843 "gcc/java/parse.y"
4239 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4240 yyvsp[-2].node, yyvsp[0].node);
4242 break;}
4243 case 438:
4244 #line 1848 "gcc/java/parse.y"
4245 {yyerror ("Missing term"); RECOVER;;
4246 break;}
4247 case 439:
4248 #line 1850 "gcc/java/parse.y"
4249 {yyerror ("Missing term"); RECOVER;;
4250 break;}
4251 case 440:
4252 #line 1852 "gcc/java/parse.y"
4253 {yyerror ("Missing term"); RECOVER;;
4254 break;}
4255 case 442:
4256 #line 1858 "gcc/java/parse.y"
4258 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4259 yyvsp[-2].node, yyvsp[0].node);
4261 break;}
4262 case 443:
4263 #line 1863 "gcc/java/parse.y"
4265 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4266 yyvsp[-2].node, yyvsp[0].node);
4268 break;}
4269 case 444:
4270 #line 1868 "gcc/java/parse.y"
4271 {yyerror ("Missing term"); RECOVER;;
4272 break;}
4273 case 445:
4274 #line 1870 "gcc/java/parse.y"
4275 {yyerror ("Missing term"); RECOVER;;
4276 break;}
4277 case 447:
4278 #line 1876 "gcc/java/parse.y"
4280 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4281 yyvsp[-2].node, yyvsp[0].node);
4283 break;}
4284 case 448:
4285 #line 1881 "gcc/java/parse.y"
4287 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4288 yyvsp[-2].node, yyvsp[0].node);
4290 break;}
4291 case 449:
4292 #line 1886 "gcc/java/parse.y"
4294 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4295 yyvsp[-2].node, yyvsp[0].node);
4297 break;}
4298 case 450:
4299 #line 1891 "gcc/java/parse.y"
4300 {yyerror ("Missing term"); RECOVER;;
4301 break;}
4302 case 451:
4303 #line 1893 "gcc/java/parse.y"
4304 {yyerror ("Missing term"); RECOVER;;
4305 break;}
4306 case 452:
4307 #line 1895 "gcc/java/parse.y"
4308 {yyerror ("Missing term"); RECOVER;;
4309 break;}
4310 case 454:
4311 #line 1901 "gcc/java/parse.y"
4313 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4314 yyvsp[-2].node, yyvsp[0].node);
4316 break;}
4317 case 455:
4318 #line 1906 "gcc/java/parse.y"
4320 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4321 yyvsp[-2].node, yyvsp[0].node);
4323 break;}
4324 case 456:
4325 #line 1911 "gcc/java/parse.y"
4327 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4328 yyvsp[-2].node, yyvsp[0].node);
4330 break;}
4331 case 457:
4332 #line 1916 "gcc/java/parse.y"
4334 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4335 yyvsp[-2].node, yyvsp[0].node);
4337 break;}
4338 case 459:
4339 #line 1922 "gcc/java/parse.y"
4340 {yyerror ("Missing term"); RECOVER;;
4341 break;}
4342 case 460:
4343 #line 1924 "gcc/java/parse.y"
4344 {yyerror ("Missing term"); RECOVER;;
4345 break;}
4346 case 461:
4347 #line 1926 "gcc/java/parse.y"
4348 {yyerror ("Missing term"); RECOVER;;
4349 break;}
4350 case 462:
4351 #line 1928 "gcc/java/parse.y"
4352 {yyerror ("Missing term"); RECOVER;;
4353 break;}
4354 case 463:
4355 #line 1930 "gcc/java/parse.y"
4356 {yyerror ("Invalid reference type"); RECOVER;;
4357 break;}
4358 case 465:
4359 #line 1936 "gcc/java/parse.y"
4361 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4362 yyvsp[-2].node, yyvsp[0].node);
4364 break;}
4365 case 466:
4366 #line 1941 "gcc/java/parse.y"
4368 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4369 yyvsp[-2].node, yyvsp[0].node);
4371 break;}
4372 case 467:
4373 #line 1946 "gcc/java/parse.y"
4374 {yyerror ("Missing term"); RECOVER;;
4375 break;}
4376 case 468:
4377 #line 1948 "gcc/java/parse.y"
4378 {yyerror ("Missing term"); RECOVER;;
4379 break;}
4380 case 470:
4381 #line 1954 "gcc/java/parse.y"
4383 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4384 yyvsp[-2].node, yyvsp[0].node);
4386 break;}
4387 case 471:
4388 #line 1959 "gcc/java/parse.y"
4389 {yyerror ("Missing term"); RECOVER;;
4390 break;}
4391 case 473:
4392 #line 1965 "gcc/java/parse.y"
4394 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4395 yyvsp[-2].node, yyvsp[0].node);
4397 break;}
4398 case 474:
4399 #line 1970 "gcc/java/parse.y"
4400 {yyerror ("Missing term"); RECOVER;;
4401 break;}
4402 case 476:
4403 #line 1976 "gcc/java/parse.y"
4405 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4406 yyvsp[-2].node, yyvsp[0].node);
4408 break;}
4409 case 477:
4410 #line 1981 "gcc/java/parse.y"
4411 {yyerror ("Missing term"); RECOVER;;
4412 break;}
4413 case 479:
4414 #line 1987 "gcc/java/parse.y"
4416 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4417 yyvsp[-2].node, yyvsp[0].node);
4419 break;}
4420 case 480:
4421 #line 1992 "gcc/java/parse.y"
4422 {yyerror ("Missing term"); RECOVER;;
4423 break;}
4424 case 482:
4425 #line 1998 "gcc/java/parse.y"
4427 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4428 yyvsp[-2].node, yyvsp[0].node);
4430 break;}
4431 case 483:
4432 #line 2003 "gcc/java/parse.y"
4433 {yyerror ("Missing term"); RECOVER;;
4434 break;}
4435 case 486:
4436 #line 2010 "gcc/java/parse.y"
4438 YYERROR_NOW;
4439 yyerror ("Missing term");
4440 DRECOVER (1);
4442 break;}
4443 case 487:
4444 #line 2016 "gcc/java/parse.y"
4445 {yyerror ("Missing term"); DRECOVER (2);;
4446 break;}
4447 case 488:
4448 #line 2018 "gcc/java/parse.y"
4449 {yyerror ("Missing term"); DRECOVER (3);;
4450 break;}
4451 case 491:
4452 #line 2028 "gcc/java/parse.y"
4453 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4454 break;}
4455 case 492:
4456 #line 2030 "gcc/java/parse.y"
4458 if (ctxp->prevent_ese != lineno)
4459 yyerror ("Missing term");
4460 DRECOVER (assign);
4462 break;}
4464 /* the action file gets copied in in place of this dollarsign */
4465 #line 498 "/x1/java-install/share/bison.simple"
4467 yyvsp -= yylen;
4468 yyssp -= yylen;
4469 #ifdef YYLSP_NEEDED
4470 yylsp -= yylen;
4471 #endif
4473 #if YYDEBUG != 0
4474 if (yydebug)
4476 short *ssp1 = yyss - 1;
4477 fprintf (stderr, "state stack now");
4478 while (ssp1 != yyssp)
4479 fprintf (stderr, " %d", *++ssp1);
4480 fprintf (stderr, "\n");
4482 #endif
4484 *++yyvsp = yyval;
4486 #ifdef YYLSP_NEEDED
4487 yylsp++;
4488 if (yylen == 0)
4490 yylsp->first_line = yylloc.first_line;
4491 yylsp->first_column = yylloc.first_column;
4492 yylsp->last_line = (yylsp-1)->last_line;
4493 yylsp->last_column = (yylsp-1)->last_column;
4494 yylsp->text = 0;
4496 else
4498 yylsp->last_line = (yylsp+yylen-1)->last_line;
4499 yylsp->last_column = (yylsp+yylen-1)->last_column;
4501 #endif
4503 /* Now "shift" the result of the reduction.
4504 Determine what state that goes to,
4505 based on the state we popped back to
4506 and the rule number reduced by. */
4508 yyn = yyr1[yyn];
4510 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4511 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4512 yystate = yytable[yystate];
4513 else
4514 yystate = yydefgoto[yyn - YYNTBASE];
4516 goto yynewstate;
4518 yyerrlab: /* here on detecting error */
4520 if (! yyerrstatus)
4521 /* If not already recovering from an error, report this error. */
4523 ++yynerrs;
4525 #ifdef YYERROR_VERBOSE
4526 yyn = yypact[yystate];
4528 if (yyn > YYFLAG && yyn < YYLAST)
4530 int size = 0;
4531 char *msg;
4532 int x, count;
4534 count = 0;
4535 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4536 for (x = (yyn < 0 ? -yyn : 0);
4537 x < (sizeof(yytname) / sizeof(char *)); x++)
4538 if (yycheck[x + yyn] == x)
4539 size += strlen(yytname[x]) + 15, count++;
4540 msg = (char *) malloc(size + 15);
4541 if (msg != 0)
4543 strcpy(msg, "parse error");
4545 if (count < 5)
4547 count = 0;
4548 for (x = (yyn < 0 ? -yyn : 0);
4549 x < (sizeof(yytname) / sizeof(char *)); x++)
4550 if (yycheck[x + yyn] == x)
4552 strcat(msg, count == 0 ? ", expecting `" : " or `");
4553 strcat(msg, yytname[x]);
4554 strcat(msg, "'");
4555 count++;
4558 yyerror(msg);
4559 free(msg);
4561 else
4562 yyerror ("parse error; also virtual memory exceeded");
4564 else
4565 #endif /* YYERROR_VERBOSE */
4566 yyerror("parse error");
4569 goto yyerrlab1;
4570 yyerrlab1: /* here on error raised explicitly by an action */
4572 if (yyerrstatus == 3)
4574 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4576 /* return failure if at end of input */
4577 if (yychar == YYEOF)
4578 YYABORT;
4580 #if YYDEBUG != 0
4581 if (yydebug)
4582 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4583 #endif
4585 yychar = YYEMPTY;
4588 /* Else will try to reuse lookahead token
4589 after shifting the error token. */
4591 yyerrstatus = 3; /* Each real token shifted decrements this */
4593 goto yyerrhandle;
4595 yyerrdefault: /* current state does not do anything special for the error token. */
4597 #if 0
4598 /* This is wrong; only states that explicitly want error tokens
4599 should shift them. */
4600 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4601 if (yyn) goto yydefault;
4602 #endif
4604 yyerrpop: /* pop the current state because it cannot handle the error token */
4606 if (yyssp == yyss) YYABORT;
4607 yyvsp--;
4608 yystate = *--yyssp;
4609 #ifdef YYLSP_NEEDED
4610 yylsp--;
4611 #endif
4613 #if YYDEBUG != 0
4614 if (yydebug)
4616 short *ssp1 = yyss - 1;
4617 fprintf (stderr, "Error: state stack now");
4618 while (ssp1 != yyssp)
4619 fprintf (stderr, " %d", *++ssp1);
4620 fprintf (stderr, "\n");
4622 #endif
4624 yyerrhandle:
4626 yyn = yypact[yystate];
4627 if (yyn == YYFLAG)
4628 goto yyerrdefault;
4630 yyn += YYTERROR;
4631 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4632 goto yyerrdefault;
4634 yyn = yytable[yyn];
4635 if (yyn < 0)
4637 if (yyn == YYFLAG)
4638 goto yyerrpop;
4639 yyn = -yyn;
4640 goto yyreduce;
4642 else if (yyn == 0)
4643 goto yyerrpop;
4645 if (yyn == YYFINAL)
4646 YYACCEPT;
4648 #if YYDEBUG != 0
4649 if (yydebug)
4650 fprintf(stderr, "Shifting error token, ");
4651 #endif
4653 *++yyvsp = yylval;
4654 #ifdef YYLSP_NEEDED
4655 *++yylsp = yylloc;
4656 #endif
4658 yystate = yyn;
4659 goto yynewstate;
4661 #line 2056 "gcc/java/parse.y"
4665 #include "lex.c"
4667 /* Flag for the error report routine to issue the error the first time
4668 it's called (overriding the default behavior which is to drop the
4669 first invocation and honor the second one, taking advantage of a
4670 richer context. */
4671 static int force_error = 0;
4673 /* Create a new parser context and make it the current one. */
4675 void
4676 java_push_parser_context ()
4678 struct parser_ctxt *new =
4679 (struct parser_ctxt *)malloc(sizeof (struct parser_ctxt));
4681 bzero (new, sizeof (struct parser_ctxt));
4682 new->next = ctxp;
4683 ctxp = new;
4684 if (ctxp->next)
4685 ctxp->incomplete_class = ctxp->next->incomplete_class;
4688 void
4689 java_parser_context_save_global ()
4691 ctxp->finput = finput;
4692 ctxp->lineno = lineno;
4693 ctxp->current_class = current_class;
4694 ctxp->filename = input_filename;
4695 ctxp->current_function_decl = current_function_decl;
4698 void
4699 java_parser_context_restore_global ()
4701 finput = ctxp->finput;
4702 lineno = ctxp->lineno;
4703 current_class = ctxp->current_class;
4704 input_filename = ctxp->filename;
4705 current_function_decl = ctxp->current_function_decl;
4708 void
4709 java_pop_parser_context (generate)
4710 int generate;
4712 tree current;
4713 struct parser_ctxt *toFree = ctxp;
4714 struct parser_ctxt *next = ctxp->next;
4716 if (next)
4718 next->incomplete_class = ctxp->incomplete_class;
4719 lineno = ctxp->lineno;
4720 finput = ctxp->finput;
4721 current_class = ctxp->current_class;
4724 /* Set the single import class file flag to 0 for the current list
4725 of imported things */
4726 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4727 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
4729 /* And restore those of the previous context */
4730 if ((ctxp = next)) /* Assignment is really meant here */
4731 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4732 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
4734 if (generate)
4736 toFree->next = ctxp_for_generation;
4737 ctxp_for_generation = toFree;
4739 else
4740 free (toFree);
4743 /* Reporting JDK1.1 features not implemented */
4745 static tree
4746 parse_jdk1_1_error (msg)
4747 char *msg;
4749 sorry (": `%s' JDK1.1(TM) feature", msg);
4750 java_error_count++;
4751 return size_zero_node;
4754 static int do_warning = 0;
4756 void
4757 yyerror (msg)
4758 char *msg;
4760 static java_lc elc;
4761 static int prev_lineno;
4762 static char *prev_msg;
4764 int save_lineno;
4765 char *remainder, *code_from_source;
4766 extern struct obstack temporary_obstack;
4768 if (!force_error && prev_lineno == lineno)
4769 return;
4771 /* Save current error location but report latter, when the context is
4772 richer. */
4773 if (ctxp->java_error_flag == 0)
4775 ctxp->java_error_flag = 1;
4776 elc = ctxp->elc;
4777 /* Do something to use the previous line if we're reaching the
4778 end of the file... */
4779 #ifdef VERBOSE_SKELETON
4780 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
4781 #endif
4782 return;
4785 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
4786 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
4787 return;
4789 ctxp->java_error_flag = 0;
4790 if (do_warning)
4791 java_warning_count++;
4792 else
4793 java_error_count++;
4795 if (elc.col == 0 && msg[1] == ';')
4797 elc.col = ctxp->p_line->char_col-1;
4798 elc.line = ctxp->p_line->lineno;
4801 save_lineno = lineno;
4802 prev_lineno = lineno = elc.line;
4803 prev_msg = msg;
4805 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
4806 obstack_grow0 (&temporary_obstack,
4807 code_from_source, strlen (code_from_source));
4808 remainder = obstack_finish (&temporary_obstack);
4809 if (do_warning)
4810 warning ("%s.\n%s", msg, remainder);
4811 else
4812 error ("%s.\n%s", msg, remainder);
4814 /* This allow us to cheaply avoid an extra 'Invalid expression
4815 statement' error report when errors have been already reported on
4816 the same line. This occurs when we report an error but don't have
4817 a synchronization point other than ';', which
4818 expression_statement is the only one to take care of. */
4819 ctxp->prevent_ese = lineno = save_lineno;
4822 static void
4823 parse_error (msg)
4824 char *msg;
4826 java_error (NULL);
4827 java_error (msg);
4830 /* Issue an error message at a current source line CL */
4832 static void
4833 parse_error_context VPROTO ((tree cl, char *msg, ...))
4835 #ifndef __STDC__
4836 tree cl;
4837 char *msg;
4838 #endif
4839 char buffer [4096];
4840 va_list ap;
4842 VA_START (ap, msg);
4843 #ifndef __STDC__
4844 cl = va_arg (ap, tree);
4845 msg = va_arg (ap, char *);
4846 #endif
4847 vsprintf (buffer, msg, ap);
4849 force_error = 1;
4850 ctxp->elc.line = EXPR_WFL_LINENO (cl);
4851 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : EXPR_WFL_COLNO (cl));
4853 parse_error (buffer);
4854 force_error = 0;
4857 /* Issue a warning at a current source line CL */
4859 static void
4860 parse_warning_context VPROTO ((tree cl, char *msg, ...))
4862 #ifndef __STDC__
4863 tree cl;
4864 char *msg;
4865 #endif
4866 char buffer [4096];
4867 va_list ap;
4869 VA_START (ap, msg);
4870 #ifndef __STDC__
4871 cl = va_arg (ap, tree);
4872 msg = va_arg (ap, char *);
4873 #endif
4874 vsprintf (buffer, msg, ap);
4876 force_error = do_warning = 1;
4877 ctxp->elc.line = EXPR_WFL_LINENO (cl);
4878 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : EXPR_WFL_COLNO (cl));
4880 parse_error (buffer);
4881 do_warning = force_error = 0;
4884 void
4885 java_report_errors ()
4887 if (java_error_count)
4888 fprintf (stderr, "%d error%s",
4889 java_error_count, (java_error_count == 1 ? "" : "s"));
4890 if (java_warning_count)
4891 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
4892 java_warning_count, (java_warning_count == 1 ? "" : "s"));
4893 if (java_error_count || java_warning_count)
4894 putc ('\n', stderr);
4897 static char *
4898 java_accstring_lookup (flags)
4899 int flags;
4901 static char buffer [80];
4902 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
4904 /* Access modifier looked-up first for easier report on forbidden
4905 access. */
4906 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
4907 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
4908 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
4909 if (flags & ACC_STATIC) COPY_RETURN ("static");
4910 if (flags & ACC_FINAL) COPY_RETURN ("final");
4911 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
4912 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
4913 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
4914 if (flags & ACC_NATIVE) COPY_RETURN ("native");
4915 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
4916 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
4918 buffer [0] = '\0';
4919 return buffer;
4920 #undef COPY_RETURN
4923 /* Issuing error messages upon redefinition of classes, interfaces or
4924 variables. */
4926 static void
4927 classitf_redefinition_error (context, id, decl, cl)
4928 char *context;
4929 tree id, decl, cl;
4931 parse_error_context (cl, "%s `%s' already defined in %s:%d",
4932 context, IDENTIFIER_POINTER (id),
4933 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
4934 /* Here we should point out where its redefined. It's a unicode. FIXME */
4937 static void
4938 variable_redefinition_error (context, name, type, line)
4939 tree context, name, type;
4940 int line;
4942 char *type_name;
4944 /* Figure a proper name for type. We might haven't resolved it */
4945 if (TREE_CODE (type) == TREE_LIST)
4946 type_name = IDENTIFIER_POINTER (TYPE_NAME (TREE_PURPOSE (type)));
4947 else
4948 type_name = lang_printable_name (type, 0);
4950 parse_error_context (context,
4951 "Variable `%s' is already defined in this method and "
4952 "was declared `%s %s' at line %d",
4953 IDENTIFIER_POINTER (name),
4954 type_name, IDENTIFIER_POINTER (name), line);
4957 static tree
4958 build_array_from_name (type, type_wfl, name, ret_name)
4959 tree type, type_wfl, name, *ret_name;
4961 int more_dims = 0;
4962 char *string;
4964 /* Eventually get more dims */
4965 string = IDENTIFIER_POINTER (name);
4966 while (string [more_dims] == '[')
4967 more_dims++;
4969 /* If we have, then craft a new type for this variable */
4970 if (more_dims)
4972 name = get_identifier (&more_dims [string]);
4974 /* If type already is a reference on an array, get the base type */
4975 if ((TREE_CODE (type) == POINTER_TYPE) &&
4976 TYPE_ARRAY_P (TREE_TYPE (type)))
4977 type = TREE_TYPE (type);
4979 /* Building the first dimension of a primitive type uses this
4980 function */
4981 if (JPRIMITIVE_TYPE_P (type))
4983 type = build_java_array_type (type, -1);
4984 more_dims--;
4986 /* Otherwise, if we have a WFL for this type, use it (the type
4987 is already an array on an unresolved type, and we just keep
4988 on adding dimensions) */
4989 else if (type_wfl)
4990 type = type_wfl;
4992 /* Add all the dimensions */
4993 while (more_dims--)
4994 type = build_unresolved_array_type (type);
4996 /* The type may have been incomplete in the first place */
4997 if (type_wfl)
4998 type = obtain_incomplete_type (type);
5001 *ret_name = name;
5002 return type;
5005 /* Build something that the type identifier resolver will identify as
5006 being an array to an unresolved type. TYPE_WFL is a WFL on a
5007 identifier. */
5009 static tree
5010 build_unresolved_array_type (type_or_wfl)
5011 tree type_or_wfl;
5013 char *ptr;
5015 /* TYPE_OR_WFL might be an array on a primitive type. In this case,
5016 just create a array type */
5017 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5019 tree type = build_java_array_type (type_or_wfl, -1);
5020 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5021 return type;
5024 obstack_1grow (&temporary_obstack, '[');
5025 obstack_grow0 (&temporary_obstack,
5026 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5027 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5028 ptr = obstack_finish (&temporary_obstack);
5029 return build_expr_wfl (get_identifier (ptr),
5030 EXPR_WFL_FILENAME (type_or_wfl),
5031 EXPR_WFL_LINENO (type_or_wfl),
5032 EXPR_WFL_COLNO (type_or_wfl));
5035 /* Check modifiers. If one doesn't fit, retrieve it in its declaration line
5036 and point it out. */
5038 static void
5039 check_modifiers (message, value, mask)
5040 char *message;
5041 int value;
5042 int mask;
5044 /* Should point out the one that don't fit. ASCII/unicode,
5045 going backward. FIXME */
5046 if (value & ~mask)
5048 int i, remainder = value & ~mask;
5049 for (i = 0; i <= 10; i++)
5050 if ((1 << i) & remainder)
5051 parse_error_context (ctxp->modifier_ctx [i], message,
5052 java_accstring_lookup (1 << i));
5056 static void
5057 parser_add_interface (class_decl, interface_decl, wfl)
5058 tree class_decl, interface_decl, wfl;
5060 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5061 parse_error_context (wfl, "Interface `%s' repeated",
5062 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5065 /* Bulk of common class/interface checks. Return 1 if an error was
5066 encountered. TAG is 0 for a class, 1 for an interface. */
5068 static int
5069 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5070 int is_interface, flags;
5071 tree raw_name, qualified_name, decl, cl;
5073 tree node;
5075 if (!quiet_flag)
5076 fprintf (stderr, " %s %s", (is_interface ? "interface" : "class"),
5077 IDENTIFIER_POINTER (qualified_name));
5079 /* Scope of an interface/class type name:
5080 - Can't be imported by a single type import
5081 - Can't already exists in the package */
5082 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5083 && (node = find_name_in_single_imports (raw_name)))
5085 parse_error_context
5086 (cl, "%s name `%s' clashes with imported type `%s'",
5087 (is_interface ? "Interface" : "Class"),
5088 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5089 return 1;
5091 if (decl && CLASS_COMPLETE_P (decl))
5093 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
5094 qualified_name, decl, cl);
5095 return 1;
5098 /* If public, file name should match class/interface name */
5099 if (flags & ACC_PUBLIC)
5101 char *f;
5103 /* Contains OS dependent assumption on path separator. FIXME */
5104 for (f = &input_filename [strlen (input_filename)];
5105 f != input_filename && f[0] != '/'; f--);
5106 if (f[0] == '/')
5107 f++;
5108 if (strncmp (IDENTIFIER_POINTER (raw_name),
5109 f , IDENTIFIER_LENGTH (raw_name)) ||
5110 f [IDENTIFIER_LENGTH (raw_name)] != '.')
5111 parse_error_context (cl, "Public %s `%s' must be defined in a file "
5112 "called `%s.java'",
5113 (is_interface ? "interface" : "class"),
5114 IDENTIFIER_POINTER (qualified_name),
5115 IDENTIFIER_POINTER (raw_name));
5118 check_modifiers ((is_interface ?
5119 "Illegal modifier `%s' for interface declaration" :
5120 "Illegal modifier `%s' for class declaration"), flags,
5121 (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS));
5122 return 0;
5125 /* If DECL is NULL, create and push a new DECL, record the current
5126 line CL and do other maintenance things. */
5128 static tree
5129 maybe_create_class_interface_decl (decl, qualified_name, cl)
5130 tree decl, qualified_name, cl;
5132 if (decl)
5133 DECL_ARTIFICIAL (decl) = 1; /* FIXME */
5134 else
5135 decl = push_class (make_class (), qualified_name);
5137 /* Take care of the file and line business */
5138 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
5139 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
5140 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
5141 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
5142 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
5144 ctxp->current_parsed_class = decl;
5146 /* Link the declaration to the already seen ones */
5147 TREE_CHAIN (decl) = ctxp->class_list;
5148 ctxp->class_list = decl;
5149 /* Install a new dependency list element */
5150 create_jdep_list (ctxp);
5152 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
5153 IDENTIFIER_POINTER (qualified_name)));
5154 return decl;
5157 static void
5158 add_superinterfaces (decl, interface_list)
5159 tree decl, interface_list;
5161 tree node;
5162 /* Superinterface(s): if present and defined, parser_check_super_interface ()
5163 takes care of ensuring that:
5164 - This is an accessible interface type,
5165 - Circularity detection.
5166 parser_add_interface is then called. If present but not defined,
5167 the check operation is delayed until the super interface gets
5168 defined. */
5169 for (node = interface_list; node; node = TREE_CHAIN (node))
5171 tree current = TREE_PURPOSE (node), interface_decl;
5172 if ((interface_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current))))
5174 if (!parser_check_super_interface (interface_decl, decl, current))
5175 parser_add_interface (decl, interface_decl, current);
5177 else
5178 register_incomplete_type (JDEP_INTERFACE,
5179 current, decl, NULL_TREE);
5183 /* Create an interface in pass1 and return its decl. Return the
5184 interface's decl in pass 2. */
5186 static tree
5187 create_interface (flags, id, super)
5188 int flags;
5189 tree id, super;
5191 tree raw_name = EXPR_WFL_NODE (id);
5192 tree q_name = parser_qualified_classname (id);
5193 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
5195 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
5197 /* Basic checks: scope, redefinition, modifiers */
5198 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
5199 return NULL_TREE;
5201 /* Interface modifiers check
5202 - public/abstract allowed (already done at that point)
5203 - abstract is obsolete (comes first, it's a warning, or should be)
5204 - Can't use twice the same (checked in the modifier rule) */
5205 if (flags & ACC_ABSTRACT)
5206 parse_warning_context
5207 (MODIFIER_WFL (ABSTRACT_TK),
5208 "Obsolete use of `abstract' modifier. Interface `%s' is implicitely "
5209 "abstract", IDENTIFIER_POINTER (raw_name));
5210 if (flags & ACC_PUBLIC && flags & ACC_ABSTRACT)
5211 parse_error_context
5212 (MODIFIER_WFL (ABSTRACT_TK),
5213 "Can't specify both `public' and `abstract' modifiers in the "
5214 "definition of interface `%s'", IDENTIFIER_POINTER (raw_name));
5216 /* Create a new decl if DECL is NULL, otherwise fix it */
5217 decl = maybe_create_class_interface_decl (decl, q_name, id);
5219 /* Set super info and mark the class a complete */
5220 set_super_info (ACC_ABSTRACT | ACC_INTERFACE | flags, TREE_TYPE (decl),
5221 object_type_node, ctxp->interface_number);
5222 ctxp->interface_number = 0;
5223 CLASS_COMPLETE_P (decl) = 1;
5224 add_superinterfaces (decl, super);
5226 return decl;
5229 /* Create an class in pass1 and return its decl. Return class
5230 interface's decl in pass 2. */
5232 static tree
5233 create_class (flags, id, super, interfaces)
5234 int flags;
5235 tree id, super, interfaces;
5237 tree raw_name = EXPR_WFL_NODE (id);
5238 tree class_id, decl;
5239 tree super_decl = NULL, super_decl_type;
5241 class_id = parser_qualified_classname (id);
5242 decl = IDENTIFIER_CLASS_VALUE (class_id);
5243 EXPR_WFL_NODE (id) = class_id;
5245 /* Basic check: scope, redefinition, modifiers */
5246 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
5247 return NULL_TREE;
5249 /* Class modifier check:
5250 - Allowed modifier (already done at that point)
5251 - abstract AND final forbidden
5252 - Public classes defined in the correct file */
5253 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
5254 parse_error_context (id, "Class `%s' can't be declared both abstract "
5255 "and final", IDENTIFIER_POINTER (raw_name));
5257 /* Create a new decl if DECL is NULL, otherwise fix it */
5258 decl = maybe_create_class_interface_decl (decl, class_id, id);
5260 /* If SUPER exists, use it, otherwise use Object */
5261 if (super)
5263 /* Can't extend java.lang.Object */
5264 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
5266 parse_error_context (id, "Can't extend `java.lang.Object'");
5267 return NULL_TREE;
5270 /* The class is known and exists if there is a decl. Otherwise,
5271 postpone the operation and do it later. */
5272 super_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (super));
5273 if (super_decl)
5275 parser_check_super (super_decl, decl, id);
5276 super_decl_type = TREE_TYPE (super_decl);
5278 else
5279 super_decl_type =
5280 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
5282 else if (TREE_TYPE (decl) != object_type_node)
5283 super_decl_type = object_type_node;
5284 /* We're defining java.lang.Object */
5285 else
5286 super_decl_type = NULL_TREE;
5288 /* Set super info and mark the class a complete */
5289 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
5290 ctxp->interface_number);
5291 ctxp->interface_number = 0;
5292 CLASS_COMPLETE_P (decl) = 1;
5293 add_superinterfaces (decl, interfaces);
5295 return decl;
5298 /* Can't use lookup_field () since we don't want to load the class and
5299 can't set the CLASS_LOADED_P flag */
5301 static tree
5302 find_field (class, name)
5303 tree class;
5304 tree name;
5306 tree decl;
5307 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
5309 if (DECL_NAME (decl) == name)
5310 return decl;
5312 return NULL_TREE;
5315 /* Wrap around lookup_field that doesn't potentially upset the value
5316 of CLASS */
5318 static tree
5319 lookup_field_wrapper (class, name)
5320 tree class, name;
5322 tree type = class;
5323 return lookup_field (&type, name);
5326 /* Find duplicate field within the same class declarations and report
5327 the error. Returns 1 if a duplicated field was found, 0
5328 otherwise. */
5330 static int
5331 duplicate_declaration_error_p (new_field_name, new_type, cl)
5332 tree new_field_name, new_type, cl;
5334 /* This might be modified to work with method decl as well */
5335 tree decl = find_field (TREE_TYPE (ctxp->current_parsed_class),
5336 new_field_name);
5337 if (decl)
5339 char *t1 = strdup (lang_printable_name (new_type, 1));
5340 char *t2 =
5341 strdup ((TREE_CODE (TREE_TYPE (decl)) == TREE_LIST ?
5342 IDENTIFIER_POINTER (TYPE_NAME
5343 (TREE_PURPOSE (TREE_TYPE (decl)))) :
5344 lang_printable_name (TREE_TYPE (decl), 1)));
5345 parse_error_context
5346 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
5347 t1, IDENTIFIER_POINTER (new_field_name),
5348 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
5349 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5350 free (t1);
5351 free (t2);
5352 return 1;
5354 return 0;
5357 /* Field registration routine. If TYPE doesn't exist, field
5358 declarations are linked to the undefined TYPE dependency list, to
5359 be later resolved in java_complete_class () */
5361 static void
5362 register_fields (flags, type, variable_list)
5363 int flags;
5364 tree type, variable_list;
5366 tree current, saved_type;
5367 tree class_type = TREE_TYPE (ctxp->current_parsed_class);
5368 int saved_lineno = lineno;
5369 int must_chain = 0;
5370 tree wfl = NULL_TREE;
5372 /* If we're adding fields to interfaces, those fields are public,
5373 static, final */
5374 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
5376 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
5377 flags, ACC_PUBLIC,
5378 "%s", "interface field(s)");
5379 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
5380 flags, ACC_STATIC,
5381 "%s", "interface field(s)");
5382 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
5383 flags, ACC_FINAL, "%s", "interface field(s)");
5384 check_modifiers ("Illegal interface member modifier `%s'", flags,
5385 INTERFACE_FIELD_MODIFIERS);
5386 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
5389 /* Obtain a suitable type for resolution, if necessary */
5390 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
5392 /* If TYPE is fully resolved and we don't have a reference, make one */
5393 if (!must_chain && TREE_CODE (type) == RECORD_TYPE)
5394 type = promote_type (type);
5396 for (current = variable_list, saved_type = type; current;
5397 current = TREE_CHAIN (current), type = saved_type)
5399 tree field_decl;
5400 tree cl = TREE_PURPOSE (current);
5401 tree init = TREE_VALUE (current);
5402 tree current_name = EXPR_WFL_NODE (cl);
5404 /* Process NAME, as it may specify extra dimension(s) for it */
5405 type = build_array_from_name (type, wfl, current_name, &current_name);
5407 /* Check for redeclarations */
5408 if (duplicate_declaration_error_p (current_name, type, cl))
5409 continue;
5411 /* Type adjustment. We may have just readjusted TYPE because
5412 the variable specified more dimensions. Make sure we have
5413 a reference if we can and don't have one already. */
5414 if (type != saved_type && !must_chain
5415 && (TREE_CODE (type) == RECORD_TYPE))
5416 type = promote_type (type);
5418 /* Set lineno to the line the field was found and create a
5419 declaration for it */
5420 lineno = EXPR_WFL_LINENO (cl);
5421 field_decl = add_field (class_type, current_name, type, flags);
5423 /* Check if we must chain. */
5424 if (must_chain)
5425 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
5427 /* Default value of a static field is 0 and it is considered
5428 initialized. */
5429 if (flags & ACC_STATIC)
5430 INITIALIZED_P (field_decl) = 1;
5432 /* If we have an initialization value tied to the field */
5433 if (init)
5435 /* The field is declared static */
5436 if (flags & ACC_STATIC)
5438 /* FIXME */
5439 if (flags & ACC_FINAL)
5441 /* Otherwise, the field should be initialized in
5442 <clinit>. This field is remembered so we can
5443 generate <clinit> later. */
5444 else
5446 INITIALIZED_P (field_decl) = 1;
5447 TREE_CHAIN (init) = ctxp->static_initialized;
5448 ctxp->static_initialized = init;
5451 /* A non-static field declared with an immediate
5452 initialization is to be initialized in <init>, if
5453 any. This field is remembered to be processed at the
5454 time of the generation of <init>. */
5455 else
5457 TREE_CHAIN (init) = ctxp->non_static_initialized;
5458 ctxp->non_static_initialized = init;
5462 lineno = saved_lineno;
5465 /* Check whether it is necessary to generate a <clinit> for the class
5466 we just parsed. */
5468 static void
5469 maybe_generate_clinit ()
5471 int saved_lineno;
5472 tree meth, mdecl, c;
5473 tree cclass, class_wfl;
5475 if (!ctxp->static_initialized || java_error_count)
5476 return;
5478 cclass = TREE_TYPE (ctxp->current_parsed_class);
5479 class_wfl = build_expr_wfl (DECL_NAME (TYPE_NAME (cclass)),
5480 input_filename, 0, 0);
5482 saved_lineno = lineno;
5483 lineno = 0;
5484 meth = make_node (FUNCTION_TYPE);
5485 TREE_TYPE (meth) = void_type_node;
5486 TYPE_ARG_TYPES (meth) = NULL_TREE;
5487 mdecl = add_method (cclass, ACC_STATIC, clinit_identifier_node,
5488 build_java_signature (meth));
5489 lineno = saved_lineno;
5491 DECL_SOURCE_LINE (mdecl) = 1;
5492 DECL_SOURCE_LINE_MERGE (mdecl, 1);
5493 source_start_java_method (mdecl);
5494 enter_block ();
5496 /* Keep initialization in order to enforce 8.5 */
5497 ctxp->static_initialized = nreverse (ctxp->static_initialized);
5499 /* We process the list of assignment we produced as the result of
5500 the declaration of initialized static field and add them as
5501 statement to the <clinit> method. */
5502 for (c = ctxp->static_initialized; c; c = TREE_CHAIN (c))
5504 /* We build the assignment expression that will initialize the
5505 field to its value. There are strict rules on static
5506 initializers (8.5). FIXME */
5507 java_method_add_stmt (mdecl, c);
5510 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
5511 exit_block ();
5512 ctxp->static_initialized = NULL_TREE;
5515 /* Shared accros method_declarator and method_header to remember the
5516 patch stage that was reached during the declaration of the method.
5517 A method DECL is built differently is there is no patch
5518 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
5519 pending on the currently defined method. */
5521 static int patch_stage;
5523 /* Check the method declaration and add the method to its current
5524 class. If the argument list is known to contain incomplete types,
5525 the method is partially added and the registration will be resume
5526 once the method arguments resolved */
5528 static tree
5529 method_header (flags, type, mdecl, throws)
5530 int flags;
5531 tree type, mdecl, throws;
5533 tree meth = TREE_VALUE (mdecl);
5534 tree id = TREE_PURPOSE (mdecl);
5535 tree this_class = TREE_TYPE (ctxp->current_parsed_class);
5536 tree meth_name, returned_type, current;
5537 int saved_lineno;
5539 check_modifiers_consistency (flags);
5541 /* There are some forbidden modifiers for an abstract method and its
5542 class must be abstract as well. */
5543 if (flags & ACC_ABSTRACT)
5545 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
5546 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
5547 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
5548 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
5549 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
5550 if (!CLASS_ABSTRACT (TYPE_NAME (this_class)))
5551 parse_error_context
5552 (id, "Class `%s' must be declared abstract to define abstract "
5553 "method `%s'",
5554 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
5555 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
5559 /* Method declared within the scope of an interface are implicitly
5560 abstract and public. Conflicts with other erroneously provided
5561 modifiers are check right after. */
5563 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
5565 /* If FLAGS isn't set because of a modifier, turn the
5566 corresponding modifier WFL to NULL so we issue a warning on
5567 the obsolete use of the modifier */
5568 if (!(flags & ACC_PUBLIC))
5569 MODIFIER_WFL (PUBLIC_TK) = NULL;
5570 if (!(flags & ACC_ABSTRACT))
5571 MODIFIER_WFL (ABSTRACT_TK) = NULL;
5572 flags |= ACC_PUBLIC;
5573 flags |= ACC_ABSTRACT;
5576 /* Modifiers context reset moved up, so abstract method declaration
5577 modifiers can be later checked. */
5579 meth_name = EXPR_WFL_NODE (id);
5581 if (unresolved_type_p (type, &returned_type))
5583 if (returned_type)
5584 TREE_TYPE (meth) = returned_type;
5585 else
5587 patch_stage = JDEP_METHOD_RETURN;
5588 TREE_TYPE (meth) =
5589 register_incomplete_type (patch_stage, type, id, NULL_TREE);
5592 else
5593 TREE_TYPE (meth) = type;
5595 saved_lineno = lineno;
5596 /* When defining an abstract or interface method, the curly
5597 bracket at level 1 doesn't exist because there is no function
5598 body */
5599 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
5600 EXPR_WFL_LINENO (id));
5602 if (patch_stage) /* includes ret type and/or all args */
5604 jdep *jdep;
5605 meth = add_method_1 (this_class, flags, meth_name, meth);
5606 /* Patch for the return type */
5607 if (patch_stage == JDEP_METHOD_RETURN)
5609 jdep = CLASSD_LAST (ctxp->classd_list);
5610 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
5612 /* This is the stop JDEP. METH allows the function's signature
5613 to be computed. */
5614 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
5616 else
5618 tree signature = build_java_signature (meth);
5619 tree arg, orig_arg;
5620 /* Save original argument list, including argument's names */
5621 orig_arg = TYPE_ARG_TYPES (meth);
5622 /* Add the method to its class */
5623 meth = add_method (this_class, flags, meth_name, signature);
5624 /* Fix the method argument list so we have the argument name
5625 information */
5626 arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
5627 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
5629 TREE_PURPOSE (arg) = this_identifier_node;
5630 arg = TREE_CHAIN (arg);
5632 while (orig_arg)
5634 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
5635 orig_arg = TREE_CHAIN (orig_arg);
5636 arg = TREE_CHAIN (arg);
5639 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
5640 lineno = saved_lineno;
5642 /* Register exception specified by the `throws' keyword for
5643 resolution and set the method decl appropriate field to the list.
5644 Note: the grammar ensures that what we get here are class
5645 types. */
5646 if (throws)
5648 throws = nreverse (throws);
5649 for (current = throws; current; current = TREE_CHAIN (current))
5651 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
5652 NULL_TREE, NULL_TREE);
5653 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
5654 &TREE_VALUE (current);
5656 DECL_FUNCTION_THROWS (meth) = throws;
5659 /* We set the DECL_NAME to ID so we can track the location where
5660 the function was declared. This allow us to report
5661 redefinition error accurately. When method are verified,
5662 DECL_NAME is reinstalled properly (using the content of the
5663 WFL node ID) (see check_method_redefinition). We don't do that
5664 when Object is being defined. */
5665 if (TREE_TYPE (ctxp->current_parsed_class) != object_type_node)
5666 DECL_NAME (meth) = id;
5667 return meth;
5670 /* Check modifiers that can be declared but exclusively */
5672 static void
5673 check_modifiers_consistency (flags)
5674 int flags;
5676 int acc_count = 0;
5677 tree cl = NULL_TREE;
5679 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, 0, acc_count, cl);
5680 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, 1, acc_count, cl);
5681 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, 2, acc_count, cl);
5682 if (acc_count > 1)
5683 parse_error_context
5684 (cl, "Inconsistent member declaration. At most one of `public', "
5685 "`private', or `protected' may be specified");
5688 /* Check the methode header METH for abstract specifics features */
5690 static void
5691 check_abstract_method_header (meth)
5692 tree meth;
5694 int flags = get_access_flags_from_decl (meth);
5695 /* DECL_NAME might still be a WFL node */
5696 tree name = (TREE_CODE (DECL_NAME (meth)) == EXPR_WITH_FILE_LOCATION ?
5697 EXPR_WFL_NODE (DECL_NAME (meth)) : DECL_NAME (meth));
5699 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags,
5700 ACC_ABSTRACT, "abstract method `%s'",
5701 IDENTIFIER_POINTER (name));
5702 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags,
5703 ACC_PUBLIC, "abstract method `%s'",
5704 IDENTIFIER_POINTER (name));
5706 check_modifiers ("Illegal modifier `%s' for interface method",
5707 flags, INTERFACE_METHOD_MODIFIERS);
5710 /* Create a FUNCTION_TYPE node and start augmenting it with the
5711 declared function arguments. Arguments type that can't be resolved
5712 are left as they are, but the returned node is marked as containing
5713 incomplete types. */
5715 static tree
5716 method_declarator (id, list)
5717 tree id, list;
5719 tree arg_types = NULL_TREE, current, node;
5720 tree meth = make_node (FUNCTION_TYPE);
5721 jdep *jdep;
5723 patch_stage = JDEP_NO_PATCH;
5725 for (current = list; current; current = TREE_CHAIN (current))
5727 int must_chain = 0;
5728 tree wfl_name = TREE_PURPOSE (current);
5729 tree type = TREE_VALUE (current);
5730 tree name = EXPR_WFL_NODE (wfl_name);
5731 tree already, arg_node;
5732 tree type_wfl = NULL_TREE;
5734 /* Obtain a suitable type for resolution, if necessary */
5735 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
5737 /* Process NAME, as it may specify extra dimension(s) for it */
5738 type = build_array_from_name (type, type_wfl, name, &name);
5739 EXPR_WFL_NODE (wfl_name) = name;
5741 /* Check redefinition */
5742 for (already = arg_types; already; already = TREE_CHAIN (already))
5743 if (TREE_PURPOSE (already) == name)
5745 parse_error_context
5746 (wfl_name, "Variable `%s' is used more than once in the "
5747 "argument list of method `%s'", IDENTIFIER_POINTER (name),
5748 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
5749 break;
5752 /* If we've an incomplete argument type, we know there is a location
5753 to patch when the type get resolved, later. */
5754 jdep = NULL;
5755 if (must_chain)
5757 patch_stage = JDEP_METHOD;
5758 type = register_incomplete_type (patch_stage,
5759 type_wfl, wfl_name, type);
5760 jdep = CLASSD_LAST (ctxp->classd_list);
5761 JDEP_MISC (jdep) = id;
5764 /* The argument node: a name and a (possibly) incomplete type */
5765 arg_node = build_tree_list (name, type);
5766 if (jdep)
5767 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
5768 TREE_CHAIN (arg_node) = arg_types;
5769 arg_types = arg_node;
5771 TYPE_ARG_TYPES (meth) = nreverse (arg_types);
5772 node = build_tree_list (id, meth);
5773 return node;
5776 static int
5777 unresolved_type_p (wfl, returned)
5778 tree wfl;
5779 tree *returned;
5782 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
5784 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
5785 if (returned)
5786 *returned = (decl ? TREE_TYPE (decl) : NULL_TREE);
5787 return 1;
5789 if (returned)
5790 *returned = wfl;
5791 return 0;
5794 /* From NAME, build a qualified identifier node using the
5795 qualification from the current package definition. */
5797 static tree
5798 parser_qualified_classname (name)
5799 tree name;
5801 if (ctxp->package)
5802 return merge_qualified_name (ctxp->package, EXPR_WFL_NODE (name));
5803 else
5804 return EXPR_WFL_NODE (name);
5807 /* Called once the type a interface extends is resolved. Returns 0 if
5808 everything is OK. */
5810 static int
5811 parser_check_super_interface (super_decl, this_decl, this_wfl)
5812 tree super_decl, this_decl, this_wfl;
5814 tree super_type = TREE_TYPE (super_decl);
5816 /* Has to be an interface */
5817 if (!CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (super_decl))))
5819 parse_error_context
5820 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
5821 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
5822 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
5823 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
5824 "interface" : "class"),
5825 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
5826 return 1;
5829 /* Check scope: same package OK, other package: OK if public */
5830 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
5831 return 1;
5833 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
5834 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
5835 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
5836 return 0;
5839 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
5840 0 if everthing is OK. */
5842 static int
5843 parser_check_super (super_decl, this_decl, wfl)
5844 tree super_decl, this_decl, wfl;
5846 tree super_type = TREE_TYPE (super_decl);
5848 /* SUPER should be a CLASS (neither an array nor an interface) */
5849 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
5851 parse_error_context
5852 (wfl, "Class `%s' can't subclass %s `%s'",
5853 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
5854 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
5855 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
5856 return 1;
5859 if (CLASS_FINAL (TYPE_NAME (super_type)))
5861 parse_error_context (wfl, "Can't subclass final classes: %s",
5862 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
5863 return 1;
5866 /* Check scope: same package OK, other package: OK if public */
5867 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
5868 return 1;
5870 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
5871 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
5872 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
5873 return 0;
5876 /* Create a new dependency list and link it (in a LIFO manner) to the
5877 CTXP list of type dependency list. */
5879 static void
5880 create_jdep_list (ctxp)
5881 struct parser_ctxt *ctxp;
5883 jdeplist *new = malloc (sizeof (jdeplist));
5885 if (!new)
5886 fatal ("Can't alloc jdeplist - create_jdep_list");
5888 new->first = new->last = NULL;
5889 new->next = ctxp->classd_list;
5890 ctxp->classd_list = new;
5893 static jdeplist *
5894 reverse_jdep_list (ctxp)
5895 struct parser_ctxt *ctxp;
5897 register jdeplist *prev = NULL, *current, *next;
5898 for (current = ctxp->classd_list; current; current = next)
5900 next = current->next;
5901 current->next = prev;
5902 prev = current;
5904 return prev;
5907 /* Create a fake pointer based on the ID stored in the WFL */
5909 static tree
5910 obtain_incomplete_type (wfl)
5911 tree wfl;
5913 tree ptr;
5914 tree name = EXPR_WFL_NODE (wfl);
5916 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
5917 if (TYPE_NAME (TREE_PURPOSE (ptr)) == name)
5918 break;
5920 if (!ptr)
5922 tree core;
5923 push_obstacks (&permanent_obstack, &permanent_obstack);
5924 BUILD_PTR_FROM_NAME (core, name);
5925 ptr = build_tree_list (core, NULL_TREE);
5926 pop_obstacks ();
5927 TREE_CHAIN (ptr) = ctxp->incomplete_class;
5928 ctxp->incomplete_class = ptr;
5931 return ptr;
5934 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
5935 non NULL instead of computing a new fake type based on WFL. The new
5936 dependency is inserted in the current type dependency list, in FIFO
5937 manner. */
5939 static tree
5940 register_incomplete_type (kind, wfl, decl, ptr)
5941 int kind;
5942 tree wfl, decl, ptr;
5944 jdep *new = malloc (sizeof (jdep));
5946 if (!new)
5947 fatal ("Can't allocate new jdep - register_incomplete_type");
5948 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
5949 ptr = obtain_incomplete_type (wfl);
5951 JDEP_KIND (new) = kind;
5952 JDEP_DECL (new) = decl;
5953 JDEP_SOLV (new) = ptr;
5954 JDEP_WFL (new) = wfl;
5955 JDEP_CHAIN (new) = NULL;
5956 JDEP_MISC (new) = NULL_TREE;
5957 JDEP_GET_PATCH (new) = (tree *)NULL;
5959 JDEP_INSERT (ctxp->classd_list, new);
5961 return ptr;
5964 void
5965 java_check_circular_reference ()
5967 tree current;
5968 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
5970 tree type = TREE_TYPE (current);
5971 if (CLASS_INTERFACE (TYPE_NAME (type)))
5973 /* Check all interfaces this class extends */
5974 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
5975 int n, i;
5977 if (!basetype_vec)
5978 return;
5979 n = TREE_VEC_LENGTH (basetype_vec);
5980 for (i = 0; i < n; i++)
5982 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
5983 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
5984 && interface_of_p (type, BINFO_TYPE (vec_elt)))
5985 parse_error_context (lookup_cl (current),
5986 "Cyclic interface inheritance");
5989 else
5990 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
5991 parse_error_context (lookup_cl (current),
5992 "Cyclic class inheritance");
5996 void
5997 safe_layout_class (class)
5998 tree class;
6000 tree save_current_class = current_class;
6001 char *save_input_filename = input_filename;
6002 int save_lineno = lineno;
6004 push_obstacks (&permanent_obstack, &permanent_obstack);
6005 layout_class (class);
6006 pop_obstacks ();
6008 current_class = save_current_class;
6009 input_filename = save_input_filename;
6010 lineno = save_lineno;
6011 CLASS_LOADED_P (class) = 1;
6014 static tree
6015 jdep_resolve_class (dep)
6016 jdep *dep;
6018 tree decl;
6020 if (!JDEP_RESOLVED_P (dep))
6022 decl =
6023 resolve_class (JDEP_TO_RESOLVE (dep), JDEP_DECL (dep), JDEP_WFL (dep));
6024 JDEP_RESOLVED (dep, decl);
6026 else
6027 decl = JDEP_RESOLVED_DECL (dep);
6029 if (!decl)
6031 complete_class_report_errors (dep);
6032 return NULL_TREE;
6034 return decl;
6037 /* Complete unsatisfied class declaration and their dependencies */
6039 void
6040 java_complete_class ()
6042 tree cclass;
6043 jdeplist *cclassd;
6044 int error_found;
6045 tree type;
6047 push_obstacks (&permanent_obstack, &permanent_obstack);
6049 /* Process imports and reverse the import on demand list */
6050 process_imports ();
6051 if (ctxp->import_demand_list)
6052 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
6054 /* Rever things so we have the right order */
6055 ctxp->class_list = nreverse (ctxp->class_list);
6056 ctxp->classd_list = reverse_jdep_list (ctxp);
6058 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
6059 cclass && cclassd;
6060 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
6062 jdep *dep;
6063 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
6065 tree decl;
6067 if (!(decl = jdep_resolve_class (dep)))
6068 continue;
6070 /* Now it's time to patch */
6071 switch (JDEP_KIND (dep))
6073 case JDEP_SUPER:
6074 /* Simply patch super */
6075 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
6076 continue;
6077 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
6078 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
6079 break;
6081 case JDEP_FIELD:
6083 /* We do part of the job done in add_field */
6084 tree field_decl = JDEP_DECL (dep);
6085 tree field_type = TREE_TYPE (decl);
6086 push_obstacks (&permanent_obstack, &permanent_obstack);
6087 if (TREE_CODE (field_type) == RECORD_TYPE)
6088 field_type = promote_type (field_type);
6089 pop_obstacks ();
6090 TREE_TYPE (field_decl) = field_type;
6091 SOURCE_FRONTEND_DEBUG
6092 (("Completed field/var decl `%s' with `%s'",
6093 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
6094 IDENTIFIER_POINTER (DECL_NAME (decl))));
6095 break;
6097 case JDEP_METHOD: /* We start patching a method */
6098 case JDEP_METHOD_RETURN:
6099 error_found = 0;
6100 while (1)
6102 if (decl)
6104 type = TREE_TYPE(decl);
6105 if (TREE_CODE (type) == RECORD_TYPE)
6106 type = promote_type (type);
6107 JDEP_APPLY_PATCH (dep, type);
6108 SOURCE_FRONTEND_DEBUG
6109 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
6110 "Completing fct `%s' with ret type `%s'":
6111 "Completing arg `%s' with type `%s'"),
6112 IDENTIFIER_POINTER (EXPR_WFL_NODE
6113 (JDEP_DECL_WFL (dep))),
6114 IDENTIFIER_POINTER (DECL_NAME (decl))));
6116 else
6117 error_found = 1;
6118 dep = JDEP_CHAIN (dep);
6119 if (JDEP_KIND (dep) == JDEP_METHOD_END)
6120 break;
6121 else
6122 decl = jdep_resolve_class (dep);
6124 if (!error_found)
6126 tree mdecl = JDEP_DECL (dep), signature;
6127 push_obstacks (&permanent_obstack, &permanent_obstack);
6128 /* Recompute and reset the signature */
6129 signature = build_java_signature (TREE_TYPE (mdecl));
6130 set_java_signature (TREE_TYPE (mdecl), signature);
6131 pop_obstacks ();
6133 else
6134 continue;
6135 break;
6137 case JDEP_INTERFACE:
6138 if (parser_check_super_interface (decl, JDEP_DECL (dep),
6139 JDEP_WFL (dep)))
6140 continue;
6141 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
6142 break;
6144 case JDEP_PARM:
6145 case JDEP_VARIABLE:
6146 type = TREE_TYPE(decl);
6147 if (TREE_CODE (type) == RECORD_TYPE)
6148 type = promote_type (type);
6149 JDEP_APPLY_PATCH (dep, type);
6150 break;
6152 case JDEP_TYPE:
6153 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6154 SOURCE_FRONTEND_DEBUG
6155 (("Completing a random type dependency on a '%s' node",
6156 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
6157 break;
6159 case JDEP_EXCEPTION:
6160 /* Check for righteous inheritance here */
6161 if (!inherits_from_p (TREE_TYPE (decl), throwable_type_node))
6163 parse_error_context
6164 (JDEP_WFL (dep), "Class `%s' in `throws' clause must be "
6165 "a subclass of class `java.lang.Throwable'",
6166 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
6168 else
6170 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6171 SOURCE_FRONTEND_DEBUG
6172 (("Completing `%s' `throws' argument node",
6173 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
6175 break;
6177 default:
6178 fatal ("Can't handle patch code %d - java_complete_class",
6179 JDEP_KIND (dep));
6183 pop_obstacks ();
6184 return;
6187 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
6188 array. */
6190 static tree
6191 resolve_class (class_type, decl, cl)
6192 tree class_type, decl, cl;
6194 char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
6195 char *base = name;
6196 tree resolved_type, resolved_type_decl;
6198 /* 1- Check to see if we have an array. If true, find what we really
6199 want to resolve */
6200 while (name[0] == '[')
6201 name++;
6202 if (base != name)
6203 TYPE_NAME (class_type) = get_identifier (name);
6205 /* 2- Resolve the bare type */
6206 if (!(resolved_type_decl = do_resolve_class (class_type, decl, cl)))
6207 return NULL_TREE;
6208 resolved_type = TREE_TYPE (resolved_type_decl);
6210 /* 3- If we have and array, reconstruct the array down to its nesting */
6211 if (base != name)
6213 while (base != name)
6215 if (TREE_CODE (resolved_type) == RECORD_TYPE)
6216 resolved_type = promote_type (resolved_type);
6217 resolved_type = build_java_array_type (resolved_type, -1);
6218 CLASS_LOADED_P (resolved_type) = 1;
6219 name--;
6221 /* Build a fake decl for this, since this is what is expected to
6222 be returned. */
6223 resolved_type_decl =
6224 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
6225 /* Figure how those two things are important for error report. FIXME */
6226 DECL_SOURCE_LINE (resolved_type_decl) = 0;
6227 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
6229 return resolved_type_decl;
6232 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
6233 are used to report error messages. */
6235 static tree
6236 do_resolve_class (class_type, decl, cl)
6237 tree class_type;
6238 tree decl;
6239 tree cl;
6241 tree new_class_decl;
6242 tree original_name = NULL_TREE;
6244 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
6245 its is changed by find_in_imports{_on_demand} */
6247 /* 1- Check for the type in single imports */
6248 if (find_in_imports (class_type))
6249 return NULL_TREE;
6251 /* 2- And check for the type in the current compilation unit. If it fails,
6252 try with a name qualified with the package name if appropriate. */
6254 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6256 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6257 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6258 load_class (TYPE_NAME (class_type), 0);
6259 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6262 original_name = TYPE_NAME (class_type);
6263 if (!QUALIFIED_P (TYPE_NAME (class_type)) && ctxp->package)
6264 TYPE_NAME (class_type) = merge_qualified_name (ctxp->package,
6265 TYPE_NAME (class_type));
6266 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6268 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6269 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6270 load_class (TYPE_NAME (class_type), 0);
6271 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6273 TYPE_NAME (class_type) = original_name;
6275 /* 3- Check an other compilation unit that bears the name of type */
6276 load_class (TYPE_NAME (class_type), 0);
6277 if (check_pkg_class_access (TYPE_NAME (class_type),
6278 (cl ? cl : lookup_cl (decl))))
6279 return NULL_TREE;
6281 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6282 return new_class_decl;
6284 /* 4- Check the import on demands. Don't allow bar.baz to be
6285 imported from foo.* */
6286 if (!QUALIFIED_P (TYPE_NAME (class_type)))
6287 if (find_in_imports_on_demand (class_type))
6288 return NULL_TREE;
6290 /* 5- Last call for a resolution */
6291 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6294 /* Resolve NAME and lay it out (if not done and if not the current
6295 parsed class). Return a decl node. */
6297 static tree
6298 resolve_and_layout (name, cl)
6299 tree name;
6300 tree cl;
6302 tree decl = resolve_no_layout (name, cl);
6303 if (decl && TREE_TYPE (decl) != current_class
6304 && !CLASS_LOADED_P (TREE_TYPE (decl)))
6305 safe_layout_class (TREE_TYPE (decl));
6306 return decl;
6309 /* Resolve a class, returns its decl but doesn't perform any
6310 layout. The current parsing context is saved and restored */
6312 static tree
6313 resolve_no_layout (name, cl)
6314 tree name, cl;
6316 tree ptr, decl;
6317 BUILD_PTR_FROM_NAME (ptr, name);
6318 java_parser_context_save_global ();
6319 decl = resolve_class (ptr, NULL_TREE, cl);
6320 java_parser_context_restore_global ();
6322 return decl;
6325 /* Called to report errors. Skip leader '[' in a complex array type
6326 description that failed to be resolved. */
6328 static char *
6329 purify_type_name (name)
6330 char *name;
6332 while (*name && *name == '[')
6333 name++;
6334 return name;
6337 /* The type CURRENT refers to can't be found. We print error messages. */
6339 static void
6340 complete_class_report_errors (dep)
6341 jdep *dep;
6343 switch (JDEP_KIND (dep))
6345 case JDEP_SUPER:
6346 parse_error_context
6347 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
6348 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6349 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6350 break;
6351 case JDEP_FIELD:
6352 parse_error_context
6353 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
6354 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6355 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6356 break;
6357 case JDEP_METHOD: /* Covers arguments */
6358 parse_error_context
6359 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6360 "argument `%s' of method `%s'",
6361 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6362 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
6363 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
6364 break;
6365 case JDEP_METHOD_RETURN: /* Covers return type */
6366 parse_error_context
6367 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6368 "return type of method `%s'",
6369 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6370 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
6371 break;
6372 case JDEP_INTERFACE:
6373 parse_error_context
6374 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
6375 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6376 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
6377 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6378 break;
6379 case JDEP_VARIABLE:
6380 parse_error_context
6381 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6382 "local variable `%s'",
6383 purify_type_name (IDENTIFIER_POINTER
6384 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
6385 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6386 break;
6387 case JDEP_EXCEPTION: /* As specified by `throws' */
6388 parse_error_context
6389 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
6390 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
6391 break;
6392 default:
6393 /* Fix for -Wall. Just break doing nothing. The error will be
6394 caught later */
6395 break;
6399 /* Check uninitialized final. */
6401 void
6402 java_check_final ()
6406 static int
6407 check_method_redefinition (class, method)
6408 tree class, method;
6410 tree redef, name;
6411 tree cl = DECL_NAME (method);
6412 tree sig = TYPE_LANG_SPECIFIC (TREE_TYPE (method))->signature;
6413 /* decl name of generated <clinit> doesn't need to be fixed and
6414 checked */
6415 if (DECL_NAME (method) != clinit_identifier_node)
6417 /* NAME is just the plain name when Object is being defined */
6418 if (class != object_type_node)
6419 name = DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
6420 else
6421 name = DECL_NAME (method);
6423 else
6424 return 0;
6426 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
6428 struct lang_type *t = TYPE_LANG_SPECIFIC (TREE_TYPE (redef));
6430 if (! t || (redef == method))
6431 break;
6432 if (DECL_NAME (redef) == name && sig == t->signature)
6434 parse_error_context (cl, "Duplicate method declaration");
6435 return 1;
6438 return 0;
6441 /* Check all the methods of CLASS. Methods are first completed then
6442 checked according to regular method existance rules.
6443 If no constructor were encountered, then build its declaration. */
6445 static void
6446 java_check_regular_methods (class_decl)
6447 tree class_decl;
6449 tree method;
6450 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
6451 tree super_class = CLASSTYPE_SUPER (class);
6452 int seen_constructor = 0;
6454 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
6456 /* Should take interfaces into account. FIXME */
6457 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
6459 tree found, sig;
6460 tree method_wfl = DECL_NAME (method);
6461 int aflags;
6463 if (DECL_CONSTRUCTOR_P (method))
6464 seen_constructor = 1;
6466 /* Check for redefinitions */
6467 if (check_method_redefinition (class, method))
6468 continue;
6470 sig = build_java_argument_signature (TREE_TYPE (method));
6472 found = lookup_argument_method (super_class, DECL_NAME (method), sig);
6474 /* Nothing overrides or it's a private method */
6475 if (!found || (found && METHOD_PRIVATE (found)))
6476 continue;
6477 /* Can't override a method with the same name and different return
6478 types. */
6479 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
6481 char *t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
6482 0));
6483 parse_error_context
6484 (method_wfl,
6485 "Method `%s' was defined with return type `%s' in class `%s'",
6486 lang_printable_name (found, 0), t,
6487 IDENTIFIER_POINTER
6488 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6489 free (t);
6492 /* Can't override final. Can't override static. */
6493 if (METHOD_FINAL (found) || METHOD_STATIC (found))
6495 /* Static *can* override static */
6496 if (METHOD_STATIC (found) && METHOD_STATIC (method))
6497 continue;
6498 parse_error_context
6499 (method_wfl,
6500 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
6501 (METHOD_FINAL (found) ? "Final" : "Static"),
6502 lang_printable_name (found, 0),
6503 (METHOD_FINAL (found) ? "final" : "static"),
6504 IDENTIFIER_POINTER
6505 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6506 continue;
6508 /* Static method can't override instance method. */
6509 if (METHOD_STATIC (method))
6511 parse_error_context
6512 (method_wfl,
6513 "Instance methods can't be overriden by a static method. Method "
6514 "`%s' is an instance method in class `%s'",
6515 lang_printable_name (found, 0),
6516 IDENTIFIER_POINTER
6517 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6518 continue;
6520 /* Overriding/hiding public must be public or
6521 overriding/hiding protected must be protected or public */
6522 if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method)) ||
6523 (METHOD_PROTECTED (found)
6524 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method))))
6526 parse_error_context
6527 (method_wfl,
6528 "Methods can't be overridden to be more private. Method `%s' is "
6529 "%s in class `%s'", lang_printable_name (found, 0),
6530 (METHOD_PUBLIC (found) ? "public" : "protected"),
6531 IDENTIFIER_POINTER
6532 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6533 continue;
6536 /* Overriding methods must have compatible `throws' clauses on checked
6537 exceptions, if any */
6538 check_throws_clauses (method, method_wfl, found);
6540 /* If the method has default access in an other package, then
6541 issue a warning that the current method doesn't override the
6542 one that was found elsewhere */
6543 aflags = get_access_flags_from_decl (found);
6544 if ((!aflags || (aflags > ACC_PROTECTED))
6545 && !class_in_current_package (DECL_CONTEXT (found)))
6546 parse_warning_context
6547 (method_wfl, "Method `%s' in class `%s' does not "
6548 "override the corresponding method in class `%s', which is "
6549 "private to a different package",
6550 lang_printable_name (found, 0),
6551 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
6552 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6554 /* Check on (default) package access. FIXME. */
6555 /* Inheriting multiple methods with the same signature. FIXME */
6558 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
6560 if (!seen_constructor)
6562 /* No constructor seen, we craft one, at line 0 */
6563 int saved_lineno = lineno;
6564 tree meth, decl;
6565 lineno = 0;
6566 meth = make_node (FUNCTION_TYPE);
6567 TREE_TYPE (meth) = void_type_node;
6568 TYPE_ARG_TYPES (meth) = NULL_TREE;
6569 decl = add_method (class, 0, init_identifier_node,
6570 build_java_signature (meth));
6571 DECL_CONSTRUCTOR_P (decl) = 1;
6572 lineno = saved_lineno;
6576 /* Return a non zero value if the `throws' clause of METHOD (if any)
6577 is incompatible with the `throws' clause of FOUND (if any). */
6579 static void
6580 check_throws_clauses (method, method_wfl, found)
6581 tree method, method_wfl, found;
6583 tree mthrows, fthrows;
6585 for (mthrows = DECL_FUNCTION_THROWS (method);
6586 mthrows; mthrows = TREE_CHAIN (mthrows))
6588 /* We don't verify unchecked expressions */
6589 if (IS_UNCHECKED_EXPRESSION_P (TREE_VALUE (mthrows)))
6590 continue;
6591 /* Checked expression must be compatible */
6592 for (fthrows = DECL_FUNCTION_THROWS (found);
6593 fthrows; fthrows = TREE_CHAIN (fthrows))
6594 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
6595 break;
6596 if (!fthrows)
6598 parse_error_context
6599 (method_wfl, "Invalid checked exception class `%s' in "
6600 "`throws' clause. The exception must be a subclass of an "
6601 "exception thrown by `%s' from class `%s'",
6602 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
6603 lang_printable_name (found, 0),
6604 IDENTIFIER_POINTER
6605 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6610 /* Check abstract method of interface INTERFACE */
6612 static void
6613 java_check_abstract_methods (interface)
6614 tree interface;
6616 int i, n;
6617 tree method, basetype_vec, found;
6619 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
6621 tree method_wfl = DECL_NAME (method);
6623 /* 2- Check for double definition inside the defining interface */
6624 if (check_method_redefinition (interface, method))
6625 continue;
6627 /* 3- Overriding is OK as far as we preserve the return type and
6628 the thrown exceptions (FIXME) */
6629 found = lookup_java_interface_method2 (interface, method);
6630 if (found)
6632 char *t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
6633 0));
6634 parse_error_context
6635 (method_wfl,
6636 "Method `%s' was defined with return type `%s' in class `%s ",
6637 lang_printable_name (found, 0), t,
6638 IDENTIFIER_POINTER
6639 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6640 free (t);
6641 continue;
6645 /* 4- Inherited methods can't differ by their returned types */
6646 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
6647 return;
6648 n = TREE_VEC_LENGTH (basetype_vec);
6649 for (i = 0; i < n; i++)
6651 tree sub_interface_method, sub_interface;
6652 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
6653 if (!vec_elt)
6654 continue;
6655 sub_interface = BINFO_TYPE (vec_elt);
6656 for (sub_interface_method = TYPE_METHODS (sub_interface);
6657 sub_interface_method;
6658 sub_interface_method = TREE_CHAIN (sub_interface_method))
6660 found = lookup_java_interface_method2 (interface,
6661 sub_interface_method);
6662 if (found && (found != sub_interface_method))
6663 parse_error_context
6664 (lookup_cl (sub_interface_method),
6665 "Interface `%s' inherits method `%s' from interface `%s'. This "
6666 "method is redefined with a different return "
6667 "type in interface `%s'",
6668 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
6669 lang_printable_name (found, 0),
6670 IDENTIFIER_POINTER
6671 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (sub_interface_method)))),
6672 IDENTIFIER_POINTER
6673 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
6678 /* Check the method on all the defined classes. Should be done to the
6679 classes declared in the compilation unit only. FIXME */
6681 void
6682 java_check_methods ()
6685 tree current;
6686 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
6687 if (CLASS_FROM_SOURCE_P (TREE_TYPE (current)))
6689 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current));
6691 if (CLASS_INTERFACE (TYPE_NAME (class)))
6692 java_check_abstract_methods (class);
6693 else
6694 java_check_regular_methods (current);
6698 /* Lookup methods in interfaces using their name and partial
6699 signature. Return a matching method only if their types differ. */
6701 static tree
6702 lookup_java_interface_method2 (class, method_decl)
6703 tree class, method_decl;
6705 int i, n;
6706 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
6708 if (!basetype_vec)
6709 return NULL_TREE;
6711 n = TREE_VEC_LENGTH (basetype_vec);
6712 for (i = 0; i < n; i++)
6714 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
6715 if ((BINFO_TYPE (vec_elt) != object_type_node)
6716 && (to_return =
6717 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
6718 return to_return;
6720 for (i = 0; i < n; i++)
6722 to_return = lookup_java_interface_method2
6723 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
6724 if (to_return)
6725 return to_return;
6728 return NULL_TREE;
6731 /* Lookup method using their name and partial signature. Return a
6732 matching method only if their types differ. */
6734 static tree
6735 lookup_java_method2 (clas, method_decl, do_interface)
6736 tree clas, method_decl;
6737 int do_interface;
6739 tree method, method_signature, method_name, method_type;
6740 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
6741 method_name = DECL_NAME (method_decl);
6742 method_type = TREE_TYPE (TREE_TYPE (method_decl));
6744 while (clas != NULL_TREE)
6746 for (method = TYPE_METHODS (clas);
6747 method != NULL_TREE; method = TREE_CHAIN (method))
6749 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
6750 if (DECL_NAME (method) == method_name
6751 && method_sig == method_signature
6752 && TREE_TYPE (TREE_TYPE (method)) != method_type)
6754 return method;
6757 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
6759 return NULL_TREE;
6762 /* Return the line that matches DECL line number. Used during error
6763 report */
6765 static tree
6766 lookup_cl (decl)
6767 tree decl;
6769 static tree cl = NULL_TREE;
6771 if (!decl)
6772 return NULL_TREE;
6774 if (cl == NULL_TREE)
6775 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
6777 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
6778 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
6780 return cl;
6783 /* Look for a simple name in the single-type import list */
6785 static tree
6786 find_name_in_single_imports (name)
6787 tree name;
6789 tree node;
6791 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
6792 if (TREE_VALUE (node) == name)
6793 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
6795 return NULL_TREE;
6798 /* Process all single-type import. */
6800 static int
6801 process_imports ()
6803 tree import;
6804 int error_found;
6806 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
6808 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
6810 /* Don't load twice something already defined. */
6811 if (IDENTIFIER_CLASS_VALUE (to_be_found))
6812 continue;
6813 QUALIFIED_P (to_be_found) = 1;
6814 load_class (to_be_found, 0);
6815 error_found =
6816 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
6817 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
6819 parse_error_context (TREE_PURPOSE (import),
6820 "Class or interface `%s' not found in import",
6821 IDENTIFIER_POINTER (to_be_found));
6822 return 1;
6824 if (error_found)
6825 return 1;
6827 return 0;
6830 /* Possibly find a class imported by a single-type import statement. Return
6831 1 if an error occured, 0 otherwise. */
6833 static int
6834 find_in_imports (class_type)
6835 tree class_type;
6837 tree import;
6839 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
6840 if (TREE_VALUE (import) == TYPE_NAME (class_type))
6842 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
6843 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
6844 return check_pkg_class_access (TYPE_NAME (class_type),
6845 TREE_PURPOSE (import));
6847 return 0;
6850 /* Process a import on demand statement (lazy) */
6852 static int
6853 read_import_entry (jcf, dirp, returned_name)
6854 JCF *jcf;
6855 DIR *dirp;
6856 char **returned_name;
6858 if (dirp)
6860 struct dirent *direntp = readdir (dirp);
6861 if (!direntp)
6863 *returned_name = NULL;
6864 return 0;
6866 else
6868 *returned_name = direntp->d_name;
6869 return (strlen (direntp->d_name));
6872 else
6874 int current_dir_len = strlen (jcf->classname);
6875 char *current_entry;
6876 int current_entry_len;
6878 /* Here we read a zip directory as a file directory. The files
6879 we're selecting must have the same root than the directory
6880 we're examining. */
6882 ZipDirectory *zipd = (ZipDirectory *)jcf->zipd;
6884 while (zipd)
6886 current_entry = ZIPDIR_FILENAME (zipd);
6887 current_entry_len = zipd->filename_length;
6888 while (current_entry_len && current_entry [current_entry_len] != '/')
6889 current_entry_len--;
6890 /* If the path of the current file doesn't match the directory we're
6891 scanning, that the end of the search */
6892 current_entry_len++;
6893 if (strncmp (jcf->classname, current_entry, current_dir_len))
6895 *returned_name = NULL;
6896 return 0;
6898 /* Ok, we have at least the same path. The position of the last '/'
6899 of the current file we're examining should match the size of
6900 name of the directory we're browsing, otherwise that an entry
6901 belonging to a sub directory, we want to skip it. */
6902 if (current_entry_len != current_dir_len)
6903 zipd = ZIPDIR_NEXT (zipd);
6904 else
6906 jcf->zipd = ZIPDIR_NEXT (zipd); /* Prepare next read */
6907 *returned_name = &current_entry [current_entry_len];
6908 return (zipd->filename_length - current_entry_len);
6911 *returned_name = NULL;
6912 return 0;
6916 /* Read a import directory, gathering potential match for further type
6917 references. Indifferently reads a filesystem or a ZIP archive
6918 directory. */
6920 static void
6921 read_import_dir (wfl)
6922 tree wfl;
6924 char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
6925 int name_len = IDENTIFIER_LENGTH (EXPR_WFL_NODE (wfl)), reclen;
6926 DIR *dirp = NULL;
6927 JCF jcfr, *jcf, *saved_jcf = current_jcf;
6928 char *founddirname, *d_name;
6930 jcf = &jcfr;
6931 if (!(founddirname = find_class (name, name_len, jcf, 0)))
6932 fatal ("Can't import `%s'", name);
6933 if (jcf->outofsynch)
6934 jcf_out_of_synch (jcf);
6935 if (jcf->seen_in_zip)
6936 jcf->zipd = ZIPDIR_NEXT ((ZipDirectory *)jcf->zipd);
6938 else if (founddirname)
6939 dirp = opendir (founddirname);
6941 if (!founddirname && !dirp)
6943 static int first = 1;
6944 if (first)
6946 char buffer [256];
6947 sprintf (buffer, "Can't find default package `%s'. Check "
6948 "the CLASSPATH environment variable and the access to the "
6949 "archives.", name);
6950 error (buffer);
6951 java_error_count++;
6952 first = 0;
6954 else
6955 parse_error_context (wfl, "Package `%s' not found in import", name);
6956 current_jcf = saved_jcf;
6957 return;
6960 /* Here we should have a unified way of retrieving an entry, to be
6961 indexed. */
6962 while ((reclen = read_import_entry (jcf, dirp, &d_name)))
6964 int java_or_class = 0;
6965 int len;
6966 if ((reclen > 5)
6967 && !strcmp (&d_name [reclen-5], ".java"))
6969 java_or_class = 1;
6970 len = reclen - 5;
6973 if (!java_or_class && (reclen > 6) &&
6974 !strcmp (&d_name [reclen-6], ".class"))
6976 java_or_class = 2;
6977 len = reclen - 6;
6980 if (java_or_class)
6982 char *id_name;
6983 tree node;
6985 obstack_grow (&temporary_obstack, name, name_len);
6986 obstack_1grow (&temporary_obstack, '/');
6987 obstack_grow0 (&temporary_obstack, d_name, len);
6988 id_name = obstack_finish (&temporary_obstack);
6990 node = get_identifier (id_name);
6991 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
6992 QUALIFIED_P (node) = 1; /* As soon as we turn / into . */
6995 if (dirp)
6996 closedir (dirp);
6998 current_jcf = saved_jcf;
7001 /* Possibly find a type in the import on demands specified
7002 types. Returns 1 if an error occured, 0 otherwise. Run throught the
7003 entire list, to detected potential double definitions. */
7005 static int
7006 find_in_imports_on_demand (class_type)
7007 tree class_type;
7009 tree node, import, node_to_use;
7010 int seen_once = -1;
7011 tree cl;
7013 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
7015 char *id_name;
7016 obstack_grow (&temporary_obstack,
7017 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
7018 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7019 obstack_1grow (&temporary_obstack, '/');
7020 obstack_grow0 (&temporary_obstack,
7021 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7022 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
7023 id_name = obstack_finish (&temporary_obstack);
7025 node = maybe_get_identifier (id_name);
7026 if (node && IS_A_CLASSFILE_NAME (node))
7028 if (seen_once < 0)
7030 cl = TREE_PURPOSE (import);
7031 seen_once = 1;
7032 node_to_use = node;
7034 else
7036 seen_once++;
7037 parse_error_context
7038 (import, "Type `%s' also potentially defined in package `%s'",
7039 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7040 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7045 if (seen_once == 1)
7047 /* Setup lineno so that it refers to the line of the import (in
7048 case we parse a class file and encounter errors */
7049 tree decl;
7050 int saved_lineno = lineno;
7051 lineno = EXPR_WFL_LINENO (cl);
7052 TYPE_NAME (class_type) = ident_subst (IDENTIFIER_POINTER (node_to_use),
7053 IDENTIFIER_LENGTH (node_to_use),
7054 "", '/', '.', "");
7055 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7056 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
7057 /* If there is no DECL set for the class or if the class isn't
7058 loaded and not seen in source yet, the load */
7059 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
7060 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
7061 load_class (node_to_use, 0);
7062 lineno = saved_lineno;
7063 return check_pkg_class_access (TYPE_NAME (class_type), cl);
7065 else
7066 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
7069 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
7070 access violations were found, 1 otherwise. */
7072 static int
7073 check_pkg_class_access (class_name, cl)
7074 tree class_name;
7075 tree cl;
7077 tree type;
7079 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
7080 return 0;
7082 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
7083 return 0;
7085 if (!CLASS_PUBLIC (TYPE_NAME (type)))
7087 parse_error_context
7088 (cl, "Can't access %s `%s'. Only public classes and interfaces in "
7089 "other packages can be accessed",
7090 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
7091 IDENTIFIER_POINTER (class_name));
7092 return 1;
7094 return 0;
7097 /* Local variable declaration. */
7099 static void
7100 declare_local_variables (modifier, type, vlist)
7101 int modifier;
7102 tree type;
7103 tree vlist;
7105 tree decl, current, saved_type;
7106 tree type_wfl = NULL_TREE;
7107 int must_chain = 0;
7109 /* Push a new block if statement were seen between the last time we
7110 pushed a block and now. Keep a cound of block to close */
7111 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)))
7113 tree body = DECL_FUNCTION_BODY (current_function_decl);
7114 tree b = enter_block ();
7115 BLOCK_EXPR_ORIGIN(b) = body;
7118 if (modifier)
7120 int i;
7121 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
7122 parse_error_context
7123 (ctxp->modifier_ctx [i],
7124 (modifier == ACC_FINAL ?
7125 "Unsupported JDK1.1 `final' locals" :
7126 "Only `final' is allowed as a local variables modifier"));
7127 return;
7130 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
7131 hold the TYPE value if a new incomplete has to be created (as
7132 opposed to being found already existing and reused). */
7133 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7135 /* If TYPE is fully resolved and we don't have a reference, make one */
7136 if (!must_chain && TREE_CODE (type) == RECORD_TYPE)
7137 type = promote_type (type);
7139 /* Go through all the declared variables */
7140 for (current = vlist, saved_type = type; current;
7141 current = TREE_CHAIN (current), type = saved_type)
7143 tree other;
7144 tree wfl = TREE_PURPOSE (current);
7145 tree name = EXPR_WFL_NODE (wfl);
7146 tree init = TREE_VALUE (current);
7148 /* Process NAME, as it may specify extra dimension(s) for it */
7149 type = build_array_from_name (type, type_wfl, name, &name);
7151 /* Variable redefinition check */
7152 if ((other = lookup_name_in_blocks (name)))
7154 variable_redefinition_error (wfl, name, TREE_TYPE (other),
7155 DECL_SOURCE_LINE (other));
7156 continue;
7159 /* Type adjustment. We may have just readjusted TYPE because
7160 the variable specified more dimensions. Make sure we have
7161 a reference if we can and don't have one already. */
7162 if (type != saved_type && !must_chain
7163 && (TREE_CODE (type) == RECORD_TYPE))
7164 type = promote_type (type);
7166 /* Never layout this decl. This will be done when its scope
7167 will be entered */
7168 decl = build_decl_no_layout (VAR_DECL, name, type);
7169 BLOCK_CHAIN_DECL (decl);
7171 /* Don't try to use an INIT statement when an error was found */
7172 if (init && java_error_count)
7173 init = NULL_TREE;
7175 /* Add the initialization function to the current function's code */
7176 if (init)
7178 /* Name might have been readjusted */
7179 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
7180 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
7181 java_method_add_stmt (current_function_decl,
7182 build_debugable_stmt (EXPR_WFL_LINECOL (init),
7183 init));
7186 /* Setup dependency the type of the decl */
7187 if (must_chain)
7189 jdep *dep;
7190 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
7191 dep = CLASSD_LAST (ctxp->classd_list);
7192 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
7195 SOURCE_FRONTEND_DEBUG (("Defined locals"));
7198 /* Called during parsing. Build decls from argument list. */
7200 static void
7201 source_start_java_method (fndecl)
7202 tree fndecl;
7204 tree tem;
7205 tree parm_decl;
7206 int i;
7208 current_function_decl = fndecl;
7210 /* New scope for the function */
7211 enter_block ();
7212 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
7213 tem != NULL_TREE; tem = TREE_CHAIN (tem), i++)
7215 tree type = TREE_VALUE (tem);
7216 tree name = TREE_PURPOSE (tem);
7218 /* If type is incomplete. Layout can't take place
7219 now. Create an incomplete decl and ask for the decl to be
7220 patched later */
7221 if (INCOMPLETE_TYPE_P (type))
7223 jdep *jdep;
7224 parm_decl = build_decl_no_layout (PARM_DECL, name, type);
7226 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
7227 jdep = CLASSD_LAST (ctxp->classd_list);
7228 JDEP_MISC (jdep) = name;
7229 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
7231 else
7232 parm_decl = build_decl (PARM_DECL, name, type);
7234 BLOCK_CHAIN_DECL (parm_decl);
7236 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
7237 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
7238 nreverse (tem);
7239 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
7242 /* Called during expansion. Push decls formerly built from argument
7243 list so they're usable during expansion. */
7245 static void
7246 expand_start_java_method (fndecl)
7247 tree fndecl;
7249 tree tem, *ptr;
7251 current_function_decl = fndecl;
7253 announce_function (fndecl);
7254 pushlevel (1); /* Push parameters */
7255 ptr = &DECL_ARGUMENTS (fndecl);
7256 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
7257 while (tem)
7259 tree next = TREE_CHAIN (tem);
7260 tree type = TREE_TYPE (tem);
7261 #ifdef PROMOTE_PROTOTYPES
7262 if (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
7263 && INTEGRAL_TYPE_P (type))
7264 type = integer_type_node;
7265 #endif
7266 DECL_ARG_TYPE (tem) = type;
7267 layout_decl (tem, 0);
7268 pushdecl (tem);
7269 INITIALIZED_P (tem) = 1; /* Parms are initialized */
7270 *ptr = tem;
7271 ptr = &TREE_CHAIN (tem);
7272 tem = next;
7274 *ptr = NULL_TREE;
7275 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
7276 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
7277 complete_start_java_method (fndecl);
7280 /* Terminate a function and expand its body. */
7282 static void
7283 source_end_java_method ()
7285 tree fndecl = current_function_decl;
7287 java_parser_context_save_global ();
7288 lineno = ctxp->last_ccb_indent1;
7290 /* Set EH language codes */
7291 java_set_exception_lang_code ();
7293 /* Generate function's code */
7294 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
7295 && ! flag_emit_class_files)
7296 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
7298 /* pop out of its parameters */
7299 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
7300 poplevel (1, 0, 1);
7301 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
7303 /* Generate rtl for function exit. */
7304 if (! flag_emit_class_files)
7306 lineno = DECL_SOURCE_LINE_LAST (fndecl);
7307 /* Emit catch-finally clauses */
7308 emit_handlers ();
7309 expand_function_end (input_filename, lineno, 0);
7311 /* Run the optimizers and output assembler code for this function. */
7312 rest_of_compilation (fndecl);
7315 current_function_decl = NULL_TREE;
7316 /* permanent_allocation (1); */
7317 java_parser_context_restore_global ();
7320 /* Record EXPR in the current function block. Complements compound
7321 expression second operand if necessary. */
7323 tree
7324 java_method_add_stmt (fndecl, expr)
7325 tree fndecl, expr;
7327 return add_stmt_to_block (DECL_FUNCTION_BODY (fndecl), NULL_TREE, expr);
7330 static tree
7331 add_stmt_to_block (b, type, stmt)
7332 tree b, type, stmt;
7334 tree body = BLOCK_EXPR_BODY (b), c;
7336 if (java_error_count)
7337 return body;
7339 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
7340 return body;
7342 BLOCK_EXPR_BODY (b) = c;
7343 TREE_SIDE_EFFECTS (c) = 1;
7344 return c;
7347 /* Add STMT to EXISTING if possible, otherwise create a new
7348 COMPOUND_EXPR and add STMT to it. */
7350 static tree
7351 add_stmt_to_compound (existing, type, stmt)
7352 tree existing, type, stmt;
7354 tree node;
7356 if (existing && (TREE_CODE (existing) == COMPOUND_EXPR)
7357 && TREE_OPERAND (existing, 1) == size_zero_node)
7359 TREE_OPERAND (existing, 1) = stmt;
7360 TREE_TYPE (existing) = type;
7361 return existing;
7363 else if (existing)
7364 node = build (COMPOUND_EXPR, type, existing, stmt);
7365 else
7366 node = build (COMPOUND_EXPR, type, stmt, size_zero_node);
7368 return node;
7371 /* Hold THIS for the scope of the current public method decl. */
7372 static tree current_this;
7374 /* Layout all class found during parsing */
7376 void
7377 java_layout_classes ()
7379 tree current;
7380 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7382 current_class = TREE_TYPE (current);
7383 TYPE_FIELDS (current_class) = nreverse (TYPE_FIELDS (current_class));
7384 if (!TYPE_SIZE (current_class))
7385 safe_layout_class (current_class);
7389 /* Expand all methods in all registered classes. */
7391 void
7392 java_complete_expand_methods ()
7394 tree current;
7396 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7398 tree class_type = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current));
7399 tree decl;
7401 current_class = TREE_TYPE (current);
7403 /* Initialize a new constant pool */
7404 init_outgoing_cpool ();
7406 /* Don't process function bodies in interfaces */
7407 if (!CLASS_INTERFACE (TYPE_NAME (current_class)))
7408 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7410 current_function_decl = decl;
7411 /* Don't generate debug info on line zero when expanding a
7412 generated constructor. */
7413 if (DECL_CONSTRUCTOR_P (decl) && !DECL_FUNCTION_BODY (decl))
7415 /* If we found errors, it's too dangerous to try to generate
7416 and expand a constructor */
7417 if (!java_error_count)
7419 restore_line_number_status (1);
7420 java_complete_expand_method (decl);
7421 restore_line_number_status (0);
7424 else
7425 java_complete_expand_method (decl);
7428 /* Make the class data, register it and run the rest of decl
7429 compilation on it */
7430 if (!java_error_count && ! flag_emit_class_files)
7432 make_class_data (current_class);
7433 register_class ();
7434 rest_of_decl_compilation (TYPE_NAME (current_class),
7435 (char*) 0, 1, 0);
7440 /* Hold a list of catch clauses list. The first element of this list is
7441 the list of the catch clauses of the currently analysed try block. */
7442 static tree currently_caught_type_list;
7444 /* Complete and expand a method. */
7446 static void
7447 java_complete_expand_method (mdecl)
7448 tree mdecl;
7450 int no_ac_found = 1;
7452 /* We generate some code for an empty constructor */
7453 if (DECL_CONSTRUCTOR_P (mdecl) && !DECL_FUNCTION_BODY (mdecl))
7455 tree arg_list, func, call;
7456 tree method_type = TREE_TYPE (mdecl);
7457 tree class_type = CLASS_TO_HANDLE_TYPE (current_class);
7458 tree self_type = (CLASSTYPE_SUPER (class_type) ?
7459 CLASSTYPE_SUPER (class_type) : class_type);
7460 tree method_signature =
7461 TYPE_LANG_SPECIFIC (method_type)->signature;
7462 tree method =
7463 lookup_java_constructor (CLASS_TO_HANDLE_TYPE (self_type),
7464 method_signature);
7465 tree block, compound;
7467 /* Fixe the begining/ending lines of the method so that with
7468 no_line_numbers set to 1 it doesn't generate debug info at
7469 line 1 for this artificial constructor. */
7470 DECL_SOURCE_LINE (mdecl) = 1;
7471 DECL_SOURCE_LINE_MERGE (mdecl, 1);
7472 source_start_java_method (mdecl);
7473 arg_list = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl));
7474 enter_block ();
7475 func = build_known_method_ref (method, method_type, self_type,
7476 method_signature, arg_list);
7478 if (! flag_emit_class_files)
7479 func = build1 (NOP_EXPR, build_pointer_type (method_type), func);
7480 call = build (CALL_EXPR, TREE_TYPE (method_type), func,
7481 build_tree_list (NULL_TREE, arg_list), NULL_TREE);
7482 TREE_SIDE_EFFECTS (call) = 1;
7483 call = build_class_init (self_type, call);
7484 compound = java_method_add_stmt (mdecl, call);
7485 block = exit_block ();
7486 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = block;
7487 /* The function decl, its block and the compound statement
7488 within this block are all of void type. */
7489 TREE_TYPE (block) = TREE_TYPE (compound) =
7490 TREE_TYPE (DECL_FUNCTION_BODY (mdecl)) = void_type_node;
7491 exit_block ();
7492 no_ac_found = 0;
7495 if (DECL_FUNCTION_BODY (mdecl))
7497 expand_start_java_method (mdecl);
7499 current_this
7500 = (!METHOD_STATIC (mdecl) ?
7501 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
7503 /* Purge the `throws' list of unchecked exceptions */
7504 purge_unchecked_exceptions (mdecl);
7506 /* Install exceptions thrown with `throws' */
7507 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
7509 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) && no_ac_found)
7510 java_complete_tree (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)));
7511 /* Don't go any further if we've found error(s) during the
7512 expansion */
7513 if (!java_error_count)
7514 source_end_java_method ();
7516 /* Pop the exceptions and sanity check */
7517 POP_EXCEPTIONS();
7518 if (currently_caught_type_list)
7519 fatal ("Exception list non empty - java_complete_expand_method");
7523 /* Expand finals. */
7525 void
7526 java_expand_finals ()
7530 /* Generate code for all context remembered for code generation */
7532 void
7533 java_expand_classes ()
7535 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
7537 ctxp = ctxp_for_generation;
7538 lang_init_source (2); /* Error msgs have method prototypes */
7539 java_complete_expand_methods (); /* Complete and expand method bodies */
7540 java_parse_abort_on_error ();
7541 java_expand_finals (); /* Expand and check the finals */
7542 java_parse_abort_on_error ();
7543 java_check_final (); /* Check unitialized final */
7544 java_parse_abort_on_error ();
7548 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
7549 a tree list node containing RIGHT. Fore coming RIGHTs will be
7550 chained to this hook. LOCATION contains the location of the
7551 separating `.' operator. */
7553 static tree
7554 make_qualified_primary (primary, right, location)
7555 tree primary, right;
7556 int location;
7558 tree wfl;
7560 /* We want to process THIS . xxx symbolicaly, to keep it consistent
7561 with the way we're processing SUPER. A THIS from a primary as a
7562 different form than a SUPER. Turn THIS into something symbolic */
7563 if (TREE_CODE (primary) == THIS_EXPR)
7565 wfl = build_wfl_node (this_identifier_node, input_filename, 0, 0);
7566 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
7567 wfl = make_qualified_name (wfl, right, location);
7568 PRIMARY_P (wfl) = 1;
7569 return wfl;
7571 /* Other non WFL node are wrapped around a WFL */
7572 else if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
7574 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
7575 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
7576 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (primary, NULL_TREE);
7578 else
7580 wfl = primary;
7581 if (!EXPR_WFL_QUALIFICATION (primary))
7582 EXPR_WFL_QUALIFICATION (primary) =
7583 build_tree_list (primary, NULL_TREE);
7586 EXPR_WFL_LINECOL (right) = location;
7587 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
7588 PRIMARY_P (wfl) = 1;
7589 return wfl;
7592 /* Simple merge of two name separated by a `.' */
7594 static tree
7595 merge_qualified_name (left, right)
7596 tree left, right;
7598 tree node;
7599 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
7600 IDENTIFIER_LENGTH (left));
7601 obstack_1grow (&temporary_obstack, '.');
7602 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
7603 IDENTIFIER_LENGTH (right));
7604 node = get_identifier (obstack_base (&temporary_obstack));
7605 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
7606 QUALIFIED_P (node) = 1;
7607 return node;
7610 /* Merge the two parts of a qualified name into LEFT. Set the
7611 location information of the resulting node to LOCATION, usually
7612 inherited from the location information of the `.' operator. */
7614 static tree
7615 make_qualified_name (left, right, location)
7616 tree left, right;
7617 int location;
7619 tree left_id = EXPR_WFL_NODE (left);
7620 tree right_id = EXPR_WFL_NODE (right);
7621 tree wfl, merge;
7623 merge = merge_qualified_name (left_id, right_id);
7625 /* Left wasn't qualified and is now qualified */
7626 if (!QUALIFIED_P (left_id))
7628 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
7629 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
7630 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
7633 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
7634 EXPR_WFL_LINECOL (wfl) = location;
7635 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
7637 EXPR_WFL_NODE (left) = merge;
7638 return left;
7641 /* Extract the last identifier component of the qualified in WFL. The
7642 last identifier is removed from the linked list */
7644 static tree
7645 cut_identifier_in_qualified (wfl)
7646 tree wfl;
7648 tree q;
7649 tree previous = NULL_TREE;
7650 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
7651 if (!TREE_CHAIN (q))
7653 if (!previous)
7654 fatal ("Operating on a non qualified qualified WFL - "
7655 "cut_identifier_in_qualified");
7656 TREE_CHAIN (previous) = NULL_TREE;
7657 return TREE_PURPOSE (q);
7661 /* Resolve the expression name NAME. Return its decl. */
7663 static tree
7664 resolve_expression_name (id)
7665 tree id;
7667 tree name = EXPR_WFL_NODE (id);
7668 tree decl;
7670 /* 6.5.5.1: Simple expression names */
7671 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
7673 /* 15.13.1: NAME can appear within the scope of a local variable
7674 declaration */
7675 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
7676 return decl;
7678 /* 15.13.1: NAME can appear within a class declaration */
7679 else
7681 decl = lookup_field_wrapper (current_class, name);
7682 if (decl)
7684 int fs = FIELD_STATIC (decl);
7685 /* Instance variable (8.3.1.1) can't appear within
7686 static method, static initializer or initializer for
7687 a static variable. */
7688 if (!fs && METHOD_STATIC (current_function_decl))
7690 parse_error_context
7691 (id, "Can't make a static reference to nonstatic variable "
7692 "`%s' in class `%s'",
7693 IDENTIFIER_POINTER (name),
7694 IDENTIFIER_POINTER (DECL_NAME
7695 (TYPE_NAME (current_class))));
7696 return error_mark_node;
7698 decl = build_field_ref ((fs ? NULL_TREE : current_this),
7699 current_class, name);
7700 return (fs ? build_class_init (current_class, decl) : decl);
7702 /* Fall down to error report on undefined variable */
7705 /* 6.5.5.2 Qualified Expression Names */
7706 else
7708 qualify_ambiguous_name (id);
7709 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
7710 /* 15.10.2: Accessing Superclass Members using super */
7711 return resolve_field_access (id, NULL, NULL);
7714 /* We've got an error here */
7715 parse_error_context (id, "Undefined variable `%s'",
7716 IDENTIFIER_POINTER (name));
7718 return error_mark_node;
7721 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
7722 We return something suitable to generate the field access. We also
7723 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
7724 recipient's address can be null. */
7726 static tree
7727 resolve_field_access (qual_wfl, field_decl, field_type)
7728 tree qual_wfl;
7729 tree *field_decl, *field_type;
7731 int is_static = 0;
7732 tree field_ref;
7733 tree decl, where_found, type_found;
7735 if (resolve_qualified_expression_name (qual_wfl, &decl,
7736 &where_found, &type_found))
7737 return error_mark_node;
7739 /* Resolve the LENGTH field of an array here */
7740 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
7741 && ! flag_emit_class_files)
7743 tree length = build_java_array_length_access (where_found);
7744 field_ref =
7745 build_java_arraynull_check (type_found, length, int_type_node);
7747 /* We might have been trying to resolve field.method(). In which
7748 case, the resolution is over and decl is the answer */
7749 else if (DECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
7750 field_ref = decl;
7751 else if (DECL_P (decl))
7753 is_static = DECL_P (decl) && FIELD_STATIC (decl);
7754 field_ref = build_field_ref ((is_static ? NULL_TREE : where_found),
7755 type_found, DECL_NAME (decl));
7756 if (field_ref == error_mark_node)
7757 return error_mark_node;
7758 if (is_static)
7760 field_ref = build_class_init (type_found, field_ref);
7761 /* If the static field was identified by an expression that
7762 needs to be generated, make the field access a compound
7763 expression whose first part of the evaluation of the
7764 field selector part. */
7765 if (where_found && TREE_CODE (where_found) != TYPE_DECL)
7767 tree type = QUAL_DECL_TYPE (field_ref);
7768 field_ref = build (COMPOUND_EXPR, type, where_found, field_ref);
7772 else
7773 field_ref = decl;
7775 if (field_decl)
7776 *field_decl = decl;
7777 if (field_type)
7778 *field_type = QUAL_DECL_TYPE (decl);
7779 return field_ref;
7782 /* 6.5.5.2: Qualified Expression Names */
7784 static int
7785 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
7786 tree wfl;
7787 tree *found_decl, *type_found, *where_found;
7789 int from_type = 0; /* Field search initiated from a type */
7790 int from_super = 0, from_cast = 0;
7791 int previous_call_static = 0;
7792 int is_static;
7793 tree decl = NULL_TREE, type = NULL_TREE, q;
7794 *where_found = NULL_TREE;
7796 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
7798 tree qual_wfl = QUAL_WFL (q);
7800 /* 15.10.1 Field Access Using a Primary */
7802 switch (TREE_CODE (qual_wfl))
7804 case CALL_EXPR:
7805 case NEW_CLASS_EXPR:
7806 /* If the access to the function call is a non static field,
7807 build the code to access it. */
7808 if (DECL_P (decl) && !FIELD_STATIC (decl))
7810 decl = maybe_access_field (decl, *where_found, type);
7811 if (decl == error_mark_node)
7812 return 1;
7814 /* And code for the function call */
7815 if (complete_function_arguments (qual_wfl))
7816 return 1;
7817 *where_found =
7818 patch_method_invocation_stmt (qual_wfl, decl, type,
7819 &is_static, NULL);
7820 if (*where_found == error_mark_node)
7821 return 1;
7822 *type_found = type = QUAL_DECL_TYPE (*where_found);
7824 /* If the previous call was static and this one is too,
7825 build a compound expression to hold the two (because in
7826 that case, previous function calls aren't transported as
7827 forcoming function's argument. */
7828 if (previous_call_static && is_static)
7830 decl = build (COMPOUND_EXPR, type, decl, *where_found);
7831 TREE_SIDE_EFFECTS (decl) = 1;
7833 else
7835 previous_call_static = is_static;
7836 decl = *where_found;
7838 continue;
7840 case CONVERT_EXPR:
7841 *where_found = decl = java_complete_tree (qual_wfl);
7842 if (decl == error_mark_node)
7843 return 1;
7844 *type_found = type = QUAL_DECL_TYPE (decl);
7845 from_cast = 1;
7846 continue;
7848 case ARRAY_REF:
7849 /* If the access to the function call is a non static field,
7850 build the code to access it. */
7851 if (DECL_P (decl) && !FIELD_STATIC (decl))
7853 decl = maybe_access_field (decl, *where_found, type);
7854 if (decl == error_mark_node)
7855 return 1;
7857 /* And code for the array reference expression */
7858 decl = java_complete_tree (qual_wfl);
7859 if (decl == error_mark_node)
7860 return 1;
7861 type = QUAL_DECL_TYPE (decl);
7862 continue;
7864 default:
7865 /* Fix for -Wall Just go to the next statement. Don't
7866 continue */
7869 /* If we fall here, we weren't processing a (static) function call. */
7870 previous_call_static = 0;
7872 /* It can be the keyword THIS */
7873 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
7875 if (!current_this)
7877 parse_error_context
7878 (wfl, "Keyword `this' used outside allowed context");
7879 return 1;
7881 /* We have to generate code for intermediate acess */
7882 *where_found = decl = current_this;
7883 type = QUAL_DECL_TYPE (decl);
7884 continue;
7887 /* 15.10.2 Accessing Superclass Members using SUPER */
7888 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
7890 tree node;
7891 /* Check on the restricted use of SUPER */
7892 if (METHOD_STATIC (current_function_decl)
7893 || current_class == object_type_node)
7895 parse_error_context
7896 (wfl, "Keyword `super' used outside allowed context");
7897 return 1;
7899 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
7900 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
7901 CLASSTYPE_SUPER (current_class),
7902 build_this (EXPR_WFL_LINECOL (qual_wfl)));
7903 *where_found = decl = java_complete_tree (node);
7904 *type_found = type = QUAL_DECL_TYPE (decl);
7905 from_super = from_type = 1;
7906 continue;
7909 /* 15.13.1: Can't search for field name in packages, so we
7910 assume a variable/class name was meant. */
7911 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
7913 if (from_super || from_cast)
7914 parse_error_context
7915 ((from_cast ? qual_wfl : wfl),
7916 "No variable `%s' defined in class `%s'",
7917 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
7918 lang_printable_name (type, 0));
7919 else
7920 parse_error_context
7921 (qual_wfl, "Undefined variable or class name: `%s'",
7922 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
7923 return 1;
7926 /* We have a type name. It's been already resolved when the
7927 expression was qualified. */
7928 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
7930 if (!(decl = QUAL_RESOLUTION (q)))
7931 return 1; /* Error reported already */
7933 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
7935 parse_error_context
7936 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
7937 java_accstring_lookup (get_access_flags_from_decl (decl)),
7938 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
7939 IDENTIFIER_POINTER (DECL_NAME (decl)),
7940 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
7941 return 1;
7944 type = TREE_TYPE (decl);
7945 from_type = 1;
7947 /* We resolve and expression name */
7948 else
7950 tree field_decl;
7952 /* If there exists an early resolution, use it. That occurs
7953 only once and we know that there are more things to
7954 come. Don't do that when processing something after SUPER
7955 (we need more thing to be put in place below */
7956 if (!from_super && QUAL_RESOLUTION (q))
7958 decl = QUAL_RESOLUTION (q);
7959 *type_found = type;
7962 /* We have to search for a field, knowing the type of its
7963 container. The flag FROM_TYPE indicates that we resolved
7964 the last member of the expression as a type name, which
7965 means that for the resolution of this field, will check
7966 on other errors than if the it was resolved as a member
7967 of an other field. */
7968 else
7970 int is_static;
7971 if (!from_type && !JREFERENCE_TYPE_P (type))
7973 parse_error_context
7974 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
7975 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
7976 lang_printable_name (type, 0),
7977 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
7978 return 1;
7981 if (!(field_decl =
7982 lookup_field_wrapper (type, EXPR_WFL_NODE (qual_wfl))))
7984 parse_error_context
7985 (qual_wfl, "No variable `%s' defined in class `%s'",
7986 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
7987 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
7988 return 1;
7991 /* Check on accessibility here */
7992 if (not_accessible_p (type, field_decl, from_super))
7994 parse_error_context
7995 (qual_wfl,
7996 "Can't access %s field `%s.%s' from `%s'",
7997 java_accstring_lookup
7998 (get_access_flags_from_decl (field_decl)),
7999 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
8000 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
8001 IDENTIFIER_POINTER
8002 (DECL_NAME (TYPE_NAME (current_class))));
8003 return 1;
8006 /* There are things to check when fields are accessed
8007 from type. There are no restrictions on a static
8008 declaration of the field when it is accessed from an
8009 interface */
8010 is_static = FIELD_STATIC (field_decl);
8011 if (!from_super && from_type
8012 && !TYPE_INTERFACE_P (type) && !is_static)
8014 parse_error_context
8015 (qual_wfl, "Can't make a static reference to nonstatic "
8016 "variable `%s' in class `%s'",
8017 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
8018 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
8019 return 1;
8021 from_cast = from_super = 0;
8023 /* If we need to generate something to get a proper handle
8024 on what this field is accessed from, do it now. */
8025 if (!is_static)
8027 decl = maybe_access_field (decl, *where_found, *type_found);
8028 if (decl == error_mark_node)
8029 return 1;
8032 /* We want to keep the location were found it, and the type
8033 we found. */
8034 *where_found = decl;
8035 *type_found = type;
8037 /* This is the decl found and eventually the next one to
8038 search from */
8039 decl = field_decl;
8041 from_type = 0;
8042 type = QUAL_DECL_TYPE (decl);
8045 *found_decl = decl;
8046 return 0;
8049 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
8050 can't be accessed from REFERENCE (a record type). */
8052 int not_accessible_p (reference, member, from_super)
8053 tree reference, member;
8054 int from_super;
8056 int access_flag = get_access_flags_from_decl (member);
8058 /* Access always granted for members declared public */
8059 if (access_flag & ACC_PUBLIC)
8060 return 0;
8062 /* Check access on protected members */
8063 if (access_flag & ACC_PROTECTED)
8065 /* Access granted if it occurs from within the package
8066 containing the class in which the protected member is
8067 declared */
8068 if (class_in_current_package (DECL_CONTEXT (member)))
8069 return 0;
8071 if (TREE_CODE (member) == FUNCTION_DECL && DECL_CONSTRUCTOR_P (member))
8073 /* Access from SUPER is granted */
8074 if (from_super)
8075 return 0;
8076 /* Otherwise, access isn't granted */
8077 return 1;
8079 else
8081 /* If accessed with the form `super.member', then access is
8082 granted */
8083 if (from_super)
8084 return 0;
8086 /* Otherwise, access is granted if occuring from the class where
8087 member is declared or a subclass of it */
8088 if (inherits_from_p (reference, current_class))
8089 return 0;
8091 return 1;
8094 /* Check access on private members. Access is granted only if it
8095 occurs from within the class in witch it is declared*/
8097 if (access_flag & ACC_PRIVATE)
8098 return (current_class == DECL_CONTEXT (member) ? 0 : 1);
8100 /* Default access are permitted only when occuring within the
8101 package in which the type (REFERENCE) is declared. In other words,
8102 REFERENCE is defined in the current package */
8103 if (ctxp->package)
8104 return !class_in_current_package (reference);
8106 /* Otherwise, access is granted */
8107 return 0;
8110 /* Returns 1 if class was declared in the current package, 0 otherwise */
8112 static int
8113 class_in_current_package (class)
8114 tree class;
8116 static tree cache = NULL_TREE;
8117 int qualified_flag;
8118 tree left;
8120 if (cache == class)
8121 return 1;
8123 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
8125 /* If the current package is empty and the name of CLASS is
8126 qualified, class isn't in the current package. If there is a
8127 current package and the name of the CLASS is not qualified, class
8128 isn't in the current package */
8129 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
8130 return 0;
8132 /* If there is not package and the name of CLASS isn't qualified,
8133 they belong to the same unnamed package */
8134 if (!ctxp->package && !qualified_flag)
8135 return 1;
8137 /* Compare the left part of the name of CLASS with the package name */
8138 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
8139 if (ctxp->package == left)
8141 cache = class;
8142 return 1;
8144 return 0;
8147 /* This function may generate code to access DECL from WHERE. This is
8148 done only if certain conditions meet. */
8150 static tree
8151 maybe_access_field (decl, where, type)
8152 tree decl, where, type;
8154 if (DECL_P (decl) && decl != current_this
8155 && (!(TREE_CODE (decl) != PARM_DECL
8156 && FIELD_STATIC (decl)))
8157 && !IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)))
8158 decl = build_field_ref (where ? where : current_this,
8159 (type ? type : DECL_CONTEXT (decl)),
8160 DECL_NAME (decl));
8161 return decl;
8164 /* Build a method invocation statement, by patching PATCH. If non NULL
8165 and according to the situation, PRIMARY and WHERE may be
8166 used. IS_STATIC is set to 1 if the invoked function is static. */
8168 static tree
8169 patch_method_invocation_stmt (patch, primary, where, is_static, ret_decl)
8170 tree patch, primary, where;
8171 int *is_static;
8172 tree *ret_decl;
8174 tree wfl = TREE_OPERAND (patch, 0);
8175 tree args = TREE_OPERAND (patch, 1);
8176 tree name = EXPR_WFL_NODE (wfl);
8177 tree list, class_type;
8179 /* Should be overriden if everything goes well. Otherwise, if
8180 something fails, it should keep this value. It stop the
8181 evaluation of a bogus assignment. See java_complete_tree,
8182 MODIFY_EXPR: for the reasons why we sometimes want to keep on
8183 evaluating an assignment */
8184 TREE_TYPE (patch) = error_mark_node;
8186 /* Since lookup functions are messing with line numbers, save the
8187 context now. */
8188 java_parser_context_save_global ();
8190 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
8192 /* Resolution of qualified name, excluding constructors */
8193 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
8195 tree class_decl, identifier, identifier_wfl;
8196 /* Extract the last IDENTIFIER of the qualified
8197 expression. This is a wfl and we will use it's location
8198 data during error report. */
8199 identifier_wfl = cut_identifier_in_qualified (wfl);
8200 identifier = EXPR_WFL_NODE (identifier_wfl);
8202 /* Given the context, IDENTIFIER is syntactically qualified
8203 as a MethodName. We need to qualify what's before */
8204 qualify_ambiguous_name (wfl);
8206 /* Package resolution are erroneous */
8207 if (RESOLVE_PACKAGE_NAME_P (wfl))
8209 tree remainder;
8210 breakdown_qualified (&remainder, NULL, EXPR_WFL_NODE (wfl));
8211 parse_error_context (wfl, "Can't search method `%s' in package "
8212 "`%s'",IDENTIFIER_POINTER (identifier),
8213 IDENTIFIER_POINTER (remainder));
8214 PATCH_METHOD_RETURN_ERROR ();
8216 /* We're resolving a call from a type */
8217 else if (RESOLVE_TYPE_NAME_P (wfl))
8219 tree decl = QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl));
8220 tree name = DECL_NAME (decl);
8221 tree type;
8223 class_decl = resolve_and_layout (name, wfl);
8224 if (CLASS_INTERFACE (decl))
8226 parse_error_context
8227 (identifier_wfl, "Can't make static reference to method "
8228 "`%s' in interface `%s'", IDENTIFIER_POINTER (identifier),
8229 IDENTIFIER_POINTER (name));
8230 PATCH_METHOD_RETURN_ERROR ();
8232 /* Look the method up in the type selector. The method ought
8233 to be static. */
8234 type = TREE_TYPE (class_decl);
8235 list = lookup_method_invoke (0, wfl, type, identifier, args);
8236 if (list && !METHOD_STATIC (list))
8238 char *fct_name = strdup (lang_printable_name (list, 0));
8239 parse_error_context
8240 (identifier_wfl,
8241 "Can't make static reference to method `%s %s' in class `%s'",
8242 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
8243 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
8244 free (fct_name);
8245 PATCH_METHOD_RETURN_ERROR ();
8248 /* We're resolving an expression name */
8249 else
8251 tree field, type;
8253 /* 1- Find the field to which the call applies */
8254 field = resolve_field_access (wfl, NULL, &type);
8255 if (field == error_mark_node)
8256 PATCH_METHOD_RETURN_ERROR ();
8258 /* 2- Do the layout of the class where the last field
8259 was found, so we can search it. */
8260 class_decl =
8261 resolve_and_layout (DECL_NAME (TYPE_NAME (type)), NULL_TREE);
8263 /* 3- Retrieve a filtered list of method matches, Refine
8264 if necessary. In any cases, point out errors. */
8265 list = lookup_method_invoke (0, identifier_wfl, type,
8266 identifier, args);
8268 /* 4- Add the field as an argument */
8269 args = tree_cons (NULL_TREE, field, nreverse (args));
8272 /* CLASS_TYPE is used during the call to not_accessible_p and
8273 IDENTIFIER_WFL will be used to report any problem further */
8274 class_type = TREE_TYPE (class_decl);
8275 wfl = identifier_wfl;
8277 /* Resolution of simple names, names generated after a primary: or
8278 constructors */
8279 else
8281 tree class_to_search;
8282 int lc; /* Looking for Constructor */
8284 /* We search constructor in their target class */
8285 if (CALL_CONSTRUCTOR_P (patch))
8287 class_to_search = resolve_no_layout (EXPR_WFL_NODE (wfl), NULL_TREE);
8288 if (!class_to_search)
8290 parse_error_context
8291 (wfl, "Class `%s' not found in type declaration",
8292 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
8293 PATCH_METHOD_RETURN_ERROR ();
8296 /* Can't instantiate an abstract class */
8297 if (CLASS_ABSTRACT (class_to_search))
8299 parse_error_context
8300 (wfl, "Class `%s' is an abstract class. It can't be "
8301 "instantiated", IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
8302 PATCH_METHOD_RETURN_ERROR ();
8304 class_to_search = TREE_TYPE (class_to_search);
8305 lc = 1;
8307 /* This is a regular search in the local class, unless an
8308 alternate class is specified. */
8309 else
8311 class_to_search = (where ? where : current_class);
8312 lc = 0;
8315 /* NAME is a simple identifier or comes from a primary. Search
8316 in the class whose declaration contain the method being
8317 invoked. */
8318 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
8320 /* Don't continue if no method were found, as the next statement
8321 can't be executed then. */
8322 if (!list)
8323 PATCH_METHOD_RETURN_ERROR ();
8325 /* Check for static reference if non static methods */
8326 if (check_for_static_method_reference (wfl, patch, list,
8327 class_to_search, primary))
8328 PATCH_METHOD_RETURN_ERROR ();
8330 /* Non static/constructor methods are called with the current
8331 object extra argument. If method is resolved as a primary,
8332 use the primary otherwise use the current THIS. */
8333 args = nreverse (args);
8334 if (!CALL_CONSTRUCTOR_P (patch) && !METHOD_STATIC (list))
8335 args = tree_cons (NULL_TREE, primary ? primary : current_this, args);
8337 class_type = class_to_search;
8340 /* Merge point of all resolution schemes. If we have nothing, this
8341 is an error, already signaled */
8342 if (!list)
8343 PATCH_METHOD_RETURN_ERROR ();
8345 /* Check accessibility, position the is_static flag, build and
8346 return the call */
8347 if (not_accessible_p (class_type, list, 0))
8349 char *fct_name = strdup (lang_printable_name (list, 0));
8350 parse_error_context
8351 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
8352 java_accstring_lookup (get_access_flags_from_decl (list)),
8353 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
8354 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))), fct_name,
8355 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
8356 free (fct_name);
8357 PATCH_METHOD_RETURN_ERROR ();
8360 if (is_static)
8361 *is_static = METHOD_STATIC (list);
8362 java_parser_context_restore_global ();
8363 /* Sometimes, we want the decl of the selected method. Such as for
8364 EH checking */
8365 if (ret_decl)
8366 *ret_decl = list;
8367 return patch_invoke (patch, list, args);
8370 /* Check that we're not trying to do a static reference to a method in
8371 non static method. Return 1 if it's the case, 0 otherwise. */
8373 static int
8374 check_for_static_method_reference (wfl, node, method, where, primary)
8375 tree wfl, node, method, where, primary;
8377 if (METHOD_STATIC (current_function_decl)
8378 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
8380 char *fct_name = strdup (lang_printable_name (method, 0));
8381 parse_error_context
8382 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
8383 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
8384 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
8385 free (fct_name);
8386 return 1;
8388 return 0;
8391 /* Patch an invoke expression METHOD and ARGS, based on its invocation
8392 mode. */
8394 static tree
8395 patch_invoke (patch, method, args)
8396 tree patch, method, args;
8398 int im;
8399 tree dtable, func;
8400 tree signature = build_java_signature (TREE_TYPE (method));
8401 tree original_call, t, ta;
8403 /* Last step for args: convert build-in types */
8404 for (t = TYPE_ARG_TYPES (TREE_TYPE (method)),
8405 ta = args; t && ta; t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
8406 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
8407 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
8408 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
8410 switch ((im = invocation_mode (method, 0)))
8412 case INVOKE_VIRTUAL:
8413 dtable = invoke_build_dtable (0, args);
8414 func = build_invokevirtual (dtable, method);
8415 break;
8417 case INVOKE_STATIC:
8418 func = build_known_method_ref (method, TREE_TYPE (method),
8419 DECL_CONTEXT (method), signature, args);
8420 break;
8422 default:
8423 fatal ("Unknown invocation mode - build_invoke");
8424 return NULL_TREE;
8427 /* Ensure self_type is initialized, (invokestatic). FIXME */
8428 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
8429 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
8430 TREE_OPERAND (patch, 0) = func;
8431 TREE_OPERAND (patch, 1) = args;
8432 original_call = patch;
8434 /* We're calling a constructor. New is called an its returned value
8435 is an argument to the constructor. We build a COMPOUND_EXPR and
8436 use saved expression so that the overall NEW expression value is
8437 a pointer to a newly created and initialized class. */
8438 if (CALL_CONSTRUCTOR_P (original_call))
8440 tree class = DECL_CONTEXT (method);
8441 tree c1, saved_new, size, new;
8442 if (!TYPE_SIZE (class))
8443 safe_layout_class (class);
8444 size = size_in_bytes (class);
8445 new = build (CALL_EXPR, promote_type (class),
8446 build_address_of (alloc_object_node),
8447 tree_cons (NULL_TREE, build_class_ref (class),
8448 build_tree_list (NULL_TREE,
8449 size_in_bytes (class))),
8450 NULL_TREE);
8451 saved_new = save_expr (new);
8452 c1 = build_tree_list (NULL_TREE, saved_new);
8453 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
8454 TREE_OPERAND (original_call, 1) = c1;
8455 TREE_SET_CODE (original_call, CALL_EXPR);
8456 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
8458 return patch;
8461 static int
8462 invocation_mode (method, super)
8463 tree method;
8464 int super;
8466 int access = get_access_flags_from_decl (method);
8468 if (access & ACC_STATIC || access & ACC_FINAL)
8469 return INVOKE_STATIC;
8471 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
8472 return INVOKE_STATIC;
8474 if (super)
8475 return INVOKE_SUPER;
8477 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
8478 return INVOKE_INTERFACE;
8480 if (DECL_CONSTRUCTOR_P (method))
8481 return INVOKE_STATIC;
8483 return INVOKE_VIRTUAL;
8486 /* Retrieve a refined list of matching methods. It covers the step
8487 15.11.2 (Compile-Time Step 2) */
8489 static tree
8490 lookup_method_invoke (lc, cl, class, name, arg_list)
8491 int lc;
8492 tree cl;
8493 tree class, name, arg_list;
8495 tree method = make_node (FUNCTION_TYPE);
8496 tree arg_type_list = NULL_TREE;
8497 tree signature, list, node;
8498 char *candidates; /* Used for error report */
8500 for (node = arg_list; node; node = TREE_CHAIN (node))
8502 tree current_arg = TREE_TYPE (TREE_VALUE (node));
8503 if (TREE_CODE (current_arg) == RECORD_TYPE)
8504 current_arg = promote_type (current_arg);
8505 arg_type_list = tree_cons (NULL_TREE, current_arg, arg_type_list);
8507 TYPE_ARG_TYPES (method) = arg_type_list;
8509 if (!lc)
8511 list = find_applicable_accessible_methods_list (class, name,
8512 arg_type_list);
8513 list = find_most_specific_methods_list (list);
8515 else
8517 TREE_TYPE (method) = void_type_node;
8518 signature = build_java_signature (method);
8519 list = lookup_java_constructor (class, signature);
8522 if (lc && list)
8523 return list;
8524 if (list && !TREE_CHAIN (list))
8525 return TREE_VALUE (list);
8527 /* Issue an error. List candidates if any. Candidates are listed
8528 only if accessible (non accessible methods may end-up here for
8529 the sake of a better error report). */
8530 candidates = NULL;
8531 if (list)
8533 tree current;
8534 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
8535 for (current = list; current; current = TREE_CHAIN (current))
8537 tree cm = TREE_VALUE (current);
8538 char string [4096];
8539 if (!cm || not_accessible_p (class, cm, 0))
8540 continue;
8541 signature = build_java_argument_signature (TREE_TYPE (cm));
8542 sprintf
8543 (string, " `%s(%s)' in `%s'%s",
8544 IDENTIFIER_POINTER (name),
8545 IDENTIFIER_POINTER (signature),
8546 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
8547 (TREE_CHAIN (current) ? "\n" : ""));
8548 obstack_grow (&temporary_obstack, string, strlen (string));
8550 obstack_1grow (&temporary_obstack, '\0');
8551 candidates = obstack_finish (&temporary_obstack);
8553 /* Issue the error message */
8554 signature = build_java_argument_signature (method);
8555 parse_error_context (cl, "Can't find method `%s(%s)' in class `%s'%s",
8556 IDENTIFIER_POINTER (name),
8557 IDENTIFIER_POINTER (signature),
8558 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))),
8559 (candidates ? candidates : ""));
8560 return NULL_TREE;
8563 /* 15.11.2.1: Find Methods that are Applicable and Accessible */
8565 static tree
8566 find_applicable_accessible_methods_list (class, name, arglist)
8567 tree class, name, arglist;
8569 tree method;
8570 tree list = NULL_TREE, all_list = NULL_TREE;
8572 while (class != NULL_TREE)
8574 for (method = TYPE_METHODS (class);
8575 method != NULL_TREE; method = TREE_CHAIN (method))
8577 /* Names have to match and we're not looking for constructor */
8578 if (DECL_NAME (method) != name
8579 || DECL_CONSTRUCTOR_P (method))
8580 continue;
8582 if (argument_types_convertible (method, arglist))
8584 /* Retain accessible methods only */
8585 if (!not_accessible_p (class, method, 0))
8586 list = tree_cons (NULL_TREE, method, list);
8587 else
8588 /* Also retain all selected method here */
8589 all_list = tree_cons (NULL_TREE, method, list);
8592 class = CLASSTYPE_SUPER (class);
8594 /* Either return the list obtained or all selected (but
8595 inaccessible) methods for better error report. */
8596 return (!list ? all_list : list);
8599 /* 15.11.2.2 Choose the Most Specific Method */
8601 static tree
8602 find_most_specific_methods_list (list)
8603 tree list;
8605 int max = 0;
8606 tree current, new_list = NULL_TREE;
8607 for (current = list; current; current = TREE_CHAIN (current))
8609 tree method;
8610 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
8612 for (method = list; method; method = TREE_CHAIN (method))
8614 /* Don't test a method against itself */
8615 if (method == current)
8616 continue;
8618 /* Compare arguments and location where method where declared */
8619 if (argument_types_convertible (TREE_VALUE (method),
8620 TREE_VALUE (current))
8621 && valid_method_invocation_conversion_p
8622 (DECL_CONTEXT (TREE_VALUE (method)),
8623 DECL_CONTEXT (TREE_VALUE (current))))
8625 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
8626 max = (v > max ? v : max);
8631 /* Review the list and select the maximally specific methods */
8632 for (current = list; current; current = TREE_CHAIN (current))
8633 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
8634 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
8636 /* If we can't find one, lower expectations and try to gather multiple
8637 maximally specific methods */
8638 while (!new_list)
8640 while (--max > 0)
8642 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
8643 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
8645 return new_list;
8648 return new_list;
8651 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
8652 converted by method invocation conversion (5.3) to the type of the
8653 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
8654 to change less often than M1. */
8656 static int
8657 argument_types_convertible (m1, m2_or_arglist)
8658 tree m1, m2_or_arglist;
8660 static tree m2_arg_value = NULL_TREE;
8661 static tree m2_arg_cache = NULL_TREE;
8663 register tree m1_arg, m2_arg;
8665 m1_arg = TYPE_ARG_TYPES (TREE_TYPE (m1));
8666 if (!METHOD_STATIC (m1))
8667 m1_arg = TREE_CHAIN (m1_arg);
8669 if (m2_arg_value == m2_or_arglist)
8670 m2_arg = m2_arg_cache;
8671 else
8673 /* M2_OR_ARGLIST can be a function DECL or a raw list of
8674 argument types */
8675 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
8677 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
8678 if (!METHOD_STATIC (m2_or_arglist))
8679 m2_arg = TREE_CHAIN (m2_arg);
8681 else
8682 m2_arg = m2_or_arglist;
8684 m2_arg_value = m2_or_arglist;
8685 m2_arg_cache = m2_arg;
8688 while (m1_arg && m2_arg)
8690 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
8691 TREE_VALUE (m2_arg)))
8692 break;
8693 m1_arg = TREE_CHAIN (m1_arg);
8694 m2_arg = TREE_CHAIN (m2_arg);
8696 return (!m1_arg && !m2_arg ? 1 : 0);
8699 /* Qualification routines */
8701 static void
8702 qualify_ambiguous_name (id)
8703 tree id;
8705 tree qual, qual_wfl, name, decl, ptr_type, saved_current_class;
8706 int again, super_found = 0, this_found = 0;
8708 /* We first qualify the first element, then derive qualification of
8709 others based on the first one. If the first element is qualified
8710 by a resolution (field or type), this resolution is stored in the
8711 QUAL_RESOLUTION of the qual element being examined. We need to
8712 save the current_class since the use of SUPER might change the
8713 its value. */
8714 saved_current_class = current_class;
8715 qual = EXPR_WFL_QUALIFICATION (id);
8716 do {
8718 /* Simple qualified expression feature a qual_wfl that is a
8719 WFL. Expression derived from a primary feature more complicated
8720 things like a CALL_EXPR. Expression from primary need to be
8721 worked out to extract the part on which the qualification will
8722 take place. */
8723 qual_wfl = QUAL_WFL (qual);
8724 switch (TREE_CODE (qual_wfl))
8726 case CALL_EXPR:
8727 qual_wfl = TREE_OPERAND (qual_wfl, 0);
8728 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
8730 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
8731 qual_wfl = QUAL_WFL (qual);
8733 break;
8734 case NEW_CLASS_EXPR:
8735 case CONVERT_EXPR:
8736 qual_wfl = TREE_OPERAND (qual_wfl, 0);
8737 break;
8738 case ARRAY_REF:
8739 while (TREE_CODE (qual_wfl) == ARRAY_REF)
8740 qual_wfl = TREE_OPERAND (qual_wfl, 0);
8741 break;
8742 default:
8743 /* Fix for -Wall. Just break doing nothing */
8744 break;
8746 name = EXPR_WFL_NODE (qual_wfl);
8747 ptr_type = current_class;
8748 again = 0;
8749 /* If we have a THIS (from a primary), we set the context accordingly */
8750 if (name == this_identifier_node)
8752 qual = TREE_CHAIN (qual);
8753 qual_wfl = QUAL_WFL (qual);
8754 name = EXPR_WFL_NODE (qual_wfl);
8755 this_found = 1;
8757 /* If we have a SUPER, we set the context accordingly */
8758 if (name == super_identifier_node)
8760 current_class = CLASSTYPE_SUPER (ptr_type);
8761 /* Check that there is such a thing as a super class. If not,
8762 return. The error will be caught later on, during the
8763 resolution */
8764 if (!current_class)
8766 current_class = saved_current_class;
8767 return;
8769 qual = TREE_CHAIN (qual);
8770 /* Do one more interation to set things up */
8771 super_found = again = 1;
8773 } while (again);
8775 /* If name appears within the scope of a location variable
8776 declaration or parameter declaration, then it is an expression
8777 name. We don't carry this test out if we're in the context of the
8778 use of SUPER or THIS */
8780 if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
8782 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
8783 QUAL_RESOLUTION (qual) = decl;
8786 /* If within the class/interface NAME was found to be used there
8787 exists a (possibly inherited) field named NAME, then this is an
8788 expression name. */
8789 else if ((decl = lookup_field_wrapper (ptr_type, name)))
8791 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
8792 QUAL_RESOLUTION (qual) = decl;
8795 /* We reclassify NAME as a type name if:
8796 - NAME is a class/interface declared within the compilation
8797 unit containing NAME,
8798 - NAME is imported via a single-type-import declaration,
8799 - NAME is declared in an another compilation unit of the package
8800 of the compilation unit containing NAME,
8801 - NAME is declared by exactly on type-import-on-demand declaration
8802 of the compilation unit containing NAME. */
8803 else if ((decl = resolve_and_layout (name, NULL_TREE)))
8805 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
8806 QUAL_RESOLUTION (qual) = decl;
8809 /* Method call are expression name */
8810 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR)
8811 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
8813 /* Check here that NAME isn't declared by more than one
8814 type-import-on-demand declaration of the compilation unit
8815 containing NAME. FIXME */
8817 /* Otherwise, NAME is reclassified as a package name */
8818 else
8819 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
8821 /* Propagate the qualification accross other components of the
8822 qualified name */
8823 for (qual = TREE_CHAIN (qual); qual;
8824 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
8826 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
8827 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
8828 else
8829 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
8832 /* Store the global qualification for the ambiguous part of ID back
8833 into ID fields */
8834 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
8835 RESOLVE_EXPRESSION_NAME_P (id) = 1;
8836 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
8837 RESOLVE_TYPE_NAME_P (id) = 1;
8838 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
8839 RESOLVE_PACKAGE_NAME_P (id) = 1;
8841 /* Restore the current class */
8842 current_class = saved_current_class;
8845 static int
8846 breakdown_qualified (left, right, source)
8847 tree *left, *right, source;
8849 char *p = IDENTIFIER_POINTER (source), *base;
8850 int l = IDENTIFIER_LENGTH (source);
8852 /* Breakdown NAME into REMAINDER . IDENTIFIER */
8853 base = p;
8854 p += (l-1);
8855 while (*p != '.' && p != base)
8856 p--;
8858 /* We didn't find a '.'. Return an error */
8859 if (p == base)
8860 return 1;
8862 *p = '\0';
8863 if (right)
8864 *right = get_identifier (p+1);
8865 *left = get_identifier (IDENTIFIER_POINTER (source));
8866 *p = '.';
8868 return 0;
8871 static int
8872 not_initialized_as_it_should_p (decl)
8873 tree decl;
8875 if (DECL_P (decl))
8877 if (TREE_CODE (decl) == FIELD_DECL
8878 && METHOD_STATIC (current_function_decl))
8879 return 0;
8880 return DECL_P (decl) && !INITIALIZED_P (decl);
8882 return 0;
8885 /* Patch tree nodes in a function body. When a BLOCK is found, push
8886 local variable decls if present. */
8888 static tree
8889 java_complete_tree (node)
8890 tree node;
8892 tree nn, cn, wfl_op1, wfl_op2;
8893 int flag;
8895 /* CONVERT_EXPR always has its type set, even though it needs to be
8896 worked out. */
8897 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
8898 return node;
8900 /* The switch block implements cases processing container nodes
8901 first. Contained nodes are always written back. Leaves come
8902 next and return a value. */
8903 switch (TREE_CODE (node))
8905 case BLOCK:
8907 /* 1- Block section.
8908 Set the local values on decl names so we can identify them
8909 faster when they're referenced. At that stage, identifiers
8910 are legal so we don't check for declaration errors. */
8911 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
8913 DECL_CONTEXT (cn) = current_function_decl;
8914 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
8915 INITIALIZED_P (cn) = 0;
8917 if (BLOCK_EXPR_BODY (node))
8919 BLOCK_EXPR_BODY (node) = java_complete_tree (BLOCK_EXPR_BODY (node));
8920 if (BLOCK_EXPR_BODY (node) == error_mark_node)
8921 return error_mark_node;
8923 /* Turn local bindings to null */
8924 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
8925 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
8927 TREE_TYPE (node) = void_type_node;
8928 break;
8930 /* 2- They are expressions but ultimately deal with statements */
8932 case THROW_EXPR:
8933 wfl_op1 = TREE_OPERAND (node, 0);
8934 COMPLETE_CHECK_OP_0 (node);
8935 return patch_throw_statement (node, wfl_op1);
8937 case SYNCHRONIZED_EXPR:
8938 wfl_op1 = TREE_OPERAND (node, 0);
8939 COMPLETE_CHECK_OP_0 (node);
8940 COMPLETE_CHECK_OP_1 (node);
8941 return patch_synchronized_statement (node, wfl_op1);
8943 case TRY_EXPR:
8944 return patch_try_statement (node);
8946 case LABELED_BLOCK_EXPR:
8947 PUSH_LABELED_BLOCK (node);
8948 if (LABELED_BLOCK_BODY (node))
8949 COMPLETE_CHECK_OP_1 (node);
8950 TREE_TYPE (node) = void_type_node;
8951 POP_LABELED_BLOCK ();
8952 return node;
8954 case EXIT_BLOCK_EXPR:
8955 /* We don't complete operand 1, because it's the return value of
8956 the EXIT_BLOCK_EXPR which doesn't exist it Java */
8957 return patch_bc_statement (node);
8959 case SWITCH_EXPR:
8960 case LOOP_EXPR:
8961 PUSH_LOOP (node);
8962 /* Check whether the loop was enclosed in a labeled
8963 statement. If not, create one, insert the loop in it and
8964 return the node */
8965 nn = patch_loop_statement (node);
8967 /* Anyways, walk the body of the loop */
8968 if (TREE_CODE (node) == LOOP_EXPR)
8969 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
8970 /* Switch statement: walk the switch expression and the cases */
8971 else
8972 node = patch_switch_statement (node);
8974 if (TREE_OPERAND (node, 0) == error_mark_node)
8975 return error_mark_node;
8976 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
8977 /* If we returned something different, that's because we
8978 inserted a label. Pop the label too. */
8979 if (nn != node)
8980 POP_LABELED_BLOCK ();
8981 POP_LOOP ();
8982 return nn;
8984 case EXIT_EXPR:
8985 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
8986 return patch_exit_expr (node);
8988 case COND_EXPR:
8989 /* Condition */
8990 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
8991 if (TREE_OPERAND (node, 0) == error_mark_node)
8992 return error_mark_node;
8993 /* then-else branches */
8994 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
8995 if (TREE_OPERAND (node, 1) == error_mark_node)
8996 return error_mark_node;
8997 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
8998 if (TREE_OPERAND (node, 2) == error_mark_node)
8999 return error_mark_node;
9000 return patch_if_else_statement (node);
9001 break;
9003 /* 3- Expression section */
9004 case COMPOUND_EXPR:
9005 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
9006 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
9007 if (TREE_OPERAND (node, 1) == error_mark_node)
9008 return error_mark_node;
9009 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
9010 break;
9012 case RETURN_EXPR:
9013 return patch_return (node);
9015 case EXPR_WITH_FILE_LOCATION:
9016 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
9017 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
9018 return resolve_expression_name (node);
9019 else
9021 EXPR_WFL_NODE (node) = java_complete_tree (EXPR_WFL_NODE (node));
9022 TREE_SIDE_EFFECTS (node) = 1;
9023 if (EXPR_WFL_NODE (node) == error_mark_node)
9025 /* Its important for the evaluation of assignment that
9026 this mark on the TREE_TYPE is propagated. */
9027 TREE_TYPE (node) = error_mark_node;
9028 return error_mark_node;
9030 else
9031 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
9033 break;
9035 case NEW_ARRAY_EXPR:
9036 /* Patch all the dimensions */
9037 flag = 0;
9038 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
9040 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
9041 tree dim = java_complete_tree (TREE_VALUE (cn));
9042 if (dim == error_mark_node)
9044 flag = 1;
9045 continue;
9047 else
9049 TREE_VALUE (cn) = dim;
9050 /* Setup the location of the current dimension, for
9051 later error report. */
9052 TREE_PURPOSE (cn) =
9053 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
9054 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
9057 /* They complete the array creation expression, if no errors
9058 were found. */
9059 return (flag ? error_mark_node : patch_newarray (node));
9061 case NEW_CLASS_EXPR:
9062 case CALL_EXPR:
9063 /* Complete function's argument(s) first */
9064 if (complete_function_arguments (node))
9065 return error_mark_node;
9066 else
9068 tree decl;
9069 node = patch_method_invocation_stmt (node, NULL_TREE,
9070 NULL_TREE, 0, &decl);
9071 if (node != error_mark_node)
9072 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
9073 return node;
9076 case MODIFY_EXPR:
9077 /* Save potential wfls */
9078 wfl_op1 = TREE_OPERAND (node, 0);
9079 wfl_op2 = TREE_OPERAND (node, 1);
9080 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
9081 if (TREE_OPERAND (node, 0) == error_mark_node)
9082 return error_mark_node;
9084 if (COMPOUND_ASSIGN_P (wfl_op2))
9086 tree lvalue;
9087 tree other =
9088 java_complete_tree (TREE_OPERAND (wfl_op2, 0));
9090 /* Hand stablize the lhs on both places */
9091 lvalue = stabilize_reference (other);
9092 TREE_OPERAND (node, 0) = lvalue;
9093 TREE_OPERAND (TREE_OPERAND (node, 1), 0) = lvalue;
9096 /* There are cases where the type of RHS is fixed. In those
9097 cases, if the evaluation of the RHS fails, we further the
9098 evaluation of the assignment to detect more errors. */
9099 nn = java_complete_tree (TREE_OPERAND (node, 1));
9100 if (nn == error_mark_node)
9102 /* It's hopeless, but we can further things on to discover
9103 an error during the assignment. In any cases, the
9104 assignment operation fails. */
9105 if (TREE_CODE (TREE_OPERAND (node, 1)) != EXPR_WITH_FILE_LOCATION
9106 && TREE_TYPE (TREE_OPERAND (node, 1)) != error_mark_node)
9107 patch_assignment (node, wfl_op1, wfl_op2);
9109 /* Now, we still mark the lhs as initialized */
9110 if (DECL_P (TREE_OPERAND (node, 0)))
9111 INITIALIZED_P (TREE_OPERAND (node, 0)) = 1;
9113 return error_mark_node;
9115 TREE_OPERAND (node, 1) = nn;
9117 /* In case we're handling = with a String as a RHS, we need to
9118 produce a String out of the RHS (it might still be a
9119 STRING_CST or a StringBuffer at this stage */
9120 if ((nn = patch_string (TREE_OPERAND (node, 1))))
9121 TREE_OPERAND (node, 1) = nn;
9122 return patch_assignment (node, wfl_op1, wfl_op2);
9124 case MULT_EXPR:
9125 case PLUS_EXPR:
9126 case MINUS_EXPR:
9127 case LSHIFT_EXPR:
9128 case RSHIFT_EXPR:
9129 case URSHIFT_EXPR:
9130 case BIT_AND_EXPR:
9131 case BIT_XOR_EXPR:
9132 case BIT_IOR_EXPR:
9133 case TRUNC_MOD_EXPR:
9134 case RDIV_EXPR:
9135 case TRUTH_ANDIF_EXPR:
9136 case TRUTH_ORIF_EXPR:
9137 case EQ_EXPR:
9138 case NE_EXPR:
9139 case GT_EXPR:
9140 case GE_EXPR:
9141 case LT_EXPR:
9142 case LE_EXPR:
9143 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
9144 knows how to handle those cases. */
9145 wfl_op1 = TREE_OPERAND (node, 0);
9146 wfl_op2 = TREE_OPERAND (node, 1);
9148 /* Don't complete string nodes if dealing with the PLUS operand. */
9149 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
9151 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
9152 if (TREE_OPERAND (node, 0) == error_mark_node)
9153 return error_mark_node;
9155 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
9157 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
9158 if (TREE_OPERAND (node, 1) == error_mark_node)
9159 return error_mark_node;
9161 return patch_binop (node, wfl_op1, wfl_op2);
9163 case UNARY_PLUS_EXPR:
9164 case NEGATE_EXPR:
9165 case TRUTH_NOT_EXPR:
9166 case BIT_NOT_EXPR:
9167 case PREDECREMENT_EXPR:
9168 case PREINCREMENT_EXPR:
9169 case POSTDECREMENT_EXPR:
9170 case POSTINCREMENT_EXPR:
9171 case CONVERT_EXPR:
9172 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
9173 how to handle those cases. */
9174 wfl_op1 = TREE_OPERAND (node, 0);
9175 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
9176 if (TREE_OPERAND (node, 0) == error_mark_node)
9177 return error_mark_node;
9178 return patch_unaryop (node, wfl_op1);
9180 case ARRAY_REF:
9181 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
9182 how to handle those cases. */
9183 wfl_op1 = TREE_OPERAND (node, 0);
9184 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
9185 if (TREE_OPERAND (node, 0) == error_mark_node)
9186 return error_mark_node;
9187 if (!flag_emit_class_files)
9188 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
9189 /* The same applies to wfl_op2 */
9190 wfl_op2 = TREE_OPERAND (node, 1);
9191 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
9192 if (TREE_OPERAND (node, 1) == error_mark_node)
9193 return error_mark_node;
9194 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
9195 return patch_array_ref (node, wfl_op1, wfl_op2);
9197 case THIS_EXPR:
9198 /* Can't use THIS in a static environment */
9199 if (!current_this)
9201 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
9202 parse_error_context (wfl_operator, "Keyword `this' used outside "
9203 "allowed context");
9204 TREE_TYPE (node) = error_mark_node;
9205 return error_mark_node;
9207 return current_this;
9209 default:
9210 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
9211 and it's time to turn it into the appropriate String object
9213 if ((node = patch_string (node)))
9214 return node;
9215 fatal ("No case for tree code `%s' - java_complete_tree\n",
9216 tree_code_name [TREE_CODE (node)]);
9218 return node;
9221 /* Complete function call's argument. Return a non zero value is an
9222 error was found. */
9224 static int
9225 complete_function_arguments (node)
9226 tree node;
9228 int flag = 0;
9229 tree cn;
9231 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
9233 tree wfl = TREE_VALUE (cn), parm, temp;
9234 parm = java_complete_tree (wfl);
9235 if (parm == error_mark_node)
9237 flag = 1;
9238 continue;
9240 /* If have a string literal that we haven't transformed yet or a
9241 crafted string buffer, as a result of use of the the String
9242 `+' operator. Build `parm.toString()' and expand it. */
9243 if ((temp = patch_string (parm)))
9244 parm = temp;
9245 TREE_VALUE (cn) = parm;
9247 if (not_initialized_as_it_should_p (parm))
9249 ERROR_VARIABLE_NOT_INITIALIZED (wfl, EXPR_WFL_NODE (wfl));
9250 INITIALIZED_P (parm) = 1;
9253 return flag;
9256 /* Sometimes (for loops and variable initialized during their
9257 declaration), we want to wrap a statement around a WFL and turn it
9258 debugable. */
9260 static tree
9261 build_debugable_stmt (location, stmt)
9262 int location;
9263 tree stmt;
9265 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
9267 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
9268 EXPR_WFL_LINECOL (stmt) = location;
9270 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
9271 return stmt;
9274 static tree
9275 build_expr_block (body, decls)
9276 tree body, decls;
9278 tree node = make_node (BLOCK);
9279 BLOCK_EXPR_DECLS (node) = decls;
9280 BLOCK_EXPR_BODY (node) = body;
9281 if (body)
9282 TREE_TYPE (node) = TREE_TYPE (body);
9283 TREE_SIDE_EFFECTS (node) = 1;
9284 return node;
9287 /* Create a new function block and link it approriately to current
9288 function block chain */
9290 static tree
9291 enter_block ()
9293 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
9296 /* Link block B supercontext to the previous block. The current
9297 function DECL is used as supercontext when enter_a_block is called
9298 for the first time for a given function. The current function body
9299 (DECL_FUNCTION_BODY) is set to be block B. */
9301 static tree
9302 enter_a_block (b)
9303 tree b;
9305 tree fndecl = current_function_decl;
9307 if (!DECL_FUNCTION_BODY (fndecl))
9309 BLOCK_SUPERCONTEXT (b) = fndecl;
9310 DECL_FUNCTION_BODY (fndecl) = b;
9312 else
9314 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
9315 DECL_FUNCTION_BODY (fndecl) = b;
9317 return b;
9320 /* Exit a block by changing the current function body
9321 (DECL_FUNCTION_BODY) to the current block super context, only if
9322 the block being exited isn't the method's top level one. */
9324 static tree
9325 exit_block ()
9327 tree b = DECL_FUNCTION_BODY (current_function_decl);
9329 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
9330 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
9332 return b;
9335 /* Lookup for NAME in the nested function's blocks, all the way up to
9336 the current toplevel one. It complies with Java's local variable
9337 scoping rules. */
9339 static tree
9340 lookup_name_in_blocks (name)
9341 tree name;
9343 tree b = DECL_FUNCTION_BODY (current_function_decl);
9345 while (b != current_function_decl)
9347 tree current;
9349 /* Paranoid sanity check. To be removed */
9350 if (TREE_CODE (b) != BLOCK)
9351 fatal ("non block expr function body - lookup_name_in_blocks");
9353 for (current = BLOCK_EXPR_DECLS (b); current;
9354 current = TREE_CHAIN (current))
9355 if (DECL_NAME (current) == name)
9356 return current;
9357 b = BLOCK_SUPERCONTEXT (b);
9359 return NULL_TREE;
9362 static void
9363 maybe_absorb_scoping_blocks ()
9365 while (BLOCK_EXPR_ORIGIN (DECL_FUNCTION_BODY (current_function_decl)))
9367 tree b = exit_block ();
9368 java_method_add_stmt (current_function_decl, b);
9369 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
9374 /* This section of the source is reserved to build_* functions that
9375 are building incomplete tree nodes and the patch_* functions that
9376 are completing them. */
9378 /* Build an incomplete CALL_EXPR node. */
9380 static tree
9381 build_method_invocation (name, args)
9382 tree name;
9383 tree args;
9385 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
9386 TREE_SIDE_EFFECTS (call) = 1;
9387 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
9388 return call;
9391 /* Build an incomplete new xxx(...) node. */
9393 static tree
9394 build_new_invocation (name, args)
9395 tree name, args;
9397 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
9398 TREE_SIDE_EFFECTS (call) = 1;
9399 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
9400 return call;
9403 /* Build an incomplete assignment expression. */
9405 static tree
9406 build_assignment (op, op_location, lhs, rhs)
9407 int op, op_location;
9408 tree lhs, rhs;
9410 tree assignment;
9411 /* Build the corresponding binop if we deal with a Compound
9412 Assignment operator. Mark the binop sub-tree as part of a
9413 Compound Assignment expression */
9414 if (op != ASSIGN_TK)
9416 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
9417 COMPOUND_ASSIGN_P (rhs) = 1;
9419 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
9420 TREE_SIDE_EFFECTS (assignment) = 1;
9421 EXPR_WFL_LINECOL (assignment) = op_location;
9422 return assignment;
9425 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
9427 static char *
9428 print_int_node (node)
9429 tree node;
9431 static char buffer [80];
9432 if (TREE_CONSTANT_OVERFLOW (node))
9433 sprintf (buffer, "<overflow>");
9435 if (TREE_INT_CST_HIGH (node) == 0)
9436 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
9437 TREE_INT_CST_LOW (node));
9438 else if (TREE_INT_CST_HIGH (node) == -1
9439 && TREE_INT_CST_LOW (node) != 0)
9441 buffer [0] = '-';
9442 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
9443 -TREE_INT_CST_LOW (node));
9445 else
9446 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
9447 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
9449 return buffer;
9452 /* 15.25 Assignment operators. */
9454 static tree
9455 patch_assignment (node, wfl_op1, wfl_op2)
9456 tree node;
9457 tree wfl_op1;
9458 tree wfl_op2;
9460 tree rhs = TREE_OPERAND (node, 1);
9461 tree lvalue = TREE_OPERAND (node, 0);
9462 tree lhs_type, rhs_type, new_rhs = NULL_TREE;
9463 int error_found = 0;
9464 int lvalue_from_array = 0;
9466 /* Can't assign to a final. */
9467 if (DECL_P (lvalue) && FIELD_FINAL (lvalue))
9469 parse_error_context
9470 (wfl_op1, "Can't assign a value to the final variable `%s'",
9471 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl_op1)));
9472 error_found = 1;
9475 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
9477 /* Lhs can be a named variable */
9478 if (DECL_P (lvalue))
9480 INITIALIZED_P (lvalue) = 1;
9481 lhs_type = TREE_TYPE (lvalue);
9483 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
9484 comment on reason why */
9485 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
9487 lhs_type = TREE_TYPE (lvalue);
9488 lvalue_from_array = 1;
9490 /* Or a field access */
9491 else if (TREE_CODE (lvalue) == COMPONENT_REF)
9492 lhs_type = TREE_TYPE (lvalue);
9493 /* Or a function return slot */
9494 else if (TREE_CODE (lvalue) == RESULT_DECL)
9495 lhs_type = TREE_TYPE (lvalue);
9496 /* Otherwise, this is an error */
9497 else
9499 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
9500 error_found = 1;
9503 rhs_type = TREE_TYPE (rhs);
9504 /* 5.1 Try the assignment conversion for builtin type. */
9505 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
9507 /* 5.2 If it failed, try a reference conversion */
9508 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
9509 lhs_type = promote_type (rhs_type);
9511 /* 15.25.2 If we have a compound assignment, convert RHS into the
9512 type of the LHS */
9513 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
9514 new_rhs = convert (lhs_type, rhs);
9516 /* Explicit cast required. This is an error */
9517 if (!new_rhs)
9519 char *t1 = strdup (lang_printable_name (TREE_TYPE (rhs), 0));
9520 char *t2 = strdup (lang_printable_name (lhs_type, 0));
9521 tree wfl;
9522 char operation [32]; /* Max size known */
9524 /* If the assignment is part of a declaration, we use the WFL of
9525 the declared variable to point out the error and call it a
9526 declaration problem. If the assignment is a genuine =
9527 operator, we call is a operator `=' problem, otherwise we
9528 call it an assignment problem. In both of these last cases,
9529 we use the WFL of the operator to indicate the error. */
9531 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
9533 wfl = wfl_op1;
9534 strcpy (operation, "declaration");
9536 else
9538 wfl = wfl_operator;
9539 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
9540 strcpy (operation, "assignment");
9541 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
9542 strcpy (operation, "`return'");
9543 else
9544 strcpy (operation, "`='");
9547 parse_error_context
9548 (wfl, (!valid_cast_to_p (rhs_type, lhs_type) ?
9549 "Incompatible type for %s. Can't convert `%s' to `%s'" :
9550 "Incompatible type for %s. Explicit cast "
9551 "needed to convert `%s' to `%s'"), operation, t1, t2);
9552 free (t1); free (t2);
9553 error_found = 1;
9556 /* Before reporting type incompatibility errors, check that the rhs
9557 is initialized, if a variable */
9558 if (not_initialized_as_it_should_p (rhs))
9560 ERROR_VARIABLE_NOT_INITIALIZED (wfl_op2, DECL_NAME (rhs));
9561 INITIALIZED_P (rhs) = 1;
9564 if (error_found)
9565 return error_mark_node;
9567 /* If we built a compound expression as the result of a reference
9568 assignment into an array element, return it here. */
9569 if (TREE_CODE (node) == COMPOUND_EXPR)
9570 return node;
9572 TREE_OPERAND (node, 0) = lvalue;
9573 TREE_OPERAND (node, 1) = new_rhs;
9574 TREE_TYPE (node) = lhs_type;
9575 return node;
9578 /* Check that type SOURCE can be cast into type DEST. If the cast
9579 can't occur at all, return 0 otherwise 1. This function is used to
9580 produce accurate error messages on the reasons why an assignment
9581 failed. */
9583 static tree
9584 try_reference_assignconv (lhs_type, rhs)
9585 tree lhs_type, rhs;
9587 tree new_rhs = NULL_TREE;
9588 tree rhs_type = TREE_TYPE (rhs);
9590 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
9592 /* `null' may be assigned to any reference type */
9593 if (rhs == null_pointer_node)
9594 new_rhs = null_pointer_node;
9595 /* Try the reference assignment conversion */
9596 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
9597 new_rhs = rhs;
9598 /* This is a magic assignment that we process differently */
9599 else if (rhs == soft_exceptioninfo_call_node)
9600 new_rhs = rhs;
9602 return new_rhs;
9605 /* Check that RHS can be converted into LHS_TYPE by the assignment
9606 conversion (5.2), for the cases of RHS being a builtin type. Return
9607 NULL_TREE if the conversion fails or if because RHS isn't of a
9608 builtin type. Return a converted RHS if the conversion is possible. */
9610 static tree
9611 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
9612 tree wfl_op1, lhs_type, rhs;
9614 tree new_rhs = NULL_TREE;
9615 tree rhs_type = TREE_TYPE (rhs);
9617 /* 5.1.1 Try Identity Conversion,
9618 5.1.2 Try Widening Primitive Conversion */
9619 if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
9620 new_rhs = convert (lhs_type, rhs);
9622 /* Try a narrowing primitive conversion (5.1.3):
9623 - expression is a constant expression of type int AND
9624 - variable is byte, short or char AND
9625 - The value of the expression is representable in the type of the
9626 variable */
9627 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
9628 && (lhs_type == byte_type_node || lhs_type == char_type_node
9629 || lhs_type == short_type_node))
9631 if (int_fits_type_p (rhs, lhs_type))
9632 new_rhs = convert (lhs_type, rhs);
9633 else if (wfl_op1) /* Might be called with a NULL */
9634 parse_warning_context
9635 (wfl_op1, "Constant expression `%s' to wide for narrowing "
9636 "primitive conversion to `%s'",
9637 print_int_node (rhs), lang_printable_name (lhs_type, 0));
9638 /* Reported a warning that will turn into an error further
9639 down, so we don't return */
9642 return new_rhs;
9645 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
9646 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
9647 0 is the conversion test fails. This implements parts the method
9648 invocation convertion (5.3). */
9650 static int
9651 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
9652 tree lhs_type, rhs_type;
9654 int all_primitive =
9655 JPRIMITIVE_TYPE_P (lhs_type) && JPRIMITIVE_TYPE_P (rhs_type);
9657 if (!all_primitive)
9658 return 0;
9660 if (lhs_type == rhs_type)
9661 return 1;
9663 /* byte, even if it's smaller than a char can't be converted into a
9664 char. Short can't too, but the < test below takes care of that */
9665 if (lhs_type == char_type_node && rhs_type == byte_type_node)
9666 return 0;
9668 if (JINTEGRAL_TYPE_P (rhs_type)
9669 && ((TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type))
9670 || (JFLOAT_TYPE_P (lhs_type) &&
9671 TYPE_PRECISION (rhs_type) == TYPE_PRECISION (lhs_type))))
9672 return 1;
9673 else if (JFLOAT_TYPE_P (rhs_type)
9674 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
9675 return 1;
9677 return 0;
9680 /* Check that something of SOURCE type can be assigned or cast to
9681 something of DEST type at runtime. Return 1 if the operation is
9682 valid, 0 otherwise. If CAST is set to 1, we're treating the case
9683 were SOURCE is cast into DEST, which borrows a lot of the
9684 assignment check. */
9686 static int
9687 valid_ref_assignconv_cast_p (source, dest, cast)
9688 tree source;
9689 tree dest;
9690 int cast;
9692 if (TREE_CODE (source) == POINTER_TYPE)
9693 source = TREE_TYPE (source);
9694 if (TREE_CODE (dest) == POINTER_TYPE)
9695 dest = TREE_TYPE (dest);
9696 /* Case where SOURCE is a class type */
9697 if (TYPE_CLASS_P (source))
9699 if (TYPE_CLASS_P (dest))
9700 return source == dest || inherits_from_p (source, dest)
9701 || (cast && inherits_from_p (dest, source));
9702 if (TYPE_INTERFACE_P (dest))
9704 /* If doing a cast and SOURCE is final, the operation is
9705 always correct a compile time (because even if SOURCE
9706 does not implement DEST, a subclass of SOURCE might). */
9707 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
9708 return 1;
9709 /* Otherwise, SOURCE must implement DEST */
9710 return interface_of_p (dest, source);
9712 /* DEST is an array, cast permited if SOURCE is of Object type */
9713 return (cast && source == object_type_node ? 1 : 0);
9715 if (TYPE_INTERFACE_P (source))
9717 if (TYPE_CLASS_P (dest))
9719 /* If not casting, DEST must be the Object type */
9720 if (!cast)
9721 return dest == object_type_node;
9722 /* We're doing a cast. The cast is always valid is class
9723 DEST is not final, otherwise, DEST must implement SOURCE */
9724 else if (!CLASS_FINAL (TYPE_NAME (dest)))
9725 return 1;
9726 else
9727 return interface_of_p (source, dest);
9729 if (TYPE_INTERFACE_P (dest))
9731 /* If doing a cast, then if SOURCE and DEST contain method
9732 with the same signature but different return type, then
9733 this is a (compile time) error */
9734 if (cast)
9736 tree method_source, method_dest;
9737 tree source_type;
9738 tree source_sig;
9739 tree source_name;
9740 for (method_source = TYPE_METHODS (source); method_source;
9741 method_source = TREE_CHAIN (method_source))
9743 source_sig =
9744 build_java_argument_signature (TREE_TYPE (method_source));
9745 source_type = TREE_TYPE (TREE_TYPE (method_source));
9746 source_name = DECL_NAME (method_source);
9747 for (method_dest = TYPE_METHODS (dest);
9748 method_dest; method_dest = TREE_CHAIN (method_dest))
9749 if (source_sig ==
9750 build_java_argument_signature (TREE_TYPE (method_dest))
9751 && source_name == DECL_NAME (method_dest)
9752 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
9753 return 0;
9755 return 1;
9757 else
9758 return source == dest || interface_of_p (dest, source);
9760 else /* Array */
9761 return 0;
9763 if (TYPE_ARRAY_P (source))
9765 if (TYPE_CLASS_P (dest))
9766 return dest == object_type_node;
9767 if (TYPE_INTERFACE_P (dest))
9768 return 0; /* Install test on Clonable. FIXME */
9769 else /* Arrays */
9771 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
9772 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
9774 /* In case of severe errors, they turn out null */
9775 if (!dest_element_type || !source_element_type)
9776 return 0;
9777 if (source_element_type == dest_element_type)
9778 return 1;
9779 return valid_ref_assignconv_cast_p (source_element_type,
9780 dest_element_type, cast);
9782 return 0;
9784 return 0;
9787 static int
9788 valid_cast_to_p (source, dest)
9789 tree source;
9790 tree dest;
9792 if (TREE_CODE (source) == POINTER_TYPE)
9793 source = TREE_TYPE (source);
9794 if (TREE_CODE (dest) == POINTER_TYPE)
9795 dest = TREE_TYPE (dest);
9797 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
9798 return valid_ref_assignconv_cast_p (source, dest, 1);
9800 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
9801 return 1;
9803 return 0;
9806 /* Method invocation conversion test. Return 1 if type SOURCE can be
9807 converted to type DEST through the methond invocation conversion
9808 process (5.3) */
9810 static int
9811 valid_method_invocation_conversion_p (dest, source)
9812 tree dest, source;
9814 return ((JPRIMITIVE_TYPE_P (source)
9815 && JPRIMITIVE_TYPE_P (dest)
9816 && valid_builtin_assignconv_identity_widening_p (dest, source))
9817 || (JREFERENCE_TYPE_P (source)
9818 && JREFERENCE_TYPE_P (dest)
9819 && valid_ref_assignconv_cast_p (source, dest, 0)));
9822 /* Build an incomplete binop expression. */
9824 static tree
9825 build_binop (op, op_location, op1, op2)
9826 enum tree_code op;
9827 int op_location;
9828 tree op1, op2;
9830 tree binop;
9832 binop = build (op, NULL_TREE, op1, op2);
9833 TREE_SIDE_EFFECTS (binop) = 1;
9834 /* Store the location of the operator, for better error report. The
9835 string of the operator will be rebuild based on the OP value. */
9836 EXPR_WFL_LINECOL (binop) = op_location;
9837 return binop;
9840 /* Build the string of the operator retained by NODE. If NODE is part
9841 of a compound expression, add an '=' at the end of the string. This
9842 function is called when an error needs to be reported on an
9843 operator. The string is returned as a pointer to a static character
9844 buffer. */
9846 static char *
9847 operator_string (node)
9848 tree node;
9850 #define BUILD_OPERATOR_STRING(S) \
9852 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
9853 return buffer; \
9856 static char buffer [10];
9857 switch (TREE_CODE (node))
9859 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
9860 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
9861 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
9862 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
9863 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
9864 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
9865 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
9866 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
9867 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
9868 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
9869 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
9870 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
9871 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
9872 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
9873 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
9874 case GT_EXPR: BUILD_OPERATOR_STRING (">");
9875 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
9876 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
9877 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
9878 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
9879 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
9880 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
9881 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
9882 case PREINCREMENT_EXPR: /* Fall through */
9883 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
9884 case PREDECREMENT_EXPR: /* Fall through */
9885 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
9886 default:
9887 fatal ("unregistered operator %s - operator_string",
9888 tree_code_name [TREE_CODE (node)]);
9890 return NULL;
9891 #undef BUILD_OPERATOR_STRING
9894 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
9895 errors but we modify NODE so that it contains the type computed
9896 according to the expression, when it's fixed. Otherwise, we write
9897 error_mark_node as the type. It allows us to further the analysis
9898 of remaining nodes and detects more errors in certain cases. */
9900 static tree
9901 patch_binop (node, wfl_op1, wfl_op2)
9902 tree node;
9903 tree wfl_op1;
9904 tree wfl_op2;
9906 tree op1 = TREE_OPERAND (node, 0);
9907 tree op2 = TREE_OPERAND (node, 1);
9908 tree op1_type = TREE_TYPE (op1);
9909 tree op2_type = TREE_TYPE (op2);
9910 tree prom_type;
9911 int code = TREE_CODE (node);
9913 /* If 1, tell the routine that we have to return error_mark_node
9914 after checking for the initialization of the RHS */
9915 int error_found = 0;
9917 /* Figure what is going to be checked first for initialization prior
9918 its use. If NODE is part of a compound assignment, we check the
9919 second operand first, otherwise the first one first. We also
9920 initialize the matching WFL for the error report. `cfi' stands
9921 for Check For Initialization */
9922 tree cfi = (COMPOUND_ASSIGN_P (node) ? op2 : op1);
9923 tree cfi_wfl = (COMPOUND_ASSIGN_P (node) ? wfl_op2 : wfl_op1);
9925 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
9927 /* Check initialization of LHS first. We then silence further error
9928 message if the variable wasn't initialized */
9929 if (not_initialized_as_it_should_p (cfi))
9931 ERROR_VARIABLE_NOT_INITIALIZED (cfi_wfl, DECL_NAME (cfi));
9932 INITIALIZED_P (op1) = 1;
9935 switch (code)
9937 /* 15.16 Multiplicative operators */
9938 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
9939 case RDIV_EXPR: /* 15.16.2 Division Operator / */
9940 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
9941 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
9943 if (!JPRIMITIVE_TYPE_P (op1_type))
9944 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
9945 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
9946 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
9947 TREE_TYPE (node) = error_mark_node;
9948 error_found = 1;
9949 break;
9951 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
9952 /* Change the division operator if necessary */
9953 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
9954 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
9955 /* This one is more complicated. FLOATs are processed by a function
9956 call to soft_fmod. */
9957 if (code == TRUNC_MOD_EXPR)
9958 return build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
9959 break;
9961 /* 15.17 Additive Operators */
9962 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
9964 /* Operation is valid if either one argument is a string
9965 constant, a String object or a StringBuffer crafted for the
9966 purpose of the a previous usage of the String concatenation
9967 operator */
9969 if (TREE_CODE (op1) == STRING_CST
9970 || TREE_CODE (op2) == STRING_CST
9971 || JSTRING_TYPE_P (op1_type)
9972 || JSTRING_TYPE_P (op2_type)
9973 || IS_CRAFTED_STRING_BUFFER_P (op1)
9974 || IS_CRAFTED_STRING_BUFFER_P (op2))
9975 return build_string_concatenation (op1, op2);
9977 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
9978 Numeric Types */
9979 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
9981 if (!JPRIMITIVE_TYPE_P (op1_type))
9982 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
9983 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
9984 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
9985 TREE_TYPE (node) = error_mark_node;
9986 error_found = 1;
9987 break;
9989 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
9990 break;
9992 /* 15.18 Shift Operators */
9993 case LSHIFT_EXPR:
9994 case RSHIFT_EXPR:
9995 case URSHIFT_EXPR:
9996 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
9998 if (!JINTEGRAL_TYPE_P (op1_type))
9999 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
10000 else
10001 parse_error_context
10002 (wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ?
10003 "Incompatible type for `%s'. Explicit cast needed to convert "
10004 "shift distance from `%s' to integral" :
10005 "Incompatible type for `%s'. Can't convert shift distance from "
10006 "`%s' to integral"),
10007 operator_string (node), lang_printable_name (op2_type, 0));
10008 TREE_TYPE (node) = error_mark_node;
10009 error_found = 1;
10010 break;
10013 /* Unary numeric promotion (5.6.1) is performed on each operand
10014 separatly */
10015 op1 = convert (promote_type (op1_type), op1);
10016 op2 = convert (promote_type (op2_type), op2);
10018 /* The type of the shift expression is the type of the promoted
10019 type of the left-hand operand */
10020 prom_type = TREE_TYPE (op1);
10022 /* Shift int only up to 0x1f and long up to 0x3f */
10023 if (prom_type == int_type_node)
10024 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
10025 build_int_2 (0x1f, 0)));
10026 else
10027 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
10028 build_int_2 (0x3f, 0)));
10030 /* The >>> operator is a >> operating on unsigned quantities */
10031 if (code == URSHIFT_EXPR)
10033 op1 = convert (unsigned_type (prom_type), op1);
10034 TREE_SET_CODE (node, RSHIFT_EXPR);
10036 break;
10039 /* 15.21 Bitwise and Logical Operators */
10040 case BIT_AND_EXPR:
10041 case BIT_XOR_EXPR:
10042 case BIT_IOR_EXPR:
10043 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
10044 /* Binary numeric promotion is performed on both operand and the
10045 expression retain that type */
10046 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
10048 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
10049 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
10050 /* The type of the bitwise operator expression is BOOLEAN */
10051 prom_type = boolean_type_node;
10052 else
10054 if (!JINTEGRAL_TYPE_P (op1_type))
10055 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
10056 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
10057 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
10058 TREE_TYPE (node) = error_mark_node;
10059 error_found = 1;
10060 /* Insert a break here if adding thing before the switch's
10061 break for this case */
10063 break;
10065 /* 15.22 Conditional-And Operator */
10066 case TRUTH_ANDIF_EXPR:
10067 /* 15.23 Conditional-Or Operator */
10068 case TRUTH_ORIF_EXPR:
10069 /* Operands must be of BOOLEAN type */
10070 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
10071 TREE_CODE (op2_type) != BOOLEAN_TYPE)
10073 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
10074 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
10075 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
10076 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
10077 TREE_TYPE (node) = boolean_type_node;
10078 error_found = 1;
10079 break;
10081 /* The type of the conditional operators is BOOLEAN */
10082 prom_type = boolean_type_node;
10083 break;
10085 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
10086 case LT_EXPR:
10087 case GT_EXPR:
10088 case LE_EXPR:
10089 case GE_EXPR:
10090 /* The type of each of the operands must be a primitive numeric
10091 type */
10092 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
10094 if (!JNUMERIC_TYPE_P (op1_type))
10095 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
10096 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
10097 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
10098 TREE_TYPE (node) = boolean_type_node;
10099 error_found = 1;
10100 break;
10102 /* Binary numeric promotion is performed on the operands */
10103 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
10104 /* The type of the relation expression is always BOOLEAN */
10105 prom_type = boolean_type_node;
10106 break;
10108 /* 15.20 Equality Operator */
10109 case EQ_EXPR:
10110 case NE_EXPR:
10111 /* 15.20.1 Numerical Equality Operators == and != */
10112 /* Binary numeric promotion is performed on the operands */
10113 if (JPRIMITIVE_TYPE_P (op1_type) && JPRIMITIVE_TYPE_P (op2_type))
10114 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
10116 /* 15.20.2 Boolean Equality Operators == and != */
10117 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
10118 TREE_CODE (op2_type) == BOOLEAN_TYPE)
10119 ; /* Nothing to do here */
10121 /* 15.20.3 Reference Equality Operators == and != */
10122 /* Types have to be either references or the null type */
10123 else if (op1 == null_pointer_node || op2 == null_pointer_node
10124 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
10125 && ((op1_type == op2_type))))
10126 ; /* Nothing to do here */
10128 /* Else we have an error figure what can't be converted into
10129 what and report the error */
10130 else
10132 char *t1;
10133 t1 = strdup (lang_printable_name (op1_type, 0));
10134 parse_error_context
10135 (wfl_operator, "Incompatible type for `%s'. Can't convert `%s' "
10136 "to `%s'", operator_string (node), t1,
10137 lang_printable_name (op2_type, 0));
10138 free (t1);
10139 TREE_TYPE (node) = boolean_type_node;
10140 error_found = 1;
10141 break;
10143 prom_type = boolean_type_node;
10144 break;
10147 /* Then check the initialization of the RHS. We don't do that if
10148 we're dealing with a node that is part of a compound
10149 assignment. We then silence further error message if the variable
10150 wasn't initialized */
10151 if (not_initialized_as_it_should_p (op2) && !COMPOUND_ASSIGN_P (node))
10153 ERROR_VARIABLE_NOT_INITIALIZED (wfl_op2, DECL_NAME (op2));
10154 INITIALIZED_P (op2) = 1;
10157 if (error_found)
10158 return error_mark_node;
10160 TREE_OPERAND (node, 0) = op1;
10161 TREE_OPERAND (node, 1) = op2;
10162 TREE_TYPE (node) = prom_type;
10163 return fold (node);
10166 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
10167 zero value, the value of CSTE comes after the valude of STRING */
10169 static tree
10170 do_merge_string_cste (cste, string, string_len, after)
10171 tree cste;
10172 char *string;
10173 int string_len, after;
10175 int len = TREE_STRING_LENGTH (cste) + string_len;
10176 char *old = TREE_STRING_POINTER (cste);
10177 TREE_STRING_LENGTH (cste) = len;
10178 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
10179 if (after)
10181 strcpy (TREE_STRING_POINTER (cste), string);
10182 strcat (TREE_STRING_POINTER (cste), old);
10184 else
10186 strcpy (TREE_STRING_POINTER (cste), old);
10187 strcat (TREE_STRING_POINTER (cste), string);
10189 return cste;
10192 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
10193 new STRING_CST on success, NULL_TREE on failure */
10195 static tree
10196 merge_string_cste (op1, op2, after)
10197 tree op1, op2;
10198 int after;
10200 /* Handle two string constants right away */
10201 if (TREE_CODE (op2) == STRING_CST)
10202 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
10203 TREE_STRING_LENGTH (op2), after);
10205 /* Reasonable integer constant can be treated right away */
10206 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
10208 static char *boolean_true = "true";
10209 static char *boolean_false = "false";
10210 static char *null_pointer = "null";
10211 char ch[3];
10212 char *string;
10214 if (op2 == boolean_true_node)
10215 string = boolean_true;
10216 else if (op2 == boolean_false_node)
10217 string = boolean_false;
10218 else if (op2 == null_pointer_node)
10219 string = null_pointer;
10220 else if (TREE_TYPE (op2) == char_type_node)
10222 ch[0] = (char )TREE_INT_CST_LOW (op2);
10223 ch[1] = '\0';
10224 string = ch;
10226 else
10227 string = print_int_node (op2);
10229 return do_merge_string_cste (op1, string, strlen (string), after);
10231 return NULL_TREE;
10234 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
10235 has to be a STRING_CST and the other part must be a STRING_CST or a
10236 INTEGRAL constant. Return a new STRING_CST if the operation
10237 succeed, NULL_TREE otherwise.
10239 If the case we want to optimize for space, we might want to return
10240 NULL_TREE for each invocation of this routine. FIXME */
10242 static tree
10243 string_constant_concatenation (op1, op2)
10244 tree op1, op2;
10246 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
10248 tree string, rest;
10249 int invert;
10251 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
10252 rest = (string == op1 ? op2 : op1);
10253 invert = (string == op1 ? 0 : 1 );
10255 /* Walk REST, only if it looks reasonable */
10256 if (TREE_CODE (rest) != STRING_CST
10257 && !IS_CRAFTED_STRING_BUFFER_P (rest)
10258 && !JSTRING_TYPE_P (TREE_TYPE (rest))
10259 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
10261 rest = java_complete_tree (rest);
10262 if (rest == error_mark_node)
10263 return error_mark_node;
10264 rest = fold (rest);
10266 return merge_string_cste (string, rest, invert);
10268 return NULL_TREE;
10271 /* Implement the `+' operator. Does static optimization if possible,
10272 otherwise create (if necessary) and append elements to a
10273 StringBuffer. The StringBuffer will be carried around until it is
10274 used for a function call or an assignment. Then toString() will be
10275 called on it to turn it into a String object. */
10277 static tree
10278 build_string_concatenation (op1, op2)
10279 tree op1, op2;
10281 tree result;
10283 /* Try to do some static optimization */
10284 if ((result = string_constant_concatenation (op1, op2)))
10285 return result;
10287 /* If operands are string constant, turn then into object references */
10289 if (TREE_CODE (op1) == STRING_CST)
10290 op1 = patch_string_cst (op1);
10291 if (TREE_CODE (op2) == STRING_CST)
10292 op2 = patch_string_cst (op2);
10294 /* If OP1 isn't already a StringBuffer, create and
10295 initialize a new one */
10296 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
10298 /* Two solutions here:
10299 1) OP1 is a string reference, we call new StringBuffer(OP1)
10300 2) Op2 is something else, we call new StringBuffer().append(OP1). */
10301 if (JSTRING_TYPE_P (TREE_TYPE (op1)))
10302 op1 = BUILD_STRING_BUFFER (op1);
10303 else
10305 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
10306 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
10310 /* No longer the last node holding a crafted StringBuffer */
10311 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
10312 /* Create a node for `{new...,xxx}.append (op2)' */
10313 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
10314 /* Mark the last node holding a crafted StringBuffer */
10315 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
10317 return op1;
10320 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
10321 StringBuffer. If no string were found to be patched, return
10322 NULL. */
10324 static tree
10325 patch_string (node)
10326 tree node;
10328 if (TREE_CODE (node) == STRING_CST)
10329 return patch_string_cst (node);
10330 else if (IS_CRAFTED_STRING_BUFFER_P (node))
10332 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
10333 return java_complete_tree (make_qualified_primary (node, invoke, 0));
10335 return NULL_TREE;
10338 /* Build the internal representation of a string constant. */
10340 static tree
10341 patch_string_cst (node)
10342 tree node;
10344 int location;
10345 push_obstacks (&permanent_obstack, &permanent_obstack);
10346 node = get_identifier (TREE_STRING_POINTER (node));
10347 location = alloc_name_constant (CONSTANT_String, node);
10348 node = build_ref_from_constant_pool (location);
10349 TREE_TYPE (node) = promote_type (string_type_node);
10350 TREE_CONSTANT (node) = 1;
10351 return node;
10354 /* Build an incomplete unary operator expression. */
10356 static tree
10357 build_unaryop (op_token, op_location, op1)
10358 int op_token, op_location;
10359 tree op1;
10361 enum tree_code op;
10362 tree unaryop;
10363 switch (op_token)
10365 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
10366 case MINUS_TK: op = NEGATE_EXPR; break;
10367 case NEG_TK: op = TRUTH_NOT_EXPR; break;
10368 case NOT_TK: op = BIT_NOT_EXPR; break;
10369 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
10370 op_token);
10373 unaryop = build1 (op, NULL_TREE, op1);
10374 TREE_SIDE_EFFECTS (unaryop) = 1;
10375 /* Store the location of the operator, for better error report. The
10376 string of the operator will be rebuild based on the OP value. */
10377 EXPR_WFL_LINECOL (unaryop) = op_location;
10378 return unaryop;
10381 /* Special case for the ++/-- operators, since they require an extra
10382 argument to build, which is set to NULL and patched
10383 later. IS_POST_P is 1 if the operator, 0 otherwise. */
10385 static tree
10386 build_incdec (op_token, op_location, op1, is_post_p)
10387 int op_token, op_location;
10388 tree op1;
10389 int is_post_p;
10391 static enum tree_code lookup [2][2] =
10393 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
10394 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
10396 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
10397 NULL_TREE, op1, NULL_TREE);
10398 TREE_SIDE_EFFECTS (node) = 1;
10399 /* Store the location of the operator, for better error report. The
10400 string of the operator will be rebuild based on the OP value. */
10401 EXPR_WFL_LINECOL (node) = op_location;
10402 return node;
10405 /* Build an incomplete cast operator, based on the use of the
10406 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
10407 set. java_complete_tree is trained to walk a CONVERT_EXPR even
10408 though its type is already set. */
10410 static tree
10411 build_cast (location, type, exp)
10412 int location;
10413 tree type, exp;
10415 tree node = build1 (CONVERT_EXPR, type, exp);
10416 EXPR_WFL_LINECOL (node) = location;
10417 return node;
10420 /* 15.14 Unary operators. We return error_mark_node in case of error,
10421 but preserve the type of NODE if the type is fixed. */
10423 static tree
10424 patch_unaryop (node, wfl_op)
10425 tree node;
10426 tree wfl_op;
10428 tree op = TREE_OPERAND (node, 0);
10429 tree op_type = TREE_TYPE (op);
10430 tree prom_type, value;
10431 int code = TREE_CODE (node);
10432 int error_found = 0;
10434 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10436 switch (code)
10438 /* 15.13.2 Postfix Increment Operator ++ */
10439 case POSTINCREMENT_EXPR:
10440 /* 15.13.3 Postfix Increment Operator -- */
10441 case POSTDECREMENT_EXPR:
10442 /* 15.14.1 Prefix Increment Operator ++ */
10443 case PREINCREMENT_EXPR:
10444 /* 15.14.2 Prefix Decrement Operator -- */
10445 case PREDECREMENT_EXPR:
10446 if (!DECL_P (op) && !(TREE_CODE (op) == INDIRECT_REF
10447 && JPRIMITIVE_TYPE_P (TREE_TYPE (op))))
10449 parse_error_context (wfl_operator, "Invalid argument to `%s'",
10450 operator_string (node));
10451 TREE_TYPE (node) = error_mark_node;
10452 error_found = 1;
10454 else if (FIELD_FINAL (op))
10456 parse_error_context
10457 (wfl_op, "Can't assign a value to the final variable `%s'",
10458 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl_op)));
10459 TREE_TYPE (node) = error_mark_node;
10460 error_found = 1;
10462 /* From now on, we know that op if a variable and that it has a
10463 valid wfl. We use wfl_op to locate errors related to the
10464 ++/-- operand. */
10465 else if (!JNUMERIC_TYPE_P (op_type))
10467 parse_error_context
10468 (wfl_op, "Invalid argument type `%s' to `%s'",
10469 lang_printable_name (op_type, 0), operator_string (node));
10470 TREE_TYPE (node) = error_mark_node;
10471 error_found = 1;
10473 else
10475 /* Before the addition, binary numeric promotion if performed on
10476 both operands */
10477 value = integer_one_node;
10478 prom_type = binary_numeric_promotion (op_type, TREE_TYPE (value),
10479 &op, &value);
10480 /* And write the promoted increment back */
10481 TREE_OPERAND (node, 1) = value;
10483 break;
10485 /* 15.14.3 Unary Plus Operator + */
10486 case UNARY_PLUS_EXPR:
10487 /* 15.14.4 Unary Minus Operator - */
10488 case NEGATE_EXPR:
10489 if (!JNUMERIC_TYPE_P (op_type))
10491 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
10492 TREE_TYPE (node) = error_mark_node;
10493 error_found = 1;
10495 /* Unary numeric promotion is performed on operand */
10496 else
10498 prom_type = promote_type (op_type);
10499 op = convert (prom_type, op);
10500 if (code == UNARY_PLUS_EXPR)
10501 node = op;
10503 break;
10505 /* 15.14.5 Bitwise Complement Operator ~ */
10506 case BIT_NOT_EXPR:
10507 if (!JINTEGRAL_TYPE_P (op_type))
10509 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
10510 TREE_TYPE (node) = error_mark_node;
10511 error_found = 1;
10513 else
10515 prom_type = promote_type (op_type);
10516 op = convert (prom_type, op);
10518 break;
10520 /* 15.14.6 Logical Complement Operator ! */
10521 case TRUTH_NOT_EXPR:
10522 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
10524 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
10525 TREE_TYPE (node) = boolean_type_node;
10526 error_found = 1;
10528 else
10529 prom_type = boolean_type_node;
10530 break;
10532 /* 15.15 Cast Expression */
10533 case CONVERT_EXPR:
10534 value = patch_cast (node, wfl_operator);
10535 if (value == error_mark_node)
10537 TREE_TYPE (node) = error_mark_node;
10538 error_found = 1;
10540 else
10541 node = value;
10542 break;
10545 /* Check variable initialization */
10546 if (not_initialized_as_it_should_p (op))
10548 ERROR_VARIABLE_NOT_INITIALIZED (wfl_op, DECL_NAME (op));
10549 INITIALIZED_P (op) = 1;
10552 if (error_found)
10553 return error_mark_node;
10554 /* In the case of UNARY_PLUS_EXPR, we replaced NODE by a new one */
10555 else if (code != UNARY_PLUS_EXPR && code != CONVERT_EXPR)
10557 TREE_OPERAND (node, 0) = op;
10558 TREE_TYPE (node) = prom_type;
10560 return fold (node);
10563 /* Generic type resolution that sometimes takes place during node
10564 patching. Returned the resolved type or generate an error
10565 message. Return the resolved type or NULL_TREE. */
10567 static tree
10568 resolve_type_during_patch (type)
10569 tree type;
10571 if (unresolved_type_p (type, NULL))
10573 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
10574 if (!type_decl)
10576 parse_error_context (type,
10577 "Class `%s' not found in type declaration",
10578 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
10579 return NULL_TREE;
10581 else
10582 return TREE_TYPE (type_decl);
10584 return type;
10586 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
10587 found. Otherwise NODE or something meant to replace it is returned. */
10589 static tree
10590 patch_cast (node, wfl_operator)
10591 tree node;
10592 tree wfl_operator;
10594 tree op = TREE_OPERAND (node, 0);
10595 tree op_type = TREE_TYPE (op);
10596 tree cast_type = TREE_TYPE (node);
10597 char *t1;
10599 /* First resolve OP_TYPE if unresolved */
10600 if (!(cast_type = resolve_type_during_patch (cast_type)))
10601 return error_mark_node;
10603 /* Check on cast that are proven correct at compile time */
10604 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
10606 static tree convert_narrow ();
10607 /* Same type */
10608 if (cast_type == op_type)
10609 return node;
10611 /* Try widening/narowwing convertion. Potentially, things need
10612 to be worked out in gcc so we implement the extreme cases
10613 correctly. fold_convert() needs to be fixed. */
10614 return convert (cast_type, op);
10617 /* The remaining legal casts involve conversion between reference
10618 types. Check for their compile time correctness. */
10619 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
10620 && valid_ref_assignconv_cast_p (cast_type, op_type, 1))
10622 TREE_TYPE (node) = promote_type (cast_type);
10623 /* Now, the case can be determined correct at compile time if
10624 OP_TYPE can be converted into CAST_TYPE by assignment
10625 conversion (5.2) */
10627 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
10628 return node;
10630 /* The cast requires a run-time check */
10631 return build (CALL_EXPR, promote_type (cast_type),
10632 build_address_of (soft_checkcast_node),
10633 tree_cons (NULL_TREE, build_class_ref (cast_type),
10634 build_tree_list (NULL_TREE, op)),
10635 NULL_TREE);
10638 /* Any other casts are proven incorrect at compile time */
10639 t1 = strdup (lang_printable_name (op_type, 0));
10640 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
10641 t1, lang_printable_name (cast_type, 0));
10642 free (t1);
10643 return error_mark_node;
10646 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
10647 a list of indices. */
10648 static tree
10649 build_array_ref (location, array, index)
10650 int location;
10651 tree array, index;
10653 tree node = build (ARRAY_REF, NULL_TREE, array, index);
10654 EXPR_WFL_LINECOL (node) = location;
10655 return node;
10658 /* 15.12 Array Access Expression */
10660 static tree
10661 patch_array_ref (node, wfl_array, wfl_index)
10662 tree node, wfl_array, wfl_index;
10664 tree array = TREE_OPERAND (node, 0);
10665 tree array_type = TREE_TYPE (array);
10666 tree index = TREE_OPERAND (node, 1);
10667 tree index_type = TREE_TYPE (index);
10668 tree promoted_index_type;
10669 int error_found = 0;
10671 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10673 if (not_initialized_as_it_should_p (array))
10675 ERROR_VARIABLE_NOT_INITIALIZED (wfl_array, DECL_NAME (array));
10676 INITIALIZED_P (array) = 1;
10679 if (TREE_CODE (array_type) == POINTER_TYPE)
10680 array_type = TREE_TYPE (array_type);
10682 /* The array reference must be an array */
10683 if (!TYPE_ARRAY_P (array_type))
10685 parse_error_context
10686 (wfl_operator, "`[]' can only be applied to arrays. It can't be "
10687 "applied to `%s'", lang_printable_name (array_type, 0));
10688 TREE_TYPE (node) = error_mark_node;
10689 error_found = 1;
10692 /* The array index underdoes unary numeric promotion. The promoted
10693 type must be int */
10694 promoted_index_type = promote_type (index_type);
10695 if (promoted_index_type != int_type_node)
10697 int could_cast = valid_cast_to_p (index_type, int_type_node);
10698 parse_error_context
10699 (wfl_operator,
10700 (could_cast ? "Incompatible type for `[]'. Explicit cast needed to "
10701 "convert `%s' to `int'" : "Incompatible type for `[]'. "
10702 "Can't convert `%s' to `int'"),
10703 lang_printable_name (index_type, 0));
10704 TREE_TYPE (node) = error_mark_node;
10705 error_found = 1;
10708 /* Now if the index is a var/parm decl, check on its initialization */
10709 if (not_initialized_as_it_should_p (index))
10711 ERROR_VARIABLE_NOT_INITIALIZED (wfl_index, DECL_NAME (index));
10712 INITIALIZED_P (index) = 1;
10715 if (error_found)
10716 return error_mark_node;
10717 index = convert (promoted_index_type, index);
10719 if (TREE_CODE (array_type) == RECORD_TYPE)
10720 array_type = promote_type (TYPE_ARRAY_ELEMENT (array_type));
10721 if (flag_emit_class_files)
10723 TREE_OPERAND (node, 0)= array;
10724 TREE_OPERAND (node, 1)= index;
10726 else
10727 node = build_java_arrayaccess (array, array_type, index);
10728 TREE_TYPE (node) = array_type;
10729 return node;
10732 /* 15.9 Array Creation Expressions */
10734 static tree
10735 build_newarray_node (type, dims, extra_dims)
10736 tree type;
10737 tree dims;
10738 int extra_dims;
10740 tree node =
10741 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
10742 build_int_2 (extra_dims, 0));
10743 return node;
10746 static tree
10747 patch_newarray (node)
10748 tree node;
10750 tree type = TREE_OPERAND (node, 0);
10751 tree dims = TREE_OPERAND (node, 1);
10752 tree cdim, array_type;
10753 int error_found = 0;
10754 int ndims = 0;
10755 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
10756 int total_dims;
10758 /* Dimension types are verified. It's better for the types to be
10759 verified in order. */
10760 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
10762 int dim_error = 0;
10763 tree dim = TREE_VALUE (cdim);
10765 /* Dim might have been saved during its evaluation */
10766 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
10768 /* The type of each specified dimension must be an integral type. */
10769 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
10770 dim_error = 1;
10772 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
10773 promoted type must be int. */
10774 else
10776 dim = convert (promote_type (TREE_TYPE (dim)), dim);
10777 if (TREE_TYPE (dim) != int_type_node)
10778 dim_error = 1;
10781 /* Report errors on types here */
10782 if (dim_error)
10784 parse_error_context
10785 (TREE_PURPOSE (cdim),
10786 "Incompatible type for dimension in array creation expression. "
10787 "%s convert `%s' to `int'",
10788 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
10789 "Explicit cast needed to" : "Can't"),
10790 lang_printable_name (TREE_TYPE (dim), 0));
10791 error_found = 1;
10794 /* Check for uninitialized variables */
10795 if (not_initialized_as_it_should_p (dim))
10797 ERROR_VARIABLE_NOT_INITIALIZED (TREE_PURPOSE (cdim),
10798 DECL_NAME (dim));
10799 INITIALIZED_P (dim) = 1;
10800 error_found = 1;
10803 TREE_PURPOSE (cdim) = NULL_TREE;
10806 /* Resolve array base type if unresolved */
10807 if (!(type = resolve_type_during_patch (type)))
10808 error_found = 1;
10810 if (error_found)
10812 /* We don't want further evaluation of this bogus array creation
10813 operation */
10814 TREE_TYPE (node) = error_mark_node;
10815 return error_mark_node;
10818 /* The node is transformed into a function call. Things are done
10819 differently according to the number of dimensions. If the number
10820 of dimension is equal to 1, then the nature of the base type
10821 (primitive or not) matters. */
10822 total_dims = xdims + ndims;
10823 if (total_dims == 1)
10825 if (JPRIMITIVE_TYPE_P (type))
10827 int type_code;
10828 if (type == boolean_type_node)
10829 type_code = 4;
10830 else if (type == char_type_node)
10831 type_code = 5;
10832 else if (type == float_type_node)
10833 type_code = 6;
10834 else if (type == double_type_node)
10835 type_code = 7;
10836 else if (type == byte_type_node)
10837 type_code = 8;
10838 else if (type == short_type_node)
10839 type_code = 9;
10840 else if (type == int_type_node)
10841 type_code = 10;
10842 else if (type == long_type_node)
10843 type_code = 11;
10844 else
10845 fatal ("Can't compute type code - patch_newarray");
10846 return build_newarray (type_code, TREE_VALUE (dims));
10848 else
10849 return build_anewarray (type, TREE_VALUE (dims));
10852 /* Add extra dimensions as unknown dimensions */
10853 while (xdims--)
10854 dims =
10855 chainon (dims, build_tree_list (NULL_TREE, integer_negative_one_node));
10856 dims = chainon (dims, build_tree_list (NULL_TREE, integer_zero_node));
10858 /* Can't reuse what's already written in expr.c because it uses the
10859 JVM stack representation. Provide a build_multianewarray. FIXME */
10860 array_type = type;
10861 for (cdim = TREE_CHAIN (dims); cdim; cdim = TREE_CHAIN (cdim))
10862 array_type = build_java_array_type (promote_type (array_type),
10863 TREE_CODE (cdim) == INTEGER_CST ?
10864 TREE_INT_CST_LOW (cdim) : -1);
10865 return build (CALL_EXPR,
10866 promote_type (array_type),
10867 build_address_of (soft_multianewarray_node),
10868 tree_cons (NULL_TREE, build_class_ref (array_type),
10869 tree_cons (NULL_TREE,
10870 build_int_2 (total_dims, 0), dims )),
10871 NULL_TREE);
10874 static tree
10875 build_this (location)
10876 int location;
10878 tree node = build_wfl_node (this_identifier_node, input_filename, 0, 0);
10879 TREE_SET_CODE (node, THIS_EXPR);
10880 EXPR_WFL_LINECOL (node) = location;
10881 return node;
10884 /* 14.15 The return statement. It builds a modify expression that
10885 assigns the returned value to the RESULT_DECL that hold the value
10886 to be returned. */
10888 static tree
10889 build_return (location, op)
10890 int location;
10891 tree op;
10893 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
10894 EXPR_WFL_LINECOL (node) = location;
10895 node = build_debugable_stmt (location, node);
10896 return node;
10899 static tree
10900 patch_return (node)
10901 tree node;
10903 tree return_exp = TREE_OPERAND (node, 0);
10904 tree meth = current_function_decl;
10905 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
10906 tree modify;
10907 int error_found = 0;
10909 TREE_TYPE (node) = error_mark_node;
10910 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10912 /* It's invalid to have a return value within a function that is
10913 declared with the keyword void or that is a constructor */
10914 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
10915 error_found = 1;
10917 /* It's invalid to have a no return value within a function that
10918 isn't declared with the keyword `void' */
10919 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
10920 error_found = 2;
10922 if (error_found)
10924 char *t = strdup (lang_printable_name (mtype, 0));
10925 parse_error_context (wfl_operator, "`return' with%s value from `%s %s'",
10926 (error_found == 1 ? "" : "out"), t,
10927 lang_printable_name (meth, 0));
10928 free (t);
10929 return error_mark_node;
10932 /* If we have a return_exp, build a modify expression and expand it */
10933 if (return_exp)
10935 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), return_exp);
10936 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
10937 modify = java_complete_tree (modify);
10938 if (modify != error_mark_node)
10940 TREE_SIDE_EFFECTS (modify) = 1;
10941 TREE_OPERAND (node, 0) = modify;
10943 else
10944 return error_mark_node;
10946 TREE_TYPE (node) = void_type_node;
10947 TREE_SIDE_EFFECTS (node) = 1;
10948 return node;
10951 /* 14.8 The if Statement */
10953 static tree
10954 build_if_else_statement (location, expression, if_body, else_body)
10955 int location;
10956 tree expression, if_body, else_body;
10958 tree node;
10959 /* FIXME: make else body be a void node, where this function is
10960 called */
10961 if (!else_body)
10962 else_body = build (COMPOUND_EXPR, void_type_node, NULL_TREE, NULL_TREE);
10963 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
10964 EXPR_WFL_LINECOL (node) = location;
10965 node = build_debugable_stmt (location, node);
10966 return node;
10969 static tree
10970 patch_if_else_statement (node)
10971 tree node;
10973 tree expression = TREE_OPERAND (node, 0);
10975 TREE_TYPE (node) = error_mark_node;
10976 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10978 /* The type of expression must be boolean */
10979 if (TREE_TYPE (expression) != boolean_type_node
10980 && TREE_TYPE (expression) != promoted_boolean_type_node)
10982 parse_error_context
10983 (wfl_operator,
10984 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
10985 lang_printable_name (TREE_TYPE (expression), 0));
10986 return error_mark_node;
10989 TREE_TYPE (node) = void_type_node;
10990 TREE_SIDE_EFFECTS (node) = 1;
10991 return node;
10994 /* 14.6 Labeled Statements */
10996 /* Action taken when a lableled statement is parsed. a new
10997 LABELED_BLOCK_EXPR is created. No statement is attached to the
10998 label, yet. */
11000 static tree
11001 build_labeled_block (location, label)
11002 int location;
11003 tree label;
11005 tree label_name = merge_qualified_name (label_id, label);
11006 tree label_decl, node;
11008 /* Issue a warning if we try to reuse a label that was previously
11009 declared */
11010 if (IDENTIFIER_LOCAL_VALUE (label_name))
11012 EXPR_WFL_LINECOL (wfl_operator) = location;
11013 parse_warning_context (wfl_operator, "Declaration of `%s' shadows "
11014 "a previous declaration",
11015 IDENTIFIER_POINTER (label));
11016 EXPR_WFL_LINECOL (wfl_operator) =
11017 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
11018 parse_warning_context (wfl_operator, "This is the location of the "
11019 "previous declaration of label `%s'",
11020 IDENTIFIER_POINTER (label));
11021 java_warning_count--;
11024 label_decl = create_label_decl (label_name);
11025 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
11026 EXPR_WFL_LINECOL (node) = location;
11027 TREE_SIDE_EFFECTS (node) = 1;
11028 return node;
11031 /* Generate a label crafting a unique name for it. This is used to
11032 implicitely label loops that aren't the body part of labeled
11033 statement. */
11035 static tree
11036 generate_labeled_block ()
11038 return build_labeled_block (0, generate_name ());
11041 /* A labeled statement LBE is attached a statement. */
11043 static tree
11044 complete_labeled_statement (lbe, statement)
11045 tree lbe; /* Labeled block expr */
11046 tree statement;
11048 /* In anyways, tie the loop to its statement */
11049 LABELED_BLOCK_BODY (lbe) = statement;
11051 /* Ok, if statement is a for loop, we have to attach the labeled
11052 statement to the block the for loop belongs to and return the
11053 block instead */
11054 if (TREE_CODE (statement) == LOOP_EXPR && IS_FOR_LOOP_P (statement))
11056 java_method_add_stmt (current_function_decl, lbe);
11057 return exit_block ();
11060 return lbe;
11063 /* 14.10, 14.11, 14.12 Loop Statements */
11065 /* Create an empty LOOP_EXPR and make it the last in the nested loop
11066 list. */
11068 static tree
11069 build_new_loop (loop_body)
11070 tree loop_body;
11072 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
11073 TREE_SIDE_EFFECTS (loop) = 1;
11074 PUSH_LOOP (loop);
11075 return loop;
11078 /* Create a loop body according to the following structure:
11079 COMPOUND_EXPR
11080 COMPOUND_EXPR (loop main body)
11081 EXIT_EXPR (this order is for while/for loops.
11082 LABELED_BLOCK_EXPR the order is reversed for do loops)
11083 LABEL_DECL (continue occurding here branche at the
11084 BODY end of this labeled block)
11085 INCREMENT (if any)
11087 REVERSED, if non zero, tells that the loop condition expr comes
11088 after the body, like in the do-while loop.
11090 To obtain a loop, the loop body structure described above is
11091 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
11093 LABELED_BLOCK_EXPR
11094 LABEL_DECL (use this label to exit the loop)
11095 LOOP_EXPR
11096 <structure described above> */
11098 static tree
11099 build_loop_body (location, condition, reversed)
11100 int location;
11101 tree condition;
11102 int reversed;
11104 tree first, second, body;
11106 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
11107 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
11108 condition = build_debugable_stmt (location, condition);
11109 TREE_SIDE_EFFECTS (condition) = 1;
11111 body = generate_labeled_block ();
11112 first = (reversed ? body : condition);
11113 second = (reversed ? condition : body);
11114 return
11115 build (COMPOUND_EXPR, NULL_TREE,
11116 build (COMPOUND_EXPR, NULL_TREE, first, second), size_zero_node);
11119 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
11120 their order) on the current loop. Unlink the current loop from the
11121 loop list. */
11123 static tree
11124 complete_loop_body (location, condition, body, reversed)
11125 int location;
11126 tree condition, body;
11127 int reversed;
11129 tree to_return = ctxp->current_loop;
11130 tree loop_body = LOOP_EXPR_BODY (to_return);
11131 if (condition)
11133 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
11134 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
11135 The real EXIT_EXPR is one operand further. */
11136 EXPR_WFL_LINECOL (cnode) = location;
11137 /* This one is for accurate error reports */
11138 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
11139 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
11141 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
11142 POP_LOOP ();
11143 return to_return;
11146 /* Tailored version of complete_loop_body for FOR loops, when FOR
11147 loops feature the condition part */
11149 static tree
11150 complete_for_loop (location, condition, update, body)
11151 int location;
11152 tree condition, update, body;
11154 /* Put the condition and the loop body in place */
11155 tree loop = complete_loop_body (location, condition, body, 0);
11156 /* LOOP is the current loop which has been now popped of the loop
11157 stack. Install the update block */
11158 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
11159 return loop;
11162 /* If the loop isn't surrounded by a labeled statement, create one and
11163 insert LOOP as it's body. */
11165 static tree
11166 patch_loop_statement (loop)
11167 tree loop;
11169 tree loop_label, to_return_as_loop;
11171 if (LOOP_HAS_LABEL_P (loop))
11173 loop_label = ctxp->current_labeled_block;
11174 to_return_as_loop = loop;
11176 else
11178 loop_label = generate_labeled_block ();
11179 LABELED_BLOCK_BODY (loop_label) = loop;
11180 PUSH_LABELED_BLOCK (loop_label);
11181 to_return_as_loop = loop_label;
11183 TREE_TYPE (to_return_as_loop) = void_type_node;
11184 return to_return_as_loop;
11187 /* 14.13, 14.14: break and continue Statements */
11189 /* Build a break or a continue statement. a null NAME indicates an
11190 unlabeled break/continue statement. */
11192 static tree
11193 build_bc_statement (location, is_break, name)
11194 int location, is_break;
11195 tree name;
11197 tree break_continue, label_block_expr = NULL_TREE;
11199 if (name)
11201 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
11202 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
11203 /* Null means that we don't have a target for this named
11204 break/continue. In this case, we make the target to be the
11205 label name, so that the error can be reported accuratly in
11206 patch_bc_statement. */
11207 label_block_expr = EXPR_WFL_NODE (name);
11209 /* Unlabeled break/continue will be handled during the
11210 break/continue patch operation */
11211 break_continue
11212 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
11214 IS_BREAK_STMT_P (break_continue) = is_break;
11215 TREE_SIDE_EFFECTS (break_continue) = 1;
11216 EXPR_WFL_LINECOL (break_continue) = location;
11217 break_continue = build_debugable_stmt (location, break_continue);
11218 return break_continue;
11221 /* Verification of a break/continue statement. */
11223 static tree
11224 patch_bc_statement (node)
11225 tree node;
11227 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
11228 int is_unlabeled = 0;
11229 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11231 /* Not having a target means that the break/continue statement is
11232 unlabeled. We try to find a decent label for it */
11233 if (!bc_label)
11235 is_unlabeled = 1;
11236 /* There should be a loop/switch to branch to */
11237 if (ctxp->current_loop)
11239 if (TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
11241 /* At that stage, we're in the loop body, which is
11242 encapsulated around a LABELED_BLOCK_EXPR. So searching
11243 the current loop label requires us to consider the
11244 labeled block before the current one. */
11245 if (!LOOP_HAS_LABEL_SKIP_P (ctxp->current_loop))
11246 fatal ("unlabeled loop has no installed label -- "
11247 "patch_bc_statement");
11248 bc_label = TREE_CHAIN (ctxp->current_labeled_block);
11250 /* For a SWITCH statement, this is the current one */
11251 else
11252 bc_label = ctxp->current_labeled_block;
11254 /* Not having a loop to break/continue to is an error */
11255 else
11257 parse_error_context (wfl_operator, "`%s' must be in loop%s",
11258 (IS_BREAK_STMT_P (node) ? "break" : "continue"),
11259 (IS_BREAK_STMT_P (node) ? " or switch" : ""));
11260 return error_mark_node;
11263 /* Having an identifier here means that the target is unknown. */
11264 else if (TREE_CODE (bc_label) == IDENTIFIER_NODE)
11266 parse_error_context (wfl_operator, "No label definition found for `%s'",
11267 IDENTIFIER_POINTER (bc_label));
11268 return error_mark_node;
11271 /* Find the statement we're targeting. */
11272 target_stmt = LABELED_BLOCK_BODY (bc_label);
11274 /* 14.13 The break Statement */
11275 if (IS_BREAK_STMT_P (node))
11277 /* Named break are always fine, as far as they have a target
11278 (already verified). Anonymous break need to target
11279 while/do/for/switch */
11280 if (is_unlabeled &&
11281 !(TREE_CODE (target_stmt) == LOOP_EXPR /* do/while/for */
11282 || TREE_CODE (target_stmt) == SWITCH_EXPR)) /* switch FIXME */
11284 parse_error_context (wfl_operator,
11285 "`break' must be in loop or switch");
11286 return error_mark_node;
11288 /* If previously unlabeled, install the new found label */
11289 if (is_unlabeled)
11290 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
11292 /* 14.14 The continue Statement */
11293 /* The continue statement must always target a loop */
11294 else
11296 if (TREE_CODE (target_stmt) != LOOP_EXPR) /* do/while/for */
11298 parse_error_context (wfl_operator, "`continue' must be in loop");
11299 return error_mark_node;
11301 /* Everything looks good. We can fix the `continue' jump to go
11302 at the place in the loop were the continue is. The continue
11303 is the current labeled block, by construction. */
11304 EXIT_BLOCK_LABELED_BLOCK (node) = ctxp->current_labeled_block;
11307 /* Our break/continue don't return values. */
11308 TREE_TYPE (node) = void_type_node;
11309 /* Encapsulate the break within a compound statement so that it's
11310 expanded all the times by expand_expr (and not clobered
11311 sometimes, like after a if statement) */
11312 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
11313 TREE_SIDE_EFFECTS (node) = 1;
11314 return node;
11317 /* Process the exit expression belonging to a loop. Its type must be
11318 boolean. */
11320 static tree
11321 patch_exit_expr (node)
11322 tree node;
11324 tree expression = TREE_OPERAND (node, 0);
11325 TREE_TYPE (node) = error_mark_node;
11326 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11328 /* The type of expression must be boolean */
11329 if (TREE_TYPE (expression) != boolean_type_node)
11331 parse_error_context
11332 (wfl_operator,
11333 "Incompatible type for loop conditional. Can't convert `%s' to "
11334 "`boolean'",
11335 lang_printable_name (TREE_TYPE (expression), 0));
11336 return error_mark_node;
11338 /* Now we know things are allright, invert the condition, fold and
11339 return */
11340 TREE_OPERAND (node, 0) =
11341 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
11342 TREE_TYPE (node) = void_type_node;
11343 return node;
11346 /* 14.9 Switch statement */
11348 static tree
11349 patch_switch_statement (node)
11350 tree node;
11352 int error_found = 0;
11353 tree se = TREE_OPERAND (node, 0), se_type, sb;
11354 tree default_found = NULL_TREE;
11356 /* Complete the switch expression */
11357 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
11358 se_type = TREE_TYPE (se);
11359 /* The type of the switch expression must be char, byte, short or
11360 int */
11361 if (!JINTEGRAL_TYPE_P (se_type))
11363 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11364 parse_error_context (wfl_operator, "Incompatible type for `switch'. "
11365 "Can't convert `%s' to `int'",
11366 lang_printable_name (se_type, 0));
11367 /* This is what java_complete_tree will check */
11368 TREE_OPERAND (node, 0) = error_mark_node;
11369 return error_mark_node;
11372 /* Process the switch body. We should have a list of TREE_LIST. The
11373 PURPOSE of each node should be a list of case values, VALUE
11374 should be the associated block. We try to process all cases and
11375 defaults before returning, possibly finding errors. */
11376 TREE_OPERAND (node, 1) = nreverse (TREE_OPERAND (node, 1));
11377 for (sb = TREE_OPERAND (node, 1); sb; sb = TREE_CHAIN (sb))
11379 tree label;
11381 /* If we don't have a TREE_LIST here, we have a statement inside
11382 the switch that isn't tied to a label. This error is caught
11383 by the parser and we don't have to report it here. */
11385 TREE_PURPOSE (sb) = nreverse (TREE_PURPOSE (sb));
11386 for (label = TREE_PURPOSE (sb); label; label = TREE_CHAIN (label))
11388 tree case_expr;
11390 /* Verification of the default label */
11391 if (TREE_CODE (label) == DEFAULT_EXPR)
11393 /* Only one default label is allowed per switch
11394 statement */
11395 if (default_found)
11397 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (label);
11398 parse_error_context (wfl_operator,
11399 "Duplicate case label: `default'");
11400 error_found = 1;
11402 else
11403 default_found = label;
11404 continue;
11406 /* Verification of case labels */
11407 else
11409 case_expr = java_complete_tree (TREE_OPERAND (label, 0));
11410 if (case_expr == error_mark_node)
11411 continue;
11413 /* First, the case expression must be constant */
11414 case_expr = fold (case_expr);
11415 if (!TREE_CONSTANT (case_expr))
11417 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (label);
11418 parse_error_context (label, "Constant expression required");
11419 error_found = 1;
11420 break;
11423 /* It must be assignable to the type of the switch
11424 expression. */
11425 if (!try_builtin_assignconv (NULL_TREE, se_type, case_expr))
11427 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (label);
11428 parse_error_context
11429 (wfl_operator,
11430 "Incompatible type for case. Can't convert `%s' to `int'",
11431 lang_printable_name (TREE_TYPE (case_expr), 0));
11432 error_found = 1;
11433 break;
11436 /* Multiple instance of a case label bearing the same
11437 value is checked during code generation. The case
11438 expression is allright so far. */
11439 TREE_OPERAND (label, 0) = case_expr;
11443 /* First TREE_VALUE should be the block tied to this list of
11444 cases. Check that this block exists and the walk it */
11445 if (TREE_VALUE (sb))
11447 TREE_VALUE (sb) = java_complete_tree (TREE_VALUE (sb));
11448 if (TREE_VALUE (sb) == error_mark_node)
11449 error_found = 1;
11453 /* Ready to return */
11454 if (error_found)
11456 TREE_TYPE (node) = error_mark_node;
11457 return error_mark_node;
11459 TREE_TYPE (node) = void_type_node;
11460 TREE_SIDE_EFFECTS (node) = 1;
11461 return node;
11464 /* Do the expansion of a Java switch. With Gcc, switches are front-end
11465 dependant things, but they rely on gcc routines. This function is
11466 placed here because it uses things defined locally in parse.y. */
11468 static tree case_identity (t, v)
11469 tree t __attribute__ ((__unused__));
11470 tree v;
11472 return v;
11475 void
11476 java_expand_switch (exp)
11477 tree exp;
11479 tree sb;
11480 expand_start_case (0, TREE_OPERAND (exp, 0), int_type_node, "switch");
11482 for (sb = TREE_OPERAND (exp, 1); sb; sb = TREE_CHAIN (sb))
11484 /* We have a list of TREE_LIST. PURPOSE is the case value, and
11485 when it exists, VALUE is the associated block */
11487 /* The first CASE element should contain the associated block,
11488 if any. All other should be case statements related to the
11489 same block */
11490 tree label;
11491 for (label = TREE_PURPOSE (sb); label; label = TREE_CHAIN (label))
11493 tree label_decl = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
11494 if (TREE_CODE (label) == CASE_EXPR)
11496 tree duplicate;
11497 if (pushcase (TREE_OPERAND (label, 0), case_identity,
11498 label_decl, &duplicate) == 2)
11500 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (label);
11501 parse_error_context
11502 (wfl_operator, "Duplicate case label: `%s'",
11503 print_int_node (TREE_OPERAND (label, 0)));
11506 else
11507 pushcase (NULL_TREE, 0, label_decl, NULL);
11509 /* Expand the associated block, if any */
11510 if (TREE_VALUE (sb))
11511 expand_expr_stmt (TREE_VALUE (sb));
11513 expand_end_case (TREE_OPERAND (exp, 0));
11516 /* 14.18 The try statement */
11518 /* Wrap BLOCK around a LABELED_BLOCK, set DECL to the newly generated
11519 exit labeld and issue a jump to FINALLY_LABEL:
11521 LABELED_BLOCK
11522 BLOCK
11523 <orignal_statments>
11524 DECL = &LABEL_DECL
11525 GOTO_EXPR
11526 FINALLY_LABEL
11527 LABEL_DECL */
11529 static tree
11530 build_jump_to_finally (block, decl, finally_label, type)
11531 tree block, decl, finally_label, type;
11533 tree stmt;
11534 tree new_block = build (LABELED_BLOCK_EXPR, type,
11535 create_label_decl (generate_name ()), block);
11537 stmt = build (MODIFY_EXPR, void_type_node, decl,
11538 build_address_of (LABELED_BLOCK_LABEL (new_block)));
11539 TREE_SIDE_EFFECTS (stmt) = 1;
11540 add_stmt_to_block (block, type, stmt);
11541 stmt = build (GOTO_EXPR, void_type_node, finally_label);
11542 TREE_SIDE_EFFECTS (stmt) = 1;
11543 add_stmt_to_block (block, type, stmt);
11544 return new_block;
11547 static tree
11548 build_try_statement (location, try_block, catches, finally)
11549 int location;
11550 tree try_block, catches, finally;
11552 tree node, rff;
11554 if (finally)
11556 /* This block defines a scope for the entire try[-catch]-finally
11557 sequence. It hold a local variable used to return from the
11558 finally using a computed goto. We call it
11559 return_from_finally (RFF). */
11560 rff = build_decl_no_layout (VAR_DECL, generate_name (),
11561 return_address_type_node);
11563 /* Modification of the try block. */
11564 try_block = build_jump_to_finally (try_block, rff,
11565 FINALLY_EXPR_LABEL (finally),
11566 NULL_TREE);
11568 /* To the finally block: add the computed goto */
11569 add_stmt_to_block (FINALLY_EXPR_BLOCK (finally), NULL_TREE,
11570 build (GOTO_EXPR, void_type_node, rff));
11572 /* Modification of each catch blocks, if any */
11573 if (catches)
11575 tree catch, catch_decl, catch_block, stmt;
11577 for (catch = catches; catch; catch = TREE_CHAIN (catch))
11578 TREE_OPERAND (catch, 0) =
11579 build_jump_to_finally (TREE_OPERAND (catch, 0), rff,
11580 FINALLY_EXPR_LABEL (finally),
11581 NULL_TREE);
11583 /* Plus, at the end of the list, we add the catch clause that
11584 will catch an uncaught exception, call finally and rethrow it:
11585 BLOCK
11586 void *exception_parameter; (catch_decl)
11587 LABELED_BLOCK
11588 BLOCK
11589 exception_parameter = _Jv_exception_info ();
11590 RFF = &LABEL_DECL;
11591 goto finally;
11592 LABEL_DECL;
11593 CALL_EXPR
11594 Jv_ReThrow
11595 exception_parameter */
11596 catch_decl = build_decl_no_layout (VAR_DECL, generate_name (),
11597 ptr_type_node);
11598 BUILD_ASSIGN_EXCEPTION_INFO (stmt, catch_decl);
11599 catch_block = build_expr_block (stmt, NULL_TREE);
11600 catch_block = build_jump_to_finally (catch_block, rff,
11601 FINALLY_EXPR_LABEL (finally),
11602 void_type_node);
11603 BUILD_THROW (stmt, catch_decl);
11604 catch_block = build_expr_block (catch_block, catch_decl);
11605 add_stmt_to_block (catch_block, void_type_node, stmt);
11607 /* Link the new handler to the existing list as the first
11608 entry. It will be the last one to be generated. */
11609 catch = build1 (CATCH_EXPR, void_type_node, catch_block);
11610 TREE_CHAIN (catch) = catches;
11611 catches = catch;
11615 node = build (TRY_EXPR, NULL_TREE, try_block, catches, finally);
11616 EXPR_WFL_LINECOL (node) = location;
11618 /* If we have a finally, surround this whole thing by a block where
11619 the RFF local variable is defined. */
11621 return (finally ? build_expr_block (node, rff) : node);
11624 /* Get the catch clause block from an element of the catch clause
11625 list. If depends on whether a finally clause exists or node (in
11626 which case the original catch clause was surrounded by a
11627 LABELED_BLOCK_EXPR. */
11629 tree
11630 java_get_catch_block (node, finally_present_p)
11631 tree node;
11632 int finally_present_p;
11634 return (CATCH_EXPR_GET_EXPR (TREE_OPERAND (node, 0), finally_present_p));
11637 static tree
11638 patch_try_statement (node)
11639 tree node;
11641 int error_found = 0;
11642 tree try = TREE_OPERAND (node, 0);
11643 /* Exception handlers are considered in left to right order */
11644 tree catch = nreverse (TREE_OPERAND (node, 1));
11645 tree finally = TREE_OPERAND (node, 2);
11646 int finally_p = (finally ? 1 : 0);
11647 tree current, caught_type_list = NULL_TREE;
11649 /* Check catch clauses, if any. Every time we find an error, we try
11650 to process the next catch clause. We process the catch clause before
11651 the try block so that when processing the try block we can check thrown
11652 exceptions againts the caught type list. */
11653 for (current = catch; current; current = TREE_CHAIN (current))
11655 tree carg_decl, carg_type;
11656 tree sub_current, catch_block, catch_clause;
11657 int unreachable;
11659 /* Always detect the last catch clause if a finally is
11660 present. This is the catch-all handler and it just needs to
11661 be walked. */
11662 if (!TREE_CHAIN (current) && finally)
11664 TREE_OPERAND (current, 0) =
11665 java_complete_tree (TREE_OPERAND (current, 0));
11666 continue;
11669 /* At this point, the structure of the catch clause is
11670 LABELED_BLOCK_EXPR (if we have a finally)
11671 CATCH_EXPR (catch node)
11672 BLOCK (with the decl of the parameter)
11673 COMPOUND_EXPR
11674 MODIFIY_EXPR (assignemnt of the catch parameter)
11675 BLOCK (catch clause block)
11676 LABEL_DECL (where to return after finally (if any))
11678 Since the structure of the catch clause depends on the
11679 presence of a finally, we use a function call to get to the
11680 cath clause */
11681 catch_clause = java_get_catch_block (current, finally_p);
11682 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
11683 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
11685 /* Catch clauses can't have more than one parameter declared,
11686 but it's already enforced by the grammar. Make sure that the
11687 only parameter of the clause statement in of class Throwable
11688 or a subclass of Throwable, but that was done earlier. The
11689 catch clause parameter type has also been resolved. */
11691 /* Just make sure that the catch clause parameter type inherits
11692 from java.lang.Throwable */
11693 if (!inherits_from_p (carg_type, throwable_type_node))
11695 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
11696 parse_error_context (wfl_operator,
11697 "Can't catch class `%s'. Catch clause "
11698 "parameter type must be a subclass of "
11699 "class `java.lang.Throwable'",
11700 lang_printable_name (carg_type, 0));
11701 error_found = 1;
11702 continue;
11705 /* Partial check for unreachable catch statement: The catch
11706 clause is reachable iff is no earlier catch block A in
11707 the try statement such that the type of the catch
11708 clause's parameter is the same as or a subclass of the
11709 type of A's parameter */
11710 unreachable = 0;
11711 for (sub_current = catch;
11712 sub_current != current; sub_current = TREE_CHAIN (sub_current))
11714 tree sub_catch_clause, decl;
11715 sub_catch_clause = java_get_catch_block (sub_current, finally_p);
11716 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
11718 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
11720 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
11721 parse_error_context
11722 (wfl_operator, "`catch' not reached because of the catch "
11723 "clause at line %d", EXPR_WFL_LINENO (sub_current));
11724 unreachable = error_found = 1;
11725 break;
11728 if (unreachable)
11729 continue;
11731 /* Things to do here: the exception must be thrown */
11733 /* Link this type to the caught type list */
11734 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
11736 /* Complete the catch clause block */
11737 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
11738 if (catch_block == error_mark_node)
11740 error_found = 1;
11741 continue;
11743 TREE_OPERAND (current, 0) = catch_block;
11746 PUSH_EXCEPTIONS (caught_type_list);
11747 if ((try = java_complete_tree (try)) == error_mark_node)
11748 error_found = 1;
11749 POP_EXCEPTIONS ();
11751 /* Process finally */
11752 if (finally)
11754 FINALLY_EXPR_BLOCK (finally) =
11755 java_complete_tree (FINALLY_EXPR_BLOCK (finally));
11756 if (FINALLY_EXPR_BLOCK (finally) == error_mark_node)
11757 error_found = 1;
11760 /* Verification ends here */
11761 if (error_found)
11762 return error_mark_node;
11764 TREE_OPERAND (node, 0) = try;
11765 TREE_OPERAND (node, 1) = catch;
11766 TREE_OPERAND (node, 2) = finally;
11767 TREE_TYPE (node) = void_type_node;
11768 return node;
11771 /* 14.17 The synchronized Statement */
11773 static tree
11774 patch_synchronized_statement (node, wfl_op1)
11775 tree node, wfl_op1;
11777 tree expr = TREE_OPERAND (node, 0);
11778 tree block = TREE_OPERAND (node, 1);
11779 tree try_block, catch_all, stmt, compound, decl;
11781 /* The TYPE of expr must be a reference type */
11782 if (!JREFERENCE_TYPE_P (TREE_TYPE (TREE_OPERAND (node, 0))))
11784 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
11785 parse_error_context (wfl_operator, "Incompatible type for `synchronized'"
11786 ". Can't convert `%s' to `java.lang.Object'",
11787 lang_printable_name (TREE_TYPE (expr), 0));
11788 return error_mark_node;
11791 /* Generate a try-finally for the synchronized statement, except
11792 that the handler that catches all throw exception calls
11793 _Jv_MonitorExit and then rethrow the exception.
11794 The synchronized statement is then implemented as:
11795 TRY
11797 _Jv_MonitorEnter (expression)
11798 synchronized_block
11799 _Jv_MonitorExit (expression)
11801 CATCH_ALL
11803 e = _Jv_exception_info ();
11804 _Jv_MonitorExit (expression)
11805 Throw (e);
11806 } */
11808 /* TRY block */
11809 BUILD_MONITOR_ENTER (stmt, expr);
11810 compound = add_stmt_to_compound (NULL_TREE, int_type_node, stmt);
11811 compound = add_stmt_to_compound (compound, void_type_node, block);
11812 BUILD_MONITOR_EXIT (stmt, expr);
11813 compound = add_stmt_to_compound (compound, int_type_node, stmt);
11814 try_block = build_expr_block (compound, NULL_TREE);
11816 /* CATCH_ALL block */
11817 decl = build_decl_no_layout (VAR_DECL, generate_name (), ptr_type_node);
11818 BUILD_ASSIGN_EXCEPTION_INFO (stmt, decl);
11819 compound = add_stmt_to_compound (NULL_TREE, void_type_node, stmt);
11820 BUILD_MONITOR_EXIT (stmt, expr);
11821 compound = add_stmt_to_compound (compound, int_type_node, stmt);
11822 BUILD_THROW (stmt, decl);
11823 compound = add_stmt_to_compound (compound, void_type_node, stmt);
11824 catch_all = build_expr_block (compound, decl);
11825 catch_all = build_expr_block (catch_all, NULL_TREE);
11826 catch_all = build1 (CATCH_EXPR, void_type_node, catch_all);
11828 /* TRY-CATCH statement */
11829 return build (TRY_EXPR, void_type_node, try_block, catch_all, NULL_TREE);
11832 /* 14.16 The throw Statement */
11834 static tree
11835 patch_throw_statement (node, wfl_op1)
11836 tree node, wfl_op1;
11838 tree expr = TREE_OPERAND (node, 0);
11839 tree type = TREE_TYPE (expr);
11840 int unchecked_ok = 0, tryblock_throws_ok = 0;
11842 /* Thrown expression must be assignable to java.lang.Throwable */
11843 if (!try_reference_assignconv (throwable_type_node, expr))
11845 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
11846 parse_error_context (wfl_operator, "Can't throw `%s'; it must be a "
11847 "subclass of class `java.lang.Throwable'",
11848 lang_printable_name (type, 0));
11849 /* If the thrown expression was a reference, we further the
11850 compile-time check. */
11851 if (!JREFERENCE_TYPE_P (type))
11852 return error_mark_node;
11855 /* At least one of the following must be true */
11857 /* The type of the throw expression is a not checked exception,
11858 i.e. is a unchecked expression. */
11859 unchecked_ok = IS_UNCHECKED_EXPRESSION_P (TREE_TYPE (type));
11861 /* Throw is contained in a try statement and at least one catch
11862 clause can receive the thrown expression or the current method is
11863 declared to throw such an exception. Or, the throw statement is
11864 contained in a method or constructor declaration and the type of
11865 the Expression is assignable to at least one type listed in the
11866 throws clause the declaration. */
11867 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
11868 if (!unchecked_ok)
11869 tryblock_throws_ok =
11870 check_thrown_exceptions_do (TREE_TYPE (expr));
11871 if (!(unchecked_ok || tryblock_throws_ok))
11873 /* If there is a surrounding try block that has no matching
11874 clatch clause, report it first. A surrounding try block exits
11875 only if there is something after the list of checked
11876 exception thrown by the current function (if any). */
11877 if (IN_TRY_BLOCK_P ())
11878 parse_error_context (wfl_operator, "Checked exception `%s' can't be "
11879 "caught by any of the catch clause(s) "
11880 "of the surrounding `try' block",
11881 lang_printable_name (type, 0));
11882 /* If we have no surrounding try statement and the method doesn't have
11883 any throws, report it now. FIXME */
11884 else if (!EXCEPTIONS_P (currently_caught_type_list)
11885 && !tryblock_throws_ok)
11886 parse_error_context (wfl_operator, "Checked exception `%s' isn't "
11887 "thrown from a `try' block",
11888 lang_printable_name (type, 0));
11889 /* Otherwise, the current method doesn't have the appropriate
11890 throws declaration */
11891 else
11892 parse_error_context (wfl_operator, "Checked exception `%s' doesn't "
11893 "match any of current method's `throws' "
11894 "declaration(s)",
11895 lang_printable_name (type, 0));
11896 return error_mark_node;
11899 /* If a throw statement is contained in a static initializer, then a
11900 compile-time check ensures that either its value is always an
11901 unchecked exception or its value is always caught by some try
11902 statement that contains it. FIXME, static initializer. */
11904 BUILD_THROW (node, expr);
11905 return node;
11908 /* Check that exception said to be thrown by method DECL can be
11909 effectively caught from where DECL is invoked. */
11911 static void
11912 check_thrown_exceptions (location, decl)
11913 int location;
11914 tree decl;
11916 tree throws;
11917 /* For all the unchecked exceptions thrown by DECL */
11918 for (throws = DECL_FUNCTION_THROWS (decl); throws;
11919 throws = TREE_CHAIN (throws))
11920 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
11922 EXPR_WFL_LINECOL (wfl_operator) = location;
11923 parse_error_context
11924 (wfl_operator, "Exception `%s' must be caught, or it must be "
11925 "declared in the `throws' clause of `%s'",
11926 lang_printable_name (TREE_VALUE (throws), 0),
11927 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
11931 /* Return 1 if EXCEPTION is caught at the current nesting level of
11932 try-catch blocks, OR is listed in the `throws' clause of the
11933 current method. */
11935 static int
11936 check_thrown_exceptions_do (exception)
11937 tree exception;
11939 tree list = currently_caught_type_list;
11940 /* First, all the nested try-catch-finally at that stage. The
11941 last element contains `throws' clause exceptions, if any. */
11942 while (list)
11944 tree caught;
11945 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
11946 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
11947 return 1;
11948 list = TREE_CHAIN (list);
11950 return 0;
11953 static void
11954 purge_unchecked_exceptions (mdecl)
11955 tree mdecl;
11957 tree throws = DECL_FUNCTION_THROWS (mdecl);
11958 tree new = NULL_TREE;
11960 while (throws)
11962 tree next = TREE_CHAIN (throws);
11963 if (!IS_UNCHECKED_EXPRESSION_P (TREE_VALUE (throws)))
11965 TREE_CHAIN (throws) = new;
11966 new = throws;
11968 throws = next;
11970 /* List is inverted here, but it doesn't matter */
11971 DECL_FUNCTION_THROWS (mdecl) = new;