]> gcc.gnu.org Git - gcc.git/blob - gcc/java/parse.c
[multiple changes]
[gcc.git] / gcc / java / parse.c
1
2 /* A Bison parser, made from ./parse.y
3 by GNU Bison version 1.25
4 */
5
6 #define YYBISON 1 /* Identify Bison output. */
7
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
122
123 #line 48 "./parse.y"
124
125 #include "config.h"
126 #include "system.h"
127 #include <dirent.h>
128 #include "tree.h"
129 #include "rtl.h"
130 #include "obstack.h"
131 #include "toplev.h"
132 #include "flags.h"
133 #include "java-tree.h"
134 #include "jcf.h"
135 #include "lex.h"
136 #include "parse.h"
137 #include "zipfile.h"
138 #include "convert.h"
139 #include "buffer.h"
140 #include "xref.h"
141 #include "except.h"
142
143 #ifndef DIR_SEPARATOR
144 #define DIR_SEPARATOR '/'
145 #endif
146
147 /* Local function prototypes */
148 static char *java_accstring_lookup PROTO ((int));
149 static void classitf_redefinition_error PROTO ((char *,tree, tree, tree));
150 static void variable_redefinition_error PROTO ((tree, tree, tree, int));
151 static void check_modifiers PROTO ((char *, int, int));
152 static tree create_class PROTO ((int, tree, tree, tree));
153 static tree create_interface PROTO ((int, tree, tree));
154 static tree find_field PROTO ((tree, tree));
155 static tree lookup_field_wrapper PROTO ((tree, tree));
156 static int duplicate_declaration_error_p PROTO ((tree, tree, tree));
157 static void register_fields PROTO ((int, tree, tree));
158 static tree parser_qualified_classname PROTO ((tree));
159 static int parser_check_super PROTO ((tree, tree, tree));
160 static int parser_check_super_interface PROTO ((tree, tree, tree));
161 static void check_modifiers_consistency PROTO ((int));
162 static tree lookup_cl PROTO ((tree));
163 static tree lookup_java_method2 PROTO ((tree, tree, int));
164 static tree method_header PROTO ((int, tree, tree, tree));
165 static void fix_method_argument_names PROTO ((tree ,tree));
166 static tree method_declarator PROTO ((tree, tree));
167 static void parse_warning_context PVPROTO ((tree cl, const char *msg, ...))
168 ATTRIBUTE_PRINTF_2;
169 static void issue_warning_error_from_context PROTO ((tree, const char *msg, va_list));
170 static tree parse_jdk1_1_error PROTO ((char *));
171 static void complete_class_report_errors PROTO ((jdep *));
172 static int process_imports PROTO ((void));
173 static void read_import_dir PROTO ((tree));
174 static int find_in_imports_on_demand PROTO ((tree));
175 static int find_in_imports PROTO ((tree));
176 static int check_pkg_class_access PROTO ((tree, tree));
177 static tree resolve_package PROTO ((tree, tree *));
178 static tree lookup_package_type PROTO ((char *, int));
179 static tree resolve_class PROTO ((tree, tree, tree));
180 static void declare_local_variables PROTO ((int, tree, tree));
181 static void source_start_java_method PROTO ((tree));
182 static void source_end_java_method PROTO ((void));
183 static void expand_start_java_method PROTO ((tree));
184 static tree find_name_in_single_imports PROTO ((tree));
185 static void check_abstract_method_header PROTO ((tree));
186 static tree lookup_java_interface_method2 PROTO ((tree, tree));
187 static tree resolve_expression_name PROTO ((tree, tree *));
188 static tree maybe_create_class_interface_decl PROTO ((tree, tree, tree));
189 static int check_class_interface_creation PROTO ((int, int, tree,
190 tree, tree, tree));
191 static tree patch_method_invocation PROTO ((tree, tree, tree,
192 int *, tree *));
193 static int breakdown_qualified PROTO ((tree *, tree *, tree));
194 static tree resolve_and_layout PROTO ((tree, tree));
195 static tree resolve_no_layout PROTO ((tree, tree));
196 static int invocation_mode PROTO ((tree, int));
197 static tree find_applicable_accessible_methods_list PROTO ((int, tree,
198 tree, tree));
199 static void search_applicable_methods_list PROTO ((int, tree, tree, tree,
200 tree *, tree *));
201 static tree find_most_specific_methods_list PROTO ((tree));
202 static int argument_types_convertible PROTO ((tree, tree));
203 static tree patch_invoke PROTO ((tree, tree, tree));
204 static tree lookup_method_invoke PROTO ((int, tree, tree, tree, tree));
205 static tree register_incomplete_type PROTO ((int, tree, tree, tree));
206 static tree obtain_incomplete_type PROTO ((tree));
207 static tree java_complete_lhs PROTO ((tree));
208 static tree java_complete_tree PROTO ((tree));
209 static void java_complete_expand_method PROTO ((tree));
210 static int unresolved_type_p PROTO ((tree, tree *));
211 static void create_jdep_list PROTO ((struct parser_ctxt *));
212 static tree build_expr_block PROTO ((tree, tree));
213 static tree enter_block PROTO ((void));
214 static tree enter_a_block PROTO ((tree));
215 static tree exit_block PROTO ((void));
216 static tree lookup_name_in_blocks PROTO ((tree));
217 static void maybe_absorb_scoping_blocks PROTO ((void));
218 static tree build_method_invocation PROTO ((tree, tree));
219 static tree build_new_invocation PROTO ((tree, tree));
220 static tree build_assignment PROTO ((int, int, tree, tree));
221 static tree build_binop PROTO ((enum tree_code, int, tree, tree));
222 static int check_final_assignment PROTO ((tree ,tree));
223 static tree patch_assignment PROTO ((tree, tree, tree ));
224 static tree patch_binop PROTO ((tree, tree, tree));
225 static tree build_unaryop PROTO ((int, int, tree));
226 static tree build_incdec PROTO ((int, int, tree, int));
227 static tree patch_unaryop PROTO ((tree, tree));
228 static tree build_cast PROTO ((int, tree, tree));
229 static tree build_null_of_type PROTO ((tree));
230 static tree patch_cast PROTO ((tree, tree));
231 static int valid_ref_assignconv_cast_p PROTO ((tree, tree, int));
232 static int valid_builtin_assignconv_identity_widening_p PROTO ((tree, tree));
233 static int valid_cast_to_p PROTO ((tree, tree));
234 static int valid_method_invocation_conversion_p PROTO ((tree, tree));
235 static tree try_builtin_assignconv PROTO ((tree, tree, tree));
236 static tree try_reference_assignconv PROTO ((tree, tree));
237 static tree build_unresolved_array_type PROTO ((tree));
238 static tree build_array_from_name PROTO ((tree, tree, tree, tree *));
239 static tree build_array_ref PROTO ((int, tree, tree));
240 static tree patch_array_ref PROTO ((tree));
241 static tree make_qualified_name PROTO ((tree, tree, int));
242 static tree merge_qualified_name PROTO ((tree, tree));
243 static tree make_qualified_primary PROTO ((tree, tree, int));
244 static int resolve_qualified_expression_name PROTO ((tree, tree *,
245 tree *, tree *));
246 static void qualify_ambiguous_name PROTO ((tree));
247 static void maybe_generate_clinit PROTO ((void));
248 static tree resolve_field_access PROTO ((tree, tree *, tree *));
249 static tree build_newarray_node PROTO ((tree, tree, int));
250 static tree patch_newarray PROTO ((tree));
251 static tree resolve_type_during_patch PROTO ((tree));
252 static tree build_this PROTO ((int));
253 static tree build_return PROTO ((int, tree));
254 static tree patch_return PROTO ((tree));
255 static tree maybe_access_field PROTO ((tree, tree, tree));
256 static int complete_function_arguments PROTO ((tree));
257 static int check_for_static_method_reference PROTO ((tree, tree, tree, tree, tree));
258 static int not_accessible_p PROTO ((tree, tree, int));
259 static void check_deprecation PROTO ((tree, tree));
260 static int class_in_current_package PROTO ((tree));
261 static tree build_if_else_statement PROTO ((int, tree, tree, tree));
262 static tree patch_if_else_statement PROTO ((tree));
263 static tree add_stmt_to_compound PROTO ((tree, tree, tree));
264 static tree add_stmt_to_block PROTO ((tree, tree, tree));
265 static tree patch_exit_expr PROTO ((tree));
266 static tree build_labeled_block PROTO ((int, tree));
267 static tree finish_labeled_statement PROTO ((tree, tree));
268 static tree build_bc_statement PROTO ((int, int, tree));
269 static tree patch_bc_statement PROTO ((tree));
270 static tree patch_loop_statement PROTO ((tree));
271 static tree build_new_loop PROTO ((tree));
272 static tree build_loop_body PROTO ((int, tree, int));
273 static tree finish_loop_body PROTO ((int, tree, tree, int));
274 static tree build_debugable_stmt PROTO ((int, tree));
275 static tree finish_for_loop PROTO ((int, tree, tree, tree));
276 static tree patch_switch_statement PROTO ((tree));
277 static tree string_constant_concatenation PROTO ((tree, tree));
278 static tree build_string_concatenation PROTO ((tree, tree));
279 static tree patch_string_cst PROTO ((tree));
280 static tree patch_string PROTO ((tree));
281 static tree build_try_statement PROTO ((int, tree, tree));
282 static tree build_try_finally_statement PROTO ((int, tree, tree));
283 static tree patch_try_statement PROTO ((tree));
284 static tree patch_synchronized_statement PROTO ((tree, tree));
285 static tree patch_throw_statement PROTO ((tree, tree));
286 static void check_thrown_exceptions PROTO ((int, tree));
287 static int check_thrown_exceptions_do PROTO ((tree));
288 static void purge_unchecked_exceptions PROTO ((tree));
289 static void check_throws_clauses PROTO ((tree, tree, tree));
290 static void finish_method_declaration PROTO ((tree));
291 static tree build_super_invocation PROTO (());
292 static int verify_constructor_circularity PROTO ((tree, tree));
293 static char *constructor_circularity_msg PROTO ((tree, tree));
294 static tree build_this_super_qualified_invocation PROTO ((int, tree, tree,
295 int, int));
296 static char *get_printable_method_name PROTO ((tree));
297 static tree patch_conditional_expr PROTO ((tree, tree, tree));
298 static void maybe_generate_finit PROTO (());
299 static void fix_constructors PROTO ((tree));
300 static int verify_constructor_super PROTO (());
301 static tree create_artificial_method PROTO ((tree, int, tree, tree, tree));
302 static void start_artificial_method_body PROTO ((tree));
303 static void end_artificial_method_body PROTO ((tree));
304 static int check_method_redefinition PROTO ((tree, tree));
305 static int reset_method_name PROTO ((tree));
306 static void java_check_regular_methods PROTO ((tree));
307 static void java_check_abstract_methods PROTO ((tree));
308 static tree maybe_build_primttype_type_ref PROTO ((tree, tree));
309 static void unreachable_stmt_error PROTO ((tree));
310 static tree find_expr_with_wfl PROTO ((tree));
311 static void missing_return_error PROTO ((tree));
312 static tree build_new_array_init PROTO ((int, tree));
313 static tree patch_new_array_init PROTO ((tree, tree));
314 static tree maybe_build_array_element_wfl PROTO ((tree));
315 static int array_constructor_check_entry PROTO ((tree, tree));
316 static char *purify_type_name PROTO ((char *));
317 static tree fold_constant_for_init PROTO ((tree, tree));
318 static tree strip_out_static_field_access_decl PROTO ((tree));
319 static jdeplist *reverse_jdep_list PROTO ((struct parser_ctxt *));
320 static void static_ref_err PROTO ((tree, tree, tree));
321
322 /* Number of error found so far. */
323 int java_error_count;
324 /* Number of warning found so far. */
325 int java_warning_count;
326 /* Tell when not to fold, when doing xrefs */
327 int do_not_fold;
328
329 /* The current parser context */
330 struct parser_ctxt *ctxp;
331
332 /* List of things that were analyzed for which code will be generated */
333 static struct parser_ctxt *ctxp_for_generation = NULL;
334
335 /* binop_lookup maps token to tree_code. It is used where binary
336 operations are involved and required by the parser. RDIV_EXPR
337 covers both integral/floating point division. The code is changed
338 once the type of both operator is worked out. */
339
340 static enum tree_code binop_lookup[19] =
341 {
342 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
343 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
344 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
345 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
346 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
347 };
348 #define BINOP_LOOKUP(VALUE) \
349 binop_lookup [((VALUE) - PLUS_TK)% \
350 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
351
352 /* Fake WFL used to report error message. It is initialized once if
353 needed and reused with it's location information is overriden. */
354 tree wfl_operator = NULL_TREE;
355
356 /* The "$L" identifier we use to create labels. */
357 static tree label_id = NULL_TREE;
358
359 /* The "StringBuffer" identifier used for the String `+' operator. */
360 static tree wfl_string_buffer = NULL_TREE;
361
362 /* The "append" identifier used for String `+' operator. */
363 static tree wfl_append = NULL_TREE;
364
365 /* The "toString" identifier used for String `+' operator. */
366 static tree wfl_to_string = NULL_TREE;
367
368 /* The "java.lang" import qualified name. */
369 static tree java_lang_id = NULL_TREE;
370
371 /* The "java.lang.Cloneable" qualified name. */
372 static tree java_lang_cloneable = NULL_TREE;
373
374 /* Context and flag for static blocks */
375 static tree current_static_block = NULL_TREE;
376
377
378 #line 303 "./parse.y"
379 typedef union {
380 tree node;
381 int sub_token;
382 struct {
383 int token;
384 int location;
385 } operator;
386 int value;
387 } YYSTYPE;
388 #line 313 "./parse.y"
389
390 #include "lex.c"
391 #ifndef YYDEBUG
392 #define YYDEBUG 1
393 #endif
394
395 #include <stdio.h>
396
397 #ifndef __cplusplus
398 #ifndef __STDC__
399 #define const
400 #endif
401 #endif
402
403
404
405 #define YYFINAL 777
406 #define YYFLAG -32768
407 #define YYNTBASE 110
408
409 #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 266)
410
411 static const char yytranslate[] = { 0,
412 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
413 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
414 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
415 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
416 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
417 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
418 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
419 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
420 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
421 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
422 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
423 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
424 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
425 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
426 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
427 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
428 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
429 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
430 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
431 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
432 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
433 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
434 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
435 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
436 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
437 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
438 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
439 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
440 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
441 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
442 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
443 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
444 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
445 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
446 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
447 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
448 106, 107, 108, 109
449 };
450
451 #if YYDEBUG != 0
452 static const short yyprhs[] = { 0,
453 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
454 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
455 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
456 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
457 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
458 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
459 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
460 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
461 229, 231, 233, 235, 238, 240, 242, 244, 248, 253,
462 255, 259, 263, 265, 269, 273, 278, 280, 284, 287,
463 291, 295, 297, 299, 300, 304, 307, 311, 315, 320,
464 325, 328, 332, 335, 339, 342, 346, 351, 355, 359,
465 363, 365, 369, 373, 376, 380, 383, 387, 388, 391,
466 394, 396, 400, 404, 406, 409, 411, 414, 418, 420,
467 421, 425, 428, 432, 436, 441, 444, 448, 452, 457,
468 459, 462, 467, 473, 481, 488, 490, 492, 493, 498,
469 499, 505, 506, 512, 513, 520, 524, 529, 532, 536,
470 539, 543, 546, 550, 552, 555, 557, 559, 561, 563,
471 565, 568, 571, 574, 578, 583, 585, 589, 593, 596,
472 600, 602, 604, 606, 609, 611, 613, 615, 618, 621,
473 625, 627, 629, 631, 633, 635, 637, 639, 641, 643,
474 645, 647, 649, 651, 653, 655, 657, 659, 661, 663,
475 665, 667, 669, 671, 674, 677, 680, 683, 686, 689,
476 692, 695, 699, 704, 709, 715, 720, 726, 733, 741,
477 748, 750, 752, 754, 756, 758, 760, 762, 768, 771,
478 775, 780, 788, 796, 797, 801, 806, 809, 813, 819,
479 822, 826, 830, 835, 837, 840, 843, 845, 848, 852,
480 855, 858, 862, 865, 870, 873, 876, 880, 885, 888,
481 890, 898, 906, 913, 917, 923, 928, 936, 943, 946,
482 949, 953, 956, 957, 959, 961, 964, 965, 967, 969,
483 973, 977, 980, 984, 987, 991, 994, 998, 1001, 1005,
484 1008, 1012, 1015, 1019, 1023, 1026, 1030, 1036, 1042, 1045,
485 1050, 1054, 1056, 1060, 1064, 1069, 1072, 1074, 1077, 1080,
486 1085, 1088, 1092, 1097, 1100, 1103, 1105, 1107, 1109, 1111,
487 1115, 1117, 1119, 1121, 1123, 1127, 1131, 1135, 1139, 1143,
488 1147, 1151, 1155, 1161, 1166, 1173, 1179, 1184, 1190, 1196,
489 1203, 1207, 1211, 1216, 1222, 1225, 1229, 1233, 1237, 1239,
490 1243, 1247, 1251, 1255, 1260, 1265, 1270, 1275, 1279, 1283,
491 1285, 1288, 1292, 1296, 1299, 1302, 1306, 1310, 1314, 1318,
492 1321, 1325, 1330, 1336, 1343, 1349, 1356, 1361, 1366, 1371,
493 1376, 1380, 1385, 1389, 1394, 1396, 1398, 1400, 1402, 1405,
494 1408, 1410, 1412, 1415, 1418, 1420, 1423, 1426, 1429, 1432,
495 1435, 1438, 1440, 1443, 1446, 1448, 1451, 1454, 1460, 1465,
496 1470, 1476, 1481, 1484, 1490, 1495, 1501, 1503, 1507, 1511,
497 1515, 1519, 1523, 1527, 1529, 1533, 1537, 1541, 1545, 1547,
498 1551, 1555, 1559, 1563, 1567, 1571, 1573, 1577, 1581, 1585,
499 1589, 1593, 1597, 1601, 1605, 1609, 1613, 1615, 1619, 1623,
500 1627, 1631, 1633, 1637, 1641, 1643, 1647, 1651, 1653, 1657,
501 1661, 1663, 1667, 1671, 1673, 1677, 1681, 1683, 1689, 1694,
502 1698, 1704, 1706, 1708, 1712, 1716, 1718, 1720, 1722, 1724,
503 1726, 1728
504 };
505
506 static const short yyrhs[] = { 123,
507 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
508 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
509 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
510 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
511 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
512 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
513 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
514 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
515 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
516 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
517 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
518 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
519 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
520 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
521 166, 0, 99, 0, 1, 0, 44, 0, 131, 44,
522 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
523 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
524 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
525 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
526 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
527 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
528 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
529 0, 139, 140, 0, 141, 0, 156, 0, 158, 0,
530 179, 0, 142, 0, 142, 99, 0, 147, 0, 132,
531 0, 166, 0, 112, 143, 99, 0, 131, 112, 143,
532 99, 0, 144, 0, 143, 100, 144, 0, 143, 100,
533 1, 0, 145, 0, 145, 92, 146, 0, 145, 92,
534 1, 0, 145, 92, 146, 1, 0, 122, 0, 145,
535 97, 98, 0, 122, 1, 0, 145, 97, 1, 0,
536 145, 98, 1, 0, 264, 0, 177, 0, 0, 149,
537 148, 155, 0, 149, 1, 0, 112, 150, 153, 0,
538 59, 150, 153, 0, 131, 112, 150, 153, 0, 131,
539 59, 150, 153, 0, 112, 1, 0, 131, 112, 1,
540 0, 59, 1, 0, 131, 59, 1, 0, 131, 1,
541 0, 122, 93, 94, 0, 122, 93, 151, 94, 0,
542 150, 97, 98, 0, 122, 93, 1, 0, 150, 97,
543 1, 0, 152, 0, 151, 100, 152, 0, 151, 100,
544 1, 0, 112, 145, 0, 131, 112, 145, 0, 112,
545 1, 0, 131, 112, 1, 0, 0, 53, 154, 0,
546 53, 1, 0, 116, 0, 154, 100, 116, 0, 154,
547 100, 1, 0, 179, 0, 179, 99, 0, 99, 0,
548 157, 179, 0, 157, 179, 99, 0, 44, 0, 0,
549 160, 159, 162, 0, 161, 153, 0, 131, 161, 153,
550 0, 120, 93, 94, 0, 120, 93, 151, 94, 0,
551 180, 163, 0, 180, 164, 163, 0, 180, 182, 163,
552 0, 180, 164, 182, 163, 0, 181, 0, 181, 99,
553 0, 165, 93, 94, 99, 0, 165, 93, 233, 94,
554 99, 0, 119, 101, 65, 93, 233, 94, 99, 0,
555 119, 101, 65, 93, 94, 99, 0, 76, 0, 65,
556 0, 0, 61, 122, 167, 172, 0, 0, 131, 61,
557 122, 168, 172, 0, 0, 61, 122, 171, 169, 172,
558 0, 0, 131, 61, 122, 171, 170, 172, 0, 61,
559 122, 1, 0, 131, 61, 122, 1, 0, 63, 117,
560 0, 171, 100, 117, 0, 63, 1, 0, 171, 100,
561 1, 0, 95, 96, 0, 95, 173, 96, 0, 174,
562 0, 173, 174, 0, 175, 0, 176, 0, 132, 0,
563 166, 0, 142, 0, 149, 99, 0, 149, 1, 0,
564 95, 96, 0, 95, 178, 96, 0, 95, 178, 100,
565 96, 0, 146, 0, 178, 100, 146, 0, 178, 100,
566 1, 0, 95, 96, 0, 180, 182, 181, 0, 95,
567 0, 96, 0, 183, 0, 182, 183, 0, 184, 0,
568 186, 0, 132, 0, 185, 99, 0, 112, 143, 0,
569 131, 112, 143, 0, 188, 0, 191, 0, 195, 0,
570 196, 0, 207, 0, 211, 0, 188, 0, 192, 0,
571 197, 0, 208, 0, 212, 0, 179, 0, 189, 0,
572 193, 0, 198, 0, 210, 0, 218, 0, 219, 0,
573 220, 0, 222, 0, 221, 0, 224, 0, 99, 0,
574 122, 88, 0, 190, 186, 0, 122, 1, 0, 190,
575 187, 0, 194, 99, 0, 1, 99, 0, 1, 95,
576 0, 1, 96, 0, 165, 93, 1, 0, 165, 93,
577 94, 1, 0, 165, 93, 233, 1, 0, 165, 93,
578 233, 94, 1, 0, 119, 101, 65, 1, 0, 119,
579 101, 65, 93, 1, 0, 119, 101, 65, 93, 233,
580 1, 0, 119, 101, 65, 93, 233, 94, 1, 0,
581 119, 101, 65, 93, 94, 1, 0, 261, 0, 245,
582 0, 246, 0, 242, 0, 243, 0, 239, 0, 231,
583 0, 48, 93, 264, 94, 186, 0, 48, 1, 0,
584 48, 93, 1, 0, 48, 93, 264, 1, 0, 48,
585 93, 264, 94, 187, 56, 186, 0, 48, 93, 264,
586 94, 187, 56, 187, 0, 0, 200, 199, 201, 0,
587 68, 93, 264, 94, 0, 68, 1, 0, 68, 93,
588 1, 0, 68, 93, 264, 94, 1, 0, 95, 96,
589 0, 95, 204, 96, 0, 95, 202, 96, 0, 95,
590 202, 204, 96, 0, 203, 0, 202, 203, 0, 204,
591 182, 0, 205, 0, 204, 205, 0, 62, 265, 88,
592 0, 47, 88, 0, 62, 1, 0, 62, 265, 1,
593 0, 47, 1, 0, 66, 93, 264, 94, 0, 206,
594 186, 0, 66, 1, 0, 66, 93, 1, 0, 66,
595 93, 264, 1, 0, 206, 187, 0, 51, 0, 209,
596 186, 66, 93, 264, 94, 99, 0, 214, 99, 264,
597 99, 216, 94, 186, 0, 214, 99, 99, 216, 94,
598 186, 0, 214, 99, 1, 0, 214, 99, 264, 99,
599 1, 0, 214, 99, 99, 1, 0, 214, 99, 264,
600 99, 216, 94, 187, 0, 214, 99, 99, 216, 94,
601 187, 0, 71, 93, 0, 71, 1, 0, 71, 93,
602 1, 0, 213, 215, 0, 0, 217, 0, 185, 0,
603 217, 1, 0, 0, 217, 0, 194, 0, 217, 100,
604 194, 0, 217, 100, 1, 0, 54, 99, 0, 54,
605 122, 99, 0, 54, 1, 0, 54, 122, 1, 0,
606 73, 99, 0, 73, 122, 99, 0, 73, 1, 0,
607 73, 122, 1, 0, 58, 99, 0, 58, 264, 99,
608 0, 58, 1, 0, 58, 264, 1, 0, 49, 264,
609 99, 0, 49, 1, 0, 49, 264, 1, 0, 223,
610 93, 264, 94, 179, 0, 223, 93, 264, 94, 1,
611 0, 223, 1, 0, 223, 93, 1, 94, 0, 223,
612 93, 1, 0, 44, 0, 70, 179, 225, 0, 70,
613 179, 228, 0, 70, 179, 225, 228, 0, 70, 1,
614 0, 226, 0, 225, 226, 0, 227, 179, 0, 60,
615 93, 152, 94, 0, 60, 1, 0, 60, 93, 1,
616 0, 60, 93, 1, 94, 0, 64, 179, 0, 64,
617 1, 0, 230, 0, 234, 0, 111, 0, 76, 0,
618 93, 264, 94, 0, 231, 0, 238, 0, 239, 0,
619 240, 0, 119, 101, 67, 0, 113, 101, 67, 0,
620 59, 101, 67, 0, 119, 101, 76, 0, 93, 264,
621 1, 0, 119, 101, 1, 0, 113, 101, 1, 0,
622 59, 101, 1, 0, 72, 116, 93, 233, 94, 0,
623 72, 116, 93, 94, 0, 72, 116, 93, 233, 94,
624 138, 0, 72, 116, 93, 94, 138, 0, 232, 122,
625 93, 94, 0, 232, 122, 93, 94, 138, 0, 232,
626 122, 93, 233, 94, 0, 232, 122, 93, 233, 94,
627 138, 0, 72, 1, 99, 0, 72, 116, 1, 0,
628 72, 116, 93, 1, 0, 72, 116, 93, 233, 1,
629 0, 232, 1, 0, 232, 122, 1, 0, 119, 101,
630 72, 0, 229, 101, 72, 0, 264, 0, 233, 100,
631 264, 0, 233, 100, 1, 0, 72, 113, 235, 0,
632 72, 115, 235, 0, 72, 113, 235, 237, 0, 72,
633 115, 235, 237, 0, 72, 115, 237, 177, 0, 72,
634 113, 237, 177, 0, 72, 1, 98, 0, 72, 1,
635 97, 0, 236, 0, 235, 236, 0, 97, 264, 98,
636 0, 97, 264, 1, 0, 97, 1, 0, 97, 98,
637 0, 237, 97, 98, 0, 237, 97, 1, 0, 229,
638 101, 122, 0, 65, 101, 122, 0, 65, 1, 0,
639 119, 93, 94, 0, 119, 93, 233, 94, 0, 229,
640 101, 122, 93, 94, 0, 229, 101, 122, 93, 233,
641 94, 0, 65, 101, 122, 93, 94, 0, 65, 101,
642 122, 93, 233, 94, 0, 65, 101, 1, 94, 0,
643 65, 101, 1, 101, 0, 119, 97, 264, 98, 0,
644 230, 97, 264, 98, 0, 119, 97, 1, 0, 119,
645 97, 264, 1, 0, 230, 97, 1, 0, 230, 97,
646 264, 1, 0, 229, 0, 119, 0, 242, 0, 243,
647 0, 241, 46, 0, 241, 45, 0, 245, 0, 246,
648 0, 3, 244, 0, 4, 244, 0, 247, 0, 3,
649 1, 0, 4, 1, 0, 46, 244, 0, 46, 1,
650 0, 45, 244, 0, 45, 1, 0, 241, 0, 89,
651 244, 0, 90, 244, 0, 248, 0, 89, 1, 0,
652 90, 1, 0, 93, 113, 237, 94, 244, 0, 93,
653 113, 94, 244, 0, 93, 264, 94, 247, 0, 93,
654 119, 237, 94, 247, 0, 93, 113, 97, 1, 0,
655 93, 1, 0, 93, 113, 237, 94, 1, 0, 93,
656 113, 94, 1, 0, 93, 119, 237, 94, 1, 0,
657 244, 0, 249, 5, 244, 0, 249, 6, 244, 0,
658 249, 7, 244, 0, 249, 5, 1, 0, 249, 6,
659 1, 0, 249, 7, 1, 0, 249, 0, 250, 3,
660 249, 0, 250, 4, 249, 0, 250, 3, 1, 0,
661 250, 4, 1, 0, 250, 0, 251, 8, 250, 0,
662 251, 9, 250, 0, 251, 10, 250, 0, 251, 8,
663 1, 0, 251, 9, 1, 0, 251, 10, 1, 0,
664 251, 0, 252, 20, 251, 0, 252, 18, 251, 0,
665 252, 21, 251, 0, 252, 19, 251, 0, 252, 57,
666 114, 0, 252, 20, 1, 0, 252, 18, 1, 0,
667 252, 21, 1, 0, 252, 19, 1, 0, 252, 57,
668 1, 0, 252, 0, 253, 16, 252, 0, 253, 17,
669 252, 0, 253, 16, 1, 0, 253, 17, 1, 0,
670 253, 0, 254, 11, 253, 0, 254, 11, 1, 0,
671 254, 0, 255, 12, 254, 0, 255, 12, 1, 0,
672 255, 0, 256, 13, 255, 0, 256, 13, 1, 0,
673 256, 0, 257, 14, 256, 0, 257, 14, 1, 0,
674 257, 0, 258, 15, 257, 0, 258, 15, 1, 0,
675 258, 0, 258, 87, 264, 88, 259, 0, 258, 87,
676 88, 1, 0, 258, 87, 1, 0, 258, 87, 264,
677 88, 1, 0, 259, 0, 261, 0, 262, 263, 260,
678 0, 262, 263, 1, 0, 119, 0, 238, 0, 240,
679 0, 91, 0, 92, 0, 260, 0, 264, 0
680 };
681
682 #endif
683
684 #if YYDEBUG != 0
685 static const short yyrline[] = { 0,
686 457, 463, 465, 466, 467, 468, 469, 473, 475, 478,
687 480, 481, 484, 486, 489, 493, 497, 501, 507, 509,
688 511, 513, 518, 520, 523, 527, 532, 537, 539, 540,
689 541, 542, 543, 544, 545, 548, 553, 559, 561, 564,
690 567, 569, 573, 575, 578, 605, 607, 611, 624, 626,
691 630, 637, 642, 644, 654, 659, 674, 678, 681, 684,
692 687, 689, 691, 696, 700, 702, 704, 706, 710, 712,
693 714, 721, 727, 732, 736, 745, 755, 757, 760, 762,
694 763, 764, 768, 770, 772, 773, 775, 780, 783, 793,
695 796, 798, 802, 805, 812, 818, 826, 828, 830, 832,
696 834, 838, 840, 844, 851, 852, 856, 859, 861, 863,
697 865, 867, 869, 871, 873, 880, 883, 885, 894, 896,
698 900, 905, 910, 914, 919, 924, 926, 933, 935, 937,
699 941, 944, 946, 950, 952, 953, 958, 964, 971, 979,
700 986, 989, 992, 996, 999, 1003, 1012, 1014, 1016, 1020,
701 1022, 1025, 1032, 1040, 1042, 1046, 1053, 1063, 1067, 1070,
702 1073, 1076, 1079, 1082, 1085, 1088, 1090, 1094, 1100, 1105,
703 1107, 1111, 1114, 1118, 1120, 1123, 1125, 1126, 1128, 1132,
704 1136, 1142, 1147, 1150, 1152, 1156, 1162, 1166, 1171, 1180,
705 1184, 1189, 1201, 1203, 1206, 1208, 1210, 1214, 1218, 1221,
706 1225, 1227, 1228, 1229, 1230, 1231, 1235, 1237, 1238, 1239,
707 1240, 1244, 1246, 1247, 1248, 1249, 1250, 1251, 1252, 1253,
708 1254, 1255, 1258, 1263, 1274, 1277, 1281, 1288, 1298, 1304,
709 1310, 1316, 1318, 1324, 1326, 1332, 1334, 1336, 1338, 1340,
710 1344, 1346, 1347, 1348, 1349, 1350, 1351, 1354, 1360, 1362,
711 1364, 1368, 1373, 1378, 1384, 1394, 1400, 1402, 1404, 1411,
712 1414, 1416, 1418, 1422, 1424, 1427, 1431, 1433, 1436, 1443,
713 1449, 1451, 1453, 1457, 1465, 1468, 1470, 1472, 1476, 1481,
714 1490, 1495, 1498, 1505, 1507, 1509, 1513, 1516, 1525, 1532,
715 1534, 1538, 1551, 1553, 1559, 1565, 1569, 1571, 1575, 1578,
716 1580, 1584, 1587, 1589, 1591, 1595, 1598, 1600, 1602, 1606,
717 1609, 1611, 1613, 1617, 1623, 1625, 1629, 1636, 1638, 1640,
718 1642, 1646, 1654, 1657, 1659, 1664, 1668, 1670, 1677, 1685,
719 1702, 1704, 1706, 1710, 1713, 1718, 1720, 1723, 1725, 1727,
720 1729, 1730, 1731, 1732, 1736, 1738, 1740, 1745, 1747, 1749,
721 1751, 1753, 1757, 1760, 1765, 1767, 1772, 1773, 1774, 1775,
722 1776, 1778, 1780, 1782, 1784, 1786, 1790, 1792, 1795, 1801,
723 1806, 1810, 1813, 1815, 1817, 1821, 1823, 1825, 1827, 1831,
724 1834, 1838, 1844, 1846, 1854, 1881, 1883, 1887, 1892, 1899,
725 1903, 1906, 1908, 1919, 1930, 1935, 1944, 1946, 1950, 1953,
726 1955, 1960, 1965, 1970, 1977, 1979, 1980, 1981, 1984, 1989,
727 1994, 1996, 1997, 1999, 2001, 2002, 2004, 2008, 2011, 2015,
728 2018, 2022, 2024, 2026, 2028, 2029, 2031, 2035, 2044, 2046,
729 2048, 2061, 2063, 2069, 2071, 2073, 2077, 2079, 2084, 2089,
730 2094, 2096, 2098, 2102, 2104, 2109, 2114, 2116, 2120, 2122,
731 2127, 2132, 2137, 2139, 2141, 2145, 2147, 2152, 2157, 2162,
732 2167, 2169, 2171, 2173, 2175, 2177, 2181, 2183, 2188, 2193,
733 2195, 2199, 2201, 2206, 2210, 2212, 2217, 2221, 2223, 2228,
734 2232, 2234, 2239, 2243, 2245, 2250, 2254, 2256, 2261, 2267,
735 2269, 2273, 2275, 2278, 2281, 2289, 2291, 2292, 2295, 2297,
736 2300, 2304
737 };
738 #endif
739
740
741 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
742
743 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
744 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
745 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
746 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
747 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
748 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
749 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
750 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
751 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
752 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
753 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
754 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
755 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
756 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
757 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
758 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
759 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
760 "class_type","interface_type","array_type","name","simple_name","qualified_name",
761 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
762 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
763 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
764 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
765 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
766 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
767 "method_declarator","formal_parameter_list","formal_parameter","throws","class_type_list",
768 "method_body","static_initializer","static","constructor_declaration","@4","constructor_header",
769 "constructor_declarator","constructor_body","constructor_block_end","explicit_constructor_invocation",
770 "this_or_super","interface_declaration","@5","@6","@7","@8","extends_interfaces",
771 "interface_body","interface_member_declarations","interface_member_declaration",
772 "constant_declaration","abstract_method_declaration","array_initializer","variable_initializers",
773 "block","block_begin","block_end","block_statements","block_statement","local_variable_declaration_statement",
774 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
775 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
776 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
777 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
778 "switch_block_statement_group","switch_labels","switch_label","while_expression",
779 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
780 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
781 "statement_expression_list","break_statement","continue_statement","return_statement",
782 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
783 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
784 "class_instance_creation_expression","something_dot_new","argument_list","array_creation_expression",
785 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
786 "postfix_expression","post_increment_expression","post_decrement_expression",
787 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
788 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
789 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
790 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
791 "conditional_expression","assignment_expression","assignment","left_hand_side",
792 "assignment_operator","expression","constant_expression", NULL
793 };
794 #endif
795
796 static const short yyr1[] = { 0,
797 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
798 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
799 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
800 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
801 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
802 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
803 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
804 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
805 140, 140, 141, 141, 141, 141, 141, 142, 142, 143,
806 143, 143, 144, 144, 144, 144, 145, 145, 145, 145,
807 145, 146, 146, 148, 147, 147, 149, 149, 149, 149,
808 149, 149, 149, 149, 149, 150, 150, 150, 150, 150,
809 151, 151, 151, 152, 152, 152, 152, 153, 153, 153,
810 154, 154, 154, 155, 155, 155, 156, 156, 157, 159,
811 158, 160, 160, 161, 161, 162, 162, 162, 162, 163,
812 163, 164, 164, 164, 164, 165, 165, 167, 166, 168,
813 166, 169, 166, 170, 166, 166, 166, 171, 171, 171,
814 171, 172, 172, 173, 173, 174, 174, 174, 174, 175,
815 176, 176, 177, 177, 177, 178, 178, 178, 179, 179,
816 180, 181, 182, 182, 183, 183, 183, 184, 185, 185,
817 186, 186, 186, 186, 186, 186, 187, 187, 187, 187,
818 187, 188, 188, 188, 188, 188, 188, 188, 188, 188,
819 188, 188, 189, 190, 191, 191, 192, 193, 193, 193,
820 193, 193, 193, 193, 193, 193, 193, 193, 193, 193,
821 194, 194, 194, 194, 194, 194, 194, 195, 195, 195,
822 195, 196, 197, 199, 198, 200, 200, 200, 200, 201,
823 201, 201, 201, 202, 202, 203, 204, 204, 205, 205,
824 205, 205, 205, 206, 207, 207, 207, 207, 208, 209,
825 210, 211, 211, 211, 211, 211, 212, 212, 213, 213,
826 213, 214, 215, 215, 215, 215, 216, 216, 217, 217,
827 217, 218, 218, 218, 218, 219, 219, 219, 219, 220,
828 220, 220, 220, 221, 221, 221, 222, 222, 222, 222,
829 222, 223, 224, 224, 224, 224, 225, 225, 226, 227,
830 227, 227, 227, 228, 228, 229, 229, 230, 230, 230,
831 230, 230, 230, 230, 230, 230, 230, 230, 230, 230,
832 230, 230, 231, 231, 231, 231, 231, 231, 231, 231,
833 231, 231, 231, 231, 231, 231, 232, 232, 233, 233,
834 233, 234, 234, 234, 234, 234, 234, 234, 234, 235,
835 235, 236, 236, 236, 237, 237, 237, 238, 238, 238,
836 239, 239, 239, 239, 239, 239, 239, 239, 240, 240,
837 240, 240, 240, 240, 241, 241, 241, 241, 242, 243,
838 244, 244, 244, 244, 244, 244, 244, 245, 245, 246,
839 246, 247, 247, 247, 247, 247, 247, 248, 248, 248,
840 248, 248, 248, 248, 248, 248, 249, 249, 249, 249,
841 249, 249, 249, 250, 250, 250, 250, 250, 251, 251,
842 251, 251, 251, 251, 251, 252, 252, 252, 252, 252,
843 252, 252, 252, 252, 252, 252, 253, 253, 253, 253,
844 253, 254, 254, 254, 255, 255, 255, 256, 256, 256,
845 257, 257, 257, 258, 258, 258, 259, 259, 259, 259,
846 259, 260, 260, 261, 261, 262, 262, 262, 263, 263,
847 264, 265
848 };
849
850 static const short yyr2[] = { 0,
851 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
852 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
853 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
854 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
855 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
856 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
857 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
858 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
859 1, 1, 1, 2, 1, 1, 1, 3, 4, 1,
860 3, 3, 1, 3, 3, 4, 1, 3, 2, 3,
861 3, 1, 1, 0, 3, 2, 3, 3, 4, 4,
862 2, 3, 2, 3, 2, 3, 4, 3, 3, 3,
863 1, 3, 3, 2, 3, 2, 3, 0, 2, 2,
864 1, 3, 3, 1, 2, 1, 2, 3, 1, 0,
865 3, 2, 3, 3, 4, 2, 3, 3, 4, 1,
866 2, 4, 5, 7, 6, 1, 1, 0, 4, 0,
867 5, 0, 5, 0, 6, 3, 4, 2, 3, 2,
868 3, 2, 3, 1, 2, 1, 1, 1, 1, 1,
869 2, 2, 2, 3, 4, 1, 3, 3, 2, 3,
870 1, 1, 1, 2, 1, 1, 1, 2, 2, 3,
871 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
872 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
873 1, 1, 1, 2, 2, 2, 2, 2, 2, 2,
874 2, 3, 4, 4, 5, 4, 5, 6, 7, 6,
875 1, 1, 1, 1, 1, 1, 1, 5, 2, 3,
876 4, 7, 7, 0, 3, 4, 2, 3, 5, 2,
877 3, 3, 4, 1, 2, 2, 1, 2, 3, 2,
878 2, 3, 2, 4, 2, 2, 3, 4, 2, 1,
879 7, 7, 6, 3, 5, 4, 7, 6, 2, 2,
880 3, 2, 0, 1, 1, 2, 0, 1, 1, 3,
881 3, 2, 3, 2, 3, 2, 3, 2, 3, 2,
882 3, 2, 3, 3, 2, 3, 5, 5, 2, 4,
883 3, 1, 3, 3, 4, 2, 1, 2, 2, 4,
884 2, 3, 4, 2, 2, 1, 1, 1, 1, 3,
885 1, 1, 1, 1, 3, 3, 3, 3, 3, 3,
886 3, 3, 5, 4, 6, 5, 4, 5, 5, 6,
887 3, 3, 4, 5, 2, 3, 3, 3, 1, 3,
888 3, 3, 3, 4, 4, 4, 4, 3, 3, 1,
889 2, 3, 3, 2, 2, 3, 3, 3, 3, 2,
890 3, 4, 5, 6, 5, 6, 4, 4, 4, 4,
891 3, 4, 3, 4, 1, 1, 1, 1, 2, 2,
892 1, 1, 2, 2, 1, 2, 2, 2, 2, 2,
893 2, 1, 2, 2, 1, 2, 2, 5, 4, 4,
894 5, 4, 2, 5, 4, 5, 1, 3, 3, 3,
895 3, 3, 3, 1, 3, 3, 3, 3, 1, 3,
896 3, 3, 3, 3, 3, 1, 3, 3, 3, 3,
897 3, 3, 3, 3, 3, 3, 1, 3, 3, 3,
898 3, 1, 3, 3, 1, 3, 3, 1, 3, 3,
899 1, 3, 3, 1, 3, 3, 1, 5, 4, 3,
900 5, 1, 1, 3, 3, 1, 1, 1, 1, 1,
901 1, 1
902 };
903
904 static const short yydefact[] = { 0,
905 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
906 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
907 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
908 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
909 166, 0, 0, 162, 63, 0, 69, 42, 40, 0,
910 0, 0, 61, 0, 49, 0, 26, 170, 17, 168,
911 15, 0, 159, 0, 0, 68, 16, 0, 0, 59,
912 167, 0, 164, 64, 69, 50, 48, 12, 0, 10,
913 11, 172, 0, 8, 9, 13, 14, 15, 0, 178,
914 180, 0, 179, 0, 174, 176, 177, 171, 169, 163,
915 67, 71, 72, 70, 0, 161, 0, 57, 113, 0,
916 128, 111, 0, 0, 90, 93, 128, 0, 0, 0,
917 115, 0, 0, 182, 181, 173, 175, 0, 0, 60,
918 165, 0, 0, 0, 0, 108, 99, 88, 0, 0,
919 0, 0, 107, 21, 18, 22, 20, 19, 114, 128,
920 112, 0, 128, 74, 73, 55, 191, 75, 23, 0,
921 86, 0, 77, 79, 83, 85, 0, 80, 0, 81,
922 140, 128, 87, 82, 0, 58, 119, 116, 0, 0,
923 0, 121, 130, 131, 129, 120, 118, 92, 0, 91,
924 95, 0, 0, 0, 0, 0, 0, 0, 339, 0,
925 0, 0, 0, 6, 5, 2, 3, 4, 7, 338,
926 0, 406, 0, 103, 405, 336, 341, 0, 337, 342,
927 343, 344, 422, 407, 408, 437, 411, 412, 415, 425,
928 444, 449, 456, 467, 472, 475, 478, 481, 484, 487,
929 492, 501, 493, 0, 102, 100, 98, 101, 110, 89,
930 109, 189, 0, 128, 76, 78, 84, 106, 0, 137,
931 0, 142, 0, 55, 0, 0, 280, 0, 0, 0,
932 0, 0, 0, 0, 0, 339, 0, 223, 0, 8,
933 406, 0, 0, 197, 0, 212, 0, 193, 195, 0,
934 196, 201, 213, 0, 202, 214, 0, 203, 204, 215,
935 254, 0, 205, 0, 216, 206, 293, 0, 217, 218,
936 219, 221, 220, 0, 222, 247, 246, 0, 244, 245,
937 242, 243, 241, 126, 124, 0, 117, 0, 0, 416,
938 406, 342, 344, 413, 417, 414, 421, 420, 419, 418,
939 0, 390, 0, 0, 0, 16, 0, 426, 423, 427,
940 424, 433, 0, 406, 0, 183, 186, 0, 0, 0,
941 0, 0, 96, 0, 0, 365, 0, 410, 409, 0,
942 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
943 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
944 499, 500, 0, 144, 0, 143, 136, 105, 134, 138,
945 191, 141, 0, 230, 231, 229, 249, 0, 315, 0,
946 304, 302, 0, 312, 310, 0, 276, 0, 257, 0,
947 326, 0, 290, 0, 308, 306, 0, 0, 199, 0,
948 0, 226, 224, 0, 0, 192, 190, 194, 198, 322,
949 406, 225, 228, 0, 275, 0, 406, 0, 295, 299,
950 292, 0, 0, 319, 0, 127, 125, 123, 122, 133,
951 132, 352, 347, 0, 389, 379, 378, 361, 0, 372,
952 380, 0, 373, 0, 362, 0, 0, 0, 0, 0,
953 0, 349, 340, 184, 0, 351, 346, 391, 0, 369,
954 401, 0, 350, 345, 367, 348, 368, 388, 403, 0,
955 366, 0, 441, 438, 442, 439, 443, 440, 447, 445,
956 448, 446, 453, 450, 454, 451, 455, 452, 463, 458,
957 465, 460, 462, 457, 464, 459, 466, 0, 461, 470,
958 468, 471, 469, 474, 473, 477, 476, 480, 479, 483,
959 482, 486, 485, 490, 0, 0, 495, 494, 145, 135,
960 406, 146, 0, 0, 150, 0, 250, 0, 316, 314,
961 305, 303, 313, 311, 277, 0, 258, 0, 0, 0,
962 323, 327, 0, 324, 291, 309, 307, 340, 0, 200,
963 232, 0, 0, 0, 255, 0, 296, 0, 284, 0,
964 0, 321, 0, 397, 398, 0, 384, 385, 0, 381,
965 374, 0, 377, 375, 376, 363, 354, 0, 435, 429,
966 432, 0, 0, 430, 188, 185, 187, 392, 0, 402,
967 399, 0, 404, 400, 357, 0, 489, 0, 0, 147,
968 0, 0, 151, 148, 251, 0, 278, 274, 0, 331,
969 0, 335, 334, 328, 325, 329, 236, 0, 233, 234,
970 0, 0, 0, 260, 0, 264, 0, 267, 0, 301,
971 300, 286, 0, 298, 0, 320, 0, 395, 0, 383,
972 382, 387, 386, 356, 364, 353, 434, 428, 436, 431,
973 371, 370, 393, 0, 358, 359, 491, 488, 0, 149,
974 0, 0, 0, 248, 0, 201, 0, 208, 209, 0,
975 210, 211, 0, 259, 332, 0, 237, 0, 0, 235,
976 273, 270, 271, 502, 0, 262, 265, 0, 261, 0,
977 268, 0, 0, 285, 0, 318, 317, 396, 355, 394,
978 360, 0, 152, 0, 0, 0, 227, 279, 0, 333,
979 330, 240, 238, 0, 272, 269, 263, 0, 283, 0,
980 0, 0, 153, 0, 252, 0, 0, 239, 281, 282,
981 155, 0, 0, 0, 0, 154, 0, 0, 0, 0,
982 288, 0, 253, 287, 0, 0, 0
983 };
984
985 static const short yydefgoto[] = { 775,
986 210, 279, 211, 85, 86, 68, 60, 87, 212, 22,
987 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
988 283, 284, 132, 105, 47, 70, 104, 130, 162, 163,
989 164, 91, 114, 115, 116, 213, 166, 259, 92, 111,
990 181, 182, 136, 185, 398, 168, 169, 170, 261, 171,
991 172, 402, 552, 553, 285, 18, 43, 72, 65, 107,
992 44, 63, 94, 95, 96, 97, 214, 358, 286, 175,
993 555, 720, 288, 289, 290, 291, 695, 292, 293, 294,
994 295, 698, 296, 297, 298, 299, 699, 300, 444, 301,
995 585, 655, 656, 657, 658, 302, 303, 701, 304, 305,
996 306, 702, 307, 308, 451, 663, 664, 309, 310, 311,
997 312, 313, 314, 315, 571, 572, 573, 574, 215, 216,
998 217, 218, 489, 219, 470, 471, 472, 220, 221, 222,
999 223, 224, 225, 226, 227, 228, 229, 230, 231, 232,
1000 233, 234, 235, 236, 237, 238, 239, 240, 241, 242,
1001 243, 244, 393, 490, 715
1002 };
1003
1004 static const short yypact[] = { 507,
1005 -32768,-32768, 15, -30, 18, 244,-32768,-32768, 414, 443,
1006 556,-32768,-32768,-32768,-32768, 714,-32768,-32768,-32768,-32768,
1007 23,-32768,-32768,-32768, 359,-32768, 340,-32768, 49, 601,
1008 -32768,-32768, 585, 603,-32768, -30, 417,-32768,-32768, 92,
1009 -32768, 489, -24, 107,-32768, 529, 295,-32768,-32768, -30,
1010 710, 452,-32768, 344,-32768, 40,-32768,-32768,-32768,-32768,
1011 192, 1047,-32768, 530, -24,-32768,-32768, 388, 534,-32768,
1012 -32768, -24, 107,-32768, 295,-32768,-32768,-32768, 540,-32768,
1013 -32768,-32768, 548, 258,-32768,-32768, 307, 442, 736,-32768,
1014 -32768, 77,-32768, 1638,-32768,-32768,-32768,-32768,-32768,-32768,
1015 -32768,-32768,-32768, 312, 406,-32768, -24,-32768,-32768, 379,
1016 -18,-32768, 426, 331,-32768, 693, -18, 120, 210, 429,
1017 -32768, 564, 587,-32768,-32768,-32768,-32768, 593, 951,-32768,
1018 -32768, 406, 607, 617, 214,-32768,-32768,-32768, 618, 1077,
1019 219, 531,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -18,
1020 -32768, 361, -18,-32768,-32768, 460, 471,-32768, 494, 736,
1021 -32768, 1204,-32768,-32768, 500,-32768, 180,-32768, 535,-32768,
1022 -32768, 591,-32768,-32768, 1759,-32768,-32768,-32768, 620, 728,
1023 377,-32768,-32768,-32768, 613,-32768,-32768,-32768, 157,-32768,
1024 -32768, 2663, 2728, 2779, 2844, 655, 32, 707,-32768, 2895,
1025 2960, 3011, 5025,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1026 673, 881, 56,-32768, 678, 746,-32768, 640,-32768, 671,
1027 -32768, 715, 866,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1028 899, 921, 1006, 838, 920, 654, 814, 820, 847, 263,
1029 -32768,-32768,-32768, 850,-32768,-32768,-32768,-32768,-32768,-32768,
1030 -32768,-32768, 963, 591,-32768,-32768,-32768,-32768, 484, 769,
1031 775,-32768, -1, 306, 353, 3076,-32768, 232, 1357, 35,
1032 392, 419, 228, 424, 234, 779, 5324,-32768, -30, 538,
1033 974, 265, 872,-32768, 784,-32768, 1691,-32768,-32768, 789,
1034 -32768,-32768,-32768, 1827,-32768,-32768, 797,-32768,-32768,-32768,
1035 -32768, 1827,-32768, 1827,-32768,-32768, 5375, 802,-32768,-32768,
1036 -32768,-32768,-32768, 427,-32768, 737, 806, 866, 902, 916,
1037 -32768,-32768,-32768,-32768, 891, 642,-32768, 592, 660,-32768,
1038 189,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1039 409,-32768, 666, 964, 793, 793, 428,-32768,-32768,-32768,
1040 -32768,-32768, 777, 1121, 66,-32768,-32768, 622, 432, 5092,
1041 3127, 729,-32768, -28, 3192,-32768, 435,-32768,-32768, 3243,
1042 3308, 3359, 3424, 3475, 3540, 3591, 3656, 3707, 3772, 3823,
1043 3888, 864, 3939, 4004, 4055, 4120, 4171, 4236, 4287, 2032,
1044 -32768,-32768, 4352,-32768, 605,-32768,-32768,-32768, 810,-32768,
1045 -32768,-32768, 1691,-32768,-32768,-32768,-32768, 4403,-32768, 95,
1046 -32768,-32768, 126,-32768,-32768, 174,-32768, 4468,-32768, 4519,
1047 -32768, 785,-32768, 4933,-32768,-32768, 182, 269, 815, 2083,
1048 604,-32768,-32768, -30, 2148,-32768,-32768,-32768,-32768,-32768,
1049 1158,-32768,-32768, 823,-32768, 861, 1018, 728,-32768,-32768,
1050 -32768, 86, 2199,-32768, 4584,-32768, 891,-32768,-32768,-32768,
1051 -32768,-32768,-32768, 565, 836,-32768,-32768,-32768, 2264, 793,
1052 -32768, 590, 793, 590,-32768, 2315, 4635, 223, -43, 2380,
1053 191,-32768, 894,-32768, 1967,-32768,-32768,-32768, 649,-32768,
1054 -32768, 237,-32768,-32768,-32768,-32768,-32768, 839,-32768, 239,
1055 -32768, 5143,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 899,
1056 -32768, 899,-32768, 921,-32768, 921,-32768, 921,-32768, 1006,
1057 -32768, 1006,-32768, 1006,-32768, 1006,-32768, 258,-32768,-32768,
1058 838,-32768, 838,-32768, 920,-32768, 654,-32768, 814,-32768,
1059 820,-32768, 847,-32768, 933, 857,-32768,-32768,-32768,-32768,
1060 1254,-32768, 1691, 859, 856, 1691,-32768, 314,-32768,-32768,
1061 -32768,-32768,-32768,-32768,-32768, 348,-32768, 870, 461, 229,
1062 785,-32768, 535,-32768,-32768,-32768,-32768,-32768, 467, 815,
1063 -32768, 967, 14, 444,-32768, 878,-32768, 5067,-32768, 4958,
1064 876, 887, 892,-32768,-32768, 5208,-32768,-32768, 241,-32768,
1065 895, 299,-32768, 895,-32768,-32768, 406, 17,-32768,-32768,
1066 -32768, 4700, 487,-32768,-32768,-32768,-32768,-32768, 4751,-32768,
1067 -32768, 5259,-32768,-32768, 406, 704,-32768, 4816, 662,-32768,
1068 1691, 2431,-32768,-32768,-32768, 1893,-32768,-32768, 343,-32768,
1069 835,-32768,-32768,-32768,-32768,-32768,-32768, 2496,-32768,-32768,
1070 999, 91, 4867,-32768, 674,-32768, 1467,-32768, 5324,-32768,
1071 -32768,-32768, 928, 923, 5000,-32768, 410,-32768, 723,-32768,
1072 -32768,-32768,-32768,-32768,-32768, 406,-32768,-32768,-32768,-32768,
1073 -32768,-32768,-32768, 731,-32768, 406,-32768,-32768, 477,-32768,
1074 243, 108, 485,-32768, 978, 979, 1893,-32768,-32768, 1893,
1075 -32768,-32768, 942,-32768, 948, 950,-32768, 1053, 128,-32768,
1076 -32768,-32768,-32768,-32768, 328,-32768,-32768, 1540,-32768, 1608,
1077 -32768, 961, 1827,-32768, 970,-32768,-32768,-32768,-32768,-32768,
1078 -32768, 2547,-32768, 262, 4403, 1827,-32768,-32768, 2612,-32768,
1079 -32768,-32768,-32768, 1071,-32768,-32768,-32768, 980,-32768, 1827,
1080 296, 202,-32768, 358,-32768, 4958, 983,-32768,-32768,-32768,
1081 -32768, 302, 1893, 990, 5000,-32768, 1021, 1893, 992, 1893,
1082 -32768, 1893,-32768,-32768, 1087, 1089,-32768
1083 };
1084
1085 static const short yypgoto[] = {-32768,
1086 -32768, -57, -60, 711, -16, -123, 568,-32768, -3, 552,
1087 -32768, 130,-32768, 1085, 791,-32768, 22,-32768,-32768, 778,
1088 12, 154,-32768,-32768, 1044, 1030,-32768, -128,-32768, 945,
1089 -32768, 382, -106, 973, -165, -193,-32768,-32768, 469, -58,
1090 865, -327, -40,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1091 957,-32768, 142,-32768, 718, -10,-32768,-32768,-32768,-32768,
1092 1072, 584,-32768, 1031,-32768,-32768, 372,-32768, -122, 867,
1093 843, -166, -279,-32768, 819, -234, 197, -551,-32768, -529,
1094 -32768,-32768,-32768, -301,-32768,-32768,-32768,-32768,-32768,-32768,
1095 -32768,-32768, 476, 486, -619, -496,-32768,-32768,-32768,-32768,
1096 -32768,-32768,-32768, -436,-32768, -603, 832,-32768,-32768,-32768,
1097 -32768,-32768,-32768,-32768,-32768, 569,-32768, 573,-32768,-32768,
1098 119,-32768, -386,-32768, 799, 362, -326, 858, 163, 1120,
1099 320, 437, 438, -112, 560, 636, -470,-32768, 632, 724,
1100 651, 625, 761, 765, 760, 764, 776,-32768, 526, 771,
1101 717,-32768,-32768, 29,-32768
1102 };
1103
1104
1105 #define YYLAST 5484
1106
1107
1108 static const short yytable[] = { 21,
1109 459, 84, 29, 176, 83, 450, 174, 438, 287, 357,
1110 184, 16, 614, 325, 650, 19, 152, 675, 26, 474,
1111 16, 16, 16, 38, 117, 59, 479, 481, 84, 67,
1112 31, 123, 342, 84, 134, 342, 83, 721, 61, 174,
1113 76, 16, 61, 497, 16, 16, 260, 59, 583, 48,
1114 612, 93, 59, 602, 31, 20, 363, 20, 88, 442,
1115 61, 725, 16, 150, 153, 61, 482, 445, 84, 446,
1116 62, 83, 84, 89, 347, 179, 143, 124, 135, 334,
1117 336, 338, 340, 93, 696, 88, 587, 349, 351, 608,
1118 88, 711, 55, 404, 405, 559, 56, 406, 721, 84,
1119 20, 84, 123, 20, 83, 89, 697, 651, 650, 249,
1120 676, 59, 251, 619, 280, 626, 619, 67, 173, 84,
1121 144, 39, 326, 40, 61, 88, 561, -157, 743, 88,
1122 61, 262, 343, 25, 27, 343, 399, 345, 77, 700,
1123 160, 353, 680, 601, 180, 696, 604, 49, 696, 50,
1124 422, 173, 764, 17, -94, -94, 88, 137, 88, 483,
1125 457, 769, 17, 17, 17, 52, 54, 697, 245, 57,
1126 697, 281, 429, 160, 563, 125, 88, 20, 712, 57,
1127 258, 346, 576, 17, -294, 588, 17, 17, 331, 331,
1128 331, 331, 84, 560, 61, 179, 331, 331, 354, 703,
1129 700, 734, 743, 700, 17, 461, 64, 619, 110, 669,
1130 146, 696, 113, 396, 186, 90, 696, 145, 696, 246,
1131 696, 744, 84, 611, 562, 434, 280, 619, 421, 642,
1132 355, 245, 411, 697, 425, 684, 556, 620, 697, 623,
1133 697, 670, 697, 649, 28, 692, 280, 90, -97, 88,
1134 -97, 110, 113, -97, -97, -97, -97, 504, 506, 508,
1135 703, 709, 710, 703, 180, 432, 700, 84, 189, 482,
1136 179, 700, 564, 700, -104, 700, 438, 389, -104, 88,
1137 577, 360, 161, 281, 613, 361, 661, 602, 450, 362,
1138 441, 617, 50, 316, 410, 762, 742, 416, 441, 672,
1139 441, 619, 758, 447, 282, 428, -322, 147, 189, -25,
1140 -25, 187, 67, 706, 635, 161, 247, 20, 448, 20,
1141 598, 528, 157, 157, 88, 61, 703, 580, 745, 20,
1142 412, 703, 426, 703, 621, 703, 624, 317, 671, 180,
1143 45, 733, 280, 704, 74, 752, 69, 367, 637, 390,
1144 -25, 438, 433, 407, 118, -25, -25, -25, 635, 41,
1145 753, -25, 578, 450, 610, -25, 331, 331, 331, 331,
1146 331, 331, 331, 331, 331, 331, 331, 331, 88, 331,
1147 331, 331, 331, 331, 331, 331, 631, 84, 101, 492,
1148 434, -65, 417, 500, 761, -65, 673, 413, -322, 551,
1149 766, 694, 46, 119, 427, 316, 46, 636, 189, 462,
1150 726, 128, 316, -30, 1, 746, 282, 53, 546, 419,
1151 316, 42, 316, 282, 423, 316, 137, 454, 475, 138,
1152 139, 282, 486, 282, -65, 501, 558, -256, -65, -66,
1153 438, 638, -31, 1, 88, 408, 566, 643, 568, 317,
1154 646, 763, 71, -158, 450, 189, 317, 2, 492, 250,
1155 139, 640, 442, 450, 317, 445, 317, 647, 3, 317,
1156 327, 133, 465, 331, 4, 463, 328, 647, 674, 331,
1157 5, 591, -66, 593, 418, 407, 2, 679, 749, 58,
1158 652, 57, 280, 498, 318, 280, 685, 599, 487, 678,
1159 129, 755, 20, 4, 157, 653, -28, 1, 492, 5,
1160 165, 420, 7, 245, 42, 760, 424, -97, 133, 455,
1161 476, 316, -97, -97, -97, -97, 148, 502, 694, 66,
1162 98, 248, 282, 749, 102, 755, 78, 760, 120, 654,
1163 109, 7, 50, 165, 727, 196, -160, 729, 112, 281,
1164 2, 197, 281, 641, -139, -29, 1, 731, 198, 648,
1165 57, 3, 199, 189, 149, 317, 252, 4, 80, 732,
1166 280, 81, 20, 5, 20, 200, 201, 735, 157, 202,
1167 84, 6, 397, 179, -32, 1, 253, 151, 204, 205,
1168 206, 207, 458, 154, 208, 209, 280, 167, 257, 2,
1169 -34, 1, -33, 1, 493, 7, 318, 177, 331, 331,
1170 3, 319, 320, 318, 20, 20, 4, 183, 188, 20,
1171 324, 318, 5, 318, 331, 20, 318, 281, 2, 157,
1172 167, 99, 441, 20, 118, 2, 103, 88, 359, 3,
1173 366, 78, 456, 134, 2, 4, 2, 682, 100, 20,
1174 2, 5, 180, 281, 7, 106, 78, 280, 594, 280,
1175 460, 4, 493, 4, 385, 595, 464, 5, 579, 5,
1176 494, 316, 20, 80, 316, 495, 81, 20, 20, 496,
1177 159, 714, 282, 7, 203, 282, 602, 722, 80, 20,
1178 131, 81, 20, 441, 630, 155, 441, 634, 549, 7,
1179 178, 7, 20, 20, 328, 20, 316, 344, 316, -35,
1180 1, 159, 329, 159, 281, 317, 281, 484, 317, 441,
1181 652, 485, 318, 319, 320, 20, 689, 20, 494, 493,
1182 319, 320, 441, 495, 321, 653, 121, 496, 319, 320,
1183 319, 320, 618, 319, 320, 20, 441, 20, 619, 316,
1184 317, 20, 317, 2, 316, 341, 78, 35, 57, 441,
1185 282, -497, -497, 754, 441, 282, 441, 757, 441, 716,
1186 4, 35, 690, 359, 36, 316, 5, 78, 364, 35,
1187 37, -341, -341, 316, 140, 78, 282, 32, 80, 141,
1188 142, 81, 20, 317, 122, 494, 36, 686, 317, 30,
1189 495, 34, 37, 619, 496, -498, -498, 32, 7, 80,
1190 322, 32, 81, 20, 20, 316, 728, 80, 316, 317,
1191 81, 20, 619, 51, 730, 386, 282, 317, 32, 282,
1192 619, 600, 387, -341, 600, 705, 316, -341, 316, 319,
1193 320, 316, 365, 603, 569, 605, 321, 282, 570, 282,
1194 -343, -343, 282, 321, 316, 378, 379, 380, 381, 317,
1195 388, 321, 317, 321, 527, 282, 321, 400, 316, 401,
1196 477, -156, 318, 478, 316, 318, 435, 359, 2, 282,
1197 317, 316, 317, 316, 78, 317, 316, 439, 316, 469,
1198 316, 323, 282, 737, 382, 443, 738, 282, 317, 282,
1199 453, 282, -343, 370, 371, 372, -343, 318, 550, 318,
1200 368, 369, 317, 78, 139, 35, 80, 584, 317, 81,
1201 20, 78, 322, 373, 374, 317, 586, 317, 596, 322,
1202 317, 622, 317, 627, 317, 383, 384, 322, 37, 322,
1203 391, 392, 322, 78, 628, 80, -407, -407, 81, 20,
1204 318, 632, 196, 80, 633, 318, 81, 20, 197, 767,
1205 -408, -408, 321, 639, 771, 198, 773, 649, 774, 199,
1206 659, -496, -496, 360, 665, 80, 318, 361, 81, 20,
1207 666, 362, 200, 201, 318, 667, 202, 141, 142, 319,
1208 320, 602, 319, 320, 156, 204, 205, 206, 207, 710,
1209 78, 208, 209, 323, 510, 512, 2, 531, 533, 79,
1210 323, 4, 78, 375, 376, 377, 318, 5, 323, 318,
1211 323, 723, 588, 323, 319, 320, 319, 320, 520, 522,
1212 524, 526, 80, 736, -207, 81, 20, 318, 322, 318,
1213 739, 740, 318, 741, 80, 157, 158, 81, 20, 332,
1214 332, 332, 332, 742, 748, 318, 394, 332, 332, -15,
1215 466, 467, 468, 750, -496, -496, 360, 319, 320, 318,
1216 430, 758, 319, 320, 431, 318, 770, 191, 759, 192,
1217 193, 765, 318, 768, 318, 772, 776, 318, 777, 318,
1218 2, 318, 529, 319, 320, 33, 78, 75, 514, 516,
1219 518, 319, 320, -15, 108, 79, 256, 4, -496, -496,
1220 360, 190, 321, 5, 430, 321, 254, 395, 362, 323,
1221 554, 194, 195, 73, 127, 449, 78, 403, 80, 437,
1222 717, 81, 20, 319, 320, 196, 319, 320, 452, 644,
1223 718, 197, 82, 645, 473, 535, 539, 321, 198, 321,
1224 537, 541, 199, 688, 319, 320, 319, 320, 80, 319,
1225 320, 81, 20, 548, 543, 200, 201, 0, 0, 202,
1226 0, 203, 319, 320, 0, 0, 0, 0, 204, 205,
1227 206, 207, 0, 0, 208, 209, 319, 320, 322, 0,
1228 321, 322, 319, 320, 0, 321, 0, 0, 0, 319,
1229 320, 319, 320, 0, 319, 320, 319, 320, 319, 320,
1230 0, -496, -496, 360, 0, 0, 321, 480, 0, 0,
1231 0, 362, 0, 322, 321, 322, 0, 332, 332, 332,
1232 332, 332, 332, 332, 332, 332, 332, 332, 332, 0,
1233 332, 332, 332, 332, 332, 332, 332, 156, -496, -496,
1234 360, 0, 0, 78, 361, 0, 321, 0, 431, 321,
1235 0, 0, 79, 0, 4, 0, 322, 0, 0, 323,
1236 5, 322, 323, 0, 0, 0, 0, 321, 0, 321,
1237 0, 0, 321, 0, 0, 80, 0, 0, 81, 20,
1238 0, 0, 322, 0, 0, 321, 0, 0, 157, 255,
1239 322, 0, 0, 0, 323, 0, 323, 0, 0, 321,
1240 0, 333, 333, 333, 333, 321, 0, 0, 0, 333,
1241 333, 0, 321, 0, 321, 0, 0, 321, 0, 321,
1242 0, 321, 322, 0, 332, 322, 0, 0, 0, -15,
1243 332, 0, 0, 0, -496, -496, 360, 323, 0, 0,
1244 430, 0, 323, 322, 629, 322, 0, 414, 322, 192,
1245 193, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1246 0, 322, 0, 323, 0, 0, 0, 0, 0, 0,
1247 0, 323, 0, 0, 0, 322, 0, 0, 0, 0,
1248 0, 322, 0, 0, 0, 0, 0, 0, 322, 0,
1249 322, 194, 195, 322, 0, 322, 78, 322, 0, 0,
1250 0, 0, 0, 323, 0, 196, 323, 0, 0, 0,
1251 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1252 0, 0, 199, 0, 323, 0, 323, 0, 80, 323,
1253 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1254 0, 0, 323, 0, 0, 415, 0, 0, 204, 205,
1255 206, 207, 0, 0, 208, 209, 323, 263, 0, 332,
1256 332, 0, 323, 0, 0, 0, 0, 0, 0, 323,
1257 0, 323, 0, 0, 323, 332, 323, 0, 323, 333,
1258 333, 333, 333, 333, 333, 333, 333, 333, 333, 333,
1259 333, 0, 333, 333, 333, 333, 333, 333, 333, 0,
1260 264, 194, 195, 652, 265, 266, 78, 267, 0, 0,
1261 268, 0, 0, 0, 269, 196, 0, 0, 653, 0,
1262 0, 270, 271, 5, 272, 0, 273, 274, 198, 275,
1263 263, 0, 276, 0, 0, 0, 0, 0, 80, 0,
1264 0, 81, 20, 0, 0, 0, 0, 0, 0, 277,
1265 0, 157, 719, 0, 0, 278, 0, 0, 204, 205,
1266 206, 207, 0, 0, 208, 209, 0, 0, 0, 0,
1267 0, 0, 0, 264, 194, 195, 652, 265, 266, 78,
1268 267, 0, 0, 268, 0, 0, 333, 269, 196, 0,
1269 0, 653, 333, 0, 270, 271, 5, 272, 263, 273,
1270 274, 198, 275, 0, 0, 276, 0, 0, 0, 0,
1271 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1272 0, 0, 277, 0, 157, 747, 0, 0, 278, 0,
1273 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1274 0, 264, 194, 195, -266, 265, 266, 78, 267, 0,
1275 0, 268, 0, 0, 0, 269, 196, 0, 0, -266,
1276 0, 0, 270, 271, 5, 272, 0, 273, 274, 198,
1277 275, 2, 0, 276, 0, 0, 0, 78, 0, 80,
1278 0, 263, 81, 20, 0, 0, 79, 0, 4, 0,
1279 277, 0, 157, -266, 5, 0, 278, 0, 0, 204,
1280 205, 206, 207, 0, 0, 208, 209, 0, 0, 80,
1281 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1282 0, 333, 333, 126, 264, 194, 195, 0, 265, 266,
1283 78, 267, 0, 0, 268, 0, 0, 333, 269, 196,
1284 0, 0, 0, 0, 0, 270, 271, 5, 272, 263,
1285 273, 274, 198, 275, 0, 0, 276, 0, 0, 0,
1286 0, 0, 80, 0, 0, 81, 20, 0, 0, 0,
1287 0, 0, 0, 277, 0, 157, 436, 0, 0, 278,
1288 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1289 0, 0, 264, 194, 195, 0, 265, 266, 78, 267,
1290 0, 0, 268, 0, 0, 0, 269, 196, 0, 0,
1291 0, 0, 0, 270, 271, 5, 272, 263, 273, 274,
1292 198, 275, 0, 0, 276, 0, 0, 0, 0, 0,
1293 80, 0, 0, 81, 20, 0, 0, 0, 0, 0,
1294 0, 277, 0, 157, 0, 0, 0, 278, 0, 0,
1295 204, 205, 206, 207, 0, 0, 208, 209, 0, 0,
1296 440, 194, 195, 0, 265, 266, 78, 267, 0, 0,
1297 268, 0, 0, 0, 269, 196, 0, 0, 0, 0,
1298 0, 270, 271, 263, 272, 0, 273, 274, 198, 275,
1299 0, 0, 276, 0, 0, 0, 0, 0, 80, 0,
1300 0, 81, 20, 0, 0, 0, 0, 0, 0, 277,
1301 0, 157, 0, 0, 0, 278, 0, 0, 204, 205,
1302 206, 207, 0, 0, 208, 209, 440, 194, 195, 0,
1303 693, 266, 78, 267, 0, 0, 268, 0, 0, 0,
1304 269, 196, 0, 0, 0, 0, 0, 270, 271, 0,
1305 272, 0, 273, 274, 198, 275, 0, 615, 276, 192,
1306 193, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1307 0, 0, 0, 0, 0, 277, 0, 157, 0, 0,
1308 0, 278, 0, 0, 204, 205, 206, 207, 0, 0,
1309 208, 209, 0, 0, 0, 0, 0, 0, 0, 0,
1310 0, 194, 195, 0, 0, 0, 78, 0, 0, 0,
1311 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1312 0, 197, 544, 0, 192, 193, 0, 0, 198, 0,
1313 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1314 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1315 0, 203, 616, 0, 0, 0, 0, 0, 204, 205,
1316 206, 207, 0, 0, 208, 209, 194, 195, 0, 0,
1317 0, 78, 0, 491, 0, 192, 193, 0, 0, 0,
1318 196, 0, 0, 0, 0, 0, 197, 0, 0, 0,
1319 0, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1320 0, 0, 0, 80, 0, 0, 81, 20, 0, 545,
1321 200, 201, 0, 0, 202, 0, 0, 194, 195, 0,
1322 0, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1323 209, 196, 0, 0, 0, 0, 0, 197, 581, 0,
1324 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1325 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1326 0, 200, 201, 0, 0, 202, 0, 0, 0, 0,
1327 148, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1328 208, 209, 194, 195, 0, 0, 0, 78, 0, 589,
1329 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1330 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1331 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1332 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1333 202, 582, 0, 194, 195, 0, 0, 0, 78, 204,
1334 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1335 0, 0, 0, 197, 597, 0, 192, 193, 0, 0,
1336 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1337 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1338 0, 202, 0, 0, 0, 0, 0, 590, 0, 0,
1339 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1340 0, 0, 0, 78, 0, 606, 0, 192, 193, 0,
1341 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1342 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1343 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1344 0, 0, 200, 201, 0, 0, 202, 0, 0, 194,
1345 195, 598, 0, 0, 78, 204, 205, 206, 207, 0,
1346 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1347 491, 0, 192, 193, 0, 0, 198, 0, 0, 0,
1348 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1349 20, 0, 0, 200, 201, 0, 0, 202, 607, 0,
1350 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1351 0, 0, 208, 209, 194, 195, 0, 0, 0, 78,
1352 0, 581, 0, 192, 193, 0, 0, 0, 196, 0,
1353 0, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1354 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1355 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1356 0, 0, 202, 0, 0, 194, 195, 598, 0, 0,
1357 78, 204, 205, 206, 207, 0, 0, 208, 209, 196,
1358 0, 0, 0, 0, 0, 197, 707, 0, 192, 193,
1359 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1360 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1361 201, 0, 0, 202, 691, 0, 0, 0, 0, 0,
1362 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1363 194, 195, 0, 0, 0, 78, 0, 707, 0, 192,
1364 193, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1365 197, 0, 0, 0, 0, 0, 0, 198, 0, 0,
1366 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1367 81, 20, 0, 0, 200, 201, 0, 0, 202, 708,
1368 0, 194, 195, 0, 0, 0, 78, 204, 205, 206,
1369 207, 0, 0, 208, 209, 196, 0, 0, 0, 0,
1370 0, 197, 589, 0, 192, 193, 0, 0, 198, 0,
1371 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1372 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1373 751, 0, 0, 0, 0, 0, 0, 0, 204, 205,
1374 206, 207, 0, 0, 208, 209, 194, 195, 0, 0,
1375 0, 78, 0, 330, 0, 192, 193, 0, 0, 0,
1376 196, 0, 0, 0, 0, 0, 197, 0, 0, 0,
1377 0, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1378 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1379 200, 201, 0, 0, 202, 0, 0, 194, 195, 0,
1380 756, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1381 209, 196, 0, 0, 0, 0, 0, 197, 335, 0,
1382 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1383 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1384 0, 200, 201, 0, 0, 202, 0, 0, 0, 0,
1385 0, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1386 208, 209, 194, 195, 0, 0, 0, 78, 0, 337,
1387 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1388 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1389 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1390 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1391 202, 0, 0, 194, 195, 0, 0, 0, 78, 204,
1392 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1393 0, 0, 0, 197, 339, 0, 192, 193, 0, 0,
1394 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1395 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1396 0, 202, 0, 0, 0, 0, 0, 0, 0, 0,
1397 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1398 0, 0, 0, 78, 0, 348, 0, 192, 193, 0,
1399 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1400 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1401 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1402 0, 0, 200, 201, 0, 0, 202, 0, 0, 194,
1403 195, 0, 0, 0, 78, 204, 205, 206, 207, 0,
1404 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1405 350, 0, 192, 193, 0, 0, 198, 0, 0, 0,
1406 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1407 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1408 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1409 0, 0, 208, 209, 194, 195, 0, 0, 0, 78,
1410 0, 352, 0, 192, 193, 0, 0, 0, 196, 0,
1411 0, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1412 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1413 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1414 0, 0, 202, 0, 0, 194, 195, 0, 0, 0,
1415 78, 204, 205, 206, 207, 0, 0, 208, 209, 196,
1416 0, 0, 0, 0, 0, 197, 409, 0, 192, 193,
1417 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1418 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1419 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1420 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1421 194, 195, 0, 0, 0, 78, 0, 491, 0, 192,
1422 193, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1423 197, 0, 0, 0, 0, 0, 0, 198, 0, 0,
1424 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1425 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1426 0, 194, 195, 0, 0, 0, 78, 204, 205, 206,
1427 207, 0, 0, 208, 209, 196, 0, 0, 0, 0,
1428 0, 197, 499, 0, 192, 193, 0, 0, 198, 0,
1429 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1430 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1431 0, 0, 0, 0, 0, 0, 0, 0, 204, 205,
1432 206, 207, 0, 0, 208, 209, 194, 195, 0, 0,
1433 0, 78, 0, 503, 0, 192, 193, 0, 0, 0,
1434 196, 0, 0, 0, 0, 0, 197, 0, 0, 0,
1435 0, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1436 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1437 200, 201, 0, 0, 202, 0, 0, 194, 195, 0,
1438 0, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1439 209, 196, 0, 0, 0, 0, 0, 197, 505, 0,
1440 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1441 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1442 0, 200, 201, 0, 0, 202, 0, 0, 0, 0,
1443 0, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1444 208, 209, 194, 195, 0, 0, 0, 78, 0, 507,
1445 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1446 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1447 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1448 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1449 202, 0, 0, 194, 195, 0, 0, 0, 78, 204,
1450 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1451 0, 0, 0, 197, 509, 0, 192, 193, 0, 0,
1452 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1453 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1454 0, 202, 0, 0, 0, 0, 0, 0, 0, 0,
1455 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1456 0, 0, 0, 78, 0, 511, 0, 192, 193, 0,
1457 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1458 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1459 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1460 0, 0, 200, 201, 0, 0, 202, 0, 0, 194,
1461 195, 0, 0, 0, 78, 204, 205, 206, 207, 0,
1462 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1463 513, 0, 192, 193, 0, 0, 198, 0, 0, 0,
1464 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1465 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1466 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1467 0, 0, 208, 209, 194, 195, 0, 0, 0, 78,
1468 0, 515, 0, 192, 193, 0, 0, 0, 196, 0,
1469 0, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1470 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1471 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1472 0, 0, 202, 0, 0, 194, 195, 0, 0, 0,
1473 78, 204, 205, 206, 207, 0, 0, 208, 209, 196,
1474 0, 0, 0, 0, 0, 197, 517, 0, 192, 193,
1475 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1476 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1477 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1478 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1479 194, 195, 0, 0, 0, 78, 0, 519, 0, 192,
1480 193, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1481 197, 0, 0, 0, 0, 0, 0, 198, 0, 0,
1482 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1483 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1484 0, 194, 195, 0, 0, 0, 78, 204, 205, 206,
1485 207, 0, 0, 208, 209, 196, 0, 0, 0, 0,
1486 0, 197, 521, 0, 192, 193, 0, 0, 198, 0,
1487 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1488 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1489 0, 0, 0, 0, 0, 0, 0, 0, 204, 205,
1490 206, 207, 0, 0, 208, 209, 194, 195, 0, 0,
1491 0, 78, 0, 523, 0, 192, 193, 0, 0, 0,
1492 196, 0, 0, 0, 0, 0, 197, 0, 0, 0,
1493 0, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1494 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1495 200, 201, 0, 0, 202, 0, 0, 194, 195, 0,
1496 0, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1497 209, 196, 0, 0, 0, 0, 0, 197, 525, 0,
1498 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1499 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1500 0, 200, 201, 0, 0, 202, 0, 0, 0, 0,
1501 0, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1502 208, 209, 194, 195, 0, 0, 0, 78, 0, 530,
1503 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1504 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1505 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1506 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1507 202, 0, 0, 194, 195, 0, 0, 0, 78, 204,
1508 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1509 0, 0, 0, 197, 532, 0, 192, 193, 0, 0,
1510 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1511 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1512 0, 202, 0, 0, 0, 0, 0, 0, 0, 0,
1513 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1514 0, 0, 0, 78, 0, 534, 0, 192, 193, 0,
1515 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1516 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1517 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1518 0, 0, 200, 201, 0, 0, 202, 0, 0, 194,
1519 195, 0, 0, 0, 78, 204, 205, 206, 207, 0,
1520 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1521 536, 0, 192, 193, 0, 0, 198, 0, 0, 0,
1522 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1523 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1524 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1525 0, 0, 208, 209, 194, 195, 0, 0, 0, 78,
1526 0, 538, 0, 192, 193, 0, 0, 0, 196, 0,
1527 0, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1528 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1529 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1530 0, 0, 202, 0, 0, 194, 195, 0, 0, 0,
1531 78, 204, 205, 206, 207, 0, 0, 208, 209, 196,
1532 0, 0, 0, 0, 0, 197, 540, 0, 192, 193,
1533 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1534 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1535 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1536 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1537 194, 195, 0, 0, 0, 78, 0, 542, 0, 192,
1538 193, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1539 197, 0, 0, 0, 0, 0, 0, 198, 0, 0,
1540 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1541 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1542 0, 194, 195, 0, 0, 0, 78, 204, 205, 206,
1543 207, 0, 0, 208, 209, 196, 0, 0, 0, 0,
1544 0, 197, 547, 0, 192, 193, 0, 0, 198, 0,
1545 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1546 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1547 0, 0, 0, 0, 0, 0, 0, 0, 204, 205,
1548 206, 207, 0, 0, 208, 209, 194, 195, 0, 0,
1549 0, 78, 0, 557, 0, 192, 193, 0, 0, 0,
1550 196, 0, 0, 0, 0, 0, 197, 0, 0, 0,
1551 0, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1552 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1553 200, 201, 0, 0, 202, 0, 0, 194, 195, 0,
1554 0, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1555 209, 196, 0, 0, 0, 0, 0, 197, 565, 0,
1556 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1557 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1558 0, 200, 201, 0, 0, 202, 0, 0, 0, 0,
1559 0, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1560 208, 209, 194, 195, 0, 0, 0, 78, 0, 567,
1561 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1562 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1563 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1564 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1565 202, 0, 0, 194, 195, 0, 0, 0, 78, 204,
1566 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1567 0, 0, 0, 197, 592, 0, 192, 193, 0, 0,
1568 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1569 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1570 0, 202, 0, 0, 0, 0, 0, 0, 0, 0,
1571 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1572 0, 0, 0, 78, 0, 609, 0, 192, 193, 0,
1573 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1574 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1575 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1576 0, 0, 200, 201, 0, 0, 202, 0, 0, 194,
1577 195, 0, 0, 0, 78, 204, 205, 206, 207, 0,
1578 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1579 677, 0, 192, 193, 0, 0, 198, 0, 0, 0,
1580 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1581 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1582 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1583 0, 0, 208, 209, 194, 195, 0, 0, 0, 78,
1584 0, 681, 0, 192, 193, 0, 0, 0, 196, 0,
1585 0, 0, 0, 0, 197, 0, 0, 0, 0, 0,
1586 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1587 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1588 0, 0, 202, 0, 0, 194, 195, 0, 0, 0,
1589 78, 204, 205, 206, 207, 0, 0, 208, 209, 196,
1590 0, 0, 0, 0, 0, 197, 687, 0, 192, 193,
1591 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1592 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1593 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1594 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1595 194, 195, 0, 0, 0, 78, 0, 713, 0, 192,
1596 193, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1597 197, 0, 0, 0, 0, 0, 0, 198, 0, 0,
1598 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1599 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1600 0, 194, 195, 0, 0, 0, 78, 204, 205, 206,
1601 207, 0, 0, 208, 209, 196, 0, 0, 0, 0,
1602 0, 197, 0, 575, 0, 0, 0, 0, 198, 0,
1603 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1604 0, 81, 20, 0, 0, 200, 201, 0, 662, 202,
1605 0, 0, 0, 0, 0, 0, 0, 0, 204, 205,
1606 206, 207, 0, 0, 208, 209, -289, -289, -289, 0,
1607 0, 0, -289, 0, 0, 0, 0, 0, 0, 0,
1608 0, -289, 0, 0, 0, 0, 0, -289, 0, 0,
1609 724, 0, 194, 195, -289, 0, 0, 78, -289, 0,
1610 0, 0, 0, 0, -289, 0, 196, -289, -289, 0,
1611 0, 0, 197, 0, 0, -289, 0, 192, 193, 198,
1612 0, -289, 0, 199, -289, -289, -289, -289, 0, 80,
1613 -289, -289, 81, 20, 194, 195, 0, 0, 0, 78,
1614 277, -297, 0, 0, 0, 0, 0, 0, 196, 204,
1615 205, 206, 207, 0, 197, 208, 209, 660, 0, 194,
1616 195, 198, 0, 0, 78, 199, 0, 0, 0, 0,
1617 0, 80, 0, 196, 81, 20, 0, 0, 0, 197,
1618 0, 0, 277, -297, 192, 193, 198, 0, 0, 0,
1619 199, 204, 205, 206, 207, 0, 80, 208, 209, 81,
1620 20, 194, 195, 200, 201, 0, 78, 202, 0, 203,
1621 356, 0, 0, 0, 0, 196, 204, 205, 206, 207,
1622 0, 197, 208, 209, 0, 0, 194, 195, 198, 0,
1623 0, 78, 199, 0, 0, 192, 193, 0, 80, 0,
1624 196, 81, 20, 0, 0, 0, 197, 0, 0, 277,
1625 0, 0, 0, 198, 0, 0, 0, 199, 204, 205,
1626 206, 207, 0, 80, 208, 209, 81, 20, 0, 0,
1627 200, 201, 0, 0, 202, 488, 0, 194, 195, 0,
1628 0, 0, 78, 204, 205, 206, 207, 0, 0, 208,
1629 209, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1630 192, 193, 0, 0, 198, 0, 0, 0, 199, 0,
1631 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1632 0, 200, 201, 0, 0, 202, 625, 0, 0, 0,
1633 0, 0, 0, 0, 204, 205, 206, 207, 0, 0,
1634 208, 209, 194, 195, 0, 0, 0, 78, 0, 0,
1635 0, 192, 193, 0, 0, 0, 196, 0, 0, 0,
1636 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1637 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1638 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1639 202, 668, 0, 194, 195, 0, 0, 0, 78, 204,
1640 205, 206, 207, 0, 0, 208, 209, 196, 0, 0,
1641 0, 0, 0, 197, 0, 0, 192, 193, 0, 0,
1642 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1643 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1644 0, 202, 683, 0, 0, 0, 0, 0, 0, 0,
1645 204, 205, 206, 207, 0, 0, 208, 209, 194, 195,
1646 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1647 0, 0, 196, 0, 0, 0, 0, 0, 197, 0,
1648 0, 0, 0, 0, 0, 198, 0, 0, 0, 199,
1649 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1650 0, 0, 200, 201, 0, 0, 202, 0, 2, 194,
1651 195, 0, 0, 0, 78, 204, 205, 206, 207, 0,
1652 0, 208, 209, 196, 0, 0, 0, 0, 0, 197,
1653 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1654 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1655 20, 0, 0, 0, 0, 0, 0, 277, 0, 0,
1656 0, 0, 0, 0, 0, 0, 204, 205, 206, 207,
1657 0, 0, 208, 209
1658 };
1659
1660 static const short yycheck[] = { 3,
1661 328, 62, 6, 132, 62, 307, 129, 287, 175, 203,
1662 134, 0, 483, 179, 1, 1, 123, 1, 1, 346,
1663 9, 10, 11, 1, 83, 42, 353, 354, 89, 46,
1664 9, 89, 1, 94, 53, 1, 94, 657, 42, 162,
1665 1, 30, 46, 72, 33, 34, 169, 64, 435, 1,
1666 94, 62, 69, 97, 33, 86, 1, 86, 62, 294,
1667 64, 665, 51, 122, 123, 69, 1, 302, 129, 304,
1668 95, 129, 133, 62, 198, 133, 117, 1, 97, 192,
1669 193, 194, 195, 94, 636, 89, 1, 200, 201, 476,
1670 94, 1, 1, 95, 96, 1, 5, 99, 718, 160,
1671 86, 162, 160, 86, 162, 94, 636, 94, 1, 150,
1672 94, 128, 153, 100, 175, 502, 100, 134, 129, 180,
1673 1, 99, 180, 101, 128, 129, 1, 93, 1, 133,
1674 134, 172, 101, 4, 5, 101, 259, 198, 99, 636,
1675 129, 202, 613, 470, 133, 697, 473, 99, 700, 101,
1676 273, 162, 756, 0, 99, 100, 160, 1, 162, 94,
1677 326, 765, 9, 10, 11, 36, 37, 697, 140, 40,
1678 700, 175, 279, 162, 1, 99, 180, 86, 88, 50,
1679 1, 198, 1, 30, 99, 100, 33, 34, 192, 193,
1680 194, 195, 253, 99, 198, 253, 200, 201, 202, 636,
1681 697, 94, 1, 700, 51, 329, 100, 100, 79, 596,
1682 1, 763, 83, 254, 1, 62, 768, 98, 770, 1,
1683 772, 94, 283, 1, 99, 283, 287, 100, 1, 1,
1684 202, 203, 1, 763, 1, 622, 403, 1, 768, 1,
1685 770, 1, 772, 1, 1, 632, 307, 94, 92, 253,
1686 94, 122, 123, 97, 98, 99, 100, 370, 371, 372,
1687 697, 648, 1, 700, 253, 1, 763, 328, 139, 1,
1688 328, 768, 99, 770, 95, 772, 556, 15, 99, 283,
1689 99, 93, 129, 287, 94, 97, 588, 97, 590, 101,
1690 294, 485, 101, 175, 266, 94, 1, 269, 302, 1,
1691 304, 100, 1, 307, 175, 277, 1, 98, 179, 45,
1692 46, 98, 329, 641, 1, 162, 98, 86, 307, 86,
1693 98, 382, 95, 95, 328, 329, 763, 434, 1, 86,
1694 99, 768, 99, 770, 98, 772, 98, 175, 98, 328,
1695 1, 99, 403, 1, 1, 732, 52, 218, 1, 87,
1696 86, 631, 88, 1, 97, 91, 92, 93, 1, 1,
1697 99, 97, 94, 665, 477, 101, 370, 371, 372, 373,
1698 374, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1699 384, 385, 386, 387, 388, 389, 553, 448, 1, 361,
1700 448, 52, 1, 365, 99, 52, 98, 268, 93, 403,
1701 99, 636, 63, 97, 275, 287, 63, 94, 279, 1,
1702 1, 100, 294, 0, 1, 88, 287, 1, 390, 1,
1703 302, 63, 304, 294, 1, 307, 1, 1, 1, 99,
1704 100, 302, 1, 304, 95, 1, 408, 95, 95, 52,
1705 720, 94, 0, 1, 448, 93, 418, 570, 420, 287,
1706 573, 94, 1, 95, 756, 326, 294, 44, 430, 99,
1707 100, 1, 697, 765, 302, 700, 304, 1, 55, 307,
1708 94, 93, 343, 477, 61, 67, 100, 1, 607, 483,
1709 67, 453, 95, 455, 93, 1, 44, 1, 723, 1,
1710 47, 362, 553, 364, 175, 556, 625, 469, 67, 612,
1711 95, 736, 86, 61, 95, 62, 0, 1, 480, 67,
1712 129, 93, 99, 485, 63, 750, 93, 92, 93, 93,
1713 93, 403, 97, 98, 99, 100, 98, 93, 763, 1,
1714 1, 1, 403, 768, 1, 770, 50, 772, 97, 96,
1715 1, 99, 101, 162, 667, 59, 95, 676, 1, 553,
1716 44, 65, 556, 93, 95, 0, 1, 686, 72, 93,
1717 431, 55, 76, 434, 1, 403, 96, 61, 82, 93,
1718 631, 85, 86, 67, 86, 89, 90, 93, 95, 93,
1719 641, 75, 99, 641, 0, 1, 93, 1, 102, 103,
1720 104, 105, 1, 1, 108, 109, 657, 129, 99, 44,
1721 0, 1, 0, 1, 1, 99, 287, 1, 612, 613,
1722 55, 175, 175, 294, 86, 86, 61, 1, 1, 86,
1723 1, 302, 67, 304, 628, 86, 307, 631, 44, 95,
1724 162, 64, 636, 86, 97, 44, 69, 641, 101, 55,
1725 1, 50, 1, 53, 44, 61, 44, 619, 65, 86,
1726 44, 67, 641, 657, 99, 72, 50, 718, 94, 720,
1727 1, 61, 1, 61, 11, 101, 1, 67, 65, 67,
1728 67, 553, 86, 82, 556, 72, 85, 86, 86, 76,
1729 129, 653, 553, 99, 95, 556, 97, 659, 82, 86,
1730 107, 85, 86, 697, 553, 128, 700, 556, 94, 99,
1731 94, 99, 86, 86, 100, 86, 588, 1, 590, 0,
1732 1, 160, 100, 162, 718, 553, 720, 96, 556, 723,
1733 47, 100, 403, 287, 287, 86, 65, 86, 67, 1,
1734 294, 294, 736, 72, 175, 62, 1, 76, 302, 302,
1735 304, 304, 94, 307, 307, 86, 750, 86, 100, 631,
1736 588, 86, 590, 44, 636, 101, 50, 44, 629, 763,
1737 631, 91, 92, 735, 768, 636, 770, 739, 772, 96,
1738 61, 44, 631, 101, 61, 657, 67, 50, 101, 44,
1739 67, 45, 46, 665, 92, 50, 657, 10, 82, 97,
1740 98, 85, 86, 631, 59, 67, 61, 94, 636, 9,
1741 72, 11, 67, 100, 76, 91, 92, 30, 99, 82,
1742 175, 34, 85, 86, 86, 697, 94, 82, 700, 657,
1743 85, 86, 100, 33, 94, 12, 697, 665, 51, 700,
1744 100, 470, 13, 97, 473, 1, 718, 101, 720, 403,
1745 403, 723, 97, 472, 60, 474, 287, 718, 64, 720,
1746 45, 46, 723, 294, 736, 18, 19, 20, 21, 697,
1747 14, 302, 700, 304, 1, 736, 307, 99, 750, 95,
1748 94, 93, 553, 97, 756, 556, 93, 101, 44, 750,
1749 718, 763, 720, 765, 50, 723, 768, 99, 770, 97,
1750 772, 175, 763, 697, 57, 99, 700, 768, 736, 770,
1751 99, 772, 97, 5, 6, 7, 101, 588, 99, 590,
1752 45, 46, 750, 50, 100, 44, 82, 95, 756, 85,
1753 86, 50, 287, 3, 4, 763, 66, 765, 93, 294,
1754 768, 93, 770, 1, 772, 16, 17, 302, 67, 304,
1755 91, 92, 307, 50, 88, 82, 45, 46, 85, 86,
1756 631, 93, 59, 82, 99, 636, 85, 86, 65, 763,
1757 45, 46, 403, 94, 768, 72, 770, 1, 772, 76,
1758 93, 91, 92, 93, 99, 82, 657, 97, 85, 86,
1759 94, 101, 89, 90, 665, 94, 93, 97, 98, 553,
1760 553, 97, 556, 556, 44, 102, 103, 104, 105, 1,
1761 50, 108, 109, 287, 373, 374, 44, 383, 384, 59,
1762 294, 61, 50, 8, 9, 10, 697, 67, 302, 700,
1763 304, 94, 100, 307, 588, 588, 590, 590, 378, 379,
1764 380, 381, 82, 56, 56, 85, 86, 718, 403, 720,
1765 99, 94, 723, 94, 82, 95, 96, 85, 86, 192,
1766 193, 194, 195, 1, 94, 736, 94, 200, 201, 86,
1767 97, 98, 99, 94, 91, 92, 93, 631, 631, 750,
1768 97, 1, 636, 636, 101, 756, 56, 1, 99, 3,
1769 4, 99, 763, 94, 765, 94, 0, 768, 0, 770,
1770 44, 772, 382, 657, 657, 11, 50, 54, 375, 376,
1771 377, 665, 665, 86, 75, 59, 162, 61, 91, 92,
1772 93, 139, 553, 67, 97, 556, 160, 253, 101, 403,
1773 403, 45, 46, 52, 94, 307, 50, 261, 82, 287,
1774 655, 85, 86, 697, 697, 59, 700, 700, 307, 571,
1775 655, 65, 96, 571, 346, 385, 387, 588, 72, 590,
1776 386, 388, 76, 628, 718, 718, 720, 720, 82, 723,
1777 723, 85, 86, 393, 389, 89, 90, -1, -1, 93,
1778 -1, 95, 736, 736, -1, -1, -1, -1, 102, 103,
1779 104, 105, -1, -1, 108, 109, 750, 750, 553, -1,
1780 631, 556, 756, 756, -1, 636, -1, -1, -1, 763,
1781 763, 765, 765, -1, 768, 768, 770, 770, 772, 772,
1782 -1, 91, 92, 93, -1, -1, 657, 97, -1, -1,
1783 -1, 101, -1, 588, 665, 590, -1, 370, 371, 372,
1784 373, 374, 375, 376, 377, 378, 379, 380, 381, -1,
1785 383, 384, 385, 386, 387, 388, 389, 44, 91, 92,
1786 93, -1, -1, 50, 97, -1, 697, -1, 101, 700,
1787 -1, -1, 59, -1, 61, -1, 631, -1, -1, 553,
1788 67, 636, 556, -1, -1, -1, -1, 718, -1, 720,
1789 -1, -1, 723, -1, -1, 82, -1, -1, 85, 86,
1790 -1, -1, 657, -1, -1, 736, -1, -1, 95, 96,
1791 665, -1, -1, -1, 588, -1, 590, -1, -1, 750,
1792 -1, 192, 193, 194, 195, 756, -1, -1, -1, 200,
1793 201, -1, 763, -1, 765, -1, -1, 768, -1, 770,
1794 -1, 772, 697, -1, 477, 700, -1, -1, -1, 86,
1795 483, -1, -1, -1, 91, 92, 93, 631, -1, -1,
1796 97, -1, 636, 718, 101, 720, -1, 1, 723, 3,
1797 4, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1798 -1, 736, -1, 657, -1, -1, -1, -1, -1, -1,
1799 -1, 665, -1, -1, -1, 750, -1, -1, -1, -1,
1800 -1, 756, -1, -1, -1, -1, -1, -1, 763, -1,
1801 765, 45, 46, 768, -1, 770, 50, 772, -1, -1,
1802 -1, -1, -1, 697, -1, 59, 700, -1, -1, -1,
1803 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
1804 -1, -1, 76, -1, 718, -1, 720, -1, 82, 723,
1805 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1806 -1, -1, 736, -1, -1, 99, -1, -1, 102, 103,
1807 104, 105, -1, -1, 108, 109, 750, 1, -1, 612,
1808 613, -1, 756, -1, -1, -1, -1, -1, -1, 763,
1809 -1, 765, -1, -1, 768, 628, 770, -1, 772, 370,
1810 371, 372, 373, 374, 375, 376, 377, 378, 379, 380,
1811 381, -1, 383, 384, 385, 386, 387, 388, 389, -1,
1812 44, 45, 46, 47, 48, 49, 50, 51, -1, -1,
1813 54, -1, -1, -1, 58, 59, -1, -1, 62, -1,
1814 -1, 65, 66, 67, 68, -1, 70, 71, 72, 73,
1815 1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1816 -1, 85, 86, -1, -1, -1, -1, -1, -1, 93,
1817 -1, 95, 96, -1, -1, 99, -1, -1, 102, 103,
1818 104, 105, -1, -1, 108, 109, -1, -1, -1, -1,
1819 -1, -1, -1, 44, 45, 46, 47, 48, 49, 50,
1820 51, -1, -1, 54, -1, -1, 477, 58, 59, -1,
1821 -1, 62, 483, -1, 65, 66, 67, 68, 1, 70,
1822 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1823 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1824 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
1825 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1826 -1, 44, 45, 46, 47, 48, 49, 50, 51, -1,
1827 -1, 54, -1, -1, -1, 58, 59, -1, -1, 62,
1828 -1, -1, 65, 66, 67, 68, -1, 70, 71, 72,
1829 73, 44, -1, 76, -1, -1, -1, 50, -1, 82,
1830 -1, 1, 85, 86, -1, -1, 59, -1, 61, -1,
1831 93, -1, 95, 96, 67, -1, 99, -1, -1, 102,
1832 103, 104, 105, -1, -1, 108, 109, -1, -1, 82,
1833 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
1834 -1, 612, 613, 96, 44, 45, 46, -1, 48, 49,
1835 50, 51, -1, -1, 54, -1, -1, 628, 58, 59,
1836 -1, -1, -1, -1, -1, 65, 66, 67, 68, 1,
1837 70, 71, 72, 73, -1, -1, 76, -1, -1, -1,
1838 -1, -1, 82, -1, -1, 85, 86, -1, -1, -1,
1839 -1, -1, -1, 93, -1, 95, 96, -1, -1, 99,
1840 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1841 -1, -1, 44, 45, 46, -1, 48, 49, 50, 51,
1842 -1, -1, 54, -1, -1, -1, 58, 59, -1, -1,
1843 -1, -1, -1, 65, 66, 67, 68, 1, 70, 71,
1844 72, 73, -1, -1, 76, -1, -1, -1, -1, -1,
1845 82, -1, -1, 85, 86, -1, -1, -1, -1, -1,
1846 -1, 93, -1, 95, -1, -1, -1, 99, -1, -1,
1847 102, 103, 104, 105, -1, -1, 108, 109, -1, -1,
1848 44, 45, 46, -1, 48, 49, 50, 51, -1, -1,
1849 54, -1, -1, -1, 58, 59, -1, -1, -1, -1,
1850 -1, 65, 66, 1, 68, -1, 70, 71, 72, 73,
1851 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1852 -1, 85, 86, -1, -1, -1, -1, -1, -1, 93,
1853 -1, 95, -1, -1, -1, 99, -1, -1, 102, 103,
1854 104, 105, -1, -1, 108, 109, 44, 45, 46, -1,
1855 48, 49, 50, 51, -1, -1, 54, -1, -1, -1,
1856 58, 59, -1, -1, -1, -1, -1, 65, 66, -1,
1857 68, -1, 70, 71, 72, 73, -1, 1, 76, 3,
1858 4, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1859 -1, -1, -1, -1, -1, 93, -1, 95, -1, -1,
1860 -1, 99, -1, -1, 102, 103, 104, 105, -1, -1,
1861 108, 109, -1, -1, -1, -1, -1, -1, -1, -1,
1862 -1, 45, 46, -1, -1, -1, 50, -1, -1, -1,
1863 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
1864 -1, 65, 1, -1, 3, 4, -1, -1, 72, -1,
1865 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1866 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1867 -1, 95, 96, -1, -1, -1, -1, -1, 102, 103,
1868 104, 105, -1, -1, 108, 109, 45, 46, -1, -1,
1869 -1, 50, -1, 1, -1, 3, 4, -1, -1, -1,
1870 59, -1, -1, -1, -1, -1, 65, -1, -1, -1,
1871 -1, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1872 -1, -1, -1, 82, -1, -1, 85, 86, -1, 88,
1873 89, 90, -1, -1, 93, -1, -1, 45, 46, -1,
1874 -1, -1, 50, 102, 103, 104, 105, -1, -1, 108,
1875 109, 59, -1, -1, -1, -1, -1, 65, 1, -1,
1876 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
1877 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1878 -1, 89, 90, -1, -1, 93, -1, -1, -1, -1,
1879 98, -1, -1, -1, 102, 103, 104, 105, -1, -1,
1880 108, 109, 45, 46, -1, -1, -1, 50, -1, 1,
1881 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
1882 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
1883 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1884 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1885 93, 94, -1, 45, 46, -1, -1, -1, 50, 102,
1886 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
1887 -1, -1, -1, 65, 1, -1, 3, 4, -1, -1,
1888 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1889 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1890 -1, 93, -1, -1, -1, -1, -1, 99, -1, -1,
1891 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
1892 -1, -1, -1, 50, -1, 1, -1, 3, 4, -1,
1893 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
1894 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
1895 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1896 -1, -1, 89, 90, -1, -1, 93, -1, -1, 45,
1897 46, 98, -1, -1, 50, 102, 103, 104, 105, -1,
1898 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
1899 1, -1, 3, 4, -1, -1, 72, -1, -1, -1,
1900 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1901 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
1902 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
1903 -1, -1, 108, 109, 45, 46, -1, -1, -1, 50,
1904 -1, 1, -1, 3, 4, -1, -1, -1, 59, -1,
1905 -1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
1906 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1907 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1908 -1, -1, 93, -1, -1, 45, 46, 98, -1, -1,
1909 50, 102, 103, 104, 105, -1, -1, 108, 109, 59,
1910 -1, -1, -1, -1, -1, 65, 1, -1, 3, 4,
1911 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1912 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1913 90, -1, -1, 93, 94, -1, -1, -1, -1, -1,
1914 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1915 45, 46, -1, -1, -1, 50, -1, 1, -1, 3,
1916 4, -1, -1, -1, 59, -1, -1, -1, -1, -1,
1917 65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
1918 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1919 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
1920 -1, 45, 46, -1, -1, -1, 50, 102, 103, 104,
1921 105, -1, -1, 108, 109, 59, -1, -1, -1, -1,
1922 -1, 65, 1, -1, 3, 4, -1, -1, 72, -1,
1923 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1924 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1925 94, -1, -1, -1, -1, -1, -1, -1, 102, 103,
1926 104, 105, -1, -1, 108, 109, 45, 46, -1, -1,
1927 -1, 50, -1, 1, -1, 3, 4, -1, -1, -1,
1928 59, -1, -1, -1, -1, -1, 65, -1, -1, -1,
1929 -1, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1930 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1931 89, 90, -1, -1, 93, -1, -1, 45, 46, -1,
1932 99, -1, 50, 102, 103, 104, 105, -1, -1, 108,
1933 109, 59, -1, -1, -1, -1, -1, 65, 1, -1,
1934 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
1935 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1936 -1, 89, 90, -1, -1, 93, -1, -1, -1, -1,
1937 -1, -1, -1, -1, 102, 103, 104, 105, -1, -1,
1938 108, 109, 45, 46, -1, -1, -1, 50, -1, 1,
1939 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
1940 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
1941 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
1942 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
1943 93, -1, -1, 45, 46, -1, -1, -1, 50, 102,
1944 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
1945 -1, -1, -1, 65, 1, -1, 3, 4, -1, -1,
1946 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
1947 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
1948 -1, 93, -1, -1, -1, -1, -1, -1, -1, -1,
1949 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
1950 -1, -1, -1, 50, -1, 1, -1, 3, 4, -1,
1951 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
1952 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
1953 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
1954 -1, -1, 89, 90, -1, -1, 93, -1, -1, 45,
1955 46, -1, -1, -1, 50, 102, 103, 104, 105, -1,
1956 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
1957 1, -1, 3, 4, -1, -1, 72, -1, -1, -1,
1958 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
1959 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
1960 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
1961 -1, -1, 108, 109, 45, 46, -1, -1, -1, 50,
1962 -1, 1, -1, 3, 4, -1, -1, -1, 59, -1,
1963 -1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
1964 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
1965 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
1966 -1, -1, 93, -1, -1, 45, 46, -1, -1, -1,
1967 50, 102, 103, 104, 105, -1, -1, 108, 109, 59,
1968 -1, -1, -1, -1, -1, 65, 1, -1, 3, 4,
1969 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
1970 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
1971 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
1972 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1973 45, 46, -1, -1, -1, 50, -1, 1, -1, 3,
1974 4, -1, -1, -1, 59, -1, -1, -1, -1, -1,
1975 65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
1976 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
1977 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
1978 -1, 45, 46, -1, -1, -1, 50, 102, 103, 104,
1979 105, -1, -1, 108, 109, 59, -1, -1, -1, -1,
1980 -1, 65, 1, -1, 3, 4, -1, -1, 72, -1,
1981 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
1982 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
1983 -1, -1, -1, -1, -1, -1, -1, -1, 102, 103,
1984 104, 105, -1, -1, 108, 109, 45, 46, -1, -1,
1985 -1, 50, -1, 1, -1, 3, 4, -1, -1, -1,
1986 59, -1, -1, -1, -1, -1, 65, -1, -1, -1,
1987 -1, -1, -1, 72, -1, -1, -1, 76, -1, -1,
1988 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
1989 89, 90, -1, -1, 93, -1, -1, 45, 46, -1,
1990 -1, -1, 50, 102, 103, 104, 105, -1, -1, 108,
1991 109, 59, -1, -1, -1, -1, -1, 65, 1, -1,
1992 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
1993 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
1994 -1, 89, 90, -1, -1, 93, -1, -1, -1, -1,
1995 -1, -1, -1, -1, 102, 103, 104, 105, -1, -1,
1996 108, 109, 45, 46, -1, -1, -1, 50, -1, 1,
1997 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
1998 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
1999 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2000 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2001 93, -1, -1, 45, 46, -1, -1, -1, 50, 102,
2002 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
2003 -1, -1, -1, 65, 1, -1, 3, 4, -1, -1,
2004 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2005 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2006 -1, 93, -1, -1, -1, -1, -1, -1, -1, -1,
2007 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
2008 -1, -1, -1, 50, -1, 1, -1, 3, 4, -1,
2009 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
2010 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
2011 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2012 -1, -1, 89, 90, -1, -1, 93, -1, -1, 45,
2013 46, -1, -1, -1, 50, 102, 103, 104, 105, -1,
2014 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
2015 1, -1, 3, 4, -1, -1, 72, -1, -1, -1,
2016 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2017 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2018 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
2019 -1, -1, 108, 109, 45, 46, -1, -1, -1, 50,
2020 -1, 1, -1, 3, 4, -1, -1, -1, 59, -1,
2021 -1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
2022 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2023 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2024 -1, -1, 93, -1, -1, 45, 46, -1, -1, -1,
2025 50, 102, 103, 104, 105, -1, -1, 108, 109, 59,
2026 -1, -1, -1, -1, -1, 65, 1, -1, 3, 4,
2027 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2028 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2029 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
2030 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
2031 45, 46, -1, -1, -1, 50, -1, 1, -1, 3,
2032 4, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2033 65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
2034 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2035 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2036 -1, 45, 46, -1, -1, -1, 50, 102, 103, 104,
2037 105, -1, -1, 108, 109, 59, -1, -1, -1, -1,
2038 -1, 65, 1, -1, 3, 4, -1, -1, 72, -1,
2039 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2040 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2041 -1, -1, -1, -1, -1, -1, -1, -1, 102, 103,
2042 104, 105, -1, -1, 108, 109, 45, 46, -1, -1,
2043 -1, 50, -1, 1, -1, 3, 4, -1, -1, -1,
2044 59, -1, -1, -1, -1, -1, 65, -1, -1, -1,
2045 -1, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2046 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2047 89, 90, -1, -1, 93, -1, -1, 45, 46, -1,
2048 -1, -1, 50, 102, 103, 104, 105, -1, -1, 108,
2049 109, 59, -1, -1, -1, -1, -1, 65, 1, -1,
2050 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
2051 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2052 -1, 89, 90, -1, -1, 93, -1, -1, -1, -1,
2053 -1, -1, -1, -1, 102, 103, 104, 105, -1, -1,
2054 108, 109, 45, 46, -1, -1, -1, 50, -1, 1,
2055 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
2056 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2057 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2058 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2059 93, -1, -1, 45, 46, -1, -1, -1, 50, 102,
2060 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
2061 -1, -1, -1, 65, 1, -1, 3, 4, -1, -1,
2062 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2063 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2064 -1, 93, -1, -1, -1, -1, -1, -1, -1, -1,
2065 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
2066 -1, -1, -1, 50, -1, 1, -1, 3, 4, -1,
2067 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
2068 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
2069 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2070 -1, -1, 89, 90, -1, -1, 93, -1, -1, 45,
2071 46, -1, -1, -1, 50, 102, 103, 104, 105, -1,
2072 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
2073 1, -1, 3, 4, -1, -1, 72, -1, -1, -1,
2074 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2075 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2076 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
2077 -1, -1, 108, 109, 45, 46, -1, -1, -1, 50,
2078 -1, 1, -1, 3, 4, -1, -1, -1, 59, -1,
2079 -1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
2080 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2081 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2082 -1, -1, 93, -1, -1, 45, 46, -1, -1, -1,
2083 50, 102, 103, 104, 105, -1, -1, 108, 109, 59,
2084 -1, -1, -1, -1, -1, 65, 1, -1, 3, 4,
2085 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2086 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2087 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
2088 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
2089 45, 46, -1, -1, -1, 50, -1, 1, -1, 3,
2090 4, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2091 65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
2092 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2093 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2094 -1, 45, 46, -1, -1, -1, 50, 102, 103, 104,
2095 105, -1, -1, 108, 109, 59, -1, -1, -1, -1,
2096 -1, 65, 1, -1, 3, 4, -1, -1, 72, -1,
2097 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2098 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2099 -1, -1, -1, -1, -1, -1, -1, -1, 102, 103,
2100 104, 105, -1, -1, 108, 109, 45, 46, -1, -1,
2101 -1, 50, -1, 1, -1, 3, 4, -1, -1, -1,
2102 59, -1, -1, -1, -1, -1, 65, -1, -1, -1,
2103 -1, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2104 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2105 89, 90, -1, -1, 93, -1, -1, 45, 46, -1,
2106 -1, -1, 50, 102, 103, 104, 105, -1, -1, 108,
2107 109, 59, -1, -1, -1, -1, -1, 65, 1, -1,
2108 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
2109 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2110 -1, 89, 90, -1, -1, 93, -1, -1, -1, -1,
2111 -1, -1, -1, -1, 102, 103, 104, 105, -1, -1,
2112 108, 109, 45, 46, -1, -1, -1, 50, -1, 1,
2113 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
2114 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2115 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2116 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2117 93, -1, -1, 45, 46, -1, -1, -1, 50, 102,
2118 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
2119 -1, -1, -1, 65, 1, -1, 3, 4, -1, -1,
2120 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2121 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2122 -1, 93, -1, -1, -1, -1, -1, -1, -1, -1,
2123 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
2124 -1, -1, -1, 50, -1, 1, -1, 3, 4, -1,
2125 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
2126 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
2127 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2128 -1, -1, 89, 90, -1, -1, 93, -1, -1, 45,
2129 46, -1, -1, -1, 50, 102, 103, 104, 105, -1,
2130 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
2131 1, -1, 3, 4, -1, -1, 72, -1, -1, -1,
2132 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2133 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2134 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
2135 -1, -1, 108, 109, 45, 46, -1, -1, -1, 50,
2136 -1, 1, -1, 3, 4, -1, -1, -1, 59, -1,
2137 -1, -1, -1, -1, 65, -1, -1, -1, -1, -1,
2138 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2139 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2140 -1, -1, 93, -1, -1, 45, 46, -1, -1, -1,
2141 50, 102, 103, 104, 105, -1, -1, 108, 109, 59,
2142 -1, -1, -1, -1, -1, 65, 1, -1, 3, 4,
2143 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2144 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2145 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
2146 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
2147 45, 46, -1, -1, -1, 50, -1, 1, -1, 3,
2148 4, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2149 65, -1, -1, -1, -1, -1, -1, 72, -1, -1,
2150 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2151 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2152 -1, 45, 46, -1, -1, -1, 50, 102, 103, 104,
2153 105, -1, -1, 108, 109, 59, -1, -1, -1, -1,
2154 -1, 65, -1, 1, -1, -1, -1, -1, 72, -1,
2155 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2156 -1, 85, 86, -1, -1, 89, 90, -1, 1, 93,
2157 -1, -1, -1, -1, -1, -1, -1, -1, 102, 103,
2158 104, 105, -1, -1, 108, 109, 44, 45, 46, -1,
2159 -1, -1, 50, -1, -1, -1, -1, -1, -1, -1,
2160 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2161 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2162 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2163 -1, -1, 65, -1, -1, 93, -1, 3, 4, 72,
2164 -1, 99, -1, 76, 102, 103, 104, 105, -1, 82,
2165 108, 109, 85, 86, 45, 46, -1, -1, -1, 50,
2166 93, 94, -1, -1, -1, -1, -1, -1, 59, 102,
2167 103, 104, 105, -1, 65, 108, 109, 1, -1, 45,
2168 46, 72, -1, -1, 50, 76, -1, -1, -1, -1,
2169 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2170 -1, -1, 93, 94, 3, 4, 72, -1, -1, -1,
2171 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2172 86, 45, 46, 89, 90, -1, 50, 93, -1, 95,
2173 96, -1, -1, -1, -1, 59, 102, 103, 104, 105,
2174 -1, 65, 108, 109, -1, -1, 45, 46, 72, -1,
2175 -1, 50, 76, -1, -1, 3, 4, -1, 82, -1,
2176 59, 85, 86, -1, -1, -1, 65, -1, -1, 93,
2177 -1, -1, -1, 72, -1, -1, -1, 76, 102, 103,
2178 104, 105, -1, 82, 108, 109, 85, 86, -1, -1,
2179 89, 90, -1, -1, 93, 94, -1, 45, 46, -1,
2180 -1, -1, 50, 102, 103, 104, 105, -1, -1, 108,
2181 109, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2182 3, 4, -1, -1, 72, -1, -1, -1, 76, -1,
2183 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2184 -1, 89, 90, -1, -1, 93, 94, -1, -1, -1,
2185 -1, -1, -1, -1, 102, 103, 104, 105, -1, -1,
2186 108, 109, 45, 46, -1, -1, -1, 50, -1, -1,
2187 -1, 3, 4, -1, -1, -1, 59, -1, -1, -1,
2188 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2189 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2190 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2191 93, 94, -1, 45, 46, -1, -1, -1, 50, 102,
2192 103, 104, 105, -1, -1, 108, 109, 59, -1, -1,
2193 -1, -1, -1, 65, -1, -1, 3, 4, -1, -1,
2194 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2195 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2196 -1, 93, 94, -1, -1, -1, -1, -1, -1, -1,
2197 102, 103, 104, 105, -1, -1, 108, 109, 45, 46,
2198 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2199 -1, -1, 59, -1, -1, -1, -1, -1, 65, -1,
2200 -1, -1, -1, -1, -1, 72, -1, -1, -1, 76,
2201 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2202 -1, -1, 89, 90, -1, -1, 93, -1, 44, 45,
2203 46, -1, -1, -1, 50, 102, 103, 104, 105, -1,
2204 -1, 108, 109, 59, -1, -1, -1, -1, -1, 65,
2205 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2206 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2207 86, -1, -1, -1, -1, -1, -1, 93, -1, -1,
2208 -1, -1, -1, -1, -1, -1, 102, 103, 104, 105,
2209 -1, -1, 108, 109
2210 };
2211 #define YYPURE 1
2212
2213 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2214 #line 3 "/usr/lib/bison.simple"
2215
2216 /* Skeleton output parser for bison,
2217 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2218
2219 This program is free software; you can redistribute it and/or modify
2220 it under the terms of the GNU General Public License as published by
2221 the Free Software Foundation; either version 2, or (at your option)
2222 any later version.
2223
2224 This program is distributed in the hope that it will be useful,
2225 but WITHOUT ANY WARRANTY; without even the implied warranty of
2226 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2227 GNU General Public License for more details.
2228
2229 You should have received a copy of the GNU General Public License
2230 along with this program; if not, write to the Free Software
2231 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
2232
2233 /* As a special exception, when this file is copied by Bison into a
2234 Bison output file, you may use that output file without restriction.
2235 This special exception was added by the Free Software Foundation
2236 in version 1.24 of Bison. */
2237
2238 #ifndef alloca
2239 #ifdef __GNUC__
2240 #define alloca __builtin_alloca
2241 #else /* not GNU C. */
2242 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
2243 #include <alloca.h>
2244 #else /* not sparc */
2245 #if defined (MSDOS) && !defined (__TURBOC__)
2246 #include <malloc.h>
2247 #else /* not MSDOS, or __TURBOC__ */
2248 #if defined(_AIX)
2249 #include <malloc.h>
2250 #pragma alloca
2251 #else /* not MSDOS, __TURBOC__, or _AIX */
2252 #ifdef __hpux
2253 #ifdef __cplusplus
2254 extern "C" {
2255 void *alloca (unsigned int);
2256 };
2257 #else /* not __cplusplus */
2258 void *alloca ();
2259 #endif /* not __cplusplus */
2260 #endif /* __hpux */
2261 #endif /* not _AIX */
2262 #endif /* not MSDOS, or __TURBOC__ */
2263 #endif /* not sparc. */
2264 #endif /* not GNU C. */
2265 #endif /* alloca not defined. */
2266
2267 /* This is the parser code that is written into each bison parser
2268 when the %semantic_parser declaration is not specified in the grammar.
2269 It was written by Richard Stallman by simplifying the hairy parser
2270 used when %semantic_parser is specified. */
2271
2272 /* Note: there must be only one dollar sign in this file.
2273 It is replaced by the list of actions, each action
2274 as one case of the switch. */
2275
2276 #define yyerrok (yyerrstatus = 0)
2277 #define yyclearin (yychar = YYEMPTY)
2278 #define YYEMPTY -2
2279 #define YYEOF 0
2280 #define YYACCEPT return(0)
2281 #define YYABORT return(1)
2282 #define YYERROR goto yyerrlab1
2283 /* Like YYERROR except do call yyerror.
2284 This remains here temporarily to ease the
2285 transition to the new meaning of YYERROR, for GCC.
2286 Once GCC version 2 has supplanted version 1, this can go. */
2287 #define YYFAIL goto yyerrlab
2288 #define YYRECOVERING() (!!yyerrstatus)
2289 #define YYBACKUP(token, value) \
2290 do \
2291 if (yychar == YYEMPTY && yylen == 1) \
2292 { yychar = (token), yylval = (value); \
2293 yychar1 = YYTRANSLATE (yychar); \
2294 YYPOPSTACK; \
2295 goto yybackup; \
2296 } \
2297 else \
2298 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2299 while (0)
2300
2301 #define YYTERROR 1
2302 #define YYERRCODE 256
2303
2304 #ifndef YYPURE
2305 #define YYLEX yylex()
2306 #endif
2307
2308 #ifdef YYPURE
2309 #ifdef YYLSP_NEEDED
2310 #ifdef YYLEX_PARAM
2311 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2312 #else
2313 #define YYLEX yylex(&yylval, &yylloc)
2314 #endif
2315 #else /* not YYLSP_NEEDED */
2316 #ifdef YYLEX_PARAM
2317 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2318 #else
2319 #define YYLEX yylex(&yylval)
2320 #endif
2321 #endif /* not YYLSP_NEEDED */
2322 #endif
2323
2324 /* If nonreentrant, generate the variables here */
2325
2326 #ifndef YYPURE
2327
2328 int yychar; /* the lookahead symbol */
2329 YYSTYPE yylval; /* the semantic value of the */
2330 /* lookahead symbol */
2331
2332 #ifdef YYLSP_NEEDED
2333 YYLTYPE yylloc; /* location data for the lookahead */
2334 /* symbol */
2335 #endif
2336
2337 int yynerrs; /* number of parse errors so far */
2338 #endif /* not YYPURE */
2339
2340 #if YYDEBUG != 0
2341 int yydebug; /* nonzero means print parse trace */
2342 /* Since this is uninitialized, it does not stop multiple parsers
2343 from coexisting. */
2344 #endif
2345
2346 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2347
2348 #ifndef YYINITDEPTH
2349 #define YYINITDEPTH 200
2350 #endif
2351
2352 /* YYMAXDEPTH is the maximum size the stacks can grow to
2353 (effective only if the built-in stack extension method is used). */
2354
2355 #if YYMAXDEPTH == 0
2356 #undef YYMAXDEPTH
2357 #endif
2358
2359 #ifndef YYMAXDEPTH
2360 #define YYMAXDEPTH 10000
2361 #endif
2362
2363 /* Prevent warning if -Wstrict-prototypes. */
2364 #ifdef __GNUC__
2365 int yyparse (void);
2366 #endif
2367 \f
2368 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2369 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2370 #else /* not GNU C or C++ */
2371 #ifndef __cplusplus
2372
2373 /* This is the most reliable way to avoid incompatibilities
2374 in available built-in functions on various systems. */
2375 static void
2376 __yy_memcpy (to, from, count)
2377 char *to;
2378 char *from;
2379 int count;
2380 {
2381 register char *f = from;
2382 register char *t = to;
2383 register int i = count;
2384
2385 while (i-- > 0)
2386 *t++ = *f++;
2387 }
2388
2389 #else /* __cplusplus */
2390
2391 /* This is the most reliable way to avoid incompatibilities
2392 in available built-in functions on various systems. */
2393 static void
2394 __yy_memcpy (char *to, char *from, int count)
2395 {
2396 register char *f = from;
2397 register char *t = to;
2398 register int i = count;
2399
2400 while (i-- > 0)
2401 *t++ = *f++;
2402 }
2403
2404 #endif
2405 #endif
2406 \f
2407 #line 196 "/usr/lib/bison.simple"
2408
2409 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2410 into yyparse. The argument should have type void *.
2411 It should actually point to an object.
2412 Grammar actions can access the variable by casting it
2413 to the proper pointer type. */
2414
2415 #ifdef YYPARSE_PARAM
2416 #ifdef __cplusplus
2417 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2418 #define YYPARSE_PARAM_DECL
2419 #else /* not __cplusplus */
2420 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2421 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2422 #endif /* not __cplusplus */
2423 #else /* not YYPARSE_PARAM */
2424 #define YYPARSE_PARAM_ARG
2425 #define YYPARSE_PARAM_DECL
2426 #endif /* not YYPARSE_PARAM */
2427
2428 int
2429 yyparse(YYPARSE_PARAM_ARG)
2430 YYPARSE_PARAM_DECL
2431 {
2432 register int yystate;
2433 register int yyn;
2434 register short *yyssp;
2435 register YYSTYPE *yyvsp;
2436 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2437 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2438
2439 short yyssa[YYINITDEPTH]; /* the state stack */
2440 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2441
2442 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2443 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2444
2445 #ifdef YYLSP_NEEDED
2446 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2447 YYLTYPE *yyls = yylsa;
2448 YYLTYPE *yylsp;
2449
2450 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2451 #else
2452 #define YYPOPSTACK (yyvsp--, yyssp--)
2453 #endif
2454
2455 int yystacksize = YYINITDEPTH;
2456
2457 #ifdef YYPURE
2458 int yychar;
2459 YYSTYPE yylval;
2460 int yynerrs;
2461 #ifdef YYLSP_NEEDED
2462 YYLTYPE yylloc;
2463 #endif
2464 #endif
2465
2466 YYSTYPE yyval; /* the variable used to return */
2467 /* semantic values from the action */
2468 /* routines */
2469
2470 int yylen;
2471
2472 #if YYDEBUG != 0
2473 if (yydebug)
2474 fprintf(stderr, "Starting parse\n");
2475 #endif
2476
2477 yystate = 0;
2478 yyerrstatus = 0;
2479 yynerrs = 0;
2480 yychar = YYEMPTY; /* Cause a token to be read. */
2481
2482 /* Initialize stack pointers.
2483 Waste one element of value and location stack
2484 so that they stay on the same level as the state stack.
2485 The wasted elements are never initialized. */
2486
2487 yyssp = yyss - 1;
2488 yyvsp = yyvs;
2489 #ifdef YYLSP_NEEDED
2490 yylsp = yyls;
2491 #endif
2492
2493 /* Push a new state, which is found in yystate . */
2494 /* In all cases, when you get here, the value and location stacks
2495 have just been pushed. so pushing a state here evens the stacks. */
2496 yynewstate:
2497
2498 *++yyssp = yystate;
2499
2500 if (yyssp >= yyss + yystacksize - 1)
2501 {
2502 /* Give user a chance to reallocate the stack */
2503 /* Use copies of these so that the &'s don't force the real ones into memory. */
2504 YYSTYPE *yyvs1 = yyvs;
2505 short *yyss1 = yyss;
2506 #ifdef YYLSP_NEEDED
2507 YYLTYPE *yyls1 = yyls;
2508 #endif
2509
2510 /* Get the current used size of the three stacks, in elements. */
2511 int size = yyssp - yyss + 1;
2512
2513 #ifdef yyoverflow
2514 /* Each stack pointer address is followed by the size of
2515 the data in use in that stack, in bytes. */
2516 #ifdef YYLSP_NEEDED
2517 /* This used to be a conditional around just the two extra args,
2518 but that might be undefined if yyoverflow is a macro. */
2519 yyoverflow("parser stack overflow",
2520 &yyss1, size * sizeof (*yyssp),
2521 &yyvs1, size * sizeof (*yyvsp),
2522 &yyls1, size * sizeof (*yylsp),
2523 &yystacksize);
2524 #else
2525 yyoverflow("parser stack overflow",
2526 &yyss1, size * sizeof (*yyssp),
2527 &yyvs1, size * sizeof (*yyvsp),
2528 &yystacksize);
2529 #endif
2530
2531 yyss = yyss1; yyvs = yyvs1;
2532 #ifdef YYLSP_NEEDED
2533 yyls = yyls1;
2534 #endif
2535 #else /* no yyoverflow */
2536 /* Extend the stack our own way. */
2537 if (yystacksize >= YYMAXDEPTH)
2538 {
2539 yyerror("parser stack overflow");
2540 return 2;
2541 }
2542 yystacksize *= 2;
2543 if (yystacksize > YYMAXDEPTH)
2544 yystacksize = YYMAXDEPTH;
2545 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
2546 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
2547 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
2548 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
2549 #ifdef YYLSP_NEEDED
2550 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
2551 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
2552 #endif
2553 #endif /* no yyoverflow */
2554
2555 yyssp = yyss + size - 1;
2556 yyvsp = yyvs + size - 1;
2557 #ifdef YYLSP_NEEDED
2558 yylsp = yyls + size - 1;
2559 #endif
2560
2561 #if YYDEBUG != 0
2562 if (yydebug)
2563 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2564 #endif
2565
2566 if (yyssp >= yyss + yystacksize - 1)
2567 YYABORT;
2568 }
2569
2570 #if YYDEBUG != 0
2571 if (yydebug)
2572 fprintf(stderr, "Entering state %d\n", yystate);
2573 #endif
2574
2575 goto yybackup;
2576 yybackup:
2577
2578 /* Do appropriate processing given the current state. */
2579 /* Read a lookahead token if we need one and don't already have one. */
2580 /* yyresume: */
2581
2582 /* First try to decide what to do without reference to lookahead token. */
2583
2584 yyn = yypact[yystate];
2585 if (yyn == YYFLAG)
2586 goto yydefault;
2587
2588 /* Not known => get a lookahead token if don't already have one. */
2589
2590 /* yychar is either YYEMPTY or YYEOF
2591 or a valid token in external form. */
2592
2593 if (yychar == YYEMPTY)
2594 {
2595 #if YYDEBUG != 0
2596 if (yydebug)
2597 fprintf(stderr, "Reading a token: ");
2598 #endif
2599 yychar = YYLEX;
2600 }
2601
2602 /* Convert token to internal form (in yychar1) for indexing tables with */
2603
2604 if (yychar <= 0) /* This means end of input. */
2605 {
2606 yychar1 = 0;
2607 yychar = YYEOF; /* Don't call YYLEX any more */
2608
2609 #if YYDEBUG != 0
2610 if (yydebug)
2611 fprintf(stderr, "Now at end of input.\n");
2612 #endif
2613 }
2614 else
2615 {
2616 yychar1 = YYTRANSLATE(yychar);
2617
2618 #if YYDEBUG != 0
2619 if (yydebug)
2620 {
2621 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2622 /* Give the individual parser a way to print the precise meaning
2623 of a token, for further debugging info. */
2624 #ifdef YYPRINT
2625 YYPRINT (stderr, yychar, yylval);
2626 #endif
2627 fprintf (stderr, ")\n");
2628 }
2629 #endif
2630 }
2631
2632 yyn += yychar1;
2633 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2634 goto yydefault;
2635
2636 yyn = yytable[yyn];
2637
2638 /* yyn is what to do for this token type in this state.
2639 Negative => reduce, -yyn is rule number.
2640 Positive => shift, yyn is new state.
2641 New state is final state => don't bother to shift,
2642 just return success.
2643 0, or most negative number => error. */
2644
2645 if (yyn < 0)
2646 {
2647 if (yyn == YYFLAG)
2648 goto yyerrlab;
2649 yyn = -yyn;
2650 goto yyreduce;
2651 }
2652 else if (yyn == 0)
2653 goto yyerrlab;
2654
2655 if (yyn == YYFINAL)
2656 YYACCEPT;
2657
2658 /* Shift the lookahead token. */
2659
2660 #if YYDEBUG != 0
2661 if (yydebug)
2662 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2663 #endif
2664
2665 /* Discard the token being shifted unless it is eof. */
2666 if (yychar != YYEOF)
2667 yychar = YYEMPTY;
2668
2669 *++yyvsp = yylval;
2670 #ifdef YYLSP_NEEDED
2671 *++yylsp = yylloc;
2672 #endif
2673
2674 /* count tokens shifted since error; after three, turn off error status. */
2675 if (yyerrstatus) yyerrstatus--;
2676
2677 yystate = yyn;
2678 goto yynewstate;
2679
2680 /* Do the default action for the current state. */
2681 yydefault:
2682
2683 yyn = yydefact[yystate];
2684 if (yyn == 0)
2685 goto yyerrlab;
2686
2687 /* Do a reduction. yyn is the number of a rule to reduce with. */
2688 yyreduce:
2689 yylen = yyr2[yyn];
2690 if (yylen > 0)
2691 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2692
2693 #if YYDEBUG != 0
2694 if (yydebug)
2695 {
2696 int i;
2697
2698 fprintf (stderr, "Reducing via rule %d (line %d), ",
2699 yyn, yyrline[yyn]);
2700
2701 /* Print the symbols being reduced, and their result. */
2702 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2703 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2704 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2705 }
2706 #endif
2707
2708
2709 switch (yyn) {
2710
2711 case 1:
2712 #line 459 "./parse.y"
2713 {;
2714 break;}
2715 case 18:
2716 #line 503 "./parse.y"
2717 {
2718 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2719 CLASS_LOADED_P (yyval.node) = 1;
2720 ;
2721 break;}
2722 case 19:
2723 #line 508 "./parse.y"
2724 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2725 break;}
2726 case 20:
2727 #line 510 "./parse.y"
2728 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2729 break;}
2730 case 21:
2731 #line 512 "./parse.y"
2732 {RULE ("']' expected"); RECOVER;;
2733 break;}
2734 case 22:
2735 #line 514 "./parse.y"
2736 {RULE ("']' expected"); RECOVER;;
2737 break;}
2738 case 26:
2739 #line 529 "./parse.y"
2740 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2741 break;}
2742 case 28:
2743 #line 538 "./parse.y"
2744 {yyval.node = NULL;;
2745 break;}
2746 case 36:
2747 #line 550 "./parse.y"
2748 {
2749 yyval.node = NULL;
2750 ;
2751 break;}
2752 case 37:
2753 #line 554 "./parse.y"
2754 {
2755 yyval.node = NULL;
2756 ;
2757 break;}
2758 case 40:
2759 #line 566 "./parse.y"
2760 { ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node); ;
2761 break;}
2762 case 41:
2763 #line 568 "./parse.y"
2764 {yyerror ("Missing name"); RECOVER;;
2765 break;}
2766 case 42:
2767 #line 570 "./parse.y"
2768 {yyerror ("';' expected"); RECOVER;;
2769 break;}
2770 case 45:
2771 #line 580 "./parse.y"
2772 {
2773 tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2774 int i = IDENTIFIER_LENGTH (name)-1;
2775 char *last = &IDENTIFIER_POINTER (name)[i];
2776 while (last != IDENTIFIER_POINTER (name))
2777 {
2778 if (last [0] == '.')
2779 break;
2780 last--;
2781 }
2782 last_name = get_identifier (++last);
2783 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
2784 {
2785 tree err = find_name_in_single_imports (last_name);
2786 if (err && err != name)
2787 parse_error_context
2788 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
2789 IDENTIFIER_POINTER (name),
2790 IDENTIFIER_POINTER (err));
2791 else
2792 REGISTER_IMPORT (yyvsp[-1].node, last_name)
2793 }
2794 else
2795 REGISTER_IMPORT (yyvsp[-1].node, last_name);
2796 ;
2797 break;}
2798 case 46:
2799 #line 606 "./parse.y"
2800 {yyerror ("Missing name"); RECOVER;;
2801 break;}
2802 case 47:
2803 #line 608 "./parse.y"
2804 {yyerror ("';' expected"); RECOVER;;
2805 break;}
2806 case 48:
2807 #line 613 "./parse.y"
2808 {
2809 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
2810 /* Don't import java.lang.* twice. */
2811 if (name != java_lang_id)
2812 {
2813 tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2814 read_import_dir (yyvsp[-3].node);
2815 TREE_CHAIN (node) = ctxp->import_demand_list;
2816 ctxp->import_demand_list = node;
2817 }
2818 ;
2819 break;}
2820 case 49:
2821 #line 625 "./parse.y"
2822 {yyerror ("'*' expected"); RECOVER;;
2823 break;}
2824 case 50:
2825 #line 627 "./parse.y"
2826 {yyerror ("';' expected"); RECOVER;;
2827 break;}
2828 case 51:
2829 #line 632 "./parse.y"
2830 {
2831 maybe_generate_finit ();
2832 maybe_generate_clinit ();
2833 yyval.node = yyvsp[0].node;
2834 ;
2835 break;}
2836 case 52:
2837 #line 638 "./parse.y"
2838 {
2839 maybe_generate_clinit ();
2840 yyval.node = yyvsp[0].node;
2841 ;
2842 break;}
2843 case 53:
2844 #line 643 "./parse.y"
2845 { yyval.node = NULL; ;
2846 break;}
2847 case 54:
2848 #line 645 "./parse.y"
2849 {
2850 YYERROR_NOW;
2851 yyerror ("Class or interface declaration expected");
2852 ;
2853 break;}
2854 case 55:
2855 #line 656 "./parse.y"
2856 {
2857 yyval.value = (1 << yyvsp[0].value);
2858 ;
2859 break;}
2860 case 56:
2861 #line 660 "./parse.y"
2862 {
2863 int acc = (1 << yyvsp[0].value);
2864 if (yyval.value & acc)
2865 parse_error_context
2866 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
2867 java_accstring_lookup (acc));
2868 else
2869 {
2870 yyval.value |= acc;
2871 }
2872 ;
2873 break;}
2874 case 57:
2875 #line 676 "./parse.y"
2876 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2877 break;}
2878 case 58:
2879 #line 678 "./parse.y"
2880 {
2881 yyval.node = yyvsp[0].node;
2882 ;
2883 break;}
2884 case 59:
2885 #line 682 "./parse.y"
2886 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
2887 break;}
2888 case 60:
2889 #line 684 "./parse.y"
2890 {
2891 yyval.node = yyvsp[0].node;
2892 ;
2893 break;}
2894 case 61:
2895 #line 688 "./parse.y"
2896 {yyerror ("Missing class name"); RECOVER;;
2897 break;}
2898 case 62:
2899 #line 690 "./parse.y"
2900 {yyerror ("Missing class name"); RECOVER;;
2901 break;}
2902 case 63:
2903 #line 692 "./parse.y"
2904 {
2905 if (!ctxp->class_err) yyerror ("'{' expected");
2906 DRECOVER(class1);
2907 ;
2908 break;}
2909 case 64:
2910 #line 697 "./parse.y"
2911 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
2912 break;}
2913 case 65:
2914 #line 701 "./parse.y"
2915 { yyval.node = NULL; ;
2916 break;}
2917 case 66:
2918 #line 703 "./parse.y"
2919 { yyval.node = yyvsp[0].node; ;
2920 break;}
2921 case 67:
2922 #line 705 "./parse.y"
2923 {yyerror ("'{' expected"); ctxp->class_err=1;;
2924 break;}
2925 case 68:
2926 #line 707 "./parse.y"
2927 {yyerror ("Missing super class name"); ctxp->class_err=1;;
2928 break;}
2929 case 69:
2930 #line 711 "./parse.y"
2931 { yyval.node = NULL_TREE; ;
2932 break;}
2933 case 70:
2934 #line 713 "./parse.y"
2935 { yyval.node = yyvsp[0].node; ;
2936 break;}
2937 case 71:
2938 #line 715 "./parse.y"
2939 {
2940 ctxp->class_err=1;
2941 yyerror ("Missing interface name");
2942 ;
2943 break;}
2944 case 72:
2945 #line 723 "./parse.y"
2946 {
2947 ctxp->interface_number = 1;
2948 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
2949 ;
2950 break;}
2951 case 73:
2952 #line 728 "./parse.y"
2953 {
2954 ctxp->interface_number++;
2955 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
2956 ;
2957 break;}
2958 case 74:
2959 #line 733 "./parse.y"
2960 {yyerror ("Missing interface name"); RECOVER;;
2961 break;}
2962 case 75:
2963 #line 738 "./parse.y"
2964 {
2965 /* Store the location of the `}' when doing xrefs */
2966 if (flag_emit_xref)
2967 DECL_END_SOURCE_LINE (ctxp->current_parsed_class) =
2968 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
2969 yyval.node = ctxp->current_parsed_class;
2970 ;
2971 break;}
2972 case 76:
2973 #line 746 "./parse.y"
2974 {
2975 /* Store the location of the `}' when doing xrefs */
2976 if (flag_emit_xref)
2977 DECL_END_SOURCE_LINE (ctxp->current_parsed_class) =
2978 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
2979 yyval.node = ctxp->current_parsed_class;
2980 ;
2981 break;}
2982 case 82:
2983 #line 765 "./parse.y"
2984 { yyval.node = parse_jdk1_1_error ("instance initializer"); ;
2985 break;}
2986 case 84:
2987 #line 771 "./parse.y"
2988 { yyval.node = yyvsp[-1].node; ;
2989 break;}
2990 case 86:
2991 #line 774 "./parse.y"
2992 { yyval.node = parse_jdk1_1_error ("inner classe declaration"); ;
2993 break;}
2994 case 87:
2995 #line 776 "./parse.y"
2996 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
2997 break;}
2998 case 88:
2999 #line 782 "./parse.y"
3000 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3001 break;}
3002 case 89:
3003 #line 784 "./parse.y"
3004 {
3005 check_modifiers
3006 ("Illegal modifier `%s' for field declaration",
3007 yyvsp[-3].value, FIELD_MODIFIERS);
3008 check_modifiers_consistency (yyvsp[-3].value);
3009 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3010 ;
3011 break;}
3012 case 91:
3013 #line 797 "./parse.y"
3014 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3015 break;}
3016 case 92:
3017 #line 799 "./parse.y"
3018 {yyerror ("Missing term"); RECOVER;;
3019 break;}
3020 case 93:
3021 #line 804 "./parse.y"
3022 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3023 break;}
3024 case 94:
3025 #line 806 "./parse.y"
3026 {
3027 if (java_error_count)
3028 yyvsp[0].node = NULL_TREE;
3029 yyval.node = build_tree_list
3030 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3031 ;
3032 break;}
3033 case 95:
3034 #line 813 "./parse.y"
3035 {
3036 yyerror ("Missing variable initializer");
3037 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3038 RECOVER;
3039 ;
3040 break;}
3041 case 96:
3042 #line 819 "./parse.y"
3043 {
3044 yyerror ("';' expected");
3045 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3046 RECOVER;
3047 ;
3048 break;}
3049 case 98:
3050 #line 829 "./parse.y"
3051 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3052 break;}
3053 case 99:
3054 #line 831 "./parse.y"
3055 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3056 break;}
3057 case 100:
3058 #line 833 "./parse.y"
3059 {yyerror ("']' expected"); DRECOVER(vdi);;
3060 break;}
3061 case 101:
3062 #line 835 "./parse.y"
3063 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3064 break;}
3065 case 104:
3066 #line 846 "./parse.y"
3067 {
3068 current_function_decl = yyvsp[0].node;
3069 source_start_java_method (current_function_decl);
3070 ;
3071 break;}
3072 case 105:
3073 #line 851 "./parse.y"
3074 { finish_method_declaration (yyvsp[0].node); ;
3075 break;}
3076 case 106:
3077 #line 853 "./parse.y"
3078 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3079 break;}
3080 case 107:
3081 #line 858 "./parse.y"
3082 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3083 break;}
3084 case 108:
3085 #line 860 "./parse.y"
3086 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3087 break;}
3088 case 109:
3089 #line 862 "./parse.y"
3090 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3091 break;}
3092 case 110:
3093 #line 864 "./parse.y"
3094 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3095 break;}
3096 case 111:
3097 #line 866 "./parse.y"
3098 {RECOVER;;
3099 break;}
3100 case 112:
3101 #line 868 "./parse.y"
3102 {RECOVER;;
3103 break;}
3104 case 113:
3105 #line 870 "./parse.y"
3106 {yyerror ("Identifier expected"); RECOVER;;
3107 break;}
3108 case 114:
3109 #line 872 "./parse.y"
3110 {yyerror ("Identifier expected"); RECOVER;;
3111 break;}
3112 case 115:
3113 #line 874 "./parse.y"
3114 {
3115 yyerror ("Invalid method declaration, return type required");
3116 RECOVER;
3117 ;
3118 break;}
3119 case 116:
3120 #line 882 "./parse.y"
3121 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3122 break;}
3123 case 117:
3124 #line 884 "./parse.y"
3125 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3126 break;}
3127 case 118:
3128 #line 886 "./parse.y"
3129 {
3130 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3131 TREE_PURPOSE (yyvsp[-2].node) =
3132 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3133 parse_warning_context
3134 (wfl_operator,
3135 "Discouraged form of returned type specification");
3136 ;
3137 break;}
3138 case 119:
3139 #line 895 "./parse.y"
3140 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3141 break;}
3142 case 120:
3143 #line 897 "./parse.y"
3144 {yyerror ("']' expected"); RECOVER;;
3145 break;}
3146 case 121:
3147 #line 902 "./parse.y"
3148 {
3149 ctxp->formal_parameter_number = 1;
3150 ;
3151 break;}
3152 case 122:
3153 #line 906 "./parse.y"
3154 {
3155 ctxp->formal_parameter_number += 1;
3156 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3157 ;
3158 break;}
3159 case 123:
3160 #line 911 "./parse.y"
3161 {yyerror ("Missing formal parameter term"); RECOVER;;
3162 break;}
3163 case 124:
3164 #line 916 "./parse.y"
3165 {
3166 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3167 ;
3168 break;}
3169 case 125:
3170 #line 920 "./parse.y"
3171 {
3172 parse_jdk1_1_error ("final parameters");
3173 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3174 ;
3175 break;}
3176 case 126:
3177 #line 925 "./parse.y"
3178 {yyerror ("Missing identifier"); RECOVER;;
3179 break;}
3180 case 127:
3181 #line 927 "./parse.y"
3182 {
3183 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[-2].value));
3184 yyerror ("Missing identifier"); RECOVER;
3185 ;
3186 break;}
3187 case 128:
3188 #line 934 "./parse.y"
3189 { yyval.node = NULL_TREE; ;
3190 break;}
3191 case 129:
3192 #line 936 "./parse.y"
3193 { yyval.node = yyvsp[0].node; ;
3194 break;}
3195 case 130:
3196 #line 938 "./parse.y"
3197 {yyerror ("Missing class type term"); RECOVER;;
3198 break;}
3199 case 131:
3200 #line 943 "./parse.y"
3201 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3202 break;}
3203 case 132:
3204 #line 945 "./parse.y"
3205 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3206 break;}
3207 case 133:
3208 #line 947 "./parse.y"
3209 {yyerror ("Missing class type term"); RECOVER;;
3210 break;}
3211 case 136:
3212 #line 954 "./parse.y"
3213 { yyval.node = NULL_TREE; ;
3214 break;}
3215 case 137:
3216 #line 960 "./parse.y"
3217 {
3218 TREE_CHAIN (yyvsp[0].node) = ctxp->static_initialized;
3219 ctxp->static_initialized = yyvsp[0].node;
3220 ;
3221 break;}
3222 case 138:
3223 #line 965 "./parse.y"
3224 {
3225 TREE_CHAIN (yyvsp[-1].node) = ctxp->static_initialized;
3226 ctxp->static_initialized = yyvsp[-1].node;
3227 ;
3228 break;}
3229 case 139:
3230 #line 973 "./parse.y"
3231 {
3232 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3233 ;
3234 break;}
3235 case 140:
3236 #line 981 "./parse.y"
3237 {
3238 current_function_decl = yyvsp[0].node;
3239 source_start_java_method (current_function_decl);
3240 ;
3241 break;}
3242 case 141:
3243 #line 986 "./parse.y"
3244 { finish_method_declaration (yyvsp[0].node); ;
3245 break;}
3246 case 142:
3247 #line 991 "./parse.y"
3248 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3249 break;}
3250 case 143:
3251 #line 993 "./parse.y"
3252 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3253 break;}
3254 case 144:
3255 #line 998 "./parse.y"
3256 { yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE); ;
3257 break;}
3258 case 145:
3259 #line 1000 "./parse.y"
3260 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3261 break;}
3262 case 146:
3263 #line 1008 "./parse.y"
3264 {
3265 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3266 yyval.node = yyvsp[0].node;
3267 ;
3268 break;}
3269 case 147:
3270 #line 1013 "./parse.y"
3271 { yyval.node = yyvsp[0].node; ;
3272 break;}
3273 case 148:
3274 #line 1015 "./parse.y"
3275 { yyval.node = yyvsp[0].node; ;
3276 break;}
3277 case 149:
3278 #line 1017 "./parse.y"
3279 { yyval.node = yyvsp[0].node; ;
3280 break;}
3281 case 152:
3282 #line 1027 "./parse.y"
3283 {
3284 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3285 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3286 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3287 ;
3288 break;}
3289 case 153:
3290 #line 1033 "./parse.y"
3291 {
3292 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3293 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3294 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3295 ;
3296 break;}
3297 case 154:
3298 #line 1041 "./parse.y"
3299 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3300 break;}
3301 case 155:
3302 #line 1043 "./parse.y"
3303 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3304 break;}
3305 case 156:
3306 #line 1048 "./parse.y"
3307 {
3308 tree wfl = build_wfl_node (this_identifier_node);
3309 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3310 yyval.node = wfl;
3311 ;
3312 break;}
3313 case 157:
3314 #line 1054 "./parse.y"
3315 {
3316 tree wfl = build_wfl_node (super_identifier_node);
3317 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3318 yyval.node = wfl;
3319 ;
3320 break;}
3321 case 158:
3322 #line 1065 "./parse.y"
3323 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3324 break;}
3325 case 159:
3326 #line 1067 "./parse.y"
3327 {
3328 yyval.node = yyvsp[0].node;
3329 ;
3330 break;}
3331 case 160:
3332 #line 1071 "./parse.y"
3333 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3334 break;}
3335 case 161:
3336 #line 1073 "./parse.y"
3337 {
3338 yyval.node = yyvsp[0].node;
3339 ;
3340 break;}
3341 case 162:
3342 #line 1077 "./parse.y"
3343 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3344 break;}
3345 case 163:
3346 #line 1079 "./parse.y"
3347 {
3348 yyval.node = yyvsp[0].node;
3349 ;
3350 break;}
3351 case 164:
3352 #line 1083 "./parse.y"
3353 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3354 break;}
3355 case 165:
3356 #line 1085 "./parse.y"
3357 {
3358 yyval.node = yyvsp[0].node;
3359 ;
3360 break;}
3361 case 166:
3362 #line 1089 "./parse.y"
3363 {yyerror ("'{' expected"); RECOVER;;
3364 break;}
3365 case 167:
3366 #line 1091 "./parse.y"
3367 {yyerror ("'{' expected"); RECOVER;;
3368 break;}
3369 case 168:
3370 #line 1096 "./parse.y"
3371 {
3372 ctxp->interface_number = 1;
3373 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3374 ;
3375 break;}
3376 case 169:
3377 #line 1101 "./parse.y"
3378 {
3379 ctxp->interface_number++;
3380 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3381 ;
3382 break;}
3383 case 170:
3384 #line 1106 "./parse.y"
3385 {yyerror ("Invalid interface type"); RECOVER;;
3386 break;}
3387 case 171:
3388 #line 1108 "./parse.y"
3389 {yyerror ("Missing term"); RECOVER;;
3390 break;}
3391 case 172:
3392 #line 1113 "./parse.y"
3393 { yyval.node = NULL_TREE; ;
3394 break;}
3395 case 173:
3396 #line 1115 "./parse.y"
3397 { yyval.node = NULL_TREE; ;
3398 break;}
3399 case 178:
3400 #line 1127 "./parse.y"
3401 { yyval.node = parse_jdk1_1_error ("inner class declaration"); ;
3402 break;}
3403 case 179:
3404 #line 1129 "./parse.y"
3405 { yyval.node = parse_jdk1_1_error ("inner interface declaration"); ;
3406 break;}
3407 case 181:
3408 #line 1138 "./parse.y"
3409 {
3410 check_abstract_method_header (yyvsp[-1].node);
3411 current_function_decl = NULL_TREE; /* FIXME ? */
3412 ;
3413 break;}
3414 case 182:
3415 #line 1143 "./parse.y"
3416 {yyerror ("';' expected"); RECOVER;;
3417 break;}
3418 case 183:
3419 #line 1149 "./parse.y"
3420 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3421 break;}
3422 case 184:
3423 #line 1151 "./parse.y"
3424 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3425 break;}
3426 case 185:
3427 #line 1153 "./parse.y"
3428 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3429 break;}
3430 case 186:
3431 #line 1158 "./parse.y"
3432 {
3433 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3434 yyvsp[0].node, NULL_TREE);
3435 ;
3436 break;}
3437 case 187:
3438 #line 1163 "./parse.y"
3439 {
3440 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3441 ;
3442 break;}
3443 case 188:
3444 #line 1167 "./parse.y"
3445 {yyerror ("Missing term"); RECOVER;;
3446 break;}
3447 case 189:
3448 #line 1173 "./parse.y"
3449 {
3450 /* Store the location of the `}' when doing xrefs */
3451 if (current_function_decl && flag_emit_xref)
3452 DECL_END_SOURCE_LINE (current_function_decl) =
3453 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3454 yyval.node = empty_stmt_node;
3455 ;
3456 break;}
3457 case 190:
3458 #line 1181 "./parse.y"
3459 { yyval.node = yyvsp[0].node; ;
3460 break;}
3461 case 191:
3462 #line 1186 "./parse.y"
3463 { enter_block (); ;
3464 break;}
3465 case 192:
3466 #line 1191 "./parse.y"
3467 {
3468 maybe_absorb_scoping_blocks ();
3469 /* Store the location of the `}' when doing xrefs */
3470 if (current_function_decl && flag_emit_xref)
3471 DECL_END_SOURCE_LINE (current_function_decl) =
3472 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3473 yyval.node = exit_block ();
3474 ;
3475 break;}
3476 case 196:
3477 #line 1209 "./parse.y"
3478 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3479 break;}
3480 case 197:
3481 #line 1211 "./parse.y"
3482 { parse_jdk1_1_error ("inner class declaration"); ;
3483 break;}
3484 case 199:
3485 #line 1220 "./parse.y"
3486 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3487 break;}
3488 case 200:
3489 #line 1222 "./parse.y"
3490 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3491 break;}
3492 case 206:
3493 #line 1232 "./parse.y"
3494 { yyval.node = exit_block (); ;
3495 break;}
3496 case 211:
3497 #line 1241 "./parse.y"
3498 { yyval.node = exit_block (); ;
3499 break;}
3500 case 223:
3501 #line 1260 "./parse.y"
3502 { yyval.node = empty_stmt_node; ;
3503 break;}
3504 case 224:
3505 #line 1265 "./parse.y"
3506 {
3507 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3508 EXPR_WFL_NODE (yyvsp[-1].node));
3509 pushlevel (2);
3510 push_labeled_block (yyval.node);
3511 PUSH_LABELED_BLOCK (yyval.node);
3512 ;
3513 break;}
3514 case 225:
3515 #line 1276 "./parse.y"
3516 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3517 break;}
3518 case 226:
3519 #line 1278 "./parse.y"
3520 {yyerror ("':' expected"); RECOVER;;
3521 break;}
3522 case 227:
3523 #line 1283 "./parse.y"
3524 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3525 break;}
3526 case 228:
3527 #line 1290 "./parse.y"
3528 {
3529 /* We have a statement. Generate a WFL around it so
3530 we can debug it */
3531 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3532 /* We know we have a statement, so set the debug
3533 info to be eventually generate here. */
3534 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3535 ;
3536 break;}
3537 case 229:
3538 #line 1299 "./parse.y"
3539 {
3540 if (ctxp->prevent_ese != lineno)
3541 yyerror ("Invalid expression statement");
3542 DRECOVER (expr_stmt);
3543 ;
3544 break;}
3545 case 230:
3546 #line 1305 "./parse.y"
3547 {
3548 if (ctxp->prevent_ese != lineno)
3549 yyerror ("Invalid expression statement");
3550 DRECOVER (expr_stmt);
3551 ;
3552 break;}
3553 case 231:
3554 #line 1311 "./parse.y"
3555 {
3556 if (ctxp->prevent_ese != lineno)
3557 yyerror ("Invalid expression statement");
3558 DRECOVER (expr_stmt);
3559 ;
3560 break;}
3561 case 232:
3562 #line 1317 "./parse.y"
3563 {yyerror ("')' expected"); RECOVER;;
3564 break;}
3565 case 233:
3566 #line 1319 "./parse.y"
3567 {
3568 yyerror ("Constructor invocation must be first "
3569 "thing in a constructor");
3570 RECOVER;
3571 ;
3572 break;}
3573 case 234:
3574 #line 1325 "./parse.y"
3575 {yyerror ("')' expected"); RECOVER;;
3576 break;}
3577 case 235:
3578 #line 1327 "./parse.y"
3579 {
3580 yyerror ("Constructor invocation must be first "
3581 "thing in a constructor");
3582 RECOVER;
3583 ;
3584 break;}
3585 case 236:
3586 #line 1333 "./parse.y"
3587 {yyerror ("'(' expected"); RECOVER;;
3588 break;}
3589 case 237:
3590 #line 1335 "./parse.y"
3591 {yyerror ("')' expected"); RECOVER;;
3592 break;}
3593 case 238:
3594 #line 1337 "./parse.y"
3595 {yyerror ("')' expected"); RECOVER;;
3596 break;}
3597 case 239:
3598 #line 1339 "./parse.y"
3599 {yyerror ("';' expected"); RECOVER;;
3600 break;}
3601 case 240:
3602 #line 1341 "./parse.y"
3603 {yyerror ("';' expected"); RECOVER;;
3604 break;}
3605 case 248:
3606 #line 1356 "./parse.y"
3607 {
3608 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
3609 yyvsp[0].node, NULL_TREE);
3610 ;
3611 break;}
3612 case 249:
3613 #line 1361 "./parse.y"
3614 {yyerror ("'(' expected"); RECOVER;;
3615 break;}
3616 case 250:
3617 #line 1363 "./parse.y"
3618 {yyerror ("Missing term"); RECOVER;;
3619 break;}
3620 case 251:
3621 #line 1365 "./parse.y"
3622 {yyerror ("')' expected"); RECOVER;;
3623 break;}
3624 case 252:
3625 #line 1370 "./parse.y"
3626 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3627 break;}
3628 case 253:
3629 #line 1375 "./parse.y"
3630 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3631 break;}
3632 case 254:
3633 #line 1380 "./parse.y"
3634 {
3635 enter_block ();
3636 ;
3637 break;}
3638 case 255:
3639 #line 1384 "./parse.y"
3640 {
3641 /* Make into "proper list" of COMPOUND_EXPRs.
3642 I.e. make the last statment also have its own
3643 COMPOUND_EXPR. */
3644 maybe_absorb_scoping_blocks ();
3645 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3646 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3647 ;
3648 break;}
3649 case 256:
3650 #line 1396 "./parse.y"
3651 {
3652 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3653 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3654 ;
3655 break;}
3656 case 257:
3657 #line 1401 "./parse.y"
3658 {yyerror ("'(' expected"); RECOVER;;
3659 break;}
3660 case 258:
3661 #line 1403 "./parse.y"
3662 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3663 break;}
3664 case 259:
3665 #line 1405 "./parse.y"
3666 {yyerror ("'{' expected"); RECOVER;;
3667 break;}
3668 case 260:
3669 #line 1413 "./parse.y"
3670 { yyval.node = NULL_TREE; ;
3671 break;}
3672 case 261:
3673 #line 1415 "./parse.y"
3674 { yyval.node = NULL_TREE; ;
3675 break;}
3676 case 262:
3677 #line 1417 "./parse.y"
3678 { yyval.node = NULL_TREE; ;
3679 break;}
3680 case 263:
3681 #line 1419 "./parse.y"
3682 { yyval.node = NULL_TREE; ;
3683 break;}
3684 case 269:
3685 #line 1438 "./parse.y"
3686 {
3687 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3688 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3689 java_method_add_stmt (current_function_decl, lab);
3690 ;
3691 break;}
3692 case 270:
3693 #line 1444 "./parse.y"
3694 {
3695 tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3696 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3697 java_method_add_stmt (current_function_decl, lab);
3698 ;
3699 break;}
3700 case 271:
3701 #line 1450 "./parse.y"
3702 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3703 break;}
3704 case 272:
3705 #line 1452 "./parse.y"
3706 {yyerror ("':' expected"); RECOVER;;
3707 break;}
3708 case 273:
3709 #line 1454 "./parse.y"
3710 {yyerror ("':' expected"); RECOVER;;
3711 break;}
3712 case 274:
3713 #line 1459 "./parse.y"
3714 {
3715 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3716 yyval.node = build_new_loop (body);
3717 ;
3718 break;}
3719 case 275:
3720 #line 1467 "./parse.y"
3721 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3722 break;}
3723 case 276:
3724 #line 1469 "./parse.y"
3725 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3726 break;}
3727 case 277:
3728 #line 1471 "./parse.y"
3729 {yyerror ("Missing term and ')' expected"); RECOVER;;
3730 break;}
3731 case 278:
3732 #line 1473 "./parse.y"
3733 {yyerror ("')' expected"); RECOVER;;
3734 break;}
3735 case 279:
3736 #line 1478 "./parse.y"
3737 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3738 break;}
3739 case 280:
3740 #line 1483 "./parse.y"
3741 {
3742 tree body = build_loop_body (0, NULL_TREE, 1);
3743 yyval.node = build_new_loop (body);
3744 ;
3745 break;}
3746 case 281:
3747 #line 1492 "./parse.y"
3748 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3749 break;}
3750 case 282:
3751 #line 1497 "./parse.y"
3752 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3753 break;}
3754 case 283:
3755 #line 1499 "./parse.y"
3756 {
3757 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3758 /* We have not condition, so we get rid of the EXIT_EXPR */
3759 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3760 empty_stmt_node;
3761 ;
3762 break;}
3763 case 284:
3764 #line 1506 "./parse.y"
3765 {yyerror ("Invalid control expression"); RECOVER;;
3766 break;}
3767 case 285:
3768 #line 1508 "./parse.y"
3769 {yyerror ("Invalid update expression"); RECOVER;;
3770 break;}
3771 case 286:
3772 #line 1510 "./parse.y"
3773 {yyerror ("Invalid update expression"); RECOVER;;
3774 break;}
3775 case 287:
3776 #line 1515 "./parse.y"
3777 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3778 break;}
3779 case 288:
3780 #line 1517 "./parse.y"
3781 {
3782 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3783 /* We have not condition, so we get rid of the EXIT_EXPR */
3784 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3785 empty_stmt_node;
3786 ;
3787 break;}
3788 case 289:
3789 #line 1527 "./parse.y"
3790 {
3791 /* This scope defined for local variable that may be
3792 defined within the scope of the for loop */
3793 enter_block ();
3794 ;
3795 break;}
3796 case 290:
3797 #line 1533 "./parse.y"
3798 {yyerror ("'(' expected"); DRECOVER(for_1);;
3799 break;}
3800 case 291:
3801 #line 1535 "./parse.y"
3802 {yyerror ("Invalid init statement"); RECOVER;;
3803 break;}
3804 case 292:
3805 #line 1540 "./parse.y"
3806 {
3807 /* We now declare the loop body. The loop is
3808 declared as a for loop. */
3809 tree body = build_loop_body (0, NULL_TREE, 0);
3810 yyval.node = build_new_loop (body);
3811 IS_FOR_LOOP_P (yyval.node) = 1;
3812 /* The loop is added to the current block the for
3813 statement is defined within */
3814 java_method_add_stmt (current_function_decl, yyval.node);
3815 ;
3816 break;}
3817 case 293:
3818 #line 1552 "./parse.y"
3819 { yyval.node = empty_stmt_node; ;
3820 break;}
3821 case 294:
3822 #line 1554 "./parse.y"
3823 {
3824 /* Init statement recorded within the previously
3825 defined block scope */
3826 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
3827 ;
3828 break;}
3829 case 295:
3830 #line 1560 "./parse.y"
3831 {
3832 /* Local variable are recorded within the previously
3833 defined block scope */
3834 yyval.node = NULL_TREE;
3835 ;
3836 break;}
3837 case 296:
3838 #line 1566 "./parse.y"
3839 {yyerror ("';' expected"); DRECOVER(for_init_1);;
3840 break;}
3841 case 297:
3842 #line 1570 "./parse.y"
3843 {yyval.node = empty_stmt_node;;
3844 break;}
3845 case 298:
3846 #line 1572 "./parse.y"
3847 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
3848 break;}
3849 case 299:
3850 #line 1577 "./parse.y"
3851 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
3852 break;}
3853 case 300:
3854 #line 1579 "./parse.y"
3855 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
3856 break;}
3857 case 301:
3858 #line 1581 "./parse.y"
3859 {yyerror ("Missing term"); RECOVER;;
3860 break;}
3861 case 302:
3862 #line 1586 "./parse.y"
3863 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
3864 break;}
3865 case 303:
3866 #line 1588 "./parse.y"
3867 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
3868 break;}
3869 case 304:
3870 #line 1590 "./parse.y"
3871 {yyerror ("Missing term"); RECOVER;;
3872 break;}
3873 case 305:
3874 #line 1592 "./parse.y"
3875 {yyerror ("';' expected"); RECOVER;;
3876 break;}
3877 case 306:
3878 #line 1597 "./parse.y"
3879 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
3880 break;}
3881 case 307:
3882 #line 1599 "./parse.y"
3883 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
3884 break;}
3885 case 308:
3886 #line 1601 "./parse.y"
3887 {yyerror ("Missing term"); RECOVER;;
3888 break;}
3889 case 309:
3890 #line 1603 "./parse.y"
3891 {yyerror ("';' expected"); RECOVER;;
3892 break;}
3893 case 310:
3894 #line 1608 "./parse.y"
3895 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
3896 break;}
3897 case 311:
3898 #line 1610 "./parse.y"
3899 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3900 break;}
3901 case 312:
3902 #line 1612 "./parse.y"
3903 {yyerror ("Missing term"); RECOVER;;
3904 break;}
3905 case 313:
3906 #line 1614 "./parse.y"
3907 {yyerror ("';' expected"); RECOVER;;
3908 break;}
3909 case 314:
3910 #line 1619 "./parse.y"
3911 {
3912 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
3913 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3914 ;
3915 break;}
3916 case 315:
3917 #line 1624 "./parse.y"
3918 {yyerror ("Missing term"); RECOVER;;
3919 break;}
3920 case 316:
3921 #line 1626 "./parse.y"
3922 {yyerror ("';' expected"); RECOVER;;
3923 break;}
3924 case 317:
3925 #line 1631 "./parse.y"
3926 {
3927 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3928 EXPR_WFL_LINECOL (yyval.node) =
3929 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
3930 ;
3931 break;}
3932 case 318:
3933 #line 1637 "./parse.y"
3934 {yyerror ("'{' expected"); RECOVER;;
3935 break;}
3936 case 319:
3937 #line 1639 "./parse.y"
3938 {yyerror ("'(' expected"); RECOVER;;
3939 break;}
3940 case 320:
3941 #line 1641 "./parse.y"
3942 {yyerror ("Missing term"); RECOVER;;
3943 break;}
3944 case 321:
3945 #line 1643 "./parse.y"
3946 {yyerror ("Missing term"); RECOVER;;
3947 break;}
3948 case 322:
3949 #line 1648 "./parse.y"
3950 {
3951 if ((1 << yyvsp[0].value) != ACC_SYNCHRONIZED)
3952 fatal ("synchronized was '%d' - yyparse", (1 << yyvsp[0].value));
3953 ;
3954 break;}
3955 case 323:
3956 #line 1656 "./parse.y"
3957 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3958 break;}
3959 case 324:
3960 #line 1658 "./parse.y"
3961 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
3962 break;}
3963 case 325:
3964 #line 1660 "./parse.y"
3965 { yyval.node = build_try_finally_statement
3966 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
3967 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
3968 ;
3969 break;}
3970 case 326:
3971 #line 1665 "./parse.y"
3972 {yyerror ("'{' expected"); DRECOVER (try_statement);;
3973 break;}
3974 case 328:
3975 #line 1671 "./parse.y"
3976 {
3977 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
3978 yyval.node = yyvsp[0].node;
3979 ;
3980 break;}
3981 case 329:
3982 #line 1679 "./parse.y"
3983 {
3984 java_method_add_stmt (current_function_decl, yyvsp[0].node);
3985 exit_block ();
3986 yyval.node = yyvsp[-1].node;
3987 ;
3988 break;}
3989 case 330:
3990 #line 1687 "./parse.y"
3991 {
3992 /* We add a block to define a scope for
3993 formal_parameter (CCBP). The formal parameter is
3994 declared initialized by the appropriate function
3995 call */
3996 tree ccpb = enter_block ();
3997 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
3998 TREE_PURPOSE (yyvsp[-1].node),
3999 soft_exceptioninfo_call_node);
4000 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4001 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4002 init));
4003 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4004 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4005 ;
4006 break;}
4007 case 331:
4008 #line 1703 "./parse.y"
4009 {yyerror ("'(' expected"); RECOVER;;
4010 break;}
4011 case 332:
4012 #line 1705 "./parse.y"
4013 {yyerror ("Missing term or ')' expected"); DRECOVER (2);;
4014 break;}
4015 case 333:
4016 #line 1707 "./parse.y"
4017 {yyerror ("')' expected"); DRECOVER (1);;
4018 break;}
4019 case 334:
4020 #line 1712 "./parse.y"
4021 { yyval.node = yyvsp[0].node; ;
4022 break;}
4023 case 335:
4024 #line 1714 "./parse.y"
4025 {yyerror ("'{' expected"); RECOVER; ;
4026 break;}
4027 case 339:
4028 #line 1726 "./parse.y"
4029 { yyval.node = build_this (yyvsp[0].operator.location); ;
4030 break;}
4031 case 340:
4032 #line 1728 "./parse.y"
4033 {yyval.node = yyvsp[-1].node;;
4034 break;}
4035 case 345:
4036 #line 1737 "./parse.y"
4037 { yyval.node = parse_jdk1_1_error ("named class literals"); ;
4038 break;}
4039 case 346:
4040 #line 1739 "./parse.y"
4041 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4042 break;}
4043 case 347:
4044 #line 1741 "./parse.y"
4045 { yyval.node = build_class_ref (void_type_node); ;
4046 break;}
4047 case 348:
4048 #line 1746 "./parse.y"
4049 { yyval.node = parse_jdk1_1_error ("class literals"); ;
4050 break;}
4051 case 349:
4052 #line 1748 "./parse.y"
4053 {yyerror ("')' expected"); RECOVER;;
4054 break;}
4055 case 350:
4056 #line 1750 "./parse.y"
4057 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4058 break;}
4059 case 351:
4060 #line 1752 "./parse.y"
4061 {yyerror ("'class' expected" ); RECOVER;;
4062 break;}
4063 case 352:
4064 #line 1754 "./parse.y"
4065 {yyerror ("'class' expected" ); RECOVER;;
4066 break;}
4067 case 353:
4068 #line 1759 "./parse.y"
4069 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4070 break;}
4071 case 354:
4072 #line 1761 "./parse.y"
4073 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4074 break;}
4075 case 355:
4076 #line 1766 "./parse.y"
4077 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4078 break;}
4079 case 356:
4080 #line 1768 "./parse.y"
4081 { yyval.node = parse_jdk1_1_error ("inner class instance creation"); ;
4082 break;}
4083 case 361:
4084 #line 1777 "./parse.y"
4085 {yyerror ("'(' expected"); DRECOVER(new_1);;
4086 break;}
4087 case 362:
4088 #line 1779 "./parse.y"
4089 {yyerror ("'(' expected"); RECOVER;;
4090 break;}
4091 case 363:
4092 #line 1781 "./parse.y"
4093 {yyerror ("')' or term expected"); RECOVER;;
4094 break;}
4095 case 364:
4096 #line 1783 "./parse.y"
4097 {yyerror ("')' expected"); RECOVER;;
4098 break;}
4099 case 365:
4100 #line 1785 "./parse.y"
4101 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4102 break;}
4103 case 366:
4104 #line 1787 "./parse.y"
4105 {yyerror ("'(' expected"); RECOVER;;
4106 break;}
4107 case 369:
4108 #line 1797 "./parse.y"
4109 {
4110 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4111 ctxp->formal_parameter_number = 1;
4112 ;
4113 break;}
4114 case 370:
4115 #line 1802 "./parse.y"
4116 {
4117 ctxp->formal_parameter_number += 1;
4118 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4119 ;
4120 break;}
4121 case 371:
4122 #line 1807 "./parse.y"
4123 {yyerror ("Missing term"); RECOVER;;
4124 break;}
4125 case 372:
4126 #line 1812 "./parse.y"
4127 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4128 break;}
4129 case 373:
4130 #line 1814 "./parse.y"
4131 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4132 break;}
4133 case 374:
4134 #line 1816 "./parse.y"
4135 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4136 break;}
4137 case 375:
4138 #line 1818 "./parse.y"
4139 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4140 break;}
4141 case 376:
4142 #line 1822 "./parse.y"
4143 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4144 break;}
4145 case 377:
4146 #line 1824 "./parse.y"
4147 { yyval.node = parse_jdk1_1_error ("anonymous array"); ;
4148 break;}
4149 case 378:
4150 #line 1826 "./parse.y"
4151 {yyerror ("'[' expected"); DRECOVER ("]");;
4152 break;}
4153 case 379:
4154 #line 1828 "./parse.y"
4155 {yyerror ("']' expected"); RECOVER;;
4156 break;}
4157 case 380:
4158 #line 1833 "./parse.y"
4159 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4160 break;}
4161 case 381:
4162 #line 1835 "./parse.y"
4163 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4164 break;}
4165 case 382:
4166 #line 1840 "./parse.y"
4167 {
4168 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4169 yyval.node = yyvsp[-1].node;
4170 ;
4171 break;}
4172 case 383:
4173 #line 1845 "./parse.y"
4174 {yyerror ("']' expected"); RECOVER;;
4175 break;}
4176 case 384:
4177 #line 1847 "./parse.y"
4178 {
4179 yyerror ("Missing term");
4180 yyerror ("']' expected");
4181 RECOVER;
4182 ;
4183 break;}
4184 case 385:
4185 #line 1856 "./parse.y"
4186 {
4187 int allocate = 0;
4188 /* If not initialized, allocate memory for the osb
4189 numbers stack */
4190 if (!ctxp->osb_limit)
4191 {
4192 allocate = ctxp->osb_limit = 32;
4193 ctxp->osb_depth = -1;
4194 }
4195 /* If capacity overflown, reallocate a bigger chuck */
4196 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4197 allocate = ctxp->osb_limit << 1;
4198
4199 if (allocate)
4200 {
4201 allocate *= sizeof (int);
4202 if (ctxp->osb_number)
4203 ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4204 allocate);
4205 else
4206 ctxp->osb_number = (int *)xmalloc (allocate);
4207 }
4208 ctxp->osb_depth++;
4209 CURRENT_OSB (ctxp) = 1;
4210 ;
4211 break;}
4212 case 386:
4213 #line 1882 "./parse.y"
4214 { CURRENT_OSB (ctxp)++; ;
4215 break;}
4216 case 387:
4217 #line 1884 "./parse.y"
4218 { yyerror ("']' expected"); RECOVER;;
4219 break;}
4220 case 388:
4221 #line 1889 "./parse.y"
4222 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4223 break;}
4224 case 389:
4225 #line 1893 "./parse.y"
4226 {
4227 tree super_wfl =
4228 build_wfl_node (super_identifier_node);
4229 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4230 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4231 ;
4232 break;}
4233 case 390:
4234 #line 1900 "./parse.y"
4235 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4236 break;}
4237 case 391:
4238 #line 1905 "./parse.y"
4239 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4240 break;}
4241 case 392:
4242 #line 1907 "./parse.y"
4243 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4244 break;}
4245 case 393:
4246 #line 1909 "./parse.y"
4247 {
4248 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4249 yyval.node = build_this_super_qualified_invocation
4250 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4251 else
4252 {
4253 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4254 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4255 }
4256 ;
4257 break;}
4258 case 394:
4259 #line 1920 "./parse.y"
4260 {
4261 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4262 yyval.node = build_this_super_qualified_invocation
4263 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4264 else
4265 {
4266 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4267 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4268 }
4269 ;
4270 break;}
4271 case 395:
4272 #line 1931 "./parse.y"
4273 {
4274 yyval.node = build_this_super_qualified_invocation
4275 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4276 ;
4277 break;}
4278 case 396:
4279 #line 1936 "./parse.y"
4280 {
4281 yyval.node = build_this_super_qualified_invocation
4282 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4283 ;
4284 break;}
4285 case 397:
4286 #line 1945 "./parse.y"
4287 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4288 break;}
4289 case 398:
4290 #line 1947 "./parse.y"
4291 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4292 break;}
4293 case 399:
4294 #line 1952 "./parse.y"
4295 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4296 break;}
4297 case 400:
4298 #line 1954 "./parse.y"
4299 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4300 break;}
4301 case 401:
4302 #line 1956 "./parse.y"
4303 {
4304 yyerror ("Missing term and ']' expected");
4305 DRECOVER(array_access);
4306 ;
4307 break;}
4308 case 402:
4309 #line 1961 "./parse.y"
4310 {
4311 yyerror ("']' expected");
4312 DRECOVER(array_access);
4313 ;
4314 break;}
4315 case 403:
4316 #line 1966 "./parse.y"
4317 {
4318 yyerror ("Missing term and ']' expected");
4319 DRECOVER(array_access);
4320 ;
4321 break;}
4322 case 404:
4323 #line 1971 "./parse.y"
4324 {
4325 yyerror ("']' expected");
4326 DRECOVER(array_access);
4327 ;
4328 break;}
4329 case 409:
4330 #line 1986 "./parse.y"
4331 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4332 break;}
4333 case 410:
4334 #line 1991 "./parse.y"
4335 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4336 break;}
4337 case 413:
4338 #line 1998 "./parse.y"
4339 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4340 break;}
4341 case 414:
4342 #line 2000 "./parse.y"
4343 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4344 break;}
4345 case 416:
4346 #line 2003 "./parse.y"
4347 {yyerror ("Missing term"); RECOVER;
4348 break;}
4349 case 417:
4350 #line 2005 "./parse.y"
4351 {yyerror ("Missing term"); RECOVER;
4352 break;}
4353 case 418:
4354 #line 2010 "./parse.y"
4355 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4356 break;}
4357 case 419:
4358 #line 2012 "./parse.y"
4359 {yyerror ("Missing term"); RECOVER;
4360 break;}
4361 case 420:
4362 #line 2017 "./parse.y"
4363 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4364 break;}
4365 case 421:
4366 #line 2019 "./parse.y"
4367 {yyerror ("Missing term"); RECOVER;
4368 break;}
4369 case 423:
4370 #line 2025 "./parse.y"
4371 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4372 break;}
4373 case 424:
4374 #line 2027 "./parse.y"
4375 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4376 break;}
4377 case 426:
4378 #line 2030 "./parse.y"
4379 {yyerror ("Missing term"); RECOVER;
4380 break;}
4381 case 427:
4382 #line 2032 "./parse.y"
4383 {yyerror ("Missing term"); RECOVER;
4384 break;}
4385 case 428:
4386 #line 2037 "./parse.y"
4387 {
4388 tree type = yyvsp[-3].node;
4389 while (CURRENT_OSB (ctxp)--)
4390 type = build_java_array_type (type, -1);
4391 ctxp->osb_depth--;
4392 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4393 ;
4394 break;}
4395 case 429:
4396 #line 2045 "./parse.y"
4397 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4398 break;}
4399 case 430:
4400 #line 2047 "./parse.y"
4401 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4402 break;}
4403 case 431:
4404 #line 2049 "./parse.y"
4405 {
4406 char *ptr;
4407 while (CURRENT_OSB (ctxp)--)
4408 obstack_1grow (&temporary_obstack, '[');
4409 ctxp->osb_depth--;
4410 obstack_grow0 (&temporary_obstack,
4411 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4412 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4413 ptr = obstack_finish (&temporary_obstack);
4414 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4415 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4416 ;
4417 break;}
4418 case 432:
4419 #line 2062 "./parse.y"
4420 {yyerror ("']' expected, invalid type expression");;
4421 break;}
4422 case 433:
4423 #line 2064 "./parse.y"
4424 {
4425 if (ctxp->prevent_ese != lineno)
4426 yyerror ("Invalid type expression"); RECOVER;
4427 RECOVER;
4428 ;
4429 break;}
4430 case 434:
4431 #line 2070 "./parse.y"
4432 {yyerror ("Missing term"); RECOVER;;
4433 break;}
4434 case 435:
4435 #line 2072 "./parse.y"
4436 {yyerror ("Missing term"); RECOVER;;
4437 break;}
4438 case 436:
4439 #line 2074 "./parse.y"
4440 {yyerror ("Missing term"); RECOVER;;
4441 break;}
4442 case 438:
4443 #line 2080 "./parse.y"
4444 {
4445 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4446 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4447 ;
4448 break;}
4449 case 439:
4450 #line 2085 "./parse.y"
4451 {
4452 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4453 yyvsp[-2].node, yyvsp[0].node);
4454 ;
4455 break;}
4456 case 440:
4457 #line 2090 "./parse.y"
4458 {
4459 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4460 yyvsp[-2].node, yyvsp[0].node);
4461 ;
4462 break;}
4463 case 441:
4464 #line 2095 "./parse.y"
4465 {yyerror ("Missing term"); RECOVER;;
4466 break;}
4467 case 442:
4468 #line 2097 "./parse.y"
4469 {yyerror ("Missing term"); RECOVER;;
4470 break;}
4471 case 443:
4472 #line 2099 "./parse.y"
4473 {yyerror ("Missing term"); RECOVER;;
4474 break;}
4475 case 445:
4476 #line 2105 "./parse.y"
4477 {
4478 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4479 yyvsp[-2].node, yyvsp[0].node);
4480 ;
4481 break;}
4482 case 446:
4483 #line 2110 "./parse.y"
4484 {
4485 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4486 yyvsp[-2].node, yyvsp[0].node);
4487 ;
4488 break;}
4489 case 447:
4490 #line 2115 "./parse.y"
4491 {yyerror ("Missing term"); RECOVER;;
4492 break;}
4493 case 448:
4494 #line 2117 "./parse.y"
4495 {yyerror ("Missing term"); RECOVER;;
4496 break;}
4497 case 450:
4498 #line 2123 "./parse.y"
4499 {
4500 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4501 yyvsp[-2].node, yyvsp[0].node);
4502 ;
4503 break;}
4504 case 451:
4505 #line 2128 "./parse.y"
4506 {
4507 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4508 yyvsp[-2].node, yyvsp[0].node);
4509 ;
4510 break;}
4511 case 452:
4512 #line 2133 "./parse.y"
4513 {
4514 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4515 yyvsp[-2].node, yyvsp[0].node);
4516 ;
4517 break;}
4518 case 453:
4519 #line 2138 "./parse.y"
4520 {yyerror ("Missing term"); RECOVER;;
4521 break;}
4522 case 454:
4523 #line 2140 "./parse.y"
4524 {yyerror ("Missing term"); RECOVER;;
4525 break;}
4526 case 455:
4527 #line 2142 "./parse.y"
4528 {yyerror ("Missing term"); RECOVER;;
4529 break;}
4530 case 457:
4531 #line 2148 "./parse.y"
4532 {
4533 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4534 yyvsp[-2].node, yyvsp[0].node);
4535 ;
4536 break;}
4537 case 458:
4538 #line 2153 "./parse.y"
4539 {
4540 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4541 yyvsp[-2].node, yyvsp[0].node);
4542 ;
4543 break;}
4544 case 459:
4545 #line 2158 "./parse.y"
4546 {
4547 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4548 yyvsp[-2].node, yyvsp[0].node);
4549 ;
4550 break;}
4551 case 460:
4552 #line 2163 "./parse.y"
4553 {
4554 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4555 yyvsp[-2].node, yyvsp[0].node);
4556 ;
4557 break;}
4558 case 461:
4559 #line 2168 "./parse.y"
4560 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4561 break;}
4562 case 462:
4563 #line 2170 "./parse.y"
4564 {yyerror ("Missing term"); RECOVER;;
4565 break;}
4566 case 463:
4567 #line 2172 "./parse.y"
4568 {yyerror ("Missing term"); RECOVER;;
4569 break;}
4570 case 464:
4571 #line 2174 "./parse.y"
4572 {yyerror ("Missing term"); RECOVER;;
4573 break;}
4574 case 465:
4575 #line 2176 "./parse.y"
4576 {yyerror ("Missing term"); RECOVER;;
4577 break;}
4578 case 466:
4579 #line 2178 "./parse.y"
4580 {yyerror ("Invalid reference type"); RECOVER;;
4581 break;}
4582 case 468:
4583 #line 2184 "./parse.y"
4584 {
4585 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4586 yyvsp[-2].node, yyvsp[0].node);
4587 ;
4588 break;}
4589 case 469:
4590 #line 2189 "./parse.y"
4591 {
4592 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4593 yyvsp[-2].node, yyvsp[0].node);
4594 ;
4595 break;}
4596 case 470:
4597 #line 2194 "./parse.y"
4598 {yyerror ("Missing term"); RECOVER;;
4599 break;}
4600 case 471:
4601 #line 2196 "./parse.y"
4602 {yyerror ("Missing term"); RECOVER;;
4603 break;}
4604 case 473:
4605 #line 2202 "./parse.y"
4606 {
4607 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4608 yyvsp[-2].node, yyvsp[0].node);
4609 ;
4610 break;}
4611 case 474:
4612 #line 2207 "./parse.y"
4613 {yyerror ("Missing term"); RECOVER;;
4614 break;}
4615 case 476:
4616 #line 2213 "./parse.y"
4617 {
4618 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4619 yyvsp[-2].node, yyvsp[0].node);
4620 ;
4621 break;}
4622 case 477:
4623 #line 2218 "./parse.y"
4624 {yyerror ("Missing term"); RECOVER;;
4625 break;}
4626 case 479:
4627 #line 2224 "./parse.y"
4628 {
4629 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4630 yyvsp[-2].node, yyvsp[0].node);
4631 ;
4632 break;}
4633 case 480:
4634 #line 2229 "./parse.y"
4635 {yyerror ("Missing term"); RECOVER;;
4636 break;}
4637 case 482:
4638 #line 2235 "./parse.y"
4639 {
4640 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4641 yyvsp[-2].node, yyvsp[0].node);
4642 ;
4643 break;}
4644 case 483:
4645 #line 2240 "./parse.y"
4646 {yyerror ("Missing term"); RECOVER;;
4647 break;}
4648 case 485:
4649 #line 2246 "./parse.y"
4650 {
4651 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4652 yyvsp[-2].node, yyvsp[0].node);
4653 ;
4654 break;}
4655 case 486:
4656 #line 2251 "./parse.y"
4657 {yyerror ("Missing term"); RECOVER;;
4658 break;}
4659 case 488:
4660 #line 2257 "./parse.y"
4661 {
4662 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4663 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4664 ;
4665 break;}
4666 case 489:
4667 #line 2262 "./parse.y"
4668 {
4669 YYERROR_NOW;
4670 yyerror ("Missing term");
4671 DRECOVER (1);
4672 ;
4673 break;}
4674 case 490:
4675 #line 2268 "./parse.y"
4676 {yyerror ("Missing term"); DRECOVER (2);;
4677 break;}
4678 case 491:
4679 #line 2270 "./parse.y"
4680 {yyerror ("Missing term"); DRECOVER (3);;
4681 break;}
4682 case 494:
4683 #line 2280 "./parse.y"
4684 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4685 break;}
4686 case 495:
4687 #line 2282 "./parse.y"
4688 {
4689 if (ctxp->prevent_ese != lineno)
4690 yyerror ("Missing term");
4691 DRECOVER (assign);
4692 ;
4693 break;}
4694 }
4695 /* the action file gets copied in in place of this dollarsign */
4696 #line 498 "/usr/lib/bison.simple"
4697 \f
4698 yyvsp -= yylen;
4699 yyssp -= yylen;
4700 #ifdef YYLSP_NEEDED
4701 yylsp -= yylen;
4702 #endif
4703
4704 #if YYDEBUG != 0
4705 if (yydebug)
4706 {
4707 short *ssp1 = yyss - 1;
4708 fprintf (stderr, "state stack now");
4709 while (ssp1 != yyssp)
4710 fprintf (stderr, " %d", *++ssp1);
4711 fprintf (stderr, "\n");
4712 }
4713 #endif
4714
4715 *++yyvsp = yyval;
4716
4717 #ifdef YYLSP_NEEDED
4718 yylsp++;
4719 if (yylen == 0)
4720 {
4721 yylsp->first_line = yylloc.first_line;
4722 yylsp->first_column = yylloc.first_column;
4723 yylsp->last_line = (yylsp-1)->last_line;
4724 yylsp->last_column = (yylsp-1)->last_column;
4725 yylsp->text = 0;
4726 }
4727 else
4728 {
4729 yylsp->last_line = (yylsp+yylen-1)->last_line;
4730 yylsp->last_column = (yylsp+yylen-1)->last_column;
4731 }
4732 #endif
4733
4734 /* Now "shift" the result of the reduction.
4735 Determine what state that goes to,
4736 based on the state we popped back to
4737 and the rule number reduced by. */
4738
4739 yyn = yyr1[yyn];
4740
4741 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
4742 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
4743 yystate = yytable[yystate];
4744 else
4745 yystate = yydefgoto[yyn - YYNTBASE];
4746
4747 goto yynewstate;
4748
4749 yyerrlab: /* here on detecting error */
4750
4751 if (! yyerrstatus)
4752 /* If not already recovering from an error, report this error. */
4753 {
4754 ++yynerrs;
4755
4756 #ifdef YYERROR_VERBOSE
4757 yyn = yypact[yystate];
4758
4759 if (yyn > YYFLAG && yyn < YYLAST)
4760 {
4761 int size = 0;
4762 char *msg;
4763 int x, count;
4764
4765 count = 0;
4766 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
4767 for (x = (yyn < 0 ? -yyn : 0);
4768 x < (sizeof(yytname) / sizeof(char *)); x++)
4769 if (yycheck[x + yyn] == x)
4770 size += strlen(yytname[x]) + 15, count++;
4771 msg = (char *) malloc(size + 15);
4772 if (msg != 0)
4773 {
4774 strcpy(msg, "parse error");
4775
4776 if (count < 5)
4777 {
4778 count = 0;
4779 for (x = (yyn < 0 ? -yyn : 0);
4780 x < (sizeof(yytname) / sizeof(char *)); x++)
4781 if (yycheck[x + yyn] == x)
4782 {
4783 strcat(msg, count == 0 ? ", expecting `" : " or `");
4784 strcat(msg, yytname[x]);
4785 strcat(msg, "'");
4786 count++;
4787 }
4788 }
4789 yyerror(msg);
4790 free(msg);
4791 }
4792 else
4793 yyerror ("parse error; also virtual memory exceeded");
4794 }
4795 else
4796 #endif /* YYERROR_VERBOSE */
4797 yyerror("parse error");
4798 }
4799
4800 goto yyerrlab1;
4801 yyerrlab1: /* here on error raised explicitly by an action */
4802
4803 if (yyerrstatus == 3)
4804 {
4805 /* if just tried and failed to reuse lookahead token after an error, discard it. */
4806
4807 /* return failure if at end of input */
4808 if (yychar == YYEOF)
4809 YYABORT;
4810
4811 #if YYDEBUG != 0
4812 if (yydebug)
4813 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
4814 #endif
4815
4816 yychar = YYEMPTY;
4817 }
4818
4819 /* Else will try to reuse lookahead token
4820 after shifting the error token. */
4821
4822 yyerrstatus = 3; /* Each real token shifted decrements this */
4823
4824 goto yyerrhandle;
4825
4826 yyerrdefault: /* current state does not do anything special for the error token. */
4827
4828 #if 0
4829 /* This is wrong; only states that explicitly want error tokens
4830 should shift them. */
4831 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
4832 if (yyn) goto yydefault;
4833 #endif
4834
4835 yyerrpop: /* pop the current state because it cannot handle the error token */
4836
4837 if (yyssp == yyss) YYABORT;
4838 yyvsp--;
4839 yystate = *--yyssp;
4840 #ifdef YYLSP_NEEDED
4841 yylsp--;
4842 #endif
4843
4844 #if YYDEBUG != 0
4845 if (yydebug)
4846 {
4847 short *ssp1 = yyss - 1;
4848 fprintf (stderr, "Error: state stack now");
4849 while (ssp1 != yyssp)
4850 fprintf (stderr, " %d", *++ssp1);
4851 fprintf (stderr, "\n");
4852 }
4853 #endif
4854
4855 yyerrhandle:
4856
4857 yyn = yypact[yystate];
4858 if (yyn == YYFLAG)
4859 goto yyerrdefault;
4860
4861 yyn += YYTERROR;
4862 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
4863 goto yyerrdefault;
4864
4865 yyn = yytable[yyn];
4866 if (yyn < 0)
4867 {
4868 if (yyn == YYFLAG)
4869 goto yyerrpop;
4870 yyn = -yyn;
4871 goto yyreduce;
4872 }
4873 else if (yyn == 0)
4874 goto yyerrpop;
4875
4876 if (yyn == YYFINAL)
4877 YYACCEPT;
4878
4879 #if YYDEBUG != 0
4880 if (yydebug)
4881 fprintf(stderr, "Shifting error token, ");
4882 #endif
4883
4884 *++yyvsp = yylval;
4885 #ifdef YYLSP_NEEDED
4886 *++yylsp = yylloc;
4887 #endif
4888
4889 yystate = yyn;
4890 goto yynewstate;
4891 }
4892 #line 2308 "./parse.y"
4893
4894 \f
4895
4896 /* Flag for the error report routine to issue the error the first time
4897 it's called (overriding the default behavior which is to drop the
4898 first invocation and honor the second one, taking advantage of a
4899 richer context. */
4900 static int force_error = 0;
4901
4902 /* Create a new parser context and make it the current one. */
4903
4904 void
4905 java_push_parser_context ()
4906 {
4907 struct parser_ctxt *new =
4908 (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
4909
4910 bzero ((PTR) new, sizeof (struct parser_ctxt));
4911 new->next = ctxp;
4912 ctxp = new;
4913 if (ctxp->next)
4914 {
4915 ctxp->incomplete_class = ctxp->next->incomplete_class;
4916 ctxp->gclass_list = ctxp->next->gclass_list;
4917 }
4918 }
4919
4920 /* If the first file of a file list was a class file, no context
4921 exists for a source file to be parsed. This boolean remembers that
4922 java_parser_context_save_global might have created a dummy one, so
4923 that java_parser_context_restore_global can pop it. */
4924 static int extra_ctxp_pushed_p = 0;
4925
4926 void
4927 java_parser_context_save_global ()
4928 {
4929 if (!ctxp)
4930 {
4931 java_push_parser_context ();
4932 extra_ctxp_pushed_p = 1;
4933 }
4934 ctxp->finput = finput;
4935 ctxp->lineno = lineno;
4936 ctxp->current_class = current_class;
4937 ctxp->filename = input_filename;
4938 ctxp->current_function_decl = current_function_decl;
4939 }
4940
4941 void
4942 java_parser_context_restore_global ()
4943 {
4944 finput = ctxp->finput;
4945 lineno = ctxp->lineno;
4946 current_class = ctxp->current_class;
4947 input_filename = ctxp->filename;
4948 current_function_decl = ctxp->current_function_decl;
4949 if (!ctxp->next && extra_ctxp_pushed_p)
4950 {
4951 java_pop_parser_context (0);
4952 extra_ctxp_pushed_p = 0;
4953 }
4954 }
4955
4956 void
4957 java_pop_parser_context (generate)
4958 int generate;
4959 {
4960 tree current;
4961 struct parser_ctxt *toFree, *next;
4962
4963 if (!ctxp)
4964 return;
4965
4966 toFree = ctxp;
4967 next = ctxp->next;
4968 if (next)
4969 {
4970 next->incomplete_class = ctxp->incomplete_class;
4971 next->gclass_list = ctxp->gclass_list;
4972 lineno = ctxp->lineno;
4973 finput = ctxp->finput;
4974 current_class = ctxp->current_class;
4975 }
4976
4977 /* Set the single import class file flag to 0 for the current list
4978 of imported things */
4979 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4980 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
4981
4982 /* And restore those of the previous context */
4983 if ((ctxp = next)) /* Assignment is really meant here */
4984 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
4985 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
4986
4987 if (generate)
4988 {
4989 toFree->next = ctxp_for_generation;
4990 ctxp_for_generation = toFree;
4991 }
4992 else
4993 free (toFree);
4994 }
4995
4996 /* Reporting JDK1.1 features not implemented */
4997
4998 static tree
4999 parse_jdk1_1_error (msg)
5000 char *msg;
5001 {
5002 sorry (": `%s' JDK1.1(TM) feature", msg);
5003 java_error_count++;
5004 return empty_stmt_node;
5005 }
5006
5007 static int do_warning = 0;
5008
5009 void
5010 yyerror (msg)
5011 char *msg;
5012 {
5013 static java_lc elc;
5014 static int prev_lineno;
5015 static char *prev_msg;
5016
5017 int save_lineno;
5018 char *remainder, *code_from_source;
5019 extern struct obstack temporary_obstack;
5020
5021 if (!force_error && prev_lineno == lineno)
5022 return;
5023
5024 /* Save current error location but report latter, when the context is
5025 richer. */
5026 if (ctxp->java_error_flag == 0)
5027 {
5028 ctxp->java_error_flag = 1;
5029 elc = ctxp->elc;
5030 /* Do something to use the previous line if we're reaching the
5031 end of the file... */
5032 #ifdef VERBOSE_SKELETON
5033 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5034 #endif
5035 return;
5036 }
5037
5038 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5039 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5040 return;
5041
5042 ctxp->java_error_flag = 0;
5043 if (do_warning)
5044 java_warning_count++;
5045 else
5046 java_error_count++;
5047
5048 if (elc.col == 0 && msg[1] == ';')
5049 {
5050 elc.col = ctxp->p_line->char_col-1;
5051 elc.line = ctxp->p_line->lineno;
5052 }
5053
5054 save_lineno = lineno;
5055 prev_lineno = lineno = elc.line;
5056 prev_msg = msg;
5057
5058 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5059 obstack_grow0 (&temporary_obstack,
5060 code_from_source, strlen (code_from_source));
5061 remainder = obstack_finish (&temporary_obstack);
5062 if (do_warning)
5063 warning ("%s.\n%s", msg, remainder);
5064 else
5065 error ("%s.\n%s", msg, remainder);
5066
5067 /* This allow us to cheaply avoid an extra 'Invalid expression
5068 statement' error report when errors have been already reported on
5069 the same line. This occurs when we report an error but don't have
5070 a synchronization point other than ';', which
5071 expression_statement is the only one to take care of. */
5072 ctxp->prevent_ese = lineno = save_lineno;
5073 }
5074
5075 static void
5076 issue_warning_error_from_context (cl, msg, ap)
5077 tree cl;
5078 const char *msg;
5079 va_list ap;
5080 {
5081 char *saved, *saved_input_filename;
5082 char buffer [4096];
5083 vsprintf (buffer, msg, ap);
5084 force_error = 1;
5085
5086 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5087 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5088 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5089
5090 /* We have a CL, that's a good reason for using it if it contains data */
5091 saved = ctxp->filename;
5092 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5093 ctxp->filename = EXPR_WFL_FILENAME (cl);
5094 saved_input_filename = input_filename;
5095 input_filename = ctxp->filename;
5096 java_error (NULL);
5097 java_error (buffer);
5098 ctxp->filename = saved;
5099 input_filename = saved_input_filename;
5100 force_error = 0;
5101 }
5102
5103 /* Issue an error message at a current source line CL */
5104
5105 void
5106 parse_error_context VPROTO ((tree cl, const char *msg, ...))
5107 {
5108 #ifndef ANSI_PROTOTYPES
5109 tree cl;
5110 const char *msg;
5111 #endif
5112 va_list ap;
5113
5114 VA_START (ap, msg);
5115 #ifndef ANSI_PROTOTYPES
5116 cl = va_arg (ap, tree);
5117 msg = va_arg (ap, const char *);
5118 #endif
5119 issue_warning_error_from_context (cl, msg, ap);
5120 va_end (ap);
5121 }
5122
5123 /* Issue a warning at a current source line CL */
5124
5125 static void
5126 parse_warning_context VPROTO ((tree cl, const char *msg, ...))
5127 {
5128 #ifndef ANSI_PROTOTYPES
5129 tree cl;
5130 const char *msg;
5131 #endif
5132 va_list ap;
5133
5134 VA_START (ap, msg);
5135 #ifndef ANSI_PROTOTYPES
5136 cl = va_arg (ap, tree);
5137 msg = va_arg (ap, const char *);
5138 #endif
5139
5140 force_error = do_warning = 1;
5141 issue_warning_error_from_context (cl, msg, ap);
5142 do_warning = force_error = 0;
5143 va_end (ap);
5144 }
5145
5146 static tree
5147 find_expr_with_wfl (node)
5148 tree node;
5149 {
5150 while (node)
5151 {
5152 char code;
5153 tree to_return;
5154
5155 switch (TREE_CODE (node))
5156 {
5157 case BLOCK:
5158 node = BLOCK_EXPR_BODY (node);
5159 continue;
5160
5161 case COMPOUND_EXPR:
5162 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5163 if (to_return)
5164 return to_return;
5165 node = TREE_OPERAND (node, 1);
5166 continue;
5167
5168 case LOOP_EXPR:
5169 node = TREE_OPERAND (node, 0);
5170 continue;
5171
5172 case LABELED_BLOCK_EXPR:
5173 node = TREE_OPERAND (node, 1);
5174 continue;
5175
5176 default:
5177 code = TREE_CODE_CLASS (TREE_CODE (node));
5178 if (((code == '1') || (code == '2') || (code == 'e'))
5179 && EXPR_WFL_LINECOL (node))
5180 return node;
5181 return NULL_TREE;
5182 }
5183 }
5184 return NULL_TREE;
5185 }
5186
5187 /* Issue a missing return statement error. Uses METHOD to figure the
5188 last line of the method the error occurs in. */
5189
5190 static void
5191 missing_return_error (method)
5192 tree method;
5193 {
5194 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5195 parse_error_context (wfl_operator, "Missing return statement");
5196 }
5197
5198 /* Issue an unreachable statement error. From NODE, find the next
5199 statement to report appropriately. */
5200 static void
5201 unreachable_stmt_error (node)
5202 tree node;
5203 {
5204 /* Browse node to find the next expression node that has a WFL. Use
5205 the location to report the error */
5206 if (TREE_CODE (node) == COMPOUND_EXPR)
5207 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5208 else
5209 node = find_expr_with_wfl (node);
5210
5211 if (node)
5212 {
5213 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5214 parse_error_context (wfl_operator, "Unreachable statement");
5215 }
5216 else
5217 fatal ("Can't get valid statement - unreachable_stmt_error");
5218 }
5219
5220 int
5221 java_report_errors ()
5222 {
5223 if (java_error_count)
5224 fprintf (stderr, "%d error%s",
5225 java_error_count, (java_error_count == 1 ? "" : "s"));
5226 if (java_warning_count)
5227 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5228 java_warning_count, (java_warning_count == 1 ? "" : "s"));
5229 if (java_error_count || java_warning_count)
5230 putc ('\n', stderr);
5231 return java_error_count;
5232 }
5233
5234 static char *
5235 java_accstring_lookup (flags)
5236 int flags;
5237 {
5238 static char buffer [80];
5239 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5240
5241 /* Access modifier looked-up first for easier report on forbidden
5242 access. */
5243 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5244 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5245 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5246 if (flags & ACC_STATIC) COPY_RETURN ("static");
5247 if (flags & ACC_FINAL) COPY_RETURN ("final");
5248 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5249 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5250 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5251 if (flags & ACC_NATIVE) COPY_RETURN ("native");
5252 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5253 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5254
5255 buffer [0] = '\0';
5256 return buffer;
5257 #undef COPY_RETURN
5258 }
5259
5260 /* Issuing error messages upon redefinition of classes, interfaces or
5261 variables. */
5262
5263 static void
5264 classitf_redefinition_error (context, id, decl, cl)
5265 char *context;
5266 tree id, decl, cl;
5267 {
5268 parse_error_context (cl, "%s `%s' already defined in %s:%d",
5269 context, IDENTIFIER_POINTER (id),
5270 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5271 /* Here we should point out where its redefined. It's a unicode. FIXME */
5272 }
5273
5274 static void
5275 variable_redefinition_error (context, name, type, line)
5276 tree context, name, type;
5277 int line;
5278 {
5279 char *type_name;
5280
5281 /* Figure a proper name for type. We might haven't resolved it */
5282 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5283 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5284 else
5285 type_name = lang_printable_name (type, 0);
5286
5287 parse_error_context (context,
5288 "Variable `%s' is already defined in this method and "
5289 "was declared `%s %s' at line %d",
5290 IDENTIFIER_POINTER (name),
5291 type_name, IDENTIFIER_POINTER (name), line);
5292 }
5293
5294 static tree
5295 build_array_from_name (type, type_wfl, name, ret_name)
5296 tree type, type_wfl, name, *ret_name;
5297 {
5298 int more_dims = 0;
5299 char *string;
5300
5301 /* Eventually get more dims */
5302 string = IDENTIFIER_POINTER (name);
5303 while (string [more_dims] == '[')
5304 more_dims++;
5305
5306 /* If we have, then craft a new type for this variable */
5307 if (more_dims)
5308 {
5309 name = get_identifier (&string [more_dims]);
5310
5311 /* If we have a pointer, use its type */
5312 if (TREE_CODE (type) == POINTER_TYPE)
5313 type = TREE_TYPE (type);
5314
5315 /* Building the first dimension of a primitive type uses this
5316 function */
5317 if (JPRIMITIVE_TYPE_P (type))
5318 {
5319 type = build_java_array_type (type, -1);
5320 CLASS_LOADED_P (type) = 1;
5321 more_dims--;
5322 }
5323 /* Otherwise, if we have a WFL for this type, use it (the type
5324 is already an array on an unresolved type, and we just keep
5325 on adding dimensions) */
5326 else if (type_wfl)
5327 type = type_wfl;
5328
5329 /* Add all the dimensions */
5330 while (more_dims--)
5331 type = build_unresolved_array_type (type);
5332
5333 /* The type may have been incomplete in the first place */
5334 if (type_wfl)
5335 type = obtain_incomplete_type (type);
5336 }
5337
5338 *ret_name = name;
5339 return type;
5340 }
5341
5342 /* Build something that the type identifier resolver will identify as
5343 being an array to an unresolved type. TYPE_WFL is a WFL on a
5344 identifier. */
5345
5346 static tree
5347 build_unresolved_array_type (type_or_wfl)
5348 tree type_or_wfl;
5349 {
5350 char *ptr;
5351
5352 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5353 just create a array type */
5354 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5355 {
5356 tree type = build_java_array_type (type_or_wfl, -1);
5357 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5358 return type;
5359 }
5360
5361 obstack_1grow (&temporary_obstack, '[');
5362 obstack_grow0 (&temporary_obstack,
5363 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5364 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5365 ptr = obstack_finish (&temporary_obstack);
5366 return build_expr_wfl (get_identifier (ptr),
5367 EXPR_WFL_FILENAME (type_or_wfl),
5368 EXPR_WFL_LINENO (type_or_wfl),
5369 EXPR_WFL_COLNO (type_or_wfl));
5370 }
5371
5372 /* Check modifiers. If one doesn't fit, retrieve it in its declaration line
5373 and point it out. */
5374
5375 static void
5376 check_modifiers (message, value, mask)
5377 char *message;
5378 int value;
5379 int mask;
5380 {
5381 /* Should point out the one that don't fit. ASCII/unicode,
5382 going backward. FIXME */
5383 if (value & ~mask)
5384 {
5385 int i, remainder = value & ~mask;
5386 for (i = 0; i <= 10; i++)
5387 if ((1 << i) & remainder)
5388 parse_error_context (ctxp->modifier_ctx [i], message,
5389 java_accstring_lookup (1 << i));
5390 }
5391 }
5392
5393 static void
5394 parser_add_interface (class_decl, interface_decl, wfl)
5395 tree class_decl, interface_decl, wfl;
5396 {
5397 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5398 parse_error_context (wfl, "Interface `%s' repeated",
5399 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5400 }
5401
5402 /* Bulk of common class/interface checks. Return 1 if an error was
5403 encountered. TAG is 0 for a class, 1 for an interface. */
5404
5405 static int
5406 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5407 int is_interface, flags;
5408 tree raw_name, qualified_name, decl, cl;
5409 {
5410 tree node;
5411
5412 if (!quiet_flag)
5413 fprintf (stderr, " %s %s", (is_interface ? "interface" : "class"),
5414 IDENTIFIER_POINTER (qualified_name));
5415
5416 /* Scope of an interface/class type name:
5417 - Can't be imported by a single type import
5418 - Can't already exists in the package */
5419 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5420 && (node = find_name_in_single_imports (raw_name)))
5421 {
5422 parse_error_context
5423 (cl, "%s name `%s' clashes with imported type `%s'",
5424 (is_interface ? "Interface" : "Class"),
5425 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5426 return 1;
5427 }
5428 if (decl && CLASS_COMPLETE_P (decl))
5429 {
5430 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
5431 qualified_name, decl, cl);
5432 return 1;
5433 }
5434
5435 /* If public, file name should match class/interface name */
5436 if (flags & ACC_PUBLIC)
5437 {
5438 char *f;
5439
5440 /* Contains OS dependent assumption on path separator. FIXME */
5441 for (f = &input_filename [strlen (input_filename)];
5442 f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
5443 f--)
5444 ;
5445 if (f[0] == '/' || f[0] == DIR_SEPARATOR)
5446 f++;
5447 if (strncmp (IDENTIFIER_POINTER (raw_name),
5448 f , IDENTIFIER_LENGTH (raw_name)) ||
5449 f [IDENTIFIER_LENGTH (raw_name)] != '.')
5450 parse_error_context (cl, "Public %s `%s' must be defined in a file "
5451 "called `%s.java'",
5452 (is_interface ? "interface" : "class"),
5453 IDENTIFIER_POINTER (qualified_name),
5454 IDENTIFIER_POINTER (raw_name));
5455 }
5456
5457 check_modifiers ((is_interface ?
5458 "Illegal modifier `%s' for interface declaration" :
5459 "Illegal modifier `%s' for class declaration"), flags,
5460 (is_interface ? INTERFACE_MODIFIERS : CLASS_MODIFIERS));
5461 return 0;
5462 }
5463
5464 /* If DECL is NULL, create and push a new DECL, record the current
5465 line CL and do other maintenance things. */
5466
5467 static tree
5468 maybe_create_class_interface_decl (decl, qualified_name, cl)
5469 tree decl, qualified_name, cl;
5470 {
5471 if (!decl)
5472 decl = push_class (make_class (), qualified_name);
5473
5474 /* Take care of the file and line business */
5475 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
5476 /* If we're emiting xrefs, store the line/col number information */
5477 if (flag_emit_xref)
5478 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
5479 else
5480 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
5481 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
5482 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
5483 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
5484
5485 ctxp->current_parsed_class = decl;
5486
5487 /* Link the declaration to the already seen ones */
5488 TREE_CHAIN (decl) = ctxp->class_list;
5489 ctxp->class_list = decl;
5490
5491 /* Create a new nodes in the global lists */
5492 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
5493 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
5494
5495 /* Install a new dependency list element */
5496 create_jdep_list (ctxp);
5497
5498 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
5499 IDENTIFIER_POINTER (qualified_name)));
5500 return decl;
5501 }
5502
5503 static void
5504 add_superinterfaces (decl, interface_list)
5505 tree decl, interface_list;
5506 {
5507 tree node;
5508 /* Superinterface(s): if present and defined, parser_check_super_interface ()
5509 takes care of ensuring that:
5510 - This is an accessible interface type,
5511 - Circularity detection.
5512 parser_add_interface is then called. If present but not defined,
5513 the check operation is delayed until the super interface gets
5514 defined. */
5515 for (node = interface_list; node; node = TREE_CHAIN (node))
5516 {
5517 tree current = TREE_PURPOSE (node);
5518 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
5519 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
5520 {
5521 if (!parser_check_super_interface (idecl, decl, current))
5522 parser_add_interface (decl, idecl, current);
5523 }
5524 else
5525 register_incomplete_type (JDEP_INTERFACE,
5526 current, decl, NULL_TREE);
5527 }
5528 }
5529
5530 /* Create an interface in pass1 and return its decl. Return the
5531 interface's decl in pass 2. */
5532
5533 static tree
5534 create_interface (flags, id, super)
5535 int flags;
5536 tree id, super;
5537 {
5538 tree raw_name = EXPR_WFL_NODE (id);
5539 tree q_name = parser_qualified_classname (id);
5540 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
5541
5542 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
5543
5544 /* Basic checks: scope, redefinition, modifiers */
5545 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
5546 return NULL_TREE;
5547
5548 /* Interface modifiers check
5549 - public/abstract allowed (already done at that point)
5550 - abstract is obsolete (comes first, it's a warning, or should be)
5551 - Can't use twice the same (checked in the modifier rule) */
5552 if ((flags & ACC_ABSTRACT) && flag_redundant)
5553 parse_warning_context
5554 (MODIFIER_WFL (ABSTRACT_TK),
5555 "Redundant use of `abstract' modifier. Interface `%s' is implicitely "
5556 "abstract", IDENTIFIER_POINTER (raw_name));
5557
5558 /* Create a new decl if DECL is NULL, otherwise fix it */
5559 decl = maybe_create_class_interface_decl (decl, q_name, id);
5560
5561 /* Set super info and mark the class a complete */
5562 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
5563 object_type_node, ctxp->interface_number);
5564 ctxp->interface_number = 0;
5565 CLASS_COMPLETE_P (decl) = 1;
5566 add_superinterfaces (decl, super);
5567
5568 return decl;
5569 }
5570
5571 /* Create an class in pass1 and return its decl. Return class
5572 interface's decl in pass 2. */
5573
5574 static tree
5575 create_class (flags, id, super, interfaces)
5576 int flags;
5577 tree id, super, interfaces;
5578 {
5579 tree raw_name = EXPR_WFL_NODE (id);
5580 tree class_id, decl;
5581 tree super_decl_type;
5582
5583 class_id = parser_qualified_classname (id);
5584 decl = IDENTIFIER_CLASS_VALUE (class_id);
5585 ctxp->current_parsed_class_un = EXPR_WFL_NODE (id);
5586 EXPR_WFL_NODE (id) = class_id;
5587
5588 /* Basic check: scope, redefinition, modifiers */
5589 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
5590 return NULL_TREE;
5591
5592 /* Class modifier check:
5593 - Allowed modifier (already done at that point)
5594 - abstract AND final forbidden
5595 - Public classes defined in the correct file */
5596 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
5597 parse_error_context (id, "Class `%s' can't be declared both abstract "
5598 "and final", IDENTIFIER_POINTER (raw_name));
5599
5600 /* Create a new decl if DECL is NULL, otherwise fix it */
5601 decl = maybe_create_class_interface_decl (decl, class_id, id);
5602
5603 /* If SUPER exists, use it, otherwise use Object */
5604 if (super)
5605 {
5606 /* Can't extend java.lang.Object */
5607 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
5608 {
5609 parse_error_context (id, "Can't extend `java.lang.Object'");
5610 return NULL_TREE;
5611 }
5612
5613 super_decl_type =
5614 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
5615 }
5616 else if (TREE_TYPE (decl) != object_type_node)
5617 super_decl_type = object_type_node;
5618 /* We're defining java.lang.Object */
5619 else
5620 super_decl_type = NULL_TREE;
5621
5622 /* Set super info and mark the class a complete */
5623 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
5624 ctxp->interface_number);
5625 ctxp->interface_number = 0;
5626 CLASS_COMPLETE_P (decl) = 1;
5627 add_superinterfaces (decl, interfaces);
5628
5629 /* If doing xref, store the location at which the inherited class
5630 (if any) was seen. */
5631 if (flag_emit_xref && super)
5632 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
5633
5634 /* Eventually sets the @deprecated tag flag */
5635 CHECK_DEPRECATED (decl);
5636
5637 return decl;
5638 }
5639
5640 /* Can't use lookup_field () since we don't want to load the class and
5641 can't set the CLASS_LOADED_P flag */
5642
5643 static tree
5644 find_field (class, name)
5645 tree class;
5646 tree name;
5647 {
5648 tree decl;
5649 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
5650 {
5651 if (DECL_NAME (decl) == name)
5652 return decl;
5653 }
5654 return NULL_TREE;
5655 }
5656
5657 /* Wrap around lookup_field that doesn't potentially upset the value
5658 of CLASS */
5659
5660 static tree
5661 lookup_field_wrapper (class, name)
5662 tree class, name;
5663 {
5664 tree type = class;
5665 tree decl;
5666 java_parser_context_save_global ();
5667 decl = lookup_field (&type, name);
5668 java_parser_context_restore_global ();
5669 return decl;
5670 }
5671
5672 /* Find duplicate field within the same class declarations and report
5673 the error. Returns 1 if a duplicated field was found, 0
5674 otherwise. */
5675
5676 static int
5677 duplicate_declaration_error_p (new_field_name, new_type, cl)
5678 tree new_field_name, new_type, cl;
5679 {
5680 /* This might be modified to work with method decl as well */
5681 tree decl = find_field (TREE_TYPE (ctxp->current_parsed_class),
5682 new_field_name);
5683 if (decl)
5684 {
5685 char *t1 = strdup (purify_type_name
5686 ((TREE_CODE (new_type) == POINTER_TYPE
5687 && TREE_TYPE (new_type) == NULL_TREE) ?
5688 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
5689 lang_printable_name (new_type, 1)));
5690 /* The type may not have been completed by the time we report
5691 the error */
5692 char *t2 = strdup (purify_type_name
5693 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
5694 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
5695 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
5696 lang_printable_name (TREE_TYPE (decl), 1)));
5697 parse_error_context
5698 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
5699 t1, IDENTIFIER_POINTER (new_field_name),
5700 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
5701 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5702 free (t1);
5703 free (t2);
5704 return 1;
5705 }
5706 return 0;
5707 }
5708
5709 /* Field registration routine. If TYPE doesn't exist, field
5710 declarations are linked to the undefined TYPE dependency list, to
5711 be later resolved in java_complete_class () */
5712
5713 static void
5714 register_fields (flags, type, variable_list)
5715 int flags;
5716 tree type, variable_list;
5717 {
5718 tree current, saved_type;
5719 tree class_type = TREE_TYPE (ctxp->current_parsed_class);
5720 int saved_lineno = lineno;
5721 int must_chain = 0;
5722 tree wfl = NULL_TREE;
5723
5724 /* If we're adding fields to interfaces, those fields are public,
5725 static, final */
5726 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
5727 {
5728 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
5729 flags, ACC_PUBLIC,
5730 "%s", "interface field(s)");
5731 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
5732 flags, ACC_STATIC,
5733 "%s", "interface field(s)");
5734 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
5735 flags, ACC_FINAL, "%s", "interface field(s)");
5736 check_modifiers ("Illegal interface member modifier `%s'", flags,
5737 INTERFACE_FIELD_MODIFIERS);
5738 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
5739 }
5740
5741 /* Obtain a suitable type for resolution, if necessary */
5742 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
5743
5744 /* If TYPE is fully resolved and we don't have a reference, make one */
5745 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5746
5747 for (current = variable_list, saved_type = type; current;
5748 current = TREE_CHAIN (current), type = saved_type)
5749 {
5750 tree real_type;
5751 tree field_decl;
5752 tree cl = TREE_PURPOSE (current);
5753 tree init = TREE_VALUE (current);
5754 tree current_name = EXPR_WFL_NODE (cl);
5755
5756 /* Process NAME, as it may specify extra dimension(s) for it */
5757 type = build_array_from_name (type, wfl, current_name, &current_name);
5758
5759 /* Type adjustment. We may have just readjusted TYPE because
5760 the variable specified more dimensions. Make sure we have
5761 a reference if we can and don't have one already. Also
5762 change the name if we have an init. */
5763 if (type != saved_type)
5764 {
5765 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5766 if (init)
5767 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
5768 }
5769
5770 real_type = GET_REAL_TYPE (type);
5771 /* Check for redeclarations */
5772 if (duplicate_declaration_error_p (current_name, real_type, cl))
5773 continue;
5774
5775 /* Set lineno to the line the field was found and create a
5776 declaration for it. Eventually sets the @deprecated tag flag. */
5777 if (flag_emit_xref)
5778 lineno = EXPR_WFL_LINECOL (cl);
5779 else
5780 lineno = EXPR_WFL_LINENO (cl);
5781 field_decl = add_field (class_type, current_name, real_type, flags);
5782 CHECK_DEPRECATED (field_decl);
5783
5784 /* Check if we must chain. */
5785 if (must_chain)
5786 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
5787
5788 /* If we have an initialization value tied to the field */
5789 if (init)
5790 {
5791 /* The field is declared static */
5792 if (flags & ACC_STATIC)
5793 {
5794 /* We include the field and its initialization part into
5795 a list used to generate <clinit>. After <clinit> is
5796 walked, field initializations will be processed and
5797 fields initialized with known constants will be taken
5798 out of <clinit> and have their DECL_INITIAL set
5799 appropriately. */
5800 TREE_CHAIN (init) = ctxp->static_initialized;
5801 ctxp->static_initialized = init;
5802 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
5803 if (TREE_OPERAND (init, 1)
5804 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
5805 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
5806 }
5807 /* A non-static field declared with an immediate initialization is
5808 to be initialized in <init>, if any. This field is remembered
5809 to be processed at the time of the generation of <init>. */
5810 else
5811 {
5812 TREE_CHAIN (init) = ctxp->non_static_initialized;
5813 ctxp->non_static_initialized = init;
5814 }
5815 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
5816 }
5817 }
5818 lineno = saved_lineno;
5819 }
5820
5821 /* Generate the method $finit$ that initializes fields initialized
5822 upon declaration. */
5823
5824 static void
5825 maybe_generate_finit ()
5826 {
5827 tree mdecl, current;
5828
5829 if (!ctxp->non_static_initialized || java_error_count)
5830 return;
5831
5832 mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5833 ACC_PRIVATE, void_type_node,
5834 finit_identifier_node, end_params_node);
5835 start_artificial_method_body (mdecl);
5836
5837 ctxp->non_static_initialized = nreverse (ctxp->non_static_initialized);
5838 for (current = ctxp->non_static_initialized; current;
5839 current = TREE_CHAIN (current))
5840 java_method_add_stmt (mdecl,
5841 build_debugable_stmt (EXPR_WFL_LINECOL (current),
5842 current));
5843
5844 end_artificial_method_body (mdecl);
5845 CLASS_HAS_FINIT_P (TREE_TYPE (ctxp->current_parsed_class)) = 1;
5846 ctxp->non_static_initialized = NULL_TREE;
5847 }
5848
5849 /* Check whether it is necessary to generate a <clinit> for the class
5850 we just parsed. */
5851
5852 static void
5853 maybe_generate_clinit ()
5854 {
5855 tree mdecl, c;
5856
5857 if (!ctxp->static_initialized || java_error_count)
5858 return;
5859
5860 mdecl = create_artificial_method (TREE_TYPE (ctxp->current_parsed_class),
5861 ACC_STATIC, void_type_node,
5862 clinit_identifier_node, end_params_node);
5863 start_artificial_method_body (mdecl);
5864
5865 /* Keep initialization in order to enforce 8.5 */
5866 ctxp->static_initialized = nreverse (ctxp->static_initialized);
5867
5868 /* We process the list of assignment we produced as the result of
5869 the declaration of initialized static field and add them as
5870 statement to the <clinit> method. */
5871 for (c = ctxp->static_initialized; c; c = TREE_CHAIN (c))
5872 {
5873 /* We build the assignment expression that will initialize the
5874 field to its value. There are strict rules on static
5875 initializers (8.5). FIXME */
5876 java_method_add_stmt (mdecl,
5877 build_debugable_stmt (EXPR_WFL_LINECOL (c), c));
5878 }
5879
5880 end_artificial_method_body (mdecl);
5881 ctxp->static_initialized = NULL_TREE;
5882 }
5883
5884 /* Shared accros method_declarator and method_header to remember the
5885 patch stage that was reached during the declaration of the method.
5886 A method DECL is built differently is there is no patch
5887 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
5888 pending on the currently defined method. */
5889
5890 static int patch_stage;
5891
5892 /* Check the method declaration and add the method to its current
5893 class. If the argument list is known to contain incomplete types,
5894 the method is partially added and the registration will be resume
5895 once the method arguments resolved. If TYPE is NULL, we're dealing
5896 with a constructor. */
5897
5898 static tree
5899 method_header (flags, type, mdecl, throws)
5900 int flags;
5901 tree type, mdecl, throws;
5902 {
5903 tree meth = TREE_VALUE (mdecl);
5904 tree id = TREE_PURPOSE (mdecl);
5905 tree this_class = TREE_TYPE (ctxp->current_parsed_class);
5906 tree type_wfl = NULL_TREE;
5907 tree meth_name = NULL_TREE, current, orig_arg;
5908 int saved_lineno;
5909 int constructor_ok = 0, must_chain;
5910
5911 check_modifiers_consistency (flags);
5912
5913 /* There are some forbidden modifiers for an abstract method and its
5914 class must be abstract as well. */
5915 if (type && (flags & ACC_ABSTRACT))
5916 {
5917 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
5918 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
5919 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
5920 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
5921 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
5922 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
5923 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
5924 parse_error_context
5925 (id, "Class `%s' must be declared abstract to define abstract "
5926 "method `%s'",
5927 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
5928 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
5929 }
5930 /* Things to be checked when declaring a constructor */
5931 if (!type)
5932 {
5933 int ec = java_error_count;
5934 /* 8.6: Constructor declarations: we might be trying to define a
5935 method without specifying a return type. */
5936 if (EXPR_WFL_NODE (id) != ctxp->current_parsed_class_un)
5937 parse_error_context
5938 (id, "Invalid method declaration, return type required");
5939 /* 8.6.3: Constructor modifiers */
5940 else
5941 {
5942 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
5943 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
5944 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
5945 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
5946 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
5947 }
5948 /* If we found error here, we don't consider it's OK to tread
5949 the method definition as a constructor, for the rest of this
5950 function */
5951 if (ec == java_error_count)
5952 constructor_ok = 1;
5953 }
5954
5955 /* Method declared within the scope of an interface are implicitly
5956 abstract and public. Conflicts with other erroneously provided
5957 modifiers are checked right after. */
5958
5959 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
5960 {
5961 /* If FLAGS isn't set because of a modifier, turn the
5962 corresponding modifier WFL to NULL so we issue a warning on
5963 the obsolete use of the modifier */
5964 if (!(flags & ACC_PUBLIC))
5965 MODIFIER_WFL (PUBLIC_TK) = NULL;
5966 if (!(flags & ACC_ABSTRACT))
5967 MODIFIER_WFL (ABSTRACT_TK) = NULL;
5968 flags |= ACC_PUBLIC;
5969 flags |= ACC_ABSTRACT;
5970 }
5971
5972 /* Modifiers context reset moved up, so abstract method declaration
5973 modifiers can be later checked. */
5974
5975 /* Set constructor returned type to void and method name to <init>,
5976 unless we found an error identifier the constructor (in which
5977 case we retain the original name) */
5978 if (!type)
5979 {
5980 type = void_type_node;
5981 if (constructor_ok)
5982 meth_name = init_identifier_node;
5983 }
5984 else
5985 meth_name = EXPR_WFL_NODE (id);
5986
5987 /* Do the returned type resolution and registration if necessary */
5988 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
5989
5990 if (meth_name)
5991 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
5992 EXPR_WFL_NODE (id) = meth_name;
5993 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
5994
5995 if (must_chain)
5996 {
5997 patch_stage = JDEP_METHOD_RETURN;
5998 register_incomplete_type (patch_stage, type_wfl, id, type);
5999 TREE_TYPE (meth) = GET_REAL_TYPE (type);
6000 }
6001 else
6002 TREE_TYPE (meth) = type;
6003
6004 saved_lineno = lineno;
6005 /* When defining an abstract or interface method, the curly
6006 bracket at level 1 doesn't exist because there is no function
6007 body */
6008 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
6009 EXPR_WFL_LINENO (id));
6010
6011 /* Remember the original argument list */
6012 orig_arg = TYPE_ARG_TYPES (meth);
6013
6014 if (patch_stage) /* includes ret type and/or all args */
6015 {
6016 jdep *jdep;
6017 meth = add_method_1 (this_class, flags, meth_name, meth);
6018 /* Patch for the return type */
6019 if (patch_stage == JDEP_METHOD_RETURN)
6020 {
6021 jdep = CLASSD_LAST (ctxp->classd_list);
6022 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
6023 }
6024 /* This is the stop JDEP. METH allows the function's signature
6025 to be computed. */
6026 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
6027 }
6028 else
6029 meth = add_method (this_class, flags, meth_name,
6030 build_java_signature (meth));
6031
6032 /* Fix the method argument list so we have the argument name
6033 information */
6034 fix_method_argument_names (orig_arg, meth);
6035
6036 /* Register the parameter number and re-install the current line
6037 number */
6038 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
6039 lineno = saved_lineno;
6040
6041 /* Register exception specified by the `throws' keyword for
6042 resolution and set the method decl appropriate field to the list.
6043 Note: the grammar ensures that what we get here are class
6044 types. */
6045 if (throws)
6046 {
6047 throws = nreverse (throws);
6048 for (current = throws; current; current = TREE_CHAIN (current))
6049 {
6050 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
6051 NULL_TREE, NULL_TREE);
6052 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
6053 &TREE_VALUE (current);
6054 }
6055 DECL_FUNCTION_THROWS (meth) = throws;
6056 }
6057
6058 /* We set the DECL_NAME to ID so we can track the location where
6059 the function was declared. This allow us to report
6060 redefinition error accurately. When method are verified,
6061 DECL_NAME is reinstalled properly (using the content of the
6062 WFL node ID) (see check_method_redefinition). We don't do that
6063 when Object is being defined. Constructor <init> names will be
6064 reinstalled the same way. */
6065 if (TREE_TYPE (ctxp->current_parsed_class) != object_type_node)
6066 DECL_NAME (meth) = id;
6067
6068 /* Set the flag if we correctly processed a constructor */
6069 if (constructor_ok)
6070 DECL_CONSTRUCTOR_P (meth) = 1;
6071
6072 /* Eventually set the @deprecated tag flag */
6073 CHECK_DEPRECATED (meth);
6074
6075 /* If doing xref, store column and line number information instead
6076 of the line number only. */
6077 if (flag_emit_xref)
6078 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
6079
6080 return meth;
6081 }
6082
6083 static void
6084 fix_method_argument_names (orig_arg, meth)
6085 tree orig_arg, meth;
6086 {
6087 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
6088 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
6089 {
6090 TREE_PURPOSE (arg) = this_identifier_node;
6091 arg = TREE_CHAIN (arg);
6092 }
6093 while (orig_arg != end_params_node)
6094 {
6095 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
6096 orig_arg = TREE_CHAIN (orig_arg);
6097 arg = TREE_CHAIN (arg);
6098 }
6099 }
6100
6101 /* Complete the method declaration with METHOD_BODY. */
6102
6103 static void
6104 finish_method_declaration (method_body)
6105 tree method_body;
6106 {
6107 int flags = get_access_flags_from_decl (current_function_decl);
6108
6109 /* 8.4.5 Method Body */
6110 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
6111 {
6112 tree wfl = DECL_NAME (current_function_decl);
6113 parse_error_context (wfl,
6114 "%s method `%s' can't have a body defined",
6115 (METHOD_NATIVE (current_function_decl) ?
6116 "Native" : "Abstract"),
6117 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6118 method_body = NULL_TREE;
6119 }
6120 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
6121 {
6122 tree wfl = DECL_NAME (current_function_decl);
6123 parse_error_context (wfl,
6124 "Non native and non abstract method `%s' must "
6125 "have a body defined",
6126 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
6127 method_body = NULL_TREE;
6128 }
6129
6130 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
6131 maybe_absorb_scoping_blocks ();
6132 /* Exit function's body */
6133 exit_block ();
6134 /* Merge last line of the function with first line, directly in the
6135 function decl. It will be used to emit correct debug info. */
6136 if (!flag_emit_xref)
6137 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
6138 /* So we don't have an irrelevant function declaration context for
6139 the next static block we'll see. */
6140 current_function_decl = NULL_TREE;
6141 }
6142
6143 /* Build a an error message for constructor circularity errors. */
6144
6145 static char *
6146 constructor_circularity_msg (from, to)
6147 tree from, to;
6148 {
6149 static char string [4096];
6150 char *t = strdup (lang_printable_name (from, 0));
6151 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
6152 free (t);
6153 return string;
6154 }
6155
6156 /* Verify a circular call to METH. Return 1 if an error is found, 0
6157 otherwise. */
6158
6159 static int
6160 verify_constructor_circularity (meth, current)
6161 tree meth, current;
6162 {
6163 static tree list = NULL_TREE;
6164 tree c;
6165 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6166 {
6167 if (TREE_VALUE (c) == meth)
6168 {
6169 char *t;
6170 if (list)
6171 {
6172 tree liste;
6173 list = nreverse (list);
6174 for (liste = list; liste; liste = TREE_CHAIN (liste))
6175 {
6176 parse_error_context
6177 (TREE_PURPOSE (TREE_PURPOSE (liste)),
6178 constructor_circularity_msg
6179 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
6180 java_error_count--;
6181 }
6182 }
6183 t = strdup (lang_printable_name (meth, 0));
6184 parse_error_context (TREE_PURPOSE (c),
6185 "%s: recursive invocation of constructor `%s'",
6186 constructor_circularity_msg (current, meth), t);
6187 free (t);
6188 list = NULL_TREE;
6189 return 1;
6190 }
6191 }
6192 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
6193 {
6194 list = tree_cons (c, current, list);
6195 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
6196 return 1;
6197 list = TREE_CHAIN (list);
6198 }
6199 return 0;
6200 }
6201
6202 /* Check modifiers that can be declared but exclusively */
6203
6204 static void
6205 check_modifiers_consistency (flags)
6206 int flags;
6207 {
6208 int acc_count = 0;
6209 tree cl = NULL_TREE;
6210
6211 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, 0, acc_count, cl);
6212 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, 1, acc_count, cl);
6213 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, 2, acc_count, cl);
6214 if (acc_count > 1)
6215 parse_error_context
6216 (cl, "Inconsistent member declaration. At most one of `public', "
6217 "`private', or `protected' may be specified");
6218 }
6219
6220 /* Check the methode header METH for abstract specifics features */
6221
6222 static void
6223 check_abstract_method_header (meth)
6224 tree meth;
6225 {
6226 int flags = get_access_flags_from_decl (meth);
6227 /* DECL_NAME might still be a WFL node */
6228 tree name = GET_METHOD_NAME (meth);
6229
6230 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (ABSTRACT_TK), flags,
6231 ACC_ABSTRACT, "abstract method `%s'",
6232 IDENTIFIER_POINTER (name));
6233 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK), flags,
6234 ACC_PUBLIC, "abstract method `%s'",
6235 IDENTIFIER_POINTER (name));
6236
6237 check_modifiers ("Illegal modifier `%s' for interface method",
6238 flags, INTERFACE_METHOD_MODIFIERS);
6239 }
6240
6241 /* Create a FUNCTION_TYPE node and start augmenting it with the
6242 declared function arguments. Arguments type that can't be resolved
6243 are left as they are, but the returned node is marked as containing
6244 incomplete types. */
6245
6246 static tree
6247 method_declarator (id, list)
6248 tree id, list;
6249 {
6250 tree arg_types = NULL_TREE, current, node;
6251 tree meth = make_node (FUNCTION_TYPE);
6252 jdep *jdep;
6253
6254 patch_stage = JDEP_NO_PATCH;
6255
6256 for (current = list; current; current = TREE_CHAIN (current))
6257 {
6258 int must_chain = 0;
6259 tree wfl_name = TREE_PURPOSE (current);
6260 tree type = TREE_VALUE (current);
6261 tree name = EXPR_WFL_NODE (wfl_name);
6262 tree already, arg_node;
6263 tree type_wfl = NULL_TREE;
6264 tree real_type;
6265
6266 /* Obtain a suitable type for resolution, if necessary */
6267 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
6268
6269 /* Process NAME, as it may specify extra dimension(s) for it */
6270 type = build_array_from_name (type, type_wfl, name, &name);
6271 EXPR_WFL_NODE (wfl_name) = name;
6272
6273 real_type = GET_REAL_TYPE (type);
6274 if (TREE_CODE (real_type) == RECORD_TYPE)
6275 {
6276 real_type = promote_type (real_type);
6277 if (TREE_CODE (type) == TREE_LIST)
6278 TREE_PURPOSE (type) = real_type;
6279 }
6280
6281 /* Check redefinition */
6282 for (already = arg_types; already; already = TREE_CHAIN (already))
6283 if (TREE_PURPOSE (already) == name)
6284 {
6285 parse_error_context
6286 (wfl_name, "Variable `%s' is used more than once in the "
6287 "argument list of method `%s'", IDENTIFIER_POINTER (name),
6288 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6289 break;
6290 }
6291
6292 /* If we've an incomplete argument type, we know there is a location
6293 to patch when the type get resolved, later. */
6294 jdep = NULL;
6295 if (must_chain)
6296 {
6297 patch_stage = JDEP_METHOD;
6298 type = register_incomplete_type (patch_stage,
6299 type_wfl, wfl_name, type);
6300 jdep = CLASSD_LAST (ctxp->classd_list);
6301 JDEP_MISC (jdep) = id;
6302 }
6303
6304 /* The argument node: a name and a (possibly) incomplete type */
6305 arg_node = build_tree_list (name, real_type);
6306 if (jdep)
6307 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
6308 TREE_CHAIN (arg_node) = arg_types;
6309 arg_types = arg_node;
6310 }
6311 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
6312 node = build_tree_list (id, meth);
6313 return node;
6314 }
6315
6316 static int
6317 unresolved_type_p (wfl, returned)
6318 tree wfl;
6319 tree *returned;
6320
6321 {
6322 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
6323 {
6324 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
6325 if (returned)
6326 *returned = (decl ? TREE_TYPE (decl) : NULL_TREE);
6327 return 1;
6328 }
6329 if (returned)
6330 *returned = wfl;
6331 return 0;
6332 }
6333
6334 /* From NAME, build a qualified identifier node using the
6335 qualification from the current package definition. */
6336
6337 static tree
6338 parser_qualified_classname (name)
6339 tree name;
6340 {
6341 if (ctxp->package)
6342 return merge_qualified_name (ctxp->package, EXPR_WFL_NODE (name));
6343 else
6344 return EXPR_WFL_NODE (name);
6345 }
6346
6347 /* Called once the type a interface extends is resolved. Returns 0 if
6348 everything is OK. */
6349
6350 static int
6351 parser_check_super_interface (super_decl, this_decl, this_wfl)
6352 tree super_decl, this_decl, this_wfl;
6353 {
6354 tree super_type = TREE_TYPE (super_decl);
6355
6356 /* Has to be an interface */
6357 if (!CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (super_decl))))
6358 {
6359 parse_error_context
6360 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
6361 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
6362 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
6363 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
6364 "interface" : "class"),
6365 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
6366 return 1;
6367 }
6368
6369 /* Check scope: same package OK, other package: OK if public */
6370 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
6371 return 1;
6372
6373 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
6374 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6375 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6376 return 0;
6377 }
6378
6379 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
6380 0 if everthing is OK. */
6381
6382 static int
6383 parser_check_super (super_decl, this_decl, wfl)
6384 tree super_decl, this_decl, wfl;
6385 {
6386 tree super_type = TREE_TYPE (super_decl);
6387
6388 /* SUPER should be a CLASS (neither an array nor an interface) */
6389 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
6390 {
6391 parse_error_context
6392 (wfl, "Class `%s' can't subclass %s `%s'",
6393 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6394 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
6395 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6396 return 1;
6397 }
6398
6399 if (CLASS_FINAL (TYPE_NAME (super_type)))
6400 {
6401 parse_error_context (wfl, "Can't subclass final classes: %s",
6402 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
6403 return 1;
6404 }
6405
6406 /* Check scope: same package OK, other package: OK if public */
6407 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
6408 return 1;
6409
6410 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
6411 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
6412 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
6413 return 0;
6414 }
6415
6416 /* Create a new dependency list and link it (in a LIFO manner) to the
6417 CTXP list of type dependency list. */
6418
6419 static void
6420 create_jdep_list (ctxp)
6421 struct parser_ctxt *ctxp;
6422 {
6423 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
6424 new->first = new->last = NULL;
6425 new->next = ctxp->classd_list;
6426 ctxp->classd_list = new;
6427 }
6428
6429 static jdeplist *
6430 reverse_jdep_list (ctxp)
6431 struct parser_ctxt *ctxp;
6432 {
6433 register jdeplist *prev = NULL, *current, *next;
6434 for (current = ctxp->classd_list; current; current = next)
6435 {
6436 next = current->next;
6437 current->next = prev;
6438 prev = current;
6439 }
6440 return prev;
6441 }
6442
6443 /* Create a fake pointer based on the ID stored in
6444 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
6445 registered again. */
6446
6447 static tree
6448 obtain_incomplete_type (type_name)
6449 tree type_name;
6450 {
6451 tree ptr, name;
6452
6453 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
6454 name = EXPR_WFL_NODE (type_name);
6455 else if (INCOMPLETE_TYPE_P (type_name))
6456 name = TYPE_NAME (type_name);
6457 else
6458 fatal ("invalid type name - obtain_incomplete_type");
6459
6460 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
6461 if (TYPE_NAME (ptr) == name)
6462 break;
6463
6464 if (!ptr)
6465 {
6466 push_obstacks (&permanent_obstack, &permanent_obstack);
6467 BUILD_PTR_FROM_NAME (ptr, name);
6468 layout_type (ptr);
6469 pop_obstacks ();
6470 TREE_CHAIN (ptr) = ctxp->incomplete_class;
6471 ctxp->incomplete_class = ptr;
6472 }
6473
6474 return ptr;
6475 }
6476
6477 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
6478 non NULL instead of computing a new fake type based on WFL. The new
6479 dependency is inserted in the current type dependency list, in FIFO
6480 manner. */
6481
6482 static tree
6483 register_incomplete_type (kind, wfl, decl, ptr)
6484 int kind;
6485 tree wfl, decl, ptr;
6486 {
6487 jdep *new = (jdep *)xmalloc (sizeof (jdep));
6488
6489 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
6490 ptr = obtain_incomplete_type (wfl);
6491
6492 JDEP_KIND (new) = kind;
6493 JDEP_DECL (new) = decl;
6494 JDEP_SOLV (new) = ptr;
6495 JDEP_WFL (new) = wfl;
6496 JDEP_CHAIN (new) = NULL;
6497 JDEP_MISC (new) = NULL_TREE;
6498 JDEP_GET_PATCH (new) = (tree *)NULL;
6499
6500 JDEP_INSERT (ctxp->classd_list, new);
6501
6502 return ptr;
6503 }
6504
6505 void
6506 java_check_circular_reference ()
6507 {
6508 tree current;
6509 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
6510 {
6511 tree type = TREE_TYPE (current);
6512 if (CLASS_INTERFACE (TYPE_NAME (type)))
6513 {
6514 /* Check all interfaces this class extends */
6515 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
6516 int n, i;
6517
6518 if (!basetype_vec)
6519 return;
6520 n = TREE_VEC_LENGTH (basetype_vec);
6521 for (i = 0; i < n; i++)
6522 {
6523 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
6524 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
6525 && interface_of_p (type, BINFO_TYPE (vec_elt)))
6526 parse_error_context (lookup_cl (current),
6527 "Cyclic interface inheritance");
6528 }
6529 }
6530 else
6531 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
6532 parse_error_context (lookup_cl (current),
6533 "Cyclic class inheritance");
6534 }
6535 }
6536
6537 /* safe_layout_class just makes sure that we can load a class without
6538 disrupting the current_class, input_file, lineno, etc, information
6539 about the class processed currently. */
6540
6541 void
6542 safe_layout_class (class)
6543 tree class;
6544 {
6545 tree save_current_class = current_class;
6546 char *save_input_filename = input_filename;
6547 int save_lineno = lineno;
6548
6549 push_obstacks (&permanent_obstack, &permanent_obstack);
6550
6551 layout_class (class);
6552 pop_obstacks ();
6553
6554 current_class = save_current_class;
6555 input_filename = save_input_filename;
6556 lineno = save_lineno;
6557 CLASS_LOADED_P (class) = 1;
6558 }
6559
6560 static tree
6561 jdep_resolve_class (dep)
6562 jdep *dep;
6563 {
6564 tree decl;
6565
6566 if (JDEP_RESOLVED_P (dep))
6567 decl = JDEP_RESOLVED_DECL (dep);
6568 else
6569 {
6570 decl = resolve_class (JDEP_TO_RESOLVE (dep),
6571 JDEP_DECL (dep), JDEP_WFL (dep));
6572 JDEP_RESOLVED (dep, decl);
6573 }
6574
6575 if (!decl)
6576 complete_class_report_errors (dep);
6577
6578 return decl;
6579 }
6580
6581 /* Complete unsatisfied class declaration and their dependencies */
6582
6583 void
6584 java_complete_class ()
6585 {
6586 tree cclass;
6587 jdeplist *cclassd;
6588 int error_found;
6589 tree type;
6590
6591 push_obstacks (&permanent_obstack, &permanent_obstack);
6592
6593 /* Process imports and reverse the import on demand list */
6594 process_imports ();
6595 if (ctxp->import_demand_list)
6596 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
6597
6598 /* Rever things so we have the right order */
6599 ctxp->class_list = nreverse (ctxp->class_list);
6600 ctxp->classd_list = reverse_jdep_list (ctxp);
6601
6602 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
6603 cclass && cclassd;
6604 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
6605 {
6606 jdep *dep;
6607 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
6608 {
6609 tree decl;
6610 if (!(decl = jdep_resolve_class (dep)))
6611 continue;
6612
6613 /* Now it's time to patch */
6614 switch (JDEP_KIND (dep))
6615 {
6616 case JDEP_SUPER:
6617 /* Simply patch super */
6618 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
6619 continue;
6620 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
6621 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
6622 break;
6623
6624 case JDEP_FIELD:
6625 {
6626 /* We do part of the job done in add_field */
6627 tree field_decl = JDEP_DECL (dep);
6628 tree field_type = TREE_TYPE (decl);
6629 push_obstacks (&permanent_obstack, &permanent_obstack);
6630 if (TREE_CODE (field_type) == RECORD_TYPE)
6631 field_type = promote_type (field_type);
6632 pop_obstacks ();
6633 TREE_TYPE (field_decl) = field_type;
6634 DECL_ALIGN (field_decl) = 0;
6635 layout_decl (field_decl, 0);
6636 SOURCE_FRONTEND_DEBUG
6637 (("Completed field/var decl `%s' with `%s'",
6638 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
6639 IDENTIFIER_POINTER (DECL_NAME (decl))));
6640 break;
6641 }
6642 case JDEP_METHOD: /* We start patching a method */
6643 case JDEP_METHOD_RETURN:
6644 error_found = 0;
6645 while (1)
6646 {
6647 if (decl)
6648 {
6649 type = TREE_TYPE(decl);
6650 if (TREE_CODE (type) == RECORD_TYPE)
6651 type = promote_type (type);
6652 JDEP_APPLY_PATCH (dep, type);
6653 SOURCE_FRONTEND_DEBUG
6654 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
6655 "Completing fct `%s' with ret type `%s'":
6656 "Completing arg `%s' with type `%s'"),
6657 IDENTIFIER_POINTER (EXPR_WFL_NODE
6658 (JDEP_DECL_WFL (dep))),
6659 IDENTIFIER_POINTER (DECL_NAME (decl))));
6660 }
6661 else
6662 error_found = 1;
6663 dep = JDEP_CHAIN (dep);
6664 if (JDEP_KIND (dep) == JDEP_METHOD_END)
6665 break;
6666 else
6667 decl = jdep_resolve_class (dep);
6668 }
6669 if (!error_found)
6670 {
6671 tree mdecl = JDEP_DECL (dep), signature;
6672 push_obstacks (&permanent_obstack, &permanent_obstack);
6673 /* Recompute and reset the signature */
6674 signature = build_java_signature (TREE_TYPE (mdecl));
6675 set_java_signature (TREE_TYPE (mdecl), signature);
6676 pop_obstacks ();
6677 }
6678 else
6679 continue;
6680 break;
6681
6682 case JDEP_INTERFACE:
6683 if (parser_check_super_interface (decl, JDEP_DECL (dep),
6684 JDEP_WFL (dep)))
6685 continue;
6686 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
6687 break;
6688
6689 case JDEP_PARM:
6690 case JDEP_VARIABLE:
6691 type = TREE_TYPE(decl);
6692 if (TREE_CODE (type) == RECORD_TYPE)
6693 type = promote_type (type);
6694 JDEP_APPLY_PATCH (dep, type);
6695 break;
6696
6697 case JDEP_TYPE:
6698 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6699 SOURCE_FRONTEND_DEBUG
6700 (("Completing a random type dependency on a '%s' node",
6701 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
6702 break;
6703
6704 case JDEP_EXCEPTION:
6705 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
6706 SOURCE_FRONTEND_DEBUG
6707 (("Completing `%s' `throws' argument node",
6708 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
6709 break;
6710
6711 default:
6712 fatal ("Can't handle patch code %d - java_complete_class",
6713 JDEP_KIND (dep));
6714 }
6715 }
6716 }
6717 pop_obstacks ();
6718 return;
6719 }
6720
6721 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
6722 array. */
6723
6724 static tree
6725 resolve_class (class_type, decl, cl)
6726 tree class_type, decl, cl;
6727 {
6728 char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
6729 char *base = name;
6730 tree resolved_type = TREE_TYPE (class_type);
6731 tree resolved_type_decl;
6732
6733 if (resolved_type != NULL_TREE)
6734 {
6735 tree resolved_type_decl = TYPE_NAME (resolved_type);
6736 if (resolved_type_decl == NULL_TREE
6737 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
6738 {
6739 resolved_type_decl = build_decl (TYPE_DECL,
6740 TYPE_NAME (class_type),
6741 resolved_type);
6742 }
6743 return resolved_type_decl;
6744 }
6745
6746 /* 1- Check to see if we have an array. If true, find what we really
6747 want to resolve */
6748 while (name[0] == '[')
6749 name++;
6750 if (base != name)
6751 TYPE_NAME (class_type) = get_identifier (name);
6752
6753 /* 2- Resolve the bare type */
6754 if (!(resolved_type_decl = do_resolve_class (class_type, decl, cl)))
6755 return NULL_TREE;
6756 resolved_type = TREE_TYPE (resolved_type_decl);
6757
6758 /* 3- If we have and array, reconstruct the array down to its nesting */
6759 if (base != name)
6760 {
6761 while (base != name)
6762 {
6763 if (TREE_CODE (resolved_type) == RECORD_TYPE)
6764 resolved_type = promote_type (resolved_type);
6765 resolved_type = build_java_array_type (resolved_type, -1);
6766 CLASS_LOADED_P (resolved_type) = 1;
6767 name--;
6768 }
6769 /* Build a fake decl for this, since this is what is expected to
6770 be returned. */
6771 resolved_type_decl =
6772 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
6773 /* Figure how those two things are important for error report. FIXME */
6774 DECL_SOURCE_LINE (resolved_type_decl) = 0;
6775 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
6776 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
6777 }
6778 TREE_TYPE (class_type) = resolved_type;
6779 return resolved_type_decl;
6780 }
6781
6782 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
6783 are used to report error messages. */
6784
6785 tree
6786 do_resolve_class (class_type, decl, cl)
6787 tree class_type;
6788 tree decl;
6789 tree cl;
6790 {
6791 tree new_class_decl;
6792 tree original_name = NULL_TREE;
6793
6794 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
6795 its is changed by find_in_imports{_on_demand} */
6796
6797 /* 1- Check for the type in single imports */
6798 if (find_in_imports (class_type))
6799 return NULL_TREE;
6800
6801 /* 2- And check for the type in the current compilation unit. If it fails,
6802 try with a name qualified with the package name if appropriate. */
6803 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6804 {
6805 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6806 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6807 load_class (TYPE_NAME (class_type), 0);
6808 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6809 }
6810
6811 original_name = TYPE_NAME (class_type);
6812 if (!QUALIFIED_P (TYPE_NAME (class_type)) && ctxp->package)
6813 TYPE_NAME (class_type) = merge_qualified_name (ctxp->package,
6814 TYPE_NAME (class_type));
6815 #if 1
6816 if (!(new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6817 load_class (TYPE_NAME (class_type), 0);
6818 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6819 {
6820 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6821 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6822 load_class (TYPE_NAME (class_type), 0);
6823 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6824 }
6825 #else
6826 new_name = TYPE_NAME (class_type);
6827 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_name)) != NULL_TREE)
6828 {
6829 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
6830 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
6831 load_class (new_name, 0);
6832 return IDENTIFIER_CLASS_VALUE (new_name);
6833 }
6834 else
6835 {
6836 tree class = read_class (new_name);
6837 if (class != NULL_TREE)
6838 {
6839 tree decl = IDENTIFIER_CLASS_VALUE (new_name);
6840 if (decl == NULL_TREE)
6841 decl = push_class (class, new_name);
6842 return decl;
6843 }
6844 }
6845 #endif
6846 TYPE_NAME (class_type) = original_name;
6847
6848 /* 3- Check an other compilation unit that bears the name of type */
6849 load_class (TYPE_NAME (class_type), 0);
6850 if (check_pkg_class_access (TYPE_NAME (class_type),
6851 (cl ? cl : lookup_cl (decl))))
6852 return NULL_TREE;
6853
6854 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
6855 return new_class_decl;
6856
6857 /* 4- Check the import on demands. Don't allow bar.baz to be
6858 imported from foo.* */
6859 if (!QUALIFIED_P (TYPE_NAME (class_type)))
6860 if (find_in_imports_on_demand (class_type))
6861 return NULL_TREE;
6862
6863 /* 5- Last call for a resolution */
6864 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
6865 }
6866
6867 /* Resolve NAME and lay it out (if not done and if not the current
6868 parsed class). Return a decl node. This function is meant to be
6869 called when type resolution is necessary during the walk pass. */
6870
6871 static tree
6872 resolve_and_layout (something, cl)
6873 tree something;
6874 tree cl;
6875 {
6876 tree decl;
6877
6878 /* Don't do that on the current class */
6879 if (something == current_class)
6880 return TYPE_NAME (current_class);
6881
6882 /* Don't do anything for void and other primitive types */
6883 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6884 return NULL_TREE;
6885
6886 /* Pointer types can be reall pointer types or fake pointers. When
6887 finding a real pointer, recheck for primitive types */
6888 if (TREE_CODE (something) == POINTER_TYPE)
6889 {
6890 if (TREE_TYPE (something))
6891 {
6892 something = TREE_TYPE (something);
6893 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
6894 return NULL_TREE;
6895 }
6896 else
6897 something = TYPE_NAME (something);
6898 }
6899
6900 /* Don't do anything for arrays of primitive types */
6901 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
6902 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
6903 return NULL_TREE;
6904
6905 /* If something is not and IDENTIFIER_NODE, it can be a a TYPE_DECL
6906 or a real TYPE */
6907 if (TREE_CODE (something) != IDENTIFIER_NODE)
6908 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
6909 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
6910
6911 if (!(decl = resolve_no_layout (something, cl)))
6912 return NULL_TREE;
6913
6914 /* Resolve and layout if necessary */
6915 layout_class_methods (TREE_TYPE (decl));
6916 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)))
6917 CHECK_METHODS (decl);
6918 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
6919 safe_layout_class (TREE_TYPE (decl));
6920
6921 return decl;
6922 }
6923
6924 /* Resolve a class, returns its decl but doesn't perform any
6925 layout. The current parsing context is saved and restored */
6926
6927 static tree
6928 resolve_no_layout (name, cl)
6929 tree name, cl;
6930 {
6931 tree ptr, decl;
6932 BUILD_PTR_FROM_NAME (ptr, name);
6933 java_parser_context_save_global ();
6934 decl = resolve_class (ptr, NULL_TREE, cl);
6935 java_parser_context_restore_global ();
6936
6937 return decl;
6938 }
6939
6940 /* Called when reporting errors. Skip leader '[' in a complex array
6941 type description that failed to be resolved. */
6942
6943 static char *
6944 purify_type_name (name)
6945 char *name;
6946 {
6947 while (*name && *name == '[')
6948 name++;
6949 return name;
6950 }
6951
6952 /* The type CURRENT refers to can't be found. We print error messages. */
6953
6954 static void
6955 complete_class_report_errors (dep)
6956 jdep *dep;
6957 {
6958 char *name;
6959
6960 if (!JDEP_WFL (dep))
6961 return;
6962
6963 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
6964 switch (JDEP_KIND (dep))
6965 {
6966 case JDEP_SUPER:
6967 parse_error_context
6968 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
6969 purify_type_name (name),
6970 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6971 break;
6972 case JDEP_FIELD:
6973 parse_error_context
6974 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
6975 purify_type_name (name),
6976 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6977 break;
6978 case JDEP_METHOD: /* Covers arguments */
6979 parse_error_context
6980 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6981 "argument `%s' of method `%s'",
6982 purify_type_name (name),
6983 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
6984 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
6985 break;
6986 case JDEP_METHOD_RETURN: /* Covers return type */
6987 parse_error_context
6988 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
6989 "return type of method `%s'",
6990 purify_type_name (name),
6991 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
6992 break;
6993 case JDEP_INTERFACE:
6994 parse_error_context
6995 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
6996 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
6997 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
6998 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
6999 break;
7000 case JDEP_VARIABLE:
7001 parse_error_context
7002 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the "
7003 "local variable `%s'",
7004 purify_type_name (IDENTIFIER_POINTER
7005 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
7006 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
7007 break;
7008 case JDEP_EXCEPTION: /* As specified by `throws' */
7009 parse_error_context
7010 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
7011 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
7012 break;
7013 default:
7014 /* Fix for -Wall. Just break doing nothing. The error will be
7015 caught later */
7016 break;
7017 }
7018 }
7019
7020 /* Check uninitialized final. */
7021
7022 void
7023 java_check_final ()
7024 {
7025 }
7026
7027 /* Return a static string containing the DECL prototype string. If
7028 DECL is a constructor, use the class name instead of the form
7029 <init> */
7030
7031 static char *
7032 get_printable_method_name (decl)
7033 tree decl;
7034 {
7035 char *to_return;
7036 tree name = NULL_TREE;
7037
7038 if (DECL_CONSTRUCTOR_P (decl))
7039 {
7040 name = DECL_NAME (decl);
7041 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
7042 }
7043
7044 to_return = lang_printable_name (decl, 0);
7045 if (DECL_CONSTRUCTOR_P (decl))
7046 DECL_NAME (decl) = name;
7047
7048 return to_return;
7049 }
7050
7051 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
7052 nevertheless needs to be verfied, 1 otherwise. */
7053
7054 static int
7055 reset_method_name (method)
7056 tree method;
7057 {
7058 if (!IS_CLINIT (method) && DECL_NAME (method) != finit_identifier_node)
7059 {
7060 /* NAME is just the plain name when Object is being defined */
7061 if (DECL_CONTEXT (method) != object_type_node)
7062 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
7063 init_identifier_node : GET_METHOD_NAME (method));
7064 return 0;
7065 }
7066 else
7067 return 1;
7068 }
7069
7070 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
7071
7072 tree
7073 java_get_real_method_name (method_decl)
7074 tree method_decl;
7075 {
7076 tree method_name = DECL_NAME (method_decl);
7077 if (DECL_CONSTRUCTOR_P (method_decl))
7078 return init_identifier_node;
7079
7080 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
7081 and still can be a constructor. FIXME */
7082
7083 /* Don't confuse method only bearing the name of their class as
7084 constructors */
7085 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
7086 && ctxp
7087 && ctxp->current_parsed_class_un == EXPR_WFL_NODE (method_name)
7088 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
7089 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
7090 return init_identifier_node;
7091 else
7092 return EXPR_WFL_NODE (method_name);
7093 }
7094
7095 /* Track method being redefined inside the same class. As a side
7096 effect, set DECL_NAME to an IDENTIFIER (prior entering this
7097 function it's a FWL, so we can track errors more accurately */
7098
7099 static int
7100 check_method_redefinition (class, method)
7101 tree class, method;
7102 {
7103 tree redef, name;
7104 tree cl = DECL_NAME (method);
7105 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
7106 /* decl name of artificial <clinit> and $finit$ doesn't need to be
7107 fixed and checked */
7108
7109 /* Reset the method name before running the check. If it returns 1,
7110 the method doesn't need to be verified with respect to method
7111 redeclaration and we return 0 */
7112 if (reset_method_name (method))
7113 return 0;
7114
7115 name = DECL_NAME (method);
7116 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
7117 {
7118 if (redef == method)
7119 break;
7120 if (DECL_NAME (redef) == name
7121 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
7122 {
7123 parse_error_context
7124 (cl, "Duplicate %s declaration `%s'",
7125 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
7126 get_printable_method_name (redef));
7127 return 1;
7128 }
7129 }
7130 return 0;
7131 }
7132
7133 /* Check all the methods of CLASS. Methods are first completed then
7134 checked according to regular method existance rules.
7135 If no constructor were encountered, then build its declaration. */
7136
7137 static void
7138 java_check_regular_methods (class_decl)
7139 tree class_decl;
7140 {
7141 int saw_constructor = 0;
7142 tree method;
7143 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
7144 tree super_class = CLASSTYPE_SUPER (class);
7145 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
7146 tree mthrows;
7147
7148 /* It is not necessary to check methods defined in java.lang.Object */
7149 if (class == object_type_node)
7150 return;
7151
7152 if (!TYPE_NVIRTUALS (class))
7153 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7154
7155 /* Should take interfaces into account. FIXME */
7156 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
7157 {
7158 tree sig;
7159 tree method_wfl = DECL_NAME (method);
7160 int aflags;
7161
7162 /* If we previously found something and its name was saved,
7163 reinstall it now */
7164 if (found && saved_found_wfl)
7165 {
7166 DECL_NAME (found) = saved_found_wfl;
7167 saved_found_wfl = NULL_TREE;
7168 }
7169
7170 /* Check for redefinitions */
7171 if (check_method_redefinition (class, method))
7172 continue;
7173
7174 /* If we see one constructor a mark so we don't generate the
7175 default one. Also skip other verifications: constructors
7176 can't be inherited hence hiden or overriden */
7177 if (DECL_CONSTRUCTOR_P (method))
7178 {
7179 saw_constructor = 1;
7180 continue;
7181 }
7182
7183 /* We verify things thrown by the method. They must inherits from
7184 java.lang.Throwable */
7185 for (mthrows = DECL_FUNCTION_THROWS (method);
7186 mthrows; mthrows = TREE_CHAIN (mthrows))
7187 {
7188 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
7189 parse_error_context
7190 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be "
7191 "a subclass of class `java.lang.Throwable'",
7192 IDENTIFIER_POINTER
7193 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
7194 }
7195
7196 sig = build_java_argument_signature (TREE_TYPE (method));
7197 found = lookup_argument_method (super_class, DECL_NAME (method), sig);
7198
7199 /* Nothing overrides or it's a private method. */
7200 if (!found)
7201 continue;
7202 if (METHOD_PRIVATE (found))
7203 {
7204 found = NULL_TREE;
7205 continue;
7206 }
7207
7208 /* If found wasn't verified, it's DECL_NAME won't be set properly.
7209 We set it temporarily for the sake of the error report. */
7210 saved_found_wfl = DECL_NAME (found);
7211 reset_method_name (found);
7212
7213 /* Can't override a method with the same name and different return
7214 types. */
7215 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
7216 {
7217 char *t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)),
7218 0));
7219 parse_error_context
7220 (method_wfl,
7221 "Method `%s' was defined with return type `%s' in class `%s'",
7222 lang_printable_name (found, 0), t,
7223 IDENTIFIER_POINTER
7224 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7225 free (t);
7226 }
7227
7228 aflags = get_access_flags_from_decl (found);
7229 /* If the method has default, access in an other package, then
7230 issue a warning that the current method doesn't override the
7231 one that was found elsewhere. Do not issue this warning when
7232 the match was found in java.lang.Object. */
7233 if (DECL_CONTEXT (found) != object_type_node
7234 && ((aflags & 0x7) == 0)
7235 && !class_in_current_package (DECL_CONTEXT (found))
7236 && DECL_NAME (found) != clinit_identifier_node
7237 && flag_not_overriding)
7238 {
7239 parse_warning_context
7240 (method_wfl, "Method `%s' in class `%s' does not "
7241 "override the corresponding method in class `%s', which is "
7242 "private to a different package",
7243 lang_printable_name (found, 0),
7244 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
7245 IDENTIFIER_POINTER (DECL_NAME
7246 (TYPE_NAME (DECL_CONTEXT (found)))));
7247 continue;
7248 }
7249
7250 /* Can't override final. Can't override static. */
7251 if (METHOD_FINAL (found) || METHOD_STATIC (found))
7252 {
7253 /* Static *can* override static */
7254 if (METHOD_STATIC (found) && METHOD_STATIC (method))
7255 continue;
7256 parse_error_context
7257 (method_wfl,
7258 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
7259 (METHOD_FINAL (found) ? "Final" : "Static"),
7260 lang_printable_name (found, 0),
7261 (METHOD_FINAL (found) ? "final" : "static"),
7262 IDENTIFIER_POINTER
7263 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7264 continue;
7265 }
7266
7267 /* Static method can't override instance method. */
7268 if (METHOD_STATIC (method))
7269 {
7270 parse_error_context
7271 (method_wfl,
7272 "Instance methods can't be overriden by a static method. Method "
7273 "`%s' is an instance method in class `%s'",
7274 lang_printable_name (found, 0),
7275 IDENTIFIER_POINTER
7276 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7277 continue;
7278 }
7279
7280 /* - Overriding/hiding public must be public
7281 - Overriding/hiding protected must be protected or public
7282 - If the overriden or hidden method has default (package)
7283 access, then the overriding or hiding method must not be
7284 private; otherwise, a compile-time error occurs */
7285 if ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
7286 || (METHOD_PROTECTED (found)
7287 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
7288 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
7289 && METHOD_PRIVATE (method)))
7290 {
7291 parse_error_context
7292 (method_wfl,
7293 "Methods can't be overridden to be more private. Method `%s' is "
7294 "not %s in class `%s'", lang_printable_name (method, 0),
7295 (METHOD_PUBLIC (method) ? "public" :
7296 (METHOD_PRIVATE (method) ? "private" : "protected")),
7297 IDENTIFIER_POINTER (DECL_NAME
7298 (TYPE_NAME (DECL_CONTEXT (found)))));
7299 continue;
7300 }
7301
7302 /* Overriding methods must have compatible `throws' clauses on checked
7303 exceptions, if any */
7304 check_throws_clauses (method, method_wfl, found);
7305
7306 /* Inheriting multiple methods with the same signature. FIXME */
7307 }
7308
7309 /* Don't forget eventual pending found and saved_found_wfl. Take
7310 into account that we might have exited because we saw an
7311 aritifical method as the last entry. */
7312
7313 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
7314 DECL_NAME (found) = saved_found_wfl;
7315
7316 if (!TYPE_NVIRTUALS (class))
7317 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
7318
7319 if (!saw_constructor)
7320 {
7321 /* No constructor seen, we craft one, at line 0. Since this
7322 operation takes place after we laid methods out
7323 (layout_class_methods), we prepare the its DECL
7324 appropriately. */
7325 int flags;
7326 tree decl;
7327
7328 /* If the class is declared PUBLIC, the default constructor is
7329 PUBLIC otherwise it has default access implied by no access
7330 modifiers. */
7331 flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7332 ACC_PUBLIC : 0);
7333 decl = create_artificial_method (class, flags, void_type_node,
7334 init_identifier_node, end_params_node);
7335 DECL_CONSTRUCTOR_P (decl) = 1;
7336 layout_class_method (TREE_TYPE (class_decl), NULL_TREE, decl, NULL_TREE);
7337 }
7338 }
7339
7340 /* Return a non zero value if the `throws' clause of METHOD (if any)
7341 is incompatible with the `throws' clause of FOUND (if any). */
7342
7343 static void
7344 check_throws_clauses (method, method_wfl, found)
7345 tree method, method_wfl, found;
7346 {
7347 tree mthrows, fthrows;
7348
7349 /* Can't check these things with class loaded from bytecode. FIXME */
7350 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
7351 return;
7352
7353 for (mthrows = DECL_FUNCTION_THROWS (method);
7354 mthrows; mthrows = TREE_CHAIN (mthrows))
7355 {
7356 /* We don't verify unchecked expressions */
7357 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
7358 continue;
7359 /* Checked expression must be compatible */
7360 for (fthrows = DECL_FUNCTION_THROWS (found);
7361 fthrows; fthrows = TREE_CHAIN (fthrows))
7362 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
7363 break;
7364 if (!fthrows)
7365 {
7366 parse_error_context
7367 (method_wfl, "Invalid checked exception class `%s' in "
7368 "`throws' clause. The exception must be a subclass of an "
7369 "exception thrown by `%s' from class `%s'",
7370 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
7371 lang_printable_name (found, 0),
7372 IDENTIFIER_POINTER
7373 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7374 }
7375 }
7376 }
7377
7378 /* Check abstract method of interface INTERFACE */
7379
7380 static void
7381 java_check_abstract_methods (interface_decl)
7382 tree interface_decl;
7383 {
7384 int i, n;
7385 tree method, basetype_vec, found;
7386 tree interface = TREE_TYPE (interface_decl);
7387
7388 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
7389 {
7390 tree method_wfl = DECL_NAME (method);
7391
7392 /* 2- Check for double definition inside the defining interface */
7393 if (check_method_redefinition (interface, method))
7394 continue;
7395
7396 /* 3- Overriding is OK as far as we preserve the return type and
7397 the thrown exceptions (FIXME) */
7398 found = lookup_java_interface_method2 (interface, method);
7399 if (found)
7400 {
7401 char *t;
7402 tree saved_found_wfl = DECL_NAME (found);
7403 reset_method_name (found);
7404 t = strdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
7405 parse_error_context
7406 (method_wfl,
7407 "Method `%s' was defined with return type `%s' in class `%s'",
7408 lang_printable_name (found, 0), t,
7409 IDENTIFIER_POINTER
7410 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7411 free (t);
7412 continue;
7413
7414 DECL_NAME (found) = saved_found_wfl;
7415 }
7416 }
7417
7418 /* 4- Inherited methods can't differ by their returned types */
7419 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
7420 return;
7421 n = TREE_VEC_LENGTH (basetype_vec);
7422 for (i = 0; i < n; i++)
7423 {
7424 tree sub_interface_method, sub_interface;
7425 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7426 if (!vec_elt)
7427 continue;
7428 sub_interface = BINFO_TYPE (vec_elt);
7429 for (sub_interface_method = TYPE_METHODS (sub_interface);
7430 sub_interface_method;
7431 sub_interface_method = TREE_CHAIN (sub_interface_method))
7432 {
7433 found = lookup_java_interface_method2 (interface,
7434 sub_interface_method);
7435 if (found && (found != sub_interface_method))
7436 {
7437 tree saved_found_wfl = DECL_NAME (found);
7438 reset_method_name (found);
7439 parse_error_context
7440 (lookup_cl (sub_interface_method),
7441 "Interface `%s' inherits method `%s' from interface `%s'. "
7442 "This method is redefined with a different return type in "
7443 "interface `%s'",
7444 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
7445 lang_printable_name (found, 0),
7446 IDENTIFIER_POINTER
7447 (DECL_NAME (TYPE_NAME
7448 (DECL_CONTEXT (sub_interface_method)))),
7449 IDENTIFIER_POINTER
7450 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
7451 DECL_NAME (found) = saved_found_wfl;
7452 }
7453 }
7454 }
7455 }
7456
7457 /* Lookup methods in interfaces using their name and partial
7458 signature. Return a matching method only if their types differ. */
7459
7460 static tree
7461 lookup_java_interface_method2 (class, method_decl)
7462 tree class, method_decl;
7463 {
7464 int i, n;
7465 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
7466
7467 if (!basetype_vec)
7468 return NULL_TREE;
7469
7470 n = TREE_VEC_LENGTH (basetype_vec);
7471 for (i = 0; i < n; i++)
7472 {
7473 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
7474 if ((BINFO_TYPE (vec_elt) != object_type_node)
7475 && (to_return =
7476 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
7477 return to_return;
7478 }
7479 for (i = 0; i < n; i++)
7480 {
7481 to_return = lookup_java_interface_method2
7482 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
7483 if (to_return)
7484 return to_return;
7485 }
7486
7487 return NULL_TREE;
7488 }
7489
7490 /* Lookup method using their name and partial signature. Return a
7491 matching method only if their types differ. */
7492
7493 static tree
7494 lookup_java_method2 (clas, method_decl, do_interface)
7495 tree clas, method_decl;
7496 int do_interface;
7497 {
7498 tree method, method_signature, method_name, method_type, name;
7499
7500 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
7501 name = DECL_NAME (method_decl);
7502 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
7503 EXPR_WFL_NODE (name) : name);
7504 method_type = TREE_TYPE (TREE_TYPE (method_decl));
7505
7506 while (clas != NULL_TREE)
7507 {
7508 for (method = TYPE_METHODS (clas);
7509 method != NULL_TREE; method = TREE_CHAIN (method))
7510 {
7511 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
7512 tree name = DECL_NAME (method);
7513 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
7514 EXPR_WFL_NODE (name) : name) == method_name
7515 && method_sig == method_signature
7516 && TREE_TYPE (TREE_TYPE (method)) != method_type)
7517 return method;
7518 }
7519 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
7520 }
7521 return NULL_TREE;
7522 }
7523
7524 /* Return the line that matches DECL line number. Used during error
7525 report */
7526
7527 static tree
7528 lookup_cl (decl)
7529 tree decl;
7530 {
7531 static tree cl = NULL_TREE;
7532
7533 if (!decl)
7534 return NULL_TREE;
7535
7536 if (cl == NULL_TREE)
7537 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
7538
7539 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
7540 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
7541
7542 return cl;
7543 }
7544
7545 /* Look for a simple name in the single-type import list */
7546
7547 static tree
7548 find_name_in_single_imports (name)
7549 tree name;
7550 {
7551 tree node;
7552
7553 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
7554 if (TREE_VALUE (node) == name)
7555 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
7556
7557 return NULL_TREE;
7558 }
7559
7560 /* Process all single-type import. */
7561
7562 static int
7563 process_imports ()
7564 {
7565 tree import;
7566 int error_found;
7567
7568 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7569 {
7570 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
7571
7572 /* Don't load twice something already defined. */
7573 if (IDENTIFIER_CLASS_VALUE (to_be_found))
7574 continue;
7575 QUALIFIED_P (to_be_found) = 1;
7576 load_class (to_be_found, 0);
7577 error_found =
7578 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
7579 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
7580 {
7581 parse_error_context (TREE_PURPOSE (import),
7582 "Class or interface `%s' not found in import",
7583 IDENTIFIER_POINTER (to_be_found));
7584 return 1;
7585 }
7586 if (error_found)
7587 return 1;
7588 }
7589 return 0;
7590 }
7591
7592 /* Possibly find a class imported by a single-type import statement. Return
7593 1 if an error occured, 0 otherwise. */
7594
7595 static int
7596 find_in_imports (class_type)
7597 tree class_type;
7598 {
7599 tree import;
7600
7601 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
7602 if (TREE_VALUE (import) == TYPE_NAME (class_type))
7603 {
7604 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
7605 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7606 }
7607 return 0;
7608 }
7609
7610 static int
7611 note_possible_classname (name, len)
7612 char *name;
7613 int len;
7614 {
7615 tree node;
7616 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
7617 len = len - 5;
7618 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
7619 len = len - 6;
7620 else
7621 return 0;
7622 node = ident_subst (name, len, "", '/', '.', "");
7623 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
7624 QUALIFIED_P (node) = 1; /* As soon as we turn / into . */
7625 return 1;
7626 }
7627
7628 /* Read a import directory, gathering potential match for further type
7629 references. Indifferently reads a filesystem or a ZIP archive
7630 directory. */
7631
7632 static void
7633 read_import_dir (wfl)
7634 tree wfl;
7635 {
7636 tree package_id = EXPR_WFL_NODE (wfl);
7637 char *package_name = IDENTIFIER_POINTER (package_id);
7638 int package_length = IDENTIFIER_LENGTH (package_id);
7639 DIR *dirp = NULL;
7640 JCF *saved_jcf = current_jcf;
7641
7642 int found = 0;
7643 int k;
7644 void *entry;
7645 struct buffer filename[1];
7646
7647
7648 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
7649 return;
7650 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
7651
7652 BUFFER_INIT (filename);
7653 buffer_grow (filename, package_length + 100);
7654
7655 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
7656 {
7657 char *entry_name = jcf_path_name (entry);
7658 int entry_length = strlen (entry_name);
7659 if (jcf_path_is_zipfile (entry))
7660 {
7661 ZipFile *zipf;
7662 buffer_grow (filename, entry_length);
7663 memcpy (filename->data, entry_name, entry_length - 1);
7664 filename->data[entry_length-1] = '\0';
7665 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
7666 if (zipf == NULL)
7667 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
7668 else
7669 {
7670 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
7671 BUFFER_RESET (filename);
7672 for (k = 0; k < package_length; k++)
7673 {
7674 char ch = package_name[k];
7675 *filename->ptr++ = ch == '.' ? '/' : ch;
7676 }
7677 *filename->ptr++ = '/';
7678
7679 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
7680 {
7681 char *current_entry = ZIPDIR_FILENAME (zipd);
7682 int current_entry_len = zipd->filename_length;
7683
7684 if (current_entry_len >= BUFFER_LENGTH (filename)
7685 && strncmp (filename->data, current_entry,
7686 BUFFER_LENGTH (filename)) != 0)
7687 continue;
7688 found |= note_possible_classname (current_entry,
7689 current_entry_len);
7690 }
7691 }
7692 }
7693 else
7694 {
7695 BUFFER_RESET (filename);
7696 buffer_grow (filename, entry_length + package_length + 4);
7697 strcpy (filename->data, entry_name);
7698 filename->ptr = filename->data + entry_length;
7699 for (k = 0; k < package_length; k++)
7700 {
7701 char ch = package_name[k];
7702 *filename->ptr++ = ch == '.' ? '/' : ch;
7703 }
7704 *filename->ptr = '\0';
7705
7706 dirp = opendir (filename->data);
7707 if (dirp == NULL)
7708 continue;
7709 *filename->ptr++ = '/';
7710 for (;;)
7711 {
7712 int len;
7713 char *d_name;
7714 struct dirent *direntp = readdir (dirp);
7715 if (!direntp)
7716 break;
7717 d_name = direntp->d_name;
7718 len = strlen (direntp->d_name);
7719 buffer_grow (filename, len+1);
7720 strcpy (filename->ptr, d_name);
7721 found |= note_possible_classname (filename->data + entry_length,
7722 package_length+len+1);
7723 }
7724 if (dirp)
7725 closedir (dirp);
7726 }
7727 }
7728
7729 free (filename->data);
7730
7731 /* Here we should have a unified way of retrieving an entry, to be
7732 indexed. */
7733 if (!found)
7734 {
7735 static int first = 1;
7736 if (first)
7737 {
7738 char buffer [256];
7739 sprintf (buffer, "Can't find default package `%s'. Check "
7740 "the CLASSPATH environment variable and the access to the "
7741 "archives.", package_name);
7742 error (buffer);
7743 java_error_count++;
7744 first = 0;
7745 }
7746 else
7747 parse_error_context (wfl, "Package `%s' not found in import",
7748 package_name);
7749 current_jcf = saved_jcf;
7750 return;
7751 }
7752 current_jcf = saved_jcf;
7753 }
7754
7755 /* Possibly find a type in the import on demands specified
7756 types. Returns 1 if an error occured, 0 otherwise. Run throught the
7757 entire list, to detected potential double definitions. */
7758
7759 static int
7760 find_in_imports_on_demand (class_type)
7761 tree class_type;
7762 {
7763 tree node, import, node_to_use = NULL_TREE;
7764 int seen_once = -1;
7765 tree cl = NULL_TREE;
7766
7767 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
7768 {
7769 char *id_name;
7770 obstack_grow (&temporary_obstack,
7771 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
7772 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7773 obstack_1grow (&temporary_obstack, '.');
7774 obstack_grow0 (&temporary_obstack,
7775 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7776 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
7777 id_name = obstack_finish (&temporary_obstack);
7778
7779 node = maybe_get_identifier (id_name);
7780 if (node && IS_A_CLASSFILE_NAME (node))
7781 {
7782 if (seen_once < 0)
7783 {
7784 cl = TREE_PURPOSE (import);
7785 seen_once = 1;
7786 node_to_use = node;
7787 }
7788 else
7789 {
7790 seen_once++;
7791 parse_error_context
7792 (import, "Type `%s' also potentially defined in package `%s'",
7793 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
7794 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
7795 }
7796 }
7797 }
7798
7799 if (seen_once == 1)
7800 {
7801 /* Setup lineno so that it refers to the line of the import (in
7802 case we parse a class file and encounter errors */
7803 tree decl;
7804 int saved_lineno = lineno;
7805 lineno = EXPR_WFL_LINENO (cl);
7806 TYPE_NAME (class_type) = node_to_use;
7807 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
7808 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
7809 /* If there is no DECL set for the class or if the class isn't
7810 loaded and not seen in source yet, the load */
7811 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
7812 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
7813 load_class (node_to_use, 0);
7814 lineno = saved_lineno;
7815 return check_pkg_class_access (TYPE_NAME (class_type), cl);
7816 }
7817 else
7818 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
7819 }
7820
7821 static tree
7822 resolve_package (pkg, next)
7823 tree pkg, *next;
7824 {
7825 tree type_name = NULL_TREE;
7826 char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
7827
7828 /* The trick is to determine when the package name stops and were
7829 the name of something contained in the package starts. Then we
7830 return a fully qualified name of what we want to get. */
7831
7832 /* Do a quick search on well known package names */
7833 if (!strncmp (name, "java.lang.reflect", 17))
7834 {
7835 *next =
7836 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
7837 type_name = lookup_package_type (name, 17);
7838 }
7839 else if (!strncmp (name, "java.lang", 9))
7840 {
7841 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
7842 type_name = lookup_package_type (name, 9);
7843 }
7844 else
7845 return NULL_TREE; /* FIXME, search all imported packages. */
7846
7847 return type_name;
7848 }
7849
7850 static tree
7851 lookup_package_type (name, from)
7852 char *name;
7853 int from;
7854 {
7855 char subname [128];
7856 char *sub = &name[from+1];
7857 while (*sub != '.' && *sub)
7858 sub++;
7859 strncpy (subname, name, sub-name);
7860 subname [sub-name] = '\0';
7861 return get_identifier (subname);
7862 }
7863
7864 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
7865 access violations were found, 1 otherwise. */
7866
7867 static int
7868 check_pkg_class_access (class_name, cl)
7869 tree class_name;
7870 tree cl;
7871 {
7872 tree type;
7873
7874 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
7875 return 0;
7876
7877 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
7878 return 0;
7879
7880 if (!CLASS_PUBLIC (TYPE_NAME (type)))
7881 {
7882 /* Access to a private class within the same package is
7883 allowed. */
7884 tree l, r;
7885 breakdown_qualified (&l, &r, class_name);
7886 if (l == ctxp->package)
7887 return 0;
7888
7889 parse_error_context
7890 (cl, "Can't access %s `%s'. Only public classes and interfaces in "
7891 "other packages can be accessed",
7892 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
7893 IDENTIFIER_POINTER (class_name));
7894 return 1;
7895 }
7896 return 0;
7897 }
7898
7899 /* Local variable declaration. */
7900
7901 static void
7902 declare_local_variables (modifier, type, vlist)
7903 int modifier;
7904 tree type;
7905 tree vlist;
7906 {
7907 tree decl, current, saved_type;
7908 tree type_wfl = NULL_TREE;
7909 int must_chain = 0;
7910
7911 /* Push a new block if statements were seen between the last time we
7912 pushed a block and now. Keep a cound of block to close */
7913 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
7914 {
7915 tree body = GET_CURRENT_BLOCK (current_function_decl);
7916 tree b = enter_block ();
7917 BLOCK_EXPR_ORIGIN (b) = body;
7918 }
7919
7920 if (modifier)
7921 {
7922 int i;
7923 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
7924 if (modifier == ACC_FINAL)
7925 {
7926 if (flag_static_local_jdk1_1)
7927 parse_warning_context (ctxp->modifier_ctx [i],
7928 "Unsupported JDK1.1 `final' local variable "
7929 "(treated as non final)");
7930 }
7931 else
7932 {
7933 parse_error_context
7934 (ctxp->modifier_ctx [i],
7935 "Only `final' is allowed as a local variables modifier");
7936 return;
7937 }
7938 }
7939
7940 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
7941 hold the TYPE value if a new incomplete has to be created (as
7942 opposed to being found already existing and reused). */
7943 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7944
7945 /* If TYPE is fully resolved and we don't have a reference, make one */
7946 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7947
7948 /* Go through all the declared variables */
7949 for (current = vlist, saved_type = type; current;
7950 current = TREE_CHAIN (current), type = saved_type)
7951 {
7952 tree other, real_type;
7953 tree wfl = TREE_PURPOSE (current);
7954 tree name = EXPR_WFL_NODE (wfl);
7955 tree init = TREE_VALUE (current);
7956
7957 /* Process NAME, as it may specify extra dimension(s) for it */
7958 type = build_array_from_name (type, type_wfl, name, &name);
7959
7960 /* Variable redefinition check */
7961 if ((other = lookup_name_in_blocks (name)))
7962 {
7963 variable_redefinition_error (wfl, name, TREE_TYPE (other),
7964 DECL_SOURCE_LINE (other));
7965 continue;
7966 }
7967
7968 /* Type adjustment. We may have just readjusted TYPE because
7969 the variable specified more dimensions. Make sure we have
7970 a reference if we can and don't have one already. */
7971 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7972
7973 real_type = GET_REAL_TYPE (type);
7974 /* Never layout this decl. This will be done when its scope
7975 will be entered */
7976 decl = build_decl (VAR_DECL, name, real_type);
7977 BLOCK_CHAIN_DECL (decl);
7978
7979 /* If doing xreferencing, replace the line number with the WFL
7980 compound value */
7981 if (flag_emit_xref)
7982 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
7983
7984 /* Don't try to use an INIT statement when an error was found */
7985 if (init && java_error_count)
7986 init = NULL_TREE;
7987
7988 /* Add the initialization function to the current function's code */
7989 if (init)
7990 {
7991 /* Name might have been readjusted */
7992 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
7993 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
7994 java_method_add_stmt (current_function_decl,
7995 build_debugable_stmt (EXPR_WFL_LINECOL (init),
7996 init));
7997 }
7998
7999 /* Setup dependency the type of the decl */
8000 if (must_chain)
8001 {
8002 jdep *dep;
8003 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
8004 dep = CLASSD_LAST (ctxp->classd_list);
8005 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
8006 }
8007 }
8008 SOURCE_FRONTEND_DEBUG (("Defined locals"));
8009 }
8010
8011 /* Called during parsing. Build decls from argument list. */
8012
8013 static void
8014 source_start_java_method (fndecl)
8015 tree fndecl;
8016 {
8017 tree tem;
8018 tree parm_decl;
8019 int i;
8020
8021 current_function_decl = fndecl;
8022
8023 /* New scope for the function */
8024 enter_block ();
8025 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
8026 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
8027 {
8028 tree type = TREE_VALUE (tem);
8029 tree name = TREE_PURPOSE (tem);
8030
8031 /* If type is incomplete. Create an incomplete decl and ask for
8032 the decl to be patched later */
8033 if (INCOMPLETE_TYPE_P (type))
8034 {
8035 jdep *jdep;
8036 tree real_type = GET_REAL_TYPE (type);
8037 parm_decl = build_decl (PARM_DECL, name, real_type);
8038 type = obtain_incomplete_type (type);
8039 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
8040 jdep = CLASSD_LAST (ctxp->classd_list);
8041 JDEP_MISC (jdep) = name;
8042 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
8043 }
8044 else
8045 parm_decl = build_decl (PARM_DECL, name, type);
8046
8047 BLOCK_CHAIN_DECL (parm_decl);
8048 }
8049 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8050 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
8051 nreverse (tem);
8052 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
8053 }
8054
8055 /* Called during parsing. Creates an artificial method declaration. */
8056
8057 static tree
8058 create_artificial_method (class, flags, type, name, args)
8059 tree class;
8060 int flags;
8061 tree type, name, args;
8062 {
8063 int saved_lineno = lineno;
8064 tree mdecl;
8065
8066 lineno = 0;
8067 mdecl = make_node (FUNCTION_TYPE);
8068 TREE_TYPE (mdecl) = type;
8069 TYPE_ARG_TYPES (mdecl) = args;
8070 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
8071 lineno = saved_lineno;
8072 DECL_ARTIFICIAL (mdecl) = 1;
8073 return mdecl;
8074 }
8075
8076 /* Starts the body if an artifical method. */
8077
8078 static void
8079 start_artificial_method_body (mdecl)
8080 tree mdecl;
8081 {
8082 DECL_SOURCE_LINE (mdecl) = 1;
8083 DECL_SOURCE_LINE_MERGE (mdecl, 1);
8084 source_start_java_method (mdecl);
8085 enter_block ();
8086 }
8087
8088 static void
8089 end_artificial_method_body (mdecl)
8090 tree mdecl;
8091 {
8092 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
8093 exit_block ();
8094 }
8095
8096 /* Called during expansion. Push decls formerly built from argument
8097 list so they're usable during expansion. */
8098
8099 static void
8100 expand_start_java_method (fndecl)
8101 tree fndecl;
8102 {
8103 tree tem, *ptr;
8104
8105 current_function_decl = fndecl;
8106
8107 announce_function (fndecl);
8108 pushlevel (1); /* Push parameters */
8109 ptr = &DECL_ARGUMENTS (fndecl);
8110 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
8111 while (tem)
8112 {
8113 tree next = TREE_CHAIN (tem);
8114 tree type = TREE_TYPE (tem);
8115 #ifdef PROMOTE_PROTOTYPES
8116 if (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
8117 && INTEGRAL_TYPE_P (type))
8118 type = integer_type_node;
8119 #endif
8120 DECL_ARG_TYPE (tem) = type;
8121 layout_decl (tem, 0);
8122 pushdecl (tem);
8123 *ptr = tem;
8124 ptr = &TREE_CHAIN (tem);
8125 tem = next;
8126 }
8127 *ptr = NULL_TREE;
8128 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8129 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
8130 }
8131
8132 /* Terminate a function and expand its body. */
8133
8134 static void
8135 source_end_java_method ()
8136 {
8137 tree fndecl = current_function_decl;
8138 int flag_asynchronous_exceptions = asynchronous_exceptions;
8139
8140 java_parser_context_save_global ();
8141 lineno = ctxp->last_ccb_indent1;
8142
8143 /* Set EH language codes */
8144 java_set_exception_lang_code ();
8145
8146 /* Turn function bodies with only a NOP expr null, so they don't get
8147 generated at all and we won't get warnings when using the -W
8148 -Wall flags. */
8149 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
8150 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
8151
8152 /* Generate function's code */
8153 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
8154 && ! flag_emit_class_files
8155 && ! flag_emit_xref)
8156 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
8157
8158 /* pop out of its parameters */
8159 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
8160 poplevel (1, 0, 1);
8161 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
8162
8163 /* Generate rtl for function exit. */
8164 if (! flag_emit_class_files && ! flag_emit_xref)
8165 {
8166 lineno = DECL_SOURCE_LINE_LAST (fndecl);
8167 /* Emit catch-finally clauses */
8168 emit_handlers ();
8169 expand_function_end (input_filename, lineno, 0);
8170
8171 /* FIXME: If the current method contains any exception handlers,
8172 force asynchronous_exceptions: this is necessary because signal
8173 handlers in libjava may throw exceptions. This is far from being
8174 a perfect solution, but it's better than doing nothing at all.*/
8175 if (catch_clauses)
8176 asynchronous_exceptions = 1;
8177
8178 /* Run the optimizers and output assembler code for this function. */
8179 rest_of_compilation (fndecl);
8180 }
8181
8182 current_function_decl = NULL_TREE;
8183 /* permanent_allocation (1); */
8184 java_parser_context_restore_global ();
8185 asynchronous_exceptions = flag_asynchronous_exceptions;
8186 }
8187
8188 /* Record EXPR in the current function block. Complements compound
8189 expression second operand if necessary. */
8190
8191 tree
8192 java_method_add_stmt (fndecl, expr)
8193 tree fndecl, expr;
8194 {
8195 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
8196 }
8197
8198 static tree
8199 add_stmt_to_block (b, type, stmt)
8200 tree b, type, stmt;
8201 {
8202 tree body = BLOCK_EXPR_BODY (b), c;
8203
8204 if (java_error_count)
8205 return body;
8206
8207 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
8208 return body;
8209
8210 BLOCK_EXPR_BODY (b) = c;
8211 TREE_SIDE_EFFECTS (c) = 1;
8212 return c;
8213 }
8214
8215 /* Add STMT to EXISTING if possible, otherwise create a new
8216 COMPOUND_EXPR and add STMT to it. */
8217
8218 static tree
8219 add_stmt_to_compound (existing, type, stmt)
8220 tree existing, type, stmt;
8221 {
8222 if (existing)
8223 return build (COMPOUND_EXPR, type, existing, stmt);
8224 else
8225 return stmt;
8226 }
8227
8228 /* Hold THIS for the scope of the current public method decl. */
8229 static tree current_this;
8230
8231 void java_layout_seen_class_methods ()
8232 {
8233 tree previous_list = all_class_list;
8234 tree end = NULL_TREE;
8235 tree current;
8236
8237 while (1)
8238 {
8239 for (current = previous_list;
8240 current != end; current = TREE_CHAIN (current))
8241 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
8242
8243 if (previous_list != all_class_list)
8244 {
8245 end = previous_list;
8246 previous_list = all_class_list;
8247 }
8248 else
8249 break;
8250 }
8251 }
8252
8253 /* Layout the methods of all classes loaded in one way on an
8254 other. Check methods of source parsed classes. Then reorder the
8255 fields and layout the classes or the type of all source parsed
8256 classes */
8257
8258 void
8259 java_layout_classes ()
8260 {
8261 tree current;
8262 int save_error_count = java_error_count;
8263
8264 /* Layout the methods of all classes seen so far */
8265 java_layout_seen_class_methods ();
8266 java_parse_abort_on_error ();
8267 all_class_list = NULL_TREE;
8268
8269 /* Then check the methods of all parsed classes */
8270 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8271 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
8272 CHECK_METHODS (TREE_VALUE (current));
8273 java_parse_abort_on_error ();
8274
8275 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
8276 {
8277 current_class = TREE_TYPE (TREE_VALUE (current));
8278
8279 /* Reverse the fields, but leave the dummy field in front.
8280 Fields are already ordered for Object and Class */
8281 if (TYPE_FIELDS (current_class) && current_class != object_type_node
8282 && current_class != class_type_node)
8283 {
8284 /* If the dummy field is there, reverse the right fields and
8285 just layout the type for proper fields offset */
8286 if (!DECL_NAME (TYPE_FIELDS (current_class)))
8287 {
8288 tree fields = TYPE_FIELDS (current_class);
8289 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
8290 TYPE_SIZE (current_class) = NULL_TREE;
8291 layout_type (current_class);
8292 }
8293 /* We don't have a dummy field, we need to layout the class,
8294 after having reversed the fields */
8295 else
8296 {
8297 TYPE_FIELDS (current_class) =
8298 nreverse (TYPE_FIELDS (current_class));
8299 TYPE_SIZE (current_class) = NULL_TREE;
8300 layout_class (current_class);
8301 }
8302 }
8303 else
8304 layout_class (current_class);
8305
8306 /* From now on, the class is considered completely loaded */
8307 CLASS_LOADED_P (current_class) = 1;
8308
8309 /* Error reported by the caller */
8310 if (java_error_count)
8311 return;
8312 }
8313
8314 /* We might have reloaded classes durign the process of laying out
8315 classes for code generation. We must layout the methods of those
8316 late additions, as constructor checks might use them */
8317 java_layout_seen_class_methods ();
8318 java_parse_abort_on_error ();
8319 }
8320
8321 /* Expand all methods in all registered classes. */
8322
8323 void
8324 java_complete_expand_methods ()
8325 {
8326 tree current;
8327
8328 do_not_fold = flag_emit_xref;
8329
8330 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
8331 {
8332 int is_interface;
8333 tree class_type = CLASS_TO_HANDLE_TYPE (TREE_TYPE (current));
8334 tree decl;
8335
8336 current_class = TREE_TYPE (current);
8337 is_interface = CLASS_INTERFACE (TYPE_NAME (current_class));
8338
8339 /* Initialize a new constant pool */
8340 init_outgoing_cpool ();
8341
8342 /* We want <clinit> (if any) to be processed first. */
8343 decl = tree_last (TYPE_METHODS (class_type));
8344 if (IS_CLINIT (decl))
8345 {
8346 tree fbody = DECL_FUNCTION_BODY (decl);
8347 tree list;
8348 if (fbody != NULL_TREE)
8349 {
8350 /* First check if we can ignore empty <clinit> */
8351 tree block_body = BLOCK_EXPR_BODY (fbody);
8352
8353 current_this = NULL_TREE;
8354 current_function_decl = decl;
8355 if (block_body != NULL_TREE)
8356 {
8357 /* Prevent the use of `this' inside <clinit> */
8358 ctxp->explicit_constructor_p = 1;
8359
8360 block_body = java_complete_tree (block_body);
8361 ctxp->explicit_constructor_p = 0;
8362 BLOCK_EXPR_BODY (fbody) = block_body;
8363 if (block_body != NULL_TREE
8364 && TREE_CODE (block_body) == BLOCK
8365 && BLOCK_EXPR_BODY (block_body) == empty_stmt_node)
8366 decl = NULL_TREE;
8367 }
8368 }
8369 list = nreverse (TREE_CHAIN (nreverse (TYPE_METHODS (class_type))));
8370 if (decl != NULL_TREE)
8371 {
8372 TREE_CHAIN (decl) = list;
8373 TYPE_METHODS (class_type) = decl;
8374 }
8375 else
8376 TYPE_METHODS (class_type) = list;
8377 }
8378
8379 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8380 {
8381 current_function_decl = decl;
8382 /* Don't generate debug info on line zero when expanding a
8383 generated constructor. */
8384 if (DECL_CONSTRUCTOR_P (decl) && !DECL_FUNCTION_BODY (decl))
8385 {
8386 /* If we found errors, it's too dangerous to try to
8387 generate and expand a constructor */
8388 if (!java_error_count)
8389 {
8390 restore_line_number_status (1);
8391 java_complete_expand_method (decl);
8392 restore_line_number_status (0);
8393 }
8394 }
8395 else if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl))
8396 continue;
8397 else
8398 java_complete_expand_method (decl);
8399 }
8400
8401 /* Now verify constructor circularity (stop after the first one
8402 we find) */
8403 if (!is_interface)
8404 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8405 if (DECL_CONSTRUCTOR_P (decl) &&
8406 verify_constructor_circularity (decl, decl))
8407 break;
8408
8409 /* Make the class data, register it and run the rest of decl
8410 compilation on it */
8411 if (!java_error_count)
8412 {
8413 if (flag_emit_class_files)
8414 write_classfile (current_class);
8415 if (flag_emit_xref)
8416 expand_xref (current_class);
8417 else if (! flag_syntax_only)
8418 finish_class (current_class);
8419 }
8420 }
8421 }
8422
8423 /* Hold a list of catch clauses list. The first element of this list is
8424 the list of the catch clauses of the currently analysed try block. */
8425 static tree currently_caught_type_list;
8426
8427 /* Complete and expand a method. */
8428
8429 static void
8430 java_complete_expand_method (mdecl)
8431 tree mdecl;
8432 {
8433 /* Fix constructors before expanding them */
8434 if (DECL_CONSTRUCTOR_P (mdecl))
8435 fix_constructors (mdecl);
8436
8437 /* Expand functions that have a body */
8438 if (DECL_FUNCTION_BODY (mdecl))
8439 {
8440 tree fbody = DECL_FUNCTION_BODY (mdecl);
8441 tree block_body = BLOCK_EXPR_BODY (fbody);
8442 tree exception_copy;
8443 expand_start_java_method (mdecl);
8444 build_result_decl (mdecl);
8445
8446 current_this
8447 = (!METHOD_STATIC (mdecl) ?
8448 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
8449
8450 /* Purge the `throws' list of unchecked exceptions. If we're
8451 doing xref, save a copy of the list and re-install it
8452 later. */
8453 if (flag_emit_xref)
8454 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
8455
8456 purge_unchecked_exceptions (mdecl);
8457
8458 /* Install exceptions thrown with `throws' */
8459 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
8460
8461 if (block_body != NULL_TREE)
8462 {
8463 block_body = java_complete_tree (block_body);
8464 if (!flag_emit_xref)
8465 check_for_initialization (block_body);
8466 ctxp->explicit_constructor_p = 0;
8467 }
8468 BLOCK_EXPR_BODY (fbody) = block_body;
8469
8470 if ((block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
8471 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
8472 && !flag_emit_xref)
8473 missing_return_error (current_function_decl);
8474
8475 complete_start_java_method (mdecl);
8476
8477 /* Don't go any further if we've found error(s) during the
8478 expansion */
8479 if (!java_error_count)
8480 source_end_java_method ();
8481 else
8482 {
8483 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
8484 poplevel (1, 0, 1);
8485 }
8486
8487 /* Pop the exceptions and sanity check */
8488 POP_EXCEPTIONS();
8489 if (currently_caught_type_list)
8490 fatal ("Exception list non empty - java_complete_expand_method");
8491
8492 if (flag_emit_xref)
8493 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
8494 }
8495 }
8496
8497 /* Craft a body for default constructor. Patch existing constructor
8498 bodies with call to super() and field initialization statements if
8499 necessary. */
8500
8501 static void
8502 fix_constructors (mdecl)
8503 tree mdecl;
8504 {
8505 tree body = DECL_FUNCTION_BODY (mdecl);
8506
8507 if (!body)
8508 {
8509 /* The constructor body must be crafted by hand. It's the
8510 constructor we defined when we realize we didn't have the
8511 CLASSNAME() constructor */
8512
8513 tree compound;
8514
8515 /* It is an error for the compiler to generate a default
8516 constructor if the superclass doesn't have a constructor that
8517 takes no argument */
8518 if (verify_constructor_super ())
8519 {
8520 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (current_class));
8521 char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
8522 parse_error_context (lookup_cl (TYPE_NAME (current_class)),
8523 "No constructor matching `%s()' found in "
8524 "class `%s'", n, n);
8525 }
8526
8527 start_artificial_method_body (mdecl);
8528
8529 /* We don't generate a super constructor invocation if we're
8530 compiling java.lang.Object. build_super_invocation takes care
8531 of that. */
8532 compound = java_method_add_stmt (mdecl, build_super_invocation ());
8533
8534 end_artificial_method_body (mdecl);
8535 }
8536 /* Search for an explicit constructor invocation */
8537 else
8538 {
8539 int found = 0;
8540 tree main_block = BLOCK_EXPR_BODY (body);
8541 tree compound = NULL_TREE;
8542
8543 while (body)
8544 switch (TREE_CODE (body))
8545 {
8546 case CALL_EXPR:
8547 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
8548 body = NULL_TREE;
8549 break;
8550 case COMPOUND_EXPR:
8551 case EXPR_WITH_FILE_LOCATION:
8552 body = TREE_OPERAND (body, 0);
8553 break;
8554 case BLOCK:
8555 body = BLOCK_EXPR_BODY (body);
8556 break;
8557 default:
8558 found = 0;
8559 body = NULL_TREE;
8560 }
8561 /* The constructor is missing an invocation of super() */
8562 if (!found)
8563 compound = add_stmt_to_compound (compound, NULL_TREE,
8564 build_super_invocation ());
8565
8566 /* Fix the constructor main block if we're adding extra stmts */
8567 if (compound)
8568 {
8569 compound = add_stmt_to_compound (compound, NULL_TREE,
8570 BLOCK_EXPR_BODY (main_block));
8571 BLOCK_EXPR_BODY (main_block) = compound;
8572 }
8573 }
8574 }
8575
8576 /* Browse constructors in the super class, searching for a constructor
8577 that doesn't take any argument. Return 0 if one is found, 1
8578 otherwise. */
8579
8580 static int
8581 verify_constructor_super ()
8582 {
8583 tree class = CLASSTYPE_SUPER (current_class);
8584 if (!class)
8585 return 0;
8586
8587 if (class)
8588 {
8589 tree mdecl;
8590 for (mdecl = TYPE_METHODS (class); mdecl; mdecl = TREE_CHAIN (mdecl))
8591 {
8592 if (DECL_CONSTRUCTOR_P (mdecl)
8593 && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (mdecl))) == end_params_node)
8594 return 0;
8595 }
8596 }
8597 return 1;
8598 }
8599
8600 /* Expand finals. */
8601
8602 void
8603 java_expand_finals ()
8604 {
8605 }
8606
8607 /* Generate code for all context remembered for code generation. */
8608
8609 void
8610 java_expand_classes ()
8611 {
8612 int save_error_count = 0;
8613 java_parse_abort_on_error ();
8614 if (!(ctxp = ctxp_for_generation))
8615 return;
8616 java_layout_classes ();
8617 java_parse_abort_on_error ();
8618
8619 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
8620 {
8621 ctxp = ctxp_for_generation;
8622 lang_init_source (2); /* Error msgs have method prototypes */
8623 java_complete_expand_methods (); /* Complete and expand method bodies */
8624 java_parse_abort_on_error ();
8625 java_expand_finals (); /* Expand and check the finals */
8626 java_parse_abort_on_error ();
8627 java_check_final (); /* Check unitialized final */
8628 java_parse_abort_on_error ();
8629 }
8630 }
8631
8632 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
8633 a tree list node containing RIGHT. Fore coming RIGHTs will be
8634 chained to this hook. LOCATION contains the location of the
8635 separating `.' operator. */
8636
8637 static tree
8638 make_qualified_primary (primary, right, location)
8639 tree primary, right;
8640 int location;
8641 {
8642 tree wfl;
8643
8644 /* We want to process THIS . xxx symbolicaly, to keep it consistent
8645 with the way we're processing SUPER. A THIS from a primary as a
8646 different form than a SUPER. Turn THIS into something symbolic */
8647 if (TREE_CODE (primary) == THIS_EXPR)
8648 {
8649 wfl = build_wfl_node (this_identifier_node);
8650 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8651 wfl = make_qualified_name (wfl, right, location);
8652 PRIMARY_P (wfl) = 1;
8653 return wfl;
8654 }
8655 /* Other non WFL node are wrapped around a WFL */
8656 else if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
8657 {
8658 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
8659 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (primary);
8660 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (primary, NULL_TREE);
8661 }
8662 else
8663 {
8664 wfl = primary;
8665 if (!EXPR_WFL_QUALIFICATION (primary))
8666 EXPR_WFL_QUALIFICATION (primary) =
8667 build_tree_list (primary, NULL_TREE);
8668 }
8669
8670 EXPR_WFL_LINECOL (right) = location;
8671 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
8672 PRIMARY_P (wfl) = 1;
8673 return wfl;
8674 }
8675
8676 /* Simple merge of two name separated by a `.' */
8677
8678 static tree
8679 merge_qualified_name (left, right)
8680 tree left, right;
8681 {
8682 tree node;
8683 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
8684 IDENTIFIER_LENGTH (left));
8685 obstack_1grow (&temporary_obstack, '.');
8686 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
8687 IDENTIFIER_LENGTH (right));
8688 node = get_identifier (obstack_base (&temporary_obstack));
8689 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
8690 QUALIFIED_P (node) = 1;
8691 return node;
8692 }
8693
8694 /* Merge the two parts of a qualified name into LEFT. Set the
8695 location information of the resulting node to LOCATION, usually
8696 inherited from the location information of the `.' operator. */
8697
8698 static tree
8699 make_qualified_name (left, right, location)
8700 tree left, right;
8701 int location;
8702 {
8703 #ifdef USE_COMPONENT_REF
8704 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
8705 EXPR_WFL_LINECOL (node) = location;
8706 return node;
8707 #else
8708 tree left_id = EXPR_WFL_NODE (left);
8709 tree right_id = EXPR_WFL_NODE (right);
8710 tree wfl, merge;
8711
8712 merge = merge_qualified_name (left_id, right_id);
8713
8714 /* Left wasn't qualified and is now qualified */
8715 if (!QUALIFIED_P (left_id))
8716 {
8717 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
8718 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
8719 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
8720 }
8721
8722 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
8723 EXPR_WFL_LINECOL (wfl) = location;
8724 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
8725
8726 EXPR_WFL_NODE (left) = merge;
8727 return left;
8728 #endif
8729 }
8730
8731 /* Extract the last identifier component of the qualified in WFL. The
8732 last identifier is removed from the linked list */
8733
8734 static tree
8735 cut_identifier_in_qualified (wfl)
8736 tree wfl;
8737 {
8738 tree q;
8739 tree previous = NULL_TREE;
8740 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
8741 if (!TREE_CHAIN (q))
8742 {
8743 if (!previous)
8744 fatal ("Operating on a non qualified qualified WFL - "
8745 "cut_identifier_in_qualified");
8746 TREE_CHAIN (previous) = NULL_TREE;
8747 return TREE_PURPOSE (q);
8748 }
8749 }
8750
8751 /* Resolve the expression name NAME. Return its decl. */
8752
8753 static tree
8754 resolve_expression_name (id, orig)
8755 tree id;
8756 tree *orig;
8757 {
8758 tree name = EXPR_WFL_NODE (id);
8759 tree decl;
8760
8761 /* 6.5.5.1: Simple expression names */
8762 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
8763 {
8764 /* 15.13.1: NAME can appear within the scope of a local variable
8765 declaration */
8766 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
8767 return decl;
8768
8769 /* 15.13.1: NAME can appear within a class declaration */
8770 else
8771 {
8772 decl = lookup_field_wrapper (current_class, name);
8773 if (decl)
8774 {
8775 int fs = FIELD_STATIC (decl);
8776 /* Instance variable (8.3.1.1) can't appear within
8777 static method, static initializer or initializer for
8778 a static variable. */
8779 if (!fs && METHOD_STATIC (current_function_decl))
8780 {
8781 static_ref_err (id, name, current_class);
8782 return error_mark_node;
8783 }
8784 /* Instance variables can't appear as an argument of
8785 an explicit constructor invocation */
8786 if (!fs && ctxp->explicit_constructor_p)
8787 {
8788 parse_error_context
8789 (id, "Can't reference `%s' before the superclass "
8790 "constructor has been called", IDENTIFIER_POINTER (name));
8791 return error_mark_node;
8792 }
8793
8794 /* Otherwise build what it takes to access the field */
8795 decl = build_field_ref ((fs ? NULL_TREE : current_this),
8796 DECL_CONTEXT (decl), name);
8797 if (fs && !flag_emit_class_files && !flag_emit_xref)
8798 decl = build_class_init (DECL_CONTEXT (decl), decl);
8799 /* We may be asked to save the real field access node */
8800 if (orig)
8801 *orig = decl;
8802 /* And we return what we got */
8803 return decl;
8804 }
8805 /* Fall down to error report on undefined variable */
8806 }
8807 }
8808 /* 6.5.5.2 Qualified Expression Names */
8809 else
8810 {
8811 if (orig)
8812 *orig = NULL_TREE;
8813 qualify_ambiguous_name (id);
8814 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
8815 /* 15.10.2: Accessing Superclass Members using super */
8816 return resolve_field_access (id, NULL, NULL);
8817 }
8818
8819 /* We've got an error here */
8820 parse_error_context (id, "Undefined variable `%s'",
8821 IDENTIFIER_POINTER (name));
8822
8823 return error_mark_node;
8824 }
8825
8826 static void
8827 static_ref_err (wfl, field_id, class_type)
8828 tree wfl, field_id, class_type;
8829 {
8830 parse_error_context
8831 (wfl,
8832 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
8833 IDENTIFIER_POINTER (field_id),
8834 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
8835 }
8836
8837 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
8838 We return something suitable to generate the field access. We also
8839 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
8840 recipient's address can be null. */
8841
8842 static tree
8843 resolve_field_access (qual_wfl, field_decl, field_type)
8844 tree qual_wfl;
8845 tree *field_decl, *field_type;
8846 {
8847 int is_static = 0;
8848 tree field_ref;
8849 tree decl, where_found, type_found;
8850
8851 if (resolve_qualified_expression_name (qual_wfl, &decl,
8852 &where_found, &type_found))
8853 return error_mark_node;
8854
8855 /* Resolve the LENGTH field of an array here */
8856 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
8857 && ! flag_emit_class_files && ! flag_emit_xref)
8858 {
8859 tree length = build_java_array_length_access (where_found);
8860 field_ref =
8861 build_java_arraynull_check (type_found, length, int_type_node);
8862 }
8863 /* We might have been trying to resolve field.method(). In which
8864 case, the resolution is over and decl is the answer */
8865 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
8866 field_ref = decl;
8867 else if (JDECL_P (decl))
8868 {
8869 int static_final_found = 0;
8870 if (!type_found)
8871 type_found = DECL_CONTEXT (decl);
8872 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
8873 if (FIELD_FINAL (decl)
8874 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
8875 && DECL_LANG_SPECIFIC (decl)
8876 && DECL_INITIAL (decl))
8877 {
8878 field_ref = DECL_INITIAL (decl);
8879 static_final_found = 1;
8880 }
8881 else
8882 field_ref = build_field_ref ((is_static && !flag_emit_xref?
8883 NULL_TREE : where_found),
8884 type_found, DECL_NAME (decl));
8885 if (field_ref == error_mark_node)
8886 return error_mark_node;
8887 if (is_static && !static_final_found
8888 && !flag_emit_class_files && !flag_emit_xref)
8889 {
8890 field_ref = build_class_init (type_found, field_ref);
8891 /* If the static field was identified by an expression that
8892 needs to be generated, make the field access a compound
8893 expression whose first part is the evaluation of the
8894 field selector part. */
8895 if (where_found && TREE_CODE (where_found) != TYPE_DECL
8896 && TREE_CODE (where_found) != RECORD_TYPE)
8897 {
8898 tree type = QUAL_DECL_TYPE (field_ref);
8899 field_ref = build (COMPOUND_EXPR, type, where_found, field_ref);
8900 }
8901 }
8902 }
8903 else
8904 field_ref = decl;
8905
8906 if (field_decl)
8907 *field_decl = decl;
8908 if (field_type)
8909 *field_type = (QUAL_DECL_TYPE (decl) ?
8910 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
8911 return field_ref;
8912 }
8913
8914 /* If NODE is an access to f static field, strip out the class
8915 initialization part and return the field decl, otherwise, return
8916 NODE. */
8917
8918 static tree
8919 strip_out_static_field_access_decl (node)
8920 tree node;
8921 {
8922 if (TREE_CODE (node) == COMPOUND_EXPR)
8923 {
8924 tree op1 = TREE_OPERAND (node, 1);
8925 if (TREE_CODE (op1) == COMPOUND_EXPR)
8926 {
8927 tree call = TREE_OPERAND (op1, 0);
8928 if (TREE_CODE (call) == CALL_EXPR
8929 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
8930 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
8931 == soft_initclass_node)
8932 return TREE_OPERAND (op1, 1);
8933 }
8934 }
8935 return node;
8936 }
8937
8938 /* 6.5.5.2: Qualified Expression Names */
8939
8940 static int
8941 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
8942 tree wfl;
8943 tree *found_decl, *type_found, *where_found;
8944 {
8945 int from_type = 0; /* Field search initiated from a type */
8946 int from_super = 0, from_cast = 0;
8947 int previous_call_static = 0;
8948 int is_static;
8949 tree decl = NULL_TREE, type = NULL_TREE, q;
8950 *type_found = *where_found = NULL_TREE;
8951
8952 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
8953 {
8954 tree qual_wfl = QUAL_WFL (q);
8955
8956 /* 15.10.1 Field Access Using a Primary */
8957 switch (TREE_CODE (qual_wfl))
8958 {
8959 case CALL_EXPR:
8960 case NEW_CLASS_EXPR:
8961 /* If the access to the function call is a non static field,
8962 build the code to access it. */
8963 if (JDECL_P (decl) && !FIELD_STATIC (decl))
8964 {
8965 decl = maybe_access_field (decl, *where_found,
8966 DECL_CONTEXT (decl));
8967 if (decl == error_mark_node)
8968 return 1;
8969 }
8970 /* And code for the function call */
8971 if (complete_function_arguments (qual_wfl))
8972 return 1;
8973 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
8974 CALL_USING_SUPER (qual_wfl) = 1;
8975 *where_found =
8976 patch_method_invocation (qual_wfl, decl, type, &is_static, NULL);
8977 if (*where_found == error_mark_node)
8978 return 1;
8979 *type_found = type = QUAL_DECL_TYPE (*where_found);
8980
8981 /* If the previous call was static and this one is too,
8982 build a compound expression to hold the two (because in
8983 that case, previous function calls aren't transported as
8984 forcoming function's argument. */
8985 if (previous_call_static && is_static)
8986 {
8987 decl = build (COMPOUND_EXPR, type, decl, *where_found);
8988 TREE_SIDE_EFFECTS (decl) = 1;
8989 }
8990 else
8991 {
8992 previous_call_static = is_static;
8993 decl = *where_found;
8994 }
8995 continue;
8996
8997 case NEW_ARRAY_EXPR:
8998 *where_found = decl = java_complete_tree (qual_wfl);
8999 if (decl == error_mark_node)
9000 return 1;
9001 *type_found = type = QUAL_DECL_TYPE (decl);
9002 CLASS_LOADED_P (type) = 1;
9003 continue;
9004
9005 case CONVERT_EXPR:
9006 *where_found = decl = java_complete_tree (qual_wfl);
9007 if (decl == error_mark_node)
9008 return 1;
9009 *type_found = type = QUAL_DECL_TYPE (decl);
9010 from_cast = 1;
9011 continue;
9012
9013 case CONDITIONAL_EXPR:
9014 case STRING_CST:
9015 *where_found = decl = java_complete_tree (qual_wfl);
9016 if (decl == error_mark_node)
9017 return 1;
9018 *type_found = type = QUAL_DECL_TYPE (decl);
9019 continue;
9020
9021 case ARRAY_REF:
9022 /* If the access to the function call is a non static field,
9023 build the code to access it. */
9024 if (JDECL_P (decl) && !FIELD_STATIC (decl))
9025 {
9026 decl = maybe_access_field (decl, *where_found, type);
9027 if (decl == error_mark_node)
9028 return 1;
9029 }
9030 /* And code for the array reference expression */
9031 decl = java_complete_tree (qual_wfl);
9032 if (decl == error_mark_node)
9033 return 1;
9034 type = QUAL_DECL_TYPE (decl);
9035 continue;
9036
9037 default:
9038 /* Fix for -Wall Just go to the next statement. Don't
9039 continue */
9040 break;
9041 }
9042
9043 /* If we fall here, we weren't processing a (static) function call. */
9044 previous_call_static = 0;
9045
9046 /* It can be the keyword THIS */
9047 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
9048 {
9049 if (!current_this)
9050 {
9051 parse_error_context
9052 (wfl, "Keyword `this' used outside allowed context");
9053 return 1;
9054 }
9055 /* We have to generate code for intermediate acess */
9056 *where_found = decl = current_this;
9057 *type_found = type = QUAL_DECL_TYPE (decl);
9058 continue;
9059 }
9060
9061 /* 15.10.2 Accessing Superclass Members using SUPER */
9062 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
9063 {
9064 tree node;
9065 /* Check on the restricted use of SUPER */
9066 if (METHOD_STATIC (current_function_decl)
9067 || current_class == object_type_node)
9068 {
9069 parse_error_context
9070 (wfl, "Keyword `super' used outside allowed context");
9071 return 1;
9072 }
9073 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
9074 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
9075 CLASSTYPE_SUPER (current_class),
9076 build_this (EXPR_WFL_LINECOL (qual_wfl)));
9077 *where_found = decl = java_complete_tree (node);
9078 if (decl == error_mark_node)
9079 return 1;
9080 *type_found = type = QUAL_DECL_TYPE (decl);
9081 from_super = from_type = 1;
9082 continue;
9083 }
9084
9085 /* 15.13.1: Can't search for field name in packages, so we
9086 assume a variable/class name was meant. */
9087 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
9088 {
9089 tree name = resolve_package (wfl, &q);
9090 if (name)
9091 {
9092 *where_found = decl = resolve_no_layout (name, qual_wfl);
9093 /* We wan't to be absolutely that the class is laid
9094 out. We're going to search something inside it. */
9095 *type_found = type = TREE_TYPE (decl);
9096 layout_class (type);
9097 from_type = 1;
9098 /* Should be a list, really. FIXME */
9099 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 1;
9100 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (TREE_CHAIN (q))) = 0;
9101 }
9102 else
9103 {
9104 if (from_super || from_cast)
9105 parse_error_context
9106 ((from_cast ? qual_wfl : wfl),
9107 "No variable `%s' defined in class `%s'",
9108 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9109 lang_printable_name (type, 0));
9110 else
9111 parse_error_context
9112 (qual_wfl, "Undefined variable or class name: `%s'",
9113 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
9114 return 1;
9115 }
9116 }
9117
9118 /* We have a type name. It's been already resolved when the
9119 expression was qualified. */
9120 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
9121 {
9122 if (!(decl = QUAL_RESOLUTION (q)))
9123 return 1; /* Error reported already */
9124
9125 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
9126 {
9127 parse_error_context
9128 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
9129 java_accstring_lookup (get_access_flags_from_decl (decl)),
9130 GET_TYPE_NAME (type),
9131 IDENTIFIER_POINTER (DECL_NAME (decl)),
9132 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9133 return 1;
9134 }
9135 check_deprecation (qual_wfl, decl);
9136
9137 type = TREE_TYPE (decl);
9138 from_type = 1;
9139 }
9140 /* We resolve and expression name */
9141 else
9142 {
9143 tree field_decl;
9144
9145 /* If there exists an early resolution, use it. That occurs
9146 only once and we know that there are more things to
9147 come. Don't do that when processing something after SUPER
9148 (we need more thing to be put in place below */
9149 if (!from_super && QUAL_RESOLUTION (q))
9150 {
9151 decl = QUAL_RESOLUTION (q);
9152 if (!type)
9153 {
9154 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
9155 {
9156 if (current_this)
9157 *where_found = current_this;
9158 else
9159 {
9160 static_ref_err (qual_wfl, DECL_NAME (decl),
9161 current_class);
9162 return 1;
9163 }
9164 }
9165 else
9166 {
9167 *where_found = TREE_TYPE (decl);
9168 if (TREE_CODE (*where_found) == POINTER_TYPE)
9169 *where_found = TREE_TYPE (*where_found);
9170 }
9171 }
9172 }
9173
9174 /* We have to search for a field, knowing the type of its
9175 container. The flag FROM_TYPE indicates that we resolved
9176 the last member of the expression as a type name, which
9177 means that for the resolution of this field, we'll look
9178 for other errors than if it was resolved as a member of
9179 an other field. */
9180 else
9181 {
9182 int is_static;
9183 tree field_decl_type; /* For layout */
9184
9185 if (!from_type && !JREFERENCE_TYPE_P (type))
9186 {
9187 parse_error_context
9188 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
9189 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9190 lang_printable_name (type, 0),
9191 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
9192 return 1;
9193 }
9194
9195 field_decl = lookup_field_wrapper (type,
9196 EXPR_WFL_NODE (qual_wfl));
9197 if (field_decl == NULL_TREE)
9198 {
9199 parse_error_context
9200 (qual_wfl, "No variable `%s' defined in type `%s'",
9201 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
9202 GET_TYPE_NAME (type));
9203 return 1;
9204 }
9205 if (field_decl == error_mark_node)
9206 return 1;
9207
9208 /* Layout the type of field_decl, since we may need
9209 it. Don't do primitive types or loaded classes. The
9210 situation of non primitive arrays may not handled
9211 properly here. FIXME */
9212 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
9213 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
9214 else
9215 field_decl_type = TREE_TYPE (field_decl);
9216 if (!JPRIMITIVE_TYPE_P (field_decl_type)
9217 && !CLASS_LOADED_P (field_decl_type)
9218 && !TYPE_ARRAY_P (field_decl_type))
9219 resolve_and_layout (field_decl_type, NULL_TREE);
9220 if (TYPE_ARRAY_P (field_decl_type))
9221 CLASS_LOADED_P (field_decl_type) = 1;
9222
9223 /* Check on accessibility here */
9224 if (not_accessible_p (type, field_decl, from_super))
9225 {
9226 parse_error_context
9227 (qual_wfl,
9228 "Can't access %s field `%s.%s' from `%s'",
9229 java_accstring_lookup
9230 (get_access_flags_from_decl (field_decl)),
9231 GET_TYPE_NAME (type),
9232 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
9233 IDENTIFIER_POINTER
9234 (DECL_NAME (TYPE_NAME (current_class))));
9235 return 1;
9236 }
9237 check_deprecation (qual_wfl, field_decl);
9238
9239 /* There are things to check when fields are accessed
9240 from type. There are no restrictions on a static
9241 declaration of the field when it is accessed from an
9242 interface */
9243 is_static = FIELD_STATIC (field_decl);
9244 if (!from_super && from_type
9245 && !TYPE_INTERFACE_P (type) && !is_static)
9246 {
9247 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
9248 return 1;
9249 }
9250 from_cast = from_super = 0;
9251
9252 /* If we need to generate something to get a proper
9253 handle on what this field is accessed from, do it
9254 now. */
9255 if (!is_static)
9256 {
9257 decl = maybe_access_field (decl, *where_found, *type_found);
9258 if (decl == error_mark_node)
9259 return 1;
9260 }
9261
9262 /* We want to keep the location were found it, and the type
9263 we found. */
9264 *where_found = decl;
9265 *type_found = type;
9266
9267 /* This is the decl found and eventually the next one to
9268 search from */
9269 decl = field_decl;
9270 }
9271 from_type = 0;
9272 type = QUAL_DECL_TYPE (decl);
9273 }
9274 }
9275 *found_decl = decl;
9276 return 0;
9277 }
9278
9279 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
9280 can't be accessed from REFERENCE (a record type). */
9281
9282 int not_accessible_p (reference, member, from_super)
9283 tree reference, member;
9284 int from_super;
9285 {
9286 int access_flag = get_access_flags_from_decl (member);
9287
9288 /* Access always granted for members declared public */
9289 if (access_flag & ACC_PUBLIC)
9290 return 0;
9291
9292 /* Check access on protected members */
9293 if (access_flag & ACC_PROTECTED)
9294 {
9295 /* Access granted if it occurs from within the package
9296 containing the class in which the protected member is
9297 declared */
9298 if (class_in_current_package (DECL_CONTEXT (member)))
9299 return 0;
9300
9301 /* If accessed with the form `super.member', then access is granted */
9302 if (from_super)
9303 return 0;
9304
9305 /* Otherwise, access is granted if occuring from the class where
9306 member is declared or a subclass of it */
9307 if (inherits_from_p (reference, current_class))
9308 return 0;
9309 return 1;
9310 }
9311
9312 /* Check access on private members. Access is granted only if it
9313 occurs from within the class in witch it is declared */
9314 if (access_flag & ACC_PRIVATE)
9315 return (current_class == DECL_CONTEXT (member) ? 0 : 1);
9316
9317 /* Default access are permitted only when occuring within the
9318 package in which the type (REFERENCE) is declared. In other words,
9319 REFERENCE is defined in the current package */
9320 if (ctxp->package)
9321 return !class_in_current_package (reference);
9322
9323 /* Otherwise, access is granted */
9324 return 0;
9325 }
9326
9327 /* Test deprecated decl access. */
9328 static void
9329 check_deprecation (wfl, decl)
9330 tree wfl, decl;
9331 {
9332 char *file = DECL_SOURCE_FILE (decl);
9333 /* Complain if the field is deprecated and the file it was defined
9334 in isn't compiled at the same time the file which contains its
9335 use is */
9336 if (DECL_DEPRECATED (decl)
9337 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
9338 {
9339 char the [20];
9340 switch (TREE_CODE (decl))
9341 {
9342 case FUNCTION_DECL:
9343 strcpy (the, "method");
9344 break;
9345 case FIELD_DECL:
9346 strcpy (the, "field");
9347 break;
9348 case TYPE_DECL:
9349 strcpy (the, "class");
9350 break;
9351 default:
9352 fatal ("unexpected DECL code - check_deprecation");
9353 }
9354 parse_warning_context
9355 (wfl, "The %s `%s' in class `%s' has been deprecated",
9356 the, lang_printable_name (decl, 0),
9357 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
9358 }
9359 }
9360
9361 /* Returns 1 if class was declared in the current package, 0 otherwise */
9362
9363 static int
9364 class_in_current_package (class)
9365 tree class;
9366 {
9367 static tree cache = NULL_TREE;
9368 int qualified_flag;
9369 tree left;
9370
9371 if (cache == class)
9372 return 1;
9373
9374 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
9375
9376 /* If the current package is empty and the name of CLASS is
9377 qualified, class isn't in the current package. If there is a
9378 current package and the name of the CLASS is not qualified, class
9379 isn't in the current package */
9380 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
9381 return 0;
9382
9383 /* If there is not package and the name of CLASS isn't qualified,
9384 they belong to the same unnamed package */
9385 if (!ctxp->package && !qualified_flag)
9386 return 1;
9387
9388 /* Compare the left part of the name of CLASS with the package name */
9389 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
9390 if (ctxp->package == left)
9391 {
9392 cache = class;
9393 return 1;
9394 }
9395 return 0;
9396 }
9397
9398 /* This function may generate code to access DECL from WHERE. This is
9399 done only if certain conditions meet. */
9400
9401 static tree
9402 maybe_access_field (decl, where, type)
9403 tree decl, where, type;
9404 {
9405 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
9406 && !FIELD_STATIC (decl))
9407 decl = build_field_ref (where ? where : current_this,
9408 (type ? type : DECL_CONTEXT (decl)),
9409 DECL_NAME (decl));
9410 return decl;
9411 }
9412
9413 /* Build a method invocation, by patching PATCH. If non NULL
9414 and according to the situation, PRIMARY and WHERE may be
9415 used. IS_STATIC is set to 1 if the invoked function is static. */
9416
9417 static tree
9418 patch_method_invocation (patch, primary, where, is_static, ret_decl)
9419 tree patch, primary, where;
9420 int *is_static;
9421 tree *ret_decl;
9422 {
9423 tree wfl = TREE_OPERAND (patch, 0);
9424 tree args = TREE_OPERAND (patch, 1);
9425 tree name = EXPR_WFL_NODE (wfl);
9426 tree list;
9427 int is_static_flag = 0;
9428 int is_super_init = 0;
9429 tree this_arg = NULL_TREE;
9430
9431 /* Should be overriden if everything goes well. Otherwise, if
9432 something fails, it should keep this value. It stop the
9433 evaluation of a bogus assignment. See java_complete_tree,
9434 MODIFY_EXPR: for the reasons why we sometimes want to keep on
9435 evaluating an assignment */
9436 TREE_TYPE (patch) = error_mark_node;
9437
9438 /* Since lookup functions are messing with line numbers, save the
9439 context now. */
9440 java_parser_context_save_global ();
9441
9442 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
9443
9444 /* Resolution of qualified name, excluding constructors */
9445 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
9446 {
9447 tree class_decl, identifier, identifier_wfl;
9448 /* Extract the last IDENTIFIER of the qualified
9449 expression. This is a wfl and we will use it's location
9450 data during error report. */
9451 identifier_wfl = cut_identifier_in_qualified (wfl);
9452 identifier = EXPR_WFL_NODE (identifier_wfl);
9453
9454 /* Given the context, IDENTIFIER is syntactically qualified
9455 as a MethodName. We need to qualify what's before */
9456 qualify_ambiguous_name (wfl);
9457
9458 /* Package resolution are erroneous */
9459 if (RESOLVE_PACKAGE_NAME_P (wfl))
9460 {
9461 tree remainder;
9462 breakdown_qualified (&remainder, NULL, EXPR_WFL_NODE (wfl));
9463 parse_error_context (wfl, "Can't search method `%s' in package "
9464 "`%s'",IDENTIFIER_POINTER (identifier),
9465 IDENTIFIER_POINTER (remainder));
9466 PATCH_METHOD_RETURN_ERROR ();
9467 }
9468 /* We're resolving a call from a type */
9469 else if (RESOLVE_TYPE_NAME_P (wfl))
9470 {
9471 tree decl = QUAL_RESOLUTION (EXPR_WFL_QUALIFICATION (wfl));
9472 tree name = DECL_NAME (decl);
9473 tree type;
9474
9475 class_decl = resolve_and_layout (name, wfl);
9476 if (CLASS_INTERFACE (decl))
9477 {
9478 parse_error_context
9479 (identifier_wfl, "Can't make static reference to method "
9480 "`%s' in interface `%s'", IDENTIFIER_POINTER (identifier),
9481 IDENTIFIER_POINTER (name));
9482 PATCH_METHOD_RETURN_ERROR ();
9483 }
9484 /* Look the method up in the type selector. The method ought
9485 to be static. */
9486 type = TREE_TYPE (class_decl);
9487 list = lookup_method_invoke (0, wfl, type, identifier, args);
9488 if (list && !METHOD_STATIC (list))
9489 {
9490 char *fct_name = strdup (lang_printable_name (list, 0));
9491 parse_error_context
9492 (identifier_wfl,
9493 "Can't make static reference to method `%s %s' in class `%s'",
9494 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
9495 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
9496 free (fct_name);
9497 PATCH_METHOD_RETURN_ERROR ();
9498 }
9499 args = nreverse (args);
9500 }
9501 /* We're resolving an expression name */
9502 else
9503 {
9504 tree field, type;
9505
9506 /* 1- Find the field to which the call applies */
9507 field = resolve_field_access (wfl, NULL, &type);
9508 if (field == error_mark_node)
9509 PATCH_METHOD_RETURN_ERROR ();
9510 /* field is used in lieu of a primary. It alows us not to
9511 report errors on erroneous use of `this' in
9512 constructors. */
9513 primary = field;
9514
9515 /* 2- Do the layout of the class where the last field
9516 was found, so we can search it. */
9517 class_decl = resolve_and_layout (type, NULL_TREE);
9518 if (class_decl != NULL_TREE)
9519 type = TREE_TYPE (class_decl);
9520
9521 /* 3- Retrieve a filtered list of method matches, Refine
9522 if necessary. In any cases, point out errors. */
9523 list = lookup_method_invoke (0, identifier_wfl, type,
9524 identifier, args);
9525
9526 /* 4- Add the field as an argument */
9527 args = nreverse (args);
9528 this_arg = field;
9529 }
9530
9531 /* IDENTIFIER_WFL will be used to report any problem further */
9532 wfl = identifier_wfl;
9533 }
9534 /* Resolution of simple names, names generated after a primary: or
9535 constructors */
9536 else
9537 {
9538 tree class_to_search;
9539 int lc; /* Looking for Constructor */
9540
9541 /* We search constructor in their target class */
9542 if (CALL_CONSTRUCTOR_P (patch))
9543 {
9544 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9545 class_to_search = EXPR_WFL_NODE (wfl);
9546 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
9547 this_identifier_node)
9548 class_to_search = NULL_TREE;
9549 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
9550 super_identifier_node)
9551 {
9552 is_super_init = 1;
9553 if (CLASSTYPE_SUPER (current_class))
9554 class_to_search =
9555 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
9556 else
9557 {
9558 parse_error_context (wfl, "Can't invoke super constructor "
9559 "on java.lang.Object");
9560 PATCH_METHOD_RETURN_ERROR ();
9561 }
9562 }
9563
9564 /* Class to search is NULL if we're searching the current one */
9565 if (class_to_search)
9566 {
9567 class_to_search = resolve_and_layout (class_to_search,
9568 NULL_TREE);
9569 if (!class_to_search)
9570 {
9571 parse_error_context
9572 (wfl, "Class `%s' not found in type declaration",
9573 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9574 PATCH_METHOD_RETURN_ERROR ();
9575 }
9576
9577 /* Can't instantiate an abstract class, but we can
9578 invoke it's constructor. It's use within the `new'
9579 context is denied here. */
9580 if (CLASS_ABSTRACT (class_to_search)
9581 && TREE_CODE (patch) == NEW_CLASS_EXPR)
9582 {
9583 parse_error_context
9584 (wfl, "Class `%s' is an abstract class. It can't be "
9585 "instantiated", IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
9586 PATCH_METHOD_RETURN_ERROR ();
9587 }
9588 class_to_search = TREE_TYPE (class_to_search);
9589 }
9590 else
9591 class_to_search = current_class;
9592 lc = 1;
9593 }
9594 /* This is a regular search in the local class, unless an
9595 alternate class is specified. */
9596 else
9597 {
9598 class_to_search = (where ? where : current_class);
9599 lc = 0;
9600 }
9601
9602 /* NAME is a simple identifier or comes from a primary. Search
9603 in the class whose declaration contain the method being
9604 invoked. */
9605 resolve_and_layout (class_to_search, NULL_TREE);
9606 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
9607
9608 /* Don't continue if no method were found, as the next statement
9609 can't be executed then. */
9610 if (!list)
9611 PATCH_METHOD_RETURN_ERROR ();
9612
9613 /* Check for static reference if non static methods */
9614 if (check_for_static_method_reference (wfl, patch, list,
9615 class_to_search, primary))
9616 PATCH_METHOD_RETURN_ERROR ();
9617
9618 /* Non static methods are called with the current object extra
9619 argument. If patch a `new TYPE()', the argument is the value
9620 returned by the object allocator. If method is resolved as a
9621 primary, use the primary otherwise use the current THIS. */
9622 args = nreverse (args);
9623 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
9624 this_arg = primary ? primary : current_this;
9625 }
9626
9627 /* Merge point of all resolution schemes. If we have nothing, this
9628 is an error, already signaled */
9629 if (!list)
9630 PATCH_METHOD_RETURN_ERROR ();
9631
9632 /* Check accessibility, position the is_static flag, build and
9633 return the call */
9634 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
9635 {
9636 char *fct_name = strdup (lang_printable_name (list, 0));
9637 parse_error_context
9638 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
9639 java_accstring_lookup (get_access_flags_from_decl (list)),
9640 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
9641 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
9642 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
9643 free (fct_name);
9644 PATCH_METHOD_RETURN_ERROR ();
9645 }
9646 check_deprecation (wfl, list);
9647
9648 is_static_flag = METHOD_STATIC (list);
9649 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
9650 args = tree_cons (NULL_TREE, this_arg, args);
9651
9652 /* In the context of an explicit constructor invocation, we can't
9653 invoke any method relying on `this'. Exceptions are: we're
9654 invoking a static function, primary exists and is not the current
9655 this, we're creating a new object. */
9656 if (ctxp->explicit_constructor_p
9657 && !is_static_flag
9658 && (!primary || primary == current_this)
9659 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
9660 {
9661 parse_error_context
9662 (wfl, "Can't reference `this' before the superclass constructor has "
9663 "been called");
9664 PATCH_METHOD_RETURN_ERROR ();
9665 }
9666 java_parser_context_restore_global ();
9667 if (is_static)
9668 *is_static = is_static_flag;
9669 /* Sometimes, we want the decl of the selected method. Such as for
9670 EH checking */
9671 if (ret_decl)
9672 *ret_decl = list;
9673 patch = patch_invoke (patch, list, args);
9674 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
9675 {
9676 /* Generate the code used to initialize fields declared with an
9677 initialization statement. For now, it returns a call the the
9678 artificial function $finit$, if required. */
9679
9680 tree finit_call =
9681 build_method_invocation (build_expr_wfl (finit_identifier_node,
9682 input_filename, 0, 0),
9683 NULL_TREE);
9684 patch = build (COMPOUND_EXPR, void_type_node, patch,
9685 java_complete_tree (finit_call));
9686 CAN_COMPLETE_NORMALLY (patch) = 1;
9687 }
9688 return patch;
9689 }
9690
9691 /* Check that we're not trying to do a static reference to a method in
9692 non static method. Return 1 if it's the case, 0 otherwise. */
9693
9694 static int
9695 check_for_static_method_reference (wfl, node, method, where, primary)
9696 tree wfl, node, method, where, primary;
9697 {
9698 if (METHOD_STATIC (current_function_decl)
9699 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
9700 {
9701 char *fct_name = strdup (lang_printable_name (method, 0));
9702 parse_error_context
9703 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
9704 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
9705 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
9706 free (fct_name);
9707 return 1;
9708 }
9709 return 0;
9710 }
9711
9712 /* Patch an invoke expression METHOD and ARGS, based on its invocation
9713 mode. */
9714
9715 static tree
9716 patch_invoke (patch, method, args)
9717 tree patch, method, args;
9718 {
9719 tree dtable, func;
9720 tree original_call, t, ta;
9721
9722 /* Last step for args: convert build-in types. If we're dealing with
9723 a new TYPE() type call, the first argument to the constructor
9724 isn't found in the incomming argument list, but delivered by
9725 `new' */
9726 t = TYPE_ARG_TYPES (TREE_TYPE (method));
9727 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
9728 t = TREE_CHAIN (t);
9729 for (ta = args; t != end_params_node && ta;
9730 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
9731 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
9732 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
9733 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
9734
9735 if (flag_emit_class_files || flag_emit_xref)
9736 func = method;
9737 else
9738 {
9739 tree signature = build_java_signature (TREE_TYPE (method));
9740 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
9741 {
9742 case INVOKE_VIRTUAL:
9743 dtable = invoke_build_dtable (0, args);
9744 func = build_invokevirtual (dtable, method);
9745 break;
9746
9747 case INVOKE_SUPER:
9748 case INVOKE_STATIC:
9749 func = build_known_method_ref (method, TREE_TYPE (method),
9750 DECL_CONTEXT (method),
9751 signature, args);
9752 break;
9753
9754 case INVOKE_INTERFACE:
9755 dtable = invoke_build_dtable (1, args);
9756 func = build_invokeinterface (dtable, DECL_NAME (method), signature);
9757 break;
9758
9759 default:
9760 fatal ("internal error - unknown invocation_mode result");
9761 }
9762
9763 /* Ensure self_type is initialized, (invokestatic). FIXME */
9764 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
9765 }
9766
9767 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
9768 TREE_OPERAND (patch, 0) = func;
9769 TREE_OPERAND (patch, 1) = args;
9770 original_call = patch;
9771
9772 /* We're processing a `new TYPE ()' form. New is called an its
9773 returned value is the first argument to the constructor. We build
9774 a COMPOUND_EXPR and use saved expression so that the overall NEW
9775 expression value is a pointer to a newly created and initialized
9776 class. */
9777 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
9778 {
9779 tree class = DECL_CONTEXT (method);
9780 tree c1, saved_new, size, new;
9781 if (flag_emit_class_files || flag_emit_xref)
9782 {
9783 TREE_TYPE (patch) = build_pointer_type (class);
9784 return patch;
9785 }
9786 if (!TYPE_SIZE (class))
9787 safe_layout_class (class);
9788 size = size_in_bytes (class);
9789 new = build (CALL_EXPR, promote_type (class),
9790 build_address_of (alloc_object_node),
9791 tree_cons (NULL_TREE, build_class_ref (class),
9792 build_tree_list (NULL_TREE,
9793 size_in_bytes (class))),
9794 NULL_TREE);
9795 saved_new = save_expr (new);
9796 c1 = build_tree_list (NULL_TREE, saved_new);
9797 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
9798 TREE_OPERAND (original_call, 1) = c1;
9799 TREE_SET_CODE (original_call, CALL_EXPR);
9800 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
9801 }
9802 return patch;
9803 }
9804
9805 static int
9806 invocation_mode (method, super)
9807 tree method;
9808 int super;
9809 {
9810 int access = get_access_flags_from_decl (method);
9811
9812 if (super)
9813 return INVOKE_SUPER;
9814
9815 if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
9816 return INVOKE_STATIC;
9817
9818 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
9819 return INVOKE_STATIC;
9820
9821 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
9822 return INVOKE_INTERFACE;
9823
9824 if (DECL_CONSTRUCTOR_P (method))
9825 return INVOKE_STATIC;
9826
9827 return INVOKE_VIRTUAL;
9828 }
9829
9830 /* Retrieve a refined list of matching methods. It covers the step
9831 15.11.2 (Compile-Time Step 2) */
9832
9833 static tree
9834 lookup_method_invoke (lc, cl, class, name, arg_list)
9835 int lc;
9836 tree cl;
9837 tree class, name, arg_list;
9838 {
9839 tree atl = end_params_node; /* Arg Type List */
9840 tree method, signature, list, node;
9841 char *candidates; /* Used for error report */
9842
9843 /* Fix the arguments */
9844 for (node = arg_list; node; node = TREE_CHAIN (node))
9845 {
9846 tree current_arg = TREE_TYPE (TREE_VALUE (node));
9847 /* Non primitive type may have to be resolved */
9848 if (!JPRIMITIVE_TYPE_P (current_arg))
9849 resolve_and_layout (current_arg, NULL_TREE);
9850 /* And promoted */
9851 if (TREE_CODE (current_arg) == RECORD_TYPE)
9852 current_arg = promote_type (current_arg);
9853 atl = tree_cons (NULL_TREE, current_arg, atl);
9854 }
9855
9856 /* Find all candidates and then refine the list, searching for the
9857 most specific method. */
9858 list = find_applicable_accessible_methods_list (lc, class, name, atl);
9859 list = find_most_specific_methods_list (list);
9860 if (list && !TREE_CHAIN (list))
9861 return TREE_VALUE (list);
9862
9863 /* Issue an error. List candidates if any. Candidates are listed
9864 only if accessible (non accessible methods may end-up here for
9865 the sake of a better error report). */
9866 candidates = NULL;
9867 if (list)
9868 {
9869 tree current;
9870 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
9871 for (current = list; current; current = TREE_CHAIN (current))
9872 {
9873 tree cm = TREE_VALUE (current);
9874 char string [4096];
9875 if (!cm || not_accessible_p (class, cm, 0))
9876 continue;
9877 sprintf
9878 (string, " `%s' in `%s'%s",
9879 get_printable_method_name (cm),
9880 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
9881 (TREE_CHAIN (current) ? "\n" : ""));
9882 obstack_grow (&temporary_obstack, string, strlen (string));
9883 }
9884 obstack_1grow (&temporary_obstack, '\0');
9885 candidates = obstack_finish (&temporary_obstack);
9886 }
9887 /* Issue the error message */
9888 method = make_node (FUNCTION_TYPE);
9889 TYPE_ARG_TYPES (method) = atl;
9890 signature = build_java_argument_signature (method);
9891 parse_error_context (cl, "Can't find %s `%s(%s)' in class `%s'%s",
9892 (lc ? "constructor" : "method"),
9893 (lc ?
9894 IDENTIFIER_POINTER(DECL_NAME (TYPE_NAME (class))) :
9895 IDENTIFIER_POINTER (name)),
9896 IDENTIFIER_POINTER (signature),
9897 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class))),
9898 (candidates ? candidates : ""));
9899 return NULL_TREE;
9900 }
9901
9902 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
9903 when we're looking for a constructor. */
9904
9905 static tree
9906 find_applicable_accessible_methods_list (lc, class, name, arglist)
9907 int lc;
9908 tree class, name, arglist;
9909 {
9910 tree list = NULL_TREE, all_list = NULL_TREE;
9911
9912 /* Search interfaces */
9913 if (CLASS_INTERFACE (TYPE_NAME (class)))
9914 {
9915 static tree searched_interfaces = NULL_TREE;
9916 static int search_not_done = 0;
9917 int i, n;
9918 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
9919
9920 /* Have we searched this interface already? */
9921 if (searched_interfaces)
9922 {
9923 tree current;
9924 for (current = searched_interfaces;
9925 current; current = TREE_CHAIN (current))
9926 if (TREE_VALUE (current) == class)
9927 return NULL;
9928 }
9929 searched_interfaces = tree_cons (NULL_TREE, class, searched_interfaces);
9930
9931 search_applicable_methods_list
9932 (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
9933
9934 n = TREE_VEC_LENGTH (basetype_vec);
9935 for (i = 0; i < n; i++)
9936 {
9937 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
9938 tree rlist;
9939
9940 /* Skip java.lang.Object (we'll search it once later.) */
9941 if (t == object_type_node)
9942 continue;
9943
9944 search_not_done++;
9945 rlist = find_applicable_accessible_methods_list (lc, t, name,
9946 arglist);
9947 all_list = chainon (rlist, (list ? list : all_list));
9948 search_not_done--;
9949 }
9950
9951 /* We're done. Reset the searched interfaces list and finally search
9952 java.lang.Object */
9953 if (!search_not_done)
9954 {
9955 searched_interfaces = NULL_TREE;
9956 search_applicable_methods_list (lc, TYPE_METHODS (object_type_node),
9957 name, arglist, &list, &all_list);
9958 }
9959 }
9960 /* Search classes */
9961 else
9962 while (class != NULL_TREE)
9963 {
9964 search_applicable_methods_list
9965 (lc, TYPE_METHODS (class), name, arglist, &list, &all_list);
9966 class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
9967 }
9968
9969 /* Either return the list obtained or all selected (but
9970 inaccessible) methods for better error report. */
9971 return (!list ? all_list : list);
9972 }
9973
9974 /* Effectively search for the approriate method in method */
9975
9976 static void
9977 search_applicable_methods_list(lc, method, name, arglist, list, all_list)
9978 int lc;
9979 tree method, name, arglist;
9980 tree *list, *all_list;
9981 {
9982 for (; method; method = TREE_CHAIN (method))
9983 {
9984 /* When dealing with constructor, stop here, otherwise search
9985 other classes */
9986 if (lc && !DECL_CONSTRUCTOR_P (method))
9987 continue;
9988 else if (!lc && (DECL_CONSTRUCTOR_P (method)
9989 || (GET_METHOD_NAME (method) != name)))
9990 continue;
9991
9992 if (argument_types_convertible (method, arglist))
9993 {
9994 /* Retain accessible methods only */
9995 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
9996 method, 0))
9997 *list = tree_cons (NULL_TREE, method, *list);
9998 else
9999 /* Also retain all selected method here */
10000 *all_list = tree_cons (NULL_TREE, method, *list);
10001 }
10002 }
10003 }
10004
10005 /* 15.11.2.2 Choose the Most Specific Method */
10006
10007 static tree
10008 find_most_specific_methods_list (list)
10009 tree list;
10010 {
10011 int max = 0;
10012 tree current, new_list = NULL_TREE;
10013 for (current = list; current; current = TREE_CHAIN (current))
10014 {
10015 tree method;
10016 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
10017
10018 for (method = list; method; method = TREE_CHAIN (method))
10019 {
10020 /* Don't test a method against itself */
10021 if (method == current)
10022 continue;
10023
10024 /* Compare arguments and location where method where declared */
10025 if (argument_types_convertible (TREE_VALUE (method),
10026 TREE_VALUE (current))
10027 && valid_method_invocation_conversion_p
10028 (DECL_CONTEXT (TREE_VALUE (method)),
10029 DECL_CONTEXT (TREE_VALUE (current))))
10030 {
10031 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
10032 max = (v > max ? v : max);
10033 }
10034 }
10035 }
10036
10037 /* Review the list and select the maximally specific methods */
10038 for (current = list; current; current = TREE_CHAIN (current))
10039 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10040 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10041
10042 /* If we can't find one, lower expectations and try to gather multiple
10043 maximally specific methods */
10044 while (!new_list)
10045 {
10046 while (--max > 0)
10047 {
10048 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
10049 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
10050 }
10051 return new_list;
10052 }
10053
10054 return new_list;
10055 }
10056
10057 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
10058 converted by method invocation conversion (5.3) to the type of the
10059 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
10060 to change less often than M1. */
10061
10062 static int
10063 argument_types_convertible (m1, m2_or_arglist)
10064 tree m1, m2_or_arglist;
10065 {
10066 static tree m2_arg_value = NULL_TREE;
10067 static tree m2_arg_cache = NULL_TREE;
10068
10069 register tree m1_arg, m2_arg;
10070
10071 m1_arg = TYPE_ARG_TYPES (TREE_TYPE (m1));
10072 if (!METHOD_STATIC (m1))
10073 m1_arg = TREE_CHAIN (m1_arg);
10074
10075 if (m2_arg_value == m2_or_arglist)
10076 m2_arg = m2_arg_cache;
10077 else
10078 {
10079 /* M2_OR_ARGLIST can be a function DECL or a raw list of
10080 argument types */
10081 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
10082 {
10083 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
10084 if (!METHOD_STATIC (m2_or_arglist))
10085 m2_arg = TREE_CHAIN (m2_arg);
10086 }
10087 else
10088 m2_arg = m2_or_arglist;
10089
10090 m2_arg_value = m2_or_arglist;
10091 m2_arg_cache = m2_arg;
10092 }
10093
10094 while (m1_arg != end_params_node && m2_arg != end_params_node)
10095 {
10096 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
10097 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
10098 TREE_VALUE (m2_arg)))
10099 break;
10100 m1_arg = TREE_CHAIN (m1_arg);
10101 m2_arg = TREE_CHAIN (m2_arg);
10102 }
10103 return m1_arg == end_params_node && m2_arg == end_params_node;
10104 }
10105
10106 /* Qualification routines */
10107
10108 static void
10109 qualify_ambiguous_name (id)
10110 tree id;
10111 {
10112 tree qual, qual_wfl, name, decl, ptr_type, saved_current_class;
10113 int again, super_found = 0, this_found = 0, new_array_found = 0;
10114
10115 /* We first qualify the first element, then derive qualification of
10116 others based on the first one. If the first element is qualified
10117 by a resolution (field or type), this resolution is stored in the
10118 QUAL_RESOLUTION of the qual element being examined. We need to
10119 save the current_class since the use of SUPER might change the
10120 its value. */
10121 saved_current_class = current_class;
10122 qual = EXPR_WFL_QUALIFICATION (id);
10123 do {
10124
10125 /* Simple qualified expression feature a qual_wfl that is a
10126 WFL. Expression derived from a primary feature more complicated
10127 things like a CALL_EXPR. Expression from primary need to be
10128 worked out to extract the part on which the qualification will
10129 take place. */
10130 qual_wfl = QUAL_WFL (qual);
10131 switch (TREE_CODE (qual_wfl))
10132 {
10133 case CALL_EXPR:
10134 qual_wfl = TREE_OPERAND (qual_wfl, 0);
10135 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
10136 {
10137 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
10138 qual_wfl = QUAL_WFL (qual);
10139 }
10140 break;
10141 case NEW_ARRAY_EXPR:
10142 qual = TREE_CHAIN (qual);
10143 new_array_found = again = 1;
10144 continue;
10145 case NEW_CLASS_EXPR:
10146 case CONVERT_EXPR:
10147 qual_wfl = TREE_OPERAND (qual_wfl, 0);
10148 break;
10149 case ARRAY_REF:
10150 while (TREE_CODE (qual_wfl) == ARRAY_REF)
10151 qual_wfl = TREE_OPERAND (qual_wfl, 0);
10152 break;
10153 default:
10154 /* Fix for -Wall. Just break doing nothing */
10155 break;
10156 }
10157 name = EXPR_WFL_NODE (qual_wfl);
10158 ptr_type = current_class;
10159 again = 0;
10160 /* If we have a THIS (from a primary), we set the context accordingly */
10161 if (name == this_identifier_node)
10162 {
10163 qual = TREE_CHAIN (qual);
10164 qual_wfl = QUAL_WFL (qual);
10165 if (TREE_CODE (qual_wfl) == CALL_EXPR)
10166 again = 1;
10167 else
10168 name = EXPR_WFL_NODE (qual_wfl);
10169 this_found = 1;
10170 }
10171 /* If we have a SUPER, we set the context accordingly */
10172 if (name == super_identifier_node)
10173 {
10174 current_class = CLASSTYPE_SUPER (ptr_type);
10175 /* Check that there is such a thing as a super class. If not,
10176 return. The error will be caught later on, during the
10177 resolution */
10178 if (!current_class)
10179 {
10180 current_class = saved_current_class;
10181 return;
10182 }
10183 qual = TREE_CHAIN (qual);
10184 /* Do one more interation to set things up */
10185 super_found = again = 1;
10186 }
10187 /* Loop one more time if we're dealing with ?: or a string
10188 constant, or a convert expression */
10189 if (TREE_CODE (qual_wfl) == CONDITIONAL_EXPR
10190 || TREE_CODE (qual_wfl) == STRING_CST
10191 || TREE_CODE (qual_wfl) == CONVERT_EXPR)
10192 {
10193 qual = TREE_CHAIN (qual);
10194 qual_wfl = QUAL_WFL (qual);
10195 again = 1;
10196 }
10197 } while (again);
10198
10199 /* If name appears within the scope of a location variable
10200 declaration or parameter declaration, then it is an expression
10201 name. We don't carry this test out if we're in the context of the
10202 use of SUPER or THIS */
10203 if (!this_found && !super_found && (decl = IDENTIFIER_LOCAL_VALUE (name)))
10204 {
10205 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10206 QUAL_RESOLUTION (qual) = decl;
10207 }
10208
10209 /* If within the class/interface NAME was found to be used there
10210 exists a (possibly inherited) field named NAME, then this is an
10211 expression name. If we saw a NEW_ARRAY_EXPR before and want to
10212 address length, it is OK. */
10213 else if ((decl = lookup_field_wrapper (ptr_type, name))
10214 || (new_array_found && name == length_identifier_node))
10215 {
10216 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10217 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
10218 }
10219
10220 /* We reclassify NAME as a type name if:
10221 - NAME is a class/interface declared within the compilation
10222 unit containing NAME,
10223 - NAME is imported via a single-type-import declaration,
10224 - NAME is declared in an another compilation unit of the package
10225 of the compilation unit containing NAME,
10226 - NAME is declared by exactly on type-import-on-demand declaration
10227 of the compilation unit containing NAME. */
10228 else if ((decl = resolve_and_layout (name, NULL_TREE)))
10229 {
10230 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
10231 QUAL_RESOLUTION (qual) = decl;
10232 }
10233
10234 /* Method call are expression name */
10235 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
10236 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF)
10237 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
10238
10239 /* Check here that NAME isn't declared by more than one
10240 type-import-on-demand declaration of the compilation unit
10241 containing NAME. FIXME */
10242
10243 /* Otherwise, NAME is reclassified as a package name */
10244 else
10245 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
10246
10247 /* Propagate the qualification accross other components of the
10248 qualified name */
10249 for (qual = TREE_CHAIN (qual); qual;
10250 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
10251 {
10252 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10253 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
10254 else
10255 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
10256 }
10257
10258 /* Store the global qualification for the ambiguous part of ID back
10259 into ID fields */
10260 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
10261 RESOLVE_EXPRESSION_NAME_P (id) = 1;
10262 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
10263 RESOLVE_TYPE_NAME_P (id) = 1;
10264 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
10265 RESOLVE_PACKAGE_NAME_P (id) = 1;
10266
10267 /* Restore the current class */
10268 current_class = saved_current_class;
10269 }
10270
10271 static int
10272 breakdown_qualified (left, right, source)
10273 tree *left, *right, source;
10274 {
10275 char *p = IDENTIFIER_POINTER (source), *base;
10276 int l = IDENTIFIER_LENGTH (source);
10277
10278 /* Breakdown NAME into REMAINDER . IDENTIFIER */
10279 base = p;
10280 p += (l-1);
10281 while (*p != '.' && p != base)
10282 p--;
10283
10284 /* We didn't find a '.'. Return an error */
10285 if (p == base)
10286 return 1;
10287
10288 *p = '\0';
10289 if (right)
10290 *right = get_identifier (p+1);
10291 *left = get_identifier (IDENTIFIER_POINTER (source));
10292 *p = '.';
10293
10294 return 0;
10295 }
10296
10297 /* Patch tree nodes in a function body. When a BLOCK is found, push
10298 local variable decls if present.
10299 Same as java_complete_lhs, but does resolve static finals to values. */
10300
10301 static tree
10302 java_complete_tree (node)
10303 tree node;
10304 {
10305 node = java_complete_lhs (node);
10306 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
10307 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
10308 && !flag_emit_xref)
10309 {
10310 tree value = DECL_INITIAL (node);
10311 DECL_INITIAL (node) = NULL_TREE;
10312 value = fold_constant_for_init (value, node);
10313 DECL_INITIAL (node) = value;
10314 if (value != NULL_TREE)
10315 return value;
10316 }
10317 return node;
10318 }
10319
10320 static tree
10321 java_stabilize_reference (node)
10322 tree node;
10323 {
10324 if (TREE_CODE (node) == COMPOUND_EXPR)
10325 {
10326 tree op0 = TREE_OPERAND (node, 0);
10327 tree op1 = TREE_OPERAND (node, 1);
10328 TREE_OPERAND (node, 0) = save_expr (op0);
10329 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
10330 return node;
10331 }
10332 else
10333 return stabilize_reference (node);
10334 }
10335
10336 /* Patch tree nodes in a function body. When a BLOCK is found, push
10337 local variable decls if present.
10338 Same as java_complete_tree, but does not resolve static finals to values. */
10339
10340 static tree
10341 java_complete_lhs (node)
10342 tree node;
10343 {
10344 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
10345 int flag;
10346
10347 /* CONVERT_EXPR always has its type set, even though it needs to be
10348 worked out. */
10349 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
10350 return node;
10351
10352 /* The switch block implements cases processing container nodes
10353 first. Contained nodes are always written back. Leaves come
10354 next and return a value. */
10355 switch (TREE_CODE (node))
10356 {
10357 case BLOCK:
10358
10359 /* 1- Block section.
10360 Set the local values on decl names so we can identify them
10361 faster when they're referenced. At that stage, identifiers
10362 are legal so we don't check for declaration errors. */
10363 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10364 {
10365 DECL_CONTEXT (cn) = current_function_decl;
10366 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
10367 }
10368 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
10369 CAN_COMPLETE_NORMALLY (node) = 1;
10370 else
10371 {
10372 tree stmt = BLOCK_EXPR_BODY (node);
10373 tree *ptr;
10374 int error_seen = 0;
10375 if (TREE_CODE (stmt) == COMPOUND_EXPR)
10376 {
10377 /* Re-order from (((A; B); C); ...; Z) to
10378 (A; (B; (C ; (...; Z)))).
10379 This makes it easier to scan the statements left-to-right
10380 without using recursion (which might overflow the stack
10381 if the block has many statements. */
10382 for (;;)
10383 {
10384 tree left = TREE_OPERAND (stmt, 0);
10385 if (TREE_CODE (left) != COMPOUND_EXPR)
10386 break;
10387 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
10388 TREE_OPERAND (left, 1) = stmt;
10389 stmt = left;
10390 }
10391 BLOCK_EXPR_BODY (node) = stmt;
10392 }
10393
10394 /* Now do the actual complete, without deep recursion for
10395 long blocks. */
10396 ptr = &BLOCK_EXPR_BODY (node);
10397 while (TREE_CODE (*ptr) == COMPOUND_EXPR
10398 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
10399 {
10400 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
10401 tree *next = &TREE_OPERAND (*ptr, 1);
10402 TREE_OPERAND (*ptr, 0) = cur;
10403 if (cur == empty_stmt_node)
10404 {
10405 /* Optimization; makes it easier to detect empty bodies.
10406 Most useful for <clinit> with all-constant initializer. */
10407 *ptr = *next;
10408 continue;
10409 }
10410 if (TREE_CODE (cur) == ERROR_MARK)
10411 error_seen++;
10412 else if (! CAN_COMPLETE_NORMALLY (cur))
10413 {
10414 wfl_op2 = *next;
10415 for (;;)
10416 {
10417 if (TREE_CODE (wfl_op2) == BLOCK)
10418 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
10419 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
10420 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
10421 else
10422 break;
10423 }
10424 if (TREE_CODE (wfl_op2) != CASE_EXPR
10425 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
10426 unreachable_stmt_error (*ptr);
10427 }
10428 ptr = next;
10429 }
10430 *ptr = java_complete_tree (*ptr);
10431
10432 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
10433 return error_mark_node;
10434 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
10435 }
10436 /* Turn local bindings to null */
10437 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
10438 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
10439
10440 TREE_TYPE (node) = void_type_node;
10441 break;
10442
10443 /* 2- They are expressions but ultimately deal with statements */
10444
10445 case THROW_EXPR:
10446 wfl_op1 = TREE_OPERAND (node, 0);
10447 COMPLETE_CHECK_OP_0 (node);
10448 /* CAN_COMPLETE_NORMALLY (node) = 0; */
10449 return patch_throw_statement (node, wfl_op1);
10450
10451 case SYNCHRONIZED_EXPR:
10452 wfl_op1 = TREE_OPERAND (node, 0);
10453 return patch_synchronized_statement (node, wfl_op1);
10454
10455 case TRY_EXPR:
10456 return patch_try_statement (node);
10457
10458 case TRY_FINALLY_EXPR:
10459 COMPLETE_CHECK_OP_0 (node);
10460 COMPLETE_CHECK_OP_1 (node);
10461 CAN_COMPLETE_NORMALLY (node)
10462 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
10463 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
10464 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
10465 return node;
10466
10467 case CLEANUP_POINT_EXPR:
10468 COMPLETE_CHECK_OP_0 (node);
10469 TREE_TYPE (node) = void_type_node;
10470 CAN_COMPLETE_NORMALLY (node) =
10471 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10472 return node;
10473
10474 case WITH_CLEANUP_EXPR:
10475 COMPLETE_CHECK_OP_0 (node);
10476 COMPLETE_CHECK_OP_2 (node);
10477 CAN_COMPLETE_NORMALLY (node) =
10478 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
10479 TREE_TYPE (node) = void_type_node;
10480 return node;
10481
10482 case LABELED_BLOCK_EXPR:
10483 PUSH_LABELED_BLOCK (node);
10484 if (LABELED_BLOCK_BODY (node))
10485 COMPLETE_CHECK_OP_1 (node);
10486 TREE_TYPE (node) = void_type_node;
10487 POP_LABELED_BLOCK ();
10488
10489 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
10490 {
10491 LABELED_BLOCK_BODY (node) = NULL_TREE;
10492 CAN_COMPLETE_NORMALLY (node) = 1;
10493 }
10494 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
10495 CAN_COMPLETE_NORMALLY (node) = 1;
10496 return node;
10497
10498 case EXIT_BLOCK_EXPR:
10499 /* We don't complete operand 1, because it's the return value of
10500 the EXIT_BLOCK_EXPR which doesn't exist it Java */
10501 return patch_bc_statement (node);
10502
10503 case CASE_EXPR:
10504 cn = java_complete_tree (TREE_OPERAND (node, 0));
10505 if (cn == error_mark_node)
10506 return cn;
10507
10508 /* First, the case expression must be constant */
10509 cn = fold (cn);
10510
10511 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
10512 {
10513 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10514 parse_error_context (node, "Constant expression required");
10515 return error_mark_node;
10516 }
10517
10518 nn = ctxp->current_loop;
10519
10520 /* It must be assignable to the type of the switch expression. */
10521 if (!try_builtin_assignconv (NULL_TREE,
10522 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
10523 {
10524 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10525 parse_error_context
10526 (wfl_operator,
10527 "Incompatible type for case. Can't convert `%s' to `int'",
10528 lang_printable_name (TREE_TYPE (cn), 0));
10529 return error_mark_node;
10530 }
10531
10532 cn = fold (convert (int_type_node, cn));
10533
10534 /* Multiple instance of a case label bearing the same
10535 value is checked during code generation. The case
10536 expression is allright so far. */
10537 TREE_OPERAND (node, 0) = cn;
10538 TREE_TYPE (node) = void_type_node;
10539 CAN_COMPLETE_NORMALLY (node) = 1;
10540 TREE_SIDE_EFFECTS (node) = 1;
10541 break;
10542
10543 case DEFAULT_EXPR:
10544 nn = ctxp->current_loop;
10545 /* Only one default label is allowed per switch statement */
10546 if (SWITCH_HAS_DEFAULT (nn))
10547 {
10548 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10549 parse_error_context (wfl_operator,
10550 "Duplicate case label: `default'");
10551 return error_mark_node;
10552 }
10553 else
10554 SWITCH_HAS_DEFAULT (nn) = 1;
10555 TREE_TYPE (node) = void_type_node;
10556 TREE_SIDE_EFFECTS (node) = 1;
10557 CAN_COMPLETE_NORMALLY (node) = 1;
10558 break;
10559
10560 case SWITCH_EXPR:
10561 case LOOP_EXPR:
10562 PUSH_LOOP (node);
10563 /* Check whether the loop was enclosed in a labeled
10564 statement. If not, create one, insert the loop in it and
10565 return the node */
10566 nn = patch_loop_statement (node);
10567
10568 /* Anyways, walk the body of the loop */
10569 if (TREE_CODE (node) == LOOP_EXPR)
10570 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10571 /* Switch statement: walk the switch expression and the cases */
10572 else
10573 node = patch_switch_statement (node);
10574
10575 if (TREE_OPERAND (node, 0) == error_mark_node)
10576 nn = error_mark_node;
10577 else
10578 {
10579 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
10580 /* If we returned something different, that's because we
10581 inserted a label. Pop the label too. */
10582 if (nn != node)
10583 {
10584 if (CAN_COMPLETE_NORMALLY (node))
10585 CAN_COMPLETE_NORMALLY (nn) = 1;
10586 POP_LABELED_BLOCK ();
10587 }
10588 }
10589 POP_LOOP ();
10590 return nn;
10591
10592 case EXIT_EXPR:
10593 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10594 return patch_exit_expr (node);
10595
10596 case COND_EXPR:
10597 /* Condition */
10598 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10599 if (TREE_OPERAND (node, 0) == error_mark_node)
10600 return error_mark_node;
10601 /* then-else branches */
10602 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10603 if (TREE_OPERAND (node, 1) == error_mark_node)
10604 return error_mark_node;
10605 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
10606 if (TREE_OPERAND (node, 2) == error_mark_node)
10607 return error_mark_node;
10608 return patch_if_else_statement (node);
10609 break;
10610
10611 case CONDITIONAL_EXPR:
10612 /* Condition */
10613 wfl_op1 = TREE_OPERAND (node, 0);
10614 COMPLETE_CHECK_OP_0 (node);
10615 wfl_op2 = TREE_OPERAND (node, 1);
10616 COMPLETE_CHECK_OP_1 (node);
10617 wfl_op3 = TREE_OPERAND (node, 2);
10618 COMPLETE_CHECK_OP_2 (node);
10619 return patch_conditional_expr (node, wfl_op1, wfl_op2);
10620
10621 /* 3- Expression section */
10622 case COMPOUND_EXPR:
10623 wfl_op2 = TREE_OPERAND (node, 1);
10624 TREE_OPERAND (node, 0) = nn =
10625 java_complete_tree (TREE_OPERAND (node, 0));
10626 if (wfl_op2 == empty_stmt_node)
10627 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
10628 else
10629 {
10630 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
10631 {
10632 /* An unreachable condition in a do-while statement
10633 is *not* (technically) an unreachable statement. */
10634 nn = wfl_op2;
10635 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
10636 nn = EXPR_WFL_NODE (nn);
10637 if (TREE_CODE (nn) != EXIT_EXPR)
10638 {
10639 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
10640 parse_error_context (wfl_operator, "Unreachable statement");
10641 }
10642 }
10643 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
10644 if (TREE_OPERAND (node, 1) == error_mark_node)
10645 return error_mark_node;
10646 CAN_COMPLETE_NORMALLY (node)
10647 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
10648 }
10649 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
10650 break;
10651
10652 case RETURN_EXPR:
10653 /* CAN_COMPLETE_NORMALLY (node) = 0; */
10654 return patch_return (node);
10655
10656 case EXPR_WITH_FILE_LOCATION:
10657 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
10658 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
10659 {
10660 tree wfl = node;
10661 node = resolve_expression_name (node, NULL);
10662 if (node == error_mark_node)
10663 return node;
10664 /* Keep line number information somewhere were it doesn't
10665 disrupt the completion process. */
10666 if (flag_emit_xref)
10667 {
10668 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
10669 TREE_OPERAND (node, 1) = wfl;
10670 }
10671 CAN_COMPLETE_NORMALLY (node) = 1;
10672 }
10673 else
10674 {
10675 tree body;
10676 int save_lineno = lineno;
10677 lineno = EXPR_WFL_LINENO (node);
10678 body = java_complete_tree (EXPR_WFL_NODE (node));
10679 lineno = save_lineno;
10680 EXPR_WFL_NODE (node) = body;
10681 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
10682 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
10683 if (body == empty_stmt_node)
10684 {
10685 /* Optimization; makes it easier to detect empty bodies. */
10686 return body;
10687 }
10688 if (body == error_mark_node)
10689 {
10690 /* Its important for the evaluation of assignment that
10691 this mark on the TREE_TYPE is propagated. */
10692 TREE_TYPE (node) = error_mark_node;
10693 return error_mark_node;
10694 }
10695 else
10696 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
10697
10698 }
10699 break;
10700
10701 case NEW_ARRAY_EXPR:
10702 /* Patch all the dimensions */
10703 flag = 0;
10704 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
10705 {
10706 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
10707 tree dim = java_complete_tree (TREE_VALUE (cn));
10708 if (dim == error_mark_node)
10709 {
10710 flag = 1;
10711 continue;
10712 }
10713 else
10714 {
10715 TREE_VALUE (cn) = dim;
10716 /* Setup the location of the current dimension, for
10717 later error report. */
10718 TREE_PURPOSE (cn) =
10719 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
10720 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
10721 }
10722 }
10723 /* They complete the array creation expression, if no errors
10724 were found. */
10725 CAN_COMPLETE_NORMALLY (node) = 1;
10726 return (flag ? error_mark_node
10727 : force_evaluation_order (patch_newarray (node)));
10728
10729 case NEW_CLASS_EXPR:
10730 case CALL_EXPR:
10731 /* Complete function's argument(s) first */
10732 if (complete_function_arguments (node))
10733 return error_mark_node;
10734 else
10735 {
10736 tree decl, wfl = TREE_OPERAND (node, 0);
10737 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
10738
10739 node = patch_method_invocation (node, NULL_TREE,
10740 NULL_TREE, 0, &decl);
10741 if (node == error_mark_node)
10742 return error_mark_node;
10743
10744 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
10745 /* If we call this(...), register signature and positions */
10746 if (in_this)
10747 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
10748 tree_cons (wfl, decl,
10749 DECL_CONSTRUCTOR_CALLS (current_function_decl));
10750 CAN_COMPLETE_NORMALLY (node) = 1;
10751 return force_evaluation_order (node);
10752 }
10753
10754 case MODIFY_EXPR:
10755 /* Save potential wfls */
10756 wfl_op1 = TREE_OPERAND (node, 0);
10757 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
10758 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
10759 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
10760 && DECL_INITIAL (nn) != NULL_TREE)
10761 {
10762 tree value = fold_constant_for_init (nn, nn);
10763 if (value != NULL_TREE)
10764 {
10765 tree type = TREE_TYPE (value);
10766 if (JPRIMITIVE_TYPE_P (type) || type == string_ptr_type_node)
10767 return empty_stmt_node;
10768 }
10769 DECL_INITIAL (nn) = NULL_TREE;
10770 }
10771 wfl_op2 = TREE_OPERAND (node, 1);
10772
10773 if (TREE_OPERAND (node, 0) == error_mark_node)
10774 return error_mark_node;
10775
10776 if (COMPOUND_ASSIGN_P (wfl_op2))
10777 {
10778 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
10779
10780 /* Hand stablize the lhs on both places */
10781 TREE_OPERAND (node, 0) = lvalue;
10782 TREE_OPERAND (TREE_OPERAND (node, 1), 0) = lvalue;
10783
10784 /* Now complete the RHS. We write it back later on. */
10785 nn = java_complete_tree (TREE_OPERAND (node, 1));
10786
10787 if ((cn = patch_string (nn)))
10788 nn = cn;
10789
10790 /* The last part of the rewrite for E1 op= E2 is to have
10791 E1 = (T)(E1 op E2), with T being the type of E1. */
10792 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
10793 TREE_TYPE (lvalue), nn));
10794 }
10795
10796 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
10797 function to complete this RHS */
10798 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT)
10799 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
10800 TREE_OPERAND (node, 1));
10801 /* Otherwise we simply complete the RHS */
10802 else
10803 nn = java_complete_tree (TREE_OPERAND (node, 1));
10804
10805 if (nn == error_mark_node)
10806 return error_mark_node;
10807
10808 /* Write back the RHS as we evaluated it. */
10809 TREE_OPERAND (node, 1) = nn;
10810
10811 /* In case we're handling = with a String as a RHS, we need to
10812 produce a String out of the RHS (it might still be a
10813 STRING_CST or a StringBuffer at this stage */
10814 if ((nn = patch_string (TREE_OPERAND (node, 1))))
10815 TREE_OPERAND (node, 1) = nn;
10816 node = patch_assignment (node, wfl_op1, wfl_op2);
10817 CAN_COMPLETE_NORMALLY (node) = 1;
10818 return node;
10819
10820 case MULT_EXPR:
10821 case PLUS_EXPR:
10822 case MINUS_EXPR:
10823 case LSHIFT_EXPR:
10824 case RSHIFT_EXPR:
10825 case URSHIFT_EXPR:
10826 case BIT_AND_EXPR:
10827 case BIT_XOR_EXPR:
10828 case BIT_IOR_EXPR:
10829 case TRUNC_MOD_EXPR:
10830 case RDIV_EXPR:
10831 case TRUTH_ANDIF_EXPR:
10832 case TRUTH_ORIF_EXPR:
10833 case EQ_EXPR:
10834 case NE_EXPR:
10835 case GT_EXPR:
10836 case GE_EXPR:
10837 case LT_EXPR:
10838 case LE_EXPR:
10839 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
10840 knows how to handle those cases. */
10841 wfl_op1 = TREE_OPERAND (node, 0);
10842 wfl_op2 = TREE_OPERAND (node, 1);
10843
10844 CAN_COMPLETE_NORMALLY (node) = 1;
10845 /* Don't complete string nodes if dealing with the PLUS operand. */
10846 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
10847 {
10848 nn = java_complete_tree (wfl_op1);
10849 if (nn == error_mark_node)
10850 return error_mark_node;
10851 if ((cn = patch_string (nn)))
10852 nn = cn;
10853 TREE_OPERAND (node, 0) = nn;
10854 }
10855 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
10856 {
10857 nn = java_complete_tree (wfl_op2);
10858 if (nn == error_mark_node)
10859 return error_mark_node;
10860 if ((cn = patch_string (nn)))
10861 nn = cn;
10862 TREE_OPERAND (node, 1) = nn;
10863 }
10864 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
10865
10866 case INSTANCEOF_EXPR:
10867 wfl_op1 = TREE_OPERAND (node, 0);
10868 COMPLETE_CHECK_OP_0 (node);
10869 if (flag_emit_xref)
10870 {
10871 TREE_TYPE (node) = boolean_type_node;
10872 return node;
10873 }
10874 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
10875
10876 case UNARY_PLUS_EXPR:
10877 case NEGATE_EXPR:
10878 case TRUTH_NOT_EXPR:
10879 case BIT_NOT_EXPR:
10880 case PREDECREMENT_EXPR:
10881 case PREINCREMENT_EXPR:
10882 case POSTDECREMENT_EXPR:
10883 case POSTINCREMENT_EXPR:
10884 case CONVERT_EXPR:
10885 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
10886 how to handle those cases. */
10887 wfl_op1 = TREE_OPERAND (node, 0);
10888 CAN_COMPLETE_NORMALLY (node) = 1;
10889 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
10890 if (TREE_OPERAND (node, 0) == error_mark_node)
10891 return error_mark_node;
10892 node = patch_unaryop (node, wfl_op1);
10893 CAN_COMPLETE_NORMALLY (node) = 1;
10894 break;
10895
10896 case ARRAY_REF:
10897 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
10898 how to handle those cases. */
10899 wfl_op1 = TREE_OPERAND (node, 0);
10900 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
10901 if (TREE_OPERAND (node, 0) == error_mark_node)
10902 return error_mark_node;
10903 if (!flag_emit_class_files && !flag_emit_xref)
10904 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
10905 /* The same applies to wfl_op2 */
10906 wfl_op2 = TREE_OPERAND (node, 1);
10907 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
10908 if (TREE_OPERAND (node, 1) == error_mark_node)
10909 return error_mark_node;
10910 if (!flag_emit_class_files && !flag_emit_xref)
10911 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
10912 return patch_array_ref (node);
10913
10914 case RECORD_TYPE:
10915 return node;;
10916
10917 case COMPONENT_REF:
10918 /* The first step in the re-write of qualified name handling. FIXME.
10919 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
10920 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
10921 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
10922 {
10923 tree name = TREE_OPERAND (node, 1);
10924 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
10925 if (field == NULL_TREE)
10926 {
10927 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
10928 return error_mark_node;
10929 }
10930 if (! FIELD_STATIC (field))
10931 {
10932 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
10933 return error_mark_node;
10934 }
10935 return field;
10936 }
10937 else
10938 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
10939 break;
10940
10941 case THIS_EXPR:
10942 /* Can't use THIS in a static environment */
10943 if (!current_this)
10944 {
10945 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10946 parse_error_context (wfl_operator, "Keyword `this' used outside "
10947 "allowed context");
10948 TREE_TYPE (node) = error_mark_node;
10949 return error_mark_node;
10950 }
10951 if (ctxp->explicit_constructor_p)
10952 {
10953 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
10954 parse_error_context
10955 (wfl_operator, "Can't reference `this' or `super' before the "
10956 "superclass constructor has been called");
10957 TREE_TYPE (node) = error_mark_node;
10958 return error_mark_node;
10959 }
10960 return current_this;
10961
10962 default:
10963 CAN_COMPLETE_NORMALLY (node) = 1;
10964 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
10965 and it's time to turn it into the appropriate String object
10966 */
10967 if ((node = patch_string (node)))
10968 return node;
10969 fatal ("No case for tree code `%s' - java_complete_tree\n",
10970 tree_code_name [TREE_CODE (node)]);
10971 }
10972 return node;
10973 }
10974
10975 /* Complete function call's argument. Return a non zero value is an
10976 error was found. */
10977
10978 static int
10979 complete_function_arguments (node)
10980 tree node;
10981 {
10982 int flag = 0;
10983 tree cn;
10984
10985 ctxp->explicit_constructor_p += (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
10986 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
10987 {
10988 tree wfl = TREE_VALUE (cn), parm, temp;
10989 parm = java_complete_tree (wfl);
10990 if (parm == error_mark_node)
10991 {
10992 flag = 1;
10993 continue;
10994 }
10995 /* If have a string literal that we haven't transformed yet or a
10996 crafted string buffer, as a result of use of the the String
10997 `+' operator. Build `parm.toString()' and expand it. */
10998 if ((temp = patch_string (parm)))
10999 parm = temp;
11000 /* Inline PRIMTYPE.TYPE read access */
11001 parm = maybe_build_primttype_type_ref (parm, wfl);
11002
11003 TREE_VALUE (cn) = parm;
11004 }
11005 ctxp->explicit_constructor_p -= (CALL_THIS_CONSTRUCTOR_P (node) ? 1 : 0);
11006 return flag;
11007 }
11008
11009 /* Sometimes (for loops and variable initialized during their
11010 declaration), we want to wrap a statement around a WFL and turn it
11011 debugable. */
11012
11013 static tree
11014 build_debugable_stmt (location, stmt)
11015 int location;
11016 tree stmt;
11017 {
11018 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
11019 {
11020 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
11021 EXPR_WFL_LINECOL (stmt) = location;
11022 }
11023 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
11024 return stmt;
11025 }
11026
11027 static tree
11028 build_expr_block (body, decls)
11029 tree body, decls;
11030 {
11031 tree node = make_node (BLOCK);
11032 BLOCK_EXPR_DECLS (node) = decls;
11033 BLOCK_EXPR_BODY (node) = body;
11034 if (body)
11035 TREE_TYPE (node) = TREE_TYPE (body);
11036 TREE_SIDE_EFFECTS (node) = 1;
11037 return node;
11038 }
11039
11040 /* Create a new function block and link it approriately to current
11041 function block chain */
11042
11043 static tree
11044 enter_block ()
11045 {
11046 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
11047 }
11048
11049 /* Link block B supercontext to the previous block. The current
11050 function DECL is used as supercontext when enter_a_block is called
11051 for the first time for a given function. The current function body
11052 (DECL_FUNCTION_BODY) is set to be block B. */
11053
11054 static tree
11055 enter_a_block (b)
11056 tree b;
11057 {
11058 tree fndecl = current_function_decl;
11059
11060 if (!fndecl) {
11061 BLOCK_SUPERCONTEXT (b) = current_static_block;
11062 current_static_block = b;
11063 }
11064
11065 else if (!DECL_FUNCTION_BODY (fndecl))
11066 {
11067 BLOCK_SUPERCONTEXT (b) = fndecl;
11068 DECL_FUNCTION_BODY (fndecl) = b;
11069 }
11070 else
11071 {
11072 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
11073 DECL_FUNCTION_BODY (fndecl) = b;
11074 }
11075 return b;
11076 }
11077
11078 /* Exit a block by changing the current function body
11079 (DECL_FUNCTION_BODY) to the current block super context, only if
11080 the block being exited isn't the method's top level one. */
11081
11082 static tree
11083 exit_block ()
11084 {
11085 tree b;
11086 if (current_function_decl)
11087 {
11088 b = DECL_FUNCTION_BODY (current_function_decl);
11089 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
11090 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
11091 }
11092 else
11093 {
11094 b = current_static_block;
11095
11096 if (BLOCK_SUPERCONTEXT (b))
11097 current_static_block = BLOCK_SUPERCONTEXT (b);
11098 }
11099 return b;
11100 }
11101
11102 /* Lookup for NAME in the nested function's blocks, all the way up to
11103 the current toplevel one. It complies with Java's local variable
11104 scoping rules. */
11105
11106 static tree
11107 lookup_name_in_blocks (name)
11108 tree name;
11109 {
11110 tree b = GET_CURRENT_BLOCK (current_function_decl);
11111
11112 while (b != current_function_decl)
11113 {
11114 tree current;
11115
11116 /* Paranoid sanity check. To be removed */
11117 if (TREE_CODE (b) != BLOCK)
11118 fatal ("non block expr function body - lookup_name_in_blocks");
11119
11120 for (current = BLOCK_EXPR_DECLS (b); current;
11121 current = TREE_CHAIN (current))
11122 if (DECL_NAME (current) == name)
11123 return current;
11124 b = BLOCK_SUPERCONTEXT (b);
11125 }
11126 return NULL_TREE;
11127 }
11128
11129 static void
11130 maybe_absorb_scoping_blocks ()
11131 {
11132 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
11133 {
11134 tree b = exit_block ();
11135 java_method_add_stmt (current_function_decl, b);
11136 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
11137 }
11138 }
11139
11140 \f
11141 /* This section of the source is reserved to build_* functions that
11142 are building incomplete tree nodes and the patch_* functions that
11143 are completing them. */
11144
11145 /* Build a super() constructor invocation. Returns empty_stmt_node if
11146 we're currently dealing with the class java.lang.Object. */
11147
11148 static tree
11149 build_super_invocation ()
11150 {
11151 if (current_class == object_type_node)
11152 return empty_stmt_node;
11153 else
11154 {
11155 tree super_wfl = build_wfl_node (super_identifier_node);
11156 return build_method_invocation (super_wfl, NULL_TREE);
11157 }
11158 }
11159
11160 /* Build a SUPER/THIS qualified method invocation. */
11161
11162 static tree
11163 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
11164 int use_this;
11165 tree name, args;
11166 int lloc, rloc;
11167
11168 {
11169 tree invok;
11170 tree wfl =
11171 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
11172 EXPR_WFL_LINECOL (wfl) = lloc;
11173 invok = build_method_invocation (name, args);
11174 return make_qualified_primary (wfl, invok, rloc);
11175 }
11176
11177 /* Build an incomplete CALL_EXPR node. */
11178
11179 static tree
11180 build_method_invocation (name, args)
11181 tree name;
11182 tree args;
11183 {
11184 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
11185 TREE_SIDE_EFFECTS (call) = 1;
11186 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11187 return call;
11188 }
11189
11190 /* Build an incomplete new xxx(...) node. */
11191
11192 static tree
11193 build_new_invocation (name, args)
11194 tree name, args;
11195 {
11196 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
11197 TREE_SIDE_EFFECTS (call) = 1;
11198 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
11199 return call;
11200 }
11201
11202 /* Build an incomplete assignment expression. */
11203
11204 static tree
11205 build_assignment (op, op_location, lhs, rhs)
11206 int op, op_location;
11207 tree lhs, rhs;
11208 {
11209 tree assignment;
11210 /* Build the corresponding binop if we deal with a Compound
11211 Assignment operator. Mark the binop sub-tree as part of a
11212 Compound Assignment expression */
11213 if (op != ASSIGN_TK)
11214 {
11215 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
11216 COMPOUND_ASSIGN_P (rhs) = 1;
11217 }
11218 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
11219 TREE_SIDE_EFFECTS (assignment) = 1;
11220 EXPR_WFL_LINECOL (assignment) = op_location;
11221 return assignment;
11222 }
11223
11224 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
11225
11226 char *
11227 print_int_node (node)
11228 tree node;
11229 {
11230 static char buffer [80];
11231 if (TREE_CONSTANT_OVERFLOW (node))
11232 sprintf (buffer, "<overflow>");
11233
11234 if (TREE_INT_CST_HIGH (node) == 0)
11235 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
11236 TREE_INT_CST_LOW (node));
11237 else if (TREE_INT_CST_HIGH (node) == -1
11238 && TREE_INT_CST_LOW (node) != 0)
11239 {
11240 buffer [0] = '-';
11241 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
11242 -TREE_INT_CST_LOW (node));
11243 }
11244 else
11245 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
11246 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
11247
11248 return buffer;
11249 }
11250
11251 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
11252 context. */
11253
11254 static int
11255 check_final_assignment (lvalue, wfl)
11256 tree lvalue, wfl;
11257 {
11258 if (JDECL_P (lvalue)
11259 && FIELD_FINAL (lvalue) && !IS_CLINIT (current_function_decl))
11260 {
11261 parse_error_context
11262 (wfl, "Can't assign a value to the final variable `%s'",
11263 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11264 return 1;
11265 }
11266 return 0;
11267 }
11268
11269 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
11270 read. This is needed to avoid circularities in the implementation
11271 of these fields in libjava. */
11272
11273 static tree
11274 maybe_build_primttype_type_ref (rhs, wfl)
11275 tree rhs, wfl;
11276 {
11277 tree to_return = NULL_TREE;
11278 tree rhs_type = TREE_TYPE (rhs);
11279 if (TREE_CODE (rhs) == COMPOUND_EXPR)
11280 {
11281 tree n = TREE_OPERAND (rhs, 1);
11282 if (TREE_CODE (n) == VAR_DECL
11283 && DECL_NAME (n) == TYPE_identifier_node
11284 && rhs_type == class_ptr_type)
11285 {
11286 char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
11287 if (!strncmp (self_name, "java.lang.", 10))
11288 to_return = build_primtype_type_ref (self_name);
11289 }
11290 }
11291 return (to_return ? to_return : rhs );
11292 }
11293
11294 /* 15.25 Assignment operators. */
11295
11296 static tree
11297 patch_assignment (node, wfl_op1, wfl_op2)
11298 tree node;
11299 tree wfl_op1;
11300 tree wfl_op2;
11301 {
11302 tree rhs = TREE_OPERAND (node, 1);
11303 tree lvalue = TREE_OPERAND (node, 0), llvalue;
11304 tree lhs_type, rhs_type, new_rhs = NULL_TREE;
11305 int error_found = 0;
11306 int lvalue_from_array = 0;
11307
11308 /* Can't assign to a final. */
11309 if (check_final_assignment (lvalue, wfl_op1))
11310 error_found = 1;
11311
11312 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11313
11314 /* Lhs can be a named variable */
11315 if (JDECL_P (lvalue))
11316 {
11317 lhs_type = TREE_TYPE (lvalue);
11318 }
11319 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
11320 comment on reason why */
11321 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
11322 {
11323 lhs_type = TREE_TYPE (lvalue);
11324 lvalue_from_array = 1;
11325 }
11326 /* Or a field access */
11327 else if (TREE_CODE (lvalue) == COMPONENT_REF)
11328 lhs_type = TREE_TYPE (lvalue);
11329 /* Or a function return slot */
11330 else if (TREE_CODE (lvalue) == RESULT_DECL)
11331 lhs_type = TREE_TYPE (lvalue);
11332 /* Otherwise, we might want to try to write into an optimized static
11333 final, this is an of a different nature, reported further on. */
11334 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
11335 && resolve_expression_name (wfl_op1, &llvalue))
11336 {
11337 if (check_final_assignment (llvalue, wfl_op1))
11338 {
11339 /* What we should do instead is resetting the all the flags
11340 previously set, exchange lvalue for llvalue and continue. */
11341 error_found = 1;
11342 return error_mark_node;
11343 }
11344 else
11345 lhs_type = TREE_TYPE (lvalue);
11346 }
11347 else
11348 {
11349 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
11350 error_found = 1;
11351 }
11352
11353 rhs_type = TREE_TYPE (rhs);
11354 /* 5.1 Try the assignment conversion for builtin type. */
11355 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
11356
11357 /* 5.2 If it failed, try a reference conversion */
11358 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
11359 lhs_type = promote_type (rhs_type);
11360
11361 /* 15.25.2 If we have a compound assignment, convert RHS into the
11362 type of the LHS */
11363 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11364 new_rhs = convert (lhs_type, rhs);
11365
11366 /* Explicit cast required. This is an error */
11367 if (!new_rhs)
11368 {
11369 char *t1 = strdup (lang_printable_name (TREE_TYPE (rhs), 0));
11370 char *t2 = strdup (lang_printable_name (lhs_type, 0));
11371 tree wfl;
11372 char operation [32]; /* Max size known */
11373
11374 /* If the assignment is part of a declaration, we use the WFL of
11375 the declared variable to point out the error and call it a
11376 declaration problem. If the assignment is a genuine =
11377 operator, we call is a operator `=' problem, otherwise we
11378 call it an assignment problem. In both of these last cases,
11379 we use the WFL of the operator to indicate the error. */
11380
11381 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
11382 {
11383 wfl = wfl_op1;
11384 strcpy (operation, "declaration");
11385 }
11386 else
11387 {
11388 wfl = wfl_operator;
11389 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
11390 strcpy (operation, "assignment");
11391 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
11392 strcpy (operation, "`return'");
11393 else
11394 strcpy (operation, "`='");
11395 }
11396
11397 parse_error_context
11398 (wfl, (!valid_cast_to_p (rhs_type, lhs_type) ?
11399 "Incompatible type for %s. Can't convert `%s' to `%s'" :
11400 "Incompatible type for %s. Explicit cast "
11401 "needed to convert `%s' to `%s'"), operation, t1, t2);
11402 free (t1); free (t2);
11403 error_found = 1;
11404 }
11405
11406 /* Inline read access to java.lang.PRIMTYPE.TYPE */
11407 if (new_rhs)
11408 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
11409
11410 if (error_found)
11411 return error_mark_node;
11412
11413 /* 10.10: Array Store Exception runtime check */
11414 if (!flag_emit_class_files
11415 && !flag_emit_xref
11416 && lvalue_from_array
11417 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type))
11418 && !CLASS_FINAL (TYPE_NAME (GET_SKIP_TYPE (rhs_type))))
11419 {
11420 tree check;
11421 tree base = lvalue;
11422
11423 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
11424 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11425 base = TREE_OPERAND (lvalue, 0);
11426 else
11427 {
11428 if (flag_bounds_check)
11429 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
11430 else
11431 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
11432 }
11433
11434 /* Build the invocation of _Jv_CheckArrayStore */
11435 check = build (CALL_EXPR, void_type_node,
11436 build_address_of (soft_checkarraystore_node),
11437 tree_cons (NULL_TREE, base,
11438 build_tree_list (NULL_TREE, new_rhs)),
11439 NULL_TREE);
11440 TREE_SIDE_EFFECTS (check) = 1;
11441
11442 /* We have to decide on an insertion point */
11443 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
11444 {
11445 tree t;
11446 if (flag_bounds_check)
11447 {
11448 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
11449 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
11450 build (COMPOUND_EXPR, void_type_node, t, check);
11451 }
11452 else
11453 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
11454 check, TREE_OPERAND (lvalue, 1));
11455 }
11456 else
11457 {
11458 /* Make sure the bound check will happen before the store check */
11459 if (flag_bounds_check)
11460 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
11461 build (COMPOUND_EXPR, void_type_node,
11462 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
11463 else
11464 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
11465 }
11466 }
11467
11468 TREE_OPERAND (node, 0) = lvalue;
11469 TREE_OPERAND (node, 1) = new_rhs;
11470 TREE_TYPE (node) = lhs_type;
11471 return node;
11472 }
11473
11474 /* Check that type SOURCE can be cast into type DEST. If the cast
11475 can't occur at all, return 0 otherwise 1. This function is used to
11476 produce accurate error messages on the reasons why an assignment
11477 failed. */
11478
11479 static tree
11480 try_reference_assignconv (lhs_type, rhs)
11481 tree lhs_type, rhs;
11482 {
11483 tree new_rhs = NULL_TREE;
11484 tree rhs_type = TREE_TYPE (rhs);
11485
11486 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
11487 {
11488 /* `null' may be assigned to any reference type */
11489 if (rhs == null_pointer_node)
11490 new_rhs = null_pointer_node;
11491 /* Try the reference assignment conversion */
11492 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
11493 new_rhs = rhs;
11494 /* This is a magic assignment that we process differently */
11495 else if (rhs == soft_exceptioninfo_call_node)
11496 new_rhs = rhs;
11497 }
11498 return new_rhs;
11499 }
11500
11501 /* Check that RHS can be converted into LHS_TYPE by the assignment
11502 conversion (5.2), for the cases of RHS being a builtin type. Return
11503 NULL_TREE if the conversion fails or if because RHS isn't of a
11504 builtin type. Return a converted RHS if the conversion is possible. */
11505
11506 static tree
11507 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
11508 tree wfl_op1, lhs_type, rhs;
11509 {
11510 tree new_rhs = NULL_TREE;
11511 tree rhs_type = TREE_TYPE (rhs);
11512
11513 /* Zero accepted everywhere */
11514 if (TREE_CODE (rhs) == INTEGER_CST
11515 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
11516 && JPRIMITIVE_TYPE_P (rhs_type))
11517 new_rhs = convert (lhs_type, rhs);
11518
11519 /* 5.1.1 Try Identity Conversion,
11520 5.1.2 Try Widening Primitive Conversion */
11521 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
11522 new_rhs = convert (lhs_type, rhs);
11523
11524 /* Try a narrowing primitive conversion (5.1.3):
11525 - expression is a constant expression of type int AND
11526 - variable is byte, short or char AND
11527 - The value of the expression is representable in the type of the
11528 variable */
11529 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
11530 && (lhs_type == byte_type_node || lhs_type == char_type_node
11531 || lhs_type == short_type_node))
11532 {
11533 if (int_fits_type_p (rhs, lhs_type))
11534 new_rhs = convert (lhs_type, rhs);
11535 else if (wfl_op1) /* Might be called with a NULL */
11536 parse_warning_context
11537 (wfl_op1, "Constant expression `%s' to wide for narrowing "
11538 "primitive conversion to `%s'",
11539 print_int_node (rhs), lang_printable_name (lhs_type, 0));
11540 /* Reported a warning that will turn into an error further
11541 down, so we don't return */
11542 }
11543
11544 return new_rhs;
11545 }
11546
11547 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
11548 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
11549 0 is the conversion test fails. This implements parts the method
11550 invocation convertion (5.3). */
11551
11552 static int
11553 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
11554 tree lhs_type, rhs_type;
11555 {
11556 /* 5.1.1: This is the identity conversion part. */
11557 if (lhs_type == rhs_type)
11558 return 1;
11559
11560 /* Reject non primitive types */
11561 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
11562 return 0;
11563
11564 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
11565 than a char can't be converted into a char. Short can't too, but
11566 the < test below takes care of that */
11567 if (lhs_type == char_type_node && rhs_type == byte_type_node)
11568 return 0;
11569
11570 /* Accept all promoted type here. Note, we can't use <= in the test
11571 below, because we still need to bounce out assignments of short
11572 to char and the likes */
11573 if (lhs_type == int_type_node
11574 && (rhs_type == promoted_byte_type_node
11575 || rhs_type == promoted_short_type_node
11576 || rhs_type == promoted_char_type_node
11577 || rhs_type == promoted_boolean_type_node))
11578 return 1;
11579
11580 /* From here, an integral is widened if its precision is smaller
11581 than the precision of the LHS or if the LHS is a floating point
11582 type, or the RHS is a float and the RHS a double. */
11583 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
11584 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
11585 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
11586 || (rhs_type == float_type_node && lhs_type == double_type_node))
11587 return 1;
11588
11589 return 0;
11590 }
11591
11592 /* Check that something of SOURCE type can be assigned or cast to
11593 something of DEST type at runtime. Return 1 if the operation is
11594 valid, 0 otherwise. If CAST is set to 1, we're treating the case
11595 were SOURCE is cast into DEST, which borrows a lot of the
11596 assignment check. */
11597
11598 static int
11599 valid_ref_assignconv_cast_p (source, dest, cast)
11600 tree source;
11601 tree dest;
11602 int cast;
11603 {
11604 /* SOURCE or DEST might be null if not from a declared entity. */
11605 if (!source || !dest)
11606 return 0;
11607 if (JNULLP_TYPE_P (source))
11608 return 1;
11609 if (TREE_CODE (source) == POINTER_TYPE)
11610 source = TREE_TYPE (source);
11611 if (TREE_CODE (dest) == POINTER_TYPE)
11612 dest = TREE_TYPE (dest);
11613 /* Case where SOURCE is a class type */
11614 if (TYPE_CLASS_P (source))
11615 {
11616 if (TYPE_CLASS_P (dest))
11617 return source == dest || inherits_from_p (source, dest)
11618 || (cast && inherits_from_p (dest, source));
11619 if (TYPE_INTERFACE_P (dest))
11620 {
11621 /* If doing a cast and SOURCE is final, the operation is
11622 always correct a compile time (because even if SOURCE
11623 does not implement DEST, a subclass of SOURCE might). */
11624 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
11625 return 1;
11626 /* Otherwise, SOURCE must implement DEST */
11627 return interface_of_p (dest, source);
11628 }
11629 /* DEST is an array, cast permited if SOURCE is of Object type */
11630 return (cast && source == object_type_node ? 1 : 0);
11631 }
11632 if (TYPE_INTERFACE_P (source))
11633 {
11634 if (TYPE_CLASS_P (dest))
11635 {
11636 /* If not casting, DEST must be the Object type */
11637 if (!cast)
11638 return dest == object_type_node;
11639 /* We're doing a cast. The cast is always valid is class
11640 DEST is not final, otherwise, DEST must implement SOURCE */
11641 else if (!CLASS_FINAL (TYPE_NAME (dest)))
11642 return 1;
11643 else
11644 return interface_of_p (source, dest);
11645 }
11646 if (TYPE_INTERFACE_P (dest))
11647 {
11648 /* If doing a cast, then if SOURCE and DEST contain method
11649 with the same signature but different return type, then
11650 this is a (compile time) error */
11651 if (cast)
11652 {
11653 tree method_source, method_dest;
11654 tree source_type;
11655 tree source_sig;
11656 tree source_name;
11657 for (method_source = TYPE_METHODS (source); method_source;
11658 method_source = TREE_CHAIN (method_source))
11659 {
11660 source_sig =
11661 build_java_argument_signature (TREE_TYPE (method_source));
11662 source_type = TREE_TYPE (TREE_TYPE (method_source));
11663 source_name = DECL_NAME (method_source);
11664 for (method_dest = TYPE_METHODS (dest);
11665 method_dest; method_dest = TREE_CHAIN (method_dest))
11666 if (source_sig ==
11667 build_java_argument_signature (TREE_TYPE (method_dest))
11668 && source_name == DECL_NAME (method_dest)
11669 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
11670 return 0;
11671 }
11672 return 1;
11673 }
11674 else
11675 return source == dest || interface_of_p (dest, source);
11676 }
11677 else /* Array */
11678 return 0;
11679 }
11680 if (TYPE_ARRAY_P (source))
11681 {
11682 if (TYPE_CLASS_P (dest))
11683 return dest == object_type_node;
11684 /* Can't cast an array to an interface unless the interface is
11685 java.lang.Cloneable */
11686 if (TYPE_INTERFACE_P (dest))
11687 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
11688 else /* Arrays */
11689 {
11690 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
11691 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
11692
11693 /* In case of severe errors, they turn out null */
11694 if (!dest_element_type || !source_element_type)
11695 return 0;
11696 if (source_element_type == dest_element_type)
11697 return 1;
11698 return valid_ref_assignconv_cast_p (source_element_type,
11699 dest_element_type, cast);
11700 }
11701 return 0;
11702 }
11703 return 0;
11704 }
11705
11706 static int
11707 valid_cast_to_p (source, dest)
11708 tree source;
11709 tree dest;
11710 {
11711 if (TREE_CODE (source) == POINTER_TYPE)
11712 source = TREE_TYPE (source);
11713 if (TREE_CODE (dest) == POINTER_TYPE)
11714 dest = TREE_TYPE (dest);
11715
11716 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
11717 return valid_ref_assignconv_cast_p (source, dest, 1);
11718
11719 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
11720 return 1;
11721
11722 return 0;
11723 }
11724
11725 /* Method invocation conversion test. Return 1 if type SOURCE can be
11726 converted to type DEST through the methond invocation conversion
11727 process (5.3) */
11728
11729 static tree
11730 do_unary_numeric_promotion (arg)
11731 tree arg;
11732 {
11733 tree type = TREE_TYPE (arg);
11734 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
11735 : TREE_CODE (type) == CHAR_TYPE)
11736 arg = convert (int_type_node, arg);
11737 return arg;
11738 }
11739
11740 /* Return a non zero value if SOURCE can be converted into DEST using
11741 the method invocation conversion rule (5.3). */
11742 static int
11743 valid_method_invocation_conversion_p (dest, source)
11744 tree dest, source;
11745 {
11746 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
11747 && valid_builtin_assignconv_identity_widening_p (dest, source))
11748 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
11749 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
11750 && valid_ref_assignconv_cast_p (source, dest, 0)));
11751 }
11752
11753 /* Build an incomplete binop expression. */
11754
11755 static tree
11756 build_binop (op, op_location, op1, op2)
11757 enum tree_code op;
11758 int op_location;
11759 tree op1, op2;
11760 {
11761 tree binop = build (op, NULL_TREE, op1, op2);
11762 TREE_SIDE_EFFECTS (binop) = 1;
11763 /* Store the location of the operator, for better error report. The
11764 string of the operator will be rebuild based on the OP value. */
11765 EXPR_WFL_LINECOL (binop) = op_location;
11766 return binop;
11767 }
11768
11769 /* Build the string of the operator retained by NODE. If NODE is part
11770 of a compound expression, add an '=' at the end of the string. This
11771 function is called when an error needs to be reported on an
11772 operator. The string is returned as a pointer to a static character
11773 buffer. */
11774
11775 static char *
11776 operator_string (node)
11777 tree node;
11778 {
11779 #define BUILD_OPERATOR_STRING(S) \
11780 { \
11781 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
11782 return buffer; \
11783 }
11784
11785 static char buffer [10];
11786 switch (TREE_CODE (node))
11787 {
11788 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
11789 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
11790 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
11791 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
11792 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
11793 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
11794 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
11795 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
11796 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
11797 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
11798 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
11799 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
11800 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
11801 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
11802 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
11803 case GT_EXPR: BUILD_OPERATOR_STRING (">");
11804 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
11805 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
11806 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
11807 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
11808 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
11809 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
11810 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
11811 case PREINCREMENT_EXPR: /* Fall through */
11812 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
11813 case PREDECREMENT_EXPR: /* Fall through */
11814 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
11815 default:
11816 fatal ("unregistered operator %s - operator_string",
11817 tree_code_name [TREE_CODE (node)]);
11818 }
11819 return NULL;
11820 #undef BUILD_OPERATOR_STRING
11821 }
11822
11823 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
11824 errors but we modify NODE so that it contains the type computed
11825 according to the expression, when it's fixed. Otherwise, we write
11826 error_mark_node as the type. It allows us to further the analysis
11827 of remaining nodes and detects more errors in certain cases. */
11828
11829 static tree
11830 patch_binop (node, wfl_op1, wfl_op2)
11831 tree node;
11832 tree wfl_op1;
11833 tree wfl_op2;
11834 {
11835 tree op1 = TREE_OPERAND (node, 0);
11836 tree op2 = TREE_OPERAND (node, 1);
11837 tree op1_type = TREE_TYPE (op1);
11838 tree op2_type = TREE_TYPE (op2);
11839 tree prom_type = NULL_TREE;
11840 int code = TREE_CODE (node);
11841
11842 /* If 1, tell the routine that we have to return error_mark_node
11843 after checking for the initialization of the RHS */
11844 int error_found = 0;
11845
11846 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
11847
11848 switch (code)
11849 {
11850 /* 15.16 Multiplicative operators */
11851 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
11852 case RDIV_EXPR: /* 15.16.2 Division Operator / */
11853 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
11854 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
11855 {
11856 if (!JPRIMITIVE_TYPE_P (op1_type))
11857 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
11858 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
11859 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
11860 TREE_TYPE (node) = error_mark_node;
11861 error_found = 1;
11862 break;
11863 }
11864 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
11865 /* Change the division operator if necessary */
11866 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
11867 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
11868
11869 /* This one is more complicated. FLOATs are processed by a
11870 function call to soft_fmod. Duplicate the value of the
11871 COMPOUND_ASSIGN_P flag. */
11872 if (code == TRUNC_MOD_EXPR)
11873 {
11874 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
11875 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
11876 TREE_SIDE_EFFECTS (mod)
11877 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
11878 return mod;
11879 }
11880 break;
11881
11882 /* 15.17 Additive Operators */
11883 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
11884
11885 /* Operation is valid if either one argument is a string
11886 constant, a String object or a StringBuffer crafted for the
11887 purpose of the a previous usage of the String concatenation
11888 operator */
11889
11890 if (TREE_CODE (op1) == STRING_CST
11891 || TREE_CODE (op2) == STRING_CST
11892 || JSTRING_TYPE_P (op1_type)
11893 || JSTRING_TYPE_P (op2_type)
11894 || IS_CRAFTED_STRING_BUFFER_P (op1)
11895 || IS_CRAFTED_STRING_BUFFER_P (op2))
11896 return build_string_concatenation (op1, op2);
11897
11898 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
11899 Numeric Types */
11900 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
11901 {
11902 if (!JPRIMITIVE_TYPE_P (op1_type))
11903 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
11904 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
11905 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
11906 TREE_TYPE (node) = error_mark_node;
11907 error_found = 1;
11908 break;
11909 }
11910 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
11911 break;
11912
11913 /* 15.18 Shift Operators */
11914 case LSHIFT_EXPR:
11915 case RSHIFT_EXPR:
11916 case URSHIFT_EXPR:
11917 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
11918 {
11919 if (!JINTEGRAL_TYPE_P (op1_type))
11920 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
11921 else
11922 parse_error_context
11923 (wfl_operator, (JPRIMITIVE_TYPE_P (op2_type) ?
11924 "Incompatible type for `%s'. Explicit cast needed to convert "
11925 "shift distance from `%s' to integral" :
11926 "Incompatible type for `%s'. Can't convert shift distance from "
11927 "`%s' to integral"),
11928 operator_string (node), lang_printable_name (op2_type, 0));
11929 TREE_TYPE (node) = error_mark_node;
11930 error_found = 1;
11931 break;
11932 }
11933
11934 /* Unary numeric promotion (5.6.1) is performed on each operand
11935 separatly */
11936 op1 = do_unary_numeric_promotion (op1);
11937 op2 = do_unary_numeric_promotion (op2);
11938
11939 /* The type of the shift expression is the type of the promoted
11940 type of the left-hand operand */
11941 prom_type = TREE_TYPE (op1);
11942
11943 /* Shift int only up to 0x1f and long up to 0x3f */
11944 if (prom_type == int_type_node)
11945 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
11946 build_int_2 (0x1f, 0)));
11947 else
11948 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
11949 build_int_2 (0x3f, 0)));
11950
11951 /* The >>> operator is a >> operating on unsigned quantities */
11952 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
11953 {
11954 tree to_return;
11955 tree utype = unsigned_type (prom_type);
11956 op1 = convert (utype, op1);
11957 TREE_SET_CODE (node, RSHIFT_EXPR);
11958 TREE_OPERAND (node, 0) = op1;
11959 TREE_OPERAND (node, 1) = op2;
11960 TREE_TYPE (node) = utype;
11961 to_return = convert (prom_type, node);
11962 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
11963 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
11964 TREE_SIDE_EFFECTS (to_return)
11965 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
11966 return to_return;
11967 }
11968 break;
11969
11970 /* 15.19.1 Type Comparison Operator instaceof */
11971 case INSTANCEOF_EXPR:
11972
11973 TREE_TYPE (node) = boolean_type_node;
11974
11975 if (!(op2_type = resolve_type_during_patch (op2)))
11976 return error_mark_node;
11977
11978 /* The first operand must be a reference type or the null type */
11979 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
11980 error_found = 1; /* Error reported further below */
11981
11982 /* The second operand must be a reference type */
11983 if (!JREFERENCE_TYPE_P (op2_type))
11984 {
11985 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
11986 parse_error_context
11987 (wfl_operator, "Invalid argument `%s' for `instanceof'",
11988 lang_printable_name (op2_type, 0));
11989 error_found = 1;
11990 }
11991
11992 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
11993 {
11994 /* If the first operand is null, the result is always false */
11995 if (op1 == null_pointer_node)
11996 return boolean_false_node;
11997 else if (flag_emit_class_files)
11998 {
11999 TREE_OPERAND (node, 1) = op2_type;
12000 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
12001 return node;
12002 }
12003 /* Otherwise we have to invoke instance of to figure it out */
12004 else
12005 {
12006 tree call =
12007 build (CALL_EXPR, boolean_type_node,
12008 build_address_of (soft_instanceof_node),
12009 tree_cons
12010 (NULL_TREE, op1,
12011 build_tree_list (NULL_TREE,
12012 build_class_ref (op2_type))),
12013 NULL_TREE);
12014 TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
12015 return call;
12016 }
12017 }
12018 /* There is no way the expression operand can be an instance of
12019 the type operand. This is a compile time error. */
12020 else
12021 {
12022 char *t1 = strdup (lang_printable_name (op1_type, 0));
12023 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
12024 parse_error_context
12025 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
12026 t1, lang_printable_name (op2_type, 0));
12027 free (t1);
12028 error_found = 1;
12029 }
12030
12031 break;
12032
12033 /* 15.21 Bitwise and Logical Operators */
12034 case BIT_AND_EXPR:
12035 case BIT_XOR_EXPR:
12036 case BIT_IOR_EXPR:
12037 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
12038 /* Binary numeric promotion is performed on both operand and the
12039 expression retain that type */
12040 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12041
12042 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
12043 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
12044 /* The type of the bitwise operator expression is BOOLEAN */
12045 prom_type = boolean_type_node;
12046 else
12047 {
12048 if (!JINTEGRAL_TYPE_P (op1_type))
12049 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
12050 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
12051 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
12052 TREE_TYPE (node) = error_mark_node;
12053 error_found = 1;
12054 /* Insert a break here if adding thing before the switch's
12055 break for this case */
12056 }
12057 break;
12058
12059 /* 15.22 Conditional-And Operator */
12060 case TRUTH_ANDIF_EXPR:
12061 /* 15.23 Conditional-Or Operator */
12062 case TRUTH_ORIF_EXPR:
12063 /* Operands must be of BOOLEAN type */
12064 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
12065 TREE_CODE (op2_type) != BOOLEAN_TYPE)
12066 {
12067 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
12068 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
12069 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
12070 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
12071 TREE_TYPE (node) = boolean_type_node;
12072 error_found = 1;
12073 break;
12074 }
12075 /* The type of the conditional operators is BOOLEAN */
12076 prom_type = boolean_type_node;
12077 break;
12078
12079 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
12080 case LT_EXPR:
12081 case GT_EXPR:
12082 case LE_EXPR:
12083 case GE_EXPR:
12084 /* The type of each of the operands must be a primitive numeric
12085 type */
12086 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
12087 {
12088 if (!JNUMERIC_TYPE_P (op1_type))
12089 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
12090 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
12091 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
12092 TREE_TYPE (node) = boolean_type_node;
12093 error_found = 1;
12094 break;
12095 }
12096 /* Binary numeric promotion is performed on the operands */
12097 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12098 /* The type of the relation expression is always BOOLEAN */
12099 prom_type = boolean_type_node;
12100 break;
12101
12102 /* 15.20 Equality Operator */
12103 case EQ_EXPR:
12104 case NE_EXPR:
12105 /* 15.20.1 Numerical Equality Operators == and != */
12106 /* Binary numeric promotion is performed on the operands */
12107 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
12108 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
12109
12110 /* 15.20.2 Boolean Equality Operators == and != */
12111 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
12112 TREE_CODE (op2_type) == BOOLEAN_TYPE)
12113 ; /* Nothing to do here */
12114
12115 /* 15.20.3 Reference Equality Operators == and != */
12116 /* Types have to be either references or the null type. If
12117 they're references, it must be possible to convert either
12118 type to the other by casting conversion. */
12119 else if (op1 == null_pointer_node || op2 == null_pointer_node
12120 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
12121 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
12122 || valid_ref_assignconv_cast_p (op2_type,
12123 op1_type, 1))))
12124 ; /* Nothing to do here */
12125
12126 /* Else we have an error figure what can't be converted into
12127 what and report the error */
12128 else
12129 {
12130 char *t1;
12131 t1 = strdup (lang_printable_name (op1_type, 0));
12132 parse_error_context
12133 (wfl_operator, "Incompatible type for `%s'. Can't convert `%s' "
12134 "to `%s'", operator_string (node), t1,
12135 lang_printable_name (op2_type, 0));
12136 free (t1);
12137 TREE_TYPE (node) = boolean_type_node;
12138 error_found = 1;
12139 break;
12140 }
12141 prom_type = boolean_type_node;
12142 break;
12143 }
12144
12145 if (error_found)
12146 return error_mark_node;
12147
12148 TREE_OPERAND (node, 0) = op1;
12149 TREE_OPERAND (node, 1) = op2;
12150 TREE_TYPE (node) = prom_type;
12151 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12152
12153 if (flag_emit_xref)
12154 return node;
12155
12156 /* fold does not respect side-effect order as required for Java but not C.
12157 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
12158 * bytecode.
12159 */
12160 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
12161 : ! TREE_SIDE_EFFECTS (node))
12162 node = fold (node);
12163 return node;
12164 }
12165
12166 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
12167 zero value, the value of CSTE comes after the valude of STRING */
12168
12169 static tree
12170 do_merge_string_cste (cste, string, string_len, after)
12171 tree cste;
12172 char *string;
12173 int string_len, after;
12174 {
12175 int len = TREE_STRING_LENGTH (cste) + string_len;
12176 char *old = TREE_STRING_POINTER (cste);
12177 TREE_STRING_LENGTH (cste) = len;
12178 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
12179 if (after)
12180 {
12181 strcpy (TREE_STRING_POINTER (cste), string);
12182 strcat (TREE_STRING_POINTER (cste), old);
12183 }
12184 else
12185 {
12186 strcpy (TREE_STRING_POINTER (cste), old);
12187 strcat (TREE_STRING_POINTER (cste), string);
12188 }
12189 return cste;
12190 }
12191
12192 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
12193 new STRING_CST on success, NULL_TREE on failure */
12194
12195 static tree
12196 merge_string_cste (op1, op2, after)
12197 tree op1, op2;
12198 int after;
12199 {
12200 /* Handle two string constants right away */
12201 if (TREE_CODE (op2) == STRING_CST)
12202 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
12203 TREE_STRING_LENGTH (op2), after);
12204
12205 /* Reasonable integer constant can be treated right away */
12206 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
12207 {
12208 static char *boolean_true = "true";
12209 static char *boolean_false = "false";
12210 static char *null_pointer = "null";
12211 char ch[3];
12212 char *string;
12213
12214 if (op2 == boolean_true_node)
12215 string = boolean_true;
12216 else if (op2 == boolean_false_node)
12217 string = boolean_false;
12218 else if (op2 == null_pointer_node)
12219 string = null_pointer;
12220 else if (TREE_TYPE (op2) == char_type_node)
12221 {
12222 ch[0] = (char )TREE_INT_CST_LOW (op2);
12223 ch[1] = '\0';
12224 string = ch;
12225 }
12226 else
12227 string = print_int_node (op2);
12228
12229 return do_merge_string_cste (op1, string, strlen (string), after);
12230 }
12231 return NULL_TREE;
12232 }
12233
12234 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
12235 has to be a STRING_CST and the other part must be a STRING_CST or a
12236 INTEGRAL constant. Return a new STRING_CST if the operation
12237 succeed, NULL_TREE otherwise.
12238
12239 If the case we want to optimize for space, we might want to return
12240 NULL_TREE for each invocation of this routine. FIXME */
12241
12242 static tree
12243 string_constant_concatenation (op1, op2)
12244 tree op1, op2;
12245 {
12246 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
12247 {
12248 tree string, rest;
12249 int invert;
12250
12251 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
12252 rest = (string == op1 ? op2 : op1);
12253 invert = (string == op1 ? 0 : 1 );
12254
12255 /* Walk REST, only if it looks reasonable */
12256 if (TREE_CODE (rest) != STRING_CST
12257 && !IS_CRAFTED_STRING_BUFFER_P (rest)
12258 && !JSTRING_TYPE_P (TREE_TYPE (rest))
12259 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
12260 {
12261 rest = java_complete_tree (rest);
12262 if (rest == error_mark_node)
12263 return error_mark_node;
12264 rest = fold (rest);
12265 }
12266 return merge_string_cste (string, rest, invert);
12267 }
12268 return NULL_TREE;
12269 }
12270
12271 /* Implement the `+' operator. Does static optimization if possible,
12272 otherwise create (if necessary) and append elements to a
12273 StringBuffer. The StringBuffer will be carried around until it is
12274 used for a function call or an assignment. Then toString() will be
12275 called on it to turn it into a String object. */
12276
12277 static tree
12278 build_string_concatenation (op1, op2)
12279 tree op1, op2;
12280 {
12281 tree result;
12282 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
12283
12284 if (flag_emit_xref)
12285 return build (PLUS_EXPR, string_type_node, op1, op2);
12286
12287 /* Try to do some static optimization */
12288 if ((result = string_constant_concatenation (op1, op2)))
12289 return result;
12290
12291 /* Discard empty strings on either side of the expression */
12292 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
12293 {
12294 op1 = op2;
12295 op2 = NULL_TREE;
12296 }
12297 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
12298 op2 = NULL_TREE;
12299
12300 /* If operands are string constant, turn then into object references */
12301 if (TREE_CODE (op1) == STRING_CST)
12302 op1 = patch_string_cst (op1);
12303 if (op2 && TREE_CODE (op2) == STRING_CST)
12304 op2 = patch_string_cst (op2);
12305
12306 /* If either one of the constant is null and the other non null
12307 operand is a String object, return it. */
12308 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
12309 return op1;
12310
12311 /* If OP1 isn't already a StringBuffer, create and
12312 initialize a new one */
12313 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
12314 {
12315 /* Two solutions here:
12316 1) OP1 is a string reference, we call new StringBuffer(OP1)
12317 2) OP1 is something else, we call new StringBuffer().append(OP1). */
12318 if (JSTRING_TYPE_P (TREE_TYPE (op1)))
12319 op1 = BUILD_STRING_BUFFER (op1);
12320 else
12321 {
12322 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
12323 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
12324 }
12325 }
12326
12327 if (op2)
12328 {
12329 /* OP1 is no longer the last node holding a crafted StringBuffer */
12330 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
12331 /* Create a node for `{new...,xxx}.append (op2)' */
12332 if (op2)
12333 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
12334 }
12335
12336 /* Mark the last node holding a crafted StringBuffer */
12337 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
12338
12339 TREE_SIDE_EFFECTS (op1) = side_effects;
12340 return op1;
12341 }
12342
12343 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
12344 StringBuffer. If no string were found to be patched, return
12345 NULL. */
12346
12347 static tree
12348 patch_string (node)
12349 tree node;
12350 {
12351 if (node == error_mark_node)
12352 return error_mark_node;
12353 if (TREE_CODE (node) == STRING_CST)
12354 return patch_string_cst (node);
12355 else if (IS_CRAFTED_STRING_BUFFER_P (node))
12356 {
12357 int saved = ctxp->explicit_constructor_p;
12358 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
12359 tree ret;
12360 /* Temporary disable forbid the use of `this'. */
12361 ctxp->explicit_constructor_p = 0;
12362 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
12363 /* Restore it at its previous value */
12364 ctxp->explicit_constructor_p = saved;
12365 return ret;
12366 }
12367 return NULL_TREE;
12368 }
12369
12370 /* Build the internal representation of a string constant. */
12371
12372 static tree
12373 patch_string_cst (node)
12374 tree node;
12375 {
12376 int location;
12377 if (! flag_emit_class_files)
12378 {
12379 push_obstacks (&permanent_obstack, &permanent_obstack);
12380 node = get_identifier (TREE_STRING_POINTER (node));
12381 location = alloc_name_constant (CONSTANT_String, node);
12382 node = build_ref_from_constant_pool (location);
12383 }
12384 TREE_TYPE (node) = string_ptr_type_node;
12385 TREE_CONSTANT (node) = 1;
12386 return node;
12387 }
12388
12389 /* Build an incomplete unary operator expression. */
12390
12391 static tree
12392 build_unaryop (op_token, op_location, op1)
12393 int op_token, op_location;
12394 tree op1;
12395 {
12396 enum tree_code op;
12397 tree unaryop;
12398 switch (op_token)
12399 {
12400 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
12401 case MINUS_TK: op = NEGATE_EXPR; break;
12402 case NEG_TK: op = TRUTH_NOT_EXPR; break;
12403 case NOT_TK: op = BIT_NOT_EXPR; break;
12404 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
12405 op_token);
12406 }
12407
12408 unaryop = build1 (op, NULL_TREE, op1);
12409 TREE_SIDE_EFFECTS (unaryop) = 1;
12410 /* Store the location of the operator, for better error report. The
12411 string of the operator will be rebuild based on the OP value. */
12412 EXPR_WFL_LINECOL (unaryop) = op_location;
12413 return unaryop;
12414 }
12415
12416 /* Special case for the ++/-- operators, since they require an extra
12417 argument to build, which is set to NULL and patched
12418 later. IS_POST_P is 1 if the operator, 0 otherwise. */
12419
12420 static tree
12421 build_incdec (op_token, op_location, op1, is_post_p)
12422 int op_token, op_location;
12423 tree op1;
12424 int is_post_p;
12425 {
12426 static enum tree_code lookup [2][2] =
12427 {
12428 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
12429 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
12430 };
12431 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
12432 NULL_TREE, op1, NULL_TREE);
12433 TREE_SIDE_EFFECTS (node) = 1;
12434 /* Store the location of the operator, for better error report. The
12435 string of the operator will be rebuild based on the OP value. */
12436 EXPR_WFL_LINECOL (node) = op_location;
12437 return node;
12438 }
12439
12440 /* Build an incomplete cast operator, based on the use of the
12441 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
12442 set. java_complete_tree is trained to walk a CONVERT_EXPR even
12443 though its type is already set. */
12444
12445 static tree
12446 build_cast (location, type, exp)
12447 int location;
12448 tree type, exp;
12449 {
12450 tree node = build1 (CONVERT_EXPR, type, exp);
12451 EXPR_WFL_LINECOL (node) = location;
12452 return node;
12453 }
12454
12455 /* 15.14 Unary operators. We return error_mark_node in case of error,
12456 but preserve the type of NODE if the type is fixed. */
12457
12458 static tree
12459 patch_unaryop (node, wfl_op)
12460 tree node;
12461 tree wfl_op;
12462 {
12463 tree op = TREE_OPERAND (node, 0);
12464 tree op_type = TREE_TYPE (op);
12465 tree prom_type = NULL_TREE, value, decl;
12466 int code = TREE_CODE (node);
12467 int error_found = 0;
12468
12469 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12470
12471 switch (code)
12472 {
12473 /* 15.13.2 Postfix Increment Operator ++ */
12474 case POSTINCREMENT_EXPR:
12475 /* 15.13.3 Postfix Increment Operator -- */
12476 case POSTDECREMENT_EXPR:
12477 /* 15.14.1 Prefix Increment Operator ++ */
12478 case PREINCREMENT_EXPR:
12479 /* 15.14.2 Prefix Decrement Operator -- */
12480 case PREDECREMENT_EXPR:
12481 decl = strip_out_static_field_access_decl (op);
12482 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
12483 if (!JDECL_P (decl)
12484 && TREE_CODE (decl) != COMPONENT_REF
12485 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
12486 && TREE_CODE (decl) != INDIRECT_REF
12487 && !(TREE_CODE (decl) == COMPOUND_EXPR
12488 && TREE_OPERAND (decl, 1)
12489 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
12490 {
12491 tree lvalue;
12492 /* Before screaming, check that we're not in fact trying to
12493 increment a optimized static final access, in which case
12494 we issue an different error message. */
12495 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
12496 && resolve_expression_name (wfl_op, &lvalue)
12497 && check_final_assignment (lvalue, wfl_op)))
12498 parse_error_context (wfl_operator, "Invalid argument to `%s'",
12499 operator_string (node));
12500 TREE_TYPE (node) = error_mark_node;
12501 error_found = 1;
12502 }
12503 else if (check_final_assignment (op, wfl_op))
12504 error_found = 1;
12505
12506 /* From now on, we know that op if a variable and that it has a
12507 valid wfl. We use wfl_op to locate errors related to the
12508 ++/-- operand. */
12509 else if (!JNUMERIC_TYPE_P (op_type))
12510 {
12511 parse_error_context
12512 (wfl_op, "Invalid argument type `%s' to `%s'",
12513 lang_printable_name (op_type, 0), operator_string (node));
12514 TREE_TYPE (node) = error_mark_node;
12515 error_found = 1;
12516 }
12517 else
12518 {
12519 /* Before the addition, binary numeric promotion is performed on
12520 both operands */
12521 value = build_int_2 (1, 0);
12522 TREE_TYPE (node) =
12523 binary_numeric_promotion (op_type, TREE_TYPE (value), &op, &value);
12524 /* And write the promoted incremented and increment */
12525 TREE_OPERAND (node, 0) = op;
12526 TREE_OPERAND (node, 1) = value;
12527 /* Convert the overall back into its original type. */
12528 return fold (convert (op_type, node));
12529 }
12530 break;
12531
12532 /* 15.14.3 Unary Plus Operator + */
12533 case UNARY_PLUS_EXPR:
12534 /* 15.14.4 Unary Minus Operator - */
12535 case NEGATE_EXPR:
12536 if (!JNUMERIC_TYPE_P (op_type))
12537 {
12538 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
12539 TREE_TYPE (node) = error_mark_node;
12540 error_found = 1;
12541 }
12542 /* Unary numeric promotion is performed on operand */
12543 else
12544 {
12545 op = do_unary_numeric_promotion (op);
12546 prom_type = TREE_TYPE (op);
12547 if (code == UNARY_PLUS_EXPR)
12548 return fold (op);
12549 }
12550 break;
12551
12552 /* 15.14.5 Bitwise Complement Operator ~ */
12553 case BIT_NOT_EXPR:
12554 if (!JINTEGRAL_TYPE_P (op_type))
12555 {
12556 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
12557 TREE_TYPE (node) = error_mark_node;
12558 error_found = 1;
12559 }
12560 else
12561 {
12562 op = do_unary_numeric_promotion (op);
12563 prom_type = TREE_TYPE (op);
12564 }
12565 break;
12566
12567 /* 15.14.6 Logical Complement Operator ! */
12568 case TRUTH_NOT_EXPR:
12569 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
12570 {
12571 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
12572 /* But the type is known. We will report an error if further
12573 attempt of a assignment is made with this rhs */
12574 TREE_TYPE (node) = boolean_type_node;
12575 error_found = 1;
12576 }
12577 else
12578 prom_type = boolean_type_node;
12579 break;
12580
12581 /* 15.15 Cast Expression */
12582 case CONVERT_EXPR:
12583 value = patch_cast (node, wfl_operator);
12584 if (value == error_mark_node)
12585 {
12586 /* If this cast is part of an assignment, we tell the code
12587 that deals with it not to complain about a mismatch,
12588 because things have been cast, anyways */
12589 TREE_TYPE (node) = error_mark_node;
12590 error_found = 1;
12591 }
12592 else
12593 {
12594 value = fold (value);
12595 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
12596 return value;
12597 }
12598 break;
12599 }
12600
12601 if (error_found)
12602 return error_mark_node;
12603
12604 /* There are cases where node has been replaced by something else
12605 and we don't end up returning here: UNARY_PLUS_EXPR,
12606 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
12607 TREE_OPERAND (node, 0) = fold (op);
12608 TREE_TYPE (node) = prom_type;
12609 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
12610 return fold (node);
12611 }
12612
12613 /* Generic type resolution that sometimes takes place during node
12614 patching. Returned the resolved type or generate an error
12615 message. Return the resolved type or NULL_TREE. */
12616
12617 static tree
12618 resolve_type_during_patch (type)
12619 tree type;
12620 {
12621 if (unresolved_type_p (type, NULL))
12622 {
12623 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
12624 if (!type_decl)
12625 {
12626 parse_error_context (type,
12627 "Class `%s' not found in type declaration",
12628 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
12629 return NULL_TREE;
12630 }
12631 else
12632 {
12633 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
12634 return TREE_TYPE (type_decl);
12635 }
12636 }
12637 return type;
12638 }
12639 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
12640 found. Otherwise NODE or something meant to replace it is returned. */
12641
12642 static tree
12643 patch_cast (node, wfl_operator)
12644 tree node;
12645 tree wfl_operator;
12646 {
12647 tree op = TREE_OPERAND (node, 0);
12648 tree op_type = TREE_TYPE (op);
12649 tree cast_type = TREE_TYPE (node);
12650 char *t1;
12651
12652 /* First resolve OP_TYPE if unresolved */
12653 if (!(cast_type = resolve_type_during_patch (cast_type)))
12654 return error_mark_node;
12655
12656 /* Check on cast that are proven correct at compile time */
12657 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
12658 {
12659 static tree convert_narrow ();
12660 /* Same type */
12661 if (cast_type == op_type)
12662 return node;
12663
12664 /* float and double type are converted to the original type main
12665 variant and then to the target type. */
12666 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
12667 op = convert (integer_type_node, op);
12668
12669 /* Try widening/narowwing convertion. Potentially, things need
12670 to be worked out in gcc so we implement the extreme cases
12671 correctly. fold_convert() needs to be fixed. */
12672 return convert (cast_type, op);
12673 }
12674
12675 /* It's also valid to cast a boolean into a boolean */
12676 if (op_type == boolean_type_node && cast_type == boolean_type_node)
12677 return node;
12678
12679 /* null can be casted to references */
12680 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
12681 return build_null_of_type (cast_type);
12682
12683 /* The remaining legal casts involve conversion between reference
12684 types. Check for their compile time correctness. */
12685 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
12686 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
12687 {
12688 TREE_TYPE (node) = promote_type (cast_type);
12689 /* Now, the case can be determined correct at compile time if
12690 OP_TYPE can be converted into CAST_TYPE by assignment
12691 conversion (5.2) */
12692
12693 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
12694 {
12695 TREE_SET_CODE (node, NOP_EXPR);
12696 return node;
12697 }
12698
12699 if (flag_emit_class_files)
12700 {
12701 TREE_SET_CODE (node, CONVERT_EXPR);
12702 return node;
12703 }
12704
12705 /* The cast requires a run-time check */
12706 return build (CALL_EXPR, promote_type (cast_type),
12707 build_address_of (soft_checkcast_node),
12708 tree_cons (NULL_TREE, build_class_ref (cast_type),
12709 build_tree_list (NULL_TREE, op)),
12710 NULL_TREE);
12711 }
12712
12713 /* Any other casts are proven incorrect at compile time */
12714 t1 = strdup (lang_printable_name (op_type, 0));
12715 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
12716 t1, lang_printable_name (cast_type, 0));
12717 free (t1);
12718 return error_mark_node;
12719 }
12720
12721 /* Build a null constant and give it the type TYPE. */
12722
12723 static tree
12724 build_null_of_type (type)
12725 tree type;
12726 {
12727 tree node = build_int_2 (0, 0);
12728 TREE_TYPE (node) = promote_type (type);
12729 return node;
12730 }
12731
12732 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
12733 a list of indices. */
12734 static tree
12735 build_array_ref (location, array, index)
12736 int location;
12737 tree array, index;
12738 {
12739 tree node = build (ARRAY_REF, NULL_TREE, array, index);
12740 EXPR_WFL_LINECOL (node) = location;
12741 return node;
12742 }
12743
12744 /* 15.12 Array Access Expression */
12745
12746 static tree
12747 patch_array_ref (node)
12748 tree node;
12749 {
12750 tree array = TREE_OPERAND (node, 0);
12751 tree array_type = TREE_TYPE (array);
12752 tree index = TREE_OPERAND (node, 1);
12753 tree index_type = TREE_TYPE (index);
12754 int error_found = 0;
12755
12756 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
12757
12758 if (TREE_CODE (array_type) == POINTER_TYPE)
12759 array_type = TREE_TYPE (array_type);
12760
12761 /* The array reference must be an array */
12762 if (!TYPE_ARRAY_P (array_type))
12763 {
12764 parse_error_context
12765 (wfl_operator, "`[]' can only be applied to arrays. It can't be "
12766 "applied to `%s'", lang_printable_name (array_type, 0));
12767 TREE_TYPE (node) = error_mark_node;
12768 error_found = 1;
12769 }
12770
12771 /* The array index underdoes unary numeric promotion. The promoted
12772 type must be int */
12773 index = do_unary_numeric_promotion (index);
12774 if (TREE_TYPE (index) != int_type_node)
12775 {
12776 int could_cast = valid_cast_to_p (index_type, int_type_node);
12777 parse_error_context
12778 (wfl_operator,
12779 (could_cast ? "Incompatible type for `[]'. Explicit cast needed to "
12780 "convert `%s' to `int'" : "Incompatible type for `[]'. "
12781 "Can't convert `%s' to `int'"),
12782 lang_printable_name (index_type, 0));
12783 TREE_TYPE (node) = error_mark_node;
12784 error_found = 1;
12785 }
12786
12787 if (error_found)
12788 return error_mark_node;
12789
12790 array_type = TYPE_ARRAY_ELEMENT (array_type);
12791
12792 if (flag_emit_class_files || flag_emit_xref)
12793 {
12794 TREE_OPERAND (node, 0) = array;
12795 TREE_OPERAND (node, 1) = index;
12796 }
12797 else
12798 {
12799 /* The save_expr is for correct evaluation order. It would be cleaner
12800 to use force_evaluation_order (see comment there), but that is
12801 difficult when we also have to deal with bounds checking. */
12802 if (TREE_SIDE_EFFECTS (index))
12803 array = save_expr (array);
12804 node = build_java_arrayaccess (array, array_type, index);
12805 if (TREE_SIDE_EFFECTS (index))
12806 node = build (COMPOUND_EXPR, array_type, array, node);
12807 }
12808 TREE_TYPE (node) = array_type;
12809 return node;
12810 }
12811
12812 /* 15.9 Array Creation Expressions */
12813
12814 static tree
12815 build_newarray_node (type, dims, extra_dims)
12816 tree type;
12817 tree dims;
12818 int extra_dims;
12819 {
12820 tree node =
12821 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
12822 build_int_2 (extra_dims, 0));
12823 return node;
12824 }
12825
12826 static tree
12827 patch_newarray (node)
12828 tree node;
12829 {
12830 tree type = TREE_OPERAND (node, 0);
12831 tree dims = TREE_OPERAND (node, 1);
12832 tree cdim, array_type;
12833 int error_found = 0;
12834 int ndims = 0;
12835 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
12836
12837 /* Dimension types are verified. It's better for the types to be
12838 verified in order. */
12839 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
12840 {
12841 int dim_error = 0;
12842 tree dim = TREE_VALUE (cdim);
12843
12844 /* Dim might have been saved during its evaluation */
12845 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
12846
12847 /* The type of each specified dimension must be an integral type. */
12848 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
12849 dim_error = 1;
12850
12851 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
12852 promoted type must be int. */
12853 else
12854 {
12855 dim = do_unary_numeric_promotion (dim);
12856 if (TREE_TYPE (dim) != int_type_node)
12857 dim_error = 1;
12858 }
12859
12860 /* Report errors on types here */
12861 if (dim_error)
12862 {
12863 parse_error_context
12864 (TREE_PURPOSE (cdim),
12865 "Incompatible type for dimension in array creation expression. "
12866 "%s convert `%s' to `int'",
12867 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
12868 "Explicit cast needed to" : "Can't"),
12869 lang_printable_name (TREE_TYPE (dim), 0));
12870 error_found = 1;
12871 }
12872
12873 TREE_PURPOSE (cdim) = NULL_TREE;
12874 }
12875
12876 /* Resolve array base type if unresolved */
12877 if (!(type = resolve_type_during_patch (type)))
12878 error_found = 1;
12879
12880 if (error_found)
12881 {
12882 /* We don't want further evaluation of this bogus array creation
12883 operation */
12884 TREE_TYPE (node) = error_mark_node;
12885 return error_mark_node;
12886 }
12887
12888 /* Set array_type to the actual (promoted) array type of the result. */
12889 if (TREE_CODE (type) == RECORD_TYPE)
12890 type = build_pointer_type (type);
12891 while (--xdims >= 0)
12892 {
12893 type = promote_type (build_java_array_type (type, -1));
12894 }
12895 dims = nreverse (dims);
12896 array_type = type;
12897 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
12898 {
12899 type = array_type;
12900 array_type = build_java_array_type (type,
12901 TREE_CODE (cdim) == INTEGER_CST ?
12902 TREE_INT_CST_LOW (cdim) : -1);
12903 array_type = promote_type (array_type);
12904 }
12905 dims = nreverse (dims);
12906
12907 /* The node is transformed into a function call. Things are done
12908 differently according to the number of dimensions. If the number
12909 of dimension is equal to 1, then the nature of the base type
12910 (primitive or not) matters. */
12911 if (ndims == 1)
12912 return build_new_array (type, TREE_VALUE (dims));
12913
12914 /* Can't reuse what's already written in expr.c because it uses the
12915 JVM stack representation. Provide a build_multianewarray. FIXME */
12916 return build (CALL_EXPR, array_type,
12917 build_address_of (soft_multianewarray_node),
12918 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
12919 tree_cons (NULL_TREE,
12920 build_int_2 (ndims, 0), dims )),
12921 NULL_TREE);
12922 }
12923
12924 /* 10.6 Array initializer. */
12925
12926 /* Build a wfl for array element that don't have one, so we can
12927 pin-point errors. */
12928
12929 static tree
12930 maybe_build_array_element_wfl (node)
12931 tree node;
12932 {
12933 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
12934 return build_expr_wfl (NULL_TREE, ctxp->filename,
12935 ctxp->elc.line, ctxp->elc.prev_col);
12936 else
12937 return NULL_TREE;
12938 }
12939
12940 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
12941 identification of initialized arrays easier to detect during walk
12942 and expansion. */
12943
12944 static tree
12945 build_new_array_init (location, values)
12946 int location;
12947 tree values;
12948 {
12949 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
12950 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
12951 EXPR_WFL_LINECOL (to_return) = location;
12952 return to_return;
12953 }
12954
12955 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
12956 occurred. Otherwise return NODE after having set its type
12957 appropriately. */
12958
12959 static tree
12960 patch_new_array_init (type, node)
12961 tree type, node;
12962 {
12963 int error_seen = 0;
12964 tree current, element_type;
12965 HOST_WIDE_INT length;
12966 int all_constant = 1;
12967 tree init = TREE_OPERAND (node, 0);
12968
12969 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
12970 {
12971 parse_error_context (node,
12972 "Invalid array initializer for non-array type `%s'",
12973 lang_printable_name (type, 1));
12974 return error_mark_node;
12975 }
12976 type = TREE_TYPE (type);
12977 element_type = TYPE_ARRAY_ELEMENT (type);
12978
12979 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
12980
12981 for (length = 0, current = CONSTRUCTOR_ELTS (init);
12982 current; length++, current = TREE_CHAIN (current))
12983 {
12984 tree elt = TREE_VALUE (current);
12985 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
12986 {
12987 error_seen |= array_constructor_check_entry (element_type, current);
12988 elt = TREE_VALUE (current);
12989 /* When compiling to native code, STRING_CST is converted to
12990 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
12991 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
12992 all_constant = 0;
12993 }
12994 else
12995 {
12996 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
12997 TREE_PURPOSE (current) = NULL_TREE;
12998 all_constant = 0;
12999 }
13000 if (elt && TREE_VALUE (elt) == error_mark_node)
13001 error_seen = 1;
13002 }
13003
13004 if (error_seen)
13005 return error_mark_node;
13006
13007 /* Create a new type. We can't reuse the one we have here by
13008 patching its dimension because it originally is of dimension -1
13009 hence reused by gcc. This would prevent triangular arrays. */
13010 type = build_java_array_type (element_type, length);
13011 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
13012 TREE_TYPE (node) = promote_type (type);
13013 TREE_CONSTANT (init) = all_constant;
13014 TREE_CONSTANT (node) = all_constant;
13015 return node;
13016 }
13017
13018 /* Verify that one entry of the initializer element list can be
13019 assigned to the array base type. Report 1 if an error occurred, 0
13020 otherwise. */
13021
13022 static int
13023 array_constructor_check_entry (type, entry)
13024 tree type, entry;
13025 {
13026 char *array_type_string = NULL; /* For error reports */
13027 tree value, type_value, new_value, wfl_value, patched;
13028 int error_seen = 0;
13029
13030 new_value = NULL_TREE;
13031 wfl_value = TREE_VALUE (entry);
13032
13033 value = java_complete_tree (TREE_VALUE (entry));
13034 /* patch_string return error_mark_node if arg is error_mark_node */
13035 if ((patched = patch_string (value)))
13036 value = patched;
13037 if (value == error_mark_node)
13038 return 1;
13039
13040 type_value = TREE_TYPE (value);
13041
13042 /* At anytime, try_builtin_assignconv can report a warning on
13043 constant overflow during narrowing. */
13044 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
13045 new_value = try_builtin_assignconv (wfl_operator, type, value);
13046 if (!new_value && (new_value = try_reference_assignconv (type, value)))
13047 type_value = promote_type (type);
13048
13049 /* Check and report errors */
13050 if (!new_value)
13051 {
13052 char *msg = (!valid_cast_to_p (type_value, type) ?
13053 "Can't" : "Explicit cast needed to");
13054 if (!array_type_string)
13055 array_type_string = strdup (lang_printable_name (type, 1));
13056 parse_error_context
13057 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
13058 msg, lang_printable_name (type_value, 1), array_type_string);
13059 error_seen = 1;
13060 }
13061
13062 if (new_value)
13063 {
13064 new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
13065 TREE_VALUE (entry) = new_value;
13066 }
13067
13068 if (array_type_string)
13069 free (array_type_string);
13070
13071 TREE_PURPOSE (entry) = NULL_TREE;
13072 return error_seen;
13073 }
13074
13075 static tree
13076 build_this (location)
13077 int location;
13078 {
13079 tree node = build_wfl_node (this_identifier_node);
13080 TREE_SET_CODE (node, THIS_EXPR);
13081 EXPR_WFL_LINECOL (node) = location;
13082 return node;
13083 }
13084
13085 /* 14.15 The return statement. It builds a modify expression that
13086 assigns the returned value to the RESULT_DECL that hold the value
13087 to be returned. */
13088
13089 static tree
13090 build_return (location, op)
13091 int location;
13092 tree op;
13093 {
13094 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
13095 EXPR_WFL_LINECOL (node) = location;
13096 node = build_debugable_stmt (location, node);
13097 return node;
13098 }
13099
13100 static tree
13101 patch_return (node)
13102 tree node;
13103 {
13104 tree return_exp = TREE_OPERAND (node, 0);
13105 tree meth = current_function_decl;
13106 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
13107 int error_found = 0;
13108
13109 TREE_TYPE (node) = error_mark_node;
13110 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13111
13112 /* It's invalid to have a return value within a function that is
13113 declared with the keyword void or that is a constructor */
13114 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
13115 error_found = 1;
13116
13117 /* It's invalid to use a return statement in a static block */
13118 if (IS_CLINIT (current_function_decl))
13119 error_found = 1;
13120
13121 /* It's invalid to have a no return value within a function that
13122 isn't declared with the keyword `void' */
13123 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
13124 error_found = 2;
13125
13126 if (error_found)
13127 {
13128 if (IS_CLINIT (current_function_decl))
13129 parse_error_context (wfl_operator,
13130 "`return' inside static initializer.");
13131
13132 else if (!DECL_CONSTRUCTOR_P (meth))
13133 {
13134 char *t = strdup (lang_printable_name (mtype, 0));
13135 parse_error_context (wfl_operator,
13136 "`return' with%s value from `%s %s'",
13137 (error_found == 1 ? "" : "out"),
13138 t, lang_printable_name (meth, 0));
13139 free (t);
13140 }
13141 else
13142 parse_error_context (wfl_operator,
13143 "`return' with value from constructor `%s'",
13144 lang_printable_name (meth, 0));
13145 return error_mark_node;
13146 }
13147
13148 /* If we have a return_exp, build a modify expression and expand
13149 it. Note: at that point, the assignment is declared valid, but we
13150 may want to carry some more hacks */
13151 if (return_exp)
13152 {
13153 tree exp = java_complete_tree (return_exp);
13154 tree modify, patched;
13155
13156 /* If the function returned value and EXP are booleans, EXP has
13157 to be converted into the type of DECL_RESULT, which is integer
13158 (see complete_start_java_method) */
13159 if (TREE_TYPE (exp) == boolean_type_node &&
13160 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
13161 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
13162
13163 /* `null' can be assigned to a function returning a reference */
13164 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
13165 exp == null_pointer_node)
13166 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
13167
13168 if ((patched = patch_string (exp)))
13169 exp = patched;
13170
13171 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
13172 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
13173 modify = java_complete_tree (modify);
13174
13175 if (modify != error_mark_node)
13176 {
13177 TREE_SIDE_EFFECTS (modify) = 1;
13178 TREE_OPERAND (node, 0) = modify;
13179 }
13180 else
13181 return error_mark_node;
13182 }
13183 TREE_TYPE (node) = void_type_node;
13184 TREE_SIDE_EFFECTS (node) = 1;
13185 return node;
13186 }
13187
13188 /* 14.8 The if Statement */
13189
13190 static tree
13191 build_if_else_statement (location, expression, if_body, else_body)
13192 int location;
13193 tree expression, if_body, else_body;
13194 {
13195 tree node;
13196 if (!else_body)
13197 else_body = empty_stmt_node;
13198 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
13199 EXPR_WFL_LINECOL (node) = location;
13200 node = build_debugable_stmt (location, node);
13201 return node;
13202 }
13203
13204 static tree
13205 patch_if_else_statement (node)
13206 tree node;
13207 {
13208 tree expression = TREE_OPERAND (node, 0);
13209
13210 TREE_TYPE (node) = error_mark_node;
13211 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13212
13213 /* The type of expression must be boolean */
13214 if (TREE_TYPE (expression) != boolean_type_node
13215 && TREE_TYPE (expression) != promoted_boolean_type_node)
13216 {
13217 parse_error_context
13218 (wfl_operator,
13219 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
13220 lang_printable_name (TREE_TYPE (expression), 0));
13221 return error_mark_node;
13222 }
13223
13224 TREE_TYPE (node) = void_type_node;
13225 TREE_SIDE_EFFECTS (node) = 1;
13226 CAN_COMPLETE_NORMALLY (node)
13227 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
13228 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
13229 return node;
13230 }
13231
13232 /* 14.6 Labeled Statements */
13233
13234 /* Action taken when a lableled statement is parsed. a new
13235 LABELED_BLOCK_EXPR is created. No statement is attached to the
13236 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
13237
13238 static tree
13239 build_labeled_block (location, label)
13240 int location;
13241 tree label;
13242 {
13243 tree label_name ;
13244 tree label_decl, node;
13245 if (label == NULL_TREE || label == continue_identifier_node)
13246 label_name = label;
13247 else
13248 {
13249 label_name = merge_qualified_name (label_id, label);
13250 /* Issue an error if we try to reuse a label that was previously
13251 declared */
13252 if (IDENTIFIER_LOCAL_VALUE (label_name))
13253 {
13254 EXPR_WFL_LINECOL (wfl_operator) = location;
13255 parse_error_context (wfl_operator, "Declaration of `%s' shadows "
13256 "a previous label declaration",
13257 IDENTIFIER_POINTER (label));
13258 EXPR_WFL_LINECOL (wfl_operator) =
13259 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
13260 parse_error_context (wfl_operator, "This is the location of the "
13261 "previous declaration of label `%s'",
13262 IDENTIFIER_POINTER (label));
13263 java_error_count--;
13264 }
13265 }
13266
13267 label_decl = create_label_decl (label_name);
13268 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
13269 EXPR_WFL_LINECOL (node) = location;
13270 TREE_SIDE_EFFECTS (node) = 1;
13271 return node;
13272 }
13273
13274 /* A labeled statement LBE is attached a statement. */
13275
13276 static tree
13277 finish_labeled_statement (lbe, statement)
13278 tree lbe; /* Labeled block expr */
13279 tree statement;
13280 {
13281 /* In anyways, tie the loop to its statement */
13282 LABELED_BLOCK_BODY (lbe) = statement;
13283 pop_labeled_block ();
13284 POP_LABELED_BLOCK ();
13285 return lbe;
13286 }
13287
13288 /* 14.10, 14.11, 14.12 Loop Statements */
13289
13290 /* Create an empty LOOP_EXPR and make it the last in the nested loop
13291 list. */
13292
13293 static tree
13294 build_new_loop (loop_body)
13295 tree loop_body;
13296 {
13297 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
13298 TREE_SIDE_EFFECTS (loop) = 1;
13299 PUSH_LOOP (loop);
13300 return loop;
13301 }
13302
13303 /* Create a loop body according to the following structure:
13304 COMPOUND_EXPR
13305 COMPOUND_EXPR (loop main body)
13306 EXIT_EXPR (this order is for while/for loops.
13307 LABELED_BLOCK_EXPR the order is reversed for do loops)
13308 LABEL_DECL (a continue occuring here branches at the
13309 BODY end of this labeled block)
13310 INCREMENT (if any)
13311
13312 REVERSED, if non zero, tells that the loop condition expr comes
13313 after the body, like in the do-while loop.
13314
13315 To obtain a loop, the loop body structure described above is
13316 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
13317
13318 LABELED_BLOCK_EXPR
13319 LABEL_DECL (use this label to exit the loop)
13320 LOOP_EXPR
13321 <structure described above> */
13322
13323 static tree
13324 build_loop_body (location, condition, reversed)
13325 int location;
13326 tree condition;
13327 int reversed;
13328 {
13329 tree first, second, body;
13330
13331 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
13332 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
13333 condition = build_debugable_stmt (location, condition);
13334 TREE_SIDE_EFFECTS (condition) = 1;
13335
13336 body = build_labeled_block (0, continue_identifier_node);
13337 first = (reversed ? body : condition);
13338 second = (reversed ? condition : body);
13339 return
13340 build (COMPOUND_EXPR, NULL_TREE,
13341 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
13342 }
13343
13344 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
13345 their order) on the current loop. Unlink the current loop from the
13346 loop list. */
13347
13348 static tree
13349 finish_loop_body (location, condition, body, reversed)
13350 int location;
13351 tree condition, body;
13352 int reversed;
13353 {
13354 tree to_return = ctxp->current_loop;
13355 tree loop_body = LOOP_EXPR_BODY (to_return);
13356 if (condition)
13357 {
13358 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
13359 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
13360 The real EXIT_EXPR is one operand further. */
13361 EXPR_WFL_LINECOL (cnode) = location;
13362 /* This one is for accurate error reports */
13363 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
13364 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
13365 }
13366 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
13367 POP_LOOP ();
13368 return to_return;
13369 }
13370
13371 /* Tailored version of finish_loop_body for FOR loops, when FOR
13372 loops feature the condition part */
13373
13374 static tree
13375 finish_for_loop (location, condition, update, body)
13376 int location;
13377 tree condition, update, body;
13378 {
13379 /* Put the condition and the loop body in place */
13380 tree loop = finish_loop_body (location, condition, body, 0);
13381 /* LOOP is the current loop which has been now popped of the loop
13382 stack. Install the update block */
13383 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
13384 return loop;
13385 }
13386
13387 /* If the loop isn't surrounded by a labeled statement, create one and
13388 insert LOOP as its body. */
13389
13390 static tree
13391 patch_loop_statement (loop)
13392 tree loop;
13393 {
13394 tree loop_label;
13395 tree block = ctxp->current_labeled_block;
13396 TREE_TYPE (loop) = void_type_node;
13397 if (block != NULL_TREE)
13398 {
13399 tree block_body = LABELED_BLOCK_BODY (block);
13400 if (IS_FOR_LOOP_P (loop))
13401 {
13402 if (TREE_CODE (block_body) == BLOCK)
13403 {
13404 block_body = BLOCK_EXPR_BODY (block_body);
13405 if (block_body == loop
13406 || (TREE_CODE (block_body) == COMPOUND_EXPR
13407 && TREE_OPERAND (block_body, 1) == loop))
13408 return loop;
13409 }
13410 }
13411 else
13412 {
13413 if (block_body == loop)
13414 return loop;
13415 }
13416 }
13417 loop_label = build_labeled_block (0, NULL_TREE);
13418 LABELED_BLOCK_BODY (loop_label) = loop;
13419 PUSH_LABELED_BLOCK (loop_label);
13420 loop = loop_label;
13421 return loop;
13422 }
13423
13424 /* 14.13, 14.14: break and continue Statements */
13425
13426 /* Build a break or a continue statement. a null NAME indicates an
13427 unlabeled break/continue statement. */
13428
13429 static tree
13430 build_bc_statement (location, is_break, name)
13431 int location, is_break;
13432 tree name;
13433 {
13434 tree break_continue, label_block_expr = NULL_TREE;
13435
13436 if (name)
13437 {
13438 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
13439 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
13440 /* Null means that we don't have a target for this named
13441 break/continue. In this case, we make the target to be the
13442 label name, so that the error can be reported accuratly in
13443 patch_bc_statement. */
13444 label_block_expr = EXPR_WFL_NODE (name);
13445 }
13446 /* Unlabeled break/continue will be handled during the
13447 break/continue patch operation */
13448 break_continue
13449 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
13450
13451 IS_BREAK_STMT_P (break_continue) = is_break;
13452 TREE_SIDE_EFFECTS (break_continue) = 1;
13453 EXPR_WFL_LINECOL (break_continue) = location;
13454 break_continue = build_debugable_stmt (location, break_continue);
13455 return break_continue;
13456 }
13457
13458 /* Verification of a break/continue statement. */
13459
13460 static tree
13461 patch_bc_statement (node)
13462 tree node;
13463 {
13464 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
13465 tree labeled_block = ctxp->current_labeled_block;
13466 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13467
13468 /* Having an identifier here means that the target is unknown. */
13469 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
13470 {
13471 parse_error_context (wfl_operator, "No label definition found for `%s'",
13472 IDENTIFIER_POINTER (bc_label));
13473 return error_mark_node;
13474 }
13475 if (! IS_BREAK_STMT_P (node))
13476 {
13477 /* It's a continue statement. */
13478 for (;; labeled_block = TREE_CHAIN (labeled_block))
13479 {
13480 if (labeled_block == NULL_TREE)
13481 {
13482 if (bc_label == NULL_TREE)
13483 parse_error_context (wfl_operator,
13484 "`continue' must be in loop");
13485 else
13486 parse_error_context
13487 (wfl_operator, "continue label `%s' does not name a loop",
13488 IDENTIFIER_POINTER (bc_label));
13489 return error_mark_node;
13490 }
13491 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
13492 == continue_identifier_node)
13493 && (bc_label == NULL_TREE
13494 || TREE_CHAIN (labeled_block) == bc_label))
13495 {
13496 bc_label = labeled_block;
13497 break;
13498 }
13499 }
13500 }
13501 else if (!bc_label)
13502 {
13503 for (;; labeled_block = TREE_CHAIN (labeled_block))
13504 {
13505 if (labeled_block == NULL_TREE)
13506 {
13507 parse_error_context (wfl_operator,
13508 "`break' must be in loop or switch");
13509 return error_mark_node;
13510 }
13511 target_stmt = LABELED_BLOCK_BODY (labeled_block);
13512 if (TREE_CODE (target_stmt) == SWITCH_EXPR
13513 || TREE_CODE (target_stmt) == LOOP_EXPR)
13514 {
13515 bc_label = labeled_block;
13516 break;
13517 }
13518 }
13519 }
13520
13521 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
13522 CAN_COMPLETE_NORMALLY (bc_label) = 1;
13523
13524 /* Our break/continue don't return values. */
13525 TREE_TYPE (node) = void_type_node;
13526 /* Encapsulate the break within a compound statement so that it's
13527 expanded all the times by expand_expr (and not clobered
13528 sometimes, like after a if statement) */
13529 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
13530 TREE_SIDE_EFFECTS (node) = 1;
13531 return node;
13532 }
13533
13534 /* Process the exit expression belonging to a loop. Its type must be
13535 boolean. */
13536
13537 static tree
13538 patch_exit_expr (node)
13539 tree node;
13540 {
13541 tree expression = TREE_OPERAND (node, 0);
13542 TREE_TYPE (node) = error_mark_node;
13543 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13544
13545 /* The type of expression must be boolean */
13546 if (TREE_TYPE (expression) != boolean_type_node)
13547 {
13548 parse_error_context
13549 (wfl_operator,
13550 "Incompatible type for loop conditional. Can't convert `%s' to "
13551 "`boolean'",
13552 lang_printable_name (TREE_TYPE (expression), 0));
13553 return error_mark_node;
13554 }
13555 /* Now we know things are allright, invert the condition, fold and
13556 return */
13557 TREE_OPERAND (node, 0) =
13558 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
13559
13560 if (! integer_zerop (TREE_OPERAND (node, 0))
13561 && ctxp->current_loop != NULL_TREE
13562 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
13563 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
13564 if (! integer_onep (TREE_OPERAND (node, 0)))
13565 CAN_COMPLETE_NORMALLY (node) = 1;
13566
13567
13568 TREE_TYPE (node) = void_type_node;
13569 return node;
13570 }
13571
13572 /* 14.9 Switch statement */
13573
13574 static tree
13575 patch_switch_statement (node)
13576 tree node;
13577 {
13578 tree se = TREE_OPERAND (node, 0), se_type;
13579
13580 /* Complete the switch expression */
13581 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
13582 se_type = TREE_TYPE (se);
13583 /* The type of the switch expression must be char, byte, short or
13584 int */
13585 if (!JINTEGRAL_TYPE_P (se_type))
13586 {
13587 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13588 parse_error_context (wfl_operator, "Incompatible type for `switch'. "
13589 "Can't convert `%s' to `int'",
13590 lang_printable_name (se_type, 0));
13591 /* This is what java_complete_tree will check */
13592 TREE_OPERAND (node, 0) = error_mark_node;
13593 return error_mark_node;
13594 }
13595
13596 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13597
13598 /* Ready to return */
13599 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
13600 {
13601 TREE_TYPE (node) = error_mark_node;
13602 return error_mark_node;
13603 }
13604 TREE_TYPE (node) = void_type_node;
13605 TREE_SIDE_EFFECTS (node) = 1;
13606 CAN_COMPLETE_NORMALLY (node)
13607 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
13608 || ! SWITCH_HAS_DEFAULT (node);
13609 return node;
13610 }
13611
13612 /* 14.18 The try statement */
13613
13614 static tree
13615 build_try_statement (location, try_block, catches)
13616 int location;
13617 tree try_block, catches;
13618 {
13619 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
13620 EXPR_WFL_LINECOL (node) = location;
13621 return node;
13622 }
13623
13624 static tree
13625 build_try_finally_statement (location, try_block, finally)
13626 int location;
13627 tree try_block, finally;
13628 {
13629 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
13630 EXPR_WFL_LINECOL (node) = location;
13631 return node;
13632 }
13633
13634 static tree
13635 patch_try_statement (node)
13636 tree node;
13637 {
13638 int error_found = 0;
13639 tree try = TREE_OPERAND (node, 0);
13640 /* Exception handlers are considered in left to right order */
13641 tree catch = nreverse (TREE_OPERAND (node, 1));
13642 tree current, caught_type_list = NULL_TREE;
13643
13644 /* Check catch clauses, if any. Every time we find an error, we try
13645 to process the next catch clause. We process the catch clause before
13646 the try block so that when processing the try block we can check thrown
13647 exceptions againts the caught type list. */
13648 for (current = catch; current; current = TREE_CHAIN (current))
13649 {
13650 tree carg_decl, carg_type;
13651 tree sub_current, catch_block, catch_clause;
13652 int unreachable;
13653
13654 /* At this point, the structure of the catch clause is
13655 CATCH_EXPR (catch node)
13656 BLOCK (with the decl of the parameter)
13657 COMPOUND_EXPR
13658 MODIFY_EXPR (assignment of the catch parameter)
13659 BLOCK (catch clause block)
13660 */
13661 catch_clause = TREE_OPERAND (current, 0);
13662 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
13663 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
13664
13665 /* Catch clauses can't have more than one parameter declared,
13666 but it's already enforced by the grammar. Make sure that the
13667 only parameter of the clause statement in of class Throwable
13668 or a subclass of Throwable, but that was done earlier. The
13669 catch clause parameter type has also been resolved. */
13670
13671 /* Just make sure that the catch clause parameter type inherits
13672 from java.lang.Throwable */
13673 if (!inherits_from_p (carg_type, throwable_type_node))
13674 {
13675 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
13676 parse_error_context (wfl_operator,
13677 "Can't catch class `%s'. Catch clause "
13678 "parameter type must be a subclass of "
13679 "class `java.lang.Throwable'",
13680 lang_printable_name (carg_type, 0));
13681 error_found = 1;
13682 continue;
13683 }
13684
13685 /* Partial check for unreachable catch statement: The catch
13686 clause is reachable iff is no earlier catch block A in
13687 the try statement such that the type of the catch
13688 clause's parameter is the same as or a subclass of the
13689 type of A's parameter */
13690 unreachable = 0;
13691 for (sub_current = catch;
13692 sub_current != current; sub_current = TREE_CHAIN (sub_current))
13693 {
13694 tree sub_catch_clause, decl;
13695 sub_catch_clause = TREE_OPERAND (sub_current, 0);
13696 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
13697
13698 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
13699 {
13700 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
13701 parse_error_context
13702 (wfl_operator, "`catch' not reached because of the catch "
13703 "clause at line %d", EXPR_WFL_LINENO (sub_current));
13704 unreachable = error_found = 1;
13705 break;
13706 }
13707 }
13708 /* Complete the catch clause block */
13709 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
13710 if (catch_block == error_mark_node)
13711 {
13712 error_found = 1;
13713 continue;
13714 }
13715 if (CAN_COMPLETE_NORMALLY (catch_block))
13716 CAN_COMPLETE_NORMALLY (node) = 1;
13717 TREE_OPERAND (current, 0) = catch_block;
13718
13719 if (unreachable)
13720 continue;
13721
13722 /* Things to do here: the exception must be thrown */
13723
13724 /* Link this type to the caught type list */
13725 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
13726 }
13727
13728 PUSH_EXCEPTIONS (caught_type_list);
13729 if ((try = java_complete_tree (try)) == error_mark_node)
13730 error_found = 1;
13731 if (CAN_COMPLETE_NORMALLY (try))
13732 CAN_COMPLETE_NORMALLY (node) = 1;
13733 POP_EXCEPTIONS ();
13734
13735 /* Verification ends here */
13736 if (error_found)
13737 return error_mark_node;
13738
13739 TREE_OPERAND (node, 0) = try;
13740 TREE_OPERAND (node, 1) = catch;
13741 TREE_TYPE (node) = void_type_node;
13742 return node;
13743 }
13744
13745 /* 14.17 The synchronized Statement */
13746
13747 static tree
13748 patch_synchronized_statement (node, wfl_op1)
13749 tree node, wfl_op1;
13750 {
13751 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
13752 tree block = TREE_OPERAND (node, 1);
13753
13754 tree enter, exit, expr_decl, assignment;
13755
13756 if (expr == error_mark_node)
13757 {
13758 block = java_complete_tree (block);
13759 return expr;
13760 }
13761
13762 /* The TYPE of expr must be a reference type */
13763 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
13764 {
13765 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13766 parse_error_context (wfl_operator, "Incompatible type for `synchronized'"
13767 ". Can't convert `%s' to `java.lang.Object'",
13768 lang_printable_name (TREE_TYPE (expr), 0));
13769 return error_mark_node;
13770 }
13771
13772 if (flag_emit_xref)
13773 {
13774 TREE_OPERAND (node, 0) = expr;
13775 TREE_OPERAND (node, 1) = java_complete_tree (block);
13776 CAN_COMPLETE_NORMALLY (node) = 1;
13777 return node;
13778 }
13779
13780 /* Generate a try-finally for the synchronized statement, except
13781 that the handler that catches all throw exception calls
13782 _Jv_MonitorExit and then rethrow the exception.
13783 The synchronized statement is then implemented as:
13784 TRY
13785 {
13786 _Jv_MonitorEnter (expression)
13787 synchronized_block
13788 _Jv_MonitorExit (expression)
13789 }
13790 CATCH_ALL
13791 {
13792 e = _Jv_exception_info ();
13793 _Jv_MonitorExit (expression)
13794 Throw (e);
13795 } */
13796
13797 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
13798 BUILD_MONITOR_ENTER (enter, expr_decl);
13799 BUILD_MONITOR_EXIT (exit, expr_decl);
13800 CAN_COMPLETE_NORMALLY (enter) = 1;
13801 CAN_COMPLETE_NORMALLY (exit) = 1;
13802 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
13803 TREE_SIDE_EFFECTS (assignment) = 1;
13804 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
13805 build (COMPOUND_EXPR, NULL_TREE,
13806 build (WITH_CLEANUP_EXPR, NULL_TREE,
13807 build (COMPOUND_EXPR, NULL_TREE,
13808 assignment, enter),
13809 NULL_TREE, exit),
13810 block));
13811 node = build_expr_block (node, expr_decl);
13812
13813 return java_complete_tree (node);
13814 }
13815
13816 /* 14.16 The throw Statement */
13817
13818 static tree
13819 patch_throw_statement (node, wfl_op1)
13820 tree node, wfl_op1;
13821 {
13822 tree expr = TREE_OPERAND (node, 0);
13823 tree type = TREE_TYPE (expr);
13824 int unchecked_ok = 0, tryblock_throws_ok = 0;
13825
13826 /* Thrown expression must be assignable to java.lang.Throwable */
13827 if (!try_reference_assignconv (throwable_type_node, expr))
13828 {
13829 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13830 parse_error_context (wfl_operator, "Can't throw `%s'; it must be a "
13831 "subclass of class `java.lang.Throwable'",
13832 lang_printable_name (type, 0));
13833 /* If the thrown expression was a reference, we further the
13834 compile-time check. */
13835 if (!JREFERENCE_TYPE_P (type))
13836 return error_mark_node;
13837 }
13838
13839 /* At least one of the following must be true */
13840
13841 /* The type of the throw expression is a not checked exception,
13842 i.e. is a unchecked expression. */
13843 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
13844
13845 /* Throw is contained in a try statement and at least one catch
13846 clause can receive the thrown expression or the current method is
13847 declared to throw such an exception. Or, the throw statement is
13848 contained in a method or constructor declaration and the type of
13849 the Expression is assignable to at least one type listed in the
13850 throws clause the declaration. */
13851 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
13852 if (!unchecked_ok)
13853 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
13854 if (!(unchecked_ok || tryblock_throws_ok))
13855 {
13856 /* If there is a surrounding try block that has no matching
13857 clatch clause, report it first. A surrounding try block exits
13858 only if there is something after the list of checked
13859 exception thrown by the current function (if any). */
13860 if (IN_TRY_BLOCK_P ())
13861 parse_error_context (wfl_operator, "Checked exception `%s' can't be "
13862 "caught by any of the catch clause(s) "
13863 "of the surrounding `try' block",
13864 lang_printable_name (type, 0));
13865 /* If we have no surrounding try statement and the method doesn't have
13866 any throws, report it now. FIXME */
13867
13868 /* We report that the exception can't be throw from a try block
13869 in all circumstances but when the `throw' is inside a static
13870 block. */
13871 else if (!EXCEPTIONS_P (currently_caught_type_list)
13872 && !tryblock_throws_ok)
13873 {
13874 if (IS_CLINIT (current_function_decl))
13875 parse_error_context (wfl_operator, "Checked exception `%s' can't "
13876 "be thrown in initializer",
13877 lang_printable_name (type, 0));
13878 else
13879 parse_error_context (wfl_operator, "Checked exception `%s' isn't "
13880 "thrown from a `try' block",
13881 lang_printable_name (type, 0));
13882 }
13883 /* Otherwise, the current method doesn't have the appropriate
13884 throws declaration */
13885 else
13886 parse_error_context (wfl_operator, "Checked exception `%s' doesn't "
13887 "match any of current method's `throws' "
13888 "declaration(s)",
13889 lang_printable_name (type, 0));
13890 return error_mark_node;
13891 }
13892
13893 if (! flag_emit_class_files && ! flag_emit_xref)
13894 BUILD_THROW (node, expr);
13895
13896 /* If doing xrefs, keep the location where the `throw' was seen. */
13897 if (flag_emit_xref)
13898 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
13899 return node;
13900 }
13901
13902 /* Check that exception said to be thrown by method DECL can be
13903 effectively caught from where DECL is invoked. */
13904
13905 static void
13906 check_thrown_exceptions (location, decl)
13907 int location;
13908 tree decl;
13909 {
13910 tree throws;
13911 /* For all the unchecked exceptions thrown by DECL */
13912 for (throws = DECL_FUNCTION_THROWS (decl); throws;
13913 throws = TREE_CHAIN (throws))
13914 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
13915 {
13916 #if 1
13917 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
13918 if (DECL_NAME (decl) == get_identifier ("clone"))
13919 continue;
13920 #endif
13921 EXPR_WFL_LINECOL (wfl_operator) = location;
13922 parse_error_context
13923 (wfl_operator, "Exception `%s' must be caught, or it must be "
13924 "declared in the `throws' clause of `%s'",
13925 lang_printable_name (TREE_VALUE (throws), 0),
13926 IDENTIFIER_POINTER (DECL_NAME (current_function_decl)));
13927 }
13928 }
13929
13930 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
13931 try-catch blocks, OR is listed in the `throws' clause of the
13932 current method. */
13933
13934 static int
13935 check_thrown_exceptions_do (exception)
13936 tree exception;
13937 {
13938 tree list = currently_caught_type_list;
13939 resolve_and_layout (exception, NULL_TREE);
13940 /* First, all the nested try-catch-finally at that stage. The
13941 last element contains `throws' clause exceptions, if any. */
13942 if (IS_UNCHECKED_EXCEPTION_P (exception))
13943 return 1;
13944 while (list)
13945 {
13946 tree caught;
13947 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
13948 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
13949 return 1;
13950 list = TREE_CHAIN (list);
13951 }
13952 return 0;
13953 }
13954
13955 static void
13956 purge_unchecked_exceptions (mdecl)
13957 tree mdecl;
13958 {
13959 tree throws = DECL_FUNCTION_THROWS (mdecl);
13960 tree new = NULL_TREE;
13961
13962 while (throws)
13963 {
13964 tree next = TREE_CHAIN (throws);
13965 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
13966 {
13967 TREE_CHAIN (throws) = new;
13968 new = throws;
13969 }
13970 throws = next;
13971 }
13972 /* List is inverted here, but it doesn't matter */
13973 DECL_FUNCTION_THROWS (mdecl) = new;
13974 }
13975
13976 /* 15.24 Conditional Operator ?: */
13977
13978 static tree
13979 patch_conditional_expr (node, wfl_cond, wfl_op1)
13980 tree node, wfl_cond, wfl_op1;
13981 {
13982 tree cond = TREE_OPERAND (node, 0);
13983 tree op1 = TREE_OPERAND (node, 1);
13984 tree op2 = TREE_OPERAND (node, 2);
13985 tree resulting_type = NULL_TREE;
13986 tree t1, t2, patched;
13987 int error_found = 0;
13988
13989 /* Operands of ?: might be StringBuffers crafted as a result of a
13990 string concatenation. Obtain a descent operand here. */
13991 if ((patched = patch_string (op1)))
13992 TREE_OPERAND (node, 1) = op1 = patched;
13993 if ((patched = patch_string (op2)))
13994 TREE_OPERAND (node, 2) = op2 = patched;
13995
13996 t1 = TREE_TYPE (op1);
13997 t2 = TREE_TYPE (op2);
13998
13999 /* The first expression must be a boolean */
14000 if (TREE_TYPE (cond) != boolean_type_node)
14001 {
14002 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
14003 parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14004 "convert `%s' to `boolean'",
14005 lang_printable_name (TREE_TYPE (cond), 0));
14006 error_found = 1;
14007 }
14008
14009 /* Second and third can be numeric, boolean (i.e. primitive),
14010 references or null. Anything else results in an error */
14011 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
14012 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
14013 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
14014 || (t1 == boolean_type_node && t2 == boolean_type_node)))
14015 error_found = 1;
14016
14017 /* Determine the type of the conditional expression. Same types are
14018 easy to deal with */
14019 else if (t1 == t2)
14020 resulting_type = t1;
14021
14022 /* There are different rules for numeric types */
14023 else if (JNUMERIC_TYPE_P (t1))
14024 {
14025 /* if byte/short found, the resulting type is short */
14026 if ((t1 == byte_type_node && t2 == short_type_node)
14027 || (t1 == short_type_node && t2 == byte_type_node))
14028 resulting_type = short_type_node;
14029
14030 /* If t1 is a constant int and t2 is of type byte, short or char
14031 and t1's value fits in t2, then the resulting type is t2 */
14032 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
14033 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
14034 resulting_type = t2;
14035
14036 /* If t2 is a constant int and t1 is of type byte, short or char
14037 and t2's value fits in t1, then the resulting type is t1 */
14038 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
14039 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
14040 resulting_type = t1;
14041
14042 /* Otherwise, binary numeric promotion is applied and the
14043 resulting type is the promoted type of operand 1 and 2 */
14044 else
14045 resulting_type = binary_numeric_promotion (t2, t2,
14046 &TREE_OPERAND (node, 1),
14047 &TREE_OPERAND (node, 2));
14048 }
14049
14050 /* Cases of a reference and a null type */
14051 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
14052 resulting_type = t1;
14053
14054 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
14055 resulting_type = t2;
14056
14057 /* Last case: different reference types. If a type can be converted
14058 into the other one by assignment conversion, the latter
14059 determines the type of the expression */
14060 else if ((resulting_type = try_reference_assignconv (t1, op2)))
14061 resulting_type = promote_type (t1);
14062
14063 else if ((resulting_type = try_reference_assignconv (t2, op1)))
14064 resulting_type = promote_type (t2);
14065
14066 /* If we don't have any resulting type, we're in trouble */
14067 if (!resulting_type)
14068 {
14069 char *t = strdup (lang_printable_name (t1, 0));
14070 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14071 parse_error_context (wfl_operator, "Incompatible type for `?:'. Can't "
14072 "convert `%s' to `%s'", t,
14073 lang_printable_name (t2, 0));
14074 free (t);
14075 error_found = 1;
14076 }
14077
14078 if (error_found)
14079 {
14080 TREE_TYPE (node) = error_mark_node;
14081 return error_mark_node;
14082 }
14083
14084 TREE_TYPE (node) = resulting_type;
14085 TREE_SET_CODE (node, COND_EXPR);
14086 CAN_COMPLETE_NORMALLY (node) = 1;
14087 return node;
14088 }
14089
14090 /* Try to constant fold NODE.
14091 If NODE is not a constant expression, return NULL_EXPR.
14092 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
14093
14094 static tree
14095 fold_constant_for_init (node, context)
14096 tree node;
14097 tree context;
14098 {
14099 tree op0, op1, val;
14100 enum tree_code code = TREE_CODE (node);
14101
14102 if (code == INTEGER_CST || code == REAL_CST || code == STRING_CST)
14103 return node;
14104 if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL)
14105 return NULL_TREE;
14106
14107 switch (code)
14108 {
14109 case PLUS_EXPR:
14110 case MINUS_EXPR:
14111 case MULT_EXPR:
14112 case TRUNC_MOD_EXPR:
14113 case RDIV_EXPR:
14114 case LSHIFT_EXPR:
14115 case RSHIFT_EXPR:
14116 case URSHIFT_EXPR:
14117 case BIT_AND_EXPR:
14118 case BIT_XOR_EXPR:
14119 case BIT_IOR_EXPR:
14120 case TRUTH_ANDIF_EXPR:
14121 case TRUTH_ORIF_EXPR:
14122 case EQ_EXPR:
14123 case NE_EXPR:
14124 case GT_EXPR:
14125 case GE_EXPR:
14126 case LT_EXPR:
14127 case LE_EXPR:
14128 op0 = TREE_OPERAND (node, 0);
14129 op1 = TREE_OPERAND (node, 1);
14130 val = fold_constant_for_init (op0, context);
14131 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14132 return NULL_TREE;
14133 TREE_OPERAND (node, 0) = val;
14134 val = fold_constant_for_init (op1, context);
14135 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14136 return NULL_TREE;
14137 TREE_OPERAND (node, 1) = val;
14138 return patch_binop (node, op0, op1);
14139
14140 case UNARY_PLUS_EXPR:
14141 case NEGATE_EXPR:
14142 case TRUTH_NOT_EXPR:
14143 case BIT_NOT_EXPR:
14144 case CONVERT_EXPR:
14145 op0 = TREE_OPERAND (node, 0);
14146 val = fold_constant_for_init (op0, context);
14147 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14148 return NULL_TREE;
14149 TREE_OPERAND (node, 0) = val;
14150 return patch_unaryop (node, op0);
14151 break;
14152
14153 case COND_EXPR:
14154 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
14155 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14156 return NULL_TREE;
14157 TREE_OPERAND (node, 0) = val;
14158 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
14159 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14160 return NULL_TREE;
14161 TREE_OPERAND (node, 1) = val;
14162 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
14163 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14164 return NULL_TREE;
14165 TREE_OPERAND (node, 2) = val;
14166 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
14167 : TREE_OPERAND (node, 2);
14168
14169 case VAR_DECL:
14170 if (! FIELD_STATIC (node) || ! FIELD_FINAL (node)
14171 || DECL_INITIAL (node) == NULL_TREE)
14172 return NULL_TREE;
14173 val = DECL_INITIAL (node);
14174 /* Guard against infinite recursion. */
14175 DECL_INITIAL (node) = NULL_TREE;
14176 val = fold_constant_for_init (val, node);
14177 DECL_INITIAL (node) = val;
14178 return val;
14179
14180 case EXPR_WITH_FILE_LOCATION:
14181 /* Compare java_complete_tree and resolve_expression_name. */
14182 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
14183 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
14184 {
14185 tree name = EXPR_WFL_NODE (node);
14186 tree decl;
14187 if (PRIMARY_P (node))
14188 return NULL_TREE;
14189 else if (! QUALIFIED_P (name))
14190 {
14191 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
14192 if (decl == NULL_TREE || ! FIELD_STATIC (decl))
14193 return NULL_TREE;
14194 return fold_constant_for_init (decl, decl);
14195 }
14196 else
14197 {
14198 #if 0
14199 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
14200 qualify_ambiguous_name (node);
14201 if (resolve_field_access (node, &decl, NULL)
14202 && decl != NULL_TREE)
14203 return fold_constant_for_init (decl, decl);
14204 #endif
14205 return NULL_TREE;
14206 }
14207 }
14208 else
14209 {
14210 op0 = TREE_OPERAND (node, 0);
14211 val = fold_constant_for_init (op0, context);
14212 if (val == NULL_TREE || ! TREE_CONSTANT (val))
14213 return NULL_TREE;
14214 TREE_OPERAND (node, 0) = val;
14215 return val;
14216 }
14217
14218 #ifdef USE_COMPONENT_REF
14219 case IDENTIFIER:
14220 case COMPONENT_REF:
14221 ?;
14222 #endif
14223
14224 default:
14225 return NULL_TREE;
14226 }
14227 }
14228
14229 #ifdef USE_COMPONENT_REF
14230 /* Context is 'T' for TypeName, 'P' for PackageName,
14231 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
14232
14233 tree
14234 resolve_simple_name (name, context)
14235 tree name;
14236 int context;
14237 {
14238 }
14239
14240 tree
14241 resolve_qualified_name (name, context)
14242 tree name;
14243 int context;
14244 {
14245 }
14246 #endif
This page took 0.850167 seconds and 5 git commands to generate.