2 /* A Bison parser, made from ./parse.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse java_parse
9 #define yyerror java_error
10 #define yylval java_lval
11 #define yychar java_char
12 #define yydebug java_debug
13 #define yynerrs java_nerrs
25 #define BOOL_AND_TK 268
26 #define BOOL_OR_TK 269
33 #define PLUS_ASSIGN_TK 276
34 #define MINUS_ASSIGN_TK 277
35 #define MULT_ASSIGN_TK 278
36 #define DIV_ASSIGN_TK 279
37 #define REM_ASSIGN_TK 280
38 #define LS_ASSIGN_TK 281
39 #define SRS_ASSIGN_TK 282
40 #define ZRS_ASSIGN_TK 283
41 #define AND_ASSIGN_TK 284
42 #define XOR_ASSIGN_TK 285
43 #define OR_ASSIGN_TK 286
45 #define PRIVATE_TK 288
46 #define PROTECTED_TK 289
49 #define SYNCHRONIZED_TK 292
50 #define VOLATILE_TK 293
51 #define TRANSIENT_TK 294
54 #define ABSTRACT_TK 297
55 #define MODIFIER_TK 298
58 #define DEFAULT_TK 301
61 #define BOOLEAN_TK 304
63 #define IMPLEMENTS_TK 306
68 #define INSTANCEOF_TK 311
72 #define INTERFACE_TK 315
74 #define EXTENDS_TK 317
75 #define FINALLY_TK 318
84 #define CONTINUE_TK 327
86 #define PACKAGE_TK 329
93 #define INTEGRAL_TK 336
102 #define ASSIGN_ANY_TK 345
103 #define ASSIGN_TK 346
113 #define STRING_LIT_TK 356
114 #define CHAR_LIT_TK 357
115 #define INT_LIT_TK 358
116 #define FP_LIT_TK 359
119 #define BOOL_LIT_TK 362
132 #include "java-tree.h"
140 #include "function.h"
142 #include "defaults.h"
144 #ifndef DIR_SEPARATOR
145 #define DIR_SEPARATOR '/'
148 /* Local function prototypes */
149 static char *java_accstring_lookup PARAMS ((int));
150 static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
151 static void variable_redefinition_error PARAMS ((tree, tree, tree, int));
152 static tree create_class PARAMS ((int, tree, tree, tree));
153 static tree create_interface PARAMS ((int, tree, tree));
154 static void end_class_declaration PARAMS ((int));
155 static tree find_field PARAMS ((tree, tree));
156 static tree lookup_field_wrapper PARAMS ((tree, tree));
157 static int duplicate_declaration_error_p PARAMS ((tree, tree, tree));
158 static void register_fields PARAMS ((int, tree, tree));
159 static tree parser_qualified_classname PARAMS ((int, tree));
160 static int parser_check_super PARAMS ((tree, tree, tree));
161 static int parser_check_super_interface PARAMS ((tree, tree, tree));
162 static void check_modifiers_consistency PARAMS ((int));
163 static tree lookup_cl PARAMS ((tree));
164 static tree lookup_java_method2 PARAMS ((tree, tree, int));
165 static tree method_header PARAMS ((int, tree, tree, tree));
166 static void fix_method_argument_names PARAMS ((tree ,tree));
167 static tree method_declarator PARAMS ((tree, tree));
168 static void parse_warning_context PARAMS ((tree cl, const char *msg, ...))
170 static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list));
171 static void parse_ctor_invocation_error PARAMS ((void));
172 static tree parse_jdk1_1_error PARAMS ((const char *));
173 static void complete_class_report_errors PARAMS ((jdep *));
174 static int process_imports PARAMS ((void));
175 static void read_import_dir PARAMS ((tree));
176 static int find_in_imports_on_demand PARAMS ((tree));
177 static int find_in_imports PARAMS ((tree));
178 static int check_pkg_class_access PARAMS ((tree, tree));
179 static tree resolve_package PARAMS ((tree, tree *));
180 static tree lookup_package_type PARAMS ((const char *, int));
181 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
182 static tree resolve_class PARAMS ((tree, tree, tree, tree));
183 static void declare_local_variables PARAMS ((int, tree, tree));
184 static void source_start_java_method PARAMS ((tree));
185 static void source_end_java_method PARAMS ((void));
186 static void expand_start_java_method PARAMS ((tree));
187 static tree find_name_in_single_imports PARAMS ((tree));
188 static void check_abstract_method_header PARAMS ((tree));
189 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
190 static tree resolve_expression_name PARAMS ((tree, tree *));
191 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
192 static int check_class_interface_creation PARAMS ((int, int, tree,
194 static tree patch_method_invocation PARAMS ((tree, tree, tree,
196 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
197 static tree resolve_and_layout PARAMS ((tree, tree));
198 static tree resolve_no_layout PARAMS ((tree, tree));
199 static int invocation_mode PARAMS ((tree, int));
200 static tree find_applicable_accessible_methods_list PARAMS ((int, tree,
202 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree,
204 static tree find_most_specific_methods_list PARAMS ((tree));
205 static int argument_types_convertible PARAMS ((tree, tree));
206 static tree patch_invoke PARAMS ((tree, tree, tree));
207 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
208 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
209 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
210 static tree obtain_incomplete_type PARAMS ((tree));
211 static tree java_complete_lhs PARAMS ((tree));
212 static tree java_complete_tree PARAMS ((tree));
213 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
214 static int maybe_yank_clinit PARAMS ((tree));
215 static void java_complete_expand_method PARAMS ((tree));
216 static int unresolved_type_p PARAMS ((tree, tree *));
217 static void create_jdep_list PARAMS ((struct parser_ctxt *));
218 static tree build_expr_block PARAMS ((tree, tree));
219 static tree enter_block PARAMS ((void));
220 static tree enter_a_block PARAMS ((tree));
221 static tree exit_block PARAMS ((void));
222 static tree lookup_name_in_blocks PARAMS ((tree));
223 static void maybe_absorb_scoping_blocks PARAMS ((void));
224 static tree build_method_invocation PARAMS ((tree, tree));
225 static tree build_new_invocation PARAMS ((tree, tree));
226 static tree build_assignment PARAMS ((int, int, tree, tree));
227 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
228 static int check_final_assignment PARAMS ((tree ,tree));
229 static tree patch_assignment PARAMS ((tree, tree, tree ));
230 static tree patch_binop PARAMS ((tree, tree, tree));
231 static tree build_unaryop PARAMS ((int, int, tree));
232 static tree build_incdec PARAMS ((int, int, tree, int));
233 static tree patch_unaryop PARAMS ((tree, tree));
234 static tree build_cast PARAMS ((int, tree, tree));
235 static tree build_null_of_type PARAMS ((tree));
236 static tree patch_cast PARAMS ((tree, tree));
237 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
238 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
239 static int valid_cast_to_p PARAMS ((tree, tree));
240 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
241 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
242 static tree try_reference_assignconv PARAMS ((tree, tree));
243 static tree build_unresolved_array_type PARAMS ((tree));
244 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
245 static tree build_array_ref PARAMS ((int, tree, tree));
246 static tree patch_array_ref PARAMS ((tree));
247 static tree make_qualified_name PARAMS ((tree, tree, int));
248 static tree merge_qualified_name PARAMS ((tree, tree));
249 static tree make_qualified_primary PARAMS ((tree, tree, int));
250 static int resolve_qualified_expression_name PARAMS ((tree, tree *,
252 static void qualify_ambiguous_name PARAMS ((tree));
253 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
254 static tree build_newarray_node PARAMS ((tree, tree, int));
255 static tree patch_newarray PARAMS ((tree));
256 static tree resolve_type_during_patch PARAMS ((tree));
257 static tree build_this PARAMS ((int));
258 static tree build_wfl_wrap PARAMS ((tree));
259 static tree build_return PARAMS ((int, tree));
260 static tree patch_return PARAMS ((tree));
261 static tree maybe_access_field PARAMS ((tree, tree, tree));
262 static int complete_function_arguments PARAMS ((tree));
263 static int check_for_static_method_reference PARAMS ((tree, tree, tree,
265 static int not_accessible_p PARAMS ((tree, tree, int));
266 static void check_deprecation PARAMS ((tree, tree));
267 static int class_in_current_package PARAMS ((tree));
268 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
269 static tree patch_if_else_statement PARAMS ((tree));
270 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
271 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
272 static tree patch_exit_expr PARAMS ((tree));
273 static tree build_labeled_block PARAMS ((int, tree));
274 static tree finish_labeled_statement PARAMS ((tree, tree));
275 static tree build_bc_statement PARAMS ((int, int, tree));
276 static tree patch_bc_statement PARAMS ((tree));
277 static tree patch_loop_statement PARAMS ((tree));
278 static tree build_new_loop PARAMS ((tree));
279 static tree build_loop_body PARAMS ((int, tree, int));
280 static tree finish_loop_body PARAMS ((int, tree, tree, int));
281 static tree build_debugable_stmt PARAMS ((int, tree));
282 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
283 static tree patch_switch_statement PARAMS ((tree));
284 static tree string_constant_concatenation PARAMS ((tree, tree));
285 static tree build_string_concatenation PARAMS ((tree, tree));
286 static tree patch_string_cst PARAMS ((tree));
287 static tree patch_string PARAMS ((tree));
288 static tree build_try_statement PARAMS ((int, tree, tree));
289 static tree build_try_finally_statement PARAMS ((int, tree, tree));
290 static tree patch_try_statement PARAMS ((tree));
291 static tree patch_synchronized_statement PARAMS ((tree, tree));
292 static tree patch_throw_statement PARAMS ((tree, tree));
293 static void check_thrown_exceptions PARAMS ((int, tree));
294 static int check_thrown_exceptions_do PARAMS ((tree));
295 static void purge_unchecked_exceptions PARAMS ((tree));
296 static void check_throws_clauses PARAMS ((tree, tree, tree));
297 static void finish_method_declaration PARAMS ((tree));
298 static tree build_super_invocation PARAMS ((tree));
299 static int verify_constructor_circularity PARAMS ((tree, tree));
300 static char *constructor_circularity_msg PARAMS ((tree, tree));
301 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
303 static const char *get_printable_method_name PARAMS ((tree));
304 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
305 static tree generate_finit PARAMS ((tree));
306 static void add_instance_initializer PARAMS ((tree));
307 static void fix_constructors PARAMS ((tree));
308 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
310 static void craft_constructor PARAMS ((tree, tree));
311 static int verify_constructor_super PARAMS ((tree));
312 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
313 static void start_artificial_method_body PARAMS ((tree));
314 static void end_artificial_method_body PARAMS ((tree));
315 static int check_method_redefinition PARAMS ((tree, tree));
316 static int reset_method_name PARAMS ((tree));
317 static int check_method_types_complete PARAMS ((tree));
318 static void java_check_regular_methods PARAMS ((tree));
319 static void java_check_abstract_methods PARAMS ((tree));
320 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
321 static void unreachable_stmt_error PARAMS ((tree));
322 static tree find_expr_with_wfl PARAMS ((tree));
323 static void missing_return_error PARAMS ((tree));
324 static tree build_new_array_init PARAMS ((int, tree));
325 static tree patch_new_array_init PARAMS ((tree, tree));
326 static tree maybe_build_array_element_wfl PARAMS ((tree));
327 static int array_constructor_check_entry PARAMS ((tree, tree));
328 static const char *purify_type_name PARAMS ((const char *));
329 static tree fold_constant_for_init PARAMS ((tree, tree));
330 static tree strip_out_static_field_access_decl PARAMS ((tree));
331 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
332 static void static_ref_err PARAMS ((tree, tree, tree));
333 static void parser_add_interface PARAMS ((tree, tree, tree));
334 static void add_superinterfaces PARAMS ((tree, tree));
335 static tree jdep_resolve_class PARAMS ((jdep *));
336 static int note_possible_classname PARAMS ((const char *, int));
337 static void java_complete_expand_classes PARAMS ((void));
338 static void java_complete_expand_class PARAMS ((tree));
339 static void java_complete_expand_methods PARAMS ((tree));
340 static tree cut_identifier_in_qualified PARAMS ((tree));
341 static tree java_stabilize_reference PARAMS ((tree));
342 static tree do_unary_numeric_promotion PARAMS ((tree));
343 static char * operator_string PARAMS ((tree));
344 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
345 static tree merge_string_cste PARAMS ((tree, tree, int));
346 static tree java_refold PARAMS ((tree));
347 static int java_decl_equiv PARAMS ((tree, tree));
348 static int binop_compound_p PARAMS ((enum tree_code));
349 static tree search_loop PARAMS ((tree));
350 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
351 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
352 static void java_check_abstract_method_definitions PARAMS ((tree));
353 static void java_debug_context_do PARAMS ((int));
354 static void java_parser_context_push_initialized_field PARAMS ((void));
355 static void java_parser_context_pop_initialized_field PARAMS ((void));
356 static tree reorder_static_initialized PARAMS ((tree));
357 static void java_parser_context_suspend PARAMS ((void));
358 static void java_parser_context_resume PARAMS ((void));
360 /* JDK 1.1 work. FIXME */
362 static tree maybe_make_nested_class_name PARAMS ((tree));
363 static void make_nested_class_name PARAMS ((tree));
364 static void set_nested_class_simple_name_value PARAMS ((tree, int));
365 static void link_nested_class_to_enclosing PARAMS ((void));
366 static tree find_as_inner_class PARAMS ((tree, tree, tree));
367 static tree find_as_inner_class_do PARAMS ((tree, tree));
368 static int check_inner_class_redefinition PARAMS ((tree, tree));
370 static tree build_thisn_assign PARAMS ((void));
371 static tree build_current_thisn PARAMS ((tree));
372 static tree build_access_to_thisn PARAMS ((tree, tree, int));
373 static tree maybe_build_thisn_access_method PARAMS ((tree));
375 static tree build_outer_field_access PARAMS ((tree, tree));
376 static tree build_outer_field_access_methods PARAMS ((tree));
377 static tree build_outer_field_access_expr PARAMS ((int, tree, tree,
379 static tree build_outer_method_access_method PARAMS ((tree));
380 static tree build_new_access_id PARAMS ((void));
381 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
384 static int outer_field_access_p PARAMS ((tree, tree));
385 static int outer_field_expanded_access_p PARAMS ((tree, tree *,
387 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
388 static tree build_incomplete_class_ref PARAMS ((int, tree));
389 static tree patch_incomplete_class_ref PARAMS ((tree));
390 static tree create_anonymous_class PARAMS ((int, tree));
391 static void patch_anonymous_class PARAMS ((tree, tree, tree));
392 static void add_inner_class_fields PARAMS ((tree, tree));
394 static tree build_dot_class_method PARAMS ((tree));
395 static tree build_dot_class_method_invocation PARAMS ((tree));
396 static void create_new_parser_context PARAMS ((int));
398 /* Number of error found so far. */
399 int java_error_count;
400 /* Number of warning found so far. */
401 int java_warning_count;
402 /* Tell when not to fold, when doing xrefs */
404 /* Cyclic inheritance report, as it can be set by layout_class */
405 char *cyclic_inheritance_report;
407 /* Tell when we're within an instance initializer */
408 static int in_instance_initializer;
410 /* The current parser context */
411 struct parser_ctxt *ctxp;
413 /* List of things that were analyzed for which code will be generated */
414 static struct parser_ctxt *ctxp_for_generation = NULL;
416 /* binop_lookup maps token to tree_code. It is used where binary
417 operations are involved and required by the parser. RDIV_EXPR
418 covers both integral/floating point division. The code is changed
419 once the type of both operator is worked out. */
421 static enum tree_code binop_lookup[19] =
423 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
424 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
425 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
426 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
427 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
429 #define BINOP_LOOKUP(VALUE) \
430 binop_lookup [((VALUE) - PLUS_TK)% \
431 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
433 /* This is the end index for binary operators that can also be used
434 in compound assignements. */
435 #define BINOP_COMPOUND_CANDIDATES 11
437 /* Fake WFL used to report error message. It is initialized once if
438 needed and reused with it's location information is overriden. */
439 tree wfl_operator = NULL_TREE;
441 /* The "$L" identifier we use to create labels. */
442 static tree label_id = NULL_TREE;
444 /* The "StringBuffer" identifier used for the String `+' operator. */
445 static tree wfl_string_buffer = NULL_TREE;
447 /* The "append" identifier used for String `+' operator. */
448 static tree wfl_append = NULL_TREE;
450 /* The "toString" identifier used for String `+' operator. */
451 static tree wfl_to_string = NULL_TREE;
453 /* The "java.lang" import qualified name. */
454 static tree java_lang_id = NULL_TREE;
456 /* The generated `inst$' identifier used for generated enclosing
457 instance/field access functions. */
458 static tree inst_id = NULL_TREE;
460 /* The "java.lang.Cloneable" qualified name. */
461 static tree java_lang_cloneable = NULL_TREE;
463 /* Context and flag for static blocks */
464 static tree current_static_block = NULL_TREE;
466 /* The generated `write_parm_value$' identifier. */
469 /* The list of all packages we've seen so far */
470 static tree package_list = NULL_TREE;
472 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
473 line and point it out. */
474 /* Should point out the one that don't fit. ASCII/unicode, going
477 #define check_modifiers(__message, __value, __mask) do { \
478 if ((__value) & ~(__mask)) \
480 int i, remainder = (__value) & ~(__mask); \
481 for (i = 0; i <= 10; i++) \
482 if ((1 << i) & remainder) \
483 parse_error_context (ctxp->modifier_ctx [i], (__message), \
484 java_accstring_lookup (1 << i)); \
489 #line 415 "./parse.y"
499 #line 425 "./parse.y"
517 #define YYFLAG -32768
520 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
522 static const char yytranslate[] = { 0,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
549 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
550 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
551 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
552 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
553 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
554 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
555 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
556 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
557 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
558 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
563 static const short yyprhs[] = { 0,
564 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
565 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
566 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
567 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
568 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
569 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
570 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
571 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
572 229, 231, 233, 235, 238, 240, 242, 244, 248, 253,
573 255, 259, 263, 265, 269, 273, 278, 280, 284, 287,
574 291, 295, 297, 299, 300, 304, 307, 311, 315, 320,
575 325, 328, 332, 335, 339, 342, 346, 351, 355, 359,
576 363, 365, 369, 373, 376, 380, 383, 387, 389, 390,
577 393, 396, 398, 402, 406, 408, 411, 413, 416, 420,
578 422, 423, 427, 430, 434, 438, 443, 446, 450, 454,
579 459, 461, 464, 469, 475, 483, 490, 492, 494, 495,
580 500, 501, 507, 508, 514, 515, 522, 526, 531, 534,
581 538, 541, 545, 548, 552, 554, 557, 559, 561, 563,
582 565, 567, 570, 573, 576, 580, 585, 587, 591, 595,
583 598, 602, 604, 606, 608, 611, 613, 615, 617, 620,
584 623, 627, 629, 631, 633, 635, 637, 639, 641, 643,
585 645, 647, 649, 651, 653, 655, 657, 659, 661, 663,
586 665, 667, 669, 671, 673, 676, 679, 682, 685, 688,
587 691, 694, 697, 701, 706, 711, 717, 722, 728, 735,
588 743, 750, 752, 754, 756, 758, 760, 762, 764, 770,
589 773, 777, 782, 790, 798, 799, 803, 808, 811, 815,
590 821, 824, 828, 832, 837, 839, 842, 845, 847, 850,
591 854, 857, 860, 864, 867, 872, 875, 878, 882, 887,
592 890, 892, 900, 908, 915, 919, 925, 930, 938, 945,
593 948, 951, 955, 958, 959, 961, 963, 966, 967, 969,
594 971, 975, 979, 982, 986, 989, 993, 996, 1000, 1003,
595 1007, 1010, 1014, 1017, 1021, 1025, 1028, 1032, 1038, 1044,
596 1047, 1052, 1056, 1058, 1062, 1066, 1071, 1074, 1076, 1079,
597 1082, 1087, 1090, 1094, 1099, 1102, 1105, 1107, 1109, 1111,
598 1113, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1135, 1139,
599 1143, 1147, 1151, 1155, 1159, 1163, 1167, 1171, 1177, 1182,
600 1184, 1189, 1195, 1201, 1208, 1212, 1216, 1221, 1227, 1230,
601 1234, 1235, 1243, 1244, 1251, 1255, 1259, 1261, 1265, 1269,
602 1273, 1277, 1282, 1287, 1292, 1297, 1301, 1305, 1307, 1310,
603 1314, 1318, 1321, 1324, 1328, 1332, 1336, 1340, 1343, 1347,
604 1352, 1358, 1365, 1371, 1378, 1383, 1388, 1393, 1398, 1402,
605 1407, 1411, 1416, 1418, 1420, 1422, 1424, 1427, 1430, 1432,
606 1434, 1437, 1440, 1442, 1445, 1448, 1451, 1454, 1457, 1460,
607 1462, 1465, 1468, 1470, 1473, 1476, 1482, 1487, 1492, 1498,
608 1503, 1506, 1512, 1517, 1523, 1525, 1529, 1533, 1537, 1541,
609 1545, 1549, 1551, 1555, 1559, 1563, 1567, 1569, 1573, 1577,
610 1581, 1585, 1589, 1593, 1595, 1599, 1603, 1607, 1611, 1615,
611 1619, 1623, 1627, 1631, 1635, 1637, 1641, 1645, 1649, 1653,
612 1655, 1659, 1663, 1665, 1669, 1673, 1675, 1679, 1683, 1685,
613 1689, 1693, 1695, 1699, 1703, 1705, 1711, 1716, 1720, 1726,
614 1728, 1730, 1734, 1738, 1740, 1742, 1744, 1746, 1748, 1750
617 static const short yyrhs[] = { 123,
618 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
619 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
620 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
621 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
622 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
623 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
624 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
625 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
626 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
627 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
628 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
629 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
630 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
631 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
632 167, 0, 99, 0, 1, 0, 44, 0, 131, 44,
633 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
634 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
635 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
636 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
637 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
638 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
639 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
640 0, 139, 140, 0, 141, 0, 157, 0, 159, 0,
641 180, 0, 142, 0, 142, 99, 0, 147, 0, 132,
642 0, 167, 0, 112, 143, 99, 0, 131, 112, 143,
643 99, 0, 144, 0, 143, 100, 144, 0, 143, 100,
644 1, 0, 145, 0, 145, 92, 146, 0, 145, 92,
645 1, 0, 145, 92, 146, 1, 0, 122, 0, 145,
646 97, 98, 0, 122, 1, 0, 145, 97, 1, 0,
647 145, 98, 1, 0, 270, 0, 178, 0, 0, 149,
648 148, 156, 0, 149, 1, 0, 112, 150, 154, 0,
649 59, 150, 154, 0, 131, 112, 150, 154, 0, 131,
650 59, 150, 154, 0, 112, 1, 0, 131, 112, 1,
651 0, 59, 1, 0, 131, 59, 1, 0, 131, 1,
652 0, 122, 93, 94, 0, 122, 93, 151, 94, 0,
653 150, 97, 98, 0, 122, 93, 1, 0, 150, 97,
654 1, 0, 152, 0, 151, 100, 152, 0, 151, 100,
655 1, 0, 112, 145, 0, 153, 112, 145, 0, 112,
656 1, 0, 153, 112, 1, 0, 131, 0, 0, 53,
657 155, 0, 53, 1, 0, 116, 0, 155, 100, 116,
658 0, 155, 100, 1, 0, 180, 0, 180, 99, 0,
659 99, 0, 158, 180, 0, 158, 180, 99, 0, 131,
660 0, 0, 161, 160, 163, 0, 162, 154, 0, 131,
661 162, 154, 0, 120, 93, 94, 0, 120, 93, 151,
662 94, 0, 181, 164, 0, 181, 165, 164, 0, 181,
663 183, 164, 0, 181, 165, 183, 164, 0, 182, 0,
664 182, 99, 0, 166, 93, 94, 99, 0, 166, 93,
665 239, 94, 99, 0, 119, 101, 65, 93, 239, 94,
666 99, 0, 119, 101, 65, 93, 94, 99, 0, 76,
667 0, 65, 0, 0, 61, 122, 168, 173, 0, 0,
668 131, 61, 122, 169, 173, 0, 0, 61, 122, 172,
669 170, 173, 0, 0, 131, 61, 122, 172, 171, 173,
670 0, 61, 122, 1, 0, 131, 61, 122, 1, 0,
671 63, 117, 0, 172, 100, 117, 0, 63, 1, 0,
672 172, 100, 1, 0, 95, 96, 0, 95, 174, 96,
673 0, 175, 0, 174, 175, 0, 176, 0, 177, 0,
674 132, 0, 167, 0, 142, 0, 149, 99, 0, 149,
675 1, 0, 95, 96, 0, 95, 179, 96, 0, 95,
676 179, 100, 96, 0, 146, 0, 179, 100, 146, 0,
677 179, 100, 1, 0, 95, 96, 0, 181, 183, 182,
678 0, 95, 0, 96, 0, 184, 0, 183, 184, 0,
679 185, 0, 187, 0, 132, 0, 186, 99, 0, 112,
680 143, 0, 153, 112, 143, 0, 189, 0, 192, 0,
681 196, 0, 197, 0, 208, 0, 212, 0, 189, 0,
682 193, 0, 198, 0, 209, 0, 213, 0, 180, 0,
683 190, 0, 194, 0, 199, 0, 211, 0, 219, 0,
684 220, 0, 221, 0, 223, 0, 222, 0, 225, 0,
685 99, 0, 122, 88, 0, 191, 187, 0, 122, 1,
686 0, 191, 188, 0, 195, 99, 0, 1, 99, 0,
687 1, 95, 0, 1, 96, 0, 166, 93, 1, 0,
688 166, 93, 94, 1, 0, 166, 93, 239, 1, 0,
689 166, 93, 239, 94, 1, 0, 119, 101, 65, 1,
690 0, 119, 101, 65, 93, 1, 0, 119, 101, 65,
691 93, 239, 1, 0, 119, 101, 65, 93, 239, 94,
692 1, 0, 119, 101, 65, 93, 94, 1, 0, 267,
693 0, 251, 0, 252, 0, 248, 0, 249, 0, 245,
694 0, 234, 0, 48, 93, 270, 94, 187, 0, 48,
695 1, 0, 48, 93, 1, 0, 48, 93, 270, 1,
696 0, 48, 93, 270, 94, 188, 56, 187, 0, 48,
697 93, 270, 94, 188, 56, 188, 0, 0, 201, 200,
698 202, 0, 68, 93, 270, 94, 0, 68, 1, 0,
699 68, 93, 1, 0, 68, 93, 270, 94, 1, 0,
700 95, 96, 0, 95, 205, 96, 0, 95, 203, 96,
701 0, 95, 203, 205, 96, 0, 204, 0, 203, 204,
702 0, 205, 183, 0, 206, 0, 205, 206, 0, 62,
703 271, 88, 0, 47, 88, 0, 62, 1, 0, 62,
704 271, 1, 0, 47, 1, 0, 66, 93, 270, 94,
705 0, 207, 187, 0, 66, 1, 0, 66, 93, 1,
706 0, 66, 93, 270, 1, 0, 207, 188, 0, 51,
707 0, 210, 187, 66, 93, 270, 94, 99, 0, 215,
708 99, 270, 99, 217, 94, 187, 0, 215, 99, 99,
709 217, 94, 187, 0, 215, 99, 1, 0, 215, 99,
710 270, 99, 1, 0, 215, 99, 99, 1, 0, 215,
711 99, 270, 99, 217, 94, 188, 0, 215, 99, 99,
712 217, 94, 188, 0, 71, 93, 0, 71, 1, 0,
713 71, 93, 1, 0, 214, 216, 0, 0, 218, 0,
714 186, 0, 218, 1, 0, 0, 218, 0, 195, 0,
715 218, 100, 195, 0, 218, 100, 1, 0, 54, 99,
716 0, 54, 122, 99, 0, 54, 1, 0, 54, 122,
717 1, 0, 73, 99, 0, 73, 122, 99, 0, 73,
718 1, 0, 73, 122, 1, 0, 58, 99, 0, 58,
719 270, 99, 0, 58, 1, 0, 58, 270, 1, 0,
720 49, 270, 99, 0, 49, 1, 0, 49, 270, 1,
721 0, 224, 93, 270, 94, 180, 0, 224, 93, 270,
722 94, 1, 0, 224, 1, 0, 224, 93, 1, 94,
723 0, 224, 93, 1, 0, 131, 0, 70, 180, 226,
724 0, 70, 180, 229, 0, 70, 180, 226, 229, 0,
725 70, 1, 0, 227, 0, 226, 227, 0, 228, 180,
726 0, 60, 93, 152, 94, 0, 60, 1, 0, 60,
727 93, 1, 0, 60, 93, 1, 94, 0, 64, 180,
728 0, 64, 1, 0, 231, 0, 240, 0, 111, 0,
729 76, 0, 93, 270, 94, 0, 234, 0, 244, 0,
730 245, 0, 246, 0, 233, 0, 119, 101, 76, 0,
731 93, 270, 1, 0, 119, 101, 1, 0, 113, 101,
732 1, 0, 59, 101, 1, 0, 113, 97, 98, 0,
733 119, 97, 98, 0, 119, 101, 67, 0, 232, 101,
734 67, 0, 113, 101, 67, 0, 59, 101, 67, 0,
735 72, 116, 93, 239, 94, 0, 72, 116, 93, 94,
736 0, 235, 0, 238, 122, 93, 94, 0, 238, 122,
737 93, 94, 138, 0, 238, 122, 93, 239, 94, 0,
738 238, 122, 93, 239, 94, 138, 0, 72, 1, 99,
739 0, 72, 116, 1, 0, 72, 116, 93, 1, 0,
740 72, 116, 93, 239, 1, 0, 238, 1, 0, 238,
741 122, 1, 0, 0, 72, 116, 93, 239, 94, 236,
742 138, 0, 0, 72, 116, 93, 94, 237, 138, 0,
743 119, 101, 72, 0, 230, 101, 72, 0, 270, 0,
744 239, 100, 270, 0, 239, 100, 1, 0, 72, 113,
745 241, 0, 72, 115, 241, 0, 72, 113, 241, 243,
746 0, 72, 115, 241, 243, 0, 72, 115, 243, 178,
747 0, 72, 113, 243, 178, 0, 72, 1, 98, 0,
748 72, 1, 97, 0, 242, 0, 241, 242, 0, 97,
749 270, 98, 0, 97, 270, 1, 0, 97, 1, 0,
750 97, 98, 0, 243, 97, 98, 0, 243, 97, 1,
751 0, 230, 101, 122, 0, 65, 101, 122, 0, 65,
752 1, 0, 119, 93, 94, 0, 119, 93, 239, 94,
753 0, 230, 101, 122, 93, 94, 0, 230, 101, 122,
754 93, 239, 94, 0, 65, 101, 122, 93, 94, 0,
755 65, 101, 122, 93, 239, 94, 0, 65, 101, 1,
756 94, 0, 65, 101, 1, 101, 0, 119, 97, 270,
757 98, 0, 231, 97, 270, 98, 0, 119, 97, 1,
758 0, 119, 97, 270, 1, 0, 231, 97, 1, 0,
759 231, 97, 270, 1, 0, 230, 0, 119, 0, 248,
760 0, 249, 0, 247, 46, 0, 247, 45, 0, 251,
761 0, 252, 0, 3, 250, 0, 4, 250, 0, 253,
762 0, 3, 1, 0, 4, 1, 0, 46, 250, 0,
763 46, 1, 0, 45, 250, 0, 45, 1, 0, 247,
764 0, 89, 250, 0, 90, 250, 0, 254, 0, 89,
765 1, 0, 90, 1, 0, 93, 113, 243, 94, 250,
766 0, 93, 113, 94, 250, 0, 93, 270, 94, 253,
767 0, 93, 119, 243, 94, 253, 0, 93, 113, 97,
768 1, 0, 93, 1, 0, 93, 113, 243, 94, 1,
769 0, 93, 113, 94, 1, 0, 93, 119, 243, 94,
770 1, 0, 250, 0, 255, 5, 250, 0, 255, 6,
771 250, 0, 255, 7, 250, 0, 255, 5, 1, 0,
772 255, 6, 1, 0, 255, 7, 1, 0, 255, 0,
773 256, 3, 255, 0, 256, 4, 255, 0, 256, 3,
774 1, 0, 256, 4, 1, 0, 256, 0, 257, 8,
775 256, 0, 257, 9, 256, 0, 257, 10, 256, 0,
776 257, 8, 1, 0, 257, 9, 1, 0, 257, 10,
777 1, 0, 257, 0, 258, 20, 257, 0, 258, 18,
778 257, 0, 258, 21, 257, 0, 258, 19, 257, 0,
779 258, 57, 114, 0, 258, 20, 1, 0, 258, 18,
780 1, 0, 258, 21, 1, 0, 258, 19, 1, 0,
781 258, 57, 1, 0, 258, 0, 259, 16, 258, 0,
782 259, 17, 258, 0, 259, 16, 1, 0, 259, 17,
783 1, 0, 259, 0, 260, 11, 259, 0, 260, 11,
784 1, 0, 260, 0, 261, 12, 260, 0, 261, 12,
785 1, 0, 261, 0, 262, 13, 261, 0, 262, 13,
786 1, 0, 262, 0, 263, 14, 262, 0, 263, 14,
787 1, 0, 263, 0, 264, 15, 263, 0, 264, 15,
788 1, 0, 264, 0, 264, 87, 270, 88, 265, 0,
789 264, 87, 88, 1, 0, 264, 87, 1, 0, 264,
790 87, 270, 88, 1, 0, 265, 0, 267, 0, 268,
791 269, 266, 0, 268, 269, 1, 0, 119, 0, 244,
792 0, 246, 0, 91, 0, 92, 0, 266, 0, 270,
799 static const short yyrline[] = { 0,
800 574, 580, 582, 583, 584, 585, 586, 590, 592, 595,
801 597, 598, 601, 603, 606, 610, 614, 618, 624, 626,
802 628, 630, 635, 637, 640, 644, 649, 654, 656, 657,
803 658, 659, 660, 661, 662, 665, 670, 676, 678, 681,
804 687, 689, 693, 695, 698, 725, 727, 731, 744, 746,
805 750, 753, 755, 757, 767, 772, 787, 791, 791, 794,
806 794, 796, 798, 803, 807, 809, 811, 813, 817, 819,
807 821, 828, 834, 839, 843, 852, 862, 864, 867, 869,
808 870, 871, 878, 880, 882, 883, 885, 890, 893, 903,
809 906, 908, 912, 915, 922, 928, 936, 938, 940, 942,
810 944, 948, 950, 954, 965, 966, 970, 973, 975, 977,
811 979, 984, 986, 988, 990, 997, 1003, 1005, 1014, 1016,
812 1020, 1025, 1030, 1034, 1039, 1044, 1049, 1056, 1066, 1068,
813 1070, 1074, 1077, 1079, 1083, 1085, 1086, 1091, 1097, 1104,
814 1120, 1127, 1130, 1133, 1137, 1143, 1147, 1156, 1158, 1160,
815 1164, 1166, 1169, 1176, 1184, 1186, 1190, 1197, 1207, 1211,
816 1211, 1214, 1214, 1217, 1217, 1220, 1220, 1222, 1226, 1232,
817 1237, 1239, 1243, 1246, 1250, 1252, 1255, 1257, 1258, 1260,
818 1264, 1268, 1274, 1279, 1282, 1284, 1288, 1294, 1298, 1303,
819 1312, 1316, 1321, 1335, 1337, 1340, 1342, 1344, 1351, 1355,
820 1358, 1362, 1364, 1365, 1366, 1367, 1368, 1372, 1374, 1375,
821 1376, 1377, 1381, 1383, 1384, 1385, 1386, 1387, 1388, 1389,
822 1390, 1391, 1392, 1395, 1400, 1411, 1414, 1418, 1425, 1435,
823 1441, 1447, 1453, 1455, 1460, 1462, 1467, 1469, 1471, 1473,
824 1475, 1479, 1481, 1482, 1483, 1484, 1485, 1486, 1489, 1495,
825 1497, 1499, 1503, 1508, 1513, 1519, 1529, 1535, 1537, 1539,
826 1546, 1549, 1551, 1553, 1557, 1559, 1562, 1566, 1568, 1571,
827 1578, 1584, 1586, 1588, 1592, 1600, 1603, 1605, 1607, 1611,
828 1616, 1625, 1630, 1633, 1640, 1642, 1644, 1648, 1651, 1660,
829 1667, 1669, 1673, 1686, 1688, 1694, 1700, 1704, 1706, 1710,
830 1713, 1715, 1719, 1722, 1724, 1726, 1730, 1733, 1735, 1737,
831 1741, 1744, 1746, 1748, 1752, 1758, 1760, 1764, 1771, 1773,
832 1775, 1777, 1781, 1793, 1796, 1798, 1803, 1807, 1809, 1816,
833 1824, 1841, 1843, 1848, 1852, 1855, 1860, 1862, 1865, 1867,
834 1869, 1871, 1872, 1873, 1874, 1875, 1879, 1884, 1886, 1888,
835 1890, 1897, 1903, 1912, 1915, 1917, 1919, 1923, 1926, 1928,
836 1932, 1938, 1939, 1945, 1946, 1948, 1950, 1952, 1954, 1956,
837 1965, 1969, 1999, 2002, 2016, 2019, 2023, 2029, 2034, 2038,
838 2041, 2043, 2045, 2049, 2058, 2066, 2068, 2072, 2075, 2079,
839 2085, 2087, 2095, 2122, 2124, 2128, 2133, 2140, 2144, 2147,
840 2149, 2160, 2171, 2176, 2185, 2187, 2191, 2194, 2196, 2201,
841 2206, 2211, 2218, 2220, 2221, 2222, 2225, 2230, 2235, 2237,
842 2238, 2240, 2242, 2243, 2245, 2249, 2252, 2256, 2259, 2263,
843 2265, 2267, 2269, 2270, 2272, 2276, 2285, 2287, 2289, 2302,
844 2304, 2310, 2312, 2314, 2318, 2320, 2325, 2330, 2335, 2337,
845 2339, 2343, 2345, 2350, 2355, 2357, 2361, 2363, 2368, 2373,
846 2378, 2380, 2382, 2386, 2388, 2393, 2398, 2403, 2408, 2410,
847 2412, 2414, 2416, 2418, 2422, 2424, 2429, 2434, 2436, 2440,
848 2442, 2447, 2451, 2453, 2458, 2462, 2464, 2469, 2473, 2475,
849 2480, 2484, 2486, 2491, 2495, 2497, 2502, 2508, 2510, 2514,
850 2516, 2519, 2522, 2530, 2532, 2533, 2536, 2538, 2541, 2545
855 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
857 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
858 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
859 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
860 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
861 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
862 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
863 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
864 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
865 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
866 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
867 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
868 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
869 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
870 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
871 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
872 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
873 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
874 "class_type","interface_type","array_type","name","simple_name","qualified_name",
875 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
876 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
877 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
878 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
879 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
880 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
881 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
882 "class_type_list","method_body","static_initializer","static","constructor_declaration",
883 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
884 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
885 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
886 "interface_member_declaration","constant_declaration","abstract_method_declaration",
887 "array_initializer","variable_initializers","block","block_begin","block_end",
888 "block_statements","block_statement","local_variable_declaration_statement",
889 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
890 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
891 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
892 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
893 "switch_block_statement_group","switch_labels","switch_label","while_expression",
894 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
895 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
896 "statement_expression_list","break_statement","continue_statement","return_statement",
897 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
898 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
899 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
900 "@10","@11","something_dot_new","argument_list","array_creation_expression",
901 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
902 "postfix_expression","post_increment_expression","post_decrement_expression",
903 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
904 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
905 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
906 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
907 "conditional_expression","assignment_expression","assignment","left_hand_side",
908 "assignment_operator","expression","constant_expression", NULL
912 static const short yyr1[] = { 0,
913 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
914 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
915 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
916 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
917 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
918 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
919 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
920 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
921 140, 140, 141, 141, 141, 141, 141, 142, 142, 143,
922 143, 143, 144, 144, 144, 144, 145, 145, 145, 145,
923 145, 146, 146, 148, 147, 147, 149, 149, 149, 149,
924 149, 149, 149, 149, 149, 150, 150, 150, 150, 150,
925 151, 151, 151, 152, 152, 152, 152, 153, 154, 154,
926 154, 155, 155, 155, 156, 156, 156, 157, 157, 158,
927 160, 159, 161, 161, 162, 162, 163, 163, 163, 163,
928 164, 164, 165, 165, 165, 165, 166, 166, 168, 167,
929 169, 167, 170, 167, 171, 167, 167, 167, 172, 172,
930 172, 172, 173, 173, 174, 174, 175, 175, 175, 175,
931 176, 177, 177, 178, 178, 178, 179, 179, 179, 180,
932 180, 181, 182, 183, 183, 184, 184, 184, 185, 186,
933 186, 187, 187, 187, 187, 187, 187, 188, 188, 188,
934 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
935 189, 189, 189, 190, 191, 192, 192, 193, 194, 194,
936 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
937 194, 195, 195, 195, 195, 195, 195, 195, 196, 196,
938 196, 196, 197, 198, 200, 199, 201, 201, 201, 201,
939 202, 202, 202, 202, 203, 203, 204, 205, 205, 206,
940 206, 206, 206, 206, 207, 208, 208, 208, 208, 209,
941 210, 211, 212, 212, 212, 212, 212, 213, 213, 214,
942 214, 214, 215, 216, 216, 216, 216, 217, 217, 218,
943 218, 218, 219, 219, 219, 219, 220, 220, 220, 220,
944 221, 221, 221, 221, 222, 222, 222, 223, 223, 223,
945 223, 223, 224, 225, 225, 225, 225, 226, 226, 227,
946 228, 228, 228, 228, 229, 229, 230, 230, 231, 231,
947 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
948 231, 232, 232, 233, 233, 233, 233, 234, 234, 234,
949 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
950 236, 235, 237, 235, 238, 238, 239, 239, 239, 240,
951 240, 240, 240, 240, 240, 240, 240, 241, 241, 242,
952 242, 242, 243, 243, 243, 244, 244, 244, 245, 245,
953 245, 245, 245, 245, 245, 245, 246, 246, 246, 246,
954 246, 246, 247, 247, 247, 247, 248, 249, 250, 250,
955 250, 250, 250, 250, 250, 251, 251, 252, 252, 253,
956 253, 253, 253, 253, 253, 254, 254, 254, 254, 254,
957 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
958 255, 256, 256, 256, 256, 256, 257, 257, 257, 257,
959 257, 257, 257, 258, 258, 258, 258, 258, 258, 258,
960 258, 258, 258, 258, 259, 259, 259, 259, 259, 260,
961 260, 260, 261, 261, 261, 262, 262, 262, 263, 263,
962 263, 264, 264, 264, 265, 265, 265, 265, 265, 266,
963 266, 267, 267, 268, 268, 268, 269, 269, 270, 271
966 static const short yyr2[] = { 0,
967 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
968 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
969 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
970 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
971 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
972 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
973 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
974 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
975 1, 1, 1, 2, 1, 1, 1, 3, 4, 1,
976 3, 3, 1, 3, 3, 4, 1, 3, 2, 3,
977 3, 1, 1, 0, 3, 2, 3, 3, 4, 4,
978 2, 3, 2, 3, 2, 3, 4, 3, 3, 3,
979 1, 3, 3, 2, 3, 2, 3, 1, 0, 2,
980 2, 1, 3, 3, 1, 2, 1, 2, 3, 1,
981 0, 3, 2, 3, 3, 4, 2, 3, 3, 4,
982 1, 2, 4, 5, 7, 6, 1, 1, 0, 4,
983 0, 5, 0, 5, 0, 6, 3, 4, 2, 3,
984 2, 3, 2, 3, 1, 2, 1, 1, 1, 1,
985 1, 2, 2, 2, 3, 4, 1, 3, 3, 2,
986 3, 1, 1, 1, 2, 1, 1, 1, 2, 2,
987 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
989 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
990 2, 2, 3, 4, 4, 5, 4, 5, 6, 7,
991 6, 1, 1, 1, 1, 1, 1, 1, 5, 2,
992 3, 4, 7, 7, 0, 3, 4, 2, 3, 5,
993 2, 3, 3, 4, 1, 2, 2, 1, 2, 3,
994 2, 2, 3, 2, 4, 2, 2, 3, 4, 2,
995 1, 7, 7, 6, 3, 5, 4, 7, 6, 2,
996 2, 3, 2, 0, 1, 1, 2, 0, 1, 1,
997 3, 3, 2, 3, 2, 3, 2, 3, 2, 3,
998 2, 3, 2, 3, 3, 2, 3, 5, 5, 2,
999 4, 3, 1, 3, 3, 4, 2, 1, 2, 2,
1000 4, 2, 3, 4, 2, 2, 1, 1, 1, 1,
1001 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
1002 3, 3, 3, 3, 3, 3, 3, 5, 4, 1,
1003 4, 5, 5, 6, 3, 3, 4, 5, 2, 3,
1004 0, 7, 0, 6, 3, 3, 1, 3, 3, 3,
1005 3, 4, 4, 4, 4, 3, 3, 1, 2, 3,
1006 3, 2, 2, 3, 3, 3, 3, 2, 3, 4,
1007 5, 6, 5, 6, 4, 4, 4, 4, 3, 4,
1008 3, 4, 1, 1, 1, 1, 2, 2, 1, 1,
1009 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,
1010 2, 2, 1, 2, 2, 5, 4, 4, 5, 4,
1011 2, 5, 4, 5, 1, 3, 3, 3, 3, 3,
1012 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
1013 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1014 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
1015 3, 3, 1, 3, 3, 1, 3, 3, 1, 3,
1016 3, 1, 3, 3, 1, 5, 4, 3, 5, 1,
1017 1, 3, 3, 1, 1, 1, 1, 1, 1, 1
1020 static const short yydefact[] = { 0,
1021 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
1022 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
1023 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
1024 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
1025 167, 0, 0, 163, 63, 0, 69, 42, 40, 0,
1026 0, 0, 61, 0, 49, 0, 26, 171, 17, 169,
1027 15, 0, 160, 0, 0, 68, 16, 0, 0, 59,
1028 168, 0, 165, 64, 69, 50, 48, 12, 0, 10,
1029 11, 173, 0, 8, 9, 13, 14, 15, 0, 179,
1030 181, 0, 180, 0, 175, 177, 178, 172, 170, 164,
1031 67, 71, 72, 70, 0, 162, 0, 57, 113, 0,
1032 129, 111, 0, 0, 90, 93, 129, 0, 0, 0,
1033 115, 0, 0, 183, 182, 174, 176, 0, 0, 60,
1034 166, 0, 0, 0, 0, 108, 99, 88, 0, 0,
1035 0, 0, 107, 21, 18, 22, 20, 19, 114, 129,
1036 112, 0, 129, 74, 73, 192, 75, 23, 0, 86,
1037 0, 77, 79, 83, 85, 0, 80, 0, 81, 141,
1038 129, 87, 82, 0, 58, 119, 116, 0, 128, 0,
1039 121, 0, 131, 132, 130, 120, 118, 92, 0, 91,
1040 95, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1041 0, 0, 0, 6, 5, 2, 3, 4, 7, 339,
1042 0, 414, 0, 103, 413, 337, 0, 346, 342, 360,
1043 0, 338, 343, 344, 345, 430, 415, 416, 445, 419,
1044 420, 423, 433, 452, 457, 464, 475, 480, 483, 486,
1045 489, 492, 495, 500, 509, 501, 0, 102, 100, 98,
1046 101, 110, 89, 109, 190, 0, 129, 76, 78, 84,
1047 106, 0, 138, 0, 143, 0, 0, 0, 281, 0,
1048 0, 0, 0, 0, 0, 0, 0, 340, 0, 224,
1049 0, 8, 414, 0, 128, 198, 0, 0, 213, 0,
1050 194, 196, 0, 197, 202, 214, 0, 203, 215, 0,
1051 204, 205, 216, 255, 0, 206, 0, 217, 207, 294,
1052 0, 218, 219, 220, 222, 221, 0, 223, 248, 247,
1053 0, 245, 246, 243, 244, 242, 126, 124, 117, 0,
1054 0, 0, 424, 414, 343, 345, 421, 425, 422, 429,
1055 428, 427, 426, 0, 398, 0, 0, 0, 16, 0,
1056 434, 431, 435, 432, 441, 0, 414, 0, 184, 187,
1057 0, 0, 0, 0, 0, 0, 96, 0, 0, 0,
1058 369, 0, 418, 417, 0, 0, 0, 0, 0, 0,
1059 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1060 0, 0, 0, 0, 0, 507, 508, 0, 145, 0,
1061 144, 137, 105, 135, 139, 192, 142, 0, 231, 232,
1062 230, 250, 0, 316, 0, 305, 303, 0, 313, 311,
1063 0, 277, 0, 258, 0, 327, 0, 291, 0, 309,
1064 307, 0, 0, 200, 0, 0, 0, 227, 225, 0,
1065 0, 193, 191, 195, 199, 414, 323, 226, 229, 0,
1066 276, 0, 414, 296, 300, 293, 0, 0, 320, 0,
1067 123, 122, 127, 125, 134, 133, 351, 357, 0, 397,
1068 387, 386, 365, 0, 380, 388, 0, 381, 0, 366,
1069 0, 0, 0, 0, 0, 0, 348, 341, 185, 0,
1070 352, 350, 356, 399, 0, 377, 409, 353, 0, 349,
1071 354, 375, 347, 376, 396, 411, 0, 355, 370, 0,
1072 449, 446, 450, 447, 451, 448, 455, 453, 456, 454,
1073 461, 458, 462, 459, 463, 460, 471, 466, 473, 468,
1074 470, 465, 472, 467, 474, 0, 469, 478, 476, 479,
1075 477, 482, 481, 485, 484, 488, 487, 491, 490, 494,
1076 493, 498, 0, 0, 503, 502, 146, 136, 414, 147,
1077 0, 0, 151, 0, 251, 0, 317, 315, 306, 304,
1078 314, 312, 278, 0, 259, 0, 0, 0, 324, 328,
1079 0, 325, 292, 310, 308, 341, 18, 19, 0, 201,
1080 233, 0, 0, 0, 256, 0, 297, 0, 285, 0,
1081 0, 322, 0, 405, 406, 0, 392, 393, 0, 389,
1082 382, 0, 385, 383, 384, 367, 359, 0, 443, 437,
1083 440, 393, 0, 393, 0, 438, 189, 186, 188, 400,
1084 0, 410, 407, 0, 412, 408, 361, 0, 497, 0,
1085 0, 148, 0, 0, 152, 149, 252, 0, 279, 275,
1086 0, 332, 0, 336, 335, 329, 326, 330, 237, 0,
1087 234, 235, 0, 0, 0, 261, 0, 265, 0, 268,
1088 0, 302, 301, 287, 0, 299, 0, 321, 0, 403,
1089 0, 391, 390, 395, 394, 0, 368, 358, 442, 436,
1090 444, 439, 379, 378, 401, 0, 362, 363, 499, 496,
1091 0, 150, 0, 0, 0, 249, 0, 202, 0, 209,
1092 210, 0, 211, 212, 0, 260, 333, 0, 238, 0,
1093 0, 236, 274, 271, 272, 510, 0, 263, 266, 0,
1094 262, 0, 269, 0, 0, 286, 0, 319, 318, 404,
1095 374, 0, 402, 364, 0, 153, 0, 0, 0, 228,
1096 280, 0, 334, 331, 241, 239, 0, 273, 270, 264,
1097 0, 284, 0, 372, 0, 0, 154, 0, 253, 0,
1098 0, 240, 282, 283, 156, 0, 0, 0, 0, 155,
1099 0, 0, 0, 0, 289, 0, 254, 288, 0, 0,
1103 static const short yydefgoto[] = { 789,
1104 210, 281, 211, 85, 86, 68, 60, 87, 212, 22,
1105 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
1106 447, 286, 132, 105, 47, 70, 104, 130, 161, 162,
1107 163, 91, 114, 115, 116, 213, 165, 262, 92, 111,
1108 180, 181, 287, 136, 185, 403, 167, 168, 169, 264,
1109 170, 171, 407, 560, 561, 288, 18, 43, 72, 65,
1110 107, 44, 63, 94, 95, 96, 97, 214, 361, 289,
1111 174, 563, 732, 291, 292, 293, 294, 707, 295, 296,
1112 297, 298, 710, 299, 300, 301, 302, 711, 303, 450,
1113 304, 595, 667, 668, 669, 670, 305, 306, 713, 307,
1114 308, 309, 714, 310, 311, 456, 675, 676, 312, 313,
1115 314, 315, 316, 317, 318, 579, 580, 581, 582, 215,
1116 216, 217, 218, 219, 220, 742, 686, 221, 495, 222,
1117 475, 476, 477, 223, 224, 225, 226, 227, 228, 229,
1118 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
1119 240, 241, 242, 243, 244, 245, 246, 247, 398, 496,
1123 static const short yypact[] = { 356,
1124 -32768,-32768, 158, -35, 339, 439,-32768,-32768, 433, 247,
1125 473,-32768,-32768,-32768,-32768, 29,-32768,-32768,-32768,-32768,
1126 12,-32768,-32768,-32768, 331,-32768, 491,-32768, 71, 469,
1127 -32768,-32768, 520, 562,-32768, -35, 510,-32768,-32768, 278,
1128 -32768, 521, -25, -8,-32768, 526, 349,-32768,-32768, -35,
1129 591, 343,-32768, 508,-32768, 25,-32768,-32768,-32768,-32768,
1130 7, 1014,-32768, 568, -25,-32768,-32768, 346, 594,-32768,
1131 -32768, -25, -8,-32768, 349,-32768,-32768,-32768, 597,-32768,
1132 -32768,-32768, 607, 165,-32768,-32768, 315, 181, 676,-32768,
1133 -32768, 30,-32768, 1034,-32768,-32768,-32768,-32768,-32768,-32768,
1134 -32768,-32768,-32768, 328, 354,-32768, -25,-32768,-32768, 370,
1135 -4,-32768, 449, 733,-32768, 201, -4, 122, 208, 377,
1136 -32768, 608, 616,-32768,-32768,-32768,-32768, 617, 938,-32768,
1137 -32768, 354, 629, 630, 215,-32768,-32768,-32768, 648, 2189,
1138 227, 489,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4,
1139 -32768, 743, -4,-32768,-32768, 412,-32768, 425, 577,-32768,
1140 943,-32768,-32768, 438,-32768, 47,-32768, 455,-32768,-32768,
1141 506,-32768,-32768, 1916,-32768,-32768,-32768, 655, 569, 321,
1142 -32768, 589,-32768,-32768, 532,-32768,-32768,-32768, 485,-32768,
1143 -32768, 3001, 3052, 3117, 3168, 533, 18, 615,-32768, 3233,
1144 3284, 3349, 5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1145 302, 915, 63,-32768, 542, 581, 587,-32768,-32768,-32768,
1146 656,-32768, 766,-32768, 780, 846,-32768,-32768,-32768,-32768,
1147 -32768,-32768,-32768, 879, 896, 937, 893, 880, 697, 701,
1148 717, 741, 74,-32768,-32768,-32768, 841,-32768,-32768,-32768,
1149 -32768,-32768,-32768,-32768,-32768, 774, 506,-32768,-32768,-32768,
1150 -32768, 565, 690, 685,-32768, 600, 172, 3400,-32768, 206,
1151 2240, 17, 311, 342, 82, 426, 211, 700, 5597,-32768,
1152 -35, 651, 837, 229, 522,-32768, 589, 705,-32768, 1848,
1153 -32768,-32768, 702,-32768,-32768,-32768, 1984,-32768,-32768, 709,
1154 -32768,-32768,-32768,-32768, 1984,-32768, 1984,-32768,-32768, 5648,
1155 738,-32768,-32768,-32768,-32768,-32768, 436,-32768, 806, 808,
1156 846, 891, 908,-32768,-32768,-32768,-32768, 869,-32768, 654,
1157 684, 686,-32768, 722,-32768,-32768,-32768,-32768,-32768,-32768,
1158 -32768,-32768,-32768, 27,-32768, 691, 860, 724, 724, 452,
1159 -32768,-32768,-32768,-32768,-32768, 694, 1044, 43,-32768,-32768,
1160 669, 747, 222, 5365, 2305, 538,-32768, 279, 3465, 772,
1161 -32768, 458,-32768,-32768, 3516, 3581, 3632, 3697, 3748, 3813,
1162 3864, 3929, 3980, 4045, 4096, 4161, 721, 4212, 4277, 4328,
1163 4393, 4444, 4509, 4560, 2356,-32768,-32768, 4625,-32768, 368,
1164 -32768,-32768,-32768, 750,-32768,-32768,-32768, 1848,-32768,-32768,
1165 -32768,-32768, 4676,-32768, 35,-32768,-32768, 56,-32768,-32768,
1166 70,-32768, 4741,-32768, 4792,-32768, 718,-32768, 5206,-32768,
1167 -32768, 144, 259, 762, 235, 2421, 652,-32768,-32768, -35,
1168 2472,-32768,-32768,-32768,-32768, 1096, 569,-32768,-32768, 779,
1169 -32768, 810, 1032,-32768,-32768,-32768, 76, 2537,-32768, 4857,
1170 -32768,-32768,-32768, 869,-32768,-32768,-32768,-32768, -49, 789,
1171 -32768,-32768,-32768, 2588, 724,-32768, 479, 724, 479,-32768,
1172 2653, 4908, 240, 135, 2704, 657,-32768, 1671,-32768, 2124,
1173 -32768,-32768,-32768,-32768, 547,-32768,-32768,-32768, 244,-32768,
1174 -32768,-32768,-32768,-32768, 801,-32768, 251,-32768,-32768, 5416,
1175 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 879,-32768, 879,
1176 -32768, 896,-32768, 896,-32768, 896,-32768, 937,-32768, 937,
1177 -32768, 937,-32768, 937,-32768, 165,-32768,-32768, 893,-32768,
1178 893,-32768, 880,-32768, 697,-32768, 701,-32768, 717,-32768,
1179 741,-32768, 901, 818,-32768,-32768,-32768,-32768, 1076,-32768,
1180 1848, 815, 811, 1848,-32768, 335,-32768,-32768,-32768,-32768,
1181 -32768,-32768,-32768, 351,-32768, 823, 463, 132, 718,-32768,
1182 455,-32768,-32768,-32768,-32768,-32768, 819, 824, 464, 762,
1183 -32768, 941, 66, -9,-32768, 851,-32768, 5340,-32768, 5231,
1184 840, 854, 857,-32768,-32768, 5481,-32768,-32768, 272,-32768,
1185 864, 294,-32768, 864,-32768,-32768, 878, 94,-32768,-32768,
1186 -32768, 819, 4973, 824, 1120,-32768,-32768,-32768,-32768,-32768,
1187 5024,-32768,-32768, 5532,-32768,-32768, 354, 548,-32768, 5089,
1188 744,-32768, 1848, 2769,-32768,-32768,-32768, 2050,-32768,-32768,
1189 263,-32768, 681,-32768,-32768,-32768,-32768,-32768,-32768, 2820,
1190 -32768,-32768, 963, 212, 5140,-32768, 419,-32768, 1564,-32768,
1191 5597,-32768,-32768,-32768, 881, 886, 5273,-32768, 268,-32768,
1192 728,-32768,-32768,-32768,-32768, 354,-32768, 903,-32768,-32768,
1193 -32768,-32768,-32768,-32768,-32768, 731,-32768, 354,-32768,-32768,
1194 504,-32768, 173, 121, 509,-32768, 940, 944, 2050,-32768,
1195 -32768, 2050,-32768,-32768, 904,-32768, 923, 925,-32768, 1020,
1196 137,-32768,-32768,-32768,-32768,-32768, 262,-32768,-32768, 1646,
1197 -32768, 1780,-32768, 932, 1984,-32768, 942,-32768,-32768,-32768,
1198 -32768, 354,-32768,-32768, 2885,-32768, 182, 4676, 1984,-32768,
1199 -32768, 2936,-32768,-32768,-32768,-32768, 1029,-32768,-32768,-32768,
1200 945,-32768, 1984,-32768, 210, 177,-32768, 401,-32768, 5231,
1201 946,-32768,-32768,-32768,-32768, 224, 2050, 947, 5273,-32768,
1202 975, 2050, 949, 2050,-32768, 2050,-32768,-32768, 1037, 1040,
1206 static const short yypgoto[] = {-32768,
1207 -32768, -54, 157, 660, 16, -122, 582,-32768, -3, 319,
1208 -32768, 64,-32768, 1038, 413,-32768, 69,-32768,-32768, 734,
1209 106, 409,-32768,-32768, 997, 979,-32768, -131,-32768, 898,
1210 -32768, -79, -116, 918, -167, -194,-32768,-32768, -64, 285,
1211 805, -325, -129, -90,-32768,-32768,-32768,-32768,-32768,-32768,
1212 -32768, 907,-32768, -544,-32768, 662, -20,-32768,-32768,-32768,
1213 -32768, 1011, 561,-32768, 978,-32768,-32768, -176,-32768, -127,
1214 813, 784, -168, -276,-32768, 769, -251, 93, -560,-32768,
1215 -528,-32768,-32768,-32768, -263,-32768,-32768,-32768,-32768,-32768,
1216 -32768,-32768,-32768, 415, 416, -632, -527,-32768,-32768,-32768,
1217 -32768,-32768,-32768,-32768, -516,-32768, -667, 770,-32768,-32768,
1218 -32768,-32768,-32768,-32768,-32768,-32768, 511,-32768, 513,-32768,
1219 -32768,-32768,-32768, 186,-32768,-32768,-32768,-32768, -426,-32768,
1220 736, 126, -324, 1163, 192, 1197, 283, 379, 507, -171,
1221 583, 704, -472,-32768, 602, 603, 481, 601, 696, 698,
1222 695, 710, 703,-32768, 454, 706, 745,-32768,-32768, 936,
1230 static const short yytable[] = { 21,
1231 175, 173, 29, 182, 462, 290, 152, 83, 360, 737,
1232 328, 184, 38, 444, 593, 626, 642, 345, 345, 646,
1233 337, 339, 341, 343, 479, 76, 143, 467, 352, 354,
1234 124, 484, 486, 173, 123, 567, 733, 664, 61, 83,
1235 263, 93, 61, 487, 604, 448, 455, 261, 134, 164,
1236 20, 605, 665, 451, 618, 452, 569, 59, 88, 252,
1237 61, 67, 254, 367, 166, 61, 662, 25, 27, 62,
1238 571, 48, 35, 93, 83, 350, 597, 31, 178, 59,
1239 265, 164, 426, 638, 59, 88, 666, 708, 394, 36,
1240 88, 64, 135, 468, 687, 37, 166, 733, 702, 52,
1241 54, 31, 778, 57, 123, 16, 83, 50, 172, -158,
1242 39, 783, 40, 57, 16, 16, 16, 346, 346, 709,
1243 712, 662, 144, 77, 61, 88, 182, 331, 125, 88,
1244 61, 715, 654, 568, 404, 16, 488, 756, 16, 16,
1245 172, -104, 110, 59, 584, -104, 113, 427, 708, 67,
1246 611, 708, 692, 614, 570, 88, 16, 88, 19, 663,
1247 395, -94, -94, 464, 434, 631, 401, 89, 572, 49,
1248 283, 50, 412, 661, -295, 598, 156, 756, 88, 681,
1249 709, 712, 722, 709, 712, 110, 113, 688, 334, 334,
1250 334, 334, 715, 631, 61, 715, 334, 334, 357, 89,
1251 182, 178, 189, 512, 514, 516, 416, 696, 146, 466,
1252 755, 430, 723, 349, 747, 186, 708, 704, 84, 145,
1253 631, 708, 492, 708, 772, 708, 156, 249, 623, 438,
1254 757, 612, 440, 721, 159, 144, 631, 284, 179, 564,
1255 621, 189, 585, 20, 632, 84, -31, 1, 709, 712,
1256 84, 635, 88, 709, 712, 709, 712, 709, 712, 487,
1257 715, 118, 758, 716, 413, 715, 159, 715, 738, 715,
1258 776, 746, 682, -25, -25, 178, 631, 120, 55, 285,
1259 767, 50, 56, 88, 372, 84, 283, 444, 493, 84,
1260 2, 20, 140, 446, 684, 629, 20, 141, 142, 724,
1261 613, 446, 615, 446, 417, 147, 453, 4, 775, 431,
1262 620, 422, 187, 5, -25, 84, 439, 84, 766, -25,
1263 -25, -25, 780, 590, 250, -25, 88, 718, 61, -25,
1264 282, 41, 587, 418, 673, 647, 455, 622, 84, 26,
1265 432, 633, 424, 71, 189, 7, 101, 67, 636, 759,
1266 504, 649, 586, 284, 348, -28, 1, -257, 356, 319,
1267 284, 179, 156, 20, 20, 320, 444, 117, 284, 683,
1268 284, 334, 334, 334, 334, 334, 334, 334, 334, 334,
1269 334, 334, 334, 88, 334, 334, 334, 334, 334, 334,
1270 334, 685, 643, 42, 189, 285, 706, -66, 362, 2,
1271 69, 647, 363, 423, 559, 42, 150, 153, 17, 470,
1272 3, 119, 84, 455, 329, 179, 4, 17, 17, 17,
1273 330, 30, 5, 34, 20, -159, 428, 128, 648, 57,
1274 6, 505, -30, 1, 425, 179, 459, -161, 17, 28,
1275 -66, 17, 17, 84, 650, 51, 282, 158, 129, 137,
1276 655, 690, 480, 658, 7, 444, 321, 448, 509, 17,
1277 451, 557, 133, 652, 659, 664, 282, 330, -34, 1,
1278 90, 284, -29, 1, 148, 319, 2, 158, 334, 158,
1279 665, 320, 319, 762, 334, 137, 84, 3, 320, 251,
1280 319, 45, 319, 4, 777, 319, 320, 769, 320, 5,
1281 57, 320, 90, 189, 659, 697, 455, 255, 74, 412,
1282 53, 774, 2, 285, 728, 455, 2, 256, 429, -32,
1283 1, 58, -323, 182, 20, 706, 66, 3, 460, 4,
1284 762, 7, 769, 4, 774, 5, 260, 160, 500, 5,
1285 -97, 133, -65, 536, 481, -97, -97, -97, -97, 156,
1286 510, 739, 322, 46, 741, 653, 660, 283, 134, -65,
1287 283, -33, 1, 2, 282, 35, 744, 7, 98, 160,
1288 46, 7, 321, 203, 3, 612, -97, 121, -97, 321,
1289 4, -97, -97, -97, -97, -65, 5, 321, 37, 321,
1290 -35, 1, 321, 319, 102, 20, 745, 109, 178, 320,
1291 610, 748, -65, 610, 501, 2, 20, 112, 149, 502,
1292 764, 20, 35, 503, -323, 347, 151, 154, 7, 334,
1293 35, 334, 4, 20, 284, 100, 78, 284, 5, 176,
1294 183, 332, 106, 344, 2, 122, 334, 36, 78, 283,
1295 630, 698, 368, 37, 446, 99, 631, 631, 188, 88,
1296 103, 4, 500, 20, 461, 327, 371, 5, 80, 156,
1297 7, 81, 20, 402, 78, 283, 285, 131, 322, 285,
1298 80, -140, 2, 81, 20, 322, 121, 369, 78, 20,
1299 323, 717, 20, 322, 463, 322, 465, 370, 322, 7,
1300 321, 469, 20, 20, 409, 410, 80, 2, 411, 81,
1301 20, 20, 20, 78, 57, 446, 284, 390, 446, 155,
1302 80, 284, 391, 81, 20, 20, 589, 282, 501, 35,
1303 282, 535, 177, 502, 2, 78, 283, 503, 283, 392,
1304 78, 446, 284, 20, 122, 80, 36, 20, 81, 20,
1305 20, 20, 37, 32, 500, 446, 319, 435, 285, 319,
1306 625, 363, 320, 612, 393, 320, 324, 80, 179, 446,
1307 81, 20, 80, 32, 489, 81, 20, 32, 490, 20,
1308 78, 20, 284, 446, 285, 284, 20, 577, 446, 406,
1309 446, 578, 446, 319, 32, 319, 322, 482, 405, 320,
1310 483, 320, -157, 284, 363, 284, 323, 441, 284, 282,
1311 445, 750, 80, 323, 751, 81, 20, 449, 701, 84,
1312 501, 323, 284, 323, 364, 502, 323, 2, 365, 503,
1313 474, 740, 366, 78, 743, 282, 284, 631, 319, 20,
1314 631, 138, 139, 319, 320, 285, 458, 285, 508, 320,
1315 284, 253, 139, 321, 491, 284, 321, 284, 558, 284,
1316 -342, -342, -344, -344, 319, 80, -505, -505, 81, 20,
1317 320, 139, 319, 528, 530, 532, 534, 399, 320, 781,
1318 -506, -506, 324, 594, 785, 596, 787, 325, 788, 324,
1319 321, 606, 321, 375, 376, 377, 282, 324, 282, 324,
1320 373, 374, 324, 634, 319, 388, 389, 319, 378, 379,
1321 320, 639, -342, 320, -344, 640, -342, 644, -344, 645,
1322 383, 384, 385, 386, 323, 319, 651, 319, 326, -352,
1323 319, 320, -15, 320, -353, 321, 320, -504, -504, 364,
1324 321, 396, 397, 436, 319, -415, -415, 437, 677, 322,
1325 320, 661, 322, 671, 380, 381, 382, 678, 319, 387,
1326 679, 321, -416, -416, 320, 319, 471, 472, 473, 321,
1327 612, 320, 319, 722, 319, 141, 142, 319, 320, 319,
1328 320, 319, -373, 320, 735, 320, 322, 320, 322, 518,
1329 520, 2, 522, 524, 526, 598, 2, 78, 539, 541,
1330 324, 321, 78, 325, 321, 749, 79, -371, 4, -208,
1331 325, 79, 752, 4, 5, -504, -504, 364, 325, 5,
1332 325, 365, 321, 325, 321, 366, 753, 321, 754, 80,
1333 755, 322, 81, 20, 80, 761, 322, 81, 20, 772,
1334 784, 321, 156, 157, 326, 763, 790, 156, 258, 791,
1335 782, 326, 786, 773, 779, 321, 537, 322, 33, 326,
1336 75, 326, 321, 108, 326, 322, 190, 2, 259, 321,
1337 400, 321, 73, 78, 321, 257, 321, 323, 321, 562,
1338 323, 127, 79, 443, 4, 248, 408, 2, 454, 457,
1339 5, 729, 730, 78, 478, 543, 547, 322, 545, 656,
1340 322, 657, 79, 700, 4, 80, 551, 0, 81, 20,
1341 5, 0, 549, 556, 323, 0, 323, 0, 322, 82,
1342 322, 325, 0, 322, 0, 80, 0, -15, 81, 20,
1343 691, 0, -504, -504, 364, 0, 0, 322, 436, 126,
1344 0, 0, 366, 0, -504, -504, 364, 358, 248, 0,
1345 485, 322, 0, 324, 366, 0, 324, 0, 322, 323,
1346 0, 0, 326, 0, 323, 322, 0, 322, 0, 0,
1347 322, -15, 322, 0, 322, 0, -504, -504, 364, 78,
1348 0, 0, 436, 0, 0, 323, 641, 0, 196, 0,
1349 324, 0, 324, 323, 197, 0, -504, -504, 364, 0,
1350 0, 198, 365, 0, 0, 199, 437, 0, 0, 0,
1351 0, 80, 0, 415, 81, 20, 421, 0, 200, 201,
1352 0, 0, 202, 0, 433, 323, 0, 0, 323, 0,
1353 0, 204, 205, 206, 207, 324, 0, 208, 209, 0,
1354 324, 0, 0, 0, 0, 0, 323, 0, 323, 0,
1355 0, 323, 0, 0, 0, 0, 0, 0, 0, 0,
1356 0, 324, 0, 0, 0, 323, 0, 0, 0, 324,
1357 0, 0, 0, 0, 325, 0, 0, 325, 0, 323,
1358 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
1359 0, 0, 0, 323, 0, 323, 0, 0, 323, 0,
1360 323, 324, 323, 0, 324, 0, 0, 0, 0, 0,
1361 499, 325, 0, 325, 507, 326, 0, 0, 326, 0,
1362 0, 0, 324, 0, 324, 0, 0, 324, 0, 0,
1363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1364 554, 324, 0, 0, 0, 0, 0, 0, 0, 0,
1365 0, 0, 326, 0, 326, 324, 325, 0, 566, 0,
1366 0, 325, 324, 0, 335, 335, 335, 335, 574, 324,
1367 576, 324, 335, 335, 324, 0, 324, 0, 324, 0,
1368 0, 499, 325, 0, 0, 0, 0, 0, 0, 0,
1369 325, 0, 0, 0, 0, 0, 0, 326, 336, 336,
1370 336, 336, 326, 601, 0, 603, 336, 336, 0, 0,
1371 0, 0, 0, 0, 0, 0, 0, 0, 0, 609,
1372 0, 0, 325, 326, 0, 325, 0, 0, 0, 0,
1373 499, 326, 0, 0, 0, 248, 0, 0, 0, 0,
1374 0, 0, 0, 325, 0, 325, 0, 0, 325, 0,
1375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1376 0, 0, 325, 326, 0, 0, 326, 0, 0, 0,
1377 0, 0, 0, 0, 0, 0, 325, 0, 0, 0,
1378 0, 0, 0, 325, 326, 0, 326, 0, 0, 326,
1379 325, 0, 325, 0, 0, 325, 0, 325, 0, 325,
1380 0, 0, 0, 326, 0, 0, 0, 0, 0, 0,
1381 0, 0, 0, 0, 0, 0, 0, 326, 0, 0,
1382 0, 0, 0, 0, 326, 0, 0, 0, 0, 0,
1383 0, 326, 0, 326, 0, 0, 326, 0, 326, 0,
1384 326, 0, 0, 0, 0, 0, 0, 335, 335, 335,
1385 335, 335, 335, 335, 335, 335, 335, 335, 335, 0,
1386 335, 335, 335, 335, 335, 335, 335, 0, 0, 0,
1387 0, 0, 0, 0, 266, 0, 694, 0, 0, 0,
1388 0, 336, 336, 336, 336, 336, 336, 336, 336, 336,
1389 336, 336, 336, 0, 336, 336, 336, 336, 336, 336,
1390 336, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1391 726, 0, 0, 0, 0, 0, 734, 2, 194, 195,
1392 664, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1393 0, 271, 196, 0, 0, 665, 0, 0, 272, 273,
1394 5, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1395 0, 0, 0, 0, 335, 80, 266, 0, 81, 20,
1396 335, 0, 0, 0, 0, 0, 279, 0, 156, 731,
1397 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1398 0, 208, 209, 0, 0, 0, 0, 0, 336, 0,
1399 0, 0, 0, 768, 336, 0, 0, 771, 0, 2,
1400 194, 195, 664, 267, 268, 78, 269, 0, 0, 270,
1401 0, 0, 0, 271, 196, 0, 0, 665, 0, 0,
1402 272, 273, 5, 274, 0, 275, 276, 198, 277, 0,
1403 78, 278, 0, 0, 0, 0, 0, 80, 0, 196,
1404 81, 20, 0, 0, 0, 197, 0, 0, 279, 0,
1405 156, 760, 198, 0, 280, 0, 199, 204, 205, 206,
1406 207, 0, 80, 208, 209, 81, 20, 0, 0, 200,
1407 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1408 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1409 266, 0, 0, 0, 0, 335, 0, 335, 0, 0,
1410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1411 0, 0, 335, 0, 0, 0, 0, 0, 0, 0,
1412 0, 0, 0, 0, 0, 0, 0, 0, 0, 336,
1413 0, 336, 0, 2, 194, 195, -267, 267, 268, 78,
1414 269, 0, 0, 270, 0, 0, 336, 271, 196, 0,
1415 0, -267, 0, 0, 272, 273, 5, 274, 266, 275,
1416 276, 198, 277, 0, 0, 278, 0, 0, 0, 0,
1417 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1418 0, 0, 279, 0, 156, -267, 0, 0, 280, 0,
1419 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1420 0, 2, 194, 195, 0, 267, 268, 78, 269, 0,
1421 0, 270, 0, 0, 0, 271, 196, 0, 0, 0,
1422 0, 0, 272, 273, 5, 274, 266, 275, 276, 198,
1423 277, 0, 0, 278, 0, 0, 0, 0, 0, 80,
1424 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1425 279, 0, 156, 442, 0, 0, 280, 0, 0, 204,
1426 205, 206, 207, 0, 0, 208, 209, 0, 0, 2,
1427 194, 195, 0, 267, 268, 78, 269, 0, 0, 270,
1428 0, 0, 0, 271, 196, 0, 0, 0, 0, 0,
1429 272, 273, 5, 274, 266, 275, 276, 198, 277, 0,
1430 0, 278, 0, 0, 0, 0, 0, 80, 0, 0,
1431 81, 20, 0, 0, 0, 0, 0, 0, 279, 0,
1432 156, 0, 0, 0, 280, 0, 0, 204, 205, 206,
1433 207, 0, 0, 208, 209, 0, 0, 2, 194, 195,
1434 0, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1435 0, 271, 196, 0, 0, 0, 0, 0, 272, 273,
1436 266, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1437 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1438 0, 0, 0, 0, 0, 0, 279, 0, 156, 0,
1439 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1440 0, 208, 209, 2, 194, 195, 0, 705, 268, 78,
1441 269, 0, 0, 270, 0, 0, 0, 271, 196, 0,
1442 0, 0, 0, 0, 272, 273, 0, 274, 0, 275,
1443 276, 198, 277, 0, 627, 278, 192, 193, 0, 0,
1444 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1445 0, 0, 279, 0, 156, 0, 0, 0, 280, 0,
1446 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1447 0, 0, 0, 0, 0, 0, 0, 0, 194, 195,
1448 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1449 0, 0, 196, 0, 0, 0, 0, 0, 197, 191,
1450 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1451 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1452 0, 0, 200, 201, 0, 0, 202, 0, 203, 628,
1453 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1454 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1455 419, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1456 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1457 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1458 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1459 0, 202, 0, 203, 194, 195, 0, 0, 0, 78,
1460 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1461 0, 0, 0, 0, 197, 497, 0, 192, 193, 0,
1462 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1463 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1464 0, 0, 202, 0, 0, 0, 0, 0, 420, 0,
1465 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1466 195, 0, 0, 0, 78, 0, 552, 0, 192, 193,
1467 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1468 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1469 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1470 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1471 194, 195, 498, 0, 0, 78, 204, 205, 206, 207,
1472 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1473 197, 497, 0, 192, 193, 0, 0, 198, 0, 0,
1474 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1475 81, 20, 0, 553, 200, 201, 0, 0, 202, 0,
1476 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1477 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1478 78, 0, 591, 0, 192, 193, 0, 0, 0, 196,
1479 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1480 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1481 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1482 201, 0, 0, 202, 0, 0, 194, 195, 588, 0,
1483 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1484 196, 0, 0, 0, 0, 0, 197, 599, 0, 192,
1485 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1486 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1487 200, 201, 0, 0, 202, 592, 0, 0, 0, 0,
1488 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1489 209, 194, 195, 0, 0, 0, 78, 0, 607, 0,
1490 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1491 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1492 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1493 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1494 0, 0, 194, 195, 0, 600, 0, 78, 204, 205,
1495 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1496 0, 0, 197, 616, 0, 192, 193, 0, 0, 198,
1497 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1498 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1499 202, 0, 0, 0, 0, 608, 0, 0, 0, 204,
1500 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1501 0, 0, 78, 0, 497, 0, 192, 193, 0, 0,
1502 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1503 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1504 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1505 0, 200, 201, 0, 0, 202, 617, 0, 194, 195,
1506 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1507 208, 209, 196, 0, 0, 0, 0, 0, 197, 591,
1508 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1509 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1510 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1511 0, 624, 0, 0, 0, 204, 205, 206, 207, 0,
1512 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1513 719, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1514 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1515 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1516 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1517 0, 202, 703, 0, 194, 195, 0, 0, 0, 78,
1518 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1519 0, 0, 0, 0, 197, 719, 0, 192, 193, 0,
1520 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1521 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1522 0, 0, 202, 720, 0, 0, 0, 0, 0, 0,
1523 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1524 195, 0, 0, 0, 78, 0, 599, 0, 192, 193,
1525 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1526 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1527 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1528 20, 0, 0, 200, 201, 0, 0, 202, 765, 0,
1529 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1530 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1531 197, 333, 0, 192, 193, 0, 0, 198, 0, 0,
1532 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1533 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1534 0, 0, 0, 0, 770, 0, 0, 204, 205, 206,
1535 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1536 78, 0, 338, 0, 192, 193, 0, 0, 0, 196,
1537 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1538 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1539 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1540 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1541 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1542 196, 0, 0, 0, 0, 0, 197, 340, 0, 192,
1543 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1544 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1545 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1546 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1547 209, 194, 195, 0, 0, 0, 78, 0, 342, 0,
1548 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1549 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1550 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1551 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1552 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1553 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1554 0, 0, 197, 351, 0, 192, 193, 0, 0, 198,
1555 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1556 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1557 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1558 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1559 0, 0, 78, 0, 353, 0, 192, 193, 0, 0,
1560 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1561 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1562 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1563 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1564 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1565 208, 209, 196, 0, 0, 0, 0, 0, 197, 355,
1566 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1567 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1568 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1569 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1570 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1571 414, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1572 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1573 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1574 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1575 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1576 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1577 0, 0, 0, 0, 197, 506, 0, 192, 193, 0,
1578 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1579 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1580 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1581 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1582 195, 0, 0, 0, 78, 0, 511, 0, 192, 193,
1583 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1584 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1585 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1586 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1587 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1588 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1589 197, 513, 0, 192, 193, 0, 0, 198, 0, 0,
1590 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1591 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1592 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1593 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1594 78, 0, 515, 0, 192, 193, 0, 0, 0, 196,
1595 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1596 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1597 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1598 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1599 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1600 196, 0, 0, 0, 0, 0, 197, 517, 0, 192,
1601 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1602 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1603 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1604 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1605 209, 194, 195, 0, 0, 0, 78, 0, 519, 0,
1606 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1607 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1608 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1609 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1610 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1611 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1612 0, 0, 197, 521, 0, 192, 193, 0, 0, 198,
1613 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1614 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1615 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1616 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1617 0, 0, 78, 0, 523, 0, 192, 193, 0, 0,
1618 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1619 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1620 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1621 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1622 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1623 208, 209, 196, 0, 0, 0, 0, 0, 197, 525,
1624 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1625 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1626 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1627 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1628 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1629 527, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1630 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1631 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1632 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1633 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1634 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1635 0, 0, 0, 0, 197, 529, 0, 192, 193, 0,
1636 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1637 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1638 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1639 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1640 195, 0, 0, 0, 78, 0, 531, 0, 192, 193,
1641 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1642 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1643 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1644 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1645 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1646 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1647 197, 533, 0, 192, 193, 0, 0, 198, 0, 0,
1648 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1649 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1650 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1651 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1652 78, 0, 538, 0, 192, 193, 0, 0, 0, 196,
1653 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1654 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1655 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1656 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1657 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1658 196, 0, 0, 0, 0, 0, 197, 540, 0, 192,
1659 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1660 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1661 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1662 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1663 209, 194, 195, 0, 0, 0, 78, 0, 542, 0,
1664 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1665 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1666 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1667 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1668 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1669 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1670 0, 0, 197, 544, 0, 192, 193, 0, 0, 198,
1671 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1672 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1673 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1674 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1675 0, 0, 78, 0, 546, 0, 192, 193, 0, 0,
1676 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1677 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1678 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1679 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1680 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1681 208, 209, 196, 0, 0, 0, 0, 0, 197, 548,
1682 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1683 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1684 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1685 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1686 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1687 550, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1688 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1689 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1690 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1691 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1692 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1693 0, 0, 0, 0, 197, 555, 0, 192, 193, 0,
1694 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1695 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1696 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1697 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1698 195, 0, 0, 0, 78, 0, 565, 0, 192, 193,
1699 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1700 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1701 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1702 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1703 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1704 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1705 197, 573, 0, 192, 193, 0, 0, 198, 0, 0,
1706 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1707 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1708 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1709 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1710 78, 0, 575, 0, 192, 193, 0, 0, 0, 196,
1711 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1712 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1713 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1714 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1715 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1716 196, 0, 0, 0, 0, 0, 197, 602, 0, 192,
1717 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1718 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1719 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1720 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1721 209, 194, 195, 0, 0, 0, 78, 0, 619, 0,
1722 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1723 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1724 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1725 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1726 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1727 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1728 0, 0, 197, 689, 0, 192, 193, 0, 0, 198,
1729 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1730 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1731 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1732 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1733 0, 0, 78, 0, 693, 0, 192, 193, 0, 0,
1734 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1735 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1736 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1737 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1738 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1739 208, 209, 196, 0, 0, 0, 0, 0, 197, 699,
1740 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1741 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1742 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1743 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1744 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1745 725, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1746 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1747 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1748 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1749 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1750 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1751 0, 0, 0, 0, 197, 0, 583, 0, 0, 0,
1752 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1753 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1754 0, 674, 202, 0, 0, 0, 0, 0, 0, 0,
1755 0, 204, 205, 206, 207, 0, 0, 208, 209, -290,
1756 -290, -290, 0, 0, 0, -290, 0, 0, 0, 0,
1757 0, 0, 0, 0, -290, 0, 0, 0, 0, 0,
1758 -290, 0, 0, 736, 0, 194, 195, -290, 0, 0,
1759 78, -290, 0, 0, 0, 0, 0, -290, 0, 196,
1760 -290, -290, 0, 0, 0, 197, 0, 0, -290, 0,
1761 192, 193, 198, 0, -290, 0, 199, -290, -290, -290,
1762 -290, 0, 80, -290, -290, 81, 20, 194, 195, 0,
1763 0, 0, 78, 279, -298, 0, 0, 0, 0, 0,
1764 0, 196, 204, 205, 206, 207, 0, 197, 208, 209,
1765 672, 0, 194, 195, 198, 0, 0, 78, 199, 0,
1766 0, 0, 0, 0, 80, 0, 196, 81, 20, 0,
1767 0, 0, 197, 0, 0, 279, -298, 192, 193, 198,
1768 0, 0, 0, 199, 204, 205, 206, 207, 0, 80,
1769 208, 209, 81, 20, 194, 195, 200, 201, 0, 78,
1770 202, 0, 203, 359, 0, 0, 0, 0, 196, 204,
1771 205, 206, 207, 0, 197, 208, 209, 0, 0, 194,
1772 195, 198, 0, 0, 78, 199, 0, 0, 192, 193,
1773 0, 80, 0, 196, 81, 20, 0, 0, 0, 197,
1774 0, 0, 279, 0, 0, 0, 198, 0, 0, 0,
1775 199, 204, 205, 206, 207, 0, 80, 208, 209, 81,
1776 20, 0, 0, 200, 201, 0, 0, 202, 494, 0,
1777 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1778 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1779 197, 0, 0, 192, 193, 0, 0, 198, 0, 0,
1780 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1781 81, 20, 0, 0, 200, 201, 0, 0, 202, 637,
1782 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1783 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1784 78, 0, 0, 0, 192, 193, 0, 0, 0, 196,
1785 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1786 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1787 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1788 201, 0, 0, 202, 680, 0, 194, 195, 0, 0,
1789 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1790 196, 0, 0, 0, 0, 0, 197, 0, 0, 192,
1791 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1792 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1793 200, 201, 0, 0, 202, 695, 0, 0, 0, 0,
1794 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1795 209, 194, 195, 0, 0, 0, 78, 0, 0, 0,
1796 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1797 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1798 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1799 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1800 0, 2, 194, 195, 0, 0, 0, 78, 204, 205,
1801 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1802 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1803 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1804 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1805 279, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1806 205, 206, 207, 0, 0, 208, 209
1809 static const short yycheck[] = { 3,
1810 132, 129, 6, 133, 330, 174, 123, 62, 203, 677,
1811 178, 134, 1, 290, 441, 488, 561, 1, 1, 564,
1812 192, 193, 194, 195, 349, 1, 117, 1, 200, 201,
1813 1, 356, 357, 161, 89, 1, 669, 47, 42, 94,
1814 168, 62, 46, 1, 94, 297, 310, 1, 53, 129,
1815 86, 101, 62, 305, 481, 307, 1, 42, 62, 150,
1816 64, 46, 153, 1, 129, 69, 1, 4, 5, 95,
1817 1, 1, 44, 94, 129, 198, 1, 9, 133, 64,
1818 171, 161, 1, 510, 69, 89, 96, 648, 15, 61,
1819 94, 100, 97, 67, 1, 67, 161, 730, 643, 36,
1820 37, 33, 770, 40, 159, 0, 161, 101, 129, 93,
1821 99, 779, 101, 50, 9, 10, 11, 101, 101, 648,
1822 648, 1, 1, 99, 128, 129, 256, 182, 99, 133,
1823 134, 648, 1, 99, 262, 30, 94, 1, 33, 34,
1824 161, 95, 79, 128, 1, 99, 83, 275, 709, 134,
1825 475, 712, 625, 478, 99, 159, 51, 161, 1, 94,
1826 87, 99, 100, 331, 281, 100, 257, 62, 99, 99,
1827 174, 101, 1, 1, 99, 100, 95, 1, 182, 606,
1828 709, 709, 1, 712, 712, 122, 123, 94, 192, 193,
1829 194, 195, 709, 100, 198, 712, 200, 201, 202, 94,
1830 330, 256, 139, 375, 376, 377, 1, 634, 1, 332,
1831 1, 1, 1, 198, 94, 1, 777, 644, 62, 98,
1832 100, 782, 1, 784, 1, 786, 95, 1, 94, 1,
1833 94, 97, 287, 660, 129, 1, 100, 174, 133, 408,
1834 1, 178, 99, 86, 1, 89, 0, 1, 777, 777,
1835 94, 1, 256, 782, 782, 784, 784, 786, 786, 1,
1836 777, 97, 1, 1, 93, 782, 161, 784, 1, 786,
1837 94, 99, 1, 45, 46, 330, 100, 97, 1, 174,
1838 99, 101, 5, 287, 221, 129, 290, 564, 67, 133,
1839 44, 86, 92, 297, 1, 490, 86, 97, 98, 88,
1840 477, 305, 479, 307, 99, 98, 310, 61, 99, 99,
1841 482, 1, 98, 67, 86, 159, 88, 161, 745, 91,
1842 92, 93, 99, 440, 98, 97, 330, 653, 332, 101,
1843 174, 1, 98, 270, 598, 1, 600, 98, 182, 1,
1844 277, 98, 1, 1, 281, 99, 1, 332, 98, 88,
1845 72, 1, 94, 290, 198, 0, 1, 95, 202, 174,
1846 297, 256, 95, 86, 86, 174, 643, 83, 305, 98,
1847 307, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1848 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
1849 394, 98, 561, 63, 331, 290, 648, 52, 97, 44,
1850 52, 1, 101, 93, 408, 63, 122, 123, 0, 346,
1851 55, 97, 256, 677, 94, 310, 61, 9, 10, 11,
1852 100, 9, 67, 11, 86, 95, 1, 100, 94, 366,
1853 75, 368, 0, 1, 93, 330, 1, 95, 30, 1,
1854 95, 33, 34, 287, 94, 33, 290, 129, 95, 1,
1855 578, 623, 1, 581, 99, 732, 174, 709, 1, 51,
1856 712, 94, 93, 1, 1, 47, 310, 100, 0, 1,
1857 62, 408, 0, 1, 98, 290, 44, 159, 482, 161,
1858 62, 290, 297, 735, 488, 1, 330, 55, 297, 1,
1859 305, 1, 307, 61, 94, 310, 305, 749, 307, 67,
1860 437, 310, 94, 440, 1, 637, 770, 96, 1, 1,
1861 1, 763, 44, 408, 96, 779, 44, 93, 93, 0,
1862 1, 1, 1, 653, 86, 777, 1, 55, 93, 61,
1863 782, 99, 784, 61, 786, 67, 99, 129, 1, 67,
1864 92, 93, 52, 387, 93, 97, 98, 99, 100, 95,
1865 93, 679, 174, 63, 686, 93, 93, 561, 53, 52,
1866 564, 0, 1, 44, 408, 44, 698, 99, 1, 161,
1867 63, 99, 290, 95, 55, 97, 92, 1, 94, 297,
1868 61, 97, 98, 99, 100, 95, 67, 305, 67, 307,
1869 0, 1, 310, 408, 1, 86, 93, 1, 653, 408,
1870 475, 93, 95, 478, 67, 44, 86, 1, 1, 72,
1871 742, 86, 44, 76, 93, 1, 1, 1, 99, 623,
1872 44, 625, 61, 86, 561, 65, 50, 564, 67, 1,
1873 1, 100, 72, 101, 44, 59, 640, 61, 50, 643,
1874 94, 94, 101, 67, 648, 64, 100, 100, 1, 653,
1875 69, 61, 1, 86, 1, 1, 1, 67, 82, 95,
1876 99, 85, 86, 99, 50, 669, 561, 107, 290, 564,
1877 82, 95, 44, 85, 86, 297, 1, 97, 50, 86,
1878 174, 1, 86, 305, 1, 307, 1, 101, 310, 99,
1879 408, 1, 86, 86, 95, 96, 82, 44, 99, 85,
1880 86, 86, 86, 50, 641, 709, 643, 11, 712, 128,
1881 82, 648, 12, 85, 86, 86, 65, 561, 67, 44,
1882 564, 1, 94, 72, 44, 50, 730, 76, 732, 13,
1883 50, 735, 669, 86, 59, 82, 61, 86, 85, 86,
1884 86, 86, 67, 10, 1, 749, 561, 97, 643, 564,
1885 94, 101, 561, 97, 14, 564, 174, 82, 653, 763,
1886 85, 86, 82, 30, 96, 85, 86, 34, 100, 86,
1887 50, 86, 709, 777, 669, 712, 86, 60, 782, 95,
1888 784, 64, 786, 598, 51, 600, 408, 94, 99, 598,
1889 97, 600, 93, 730, 101, 732, 290, 93, 735, 643,
1890 99, 709, 82, 297, 712, 85, 86, 99, 65, 653,
1891 67, 305, 749, 307, 93, 72, 310, 44, 97, 76,
1892 97, 94, 101, 50, 94, 669, 763, 100, 643, 86,
1893 100, 99, 100, 648, 643, 730, 99, 732, 67, 648,
1894 777, 99, 100, 561, 98, 782, 564, 784, 99, 786,
1895 45, 46, 45, 46, 669, 82, 91, 92, 85, 86,
1896 669, 100, 677, 383, 384, 385, 386, 94, 677, 777,
1897 91, 92, 290, 95, 782, 66, 784, 174, 786, 297,
1898 598, 93, 600, 5, 6, 7, 730, 305, 732, 307,
1899 45, 46, 310, 93, 709, 16, 17, 712, 3, 4,
1900 709, 1, 97, 712, 97, 88, 101, 93, 101, 99,
1901 18, 19, 20, 21, 408, 730, 94, 732, 174, 101,
1902 735, 730, 86, 732, 101, 643, 735, 91, 92, 93,
1903 648, 91, 92, 97, 749, 45, 46, 101, 99, 561,
1904 749, 1, 564, 93, 8, 9, 10, 94, 763, 57,
1905 94, 669, 45, 46, 763, 770, 97, 98, 99, 677,
1906 97, 770, 777, 1, 779, 97, 98, 782, 777, 784,
1907 779, 786, 95, 782, 94, 784, 598, 786, 600, 378,
1908 379, 44, 380, 381, 382, 100, 44, 50, 388, 389,
1909 408, 709, 50, 290, 712, 56, 59, 95, 61, 56,
1910 297, 59, 99, 61, 67, 91, 92, 93, 305, 67,
1911 307, 97, 730, 310, 732, 101, 94, 735, 94, 82,
1912 1, 643, 85, 86, 82, 94, 648, 85, 86, 1,
1913 56, 749, 95, 96, 290, 94, 0, 95, 96, 0,
1914 94, 297, 94, 99, 99, 763, 387, 669, 11, 305,
1915 54, 307, 770, 75, 310, 677, 139, 44, 161, 777,
1916 256, 779, 52, 50, 782, 159, 784, 561, 786, 408,
1917 564, 94, 59, 290, 61, 140, 264, 44, 310, 310,
1918 67, 667, 667, 50, 349, 390, 392, 709, 391, 579,
1919 712, 579, 59, 640, 61, 82, 394, -1, 85, 86,
1920 67, -1, 393, 398, 598, -1, 600, -1, 730, 96,
1921 732, 408, -1, 735, -1, 82, -1, 86, 85, 86,
1922 1, -1, 91, 92, 93, -1, -1, 749, 97, 96,
1923 -1, -1, 101, -1, 91, 92, 93, 202, 203, -1,
1924 97, 763, -1, 561, 101, -1, 564, -1, 770, 643,
1925 -1, -1, 408, -1, 648, 777, -1, 779, -1, -1,
1926 782, 86, 784, -1, 786, -1, 91, 92, 93, 50,
1927 -1, -1, 97, -1, -1, 669, 101, -1, 59, -1,
1928 598, -1, 600, 677, 65, -1, 91, 92, 93, -1,
1929 -1, 72, 97, -1, -1, 76, 101, -1, -1, -1,
1930 -1, 82, -1, 268, 85, 86, 271, -1, 89, 90,
1931 -1, -1, 93, -1, 279, 709, -1, -1, 712, -1,
1932 -1, 102, 103, 104, 105, 643, -1, 108, 109, -1,
1933 648, -1, -1, -1, -1, -1, 730, -1, 732, -1,
1934 -1, 735, -1, -1, -1, -1, -1, -1, -1, -1,
1935 -1, 669, -1, -1, -1, 749, -1, -1, -1, 677,
1936 -1, -1, -1, -1, 561, -1, -1, 564, -1, 763,
1937 -1, -1, -1, -1, -1, -1, 770, -1, -1, -1,
1938 -1, -1, -1, 777, -1, 779, -1, -1, 782, -1,
1939 784, 709, 786, -1, 712, -1, -1, -1, -1, -1,
1940 365, 598, -1, 600, 369, 561, -1, -1, 564, -1,
1941 -1, -1, 730, -1, 732, -1, -1, 735, -1, -1,
1942 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1943 395, 749, -1, -1, -1, -1, -1, -1, -1, -1,
1944 -1, -1, 598, -1, 600, 763, 643, -1, 413, -1,
1945 -1, 648, 770, -1, 192, 193, 194, 195, 423, 777,
1946 425, 779, 200, 201, 782, -1, 784, -1, 786, -1,
1947 -1, 436, 669, -1, -1, -1, -1, -1, -1, -1,
1948 677, -1, -1, -1, -1, -1, -1, 643, 192, 193,
1949 194, 195, 648, 458, -1, 460, 200, 201, -1, -1,
1950 -1, -1, -1, -1, -1, -1, -1, -1, -1, 474,
1951 -1, -1, 709, 669, -1, 712, -1, -1, -1, -1,
1952 485, 677, -1, -1, -1, 490, -1, -1, -1, -1,
1953 -1, -1, -1, 730, -1, 732, -1, -1, 735, -1,
1954 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1955 -1, -1, 749, 709, -1, -1, 712, -1, -1, -1,
1956 -1, -1, -1, -1, -1, -1, 763, -1, -1, -1,
1957 -1, -1, -1, 770, 730, -1, 732, -1, -1, 735,
1958 777, -1, 779, -1, -1, 782, -1, 784, -1, 786,
1959 -1, -1, -1, 749, -1, -1, -1, -1, -1, -1,
1960 -1, -1, -1, -1, -1, -1, -1, 763, -1, -1,
1961 -1, -1, -1, -1, 770, -1, -1, -1, -1, -1,
1962 -1, 777, -1, 779, -1, -1, 782, -1, 784, -1,
1963 786, -1, -1, -1, -1, -1, -1, 375, 376, 377,
1964 378, 379, 380, 381, 382, 383, 384, 385, 386, -1,
1965 388, 389, 390, 391, 392, 393, 394, -1, -1, -1,
1966 -1, -1, -1, -1, 1, -1, 631, -1, -1, -1,
1967 -1, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1968 384, 385, 386, -1, 388, 389, 390, 391, 392, 393,
1969 394, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1970 665, -1, -1, -1, -1, -1, 671, 44, 45, 46,
1971 47, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1972 -1, 58, 59, -1, -1, 62, -1, -1, 65, 66,
1973 67, 68, -1, 70, 71, 72, 73, -1, -1, 76,
1974 -1, -1, -1, -1, 482, 82, 1, -1, 85, 86,
1975 488, -1, -1, -1, -1, -1, 93, -1, 95, 96,
1976 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1977 -1, 108, 109, -1, -1, -1, -1, -1, 482, -1,
1978 -1, -1, -1, 748, 488, -1, -1, 752, -1, 44,
1979 45, 46, 47, 48, 49, 50, 51, -1, -1, 54,
1980 -1, -1, -1, 58, 59, -1, -1, 62, -1, -1,
1981 65, 66, 67, 68, -1, 70, 71, 72, 73, -1,
1982 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
1983 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
1984 95, 96, 72, -1, 99, -1, 76, 102, 103, 104,
1985 105, -1, 82, 108, 109, 85, 86, -1, -1, 89,
1986 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
1987 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1988 1, -1, -1, -1, -1, 623, -1, 625, -1, -1,
1989 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, 640, -1, -1, -1, -1, -1, -1, -1,
1991 -1, -1, -1, -1, -1, -1, -1, -1, -1, 623,
1992 -1, 625, -1, 44, 45, 46, 47, 48, 49, 50,
1993 51, -1, -1, 54, -1, -1, 640, 58, 59, -1,
1994 -1, 62, -1, -1, 65, 66, 67, 68, 1, 70,
1995 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1996 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1997 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
1998 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1999 -1, 44, 45, 46, -1, 48, 49, 50, 51, -1,
2000 -1, 54, -1, -1, -1, 58, 59, -1, -1, -1,
2001 -1, -1, 65, 66, 67, 68, 1, 70, 71, 72,
2002 73, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2003 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2004 93, -1, 95, 96, -1, -1, 99, -1, -1, 102,
2005 103, 104, 105, -1, -1, 108, 109, -1, -1, 44,
2006 45, 46, -1, 48, 49, 50, 51, -1, -1, 54,
2007 -1, -1, -1, 58, 59, -1, -1, -1, -1, -1,
2008 65, 66, 67, 68, 1, 70, 71, 72, 73, -1,
2009 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2010 85, 86, -1, -1, -1, -1, -1, -1, 93, -1,
2011 95, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2012 105, -1, -1, 108, 109, -1, -1, 44, 45, 46,
2013 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
2014 -1, 58, 59, -1, -1, -1, -1, -1, 65, 66,
2015 1, 68, -1, 70, 71, 72, 73, -1, -1, 76,
2016 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2017 -1, -1, -1, -1, -1, -1, 93, -1, 95, -1,
2018 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
2019 -1, 108, 109, 44, 45, 46, -1, 48, 49, 50,
2020 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
2021 -1, -1, -1, -1, 65, 66, -1, 68, -1, 70,
2022 71, 72, 73, -1, 1, 76, 3, 4, -1, -1,
2023 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
2024 -1, -1, 93, -1, 95, -1, -1, -1, 99, -1,
2025 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
2026 -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,
2027 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2028 -1, -1, 59, -1, -1, -1, -1, -1, 65, 1,
2029 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2030 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2031 -1, -1, 89, 90, -1, -1, 93, -1, 95, 96,
2032 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2033 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2034 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2035 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2036 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2037 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2038 -1, 93, -1, 95, 45, 46, -1, -1, -1, 50,
2039 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2040 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2041 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2042 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2043 -1, -1, 93, -1, -1, -1, -1, -1, 99, -1,
2044 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2045 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2046 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2047 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2048 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2049 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2050 45, 46, 98, -1, -1, 50, 102, 103, 104, 105,
2051 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2052 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2053 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2054 85, 86, -1, 88, 89, 90, -1, -1, 93, -1,
2055 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2056 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2057 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2058 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2059 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2060 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2061 90, -1, -1, 93, -1, -1, 45, 46, 98, -1,
2062 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2063 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2064 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2065 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2066 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2067 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2068 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2069 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2070 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2071 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2072 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2073 -1, -1, 45, 46, -1, 99, -1, 50, 102, 103,
2074 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2075 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2076 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2077 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2078 93, -1, -1, -1, -1, 98, -1, -1, -1, 102,
2079 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2080 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2081 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2082 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2083 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2084 -1, 89, 90, -1, -1, 93, 94, -1, 45, 46,
2085 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2086 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2087 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2088 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2089 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2090 -1, 98, -1, -1, -1, 102, 103, 104, 105, -1,
2091 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2092 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2093 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2094 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2095 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2096 -1, 93, 94, -1, 45, 46, -1, -1, -1, 50,
2097 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2098 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2099 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2100 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2101 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
2102 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2103 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2104 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2105 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2106 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2107 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2108 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2109 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2110 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2111 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2112 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2113 -1, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2114 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2115 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2116 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2117 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2118 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2119 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2120 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2121 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2122 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2123 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2124 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2125 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2126 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2127 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2128 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2129 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2130 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2131 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2132 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2133 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2134 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2135 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2136 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2137 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2138 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2139 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2140 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2141 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2142 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2143 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2144 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2145 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2146 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2147 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2148 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2149 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2150 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2151 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2152 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2153 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2154 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2155 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2156 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2157 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2158 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2159 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2160 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2161 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2162 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2163 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2164 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2165 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2166 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2167 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2168 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2169 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2170 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2171 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2172 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2173 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2174 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2175 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2176 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2177 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2178 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2179 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2180 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2181 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2182 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2183 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2184 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2185 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2186 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2187 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2188 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2189 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2190 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2191 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2192 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2193 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2194 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2195 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2196 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2197 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2198 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2199 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2200 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2201 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2202 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2203 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2204 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2205 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2206 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2207 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2208 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2209 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2210 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2211 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2212 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2213 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2214 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2215 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2216 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2217 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2218 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2219 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2220 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2221 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2222 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2223 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2224 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2225 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2226 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2227 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2228 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2229 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2230 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2231 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2232 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2233 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2234 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2235 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2236 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2237 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2238 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2239 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2240 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2241 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2242 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2243 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2244 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2245 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2246 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2247 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2248 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2249 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2250 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2251 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2252 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2253 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2254 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2255 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2256 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2257 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2258 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2259 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2260 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2261 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2262 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2263 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2264 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2265 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2266 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2267 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2268 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2269 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2270 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2271 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2272 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2273 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2274 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2275 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2276 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2277 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2278 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2279 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2280 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2281 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2282 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2283 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2284 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2285 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2286 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2287 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2288 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2289 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2290 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2291 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2292 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2293 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2294 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2295 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2296 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2297 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2298 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2299 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2300 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2301 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2302 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2303 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2304 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2305 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2306 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2307 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2308 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2309 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2310 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2311 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2312 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2313 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2314 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2315 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2316 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2317 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2318 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2319 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2320 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2321 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2322 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2323 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2324 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2325 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2326 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2327 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2328 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2329 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2330 -1, -1, -1, -1, 65, -1, 1, -1, -1, -1,
2331 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2332 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2333 -1, 1, 93, -1, -1, -1, -1, -1, -1, -1,
2334 -1, 102, 103, 104, 105, -1, -1, 108, 109, 44,
2335 45, 46, -1, -1, -1, 50, -1, -1, -1, -1,
2336 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2337 65, -1, -1, 1, -1, 45, 46, 72, -1, -1,
2338 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
2339 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
2340 3, 4, 72, -1, 99, -1, 76, 102, 103, 104,
2341 105, -1, 82, 108, 109, 85, 86, 45, 46, -1,
2342 -1, -1, 50, 93, 94, -1, -1, -1, -1, -1,
2343 -1, 59, 102, 103, 104, 105, -1, 65, 108, 109,
2344 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2345 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2346 -1, -1, 65, -1, -1, 93, 94, 3, 4, 72,
2347 -1, -1, -1, 76, 102, 103, 104, 105, -1, 82,
2348 108, 109, 85, 86, 45, 46, 89, 90, -1, 50,
2349 93, -1, 95, 96, -1, -1, -1, -1, 59, 102,
2350 103, 104, 105, -1, 65, 108, 109, -1, -1, 45,
2351 46, 72, -1, -1, 50, 76, -1, -1, 3, 4,
2352 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2353 -1, -1, 93, -1, -1, -1, 72, -1, -1, -1,
2354 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2355 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2356 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2357 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2358 65, -1, -1, 3, 4, -1, -1, 72, -1, -1,
2359 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2360 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
2361 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2362 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2363 50, -1, -1, -1, 3, 4, -1, -1, -1, 59,
2364 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2365 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2366 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2367 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
2368 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2369 59, -1, -1, -1, -1, -1, 65, -1, -1, 3,
2370 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2371 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2372 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2373 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2374 109, 45, 46, -1, -1, -1, 50, -1, -1, -1,
2375 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
2376 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2377 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2378 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2379 -1, 44, 45, 46, -1, -1, -1, 50, 102, 103,
2380 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2381 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2382 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2383 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2384 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2385 103, 104, 105, -1, -1, 108, 109
2389 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2390 #line 3 "/usr/lib/bison.simple"
2391 /* This file comes from bison-1.28. */
2393 /* Skeleton output parser for bison,
2394 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2396 This program is free software; you can redistribute it and/or modify
2397 it under the terms of the GNU General Public License as published by
2398 the Free Software Foundation; either version 2, or (at your option)
2401 This program is distributed in the hope that it will be useful,
2402 but WITHOUT ANY WARRANTY; without even the implied warranty of
2403 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2404 GNU General Public License for more details.
2406 You should have received a copy of the GNU General Public License
2407 along with this program; if not, write to the Free Software
2408 Foundation, Inc., 59 Temple Place - Suite 330,
2409 Boston, MA 02111-1307, USA. */
2411 /* As a special exception, when this file is copied by Bison into a
2412 Bison output file, you may use that output file without restriction.
2413 This special exception was added by the Free Software Foundation
2414 in version 1.24 of Bison. */
2416 /* This is the parser code that is written into each bison parser
2417 when the %semantic_parser declaration is not specified in the grammar.
2418 It was written by Richard Stallman by simplifying the hairy parser
2419 used when %semantic_parser is specified. */
2421 #ifndef YYSTACK_USE_ALLOCA
2423 #define YYSTACK_USE_ALLOCA
2424 #else /* alloca not defined */
2426 #define YYSTACK_USE_ALLOCA
2427 #define alloca __builtin_alloca
2428 #else /* not GNU C. */
2429 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2430 #define YYSTACK_USE_ALLOCA
2432 #else /* not sparc */
2433 /* We think this test detects Watcom and Microsoft C. */
2434 /* This used to test MSDOS, but that is a bad idea
2435 since that symbol is in the user namespace. */
2436 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2437 #if 0 /* No need for malloc.h, which pollutes the namespace;
2438 instead, just don't use alloca. */
2441 #else /* not MSDOS, or __TURBOC__ */
2443 /* I don't know what this was needed for, but it pollutes the namespace.
2444 So I turned it off. rms, 2 May 1997. */
2445 /* #include <malloc.h> */
2447 #define YYSTACK_USE_ALLOCA
2448 #else /* not MSDOS, or __TURBOC__, or _AIX */
2450 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2451 and on HPUX 10. Eventually we can turn this on. */
2452 #define YYSTACK_USE_ALLOCA
2453 #define alloca __builtin_alloca
2456 #endif /* not _AIX */
2457 #endif /* not MSDOS, or __TURBOC__ */
2458 #endif /* not sparc */
2459 #endif /* not GNU C */
2460 #endif /* alloca not defined */
2461 #endif /* YYSTACK_USE_ALLOCA not defined */
2463 #ifdef YYSTACK_USE_ALLOCA
2464 #define YYSTACK_ALLOC alloca
2466 #define YYSTACK_ALLOC malloc
2469 /* Note: there must be only one dollar sign in this file.
2470 It is replaced by the list of actions, each action
2471 as one case of the switch. */
2473 #define yyerrok (yyerrstatus = 0)
2474 #define yyclearin (yychar = YYEMPTY)
2477 #define YYACCEPT goto yyacceptlab
2478 #define YYABORT goto yyabortlab
2479 #define YYERROR goto yyerrlab1
2480 /* Like YYERROR except do call yyerror.
2481 This remains here temporarily to ease the
2482 transition to the new meaning of YYERROR, for GCC.
2483 Once GCC version 2 has supplanted version 1, this can go. */
2484 #define YYFAIL goto yyerrlab
2485 #define YYRECOVERING() (!!yyerrstatus)
2486 #define YYBACKUP(token, value) \
2488 if (yychar == YYEMPTY && yylen == 1) \
2489 { yychar = (token), yylval = (value); \
2490 yychar1 = YYTRANSLATE (yychar); \
2495 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2499 #define YYERRCODE 256
2502 #define YYLEX yylex()
2508 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2510 #define YYLEX yylex(&yylval, &yylloc)
2512 #else /* not YYLSP_NEEDED */
2514 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2516 #define YYLEX yylex(&yylval)
2518 #endif /* not YYLSP_NEEDED */
2521 /* If nonreentrant, generate the variables here */
2525 int yychar; /* the lookahead symbol */
2526 YYSTYPE yylval; /* the semantic value of the */
2527 /* lookahead symbol */
2530 YYLTYPE yylloc; /* location data for the lookahead */
2534 int yynerrs; /* number of parse errors so far */
2535 #endif /* not YYPURE */
2538 int yydebug; /* nonzero means print parse trace */
2539 /* Since this is uninitialized, it does not stop multiple parsers
2543 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2546 #define YYINITDEPTH 200
2549 /* YYMAXDEPTH is the maximum size the stacks can grow to
2550 (effective only if the built-in stack extension method is used). */
2557 #define YYMAXDEPTH 10000
2560 /* Define __yy_memcpy. Note that the size argument
2561 should be passed with type unsigned int, because that is what the non-GCC
2562 definitions require. With GCC, __builtin_memcpy takes an arg
2563 of type size_t, but it can handle unsigned int. */
2565 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2566 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2567 #else /* not GNU C or C++ */
2570 /* This is the most reliable way to avoid incompatibilities
2571 in available built-in functions on various systems. */
2573 __yy_memcpy (to, from, count)
2578 register char *f = from;
2579 register char *t = to;
2580 register int i = count;
2586 #else /* __cplusplus */
2588 /* This is the most reliable way to avoid incompatibilities
2589 in available built-in functions on various systems. */
2591 __yy_memcpy (char *to, char *from, unsigned int count)
2593 register char *t = to;
2594 register char *f = from;
2595 register int i = count;
2604 #line 217 "/usr/lib/bison.simple"
2606 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2607 into yyparse. The argument should have type void *.
2608 It should actually point to an object.
2609 Grammar actions can access the variable by casting it
2610 to the proper pointer type. */
2612 #ifdef YYPARSE_PARAM
2614 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2615 #define YYPARSE_PARAM_DECL
2616 #else /* not __cplusplus */
2617 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2618 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2619 #endif /* not __cplusplus */
2620 #else /* not YYPARSE_PARAM */
2621 #define YYPARSE_PARAM_ARG
2622 #define YYPARSE_PARAM_DECL
2623 #endif /* not YYPARSE_PARAM */
2625 /* Prevent warning if -Wstrict-prototypes. */
2627 #ifdef YYPARSE_PARAM
2628 int yyparse (void *);
2635 yyparse(YYPARSE_PARAM_ARG)
2638 register int yystate;
2640 register short *yyssp;
2641 register YYSTYPE *yyvsp;
2642 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2643 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2645 short yyssa[YYINITDEPTH]; /* the state stack */
2646 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2648 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2649 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2652 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2653 YYLTYPE *yyls = yylsa;
2656 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2658 #define YYPOPSTACK (yyvsp--, yyssp--)
2661 int yystacksize = YYINITDEPTH;
2662 int yyfree_stacks = 0;
2673 YYSTYPE yyval; /* the variable used to return */
2674 /* semantic values from the action */
2681 fprintf(stderr, "Starting parse\n");
2687 yychar = YYEMPTY; /* Cause a token to be read. */
2689 /* Initialize stack pointers.
2690 Waste one element of value and location stack
2691 so that they stay on the same level as the state stack.
2692 The wasted elements are never initialized. */
2700 /* Push a new state, which is found in yystate . */
2701 /* In all cases, when you get here, the value and location stacks
2702 have just been pushed. so pushing a state here evens the stacks. */
2707 if (yyssp >= yyss + yystacksize - 1)
2709 /* Give user a chance to reallocate the stack */
2710 /* Use copies of these so that the &'s don't force the real ones into memory. */
2711 YYSTYPE *yyvs1 = yyvs;
2712 short *yyss1 = yyss;
2714 YYLTYPE *yyls1 = yyls;
2717 /* Get the current used size of the three stacks, in elements. */
2718 int size = yyssp - yyss + 1;
2721 /* Each stack pointer address is followed by the size of
2722 the data in use in that stack, in bytes. */
2724 /* This used to be a conditional around just the two extra args,
2725 but that might be undefined if yyoverflow is a macro. */
2726 yyoverflow("parser stack overflow",
2727 &yyss1, size * sizeof (*yyssp),
2728 &yyvs1, size * sizeof (*yyvsp),
2729 &yyls1, size * sizeof (*yylsp),
2732 yyoverflow("parser stack overflow",
2733 &yyss1, size * sizeof (*yyssp),
2734 &yyvs1, size * sizeof (*yyvsp),
2738 yyss = yyss1; yyvs = yyvs1;
2742 #else /* no yyoverflow */
2743 /* Extend the stack our own way. */
2744 if (yystacksize >= YYMAXDEPTH)
2746 yyerror("parser stack overflow");
2758 if (yystacksize > YYMAXDEPTH)
2759 yystacksize = YYMAXDEPTH;
2760 #ifndef YYSTACK_USE_ALLOCA
2763 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2764 __yy_memcpy ((char *)yyss, (char *)yyss1,
2765 size * (unsigned int) sizeof (*yyssp));
2766 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2767 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2768 size * (unsigned int) sizeof (*yyvsp));
2770 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2771 __yy_memcpy ((char *)yyls, (char *)yyls1,
2772 size * (unsigned int) sizeof (*yylsp));
2774 #endif /* no yyoverflow */
2776 yyssp = yyss + size - 1;
2777 yyvsp = yyvs + size - 1;
2779 yylsp = yyls + size - 1;
2784 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2787 if (yyssp >= yyss + yystacksize - 1)
2793 fprintf(stderr, "Entering state %d\n", yystate);
2799 /* Do appropriate processing given the current state. */
2800 /* Read a lookahead token if we need one and don't already have one. */
2803 /* First try to decide what to do without reference to lookahead token. */
2805 yyn = yypact[yystate];
2809 /* Not known => get a lookahead token if don't already have one. */
2811 /* yychar is either YYEMPTY or YYEOF
2812 or a valid token in external form. */
2814 if (yychar == YYEMPTY)
2818 fprintf(stderr, "Reading a token: ");
2823 /* Convert token to internal form (in yychar1) for indexing tables with */
2825 if (yychar <= 0) /* This means end of input. */
2828 yychar = YYEOF; /* Don't call YYLEX any more */
2832 fprintf(stderr, "Now at end of input.\n");
2837 yychar1 = YYTRANSLATE(yychar);
2842 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2843 /* Give the individual parser a way to print the precise meaning
2844 of a token, for further debugging info. */
2846 YYPRINT (stderr, yychar, yylval);
2848 fprintf (stderr, ")\n");
2854 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2859 /* yyn is what to do for this token type in this state.
2860 Negative => reduce, -yyn is rule number.
2861 Positive => shift, yyn is new state.
2862 New state is final state => don't bother to shift,
2863 just return success.
2864 0, or most negative number => error. */
2879 /* Shift the lookahead token. */
2883 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2886 /* Discard the token being shifted unless it is eof. */
2887 if (yychar != YYEOF)
2895 /* count tokens shifted since error; after three, turn off error status. */
2896 if (yyerrstatus) yyerrstatus--;
2901 /* Do the default action for the current state. */
2904 yyn = yydefact[yystate];
2908 /* Do a reduction. yyn is the number of a rule to reduce with. */
2912 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2919 fprintf (stderr, "Reducing via rule %d (line %d), ",
2922 /* Print the symbols being reduced, and their result. */
2923 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2924 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2925 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2933 #line 576 "./parse.y"
2937 #line 620 "./parse.y"
2939 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2940 CLASS_LOADED_P (yyval.node) = 1;
2944 #line 625 "./parse.y"
2945 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2948 #line 627 "./parse.y"
2949 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2952 #line 629 "./parse.y"
2953 {RULE ("']' expected"); RECOVER;;
2956 #line 631 "./parse.y"
2957 {RULE ("']' expected"); RECOVER;;
2960 #line 646 "./parse.y"
2961 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2964 #line 655 "./parse.y"
2965 {yyval.node = NULL;;
2968 #line 667 "./parse.y"
2974 #line 671 "./parse.y"
2980 #line 683 "./parse.y"
2982 ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2983 package_list = tree_cons (ctxp->package, NULL, package_list);
2987 #line 688 "./parse.y"
2988 {yyerror ("Missing name"); RECOVER;;
2991 #line 690 "./parse.y"
2992 {yyerror ("';' expected"); RECOVER;;
2995 #line 700 "./parse.y"
2997 tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2998 int i = IDENTIFIER_LENGTH (name)-1;
2999 const char *last = &IDENTIFIER_POINTER (name)[i];
3000 while (last != IDENTIFIER_POINTER (name))
3002 if (last [0] == '.')
3006 last_name = get_identifier (++last);
3007 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3009 tree err = find_name_in_single_imports (last_name);
3010 if (err && err != name)
3012 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3013 IDENTIFIER_POINTER (name),
3014 IDENTIFIER_POINTER (err));
3016 REGISTER_IMPORT (yyvsp[-1].node, last_name)
3019 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3023 #line 726 "./parse.y"
3024 {yyerror ("Missing name"); RECOVER;;
3027 #line 728 "./parse.y"
3028 {yyerror ("';' expected"); RECOVER;;
3031 #line 733 "./parse.y"
3033 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3034 /* Don't import java.lang.* twice. */
3035 if (name != java_lang_id)
3037 tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3038 read_import_dir (yyvsp[-3].node);
3039 TREE_CHAIN (node) = ctxp->import_demand_list;
3040 ctxp->import_demand_list = node;
3045 #line 745 "./parse.y"
3046 {yyerror ("'*' expected"); RECOVER;;
3049 #line 747 "./parse.y"
3050 {yyerror ("';' expected"); RECOVER;;
3053 #line 752 "./parse.y"
3054 { end_class_declaration (0); ;
3057 #line 754 "./parse.y"
3058 { end_class_declaration (0); ;
3061 #line 756 "./parse.y"
3062 { yyval.node = NULL; ;
3065 #line 758 "./parse.y"
3068 yyerror ("Class or interface declaration expected");
3072 #line 769 "./parse.y"
3074 yyval.value = (1 << yyvsp[0].value);
3078 #line 773 "./parse.y"
3080 int acc = (1 << yyvsp[0].value);
3081 if (yyval.value & acc)
3083 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3084 java_accstring_lookup (acc));
3092 #line 789 "./parse.y"
3093 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3096 #line 792 "./parse.y"
3097 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3100 #line 795 "./parse.y"
3101 {yyerror ("Missing class name"); RECOVER;;
3104 #line 797 "./parse.y"
3105 {yyerror ("Missing class name"); RECOVER;;
3108 #line 799 "./parse.y"
3110 if (!ctxp->class_err) yyerror ("'{' expected");
3115 #line 804 "./parse.y"
3116 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3119 #line 808 "./parse.y"
3120 { yyval.node = NULL; ;
3123 #line 810 "./parse.y"
3124 { yyval.node = yyvsp[0].node; ;
3127 #line 812 "./parse.y"
3128 {yyerror ("'{' expected"); ctxp->class_err=1;;
3131 #line 814 "./parse.y"
3132 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3135 #line 818 "./parse.y"
3136 { yyval.node = NULL_TREE; ;
3139 #line 820 "./parse.y"
3140 { yyval.node = yyvsp[0].node; ;
3143 #line 822 "./parse.y"
3146 yyerror ("Missing interface name");
3150 #line 830 "./parse.y"
3152 ctxp->interface_number = 1;
3153 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3157 #line 835 "./parse.y"
3159 ctxp->interface_number++;
3160 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3164 #line 840 "./parse.y"
3165 {yyerror ("Missing interface name"); RECOVER;;
3168 #line 845 "./parse.y"
3170 /* Store the location of the `}' when doing xrefs */
3172 DECL_END_SOURCE_LINE (GET_CPC ()) =
3173 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3174 yyval.node = GET_CPC ();
3178 #line 853 "./parse.y"
3180 /* Store the location of the `}' when doing xrefs */
3182 DECL_END_SOURCE_LINE (GET_CPC ()) =
3183 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3184 yyval.node = GET_CPC ();
3188 #line 872 "./parse.y"
3190 TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3191 SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3195 #line 881 "./parse.y"
3196 { yyval.node = yyvsp[-1].node; ;
3199 #line 884 "./parse.y"
3200 { end_class_declaration (1); ;
3203 #line 886 "./parse.y"
3204 { end_class_declaration (1); ;
3207 #line 892 "./parse.y"
3208 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3211 #line 894 "./parse.y"
3214 ("Illegal modifier `%s' for field declaration",
3215 yyvsp[-3].value, FIELD_MODIFIERS);
3216 check_modifiers_consistency (yyvsp[-3].value);
3217 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3221 #line 907 "./parse.y"
3222 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3225 #line 909 "./parse.y"
3226 {yyerror ("Missing term"); RECOVER;;
3229 #line 914 "./parse.y"
3230 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3233 #line 916 "./parse.y"
3235 if (java_error_count)
3236 yyvsp[0].node = NULL_TREE;
3237 yyval.node = build_tree_list
3238 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3242 #line 923 "./parse.y"
3244 yyerror ("Missing variable initializer");
3245 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3250 #line 929 "./parse.y"
3252 yyerror ("';' expected");
3253 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3258 #line 939 "./parse.y"
3259 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3262 #line 941 "./parse.y"
3263 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3266 #line 943 "./parse.y"
3267 {yyerror ("']' expected"); DRECOVER(vdi);;
3270 #line 945 "./parse.y"
3271 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3274 #line 956 "./parse.y"
3276 current_function_decl = yyvsp[0].node;
3277 if (current_function_decl
3278 && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3279 source_start_java_method (current_function_decl);
3281 current_function_decl = NULL_TREE;
3285 #line 965 "./parse.y"
3286 { finish_method_declaration (yyvsp[0].node); ;
3289 #line 967 "./parse.y"
3290 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3293 #line 972 "./parse.y"
3294 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3297 #line 974 "./parse.y"
3298 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3301 #line 976 "./parse.y"
3302 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3305 #line 978 "./parse.y"
3306 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3309 #line 980 "./parse.y"
3311 yyerror ("Invalid method declaration, method name required");
3316 #line 985 "./parse.y"
3320 #line 987 "./parse.y"
3321 {yyerror ("Identifier expected"); RECOVER;;
3324 #line 989 "./parse.y"
3325 {yyerror ("Identifier expected"); RECOVER;;
3328 #line 991 "./parse.y"
3330 yyerror ("Invalid method declaration, return type required");
3335 #line 999 "./parse.y"
3337 ctxp->formal_parameter_number = 0;
3338 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3342 #line 1004 "./parse.y"
3343 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3346 #line 1006 "./parse.y"
3348 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3349 TREE_PURPOSE (yyvsp[-2].node) =
3350 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3351 parse_warning_context
3353 "Discouraged form of returned type specification");
3357 #line 1015 "./parse.y"
3358 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3361 #line 1017 "./parse.y"
3362 {yyerror ("']' expected"); RECOVER;;
3365 #line 1022 "./parse.y"
3367 ctxp->formal_parameter_number = 1;
3371 #line 1026 "./parse.y"
3373 ctxp->formal_parameter_number += 1;
3374 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3378 #line 1031 "./parse.y"
3379 { yyerror ("Missing formal parameter term"); RECOVER; ;
3382 #line 1036 "./parse.y"
3384 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3388 #line 1040 "./parse.y"
3390 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3391 ARG_FINAL_P (yyval.node) = 1;
3395 #line 1045 "./parse.y"
3397 yyerror ("Missing identifier"); RECOVER;
3398 yyval.node = NULL_TREE;
3402 #line 1050 "./parse.y"
3404 yyerror ("Missing identifier"); RECOVER;
3405 yyval.node = NULL_TREE;
3409 #line 1058 "./parse.y"
3411 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3412 yyvsp[0].value, ACC_FINAL);
3413 if (yyvsp[0].value != ACC_FINAL)
3414 MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3418 #line 1067 "./parse.y"
3419 { yyval.node = NULL_TREE; ;
3422 #line 1069 "./parse.y"
3423 { yyval.node = yyvsp[0].node; ;
3426 #line 1071 "./parse.y"
3427 {yyerror ("Missing class type term"); RECOVER;;
3430 #line 1076 "./parse.y"
3431 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3434 #line 1078 "./parse.y"
3435 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3438 #line 1080 "./parse.y"
3439 {yyerror ("Missing class type term"); RECOVER;;
3442 #line 1087 "./parse.y"
3443 { yyval.node = NULL_TREE; ;
3446 #line 1093 "./parse.y"
3448 TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3449 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3453 #line 1098 "./parse.y"
3455 TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3456 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3460 #line 1106 "./parse.y"
3462 check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3463 /* Can't have a static initializer in an innerclass */
3464 if (yyvsp[0].value | ACC_STATIC &&
3465 GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3467 (MODIFIER_WFL (STATIC_TK),
3468 "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3469 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3470 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3474 #line 1122 "./parse.y"
3476 current_function_decl = yyvsp[0].node;
3477 source_start_java_method (current_function_decl);
3481 #line 1127 "./parse.y"
3482 { finish_method_declaration (yyvsp[0].node); ;
3485 #line 1132 "./parse.y"
3486 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3489 #line 1134 "./parse.y"
3490 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3493 #line 1139 "./parse.y"
3495 ctxp->formal_parameter_number = 0;
3496 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3500 #line 1144 "./parse.y"
3501 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3504 #line 1152 "./parse.y"
3506 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3507 yyval.node = yyvsp[0].node;
3511 #line 1157 "./parse.y"
3512 { yyval.node = yyvsp[0].node; ;
3515 #line 1159 "./parse.y"
3516 { yyval.node = yyvsp[0].node; ;
3519 #line 1161 "./parse.y"
3520 { yyval.node = yyvsp[0].node; ;
3523 #line 1171 "./parse.y"
3525 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3526 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3527 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3531 #line 1177 "./parse.y"
3533 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3534 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3535 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3539 #line 1185 "./parse.y"
3540 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3543 #line 1187 "./parse.y"
3544 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3547 #line 1192 "./parse.y"
3549 tree wfl = build_wfl_node (this_identifier_node);
3550 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3555 #line 1198 "./parse.y"
3557 tree wfl = build_wfl_node (super_identifier_node);
3558 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3563 #line 1209 "./parse.y"
3564 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3567 #line 1212 "./parse.y"
3568 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3571 #line 1215 "./parse.y"
3572 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3575 #line 1218 "./parse.y"
3576 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3579 #line 1221 "./parse.y"
3580 {yyerror ("'{' expected"); RECOVER;;
3583 #line 1223 "./parse.y"
3584 {yyerror ("'{' expected"); RECOVER;;
3587 #line 1228 "./parse.y"
3589 ctxp->interface_number = 1;
3590 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3594 #line 1233 "./parse.y"
3596 ctxp->interface_number++;
3597 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3601 #line 1238 "./parse.y"
3602 {yyerror ("Invalid interface type"); RECOVER;;
3605 #line 1240 "./parse.y"
3606 {yyerror ("Missing term"); RECOVER;;
3609 #line 1245 "./parse.y"
3610 { yyval.node = NULL_TREE; ;
3613 #line 1247 "./parse.y"
3614 { yyval.node = NULL_TREE; ;
3617 #line 1259 "./parse.y"
3618 { end_class_declaration (1); ;
3621 #line 1261 "./parse.y"
3622 { end_class_declaration (1); ;
3625 #line 1270 "./parse.y"
3627 check_abstract_method_header (yyvsp[-1].node);
3628 current_function_decl = NULL_TREE; /* FIXME ? */
3632 #line 1275 "./parse.y"
3633 {yyerror ("';' expected"); RECOVER;;
3636 #line 1281 "./parse.y"
3637 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3640 #line 1283 "./parse.y"
3641 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3644 #line 1285 "./parse.y"
3645 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3648 #line 1290 "./parse.y"
3650 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3651 yyvsp[0].node, NULL_TREE);
3655 #line 1295 "./parse.y"
3657 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3661 #line 1299 "./parse.y"
3662 {yyerror ("Missing term"); RECOVER;;
3665 #line 1305 "./parse.y"
3667 /* Store the location of the `}' when doing xrefs */
3668 if (current_function_decl && flag_emit_xref)
3669 DECL_END_SOURCE_LINE (current_function_decl) =
3670 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3671 yyval.node = empty_stmt_node;
3675 #line 1313 "./parse.y"
3676 { yyval.node = yyvsp[0].node; ;
3679 #line 1318 "./parse.y"
3683 #line 1323 "./parse.y"
3685 maybe_absorb_scoping_blocks ();
3686 /* Store the location of the `}' when doing xrefs */
3687 if (current_function_decl && flag_emit_xref)
3688 DECL_END_SOURCE_LINE (current_function_decl) =
3689 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3690 yyval.node = exit_block ();
3691 if (!BLOCK_SUBBLOCKS (yyval.node))
3692 BLOCK_SUBBLOCKS (yyval.node) = empty_stmt_node;
3696 #line 1343 "./parse.y"
3697 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3700 #line 1345 "./parse.y"
3702 LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3703 end_class_declaration (1);
3707 #line 1357 "./parse.y"
3708 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3711 #line 1359 "./parse.y"
3712 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3715 #line 1369 "./parse.y"
3716 { yyval.node = exit_block (); ;
3719 #line 1378 "./parse.y"
3720 { yyval.node = exit_block (); ;
3723 #line 1397 "./parse.y"
3724 { yyval.node = empty_stmt_node; ;
3727 #line 1402 "./parse.y"
3729 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3730 EXPR_WFL_NODE (yyvsp[-1].node));
3732 push_labeled_block (yyval.node);
3733 PUSH_LABELED_BLOCK (yyval.node);
3737 #line 1413 "./parse.y"
3738 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3741 #line 1415 "./parse.y"
3742 {yyerror ("':' expected"); RECOVER;;
3745 #line 1420 "./parse.y"
3746 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3749 #line 1427 "./parse.y"
3751 /* We have a statement. Generate a WFL around it so
3753 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3754 /* We know we have a statement, so set the debug
3755 info to be eventually generate here. */
3756 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3760 #line 1436 "./parse.y"
3762 if (ctxp->prevent_ese != lineno)
3763 yyerror ("Invalid expression statement");
3764 DRECOVER (expr_stmt);
3768 #line 1442 "./parse.y"
3770 if (ctxp->prevent_ese != lineno)
3771 yyerror ("Invalid expression statement");
3772 DRECOVER (expr_stmt);
3776 #line 1448 "./parse.y"
3778 if (ctxp->prevent_ese != lineno)
3779 yyerror ("Invalid expression statement");
3780 DRECOVER (expr_stmt);
3784 #line 1454 "./parse.y"
3785 {yyerror ("')' expected"); RECOVER;;
3788 #line 1456 "./parse.y"
3790 parse_ctor_invocation_error ();
3795 #line 1461 "./parse.y"
3796 {yyerror ("')' expected"); RECOVER;;
3799 #line 1463 "./parse.y"
3801 parse_ctor_invocation_error ();
3806 #line 1468 "./parse.y"
3807 {yyerror ("'(' expected"); RECOVER;;
3810 #line 1470 "./parse.y"
3811 {yyerror ("')' expected"); RECOVER;;
3814 #line 1472 "./parse.y"
3815 {yyerror ("')' expected"); RECOVER;;
3818 #line 1474 "./parse.y"
3819 {yyerror ("';' expected"); RECOVER;;
3822 #line 1476 "./parse.y"
3823 {yyerror ("';' expected"); RECOVER;;
3826 #line 1491 "./parse.y"
3828 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
3829 yyvsp[0].node, NULL_TREE);
3833 #line 1496 "./parse.y"
3834 {yyerror ("'(' expected"); RECOVER;;
3837 #line 1498 "./parse.y"
3838 {yyerror ("Missing term"); RECOVER;;
3841 #line 1500 "./parse.y"
3842 {yyerror ("')' expected"); RECOVER;;
3845 #line 1505 "./parse.y"
3846 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3849 #line 1510 "./parse.y"
3850 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3853 #line 1515 "./parse.y"
3859 #line 1519 "./parse.y"
3861 /* Make into "proper list" of COMPOUND_EXPRs.
3862 I.e. make the last statment also have its own
3864 maybe_absorb_scoping_blocks ();
3865 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3866 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3870 #line 1531 "./parse.y"
3872 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3873 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3877 #line 1536 "./parse.y"
3878 {yyerror ("'(' expected"); RECOVER;;
3881 #line 1538 "./parse.y"
3882 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3885 #line 1540 "./parse.y"
3886 {yyerror ("'{' expected"); RECOVER;;
3889 #line 1548 "./parse.y"
3890 { yyval.node = NULL_TREE; ;
3893 #line 1550 "./parse.y"
3894 { yyval.node = NULL_TREE; ;
3897 #line 1552 "./parse.y"
3898 { yyval.node = NULL_TREE; ;
3901 #line 1554 "./parse.y"
3902 { yyval.node = NULL_TREE; ;
3905 #line 1573 "./parse.y"
3907 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3908 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3909 java_method_add_stmt (current_function_decl, lab);
3913 #line 1579 "./parse.y"
3915 tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3916 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3917 java_method_add_stmt (current_function_decl, lab);
3921 #line 1585 "./parse.y"
3922 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3925 #line 1587 "./parse.y"
3926 {yyerror ("':' expected"); RECOVER;;
3929 #line 1589 "./parse.y"
3930 {yyerror ("':' expected"); RECOVER;;
3933 #line 1594 "./parse.y"
3935 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3936 yyval.node = build_new_loop (body);
3940 #line 1602 "./parse.y"
3941 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3944 #line 1604 "./parse.y"
3945 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3948 #line 1606 "./parse.y"
3949 {yyerror ("Missing term and ')' expected"); RECOVER;;
3952 #line 1608 "./parse.y"
3953 {yyerror ("')' expected"); RECOVER;;
3956 #line 1613 "./parse.y"
3957 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3960 #line 1618 "./parse.y"
3962 tree body = build_loop_body (0, NULL_TREE, 1);
3963 yyval.node = build_new_loop (body);
3967 #line 1627 "./parse.y"
3968 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3971 #line 1632 "./parse.y"
3972 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3975 #line 1634 "./parse.y"
3977 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3978 /* We have not condition, so we get rid of the EXIT_EXPR */
3979 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3984 #line 1641 "./parse.y"
3985 {yyerror ("Invalid control expression"); RECOVER;;
3988 #line 1643 "./parse.y"
3989 {yyerror ("Invalid update expression"); RECOVER;;
3992 #line 1645 "./parse.y"
3993 {yyerror ("Invalid update expression"); RECOVER;;
3996 #line 1650 "./parse.y"
3997 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
4000 #line 1652 "./parse.y"
4002 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4003 /* We have not condition, so we get rid of the EXIT_EXPR */
4004 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
4009 #line 1662 "./parse.y"
4011 /* This scope defined for local variable that may be
4012 defined within the scope of the for loop */
4017 #line 1668 "./parse.y"
4018 {yyerror ("'(' expected"); DRECOVER(for_1);;
4021 #line 1670 "./parse.y"
4022 {yyerror ("Invalid init statement"); RECOVER;;
4025 #line 1675 "./parse.y"
4027 /* We now declare the loop body. The loop is
4028 declared as a for loop. */
4029 tree body = build_loop_body (0, NULL_TREE, 0);
4030 yyval.node = build_new_loop (body);
4031 FOR_LOOP_P (yyval.node) = 1;
4032 /* The loop is added to the current block the for
4033 statement is defined within */
4034 java_method_add_stmt (current_function_decl, yyval.node);
4038 #line 1687 "./parse.y"
4039 { yyval.node = empty_stmt_node; ;
4042 #line 1689 "./parse.y"
4044 /* Init statement recorded within the previously
4045 defined block scope */
4046 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4050 #line 1695 "./parse.y"
4052 /* Local variable are recorded within the previously
4053 defined block scope */
4054 yyval.node = NULL_TREE;
4058 #line 1701 "./parse.y"
4059 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4062 #line 1705 "./parse.y"
4063 {yyval.node = empty_stmt_node;;
4066 #line 1707 "./parse.y"
4067 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4070 #line 1712 "./parse.y"
4071 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4074 #line 1714 "./parse.y"
4075 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4078 #line 1716 "./parse.y"
4079 {yyerror ("Missing term"); RECOVER;;
4082 #line 1721 "./parse.y"
4083 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4086 #line 1723 "./parse.y"
4087 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4090 #line 1725 "./parse.y"
4091 {yyerror ("Missing term"); RECOVER;;
4094 #line 1727 "./parse.y"
4095 {yyerror ("';' expected"); RECOVER;;
4098 #line 1732 "./parse.y"
4099 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4102 #line 1734 "./parse.y"
4103 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4106 #line 1736 "./parse.y"
4107 {yyerror ("Missing term"); RECOVER;;
4110 #line 1738 "./parse.y"
4111 {yyerror ("';' expected"); RECOVER;;
4114 #line 1743 "./parse.y"
4115 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4118 #line 1745 "./parse.y"
4119 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4122 #line 1747 "./parse.y"
4123 {yyerror ("Missing term"); RECOVER;;
4126 #line 1749 "./parse.y"
4127 {yyerror ("';' expected"); RECOVER;;
4130 #line 1754 "./parse.y"
4132 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4133 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4137 #line 1759 "./parse.y"
4138 {yyerror ("Missing term"); RECOVER;;
4141 #line 1761 "./parse.y"
4142 {yyerror ("';' expected"); RECOVER;;
4145 #line 1766 "./parse.y"
4147 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4148 EXPR_WFL_LINECOL (yyval.node) =
4149 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4153 #line 1772 "./parse.y"
4154 {yyerror ("'{' expected"); RECOVER;;
4157 #line 1774 "./parse.y"
4158 {yyerror ("'(' expected"); RECOVER;;
4161 #line 1776 "./parse.y"
4162 {yyerror ("Missing term"); RECOVER;;
4165 #line 1778 "./parse.y"
4166 {yyerror ("Missing term"); RECOVER;;
4169 #line 1783 "./parse.y"
4172 "Illegal modifier `%s'. Only `synchronized' was expected here",
4173 yyvsp[0].value, ACC_SYNCHRONIZED);
4174 if (yyvsp[0].value != ACC_SYNCHRONIZED)
4175 MODIFIER_WFL (SYNCHRONIZED_TK) =
4176 build_wfl_node (NULL_TREE);
4180 #line 1795 "./parse.y"
4181 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4184 #line 1797 "./parse.y"
4185 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4188 #line 1799 "./parse.y"
4189 { yyval.node = build_try_finally_statement
4190 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4191 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4195 #line 1804 "./parse.y"
4196 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4199 #line 1810 "./parse.y"
4201 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4202 yyval.node = yyvsp[0].node;
4206 #line 1818 "./parse.y"
4208 java_method_add_stmt (current_function_decl, yyvsp[0].node);
4210 yyval.node = yyvsp[-1].node;
4214 #line 1826 "./parse.y"
4216 /* We add a block to define a scope for
4217 formal_parameter (CCBP). The formal parameter is
4218 declared initialized by the appropriate function
4220 tree ccpb = enter_block ();
4221 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
4222 TREE_PURPOSE (yyvsp[-1].node),
4223 soft_exceptioninfo_call_node);
4224 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4225 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4227 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4228 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4232 #line 1842 "./parse.y"
4233 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4236 #line 1844 "./parse.y"
4238 yyerror ("Missing term or ')' expected");
4239 RECOVER; yyval.node = NULL_TREE;
4243 #line 1849 "./parse.y"
4244 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4247 #line 1854 "./parse.y"
4248 { yyval.node = yyvsp[0].node; ;
4251 #line 1856 "./parse.y"
4252 {yyerror ("'{' expected"); RECOVER; ;
4255 #line 1868 "./parse.y"
4256 { yyval.node = build_this (yyvsp[0].operator.location); ;
4259 #line 1870 "./parse.y"
4260 {yyval.node = yyvsp[-1].node;;
4263 #line 1880 "./parse.y"
4265 tree wfl = build_wfl_node (this_identifier_node);
4266 yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4270 #line 1885 "./parse.y"
4271 {yyerror ("')' expected"); RECOVER;;
4274 #line 1887 "./parse.y"
4275 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4278 #line 1889 "./parse.y"
4279 {yyerror ("'class' expected" ); RECOVER;;
4282 #line 1891 "./parse.y"
4283 {yyerror ("'class' expected" ); RECOVER;;
4286 #line 1899 "./parse.y"
4288 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4289 CLASS_LOADED_P (yyval.node) = 1;
4293 #line 1904 "./parse.y"
4294 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4297 #line 1914 "./parse.y"
4298 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4301 #line 1916 "./parse.y"
4302 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4305 #line 1918 "./parse.y"
4306 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4309 #line 1920 "./parse.y"
4310 { yyval.node = build_class_ref (void_type_node); ;
4313 #line 1925 "./parse.y"
4314 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4317 #line 1927 "./parse.y"
4318 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4321 #line 1933 "./parse.y"
4323 tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4324 yyval.node = make_qualified_primary (yyvsp[-3].node, ctor,
4325 EXPR_WFL_LINECOL (yyvsp[-3].node));
4329 #line 1940 "./parse.y"
4331 tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4332 yyval.node = make_qualified_primary (yyvsp[-4].node, ctor,
4333 EXPR_WFL_LINECOL (yyvsp[-4].node));
4337 #line 1947 "./parse.y"
4338 {yyerror ("'(' expected"); DRECOVER(new_1);;
4341 #line 1949 "./parse.y"
4342 {yyerror ("'(' expected"); RECOVER;;
4345 #line 1951 "./parse.y"
4346 {yyerror ("')' or term expected"); RECOVER;;
4349 #line 1953 "./parse.y"
4350 {yyerror ("')' expected"); RECOVER;;
4353 #line 1955 "./parse.y"
4354 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4357 #line 1957 "./parse.y"
4358 {yyerror ("'(' expected"); RECOVER;;
4361 #line 1967 "./parse.y"
4362 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4365 #line 1969 "./parse.y"
4367 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4368 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4370 end_class_declaration (1);
4372 /* Now we can craft the new expression */
4373 yyval.node = build_new_invocation (id, yyvsp[-3].node);
4375 /* Note that we can't possibly be here if
4376 `class_type' is an interface (in which case the
4377 anonymous class extends Object and implements
4378 `class_type', hence its constructor can't have
4381 /* Otherwise, the innerclass must feature a
4382 constructor matching `argument_list'. Anonymous
4383 classes are a bit special: it's impossible to
4384 define constructor for them, hence constructors
4385 must be generated following the hints provided by
4386 the `new' expression. Whether a super constructor
4387 of that nature exists or not is to be verified
4388 later on in verify_constructor_super.
4390 It's during the expansion of a `new' statement
4391 refering to an anonymous class that a ctor will
4392 be generated for the anonymous class, with the
4398 #line 2000 "./parse.y"
4399 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4402 #line 2002 "./parse.y"
4404 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4405 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4407 end_class_declaration (1);
4409 /* Now we can craft the new expression. The
4410 statement doesn't need to be remember so that a
4411 constructor can be generated, since its signature
4412 is already known. */
4413 yyval.node = build_new_invocation (id, NULL_TREE);
4417 #line 2018 "./parse.y"
4418 { yyval.node = yyvsp[-2].node; ;
4421 #line 2020 "./parse.y"
4422 { yyval.node = yyvsp[-2].node; ;
4425 #line 2025 "./parse.y"
4427 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4428 ctxp->formal_parameter_number = 1;
4432 #line 2030 "./parse.y"
4434 ctxp->formal_parameter_number += 1;
4435 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4439 #line 2035 "./parse.y"
4440 {yyerror ("Missing term"); RECOVER;;
4443 #line 2040 "./parse.y"
4444 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4447 #line 2042 "./parse.y"
4448 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4451 #line 2044 "./parse.y"
4452 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4455 #line 2046 "./parse.y"
4456 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4459 #line 2050 "./parse.y"
4462 while (CURRENT_OSB (ctxp)--)
4463 obstack_1grow (&temporary_obstack, '[');
4464 sig = obstack_finish (&temporary_obstack);
4465 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4466 yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4470 #line 2059 "./parse.y"
4472 tree type = yyvsp[-2].node;
4473 while (CURRENT_OSB (ctxp)--)
4474 type = build_java_array_type (type, -1);
4475 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4476 build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4480 #line 2067 "./parse.y"
4481 {yyerror ("'[' expected"); DRECOVER ("]");;
4484 #line 2069 "./parse.y"
4485 {yyerror ("']' expected"); RECOVER;;
4488 #line 2074 "./parse.y"
4489 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4492 #line 2076 "./parse.y"
4493 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4496 #line 2081 "./parse.y"
4498 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4499 yyval.node = yyvsp[-1].node;
4503 #line 2086 "./parse.y"
4504 {yyerror ("']' expected"); RECOVER;;
4507 #line 2088 "./parse.y"
4509 yyerror ("Missing term");
4510 yyerror ("']' expected");
4515 #line 2097 "./parse.y"
4518 /* If not initialized, allocate memory for the osb
4520 if (!ctxp->osb_limit)
4522 allocate = ctxp->osb_limit = 32;
4523 ctxp->osb_depth = -1;
4525 /* If capacity overflown, reallocate a bigger chunk */
4526 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4527 allocate = ctxp->osb_limit << 1;
4531 allocate *= sizeof (int);
4532 if (ctxp->osb_number)
4533 ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4536 ctxp->osb_number = (int *)xmalloc (allocate);
4539 CURRENT_OSB (ctxp) = 1;
4543 #line 2123 "./parse.y"
4544 { CURRENT_OSB (ctxp)++; ;
4547 #line 2125 "./parse.y"
4548 { yyerror ("']' expected"); RECOVER;;
4551 #line 2130 "./parse.y"
4552 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4555 #line 2134 "./parse.y"
4558 build_wfl_node (super_identifier_node);
4559 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4560 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4564 #line 2141 "./parse.y"
4565 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4568 #line 2146 "./parse.y"
4569 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4572 #line 2148 "./parse.y"
4573 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4576 #line 2150 "./parse.y"
4578 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4579 yyval.node = build_this_super_qualified_invocation
4580 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4583 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4584 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4589 #line 2161 "./parse.y"
4591 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4592 yyval.node = build_this_super_qualified_invocation
4593 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4596 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4597 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4602 #line 2172 "./parse.y"
4604 yyval.node = build_this_super_qualified_invocation
4605 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4609 #line 2177 "./parse.y"
4611 yyval.node = build_this_super_qualified_invocation
4612 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4616 #line 2186 "./parse.y"
4617 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4620 #line 2188 "./parse.y"
4621 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4624 #line 2193 "./parse.y"
4625 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4628 #line 2195 "./parse.y"
4629 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4632 #line 2197 "./parse.y"
4634 yyerror ("Missing term and ']' expected");
4635 DRECOVER(array_access);
4639 #line 2202 "./parse.y"
4641 yyerror ("']' expected");
4642 DRECOVER(array_access);
4646 #line 2207 "./parse.y"
4648 yyerror ("Missing term and ']' expected");
4649 DRECOVER(array_access);
4653 #line 2212 "./parse.y"
4655 yyerror ("']' expected");
4656 DRECOVER(array_access);
4660 #line 2227 "./parse.y"
4661 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4664 #line 2232 "./parse.y"
4665 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4668 #line 2239 "./parse.y"
4669 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4672 #line 2241 "./parse.y"
4673 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4676 #line 2244 "./parse.y"
4677 {yyerror ("Missing term"); RECOVER;
4680 #line 2246 "./parse.y"
4681 {yyerror ("Missing term"); RECOVER;
4684 #line 2251 "./parse.y"
4685 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4688 #line 2253 "./parse.y"
4689 {yyerror ("Missing term"); RECOVER;
4692 #line 2258 "./parse.y"
4693 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4696 #line 2260 "./parse.y"
4697 {yyerror ("Missing term"); RECOVER;
4700 #line 2266 "./parse.y"
4701 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4704 #line 2268 "./parse.y"
4705 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4708 #line 2271 "./parse.y"
4709 {yyerror ("Missing term"); RECOVER;
4712 #line 2273 "./parse.y"
4713 {yyerror ("Missing term"); RECOVER;
4716 #line 2278 "./parse.y"
4718 tree type = yyvsp[-3].node;
4719 while (CURRENT_OSB (ctxp)--)
4720 type = build_java_array_type (type, -1);
4722 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4726 #line 2286 "./parse.y"
4727 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4730 #line 2288 "./parse.y"
4731 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4734 #line 2290 "./parse.y"
4737 while (CURRENT_OSB (ctxp)--)
4738 obstack_1grow (&temporary_obstack, '[');
4740 obstack_grow0 (&temporary_obstack,
4741 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4742 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4743 ptr = obstack_finish (&temporary_obstack);
4744 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4745 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4749 #line 2303 "./parse.y"
4750 {yyerror ("']' expected, invalid type expression");;
4753 #line 2305 "./parse.y"
4755 if (ctxp->prevent_ese != lineno)
4756 yyerror ("Invalid type expression"); RECOVER;
4761 #line 2311 "./parse.y"
4762 {yyerror ("Missing term"); RECOVER;;
4765 #line 2313 "./parse.y"
4766 {yyerror ("Missing term"); RECOVER;;
4769 #line 2315 "./parse.y"
4770 {yyerror ("Missing term"); RECOVER;;
4773 #line 2321 "./parse.y"
4775 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4776 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4780 #line 2326 "./parse.y"
4782 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4783 yyvsp[-2].node, yyvsp[0].node);
4787 #line 2331 "./parse.y"
4789 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4790 yyvsp[-2].node, yyvsp[0].node);
4794 #line 2336 "./parse.y"
4795 {yyerror ("Missing term"); RECOVER;;
4798 #line 2338 "./parse.y"
4799 {yyerror ("Missing term"); RECOVER;;
4802 #line 2340 "./parse.y"
4803 {yyerror ("Missing term"); RECOVER;;
4806 #line 2346 "./parse.y"
4808 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4809 yyvsp[-2].node, yyvsp[0].node);
4813 #line 2351 "./parse.y"
4815 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4816 yyvsp[-2].node, yyvsp[0].node);
4820 #line 2356 "./parse.y"
4821 {yyerror ("Missing term"); RECOVER;;
4824 #line 2358 "./parse.y"
4825 {yyerror ("Missing term"); RECOVER;;
4828 #line 2364 "./parse.y"
4830 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4831 yyvsp[-2].node, yyvsp[0].node);
4835 #line 2369 "./parse.y"
4837 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4838 yyvsp[-2].node, yyvsp[0].node);
4842 #line 2374 "./parse.y"
4844 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4845 yyvsp[-2].node, yyvsp[0].node);
4849 #line 2379 "./parse.y"
4850 {yyerror ("Missing term"); RECOVER;;
4853 #line 2381 "./parse.y"
4854 {yyerror ("Missing term"); RECOVER;;
4857 #line 2383 "./parse.y"
4858 {yyerror ("Missing term"); RECOVER;;
4861 #line 2389 "./parse.y"
4863 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4864 yyvsp[-2].node, yyvsp[0].node);
4868 #line 2394 "./parse.y"
4870 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4871 yyvsp[-2].node, yyvsp[0].node);
4875 #line 2399 "./parse.y"
4877 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4878 yyvsp[-2].node, yyvsp[0].node);
4882 #line 2404 "./parse.y"
4884 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4885 yyvsp[-2].node, yyvsp[0].node);
4889 #line 2409 "./parse.y"
4890 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4893 #line 2411 "./parse.y"
4894 {yyerror ("Missing term"); RECOVER;;
4897 #line 2413 "./parse.y"
4898 {yyerror ("Missing term"); RECOVER;;
4901 #line 2415 "./parse.y"
4902 {yyerror ("Missing term"); RECOVER;;
4905 #line 2417 "./parse.y"
4906 {yyerror ("Missing term"); RECOVER;;
4909 #line 2419 "./parse.y"
4910 {yyerror ("Invalid reference type"); RECOVER;;
4913 #line 2425 "./parse.y"
4915 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4916 yyvsp[-2].node, yyvsp[0].node);
4920 #line 2430 "./parse.y"
4922 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4923 yyvsp[-2].node, yyvsp[0].node);
4927 #line 2435 "./parse.y"
4928 {yyerror ("Missing term"); RECOVER;;
4931 #line 2437 "./parse.y"
4932 {yyerror ("Missing term"); RECOVER;;
4935 #line 2443 "./parse.y"
4937 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4938 yyvsp[-2].node, yyvsp[0].node);
4942 #line 2448 "./parse.y"
4943 {yyerror ("Missing term"); RECOVER;;
4946 #line 2454 "./parse.y"
4948 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4949 yyvsp[-2].node, yyvsp[0].node);
4953 #line 2459 "./parse.y"
4954 {yyerror ("Missing term"); RECOVER;;
4957 #line 2465 "./parse.y"
4959 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4960 yyvsp[-2].node, yyvsp[0].node);
4964 #line 2470 "./parse.y"
4965 {yyerror ("Missing term"); RECOVER;;
4968 #line 2476 "./parse.y"
4970 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4971 yyvsp[-2].node, yyvsp[0].node);
4975 #line 2481 "./parse.y"
4976 {yyerror ("Missing term"); RECOVER;;
4979 #line 2487 "./parse.y"
4981 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4982 yyvsp[-2].node, yyvsp[0].node);
4986 #line 2492 "./parse.y"
4987 {yyerror ("Missing term"); RECOVER;;
4990 #line 2498 "./parse.y"
4992 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4993 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4997 #line 2503 "./parse.y"
5000 yyerror ("Missing term");
5005 #line 2509 "./parse.y"
5006 {yyerror ("Missing term"); DRECOVER (2);;
5009 #line 2511 "./parse.y"
5010 {yyerror ("Missing term"); DRECOVER (3);;
5013 #line 2521 "./parse.y"
5014 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5017 #line 2523 "./parse.y"
5019 if (ctxp->prevent_ese != lineno)
5020 yyerror ("Missing term");
5025 /* the action file gets copied in in place of this dollarsign */
5026 #line 543 "/usr/lib/bison.simple"
5037 short *ssp1 = yyss - 1;
5038 fprintf (stderr, "state stack now");
5039 while (ssp1 != yyssp)
5040 fprintf (stderr, " %d", *++ssp1);
5041 fprintf (stderr, "\n");
5051 yylsp->first_line = yylloc.first_line;
5052 yylsp->first_column = yylloc.first_column;
5053 yylsp->last_line = (yylsp-1)->last_line;
5054 yylsp->last_column = (yylsp-1)->last_column;
5059 yylsp->last_line = (yylsp+yylen-1)->last_line;
5060 yylsp->last_column = (yylsp+yylen-1)->last_column;
5064 /* Now "shift" the result of the reduction.
5065 Determine what state that goes to,
5066 based on the state we popped back to
5067 and the rule number reduced by. */
5071 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5072 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5073 yystate = yytable[yystate];
5075 yystate = yydefgoto[yyn - YYNTBASE];
5079 yyerrlab: /* here on detecting error */
5082 /* If not already recovering from an error, report this error. */
5086 #ifdef YYERROR_VERBOSE
5087 yyn = yypact[yystate];
5089 if (yyn > YYFLAG && yyn < YYLAST)
5096 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5097 for (x = (yyn < 0 ? -yyn : 0);
5098 x < (sizeof(yytname) / sizeof(char *)); x++)
5099 if (yycheck[x + yyn] == x)
5100 size += strlen(yytname[x]) + 15, count++;
5101 msg = (char *) malloc(size + 15);
5104 strcpy(msg, "parse error");
5109 for (x = (yyn < 0 ? -yyn : 0);
5110 x < (sizeof(yytname) / sizeof(char *)); x++)
5111 if (yycheck[x + yyn] == x)
5113 strcat(msg, count == 0 ? ", expecting `" : " or `");
5114 strcat(msg, yytname[x]);
5123 yyerror ("parse error; also virtual memory exceeded");
5126 #endif /* YYERROR_VERBOSE */
5127 yyerror("parse error");
5131 yyerrlab1: /* here on error raised explicitly by an action */
5133 if (yyerrstatus == 3)
5135 /* if just tried and failed to reuse lookahead token after an error, discard it. */
5137 /* return failure if at end of input */
5138 if (yychar == YYEOF)
5143 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5149 /* Else will try to reuse lookahead token
5150 after shifting the error token. */
5152 yyerrstatus = 3; /* Each real token shifted decrements this */
5156 yyerrdefault: /* current state does not do anything special for the error token. */
5159 /* This is wrong; only states that explicitly want error tokens
5160 should shift them. */
5161 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5162 if (yyn) goto yydefault;
5165 yyerrpop: /* pop the current state because it cannot handle the error token */
5167 if (yyssp == yyss) YYABORT;
5177 short *ssp1 = yyss - 1;
5178 fprintf (stderr, "Error: state stack now");
5179 while (ssp1 != yyssp)
5180 fprintf (stderr, " %d", *++ssp1);
5181 fprintf (stderr, "\n");
5187 yyn = yypact[yystate];
5192 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5211 fprintf(stderr, "Shifting error token, ");
5223 /* YYACCEPT comes here. */
5235 /* YYABORT comes here. */
5246 #line 2549 "./parse.y"
5250 /* This section of the code deal with save/restoring parser contexts.
5251 Add mode documentation here. FIXME */
5253 /* Helper function. Create a new parser context. With
5254 COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5255 context is copied, otherwise, the new context is zeroed. The newly
5256 created context becomes the current one. */
5259 create_new_parser_context (copy_from_previous)
5260 int copy_from_previous;
5262 struct parser_ctxt *new;
5264 new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5265 if (copy_from_previous)
5267 memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5268 new->saved_data_ctx = 1;
5271 bzero ((PTR) new, sizeof (struct parser_ctxt));
5277 /* Create a new parser context and make it the current one. */
5280 java_push_parser_context ()
5282 create_new_parser_context (0);
5285 ctxp->incomplete_class = ctxp->next->incomplete_class;
5286 ctxp->gclass_list = ctxp->next->gclass_list;
5291 java_pop_parser_context (generate)
5295 struct parser_ctxt *toFree, *next;
5304 next->incomplete_class = ctxp->incomplete_class;
5305 next->gclass_list = ctxp->gclass_list;
5306 lineno = ctxp->lineno;
5307 finput = ctxp->finput;
5308 current_class = ctxp->current_class;
5311 /* Set the single import class file flag to 0 for the current list
5312 of imported things */
5313 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5314 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5316 /* And restore those of the previous context */
5317 if ((ctxp = next)) /* Assignment is really meant here */
5318 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5319 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5321 /* If we pushed a context to parse a class intended to be generated,
5322 we keep it so we can remember the class. What we could actually
5323 do is to just update a list of class names. */
5326 toFree->next = ctxp_for_generation;
5327 ctxp_for_generation = toFree;
5333 /* Create a parser context for the use of saving some global
5337 java_parser_context_save_global ()
5341 java_push_parser_context ();
5342 ctxp->saved_data_ctx = 1;
5345 /* If this context already stores data, create a new one suitable
5346 for data storage. */
5347 else if (ctxp->saved_data)
5348 create_new_parser_context (1);
5350 ctxp->finput = finput;
5351 ctxp->lineno = lineno;
5352 ctxp->current_class = current_class;
5353 ctxp->filename = input_filename;
5354 ctxp->current_function_decl = current_function_decl;
5355 ctxp->saved_data = 1;
5358 /* Restore some global variables from the previous context. Make the
5359 previous context the current one. */
5362 java_parser_context_restore_global ()
5364 finput = ctxp->finput;
5365 lineno = ctxp->lineno;
5366 current_class = ctxp->current_class;
5367 input_filename = ctxp->filename;
5368 current_function_decl = ctxp->current_function_decl;
5369 ctxp->saved_data = 0;
5370 if (ctxp->saved_data_ctx)
5371 java_pop_parser_context (0);
5374 /* Suspend vital data for the current class/function being parsed so
5375 that an other class can be parsed. Used to let local/anonymous
5376 classes be parsed. */
5379 java_parser_context_suspend ()
5381 /* This makes debugging through java_debug_context easier */
5382 static const char *name = "<inner buffer context>";
5384 /* Duplicate the previous context, use it to save the globals we're
5386 create_new_parser_context (1);
5387 ctxp->current_function_decl = current_function_decl;
5388 ctxp->current_class = current_class;
5390 /* Then create a new context which inherits all data from the
5391 previous one. This will be the new current context */
5392 create_new_parser_context (1);
5394 /* Help debugging */
5395 ctxp->next->filename = name;
5398 /* Resume vital data for the current class/function being parsed so
5399 that an other class can be parsed. Used to let local/anonymous
5400 classes be parsed. The trick is the data storing file position
5401 informations must be restored to their current value, so parsing
5402 can resume as if no context was ever saved. */
5405 java_parser_context_resume ()
5407 struct parser_ctxt *old = ctxp; /* This one is to be discarded */
5408 struct parser_ctxt *saver = old->next; /* This one contain saved info */
5409 struct parser_ctxt *restored = saver->next; /* This one is the old current */
5411 /* We need to inherit the list of classes to complete/generate */
5412 restored->incomplete_class = old->incomplete_class;
5413 restored->gclass_list = old->gclass_list;
5414 restored->classd_list = old->classd_list;
5415 restored->class_list = old->class_list;
5417 /* Restore the current class and function from the saver */
5418 current_class = saver->current_class;
5419 current_function_decl = saver->current_function_decl;
5421 /* Retrive the restored context */
5424 /* Re-installed the data for the parsing to carry on */
5425 bcopy (&old->marker_begining, &ctxp->marker_begining,
5426 (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5428 /* Buffer context can now be discarded */
5433 /* Add a new anchor node to which all statement(s) initializing static
5434 and non static initialized upon declaration field(s) will be
5438 java_parser_context_push_initialized_field ()
5442 node = build_tree_list (NULL_TREE, NULL_TREE);
5443 TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5444 CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5446 node = build_tree_list (NULL_TREE, NULL_TREE);
5447 TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5448 CPC_INITIALIZER_LIST (ctxp) = node;
5450 node = build_tree_list (NULL_TREE, NULL_TREE);
5451 TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5452 CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5455 /* Pop the lists of initialized field. If this lists aren't empty,
5456 remember them so we can use it to create and populate the $finit$
5457 or <clinit> functions. */
5460 java_parser_context_pop_initialized_field ()
5463 tree class_type = TREE_TYPE (GET_CPC ());
5465 if (CPC_INITIALIZER_LIST (ctxp))
5467 stmts = CPC_INITIALIZER_STMT (ctxp);
5468 CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5469 if (stmts && !java_error_count)
5470 TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5473 if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5475 stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5476 CPC_STATIC_INITIALIZER_LIST (ctxp) =
5477 TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5478 /* Keep initialization in order to enforce 8.5 */
5479 if (stmts && !java_error_count)
5480 TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5483 /* JDK 1.1 instance initializers */
5484 if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5486 stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5487 CPC_INSTANCE_INITIALIZER_LIST (ctxp) =
5488 TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5489 if (stmts && !java_error_count)
5490 TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5495 reorder_static_initialized (list)
5498 /* We have to keep things in order. The alias initializer have to
5499 come first, then the initialized regular field, in reverse to
5500 keep them in lexical order. */
5501 tree marker, previous = NULL_TREE;
5502 for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5503 if (TREE_CODE (marker) == TREE_LIST
5504 && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5507 /* No static initialized, the list is fine as is */
5509 list = TREE_CHAIN (marker);
5511 /* No marker? reverse the whole list */
5513 list = nreverse (list);
5515 /* Otherwise, reverse what's after the marker and the new reordered
5516 sublist will replace the marker. */
5519 TREE_CHAIN (previous) = NULL_TREE;
5520 list = nreverse (list);
5521 list = chainon (TREE_CHAIN (marker), list);
5526 /* Helper functions to dump the parser context stack. */
5528 #define TAB_CONTEXT(C) \
5529 {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5532 java_debug_context_do (tab)
5535 struct parser_ctxt *copy = ctxp;
5539 fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5541 fprintf (stderr, "filename: %s\n", copy->filename);
5543 fprintf (stderr, "lineno: %d\n", copy->lineno);
5545 fprintf (stderr, "package: %s\n",
5547 IDENTIFIER_POINTER (copy->package) : "<none>"));
5549 fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5551 fprintf (stderr, "saved data: %d\n", copy->saved_data);
5557 /* Dump the stacked up parser contexts. Intended to be called from a
5561 java_debug_context ()
5563 java_debug_context_do (0);
5568 /* Flag for the error report routine to issue the error the first time
5569 it's called (overriding the default behavior which is to drop the
5570 first invocation and honor the second one, taking advantage of a
5572 static int force_error = 0;
5574 /* Reporting an constructor invocation error. */
5576 parse_ctor_invocation_error ()
5578 if (DECL_CONSTRUCTOR_P (current_function_decl))
5579 yyerror ("Constructor invocation must be first thing in a constructor");
5581 yyerror ("Only constructors can invoke constructors");
5584 /* Reporting JDK1.1 features not implemented. */
5587 parse_jdk1_1_error (msg)
5590 sorry (": `%s' JDK1.1(TM) feature", msg);
5592 return empty_stmt_node;
5595 static int do_warning = 0;
5602 static int prev_lineno;
5603 static const char *prev_msg;
5606 char *remainder, *code_from_source;
5607 extern struct obstack temporary_obstack;
5609 if (!force_error && prev_lineno == lineno)
5612 /* Save current error location but report latter, when the context is
5614 if (ctxp->java_error_flag == 0)
5616 ctxp->java_error_flag = 1;
5618 /* Do something to use the previous line if we're reaching the
5619 end of the file... */
5620 #ifdef VERBOSE_SKELETON
5621 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5626 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5627 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5630 ctxp->java_error_flag = 0;
5632 java_warning_count++;
5636 if (elc.col == 0 && msg && msg[1] == ';')
5638 elc.col = ctxp->p_line->char_col-1;
5639 elc.line = ctxp->p_line->lineno;
5642 save_lineno = lineno;
5643 prev_lineno = lineno = elc.line;
5646 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5647 obstack_grow0 (&temporary_obstack,
5648 code_from_source, strlen (code_from_source));
5649 remainder = obstack_finish (&temporary_obstack);
5651 warning ("%s.\n%s", msg, remainder);
5653 error ("%s.\n%s", msg, remainder);
5655 /* This allow us to cheaply avoid an extra 'Invalid expression
5656 statement' error report when errors have been already reported on
5657 the same line. This occurs when we report an error but don't have
5658 a synchronization point other than ';', which
5659 expression_statement is the only one to take care of. */
5660 ctxp->prevent_ese = lineno = save_lineno;
5664 issue_warning_error_from_context (cl, msg, ap)
5669 const char *saved, *saved_input_filename;
5671 vsprintf (buffer, msg, ap);
5674 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5675 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5676 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5678 /* We have a CL, that's a good reason for using it if it contains data */
5679 saved = ctxp->filename;
5680 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5681 ctxp->filename = EXPR_WFL_FILENAME (cl);
5682 saved_input_filename = input_filename;
5683 input_filename = ctxp->filename;
5685 java_error (buffer);
5686 ctxp->filename = saved;
5687 input_filename = saved_input_filename;
5691 /* Issue an error message at a current source line CL */
5694 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5696 #ifndef ANSI_PROTOTYPES
5703 #ifndef ANSI_PROTOTYPES
5704 cl = va_arg (ap, tree);
5705 msg = va_arg (ap, const char *);
5707 issue_warning_error_from_context (cl, msg, ap);
5711 /* Issue a warning at a current source line CL */
5714 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5716 #ifndef ANSI_PROTOTYPES
5723 #ifndef ANSI_PROTOTYPES
5724 cl = va_arg (ap, tree);
5725 msg = va_arg (ap, const char *);
5728 force_error = do_warning = 1;
5729 issue_warning_error_from_context (cl, msg, ap);
5730 do_warning = force_error = 0;
5735 find_expr_with_wfl (node)
5743 switch (TREE_CODE (node))
5746 node = BLOCK_EXPR_BODY (node);
5750 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5753 node = TREE_OPERAND (node, 1);
5757 node = TREE_OPERAND (node, 0);
5760 case LABELED_BLOCK_EXPR:
5761 node = TREE_OPERAND (node, 1);
5765 code = TREE_CODE_CLASS (TREE_CODE (node));
5766 if (((code == '1') || (code == '2') || (code == 'e'))
5767 && EXPR_WFL_LINECOL (node))
5775 /* Issue a missing return statement error. Uses METHOD to figure the
5776 last line of the method the error occurs in. */
5779 missing_return_error (method)
5782 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5783 parse_error_context (wfl_operator, "Missing return statement");
5786 /* Issue an unreachable statement error. From NODE, find the next
5787 statement to report appropriately. */
5789 unreachable_stmt_error (node)
5792 /* Browse node to find the next expression node that has a WFL. Use
5793 the location to report the error */
5794 if (TREE_CODE (node) == COMPOUND_EXPR)
5795 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5797 node = find_expr_with_wfl (node);
5801 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5802 parse_error_context (wfl_operator, "Unreachable statement");
5805 fatal ("Can't get valid statement - unreachable_stmt_error");
5809 java_report_errors ()
5811 if (java_error_count)
5812 fprintf (stderr, "%d error%s",
5813 java_error_count, (java_error_count == 1 ? "" : "s"));
5814 if (java_warning_count)
5815 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5816 java_warning_count, (java_warning_count == 1 ? "" : "s"));
5817 if (java_error_count || java_warning_count)
5818 putc ('\n', stderr);
5819 return java_error_count;
5823 java_accstring_lookup (flags)
5826 static char buffer [80];
5827 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5829 /* Access modifier looked-up first for easier report on forbidden
5831 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5832 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5833 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5834 if (flags & ACC_STATIC) COPY_RETURN ("static");
5835 if (flags & ACC_FINAL) COPY_RETURN ("final");
5836 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5837 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5838 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5839 if (flags & ACC_NATIVE) COPY_RETURN ("native");
5840 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5841 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5848 /* Issuing error messages upon redefinition of classes, interfaces or
5852 classitf_redefinition_error (context, id, decl, cl)
5853 const char *context;
5856 parse_error_context (cl, "%s `%s' already defined in %s:%d",
5857 context, IDENTIFIER_POINTER (id),
5858 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5859 /* Here we should point out where its redefined. It's a unicode. FIXME */
5863 variable_redefinition_error (context, name, type, line)
5864 tree context, name, type;
5867 const char *type_name;
5869 /* Figure a proper name for type. We might haven't resolved it */
5870 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5871 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5873 type_name = lang_printable_name (type, 0);
5875 parse_error_context (context,
5876 "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
5877 IDENTIFIER_POINTER (name),
5878 type_name, IDENTIFIER_POINTER (name), line);
5882 build_array_from_name (type, type_wfl, name, ret_name)
5883 tree type, type_wfl, name, *ret_name;
5888 /* Eventually get more dims */
5889 string = IDENTIFIER_POINTER (name);
5890 while (string [more_dims] == '[')
5893 /* If we have, then craft a new type for this variable */
5896 name = get_identifier (&string [more_dims]);
5898 /* If we have a pointer, use its type */
5899 if (TREE_CODE (type) == POINTER_TYPE)
5900 type = TREE_TYPE (type);
5902 /* Building the first dimension of a primitive type uses this
5904 if (JPRIMITIVE_TYPE_P (type))
5906 type = build_java_array_type (type, -1);
5907 CLASS_LOADED_P (type) = 1;
5910 /* Otherwise, if we have a WFL for this type, use it (the type
5911 is already an array on an unresolved type, and we just keep
5912 on adding dimensions) */
5916 /* Add all the dimensions */
5918 type = build_unresolved_array_type (type);
5920 /* The type may have been incomplete in the first place */
5922 type = obtain_incomplete_type (type);
5930 /* Build something that the type identifier resolver will identify as
5931 being an array to an unresolved type. TYPE_WFL is a WFL on a
5935 build_unresolved_array_type (type_or_wfl)
5940 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5941 just create a array type */
5942 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5944 tree type = build_java_array_type (type_or_wfl, -1);
5945 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5949 obstack_1grow (&temporary_obstack, '[');
5950 obstack_grow0 (&temporary_obstack,
5951 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5952 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5953 ptr = obstack_finish (&temporary_obstack);
5954 return build_expr_wfl (get_identifier (ptr),
5955 EXPR_WFL_FILENAME (type_or_wfl),
5956 EXPR_WFL_LINENO (type_or_wfl),
5957 EXPR_WFL_COLNO (type_or_wfl));
5961 parser_add_interface (class_decl, interface_decl, wfl)
5962 tree class_decl, interface_decl, wfl;
5964 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5965 parse_error_context (wfl, "Interface `%s' repeated",
5966 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5969 /* Bulk of common class/interface checks. Return 1 if an error was
5970 encountered. TAG is 0 for a class, 1 for an interface. */
5973 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5974 int is_interface, flags;
5975 tree raw_name, qualified_name, decl, cl;
5978 int sca = 0; /* Static class allowed */
5979 int icaf = 0; /* Inner class allowed flags */
5980 int uaaf = CLASS_MODIFIERS; /* Usually allowed access flags */
5983 fprintf (stderr, " %s%s %s",
5984 (CPC_INNER_P () ? "inner" : ""),
5985 (is_interface ? "interface" : "class"),
5986 IDENTIFIER_POINTER (qualified_name));
5988 /* Scope of an interface/class type name:
5989 - Can't be imported by a single type import
5990 - Can't already exists in the package */
5991 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5992 && (node = find_name_in_single_imports (raw_name)))
5995 (cl, "%s name `%s' clashes with imported type `%s'",
5996 (is_interface ? "Interface" : "Class"),
5997 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
6000 if (decl && CLASS_COMPLETE_P (decl))
6002 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
6003 qualified_name, decl, cl);
6007 if (check_inner_class_redefinition (raw_name, cl))
6010 /* If public, file name should match class/interface name, except
6011 when dealing with an inner class */
6012 if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6016 /* Contains OS dependent assumption on path separator. FIXME */
6017 for (f = &input_filename [strlen (input_filename)];
6018 f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6021 if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6023 if (strncmp (IDENTIFIER_POINTER (raw_name),
6024 f , IDENTIFIER_LENGTH (raw_name)) ||
6025 f [IDENTIFIER_LENGTH (raw_name)] != '.')
6027 (cl, "Public %s `%s' must be defined in a file called `%s.java'",
6028 (is_interface ? "interface" : "class"),
6029 IDENTIFIER_POINTER (qualified_name),
6030 IDENTIFIER_POINTER (raw_name));
6033 /* Static classes can be declared only in top level classes. Note:
6034 once static, a inner class is a top level class. */
6035 if (flags & ACC_STATIC)
6037 /* Catch the specific error of declaring an class inner class
6038 with no toplevel enclosing class. Prevent check_modifiers from
6039 complaining a second time */
6040 if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6042 parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
6043 IDENTIFIER_POINTER (qualified_name));
6046 /* Else, in the context of a top-level class declaration, let
6047 `check_modifiers' do its job, otherwise, give it a go */
6049 sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6052 /* Inner classes can be declared private or protected
6053 within their enclosing classes. */
6056 /* A class which is local to a block can't be public, private,
6057 protected or static. But it is created final, so allow this
6059 if (current_function_decl)
6060 icaf = sca = uaaf = ACC_FINAL;
6063 check_modifiers_consistency (flags);
6064 icaf = ACC_PRIVATE|ACC_PROTECTED;
6071 uaaf = INTERFACE_INNER_MODIFIERS;
6073 uaaf = INTERFACE_MODIFIERS;
6075 check_modifiers ("Illegal modifier `%s' for interface declaration",
6079 check_modifiers ((current_function_decl ?
6080 "Illegal modifier `%s' for local class declaration" :
6081 "Illegal modifier `%s' for class declaration"),
6082 flags, uaaf|sca|icaf);
6087 make_nested_class_name (cpc_list)
6095 make_nested_class_name (TREE_CHAIN (cpc_list));
6097 /* Pick the qualified name when dealing with the first upmost
6099 name = (TREE_CHAIN (cpc_list) ?
6100 TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6101 obstack_grow (&temporary_obstack,
6102 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6103 /* Why is NO_DOLLAR_IN_LABEL defined? */
6105 #ifdef NO_DOLLAR_IN_LABEL
6106 fatal ("make_nested_class_name: Can't use '$' as a separator "
6107 "for inner classes");
6110 obstack_1grow (&temporary_obstack, '$');
6113 /* Can't redefine a class already defined in an earlier scope. */
6116 check_inner_class_redefinition (raw_name, cl)
6121 for (scope_list = GET_CPC_LIST (); scope_list;
6122 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6123 if (raw_name == GET_CPC_UN_NODE (scope_list))
6126 (cl, "The class name `%s' is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes",
6127 IDENTIFIER_POINTER (raw_name));
6134 find_as_inner_class (enclosing, name, cl)
6135 tree enclosing, name, cl;
6137 tree qual, to_return;
6141 name = TYPE_NAME (name);
6143 /* First search: within the scope of `enclosing', search for name */
6144 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6145 qual = EXPR_WFL_QUALIFICATION (cl);
6147 qual = build_tree_list (cl, NULL_TREE);
6149 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6151 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6154 /* We're dealing with a qualified name. Try to resolve thing until
6155 we get something that is an enclosing class. */
6156 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6158 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6160 for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6161 qual = TREE_CHAIN (qual))
6163 acc = merge_qualified_name (acc,
6164 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6165 BUILD_PTR_FROM_NAME (ptr, acc);
6166 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6169 /* A NULL qual and a decl means that the search ended
6170 successfully?!? We have to do something then. FIXME */
6175 qual = EXPR_WFL_QUALIFICATION (cl);
6177 /* Otherwise, create a qual for the other part of the resolution. */
6179 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6181 return find_as_inner_class_do (qual, enclosing);
6184 /* We go inside the list of sub classes and try to find a way
6188 find_as_inner_class_do (qual, enclosing)
6189 tree qual, enclosing;
6194 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6196 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6197 tree next_enclosing = NULL_TREE;
6200 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6201 inner_list; inner_list = TREE_CHAIN (inner_list))
6203 if (TREE_VALUE (inner_list) == name_to_match)
6205 next_enclosing = TREE_PURPOSE (inner_list);
6209 enclosing = next_enclosing;
6212 return (!qual && enclosing ? enclosing : NULL_TREE);
6215 /* Reach all inner classes and tie their unqualified name to a
6219 set_nested_class_simple_name_value (outer, set)
6225 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6226 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6227 TREE_PURPOSE (l) : NULL_TREE);
6231 link_nested_class_to_enclosing ()
6233 if (GET_ENCLOSING_CPC ())
6235 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6236 DECL_INNER_CLASS_LIST (enclosing) =
6237 tree_cons (GET_CPC (), GET_CPC_UN (),
6238 DECL_INNER_CLASS_LIST (enclosing));
6239 enclosing = enclosing;
6244 maybe_make_nested_class_name (name)
6247 tree id = NULL_TREE;
6251 make_nested_class_name (GET_CPC_LIST ());
6252 obstack_grow0 (&temporary_obstack,
6253 IDENTIFIER_POINTER (name),
6254 IDENTIFIER_LENGTH (name));
6255 id = get_identifier (obstack_finish (&temporary_obstack));
6257 QUALIFIED_P (id) = 1;
6262 /* If DECL is NULL, create and push a new DECL, record the current
6263 line CL and do other maintenance things. */
6266 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6267 tree decl, raw_name, qualified_name, cl;
6270 decl = push_class (make_class (), qualified_name);
6272 /* Take care of the file and line business */
6273 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6274 /* If we're emiting xrefs, store the line/col number information */
6276 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6278 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6279 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6280 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6281 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6283 PUSH_CPC (decl, raw_name);
6284 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6286 /* Link the declaration to the already seen ones */
6287 TREE_CHAIN (decl) = ctxp->class_list;
6288 ctxp->class_list = decl;
6290 /* Create a new nodes in the global lists */
6291 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6292 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6294 /* Install a new dependency list element */
6295 create_jdep_list (ctxp);
6297 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6298 IDENTIFIER_POINTER (qualified_name)));
6303 add_superinterfaces (decl, interface_list)
6304 tree decl, interface_list;
6307 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6308 takes care of ensuring that:
6309 - This is an accessible interface type,
6310 - Circularity detection.
6311 parser_add_interface is then called. If present but not defined,
6312 the check operation is delayed until the super interface gets
6314 for (node = interface_list; node; node = TREE_CHAIN (node))
6316 tree current = TREE_PURPOSE (node);
6317 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6318 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6320 if (!parser_check_super_interface (idecl, decl, current))
6321 parser_add_interface (decl, idecl, current);
6324 register_incomplete_type (JDEP_INTERFACE,
6325 current, decl, NULL_TREE);
6329 /* Create an interface in pass1 and return its decl. Return the
6330 interface's decl in pass 2. */
6333 create_interface (flags, id, super)
6337 tree raw_name = EXPR_WFL_NODE (id);
6338 tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6339 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6341 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6343 /* Basic checks: scope, redefinition, modifiers */
6344 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6350 /* Suspend the current parsing context if we're parsing an inner
6353 java_parser_context_suspend ();
6355 /* Push a new context for (static) initialized upon declaration fields */
6356 java_parser_context_push_initialized_field ();
6358 /* Interface modifiers check
6359 - public/abstract allowed (already done at that point)
6360 - abstract is obsolete (comes first, it's a warning, or should be)
6361 - Can't use twice the same (checked in the modifier rule) */
6362 if ((flags & ACC_ABSTRACT) && flag_redundant)
6363 parse_warning_context
6364 (MODIFIER_WFL (ABSTRACT_TK),
6365 "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6367 /* Create a new decl if DECL is NULL, otherwise fix it */
6368 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6370 /* Set super info and mark the class a complete */
6371 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6372 object_type_node, ctxp->interface_number);
6373 ctxp->interface_number = 0;
6374 CLASS_COMPLETE_P (decl) = 1;
6375 add_superinterfaces (decl, super);
6380 /* Anonymous class counter. Will be reset to 1 every time a non
6381 anonymous class gets created. */
6382 static int anonymous_class_counter = 1;
6384 /* Patch anonymous class CLASS, by either extending or implementing
6388 patch_anonymous_class (type_decl, class_decl, wfl)
6389 tree type_decl, class_decl, wfl;
6391 tree class = TREE_TYPE (class_decl);
6392 tree type = TREE_TYPE (type_decl);
6393 tree binfo = TYPE_BINFO (class);
6395 /* If it's an interface, implement it */
6396 if (CLASS_INTERFACE (type_decl))
6401 if (parser_check_super_interface (type_decl, class_decl, wfl))
6404 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6405 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6406 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6407 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6408 /* And add the interface */
6409 parser_add_interface (class_decl, type_decl, wfl);
6411 /* Otherwise, it's a type we want to extend */
6414 if (parser_check_super (type_decl, class_decl, wfl))
6416 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6421 create_anonymous_class (location, type_name)
6426 tree super = NULL_TREE, itf = NULL_TREE;
6427 tree id, type_decl, class;
6429 /* The unqualified name of the anonymous class. It's just a number. */
6430 sprintf (buffer, "%d", anonymous_class_counter++);
6431 id = build_wfl_node (get_identifier (buffer));
6432 EXPR_WFL_LINECOL (id) = location;
6434 /* We know about the type to extend/implement. We go ahead */
6435 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6437 /* Create a class which either implements on extends the designated
6438 class. The class bears an innacessible name. */
6439 if (CLASS_INTERFACE (type_decl))
6441 /* It's OK to modify it here. It's been already used and
6442 shouldn't be reused */
6443 ctxp->interface_number = 1;
6444 /* Interfaces should presented as a list of WFLs */
6445 itf = build_tree_list (type_name, NULL_TREE);
6451 class = create_class (ACC_FINAL, id, super, itf);
6453 /* We didn't know anything about the stuff. We register a dependence. */
6455 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6457 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6461 /* Create a class in pass1 and return its decl. Return class
6462 interface's decl in pass 2. */
6465 create_class (flags, id, super, interfaces)
6467 tree id, super, interfaces;
6469 tree raw_name = EXPR_WFL_NODE (id);
6470 tree class_id, decl;
6471 tree super_decl_type;
6473 class_id = parser_qualified_classname (0, raw_name);
6474 decl = IDENTIFIER_CLASS_VALUE (class_id);
6475 EXPR_WFL_NODE (id) = class_id;
6477 /* Basic check: scope, redefinition, modifiers */
6478 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6484 /* Suspend the current parsing context if we're parsing an inner
6485 class or an anonymous class. */
6487 java_parser_context_suspend ();
6488 /* Push a new context for (static) initialized upon declaration fields */
6489 java_parser_context_push_initialized_field ();
6491 /* Class modifier check:
6492 - Allowed modifier (already done at that point)
6493 - abstract AND final forbidden
6494 - Public classes defined in the correct file */
6495 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6497 (id, "Class `%s' can't be declared both abstract and final",
6498 IDENTIFIER_POINTER (raw_name));
6500 /* Create a new decl if DECL is NULL, otherwise fix it */
6501 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6503 /* If SUPER exists, use it, otherwise use Object */
6506 /* Can't extend java.lang.Object */
6507 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6509 parse_error_context (id, "Can't extend `java.lang.Object'");
6514 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6516 else if (TREE_TYPE (decl) != object_type_node)
6517 super_decl_type = object_type_node;
6518 /* We're defining java.lang.Object */
6520 super_decl_type = NULL_TREE;
6522 /* Set super info and mark the class a complete */
6523 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6524 ctxp->interface_number);
6525 ctxp->interface_number = 0;
6526 CLASS_COMPLETE_P (decl) = 1;
6527 add_superinterfaces (decl, interfaces);
6529 /* If the class is a top level inner class, install an alias. */
6530 if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6532 tree alias = parser_qualified_classname (1, raw_name);
6533 IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6536 /* Add the private this$<n> field, Replicate final locals still in
6537 scope as private final fields mangled like val$<local_name>.
6538 This doesn't not occur for top level (static) inner classes. */
6539 if (PURE_INNER_CLASS_DECL_P (decl))
6540 add_inner_class_fields (decl, current_function_decl);
6542 /* If doing xref, store the location at which the inherited class
6543 (if any) was seen. */
6544 if (flag_emit_xref && super)
6545 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6547 /* Eventually sets the @deprecated tag flag */
6548 CHECK_DEPRECATED (decl);
6550 /* Reset the anonymous class counter when declaring non inner classes */
6551 if (!INNER_CLASS_DECL_P (decl))
6552 anonymous_class_counter = 1;
6557 /* End a class declaration: register the statements used to create
6558 $finit$ and <clinit>, pop the current class and resume the prior
6559 parser context if necessary. */
6562 end_class_declaration (resume)
6565 /* If an error occured, context weren't pushed and won't need to be
6566 popped by a resume. */
6567 int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6569 java_parser_context_pop_initialized_field ();
6571 if (resume && no_error_occured)
6572 java_parser_context_resume ();
6574 /* We're ending a class declaration, this is a good time to reset
6575 the interface cout. Note that might have been already done in
6576 create_interface, but if at that time an inner class was being
6577 dealt with, the interface count was reset in a context created
6578 for the sake of handling inner classes declaration. */
6579 ctxp->interface_number = 0;
6583 add_inner_class_fields (class_decl, fct_decl)
6587 tree block, marker, f;
6589 f = add_field (TREE_TYPE (class_decl),
6590 build_current_thisn (TREE_TYPE (class_decl)),
6591 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
6593 FIELD_THISN (f) = 1;
6598 for (block = GET_CURRENT_BLOCK (fct_decl);
6599 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6602 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6605 tree wfl, init, list;
6607 /* Avoid non final arguments. */
6608 if (!LOCAL_FINAL (decl))
6611 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6612 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6613 wfl = build_wfl_node (get_identifier (name));
6614 init = build_wfl_node (get_identifier (pname));
6615 /* Build an initialization for the field: it will be
6616 initialized by a parameter added to $finit$, bearing a
6617 mangled name of the field itself (param$<n>.) The
6618 parameter is provided to $finit$ by the constructor
6619 invoking it (hence the constructor will also feature a
6620 hidden parameter, set to the value of the outer context
6621 local at the time the inner class is created.)
6623 Note: we take into account all possible locals that can
6624 be accessed by the inner class. It's actually not trivial
6625 to minimize these aliases down to the ones really
6626 used. One way to do that would be to expand all regular
6627 methods first, then $finit$ to get a picture of what's
6628 used. It works with the exception that we would have to
6629 go back on all constructor invoked in regular methods to
6630 have their invokation reworked (to include the right amount
6631 of alias initializer parameters.)
6633 The only real way around, I think, is a first pass to
6634 identify locals really used in the inner class. We leave
6635 the flag FIELD_LOCAL_ALIAS_USED around for that future
6638 On the other hand, it only affect local inner classes,
6639 whose constructors (and $finit$ call) will be featuring
6640 unecessary arguments. It's easy for a developper to keep
6641 this number of parameter down by using the `final'
6642 keyword only when necessary. For the time being, we can
6643 issue a warning on unecessary finals. FIXME */
6644 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
6647 /* Register the field. The TREE_LIST holding the part
6648 initialized/initializer will be marked ARG_FINAL_P so
6649 that the created field can be marked
6650 FIELD_LOCAL_ALIAS. */
6651 list = build_tree_list (wfl, init);
6652 ARG_FINAL_P (list) = 1;
6653 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6657 if (!CPC_INITIALIZER_STMT (ctxp))
6660 /* If we ever registered an alias field, insert and marker to
6661 remeber where the list ends. The second part of the list (the one
6662 featuring initialized fields) so it can be later reversed to
6663 enforce 8.5. The marker will be removed during that operation. */
6664 marker = build_tree_list (NULL_TREE, NULL_TREE);
6665 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6666 SET_CPC_INITIALIZER_STMT (ctxp, marker);
6669 /* Can't use lookup_field () since we don't want to load the class and
6670 can't set the CLASS_LOADED_P flag */
6673 find_field (class, name)
6678 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6680 if (DECL_NAME (decl) == name)
6686 /* Wrap around lookup_field that doesn't potentially upset the value
6690 lookup_field_wrapper (class, name)
6695 java_parser_context_save_global ();
6696 decl = lookup_field (&type, name);
6698 /* Last chance: if we're within the context of an inner class, we
6699 might be trying to access a local variable defined in an outer
6700 context. We try to look for it now. */
6701 if (INNER_CLASS_TYPE_P (class) && (!decl || decl == error_mark_node))
6704 MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6705 name = get_identifier (alias_buffer);
6707 decl = lookup_field (&type, name);
6708 if (decl && decl != error_mark_node)
6709 FIELD_LOCAL_ALIAS_USED (decl) = 1;
6712 java_parser_context_restore_global ();
6713 return decl == error_mark_node ? NULL : decl;
6716 /* Find duplicate field within the same class declarations and report
6717 the error. Returns 1 if a duplicated field was found, 0
6721 duplicate_declaration_error_p (new_field_name, new_type, cl)
6722 tree new_field_name, new_type, cl;
6724 /* This might be modified to work with method decl as well */
6725 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6728 char *t1 = xstrdup (purify_type_name
6729 ((TREE_CODE (new_type) == POINTER_TYPE
6730 && TREE_TYPE (new_type) == NULL_TREE) ?
6731 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6732 lang_printable_name (new_type, 1)));
6733 /* The type may not have been completed by the time we report
6735 char *t2 = xstrdup (purify_type_name
6736 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
6737 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6738 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6739 lang_printable_name (TREE_TYPE (decl), 1)));
6741 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
6742 t1, IDENTIFIER_POINTER (new_field_name),
6743 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6744 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6752 /* Field registration routine. If TYPE doesn't exist, field
6753 declarations are linked to the undefined TYPE dependency list, to
6754 be later resolved in java_complete_class () */
6757 register_fields (flags, type, variable_list)
6759 tree type, variable_list;
6761 tree current, saved_type;
6762 tree class_type = NULL_TREE;
6763 int saved_lineno = lineno;
6765 tree wfl = NULL_TREE;
6768 class_type = TREE_TYPE (GET_CPC ());
6770 if (!class_type || class_type == error_mark_node)
6773 /* If we're adding fields to interfaces, those fields are public,
6775 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6777 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6778 flags, ACC_PUBLIC, "interface field(s)");
6779 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6780 flags, ACC_STATIC, "interface field(s)");
6781 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6782 flags, ACC_FINAL, "interface field(s)");
6783 check_modifiers ("Illegal interface member modifier `%s'", flags,
6784 INTERFACE_FIELD_MODIFIERS);
6785 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6788 /* Obtain a suitable type for resolution, if necessary */
6789 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6791 /* If TYPE is fully resolved and we don't have a reference, make one */
6792 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6794 for (current = variable_list, saved_type = type; current;
6795 current = TREE_CHAIN (current), type = saved_type)
6799 tree cl = TREE_PURPOSE (current);
6800 tree init = TREE_VALUE (current);
6801 tree current_name = EXPR_WFL_NODE (cl);
6803 /* Can't declare static fields in inner classes */
6804 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6805 && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6807 (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6808 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6809 lang_printable_name (class_type, 0));
6811 /* Process NAME, as it may specify extra dimension(s) for it */
6812 type = build_array_from_name (type, wfl, current_name, ¤t_name);
6814 /* Type adjustment. We may have just readjusted TYPE because
6815 the variable specified more dimensions. Make sure we have
6816 a reference if we can and don't have one already. Also
6817 change the name if we have an init. */
6818 if (type != saved_type)
6820 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6822 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6825 real_type = GET_REAL_TYPE (type);
6826 /* Check for redeclarations */
6827 if (duplicate_declaration_error_p (current_name, real_type, cl))
6830 /* Set lineno to the line the field was found and create a
6831 declaration for it. Eventually sets the @deprecated tag flag. */
6833 lineno = EXPR_WFL_LINECOL (cl);
6835 lineno = EXPR_WFL_LINENO (cl);
6836 field_decl = add_field (class_type, current_name, real_type, flags);
6837 CHECK_DEPRECATED (field_decl);
6839 /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6840 mark the created field FIELD_LOCAL_ALIAS, so that we can
6841 hide parameters to this inner class $finit$ and constructors. */
6842 if (ARG_FINAL_P (current))
6843 FIELD_LOCAL_ALIAS (field_decl) = 1;
6845 /* Check if we must chain. */
6847 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6849 /* If we have an initialization value tied to the field */
6852 /* The field is declared static */
6853 if (flags & ACC_STATIC)
6855 /* We include the field and its initialization part into
6856 a list used to generate <clinit>. After <clinit> is
6857 walked, field initializations will be processed and
6858 fields initialized with known constants will be taken
6859 out of <clinit> and have their DECL_INITIAL set
6861 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6862 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6863 if (TREE_OPERAND (init, 1)
6864 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6865 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6867 /* A non-static field declared with an immediate initialization is
6868 to be initialized in <init>, if any. This field is remembered
6869 to be processed at the time of the generation of <init>. */
6872 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6873 SET_CPC_INITIALIZER_STMT (ctxp, init);
6875 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6876 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6879 lineno = saved_lineno;
6882 /* Generate $finit$, using the list of initialized fields to populate
6883 its body. $finit$'s parameter(s) list is adjusted to include the
6884 one(s) used to initialized the field(s) caching outer context
6888 generate_finit (class_type)
6892 tree list = TYPE_FINIT_STMT_LIST (class_type);
6893 tree mdecl, current, parms;
6895 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
6896 class_type, NULL_TREE,
6898 CRAFTED_PARAM_LIST_FIXUP (parms);
6899 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6900 finit_identifier_node, parms);
6901 fix_method_argument_names (parms, mdecl);
6902 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6904 DECL_FUNCTION_NAP (mdecl) = count;
6905 start_artificial_method_body (mdecl);
6907 for (current = list; current; current = TREE_CHAIN (current))
6908 java_method_add_stmt (mdecl,
6909 build_debugable_stmt (EXPR_WFL_LINECOL (current),
6911 end_artificial_method_body (mdecl);
6916 add_instance_initializer (mdecl)
6920 tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6921 tree compound = NULL_TREE;
6925 for (current = stmt_list; current; current = TREE_CHAIN (current))
6926 compound = add_stmt_to_compound (compound, NULL_TREE, current);
6928 java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6929 NULL_TREE, compound));
6933 /* Shared accros method_declarator and method_header to remember the
6934 patch stage that was reached during the declaration of the method.
6935 A method DECL is built differently is there is no patch
6936 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6937 pending on the currently defined method. */
6939 static int patch_stage;
6941 /* Check the method declaration and add the method to its current
6942 class. If the argument list is known to contain incomplete types,
6943 the method is partially added and the registration will be resume
6944 once the method arguments resolved. If TYPE is NULL, we're dealing
6945 with a constructor. */
6948 method_header (flags, type, mdecl, throws)
6950 tree type, mdecl, throws;
6952 tree meth = TREE_VALUE (mdecl);
6953 tree id = TREE_PURPOSE (mdecl);
6954 tree type_wfl = NULL_TREE;
6955 tree meth_name = NULL_TREE;
6956 tree current, orig_arg, this_class = NULL;
6958 int constructor_ok = 0, must_chain;
6961 check_modifiers_consistency (flags);
6964 this_class = TREE_TYPE (GET_CPC ());
6966 if (!this_class || this_class == error_mark_node)
6969 /* There are some forbidden modifiers for an abstract method and its
6970 class must be abstract as well. */
6971 if (type && (flags & ACC_ABSTRACT))
6973 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6974 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6975 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6976 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6977 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6978 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6979 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6981 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
6982 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6983 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6986 /* Things to be checked when declaring a constructor */
6989 int ec = java_error_count;
6990 /* 8.6: Constructor declarations: we might be trying to define a
6991 method without specifying a return type. */
6992 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6994 (id, "Invalid method declaration, return type required");
6995 /* 8.6.3: Constructor modifiers */
6998 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6999 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
7000 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
7001 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
7002 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
7004 /* If we found error here, we don't consider it's OK to tread
7005 the method definition as a constructor, for the rest of this
7007 if (ec == java_error_count)
7011 /* Method declared within the scope of an interface are implicitly
7012 abstract and public. Conflicts with other erroneously provided
7013 modifiers are checked right after. */
7015 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7017 /* If FLAGS isn't set because of a modifier, turn the
7018 corresponding modifier WFL to NULL so we issue a warning on
7019 the obsolete use of the modifier */
7020 if (!(flags & ACC_PUBLIC))
7021 MODIFIER_WFL (PUBLIC_TK) = NULL;
7022 if (!(flags & ACC_ABSTRACT))
7023 MODIFIER_WFL (ABSTRACT_TK) = NULL;
7024 flags |= ACC_PUBLIC;
7025 flags |= ACC_ABSTRACT;
7028 /* Inner class can't declare static methods */
7029 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7032 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7033 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7034 lang_printable_name (this_class, 0));
7037 /* Modifiers context reset moved up, so abstract method declaration
7038 modifiers can be later checked. */
7040 /* Set constructor returned type to void and method name to <init>,
7041 unless we found an error identifier the constructor (in which
7042 case we retain the original name) */
7045 type = void_type_node;
7047 meth_name = init_identifier_node;
7050 meth_name = EXPR_WFL_NODE (id);
7052 /* Do the returned type resolution and registration if necessary */
7053 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7056 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7057 EXPR_WFL_NODE (id) = meth_name;
7058 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7062 patch_stage = JDEP_METHOD_RETURN;
7063 register_incomplete_type (patch_stage, type_wfl, id, type);
7064 TREE_TYPE (meth) = GET_REAL_TYPE (type);
7067 TREE_TYPE (meth) = type;
7069 saved_lineno = lineno;
7070 /* When defining an abstract or interface method, the curly
7071 bracket at level 1 doesn't exist because there is no function
7073 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
7074 EXPR_WFL_LINENO (id));
7076 /* Remember the original argument list */
7077 orig_arg = TYPE_ARG_TYPES (meth);
7079 if (patch_stage) /* includes ret type and/or all args */
7082 meth = add_method_1 (this_class, flags, meth_name, meth);
7083 /* Patch for the return type */
7084 if (patch_stage == JDEP_METHOD_RETURN)
7086 jdep = CLASSD_LAST (ctxp->classd_list);
7087 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7089 /* This is the stop JDEP. METH allows the function's signature
7091 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7094 meth = add_method (this_class, flags, meth_name,
7095 build_java_signature (meth));
7097 /* Remember final parameters */
7098 MARK_FINAL_PARMS (meth, orig_arg);
7100 /* Fix the method argument list so we have the argument name
7102 fix_method_argument_names (orig_arg, meth);
7104 /* Register the parameter number and re-install the current line
7106 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7107 lineno = saved_lineno;
7109 /* Register exception specified by the `throws' keyword for
7110 resolution and set the method decl appropriate field to the list.
7111 Note: the grammar ensures that what we get here are class
7115 throws = nreverse (throws);
7116 for (current = throws; current; current = TREE_CHAIN (current))
7118 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7119 NULL_TREE, NULL_TREE);
7120 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7121 &TREE_VALUE (current);
7123 DECL_FUNCTION_THROWS (meth) = throws;
7126 /* We set the DECL_NAME to ID so we can track the location where
7127 the function was declared. This allow us to report
7128 redefinition error accurately. When method are verified,
7129 DECL_NAME is reinstalled properly (using the content of the
7130 WFL node ID) (see check_method_redefinition). We don't do that
7131 when Object is being defined. Constructor <init> names will be
7132 reinstalled the same way. */
7133 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7134 DECL_NAME (meth) = id;
7136 /* Set the flag if we correctly processed a constructor */
7139 DECL_CONSTRUCTOR_P (meth) = 1;
7140 /* Compute and store the number of artificial parameters declared
7141 for this constructor */
7142 for (count = 0, current = TYPE_FIELDS (this_class); current;
7143 current = TREE_CHAIN (current))
7144 if (FIELD_LOCAL_ALIAS (current))
7146 DECL_FUNCTION_NAP (meth) = count;
7149 /* Eventually set the @deprecated tag flag */
7150 CHECK_DEPRECATED (meth);
7152 /* If doing xref, store column and line number information instead
7153 of the line number only. */
7155 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7161 fix_method_argument_names (orig_arg, meth)
7162 tree orig_arg, meth;
7164 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7165 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7167 TREE_PURPOSE (arg) = this_identifier_node;
7168 arg = TREE_CHAIN (arg);
7170 while (orig_arg != end_params_node)
7172 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7173 orig_arg = TREE_CHAIN (orig_arg);
7174 arg = TREE_CHAIN (arg);
7178 /* Complete the method declaration with METHOD_BODY. */
7181 finish_method_declaration (method_body)
7186 if (!current_function_decl)
7189 flags = get_access_flags_from_decl (current_function_decl);
7191 /* 8.4.5 Method Body */
7192 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7194 tree wfl = DECL_NAME (current_function_decl);
7195 parse_error_context (wfl,
7196 "%s method `%s' can't have a body defined",
7197 (METHOD_NATIVE (current_function_decl) ?
7198 "Native" : "Abstract"),
7199 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7200 method_body = NULL_TREE;
7202 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7204 tree wfl = DECL_NAME (current_function_decl);
7207 "Non native and non abstract method `%s' must have a body defined",
7208 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7209 method_body = NULL_TREE;
7212 if (flag_emit_class_files && method_body
7213 && TREE_CODE (method_body) == NOP_EXPR
7214 && TREE_TYPE (current_function_decl)
7215 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7216 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7218 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7219 maybe_absorb_scoping_blocks ();
7220 /* Exit function's body */
7222 /* Merge last line of the function with first line, directly in the
7223 function decl. It will be used to emit correct debug info. */
7224 if (!flag_emit_xref)
7225 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7227 /* Since function's argument's list are shared, reset the
7228 ARG_FINAL_P parameter that might have been set on some of this
7229 function parameters. */
7230 UNMARK_FINAL_PARMS (current_function_decl);
7232 /* So we don't have an irrelevant function declaration context for
7233 the next static block we'll see. */
7234 current_function_decl = NULL_TREE;
7237 /* Build a an error message for constructor circularity errors. */
7240 constructor_circularity_msg (from, to)
7243 static char string [4096];
7244 char *t = xstrdup (lang_printable_name (from, 0));
7245 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7250 /* Verify a circular call to METH. Return 1 if an error is found, 0
7254 verify_constructor_circularity (meth, current)
7257 static tree list = NULL_TREE;
7259 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7261 if (TREE_VALUE (c) == meth)
7267 list = nreverse (list);
7268 for (liste = list; liste; liste = TREE_CHAIN (liste))
7271 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7272 constructor_circularity_msg
7273 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7277 t = xstrdup (lang_printable_name (meth, 0));
7278 parse_error_context (TREE_PURPOSE (c),
7279 "%s: recursive invocation of constructor `%s'",
7280 constructor_circularity_msg (current, meth), t);
7286 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7288 list = tree_cons (c, current, list);
7289 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7291 list = TREE_CHAIN (list);
7296 /* Check modifiers that can be declared but exclusively */
7299 check_modifiers_consistency (flags)
7303 tree cl = NULL_TREE;
7305 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7306 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7307 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7310 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7314 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7316 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7319 parse_error_context (cl,
7320 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7323 /* Check the methode header METH for abstract specifics features */
7326 check_abstract_method_header (meth)
7329 int flags = get_access_flags_from_decl (meth);
7330 /* DECL_NAME might still be a WFL node */
7331 tree name = GET_METHOD_NAME (meth);
7333 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7334 ACC_ABSTRACT, "abstract method",
7335 IDENTIFIER_POINTER (name));
7336 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7337 ACC_PUBLIC, "abstract method",
7338 IDENTIFIER_POINTER (name));
7340 check_modifiers ("Illegal modifier `%s' for interface method",
7341 flags, INTERFACE_METHOD_MODIFIERS);
7344 /* Create a FUNCTION_TYPE node and start augmenting it with the
7345 declared function arguments. Arguments type that can't be resolved
7346 are left as they are, but the returned node is marked as containing
7347 incomplete types. */
7350 method_declarator (id, list)
7353 tree arg_types = NULL_TREE, current, node;
7354 tree meth = make_node (FUNCTION_TYPE);
7357 patch_stage = JDEP_NO_PATCH;
7359 /* If we're dealing with an inner class constructor, we hide the
7360 this$<n> decl in the name field of its parameter declaration. We
7361 also might have to hide the outer context local alias
7362 initializers. Not done when the class is a toplevel class. */
7363 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7364 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7366 tree aliases_list, type, thisn;
7367 /* First the aliases, linked to the regular parameters */
7369 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7370 TREE_TYPE (GET_CPC ()),
7372 list = chainon (nreverse (aliases_list), list);
7375 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7376 thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7377 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7381 for (current = list; current; current = TREE_CHAIN (current))
7384 tree wfl_name = TREE_PURPOSE (current);
7385 tree type = TREE_VALUE (current);
7386 tree name = EXPR_WFL_NODE (wfl_name);
7387 tree already, arg_node;
7388 tree type_wfl = NULL_TREE;
7391 /* Obtain a suitable type for resolution, if necessary */
7392 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7394 /* Process NAME, as it may specify extra dimension(s) for it */
7395 type = build_array_from_name (type, type_wfl, name, &name);
7396 EXPR_WFL_NODE (wfl_name) = name;
7398 real_type = GET_REAL_TYPE (type);
7399 if (TREE_CODE (real_type) == RECORD_TYPE)
7401 real_type = promote_type (real_type);
7402 if (TREE_CODE (type) == TREE_LIST)
7403 TREE_PURPOSE (type) = real_type;
7406 /* Check redefinition */
7407 for (already = arg_types; already; already = TREE_CHAIN (already))
7408 if (TREE_PURPOSE (already) == name)
7411 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7412 IDENTIFIER_POINTER (name),
7413 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7417 /* If we've an incomplete argument type, we know there is a location
7418 to patch when the type get resolved, later. */
7422 patch_stage = JDEP_METHOD;
7423 type = register_incomplete_type (patch_stage,
7424 type_wfl, wfl_name, type);
7425 jdep = CLASSD_LAST (ctxp->classd_list);
7426 JDEP_MISC (jdep) = id;
7429 /* The argument node: a name and a (possibly) incomplete type. */
7430 arg_node = build_tree_list (name, real_type);
7431 /* Remeber arguments declared final. */
7432 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7435 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7436 TREE_CHAIN (arg_node) = arg_types;
7437 arg_types = arg_node;
7439 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7440 node = build_tree_list (id, meth);
7445 unresolved_type_p (wfl, returned)
7450 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7454 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7455 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7456 *returned = TREE_TYPE (decl);
7457 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7458 *returned = TREE_TYPE (GET_CPC ());
7460 *returned = NULL_TREE;
7469 /* From NAME, build a qualified identifier node using the
7470 qualification from the current package definition. */
7473 parser_qualified_classname (is_static, name)
7477 tree nested_class_name;
7480 && (nested_class_name = maybe_make_nested_class_name (name)))
7481 return nested_class_name;
7484 return merge_qualified_name (ctxp->package, name);
7489 /* Called once the type a interface extends is resolved. Returns 0 if
7490 everything is OK. */
7493 parser_check_super_interface (super_decl, this_decl, this_wfl)
7494 tree super_decl, this_decl, this_wfl;
7496 tree super_type = TREE_TYPE (super_decl);
7498 /* Has to be an interface */
7499 if (!CLASS_INTERFACE (super_decl))
7502 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7503 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7504 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7505 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7506 "interface" : "class"),
7507 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7511 /* Check scope: same package OK, other package: OK if public */
7512 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7515 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7516 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7517 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7521 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7522 0 if everthing is OK. */
7525 parser_check_super (super_decl, this_decl, wfl)
7526 tree super_decl, this_decl, wfl;
7528 tree super_type = TREE_TYPE (super_decl);
7530 /* SUPER should be a CLASS (neither an array nor an interface) */
7531 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7534 (wfl, "Class `%s' can't subclass %s `%s'",
7535 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7536 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7537 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7541 if (CLASS_FINAL (TYPE_NAME (super_type)))
7543 parse_error_context (wfl, "Can't subclass final classes: %s",
7544 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7548 /* Check scope: same package OK, other package: OK if public */
7549 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7552 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7553 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7554 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7558 /* Create a new dependency list and link it (in a LIFO manner) to the
7559 CTXP list of type dependency list. */
7562 create_jdep_list (ctxp)
7563 struct parser_ctxt *ctxp;
7565 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
7566 new->first = new->last = NULL;
7567 new->next = ctxp->classd_list;
7568 ctxp->classd_list = new;
7572 reverse_jdep_list (ctxp)
7573 struct parser_ctxt *ctxp;
7575 register jdeplist *prev = NULL, *current, *next;
7576 for (current = ctxp->classd_list; current; current = next)
7578 next = current->next;
7579 current->next = prev;
7585 /* Create a fake pointer based on the ID stored in
7586 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7587 registered again. */
7590 obtain_incomplete_type (type_name)
7595 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7596 name = EXPR_WFL_NODE (type_name);
7597 else if (INCOMPLETE_TYPE_P (type_name))
7598 name = TYPE_NAME (type_name);
7600 fatal ("invalid type name - obtain_incomplete_type");
7602 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7603 if (TYPE_NAME (ptr) == name)
7608 push_obstacks (&permanent_obstack, &permanent_obstack);
7609 BUILD_PTR_FROM_NAME (ptr, name);
7612 TREE_CHAIN (ptr) = ctxp->incomplete_class;
7613 ctxp->incomplete_class = ptr;
7619 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7620 non NULL instead of computing a new fake type based on WFL. The new
7621 dependency is inserted in the current type dependency list, in FIFO
7625 register_incomplete_type (kind, wfl, decl, ptr)
7627 tree wfl, decl, ptr;
7629 jdep *new = (jdep *)xmalloc (sizeof (jdep));
7631 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7632 ptr = obtain_incomplete_type (wfl);
7634 JDEP_KIND (new) = kind;
7635 JDEP_DECL (new) = decl;
7636 JDEP_SOLV (new) = ptr;
7637 JDEP_WFL (new) = wfl;
7638 JDEP_CHAIN (new) = NULL;
7639 JDEP_MISC (new) = NULL_TREE;
7640 /* For some dependencies, set the enclosing class of the current
7641 class to be the enclosing context */
7642 if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS)
7643 && GET_ENCLOSING_CPC ())
7644 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7646 JDEP_ENCLOSING (new) = GET_CPC ();
7647 JDEP_GET_PATCH (new) = (tree *)NULL;
7649 JDEP_INSERT (ctxp->classd_list, new);
7655 java_check_circular_reference ()
7658 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7660 tree type = TREE_TYPE (current);
7661 if (CLASS_INTERFACE (current))
7663 /* Check all interfaces this class extends */
7664 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7669 n = TREE_VEC_LENGTH (basetype_vec);
7670 for (i = 0; i < n; i++)
7672 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7673 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
7674 && interface_of_p (type, BINFO_TYPE (vec_elt)))
7675 parse_error_context (lookup_cl (current),
7676 "Cyclic interface inheritance");
7680 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7681 parse_error_context (lookup_cl (current),
7682 "Cyclic class inheritance%s",
7683 (cyclic_inheritance_report ?
7684 cyclic_inheritance_report : ""));
7688 /* Augment the parameter list PARM with parameters crafted to
7689 initialize outer context locals aliases. Through ARTIFICIAL, a
7690 count is kept of the number of crafted parameters. MODE governs
7691 what eventually gets created: something suitable for a function
7692 creation or a function invocation, either the constructor or
7696 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7698 tree class_type, parm;
7702 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7703 if (FIELD_LOCAL_ALIAS (field))
7705 char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7706 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7710 case AIPL_FUNCTION_DECLARATION:
7711 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7712 purpose = build_wfl_node (get_identifier (buffer));
7713 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7714 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7716 value = TREE_TYPE (field);
7719 case AIPL_FUNCTION_CREATION:
7720 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7721 purpose = get_identifier (buffer);
7722 value = TREE_TYPE (field);
7725 case AIPL_FUNCTION_FINIT_INVOCATION:
7726 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7727 /* Now, this is wrong. purpose should always be the NAME
7728 of something and value its matching value (decl, type,
7729 etc...) FIXME -- but there is a lot to fix. */
7731 /* When invoked for this kind of operation, we already
7732 know whether a field is used or not. */
7733 purpose = TREE_TYPE (field);
7734 value = build_wfl_node (get_identifier (buffer));
7737 case AIPL_FUNCTION_CTOR_INVOCATION:
7738 /* There are two case: the constructor invokation happends
7739 outside the local inner, in which case, locales from the outer
7740 context are directly used.
7742 Otherwise, we fold to using the alias directly. */
7743 if (class_type == current_class)
7747 name = get_identifier (&buffer[4]);
7748 value = IDENTIFIER_LOCAL_VALUE (name);
7752 parm = tree_cons (purpose, value, parm);
7759 /* Craft a constructor for CLASS_DECL -- what we should do when none
7760 where found. ARGS is non NULL when a special signature must be
7761 enforced. This is the case for anonymous classes. */
7764 craft_constructor (class_decl, args)
7765 tree class_decl, args;
7767 tree class_type = TREE_TYPE (class_decl);
7768 tree parm = NULL_TREE;
7769 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7771 int i = 0, artificial = 0;
7772 tree decl, ctor_name;
7775 push_obstacks (&permanent_obstack, &permanent_obstack);
7777 /* The constructor name is <init> unless we're dealing with an
7778 anonymous class, in which case the name will be fixed after having
7780 if (ANONYMOUS_CLASS_P (class_type))
7781 ctor_name = DECL_NAME (class_decl);
7783 ctor_name = init_identifier_node;
7785 /* If we're dealing with an inner class constructor, we hide the
7786 this$<n> decl in the name field of its parameter declaration. */
7787 if (PURE_INNER_CLASS_TYPE_P (class_type))
7789 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7790 parm = tree_cons (build_current_thisn (class_type),
7791 build_pointer_type (type), parm);
7793 /* Some more arguments to be hidden here. The values of the local
7794 variables of the outer context that the inner class needs to see. */
7795 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7800 /* Then if there are any args to be enforced, enforce them now */
7801 for (; args && args != end_params_node; args = TREE_CHAIN (args))
7803 sprintf (buffer, "parm%d", i++);
7804 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7807 CRAFTED_PARAM_LIST_FIXUP (parm);
7808 decl = create_artificial_method (class_type, flags, void_type_node,
7810 fix_method_argument_names (parm, decl);
7811 /* Now, mark the artificial parameters. */
7812 DECL_FUNCTION_NAP (decl) = artificial;
7815 DECL_CONSTRUCTOR_P (decl) = 1;
7819 /* Fix the constructors. This will be called right after circular
7820 references have been checked. It is necessary to fix constructors
7821 early even if no code generation will take place for that class:
7822 some generated constructor might be required by the class whose
7823 compilation triggered this one to be simply loaded. */
7826 java_fix_constructors ()
7830 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7832 tree class_type = TREE_TYPE (current);
7836 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7839 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7841 if (DECL_CONSTRUCTOR_P (decl))
7843 fix_constructors (decl);
7848 /* Anonymous class constructor can't be generated that early. */
7849 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7850 craft_constructor (current, NULL_TREE);
7854 /* safe_layout_class just makes sure that we can load a class without
7855 disrupting the current_class, input_file, lineno, etc, information
7856 about the class processed currently. */
7859 safe_layout_class (class)
7862 tree save_current_class = current_class;
7863 const char *save_input_filename = input_filename;
7864 int save_lineno = lineno;
7866 push_obstacks (&permanent_obstack, &permanent_obstack);
7868 layout_class (class);
7871 current_class = save_current_class;
7872 input_filename = save_input_filename;
7873 lineno = save_lineno;
7874 CLASS_LOADED_P (class) = 1;
7878 jdep_resolve_class (dep)
7883 if (JDEP_RESOLVED_P (dep))
7884 decl = JDEP_RESOLVED_DECL (dep);
7887 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7888 JDEP_DECL (dep), JDEP_WFL (dep));
7889 JDEP_RESOLVED (dep, decl);
7893 complete_class_report_errors (dep);
7898 /* Complete unsatisfied class declaration and their dependencies */
7901 java_complete_class ()
7908 push_obstacks (&permanent_obstack, &permanent_obstack);
7910 /* Process imports and reverse the import on demand list */
7912 if (ctxp->import_demand_list)
7913 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7915 /* Rever things so we have the right order */
7916 ctxp->class_list = nreverse (ctxp->class_list);
7917 ctxp->classd_list = reverse_jdep_list (ctxp);
7919 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
7921 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7924 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7927 if (!(decl = jdep_resolve_class (dep)))
7930 /* Now it's time to patch */
7931 switch (JDEP_KIND (dep))
7934 /* Simply patch super */
7935 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7937 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
7938 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7943 /* We do part of the job done in add_field */
7944 tree field_decl = JDEP_DECL (dep);
7945 tree field_type = TREE_TYPE (decl);
7946 push_obstacks (&permanent_obstack, &permanent_obstack);
7947 if (TREE_CODE (field_type) == RECORD_TYPE)
7948 field_type = promote_type (field_type);
7950 TREE_TYPE (field_decl) = field_type;
7951 DECL_ALIGN (field_decl) = 0;
7952 layout_decl (field_decl, 0);
7953 SOURCE_FRONTEND_DEBUG
7954 (("Completed field/var decl `%s' with `%s'",
7955 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7956 IDENTIFIER_POINTER (DECL_NAME (decl))));
7959 case JDEP_METHOD: /* We start patching a method */
7960 case JDEP_METHOD_RETURN:
7966 type = TREE_TYPE(decl);
7967 if (TREE_CODE (type) == RECORD_TYPE)
7968 type = promote_type (type);
7969 JDEP_APPLY_PATCH (dep, type);
7970 SOURCE_FRONTEND_DEBUG
7971 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7972 "Completing fct `%s' with ret type `%s'":
7973 "Completing arg `%s' with type `%s'"),
7974 IDENTIFIER_POINTER (EXPR_WFL_NODE
7975 (JDEP_DECL_WFL (dep))),
7976 IDENTIFIER_POINTER (DECL_NAME (decl))));
7980 dep = JDEP_CHAIN (dep);
7981 if (JDEP_KIND (dep) == JDEP_METHOD_END)
7984 decl = jdep_resolve_class (dep);
7988 tree mdecl = JDEP_DECL (dep), signature;
7989 push_obstacks (&permanent_obstack, &permanent_obstack);
7990 /* Recompute and reset the signature, check first that
7991 all types are now defined. If they're not,
7992 dont build the signature. */
7993 if (check_method_types_complete (mdecl))
7995 signature = build_java_signature (TREE_TYPE (mdecl));
7996 set_java_signature (TREE_TYPE (mdecl), signature);
8004 case JDEP_INTERFACE:
8005 if (parser_check_super_interface (decl, JDEP_DECL (dep),
8008 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8013 type = TREE_TYPE(decl);
8014 if (TREE_CODE (type) == RECORD_TYPE)
8015 type = promote_type (type);
8016 JDEP_APPLY_PATCH (dep, type);
8020 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8021 SOURCE_FRONTEND_DEBUG
8022 (("Completing a random type dependency on a '%s' node",
8023 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8026 case JDEP_EXCEPTION:
8027 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8028 SOURCE_FRONTEND_DEBUG
8029 (("Completing `%s' `throws' argument node",
8030 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8033 case JDEP_ANONYMOUS:
8034 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8038 fatal ("Can't handle patch code %d - java_complete_class",
8047 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8051 resolve_class (enclosing, class_type, decl, cl)
8052 tree enclosing, class_type, decl, cl;
8054 const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8055 const char *base = name;
8056 tree resolved_type = TREE_TYPE (class_type);
8057 tree resolved_type_decl;
8059 if (resolved_type != NULL_TREE)
8061 tree resolved_type_decl = TYPE_NAME (resolved_type);
8062 if (resolved_type_decl == NULL_TREE
8063 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8065 resolved_type_decl = build_decl (TYPE_DECL,
8066 TYPE_NAME (class_type),
8069 return resolved_type_decl;
8072 /* 1- Check to see if we have an array. If true, find what we really
8074 while (name[0] == '[')
8077 TYPE_NAME (class_type) = get_identifier (name);
8079 /* 2- Resolve the bare type */
8080 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
8083 resolved_type = TREE_TYPE (resolved_type_decl);
8085 /* 3- If we have and array, reconstruct the array down to its nesting */
8088 while (base != name)
8090 if (TREE_CODE (resolved_type) == RECORD_TYPE)
8091 resolved_type = promote_type (resolved_type);
8092 resolved_type = build_java_array_type (resolved_type, -1);
8093 CLASS_LOADED_P (resolved_type) = 1;
8096 /* Build a fake decl for this, since this is what is expected to
8098 resolved_type_decl =
8099 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8100 /* Figure how those two things are important for error report. FIXME */
8101 DECL_SOURCE_LINE (resolved_type_decl) = 0;
8102 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8103 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8105 TREE_TYPE (class_type) = resolved_type;
8106 return resolved_type_decl;
8109 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8110 are used to report error messages. */
8113 do_resolve_class (enclosing, class_type, decl, cl)
8114 tree enclosing, class_type, decl, cl;
8116 tree new_class_decl;
8117 tree original_name = NULL_TREE;
8119 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8120 its is changed by find_in_imports{_on_demand} */
8122 /* 0- Search in the current class as an inner class */
8124 /* Maybe some code here should be added to load the class or
8125 something, at least if the class isn't an inner class and ended
8126 being loaded from class file. FIXME. */
8131 if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8132 return new_class_decl;
8134 /* Now go to the upper classes, bail out if necessary. */
8135 enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8136 if (!enclosing || enclosing == object_type_node)
8139 if (TREE_CODE (enclosing) == RECORD_TYPE)
8141 enclosing = TYPE_NAME (enclosing);
8145 if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8147 BUILD_PTR_FROM_NAME (name, enclosing);
8151 enclosing = do_resolve_class (NULL, name, NULL, NULL);
8154 /* 1- Check for the type in single imports */
8155 if (find_in_imports (class_type))
8158 /* 2- And check for the type in the current compilation unit. If it fails,
8159 try with a name qualified with the package name we've seen so far */
8160 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8162 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8163 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8164 load_class (TYPE_NAME (class_type), 0);
8165 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8168 original_name = TYPE_NAME (class_type);
8169 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8172 for (package = package_list; package; package = TREE_CHAIN (package))
8176 new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8178 TYPE_NAME (class_type) = new_qualified;
8179 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8180 if (!new_class_decl)
8181 load_class (TYPE_NAME (class_type), 0);
8182 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8185 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8186 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8187 load_class (TYPE_NAME (class_type), 0);
8188 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8193 TYPE_NAME (class_type) = original_name;
8195 /* 3- Check an other compilation unit that bears the name of type */
8196 load_class (TYPE_NAME (class_type), 0);
8197 if (check_pkg_class_access (TYPE_NAME (class_type),
8198 (cl ? cl : lookup_cl (decl))))
8201 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8202 return new_class_decl;
8204 /* 4- Check the import on demands. Don't allow bar.baz to be
8205 imported from foo.* */
8206 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8207 if (find_in_imports_on_demand (class_type))
8210 /* 5- Last call for a resolution */
8211 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8214 /* Resolve NAME and lay it out (if not done and if not the current
8215 parsed class). Return a decl node. This function is meant to be
8216 called when type resolution is necessary during the walk pass. */
8219 resolve_and_layout (something, cl)
8225 /* Don't do that on the current class */
8226 if (something == current_class)
8227 return TYPE_NAME (current_class);
8229 /* Don't do anything for void and other primitive types */
8230 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8233 /* Pointer types can be reall pointer types or fake pointers. When
8234 finding a real pointer, recheck for primitive types */
8235 if (TREE_CODE (something) == POINTER_TYPE)
8237 if (TREE_TYPE (something))
8239 something = TREE_TYPE (something);
8240 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8244 something = TYPE_NAME (something);
8247 /* Don't do anything for arrays of primitive types */
8248 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8249 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8252 /* Something might be a WFL */
8253 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8254 something = EXPR_WFL_NODE (something);
8256 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8257 TYPE_DECL or a real TYPE */
8258 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8259 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8260 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8262 if (!(decl = resolve_no_layout (something, cl)))
8265 /* Resolve and layout if necessary */
8266 layout_class_methods (TREE_TYPE (decl));
8267 /* Check methods, but only once */
8268 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
8269 && !CLASS_LOADED_P (TREE_TYPE (decl)))
8270 CHECK_METHODS (decl);
8271 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8272 safe_layout_class (TREE_TYPE (decl));
8277 /* Resolve a class, returns its decl but doesn't perform any
8278 layout. The current parsing context is saved and restored */
8281 resolve_no_layout (name, cl)
8285 BUILD_PTR_FROM_NAME (ptr, name);
8286 java_parser_context_save_global ();
8287 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8288 java_parser_context_restore_global ();
8293 /* Called when reporting errors. Skip leader '[' in a complex array
8294 type description that failed to be resolved. */
8297 purify_type_name (name)
8300 while (*name && *name == '[')
8305 /* The type CURRENT refers to can't be found. We print error messages. */
8308 complete_class_report_errors (dep)
8313 if (!JDEP_WFL (dep))
8316 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8317 switch (JDEP_KIND (dep))
8321 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8322 purify_type_name (name),
8323 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8327 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8328 purify_type_name (name),
8329 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8331 case JDEP_METHOD: /* Covers arguments */
8333 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8334 purify_type_name (name),
8335 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8336 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8338 case JDEP_METHOD_RETURN: /* Covers return type */
8340 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8341 purify_type_name (name),
8342 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8344 case JDEP_INTERFACE:
8346 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8347 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8348 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8349 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8353 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8354 purify_type_name (IDENTIFIER_POINTER
8355 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8356 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8358 case JDEP_EXCEPTION: /* As specified by `throws' */
8360 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8361 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8364 /* Fix for -Wall. Just break doing nothing. The error will be
8370 /* Return a static string containing the DECL prototype string. If
8371 DECL is a constructor, use the class name instead of the form
8375 get_printable_method_name (decl)
8378 const char *to_return;
8379 tree name = NULL_TREE;
8381 if (DECL_CONSTRUCTOR_P (decl))
8383 name = DECL_NAME (decl);
8384 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8387 to_return = lang_printable_name (decl, 0);
8388 if (DECL_CONSTRUCTOR_P (decl))
8389 DECL_NAME (decl) = name;
8394 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8395 nevertheless needs to be verfied, 1 otherwise. */
8398 reset_method_name (method)
8401 if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8403 /* NAME is just the plain name when Object is being defined */
8404 if (DECL_CONTEXT (method) != object_type_node)
8405 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
8406 init_identifier_node : GET_METHOD_NAME (method));
8413 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8416 java_get_real_method_name (method_decl)
8419 tree method_name = DECL_NAME (method_decl);
8420 if (DECL_CONSTRUCTOR_P (method_decl))
8421 return init_identifier_node;
8423 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8424 and still can be a constructor. FIXME */
8426 /* Don't confuse method only bearing the name of their class as
8428 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8430 && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8431 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8432 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8433 return init_identifier_node;
8435 return EXPR_WFL_NODE (method_name);
8438 /* Track method being redefined inside the same class. As a side
8439 effect, set DECL_NAME to an IDENTIFIER (prior entering this
8440 function it's a FWL, so we can track errors more accurately.) */
8443 check_method_redefinition (class, method)
8447 tree cl = DECL_NAME (method);
8448 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8449 /* decl name of artificial <clinit> and $finit$ doesn't need to be
8450 fixed and checked */
8452 /* Reset the method name before running the check. If it returns 1,
8453 the method doesn't need to be verified with respect to method
8454 redeclaration and we return 0 */
8455 if (reset_method_name (method))
8458 name = DECL_NAME (method);
8459 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8461 if (redef == method)
8463 if (DECL_NAME (redef) == name
8464 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8467 (cl, "Duplicate %s declaration `%s'",
8468 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8469 get_printable_method_name (redef));
8477 check_abstract_method_definitions (do_interface, class_decl, type)
8479 tree class_decl, type;
8481 tree class = TREE_TYPE (class_decl);
8482 tree method, end_type;
8484 end_type = (do_interface ? object_type_node : type);
8485 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8487 tree other_super, other_method, method_sig, method_name;
8489 int end_type_reached = 0;
8491 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8494 /* Now verify that somewhere in between TYPE and CLASS,
8495 abstract method METHOD gets a non abstract definition
8496 that is inherited by CLASS. */
8498 method_sig = build_java_signature (TREE_TYPE (method));
8499 method_name = DECL_NAME (method);
8500 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8501 method_name = EXPR_WFL_NODE (method_name);
8503 other_super = class;
8505 if (other_super == end_type)
8506 end_type_reached = 1;
8509 for (other_method = TYPE_METHODS (other_super); other_method;
8510 other_method = TREE_CHAIN (other_method))
8512 tree s = build_java_signature (TREE_TYPE (other_method));
8513 tree other_name = DECL_NAME (other_method);
8515 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8516 other_name = EXPR_WFL_NODE (other_name);
8517 if (!DECL_CLINIT_P (other_method)
8518 && !DECL_CONSTRUCTOR_P (other_method)
8519 && method_name == other_name && method_sig == s)
8525 other_super = CLASSTYPE_SUPER (other_super);
8526 } while (!end_type_reached);
8528 /* Report that abstract METHOD didn't find an implementation
8529 that CLASS can use. */
8532 char *t = xstrdup (lang_printable_name
8533 (TREE_TYPE (TREE_TYPE (method)), 0));
8534 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8535 tree saved_wfl = NULL_TREE;
8537 if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8539 saved_wfl = DECL_NAME (method);
8540 DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8544 (lookup_cl (class_decl),
8545 "Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
8546 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8547 t, lang_printable_name (method, 0),
8548 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
8549 "interface" : "class"),
8550 IDENTIFIER_POINTER (ccn),
8551 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8552 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8557 DECL_NAME (method) = saved_wfl;
8562 /* Check that CLASS_DECL somehow implements all inherited abstract
8566 java_check_abstract_method_definitions (class_decl)
8569 tree class = TREE_TYPE (class_decl);
8573 if (CLASS_ABSTRACT (class_decl))
8576 /* Check for inherited types */
8579 super = CLASSTYPE_SUPER (super);
8580 check_abstract_method_definitions (0, class_decl, super);
8581 } while (super != object_type_node);
8583 /* Check for implemented interfaces. */
8584 vector = TYPE_BINFO_BASETYPES (class);
8585 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8587 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8588 check_abstract_method_definitions (1, class_decl, super);
8592 /* Check all the types method DECL uses and return 1 if all of them
8593 are now complete, 0 otherwise. This is used to check whether its
8594 safe to build a method signature or not. */
8597 check_method_types_complete (decl)
8600 tree type = TREE_TYPE (decl);
8603 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8606 args = TYPE_ARG_TYPES (type);
8607 if (TREE_CODE (type) == METHOD_TYPE)
8608 args = TREE_CHAIN (args);
8609 for (; args != end_params_node; args = TREE_CHAIN (args))
8610 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8616 /* Check all the methods of CLASS_DECL. Methods are first completed
8617 then checked according to regular method existance rules. If no
8618 constructor for CLASS_DECL were encountered, then build its
8622 java_check_regular_methods (class_decl)
8625 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8627 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8628 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8631 /* It is not necessary to check methods defined in java.lang.Object */
8632 if (class == object_type_node)
8635 if (!TYPE_NVIRTUALS (class))
8636 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8638 /* Should take interfaces into account. FIXME */
8639 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8642 tree method_wfl = DECL_NAME (method);
8645 /* If we previously found something and its name was saved,
8647 if (found && saved_found_wfl)
8649 DECL_NAME (found) = saved_found_wfl;
8650 saved_found_wfl = NULL_TREE;
8653 /* Check for redefinitions */
8654 if (check_method_redefinition (class, method))
8657 /* If we see one constructor a mark so we don't generate the
8658 default one. Also skip other verifications: constructors
8659 can't be inherited hence hiden or overriden */
8660 if (DECL_CONSTRUCTOR_P (method))
8662 saw_constructor = 1;
8666 /* We verify things thrown by the method. They must inherits from
8667 java.lang.Throwable */
8668 for (mthrows = DECL_FUNCTION_THROWS (method);
8669 mthrows; mthrows = TREE_CHAIN (mthrows))
8671 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8673 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8675 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8678 sig = build_java_argument_signature (TREE_TYPE (method));
8679 found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8681 /* Inner class can't declare static methods */
8682 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8684 char *t = xstrdup (lang_printable_name (class, 0));
8686 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8687 lang_printable_name (method, 0), t);
8691 /* Nothing overrides or it's a private method. */
8694 if (METHOD_PRIVATE (found))
8700 /* If found wasn't verified, it's DECL_NAME won't be set properly.
8701 We set it temporarily for the sake of the error report. */
8702 saved_found_wfl = DECL_NAME (found);
8703 reset_method_name (found);
8705 /* If `found' is declared in an interface, make sure the
8706 modifier matches. */
8707 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8708 && clinit_identifier_node != DECL_NAME (found)
8709 && !METHOD_PUBLIC (method))
8711 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8712 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8713 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8714 lang_printable_name (method, 0),
8715 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8718 /* Can't override a method with the same name and different return
8720 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8723 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8726 "Method `%s' was defined with return type `%s' in class `%s'",
8727 lang_printable_name (found, 0), t,
8729 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8733 aflags = get_access_flags_from_decl (found);
8734 /* If the method has default, access in an other package, then
8735 issue a warning that the current method doesn't override the
8736 one that was found elsewhere. Do not issue this warning when
8737 the match was found in java.lang.Object. */
8738 if (DECL_CONTEXT (found) != object_type_node
8739 && ((aflags & ACC_VISIBILITY) == 0)
8740 && !class_in_current_package (DECL_CONTEXT (found))
8741 && !DECL_CLINIT_P (found)
8742 && flag_not_overriding)
8744 parse_warning_context
8745 (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8746 lang_printable_name (found, 0),
8747 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8748 IDENTIFIER_POINTER (DECL_NAME
8749 (TYPE_NAME (DECL_CONTEXT (found)))));
8753 /* Can't override final. Can't override static. */
8754 if (METHOD_FINAL (found) || METHOD_STATIC (found))
8756 /* Static *can* override static */
8757 if (METHOD_STATIC (found) && METHOD_STATIC (method))
8761 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8762 (METHOD_FINAL (found) ? "Final" : "Static"),
8763 lang_printable_name (found, 0),
8764 (METHOD_FINAL (found) ? "final" : "static"),
8766 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8770 /* Static method can't override instance method. */
8771 if (METHOD_STATIC (method))
8775 "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8776 lang_printable_name (found, 0),
8778 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8782 /* - Overriding/hiding public must be public
8783 - Overriding/hiding protected must be protected or public
8784 - If the overriden or hidden method has default (package)
8785 access, then the overriding or hiding method must not be
8786 private; otherwise, a compile-time error occurs. If
8787 `found' belongs to an interface, things have been already
8789 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8790 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8791 || (METHOD_PROTECTED (found)
8792 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8793 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8794 && METHOD_PRIVATE (method))))
8798 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8799 (METHOD_PUBLIC (method) ? "public" :
8800 (METHOD_PRIVATE (method) ? "private" : "protected")),
8801 IDENTIFIER_POINTER (DECL_NAME
8802 (TYPE_NAME (DECL_CONTEXT (found)))));
8806 /* Overriding methods must have compatible `throws' clauses on checked
8807 exceptions, if any */
8808 check_throws_clauses (method, method_wfl, found);
8810 /* Inheriting multiple methods with the same signature. FIXME */
8813 /* Don't forget eventual pending found and saved_found_wfl. Take
8814 into account that we might have exited because we saw an
8815 artificial method as the last entry. */
8817 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8818 DECL_NAME (found) = saved_found_wfl;
8820 if (!TYPE_NVIRTUALS (class))
8821 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8823 /* Search for inherited abstract method not yet implemented in this
8825 java_check_abstract_method_definitions (class_decl);
8827 if (!saw_constructor)
8828 fatal ("No constructor found");
8831 /* Return a non zero value if the `throws' clause of METHOD (if any)
8832 is incompatible with the `throws' clause of FOUND (if any). */
8835 check_throws_clauses (method, method_wfl, found)
8836 tree method, method_wfl, found;
8838 tree mthrows, fthrows;
8840 /* Can't check these things with class loaded from bytecode. FIXME */
8841 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8844 for (mthrows = DECL_FUNCTION_THROWS (method);
8845 mthrows; mthrows = TREE_CHAIN (mthrows))
8847 /* We don't verify unchecked expressions */
8848 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8850 /* Checked expression must be compatible */
8851 for (fthrows = DECL_FUNCTION_THROWS (found);
8852 fthrows; fthrows = TREE_CHAIN (fthrows))
8853 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8858 (method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
8859 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8860 lang_printable_name (found, 0),
8862 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8867 /* Check abstract method of interface INTERFACE */
8870 java_check_abstract_methods (interface_decl)
8871 tree interface_decl;
8874 tree method, basetype_vec, found;
8875 tree interface = TREE_TYPE (interface_decl);
8877 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8879 tree method_wfl = DECL_NAME (method);
8881 /* 2- Check for double definition inside the defining interface */
8882 if (check_method_redefinition (interface, method))
8885 /* 3- Overriding is OK as far as we preserve the return type and
8886 the thrown exceptions (FIXME) */
8887 found = lookup_java_interface_method2 (interface, method);
8891 tree saved_found_wfl = DECL_NAME (found);
8892 reset_method_name (found);
8893 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8896 "Method `%s' was defined with return type `%s' in class `%s'",
8897 lang_printable_name (found, 0), t,
8899 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8901 DECL_NAME (found) = saved_found_wfl;
8906 /* 4- Inherited methods can't differ by their returned types */
8907 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8909 n = TREE_VEC_LENGTH (basetype_vec);
8910 for (i = 0; i < n; i++)
8912 tree sub_interface_method, sub_interface;
8913 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8916 sub_interface = BINFO_TYPE (vec_elt);
8917 for (sub_interface_method = TYPE_METHODS (sub_interface);
8918 sub_interface_method;
8919 sub_interface_method = TREE_CHAIN (sub_interface_method))
8921 found = lookup_java_interface_method2 (interface,
8922 sub_interface_method);
8923 if (found && (found != sub_interface_method))
8925 tree saved_found_wfl = DECL_NAME (found);
8926 reset_method_name (found);
8928 (lookup_cl (sub_interface_method),
8929 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8930 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8931 lang_printable_name (found, 0),
8933 (DECL_NAME (TYPE_NAME
8934 (DECL_CONTEXT (sub_interface_method)))),
8936 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8937 DECL_NAME (found) = saved_found_wfl;
8943 /* Lookup methods in interfaces using their name and partial
8944 signature. Return a matching method only if their types differ. */
8947 lookup_java_interface_method2 (class, method_decl)
8948 tree class, method_decl;
8951 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8956 n = TREE_VEC_LENGTH (basetype_vec);
8957 for (i = 0; i < n; i++)
8959 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8960 if ((BINFO_TYPE (vec_elt) != object_type_node)
8962 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8965 for (i = 0; i < n; i++)
8967 to_return = lookup_java_interface_method2
8968 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8976 /* Lookup method using their name and partial signature. Return a
8977 matching method only if their types differ. */
8980 lookup_java_method2 (clas, method_decl, do_interface)
8981 tree clas, method_decl;
8984 tree method, method_signature, method_name, method_type, name;
8986 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8987 name = DECL_NAME (method_decl);
8988 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8989 EXPR_WFL_NODE (name) : name);
8990 method_type = TREE_TYPE (TREE_TYPE (method_decl));
8992 while (clas != NULL_TREE)
8994 for (method = TYPE_METHODS (clas);
8995 method != NULL_TREE; method = TREE_CHAIN (method))
8997 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8998 tree name = DECL_NAME (method);
8999 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9000 EXPR_WFL_NODE (name) : name) == method_name
9001 && method_sig == method_signature
9002 && TREE_TYPE (TREE_TYPE (method)) != method_type)
9005 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
9010 /* Return the line that matches DECL line number, and try its best to
9011 position the column number. Used during error reports. */
9017 static tree cl = NULL_TREE;
9023 if (cl == NULL_TREE)
9024 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9026 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9027 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9029 line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9030 EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9032 found = strstr ((const char *)line,
9033 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9035 EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9040 /* Look for a simple name in the single-type import list */
9043 find_name_in_single_imports (name)
9048 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9049 if (TREE_VALUE (node) == name)
9050 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9055 /* Process all single-type import. */
9063 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9065 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9067 /* Don't load twice something already defined. */
9068 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9070 QUALIFIED_P (to_be_found) = 1;
9071 load_class (to_be_found, 0);
9073 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9074 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9076 parse_error_context (TREE_PURPOSE (import),
9077 "Class or interface `%s' not found in import",
9078 IDENTIFIER_POINTER (to_be_found));
9087 /* Possibly find a class imported by a single-type import statement. Return
9088 1 if an error occured, 0 otherwise. */
9091 find_in_imports (class_type)
9096 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9097 if (TREE_VALUE (import) == TYPE_NAME (class_type))
9099 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9100 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9106 note_possible_classname (name, len)
9111 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9113 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9117 node = ident_subst (name, len, "", '/', '.', "");
9118 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9119 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9123 /* Read a import directory, gathering potential match for further type
9124 references. Indifferently reads a filesystem or a ZIP archive
9128 read_import_dir (wfl)
9131 tree package_id = EXPR_WFL_NODE (wfl);
9132 const char *package_name = IDENTIFIER_POINTER (package_id);
9133 int package_length = IDENTIFIER_LENGTH (package_id);
9135 JCF *saved_jcf = current_jcf;
9140 struct buffer filename[1];
9143 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9145 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9147 BUFFER_INIT (filename);
9148 buffer_grow (filename, package_length + 100);
9150 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9152 const char *entry_name = jcf_path_name (entry);
9153 int entry_length = strlen (entry_name);
9154 if (jcf_path_is_zipfile (entry))
9157 buffer_grow (filename, entry_length);
9158 memcpy (filename->data, entry_name, entry_length - 1);
9159 filename->data[entry_length-1] = '\0';
9160 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9162 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9165 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9166 BUFFER_RESET (filename);
9167 for (k = 0; k < package_length; k++)
9169 char ch = package_name[k];
9170 *filename->ptr++ = ch == '.' ? '/' : ch;
9172 *filename->ptr++ = '/';
9174 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9176 const char *current_entry = ZIPDIR_FILENAME (zipd);
9177 int current_entry_len = zipd->filename_length;
9179 if (current_entry_len >= BUFFER_LENGTH (filename)
9180 && strncmp (filename->data, current_entry,
9181 BUFFER_LENGTH (filename)) != 0)
9183 found |= note_possible_classname (current_entry,
9190 BUFFER_RESET (filename);
9191 buffer_grow (filename, entry_length + package_length + 4);
9192 strcpy (filename->data, entry_name);
9193 filename->ptr = filename->data + entry_length;
9194 for (k = 0; k < package_length; k++)
9196 char ch = package_name[k];
9197 *filename->ptr++ = ch == '.' ? '/' : ch;
9199 *filename->ptr = '\0';
9201 dirp = opendir (filename->data);
9204 *filename->ptr++ = '/';
9209 struct dirent *direntp = readdir (dirp);
9212 d_name = direntp->d_name;
9213 len = strlen (direntp->d_name);
9214 buffer_grow (filename, len+1);
9215 strcpy (filename->ptr, d_name);
9216 found |= note_possible_classname (filename->data + entry_length,
9217 package_length+len+1);
9224 free (filename->data);
9226 /* Here we should have a unified way of retrieving an entry, to be
9230 static int first = 1;
9233 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9238 parse_error_context (wfl, "Package `%s' not found in import",
9240 current_jcf = saved_jcf;
9243 current_jcf = saved_jcf;
9246 /* Possibly find a type in the import on demands specified
9247 types. Returns 1 if an error occured, 0 otherwise. Run throught the
9248 entire list, to detected potential double definitions. */
9251 find_in_imports_on_demand (class_type)
9254 tree node, import, node_to_use = NULL_TREE;
9256 tree cl = NULL_TREE;
9258 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9260 const char *id_name;
9261 obstack_grow (&temporary_obstack,
9262 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9263 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9264 obstack_1grow (&temporary_obstack, '.');
9265 obstack_grow0 (&temporary_obstack,
9266 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9267 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9268 id_name = obstack_finish (&temporary_obstack);
9270 node = maybe_get_identifier (id_name);
9271 if (node && IS_A_CLASSFILE_NAME (node))
9275 cl = TREE_PURPOSE (import);
9283 (import, "Type `%s' also potentially defined in package `%s'",
9284 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9285 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9292 /* Setup lineno so that it refers to the line of the import (in
9293 case we parse a class file and encounter errors */
9295 int saved_lineno = lineno;
9296 lineno = EXPR_WFL_LINENO (cl);
9297 TYPE_NAME (class_type) = node_to_use;
9298 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9299 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9300 /* If there is no DECL set for the class or if the class isn't
9301 loaded and not seen in source yet, the load */
9302 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9303 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9304 load_class (node_to_use, 0);
9305 lineno = saved_lineno;
9306 return check_pkg_class_access (TYPE_NAME (class_type), cl);
9309 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9313 resolve_package (pkg, next)
9317 tree type_name = NULL_TREE;
9318 const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9320 /* The trick is to determine when the package name stops and were
9321 the name of something contained in the package starts. Then we
9322 return a fully qualified name of what we want to get. */
9324 /* Do a quick search on well known package names */
9325 if (!strncmp (name, "java.lang.reflect", 17))
9328 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9329 type_name = lookup_package_type (name, 17);
9331 else if (!strncmp (name, "java.lang", 9))
9333 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9334 type_name = lookup_package_type (name, 9);
9337 /* If we found something here, return */
9341 *next = EXPR_WFL_QUALIFICATION (pkg);
9343 /* Try the current package. */
9344 if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),
9345 IDENTIFIER_LENGTH (ctxp->package)))
9348 lookup_package_type_and_set_next (name,
9349 IDENTIFIER_LENGTH (ctxp->package),
9355 /* Search in imported package */
9356 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9358 tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9359 int len = IDENTIFIER_LENGTH (current_pkg_name);
9360 if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9364 breakdown_qualified (&left, &dummy, current_pkg_name);
9365 len = IDENTIFIER_LENGTH (left);
9366 type_name = lookup_package_type_and_set_next (name, len, next);
9372 /* Try to progressively construct a type name */
9373 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9374 for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg);
9375 current; current = TREE_CHAIN (current))
9377 acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9378 if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9381 /* resolve_package should be used in a loop, hence we
9382 point at this one to naturally process the next one at
9383 the next iteration. */
9392 lookup_package_type_and_set_next (name, len, next)
9398 tree type_name = lookup_package_type (name, len);
9403 ptr = IDENTIFIER_POINTER (type_name);
9404 while (ptr && (ptr = strchr (ptr, '.')))
9406 *next = TREE_CHAIN (*next);
9413 lookup_package_type (name, from)
9418 const char *sub = &name[from+1];
9419 while (*sub != '.' && *sub)
9421 strncpy (subname, name, sub-name);
9422 subname [sub-name] = '\0';
9423 return get_identifier (subname);
9426 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9427 access violations were found, 1 otherwise. */
9430 check_pkg_class_access (class_name, cl)
9436 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9439 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9442 if (!CLASS_PUBLIC (TYPE_NAME (type)))
9444 /* Access to a private class within the same package is
9447 breakdown_qualified (&l, &r, class_name);
9448 if (l == ctxp->package)
9452 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9453 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9454 IDENTIFIER_POINTER (class_name));
9460 /* Local variable declaration. */
9463 declare_local_variables (modifier, type, vlist)
9468 tree decl, current, saved_type;
9469 tree type_wfl = NULL_TREE;
9473 /* Push a new block if statements were seen between the last time we
9474 pushed a block and now. Keep a cound of block to close */
9475 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9477 tree body = GET_CURRENT_BLOCK (current_function_decl);
9478 tree b = enter_block ();
9479 BLOCK_EXPR_ORIGIN (b) = body;
9485 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9486 if (modifier == ACC_FINAL)
9491 (ctxp->modifier_ctx [i],
9492 "Only `final' is allowed as a local variables modifier");
9497 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9498 hold the TYPE value if a new incomplete has to be created (as
9499 opposed to being found already existing and reused). */
9500 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9502 /* If TYPE is fully resolved and we don't have a reference, make one */
9503 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9505 /* Go through all the declared variables */
9506 for (current = vlist, saved_type = type; current;
9507 current = TREE_CHAIN (current), type = saved_type)
9509 tree other, real_type;
9510 tree wfl = TREE_PURPOSE (current);
9511 tree name = EXPR_WFL_NODE (wfl);
9512 tree init = TREE_VALUE (current);
9514 /* Process NAME, as it may specify extra dimension(s) for it */
9515 type = build_array_from_name (type, type_wfl, name, &name);
9517 /* Variable redefinition check */
9518 if ((other = lookup_name_in_blocks (name)))
9520 variable_redefinition_error (wfl, name, TREE_TYPE (other),
9521 DECL_SOURCE_LINE (other));
9525 /* Type adjustment. We may have just readjusted TYPE because
9526 the variable specified more dimensions. Make sure we have
9527 a reference if we can and don't have one already. */
9528 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9530 real_type = GET_REAL_TYPE (type);
9531 /* Never layout this decl. This will be done when its scope
9533 decl = build_decl (VAR_DECL, name, real_type);
9534 LOCAL_FINAL (decl) = final_p;
9535 BLOCK_CHAIN_DECL (decl);
9537 /* If doing xreferencing, replace the line number with the WFL
9540 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9542 /* Don't try to use an INIT statement when an error was found */
9543 if (init && java_error_count)
9546 /* Add the initialization function to the current function's code */
9549 /* Name might have been readjusted */
9550 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9551 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9552 java_method_add_stmt (current_function_decl,
9553 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9557 /* Setup dependency the type of the decl */
9561 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9562 dep = CLASSD_LAST (ctxp->classd_list);
9563 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9566 SOURCE_FRONTEND_DEBUG (("Defined locals"));
9569 /* Called during parsing. Build decls from argument list. */
9572 source_start_java_method (fndecl)
9582 current_function_decl = fndecl;
9584 /* New scope for the function */
9586 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9587 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9589 tree type = TREE_VALUE (tem);
9590 tree name = TREE_PURPOSE (tem);
9592 /* If type is incomplete. Create an incomplete decl and ask for
9593 the decl to be patched later */
9594 if (INCOMPLETE_TYPE_P (type))
9597 tree real_type = GET_REAL_TYPE (type);
9598 parm_decl = build_decl (PARM_DECL, name, real_type);
9599 type = obtain_incomplete_type (type);
9600 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9601 jdep = CLASSD_LAST (ctxp->classd_list);
9602 JDEP_MISC (jdep) = name;
9603 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9606 parm_decl = build_decl (PARM_DECL, name, type);
9608 /* Remember if a local variable was declared final (via its
9609 TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9610 if (ARG_FINAL_P (tem))
9611 LOCAL_FINAL (parm_decl) = 1;
9613 BLOCK_CHAIN_DECL (parm_decl);
9615 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9616 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9618 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9619 DECL_MAX_LOCALS (current_function_decl) = i;
9622 /* Called during parsing. Creates an artificial method declaration. */
9625 create_artificial_method (class, flags, type, name, args)
9628 tree type, name, args;
9632 java_parser_context_save_global ();
9634 mdecl = make_node (FUNCTION_TYPE);
9635 TREE_TYPE (mdecl) = type;
9636 TYPE_ARG_TYPES (mdecl) = args;
9637 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
9638 java_parser_context_restore_global ();
9639 DECL_ARTIFICIAL (mdecl) = 1;
9643 /* Starts the body if an artifical method. */
9646 start_artificial_method_body (mdecl)
9649 DECL_SOURCE_LINE (mdecl) = 1;
9650 DECL_SOURCE_LINE_MERGE (mdecl, 1);
9651 source_start_java_method (mdecl);
9656 end_artificial_method_body (mdecl)
9659 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9663 /* Called during expansion. Push decls formerly built from argument
9664 list so they're usable during expansion. */
9667 expand_start_java_method (fndecl)
9672 current_function_decl = fndecl;
9675 fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9676 announce_function (fndecl);
9678 fprintf (stderr, "]");
9680 pushlevel (1); /* Prepare for a parameter push */
9681 ptr = &DECL_ARGUMENTS (fndecl);
9682 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9685 tree next = TREE_CHAIN (tem);
9686 tree type = TREE_TYPE (tem);
9687 if (PROMOTE_PROTOTYPES
9688 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9689 && INTEGRAL_TYPE_P (type))
9690 type = integer_type_node;
9691 DECL_ARG_TYPE (tem) = type;
9692 layout_decl (tem, 0);
9695 ptr = &TREE_CHAIN (tem);
9699 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9700 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9703 /* Terminate a function and expand its body. */
9706 source_end_java_method ()
9708 tree fndecl = current_function_decl;
9709 int flag_asynchronous_exceptions = asynchronous_exceptions;
9714 java_parser_context_save_global ();
9715 lineno = ctxp->last_ccb_indent1;
9717 /* Set EH language codes */
9718 java_set_exception_lang_code ();
9720 /* Turn function bodies with only a NOP expr null, so they don't get
9721 generated at all and we won't get warnings when using the -W
9723 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9724 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9726 /* Generate function's code */
9727 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9728 && ! flag_emit_class_files
9729 && ! flag_emit_xref)
9730 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9732 /* pop out of its parameters */
9733 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9735 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9737 /* Generate rtl for function exit. */
9738 if (! flag_emit_class_files && ! flag_emit_xref)
9740 lineno = DECL_SOURCE_LINE_LAST (fndecl);
9741 /* Emit catch-finally clauses */
9743 expand_function_end (input_filename, lineno, 0);
9745 /* FIXME: If the current method contains any exception handlers,
9746 force asynchronous_exceptions: this is necessary because signal
9747 handlers in libjava may throw exceptions. This is far from being
9748 a perfect solution, but it's better than doing nothing at all.*/
9750 asynchronous_exceptions = 1;
9752 /* Run the optimizers and output assembler code for this function. */
9753 rest_of_compilation (fndecl);
9756 current_function_decl = NULL_TREE;
9757 permanent_allocation (1);
9758 java_parser_context_restore_global ();
9759 asynchronous_exceptions = flag_asynchronous_exceptions;
9762 /* Record EXPR in the current function block. Complements compound
9763 expression second operand if necessary. */
9766 java_method_add_stmt (fndecl, expr)
9769 if (!GET_CURRENT_BLOCK (fndecl))
9771 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9775 add_stmt_to_block (b, type, stmt)
9778 tree body = BLOCK_EXPR_BODY (b), c;
9780 if (java_error_count)
9783 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9786 BLOCK_EXPR_BODY (b) = c;
9787 TREE_SIDE_EFFECTS (c) = 1;
9791 /* Add STMT to EXISTING if possible, otherwise create a new
9792 COMPOUND_EXPR and add STMT to it. */
9795 add_stmt_to_compound (existing, type, stmt)
9796 tree existing, type, stmt;
9799 return build (COMPOUND_EXPR, type, existing, stmt);
9804 /* Hold THIS for the scope of the current public method decl. */
9805 static tree current_this;
9807 void java_layout_seen_class_methods ()
9809 tree previous_list = all_class_list;
9810 tree end = NULL_TREE;
9815 for (current = previous_list;
9816 current != end; current = TREE_CHAIN (current))
9817 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9819 if (previous_list != all_class_list)
9821 end = previous_list;
9822 previous_list = all_class_list;
9830 java_reorder_fields ()
9832 static tree stop_reordering = NULL_TREE;
9835 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9837 current_class = TREE_TYPE (TREE_VALUE (current));
9839 if (current_class == stop_reordering)
9842 /* Reverse the fields, but leave the dummy field in front.
9843 Fields are already ordered for Object and Class */
9844 if (TYPE_FIELDS (current_class) && current_class != object_type_node
9845 && current_class != class_type_node)
9847 /* If the dummy field is there, reverse the right fields and
9848 just layout the type for proper fields offset */
9849 if (!DECL_NAME (TYPE_FIELDS (current_class)))
9851 tree fields = TYPE_FIELDS (current_class);
9852 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9853 TYPE_SIZE (current_class) = NULL_TREE;
9855 /* We don't have a dummy field, we need to layout the class,
9856 after having reversed the fields */
9859 TYPE_FIELDS (current_class) =
9860 nreverse (TYPE_FIELDS (current_class));
9861 TYPE_SIZE (current_class) = NULL_TREE;
9865 stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9868 /* Layout the methods of all classes loaded in one way on an
9869 other. Check methods of source parsed classes. Then reorder the
9870 fields and layout the classes or the type of all source parsed
9874 java_layout_classes ()
9877 int save_error_count = java_error_count;
9879 /* Layout the methods of all classes seen so far */
9880 java_layout_seen_class_methods ();
9881 java_parse_abort_on_error ();
9882 all_class_list = NULL_TREE;
9884 /* Then check the methods of all parsed classes */
9885 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9886 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9887 CHECK_METHODS (TREE_VALUE (current));
9888 java_parse_abort_on_error ();
9890 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9892 current_class = TREE_TYPE (TREE_VALUE (current));
9893 layout_class (current_class);
9895 /* From now on, the class is considered completely loaded */
9896 CLASS_LOADED_P (current_class) = 1;
9898 /* Error reported by the caller */
9899 if (java_error_count)
9903 /* We might have reloaded classes durign the process of laying out
9904 classes for code generation. We must layout the methods of those
9905 late additions, as constructor checks might use them */
9906 java_layout_seen_class_methods ();
9907 java_parse_abort_on_error ();
9910 /* Expand methods in the current set of classes rememebered for
9914 java_complete_expand_classes ()
9918 do_not_fold = flag_emit_xref;
9920 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9921 if (!INNER_CLASS_DECL_P (current))
9922 java_complete_expand_class (current);
9925 /* Expand the methods found in OUTER, starting first by OUTER's inner
9929 java_complete_expand_class (outer)
9934 set_nested_class_simple_name_value (outer, 1); /* Set */
9936 /* We need to go after all inner classes and start expanding them,
9937 starting with most nested ones. We have to do that because nested
9938 classes might add functions to outer classes */
9940 for (inner_list = DECL_INNER_CLASS_LIST (outer);
9941 inner_list; inner_list = TREE_CHAIN (inner_list))
9942 java_complete_expand_class (TREE_PURPOSE (inner_list));
9944 java_complete_expand_methods (outer);
9945 set_nested_class_simple_name_value (outer, 0); /* Reset */
9948 /* Expand methods registered in CLASS_DECL. The general idea is that
9949 we expand regular methods first. This allows us get an estimate on
9950 how outer context local alias fields are really used so we can add
9951 to the constructor just enough code to initialize them properly (it
9952 also lets us generate $finit$ correctly.) Then we expand the
9953 constructors and then <clinit>. */
9956 java_complete_expand_methods (class_decl)
9959 tree clinit, finit, decl, first_decl;
9961 current_class = TREE_TYPE (class_decl);
9963 /* Initialize a new constant pool */
9964 init_outgoing_cpool ();
9966 /* Pre-expand <clinit> to figure whether we really need it or
9967 not. If we do need it, we pre-expand the static fields so they're
9968 ready to be used somewhere else. <clinit> will be fully expanded
9969 after we processed the constructors. */
9970 first_decl = TYPE_METHODS (current_class);
9971 clinit = maybe_generate_pre_expand_clinit (current_class);
9973 /* Then generate $finit$ (if we need to) because constructor will
9975 if (TYPE_FINIT_STMT_LIST (current_class))
9977 finit = generate_finit (current_class);
9978 java_complete_expand_method (finit);
9981 /* Now do the constructors */
9982 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9986 if (!DECL_CONSTRUCTOR_P (decl))
9989 no_body = !DECL_FUNCTION_BODY (decl);
9990 /* Don't generate debug info on line zero when expanding a
9991 generated constructor. */
9993 restore_line_number_status (1);
9995 java_complete_expand_method (decl);
9998 restore_line_number_status (0);
10001 /* First, do the ordinary methods. */
10002 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
10004 /* Skip abstract or native methods -- but do handle native
10005 methods when generating JNI stubs. */
10006 if (METHOD_ABSTRACT (decl)
10007 || (! flag_jni && METHOD_NATIVE (decl))
10008 || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
10011 if (METHOD_NATIVE (decl))
10013 tree body = build_jni_stub (decl);
10014 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl)) = body;
10017 java_complete_expand_method (decl);
10020 /* If there is indeed a <clinit>, fully expand it now */
10023 /* Prevent the use of `this' inside <clinit> */
10024 ctxp->explicit_constructor_p = 1;
10025 java_complete_expand_method (clinit);
10026 ctxp->explicit_constructor_p = 0;
10029 /* We might have generated a class$ that we now want to expand */
10030 if (TYPE_DOT_CLASS (current_class))
10031 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10033 /* Now verify constructor circularity (stop after the first one we
10035 if (!CLASS_INTERFACE (class_decl))
10036 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10037 if (DECL_CONSTRUCTOR_P (decl)
10038 && verify_constructor_circularity (decl, decl))
10041 /* Save the constant pool. We'll need to restore it later. */
10042 TYPE_CPOOL (current_class) = outgoing_cpool;
10045 /* Hold a list of catch clauses list. The first element of this list is
10046 the list of the catch clauses of the currently analysed try block. */
10047 static tree currently_caught_type_list;
10049 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10050 safely used in some other methods/constructors. */
10053 maybe_generate_pre_expand_clinit (class_type)
10056 tree current, mdecl;
10058 if (!TYPE_CLINIT_STMT_LIST (class_type))
10061 /* Go through all static fields and pre expand them */
10062 for (current = TYPE_FIELDS (class_type); current;
10063 current = TREE_CHAIN (current))
10064 if (FIELD_STATIC (current))
10065 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10067 /* Then build the <clinit> method */
10068 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10069 clinit_identifier_node, end_params_node);
10070 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10072 start_artificial_method_body (mdecl);
10074 /* We process the list of assignment we produced as the result of
10075 the declaration of initialized static field and add them as
10076 statement to the <clinit> method. */
10077 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10078 current = TREE_CHAIN (current))
10080 /* We build the assignment expression that will initialize the
10081 field to its value. There are strict rules on static
10082 initializers (8.5). FIXME */
10083 tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10084 java_method_add_stmt (mdecl, stmt);
10087 end_artificial_method_body (mdecl);
10089 /* Now we want to place <clinit> as the last method (because we need
10090 it at least for interface so that it doesn't interfere with the
10091 dispatch table based lookup. */
10092 if (TREE_CHAIN (TYPE_METHODS (class_type)))
10094 current = TREE_CHAIN (TYPE_METHODS (class_type));
10095 TYPE_METHODS (class_type) = current;
10097 while (TREE_CHAIN (current))
10098 current = TREE_CHAIN (current);
10100 TREE_CHAIN (current) = mdecl;
10101 TREE_CHAIN (mdecl) = NULL_TREE;
10107 /* See whether we could get rid of <clinit>. Criteria are: all static
10108 final fields have constant initial values and the body of <clinit>
10109 is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
10112 maybe_yank_clinit (mdecl)
10115 tree type, current;
10118 if (!DECL_CLINIT_P (mdecl))
10121 /* If the body isn't empty, then we keep <clinit> */
10122 fbody = DECL_FUNCTION_BODY (mdecl);
10123 if ((bbody = BLOCK_EXPR_BODY (fbody)))
10124 bbody = BLOCK_EXPR_BODY (bbody);
10125 if (bbody && bbody != empty_stmt_node)
10128 type = DECL_CONTEXT (mdecl);
10129 current = TYPE_FIELDS (type);
10131 for (current = (current ? TREE_CHAIN (current) : current);
10132 current; current = TREE_CHAIN (current))
10133 if (!(FIELD_STATIC (current) && FIELD_FINAL (current)
10134 && DECL_INITIAL (current) && TREE_CONSTANT (DECL_INITIAL (current))))
10140 /* Get rid of <clinit> in the class' list of methods */
10141 if (TYPE_METHODS (type) == mdecl)
10142 TYPE_METHODS (type) = TREE_CHAIN (mdecl);
10144 for (current = TYPE_METHODS (type); current;
10145 current = TREE_CHAIN (current))
10146 if (TREE_CHAIN (current) == mdecl)
10148 TREE_CHAIN (current) = TREE_CHAIN (mdecl);
10156 /* Complete and expand a method. */
10159 java_complete_expand_method (mdecl)
10162 int yank_clinit = 0;
10164 current_function_decl = mdecl;
10165 /* Fix constructors before expanding them */
10166 if (DECL_CONSTRUCTOR_P (mdecl))
10167 fix_constructors (mdecl);
10169 /* Expand functions that have a body */
10170 if (DECL_FUNCTION_BODY (mdecl))
10172 tree fbody = DECL_FUNCTION_BODY (mdecl);
10173 tree block_body = BLOCK_EXPR_BODY (fbody);
10174 tree exception_copy = NULL_TREE;
10175 expand_start_java_method (mdecl);
10176 build_result_decl (mdecl);
10179 = (!METHOD_STATIC (mdecl) ?
10180 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10182 /* Purge the `throws' list of unchecked exceptions. If we're
10183 doing xref, save a copy of the list and re-install it
10185 if (flag_emit_xref)
10186 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10188 purge_unchecked_exceptions (mdecl);
10190 /* Install exceptions thrown with `throws' */
10191 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10193 if (block_body != NULL_TREE)
10195 block_body = java_complete_tree (block_body);
10197 if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
10198 check_for_initialization (block_body);
10199 ctxp->explicit_constructor_p = 0;
10202 BLOCK_EXPR_BODY (fbody) = block_body;
10204 /* If we saw a return but couldn't evaluate it properly, we'll
10205 have an error_mark_node here. */
10206 if (block_body != error_mark_node
10207 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10208 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10209 && !flag_emit_xref)
10210 missing_return_error (current_function_decl);
10212 /* Check wether we could just get rid of clinit, now the picture
10214 if (!(yank_clinit = maybe_yank_clinit (mdecl)))
10215 complete_start_java_method (mdecl);
10217 /* Don't go any further if we've found error(s) during the
10219 if (!java_error_count && !yank_clinit)
10220 source_end_java_method ();
10223 if (java_error_count)
10224 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10225 poplevel (1, 0, 1);
10228 /* Pop the exceptions and sanity check */
10230 if (currently_caught_type_list)
10231 fatal ("Exception list non empty - java_complete_expand_method");
10233 if (flag_emit_xref)
10234 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10240 /* This section of the code deals with accessing enclosing context
10241 fields either directly by using the relevant access to this$<n> or
10242 by invoking an access method crafted for that purpose. */
10244 /* Build the necessary access from an inner class to an outer
10245 class. This routine could be optimized to cache previous result
10246 (decl, current_class and returned access). When an access method
10247 needs to be generated, it always takes the form of a read. It might
10248 be later turned into a write by calling outer_field_access_fix. */
10251 build_outer_field_access (id, decl)
10254 tree access = NULL_TREE;
10255 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10257 /* If decl's class is the direct outer class of the current_class,
10258 build the access as `this$<n>.<field>'. Not that we will break
10259 the `private' barrier if we're not emitting bytecodes. */
10260 if (ctx == DECL_CONTEXT (decl)
10261 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10263 tree thisn = build_current_thisn (current_class);
10264 access = make_qualified_primary (build_wfl_node (thisn),
10265 id, EXPR_WFL_LINECOL (id));
10267 /* Otherwise, generate access methods to outer this and access the
10268 field (either using an access method or by direct access.) */
10271 int lc = EXPR_WFL_LINECOL (id);
10273 /* Now we chain the required number of calls to the access$0 to
10274 get a hold to the enclosing instance we need, and the we
10275 build the field access. */
10276 access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10278 /* If the field is private and we're generating bytecode, then
10279 we generate an access method */
10280 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10282 tree name = build_outer_field_access_methods (decl);
10283 access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10284 name, access, NULL_TREE);
10286 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10287 Once again we break the `private' access rule from a foreign
10290 access = make_qualified_primary (access, id, lc);
10292 return resolve_expression_name (access, NULL);
10295 /* Return a non zero value if NODE describes an outer field inner
10299 outer_field_access_p (type, decl)
10302 if (!INNER_CLASS_TYPE_P (type)
10303 || TREE_CODE (decl) != FIELD_DECL
10304 || DECL_CONTEXT (decl) == type)
10307 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10308 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10310 if (type == DECL_CONTEXT (decl))
10312 if (!DECL_CONTEXT (TYPE_NAME (type)))
10319 /* Return a non zero value if NODE represents an outer field inner
10320 access that was been already expanded. As a side effect, it returns
10321 the name of the field being accessed and the argument passed to the
10322 access function, suitable for a regeneration of the access method
10323 call if necessary. */
10326 outer_field_expanded_access_p (node, name, arg_type, arg)
10327 tree node, *name, *arg_type, *arg;
10329 int identified = 0;
10331 if (TREE_CODE (node) != CALL_EXPR)
10334 /* Well, gcj generates slightly different tree nodes when compiling
10335 to native or bytecodes. It's the case for function calls. */
10337 if (flag_emit_class_files
10338 && TREE_CODE (node) == CALL_EXPR
10339 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10341 else if (!flag_emit_class_files)
10343 node = TREE_OPERAND (node, 0);
10345 if (node && TREE_OPERAND (node, 0)
10346 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10348 node = TREE_OPERAND (node, 0);
10349 if (TREE_OPERAND (node, 0)
10350 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10351 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
10352 (DECL_NAME (TREE_OPERAND (node, 0)))))
10357 if (identified && name && arg_type && arg)
10359 tree argument = TREE_OPERAND (node, 1);
10360 *name = DECL_NAME (TREE_OPERAND (node, 0));
10361 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10362 *arg = TREE_VALUE (argument);
10367 /* Detect in NODE an outer field read access from an inner class and
10368 transform it into a write with RHS as an argument. This function is
10369 called from the java_complete_lhs when an assignment to a LHS can
10373 outer_field_access_fix (wfl, node, rhs)
10374 tree wfl, node, rhs;
10376 tree name, arg_type, arg;
10378 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10380 /* At any rate, check whether we're trying to assign a value to
10382 tree accessed = (JDECL_P (node) ? node :
10383 (TREE_CODE (node) == COMPONENT_REF ?
10384 TREE_OPERAND (node, 1) : node));
10385 if (check_final_assignment (accessed, wfl))
10386 return error_mark_node;
10388 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
10389 arg_type, name, arg, rhs);
10390 return java_complete_tree (node);
10395 /* Construct the expression that calls an access method:
10396 <type>.access$<n>(<arg1> [, <arg2>]);
10398 ARG2 can be NULL and will be omitted in that case. It will denote a
10402 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10404 tree type, access_method_name, arg1, arg2;
10406 tree args, cn, access;
10408 args = arg1 ? arg1 :
10409 build_wfl_node (build_current_thisn (current_class));
10410 args = build_tree_list (NULL_TREE, args);
10413 args = tree_cons (NULL_TREE, arg2, args);
10415 access = build_method_invocation (build_wfl_node (access_method_name), args);
10416 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10417 return make_qualified_primary (cn, access, lc);
10421 build_new_access_id ()
10423 static int access_n_counter = 1;
10426 sprintf (buffer, "access$%d", access_n_counter++);
10427 return get_identifier (buffer);
10430 /* Create the static access functions for the outer field DECL. We define a
10432 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10433 return inst$.field;
10435 and a write access:
10436 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10437 TREE_TYPE (<field>) value$) {
10438 return inst$.field = value$;
10440 We should have a usage flags on the DECL so we can lazily turn the ones
10441 we're using for code generation. FIXME.
10445 build_outer_field_access_methods (decl)
10448 tree id, args, stmt, mdecl;
10450 /* Check point, to be removed. FIXME */
10451 if (FIELD_INNER_ACCESS (decl)
10452 && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10455 if (FIELD_INNER_ACCESS (decl))
10456 return FIELD_INNER_ACCESS (decl);
10458 push_obstacks (&permanent_obstack, &permanent_obstack);
10460 /* Create the identifier and a function named after it. */
10461 id = build_new_access_id ();
10463 /* The identifier is marked as bearing the name of a generated write
10464 access function for outer field accessed from inner classes. */
10465 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10467 /* Create the read access */
10468 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10469 TREE_CHAIN (args) = end_params_node;
10470 stmt = make_qualified_primary (build_wfl_node (inst_id),
10471 build_wfl_node (DECL_NAME (decl)), 0);
10472 stmt = build_return (0, stmt);
10473 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10474 TREE_TYPE (decl), id, args, stmt);
10475 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10477 /* Create the write access method */
10478 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10479 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10480 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10481 stmt = make_qualified_primary (build_wfl_node (inst_id),
10482 build_wfl_node (DECL_NAME (decl)), 0);
10483 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10484 build_wfl_node (wpv_id)));
10486 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10487 TREE_TYPE (decl), id, args, stmt);
10488 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10491 /* Return the access name */
10492 return FIELD_INNER_ACCESS (decl) = id;
10495 /* Build an field access method NAME. */
10498 build_outer_field_access_method (class, type, name, args, body)
10499 tree class, type, name, args, body;
10501 tree saved_current_function_decl, mdecl;
10503 /* Create the method */
10504 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10505 fix_method_argument_names (args, mdecl);
10506 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10508 /* Attach the method body. */
10509 saved_current_function_decl = current_function_decl;
10510 start_artificial_method_body (mdecl);
10511 java_method_add_stmt (mdecl, body);
10512 end_artificial_method_body (mdecl);
10513 current_function_decl = saved_current_function_decl;
10519 /* This section deals with building access function necessary for
10520 certain kinds of method invocation from inner classes. */
10523 build_outer_method_access_method (decl)
10526 tree saved_current_function_decl, mdecl;
10527 tree args = NULL_TREE, call_args = NULL_TREE;
10528 tree carg, id, body, class;
10530 int parm_id_count = 0;
10532 /* Test this abort with an access to a private field */
10533 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10536 /* Check the cache first */
10537 if (DECL_FUNCTION_INNER_ACCESS (decl))
10538 return DECL_FUNCTION_INNER_ACCESS (decl);
10540 class = DECL_CONTEXT (decl);
10542 /* Obtain an access identifier and mark it */
10543 id = build_new_access_id ();
10544 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10546 push_obstacks (&permanent_obstack, &permanent_obstack);
10548 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10549 /* Create the arguments, as much as the original */
10550 for (; carg && carg != end_params_node;
10551 carg = TREE_CHAIN (carg))
10553 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10554 args = chainon (args, build_tree_list (get_identifier (buffer),
10555 TREE_VALUE (carg)));
10557 args = chainon (args, end_params_node);
10559 /* Create the method */
10560 mdecl = create_artificial_method (class, ACC_STATIC,
10561 TREE_TYPE (TREE_TYPE (decl)), id, args);
10562 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10563 /* There is a potential bug here. We should be able to use
10564 fix_method_argument_names, but then arg names get mixed up and
10565 eventually a constructor will have its this$0 altered and the
10566 outer context won't be assignment properly. The test case is
10568 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10570 /* Attach the method body. */
10571 saved_current_function_decl = current_function_decl;
10572 start_artificial_method_body (mdecl);
10574 /* The actual method invocation uses the same args. When invoking a
10575 static methods that way, we don't want to skip the first
10578 if (!METHOD_STATIC (decl))
10579 carg = TREE_CHAIN (carg);
10580 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10581 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10584 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
10586 if (!METHOD_STATIC (decl))
10587 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
10589 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10590 body = build_return (0, body);
10591 java_method_add_stmt (mdecl,body);
10592 end_artificial_method_body (mdecl);
10593 current_function_decl = saved_current_function_decl;
10596 /* Back tag the access function so it know what it accesses */
10597 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10599 /* Tag the current method so it knows it has an access generated */
10600 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10604 /* This section of the code deals with building expressions to access
10605 the enclosing instance of an inner class. The enclosing instance is
10606 kept in a generated field called this$<n>, with <n> being the
10607 inner class nesting level (starting from 0.) */
10609 /* Build an access to a given this$<n>, possibly by chaining access
10610 call to others. Access methods to this$<n> are build on the fly if
10614 build_access_to_thisn (from, to, lc)
10618 tree access = NULL_TREE;
10622 tree access0_wfl, cn;
10624 maybe_build_thisn_access_method (from);
10625 access0_wfl = build_wfl_node (access0_identifier_node);
10626 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10627 EXPR_WFL_LINECOL (access0_wfl) = lc;
10631 access = build_current_thisn (current_class);
10632 access = build_wfl_node (access);
10634 access = build_tree_list (NULL_TREE, access);
10635 access = build_method_invocation (access0_wfl, access);
10636 access = make_qualified_primary (cn, access, lc);
10638 from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10643 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10644 is returned if nothing needs to be generated. Otherwise, the method
10645 generated and a method decl is returned.
10647 NOTE: These generated methods should be declared in a class file
10648 attribute so that they can't be referred to directly. */
10651 maybe_build_thisn_access_method (type)
10654 tree mdecl, args, stmt, rtype;
10655 tree saved_current_function_decl;
10657 /* If TYPE is a top-level class, no access method is required.
10658 If there already is such an access method, bail out. */
10659 if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10662 /* We generate the method. The method looks like:
10663 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10665 push_obstacks (&permanent_obstack, &permanent_obstack);
10666 args = build_tree_list (inst_id, build_pointer_type (type));
10667 TREE_CHAIN (args) = end_params_node;
10668 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10669 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10670 access0_identifier_node, args);
10671 fix_method_argument_names (args, mdecl);
10672 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10673 stmt = build_current_thisn (type);
10674 stmt = make_qualified_primary (build_wfl_node (inst_id),
10675 build_wfl_node (stmt), 0);
10676 stmt = build_return (0, stmt);
10678 saved_current_function_decl = current_function_decl;
10679 start_artificial_method_body (mdecl);
10680 java_method_add_stmt (mdecl, stmt);
10681 end_artificial_method_body (mdecl);
10682 current_function_decl = saved_current_function_decl;
10685 CLASS_ACCESS0_GENERATED_P (type) = 1;
10690 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10691 the first level of innerclassing. this$1 for the next one, etc...
10692 This function can be invoked with TYPE to NULL, available and then
10693 has to count the parser context. */
10696 build_current_thisn (type)
10699 static int saved_i = -1;
10700 static tree saved_thisn = NULL_TREE;
10708 static tree saved_type = NULL_TREE;
10709 static int saved_type_i = 0;
10711 if (type == saved_type)
10715 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
10716 decl; decl = DECL_CONTEXT (decl), i++)
10724 i = list_length (GET_CPC_LIST ())-2;
10727 return saved_thisn;
10729 sprintf (buffer, "this$%d", i);
10731 saved_thisn = get_identifier (buffer);
10732 return saved_thisn;
10735 /* Return the assignement to the hidden enclosing context `this$<n>'
10736 by the second incoming parameter to the innerclass constructor. The
10737 form used is `this.this$<n> = this$<n>;'. */
10740 build_thisn_assign ()
10742 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10744 tree thisn = build_current_thisn (current_class);
10745 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10746 build_wfl_node (thisn), 0);
10747 tree rhs = build_wfl_node (thisn);
10748 EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10749 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10755 /* Building the synthetic `class$' used to implement the `.class' 1.1
10756 extension for non primitive types. This method looks like:
10758 static Class class$(String type) throws NoClassDefFoundError
10760 try {return (java.lang.Class.forName (String));}
10761 catch (ClassNotFoundException e) {
10762 throw new NoClassDefFoundError(e.getMessage());}
10766 build_dot_class_method (class)
10769 #define BWF(S) build_wfl_node (get_identifier ((S)))
10770 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10771 tree args, tmp, saved_current_function_decl, mdecl;
10772 tree stmt, throw_stmt, catch, catch_block, try_block;
10773 tree catch_clause_param;
10774 tree class_not_found_exception, no_class_def_found_error;
10776 static tree get_message_wfl, type_parm_wfl;
10778 if (!get_message_wfl)
10780 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10781 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10784 /* Build the arguments */
10785 args = build_tree_list (get_identifier ("type$"),
10786 build_pointer_type (string_type_node));
10787 TREE_CHAIN (args) = end_params_node;
10789 /* Build the qualified name java.lang.Class.forName */
10790 tmp = MQN (MQN (MQN (BWF ("java"),
10791 BWF ("lang")), BWF ("Class")), BWF ("forName"));
10793 /* For things we have to catch and throw */
10794 class_not_found_exception =
10795 lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10796 no_class_def_found_error =
10797 lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10798 load_class (class_not_found_exception, 1);
10799 load_class (no_class_def_found_error, 1);
10801 /* Create the "class$" function */
10802 mdecl = create_artificial_method (class, ACC_STATIC,
10803 build_pointer_type (class_type_node),
10804 get_identifier ("class$"), args);
10805 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10806 no_class_def_found_error);
10808 /* We start by building the try block. We need to build:
10809 return (java.lang.Class.forName (type)); */
10810 stmt = build_method_invocation (tmp,
10811 build_tree_list (NULL_TREE, type_parm_wfl));
10812 stmt = build_return (0, stmt);
10813 /* Put it in a block. That's the try block */
10814 try_block = build_expr_block (stmt, NULL_TREE);
10816 /* Now onto the catch block. We start by building the expression
10817 throwing a new exception:
10818 throw new NoClassDefFoundError (_.getMessage); */
10819 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
10820 get_message_wfl, 0);
10821 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10823 /* Build new NoClassDefFoundError (_.getMessage) */
10824 throw_stmt = build_new_invocation
10825 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10826 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10828 /* Build the throw, (it's too early to use BUILD_THROW) */
10829 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10831 /* Build the catch block to encapsulate all this. We begin by
10832 building an decl for the catch clause parameter and link it to
10833 newly created block, the catch block. */
10834 catch_clause_param =
10835 build_decl (VAR_DECL, wpv_id,
10836 build_pointer_type (class_not_found_exception));
10837 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10839 /* We initialize the variable with the exception handler. */
10840 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10841 soft_exceptioninfo_call_node);
10842 add_stmt_to_block (catch_block, NULL_TREE, catch);
10844 /* We add the statement throwing the new exception */
10845 add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10847 /* Build a catch expression for all this */
10848 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10850 /* Build the try/catch sequence */
10851 stmt = build_try_statement (0, try_block, catch_block);
10853 fix_method_argument_names (args, mdecl);
10854 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10855 saved_current_function_decl = current_function_decl;
10856 start_artificial_method_body (mdecl);
10857 java_method_add_stmt (mdecl, stmt);
10858 end_artificial_method_body (mdecl);
10859 current_function_decl = saved_current_function_decl;
10860 TYPE_DOT_CLASS (class) = mdecl;
10866 build_dot_class_method_invocation (name)
10869 tree s = make_node (STRING_CST);
10870 TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10871 TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10872 TREE_STRING_LENGTH (s)+1);
10873 strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10874 return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10875 build_tree_list (NULL_TREE, s));
10878 /* This section of the code deals with constructor. */
10880 /* Craft a body for default constructor. Patch existing constructor
10881 bodies with call to super() and field initialization statements if
10885 fix_constructors (mdecl)
10888 tree body = DECL_FUNCTION_BODY (mdecl);
10889 tree thisn_assign, compound = NULL_TREE;
10890 tree class_type = DECL_CONTEXT (mdecl);
10894 /* It is an error for the compiler to generate a default
10895 constructor if the superclass doesn't have a constructor that
10896 takes no argument, or the same args for an anonymous class */
10897 if (verify_constructor_super (mdecl))
10899 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10900 tree save = DECL_NAME (mdecl);
10901 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10902 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10903 parse_error_context
10904 (lookup_cl (TYPE_NAME (class_type)),
10905 "No constructor matching `%s' found in class `%s'",
10906 lang_printable_name (mdecl, 0), n);
10907 DECL_NAME (mdecl) = save;
10910 /* The constructor body must be crafted by hand. It's the
10911 constructor we defined when we realize we didn't have the
10912 CLASSNAME() constructor */
10913 start_artificial_method_body (mdecl);
10915 /* We don't generate a super constructor invocation if we're
10916 compiling java.lang.Object. build_super_invocation takes care
10918 compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10920 /* Insert the instance initializer block right here, after the
10921 super invocation. */
10922 add_instance_initializer (mdecl);
10924 /* Insert an assignment to the this$<n> hidden field, if
10926 if ((thisn_assign = build_thisn_assign ()))
10927 java_method_add_stmt (mdecl, thisn_assign);
10929 end_artificial_method_body (mdecl);
10931 /* Search for an explicit constructor invocation */
10935 tree main_block = BLOCK_EXPR_BODY (body);
10938 switch (TREE_CODE (body))
10941 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10944 case COMPOUND_EXPR:
10945 case EXPR_WITH_FILE_LOCATION:
10946 body = TREE_OPERAND (body, 0);
10949 body = BLOCK_EXPR_BODY (body);
10955 /* The constructor is missing an invocation of super() */
10957 compound = add_stmt_to_compound (compound, NULL_TREE,
10958 build_super_invocation (mdecl));
10960 /* Insert the instance initializer block right here, after the
10961 super invocation. */
10962 add_instance_initializer (mdecl);
10964 /* Generate the assignment to this$<n>, if necessary */
10965 if ((thisn_assign = build_thisn_assign ()))
10966 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10968 /* Fix the constructor main block if we're adding extra stmts */
10971 compound = add_stmt_to_compound (compound, NULL_TREE,
10972 BLOCK_EXPR_BODY (main_block));
10973 BLOCK_EXPR_BODY (main_block) = compound;
10978 /* Browse constructors in the super class, searching for a constructor
10979 that doesn't take any argument. Return 0 if one is found, 1
10980 otherwise. If the current class is an anonymous inner class, look
10981 for something that has the same signature. */
10984 verify_constructor_super (mdecl)
10987 tree class = CLASSTYPE_SUPER (current_class);
10988 int super_inner = PURE_INNER_CLASS_TYPE_P (class);
10994 if (ANONYMOUS_CLASS_P (current_class))
10996 tree mdecl_arg_type;
10997 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10998 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10999 if (DECL_CONSTRUCTOR_P (sdecl))
11001 tree arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11003 arg_type = TREE_CHAIN (arg_type);
11004 for (; (arg_type != end_params_node
11005 && mdecl_arg_type != end_params_node);
11006 arg_type = TREE_CHAIN (arg_type),
11007 mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
11008 if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
11011 if (arg_type == end_params_node &&
11012 mdecl_arg_type == end_params_node)
11018 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11020 tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11022 arg = TREE_CHAIN (arg);
11023 if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
11030 /* Generate code for all context remembered for code generation. */
11033 java_expand_classes ()
11035 int save_error_count = 0;
11036 static struct parser_ctxt *saved_ctxp = NULL;
11038 java_parse_abort_on_error ();
11039 if (!(ctxp = ctxp_for_generation))
11041 java_layout_classes ();
11042 java_parse_abort_on_error ();
11044 /* The list of packages declaration seen so far needs to be
11045 reversed, so that package declared in a file being compiled gets
11046 priority over packages declared as a side effect of parsing other
11048 package_list = nreverse (package_list);
11050 saved_ctxp = ctxp_for_generation;
11051 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11053 ctxp = ctxp_for_generation;
11054 lang_init_source (2); /* Error msgs have method prototypes */
11055 java_complete_expand_classes (); /* Complete and expand classes */
11056 java_parse_abort_on_error ();
11059 /* Find anonymous classes and expand their constructor, now they
11060 have been fixed. */
11061 for (ctxp_for_generation = saved_ctxp;
11062 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11065 ctxp = ctxp_for_generation;
11066 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11068 current_class = TREE_TYPE (current);
11069 if (ANONYMOUS_CLASS_P (current_class))
11072 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
11074 if (DECL_CONSTRUCTOR_P (d))
11076 restore_line_number_status (1);
11077 reset_method_name (d);
11078 java_complete_expand_method (d);
11079 restore_line_number_status (0);
11080 break; /* We now there are no other ones */
11087 /* If we've found error at that stage, don't try to generate
11088 anything, unless we're emitting xrefs or checking the syntax only
11089 (but not using -fsyntax-only for the purpose of generating
11091 if (java_error_count && !flag_emit_xref
11092 && (!flag_syntax_only && !flag_emit_class_files))
11095 /* Now things are stable, go for generation of the class data. */
11096 for (ctxp_for_generation = saved_ctxp;
11097 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11100 ctxp = ctxp_for_generation;
11101 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11103 current_class = TREE_TYPE (current);
11104 outgoing_cpool = TYPE_CPOOL (current_class);
11105 if (flag_emit_class_files)
11106 write_classfile (current_class);
11107 if (flag_emit_xref)
11108 expand_xref (current_class);
11109 else if (! flag_syntax_only)
11115 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11116 a tree list node containing RIGHT. Fore coming RIGHTs will be
11117 chained to this hook. LOCATION contains the location of the
11118 separating `.' operator. */
11121 make_qualified_primary (primary, right, location)
11122 tree primary, right;
11127 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11128 wfl = build_wfl_wrap (primary);
11132 /* If wfl wasn't qualified, we build a first anchor */
11133 if (!EXPR_WFL_QUALIFICATION (wfl))
11134 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11137 /* And chain them */
11138 EXPR_WFL_LINECOL (right) = location;
11139 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11140 PRIMARY_P (wfl) = 1;
11144 /* Simple merge of two name separated by a `.' */
11147 merge_qualified_name (left, right)
11151 if (!left && !right)
11160 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11161 IDENTIFIER_LENGTH (left));
11162 obstack_1grow (&temporary_obstack, '.');
11163 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11164 IDENTIFIER_LENGTH (right));
11165 node = get_identifier (obstack_base (&temporary_obstack));
11166 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11167 QUALIFIED_P (node) = 1;
11171 /* Merge the two parts of a qualified name into LEFT. Set the
11172 location information of the resulting node to LOCATION, usually
11173 inherited from the location information of the `.' operator. */
11176 make_qualified_name (left, right, location)
11180 #ifdef USE_COMPONENT_REF
11181 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11182 EXPR_WFL_LINECOL (node) = location;
11185 tree left_id = EXPR_WFL_NODE (left);
11186 tree right_id = EXPR_WFL_NODE (right);
11189 merge = merge_qualified_name (left_id, right_id);
11191 /* Left wasn't qualified and is now qualified */
11192 if (!QUALIFIED_P (left_id))
11194 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11195 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11196 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11199 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11200 EXPR_WFL_LINECOL (wfl) = location;
11201 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11203 EXPR_WFL_NODE (left) = merge;
11208 /* Extract the last identifier component of the qualified in WFL. The
11209 last identifier is removed from the linked list */
11212 cut_identifier_in_qualified (wfl)
11216 tree previous = NULL_TREE;
11217 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11218 if (!TREE_CHAIN (q))
11221 fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11222 TREE_CHAIN (previous) = NULL_TREE;
11223 return TREE_PURPOSE (q);
11227 /* Resolve the expression name NAME. Return its decl. */
11230 resolve_expression_name (id, orig)
11234 tree name = EXPR_WFL_NODE (id);
11237 /* 6.5.5.1: Simple expression names */
11238 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11240 /* 15.13.1: NAME can appear within the scope of a local variable
11242 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11245 /* 15.13.1: NAME can appear within a class declaration */
11248 decl = lookup_field_wrapper (current_class, name);
11251 tree access = NULL_TREE;
11252 int fs = FIELD_STATIC (decl);
11254 /* If we're accessing an outer scope local alias, make
11255 sure we change the name of the field we're going to
11256 build access to. */
11257 if (FIELD_LOCAL_ALIAS_USED (decl))
11258 name = DECL_NAME (decl);
11260 /* Instance variable (8.3.1.1) can't appear within
11261 static method, static initializer or initializer for
11262 a static variable. */
11263 if (!fs && METHOD_STATIC (current_function_decl))
11265 static_ref_err (id, name, current_class);
11266 return error_mark_node;
11268 /* Instance variables can't appear as an argument of
11269 an explicit constructor invocation */
11270 if (!fs && ctxp->explicit_constructor_p)
11272 parse_error_context
11273 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11274 return error_mark_node;
11277 /* If we're processing an inner class and we're trying
11278 to access a field belonging to an outer class, build
11279 the access to the field */
11280 if (!fs && outer_field_access_p (current_class, decl))
11281 return build_outer_field_access (id, decl);
11283 /* Otherwise build what it takes to access the field */
11284 access = build_field_ref ((fs ? NULL_TREE : current_this),
11285 DECL_CONTEXT (decl), name);
11286 if (fs && !flag_emit_class_files && !flag_emit_xref)
11287 access = build_class_init (DECL_CONTEXT (access), access);
11288 /* We may be asked to save the real field access node */
11291 /* And we return what we got */
11294 /* Fall down to error report on undefined variable */
11297 /* 6.5.5.2 Qualified Expression Names */
11302 qualify_ambiguous_name (id);
11303 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11304 /* 15.10.2: Accessing Superclass Members using super */
11305 return resolve_field_access (id, orig, NULL);
11308 /* We've got an error here */
11309 parse_error_context (id, "Undefined variable `%s'",
11310 IDENTIFIER_POINTER (name));
11312 return error_mark_node;
11316 static_ref_err (wfl, field_id, class_type)
11317 tree wfl, field_id, class_type;
11319 parse_error_context
11321 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11322 IDENTIFIER_POINTER (field_id),
11323 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11326 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11327 We return something suitable to generate the field access. We also
11328 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
11329 recipient's address can be null. */
11332 resolve_field_access (qual_wfl, field_decl, field_type)
11334 tree *field_decl, *field_type;
11338 tree decl, where_found, type_found;
11340 if (resolve_qualified_expression_name (qual_wfl, &decl,
11341 &where_found, &type_found))
11342 return error_mark_node;
11344 /* Resolve the LENGTH field of an array here */
11345 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11346 && ! flag_emit_class_files && ! flag_emit_xref)
11348 tree length = build_java_array_length_access (where_found);
11350 build_java_arraynull_check (type_found, length, int_type_node);
11352 /* We might have been trying to resolve field.method(). In which
11353 case, the resolution is over and decl is the answer */
11354 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11356 else if (JDECL_P (decl))
11358 int static_final_found = 0;
11360 type_found = DECL_CONTEXT (decl);
11361 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11362 if (FIELD_FINAL (decl)
11363 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11364 && DECL_INITIAL (decl))
11366 field_ref = java_complete_tree (DECL_INITIAL (decl));
11367 static_final_found = 1;
11370 field_ref = build_field_ref ((is_static && !flag_emit_xref?
11371 NULL_TREE : where_found),
11372 type_found, DECL_NAME (decl));
11373 if (field_ref == error_mark_node)
11374 return error_mark_node;
11375 if (is_static && !static_final_found
11376 && !flag_emit_class_files && !flag_emit_xref)
11377 field_ref = build_class_init (DECL_CONTEXT (decl), field_ref);
11383 *field_decl = decl;
11385 *field_type = (QUAL_DECL_TYPE (decl) ?
11386 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11390 /* If NODE is an access to f static field, strip out the class
11391 initialization part and return the field decl, otherwise, return
11395 strip_out_static_field_access_decl (node)
11398 if (TREE_CODE (node) == COMPOUND_EXPR)
11400 tree op1 = TREE_OPERAND (node, 1);
11401 if (TREE_CODE (op1) == COMPOUND_EXPR)
11403 tree call = TREE_OPERAND (op1, 0);
11404 if (TREE_CODE (call) == CALL_EXPR
11405 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11406 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11407 == soft_initclass_node)
11408 return TREE_OPERAND (op1, 1);
11410 else if (JDECL_P (op1))
11416 /* 6.5.5.2: Qualified Expression Names */
11419 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11421 tree *found_decl, *type_found, *where_found;
11423 int from_type = 0; /* Field search initiated from a type */
11424 int from_super = 0, from_cast = 0, from_qualified_this = 0;
11425 int previous_call_static = 0;
11427 tree decl = NULL_TREE, type = NULL_TREE, q;
11428 /* For certain for of inner class instantiation */
11429 tree saved_current, saved_this;
11430 #define RESTORE_THIS_AND_CURRENT_CLASS \
11431 { current_class = saved_current; current_this = saved_this;}
11433 *type_found = *where_found = NULL_TREE;
11435 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11437 tree qual_wfl = QUAL_WFL (q);
11438 tree ret_decl; /* for EH checking */
11439 int location; /* for EH checking */
11441 /* 15.10.1 Field Access Using a Primary */
11442 switch (TREE_CODE (qual_wfl))
11445 case NEW_CLASS_EXPR:
11446 /* If the access to the function call is a non static field,
11447 build the code to access it. */
11448 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11450 decl = maybe_access_field (decl, *where_found,
11451 DECL_CONTEXT (decl));
11452 if (decl == error_mark_node)
11456 /* And code for the function call */
11457 if (complete_function_arguments (qual_wfl))
11460 /* We might have to setup a new current class and a new this
11461 for the search of an inner class, relative to the type of
11462 a expression resolved as `decl'. The current values are
11463 saved and restored shortly after */
11464 saved_current = current_class;
11465 saved_this = current_this;
11466 if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11468 current_class = type;
11469 current_this = decl;
11472 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11473 CALL_USING_SUPER (qual_wfl) = 1;
11474 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11475 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11476 *where_found = patch_method_invocation (qual_wfl, decl, type,
11477 &is_static, &ret_decl);
11478 if (*where_found == error_mark_node)
11480 RESTORE_THIS_AND_CURRENT_CLASS;
11483 *type_found = type = QUAL_DECL_TYPE (*where_found);
11485 /* If we're creating an inner class instance, check for that
11486 an enclosing instance is in scope */
11487 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11488 && INNER_ENCLOSING_SCOPE_CHECK (type))
11490 parse_error_context
11491 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11492 lang_printable_name (type, 0),
11493 (!current_this ? "" :
11494 "; an explicit one must be provided when creating this inner class"));
11495 RESTORE_THIS_AND_CURRENT_CLASS;
11499 /* In case we had to change then to resolve a inner class
11500 instantiation using a primary qualified by a `new' */
11501 RESTORE_THIS_AND_CURRENT_CLASS;
11505 check_thrown_exceptions (location, ret_decl);
11507 /* If the previous call was static and this one is too,
11508 build a compound expression to hold the two (because in
11509 that case, previous function calls aren't transported as
11510 forcoming function's argument. */
11511 if (previous_call_static && is_static)
11513 decl = build (COMPOUND_EXPR, type, decl, *where_found);
11514 TREE_SIDE_EFFECTS (decl) = 1;
11518 previous_call_static = is_static;
11519 decl = *where_found;
11524 case NEW_ARRAY_EXPR:
11525 case NEW_ANONYMOUS_ARRAY_EXPR:
11526 *where_found = decl = java_complete_tree (qual_wfl);
11527 if (decl == error_mark_node)
11529 *type_found = type = QUAL_DECL_TYPE (decl);
11530 CLASS_LOADED_P (type) = 1;
11534 *where_found = decl = java_complete_tree (qual_wfl);
11535 if (decl == error_mark_node)
11537 *type_found = type = QUAL_DECL_TYPE (decl);
11541 case CONDITIONAL_EXPR:
11544 *where_found = decl = java_complete_tree (qual_wfl);
11545 if (decl == error_mark_node)
11547 *type_found = type = QUAL_DECL_TYPE (decl);
11551 /* If the access to the function call is a non static field,
11552 build the code to access it. */
11553 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11555 decl = maybe_access_field (decl, *where_found, type);
11556 if (decl == error_mark_node)
11559 /* And code for the array reference expression */
11560 decl = java_complete_tree (qual_wfl);
11561 if (decl == error_mark_node)
11563 type = QUAL_DECL_TYPE (decl);
11567 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11569 if ((type = patch_string (decl)))
11571 *where_found = QUAL_RESOLUTION (q) = decl;
11572 *type_found = type = TREE_TYPE (decl);
11575 case CLASS_LITERAL:
11576 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11578 *where_found = QUAL_RESOLUTION (q) = decl;
11579 *type_found = type = TREE_TYPE (decl);
11583 /* Fix for -Wall Just go to the next statement. Don't
11588 /* If we fall here, we weren't processing a (static) function call. */
11589 previous_call_static = 0;
11591 /* It can be the keyword THIS */
11592 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11596 parse_error_context
11597 (wfl, "Keyword `this' used outside allowed context");
11600 if (ctxp->explicit_constructor_p)
11602 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11605 /* We have to generate code for intermediate acess */
11606 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11608 *where_found = decl = current_this;
11609 *type_found = type = QUAL_DECL_TYPE (decl);
11611 /* We're trying to access the this from somewhere else... */
11614 *where_found = decl = build_current_thisn (type);
11615 from_qualified_this = 1;
11622 /* 15.10.2 Accessing Superclass Members using SUPER */
11623 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11626 /* Check on the restricted use of SUPER */
11627 if (METHOD_STATIC (current_function_decl)
11628 || current_class == object_type_node)
11630 parse_error_context
11631 (wfl, "Keyword `super' used outside allowed context");
11634 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11635 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
11636 CLASSTYPE_SUPER (current_class),
11637 build_this (EXPR_WFL_LINECOL (qual_wfl)));
11638 *where_found = decl = java_complete_tree (node);
11639 if (decl == error_mark_node)
11641 *type_found = type = QUAL_DECL_TYPE (decl);
11642 from_super = from_type = 1;
11646 /* 15.13.1: Can't search for field name in packages, so we
11647 assume a variable/class name was meant. */
11648 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11650 tree name = resolve_package (wfl, &q);
11654 *where_found = decl = resolve_no_layout (name, qual_wfl);
11655 /* We want to be absolutely sure that the class is laid
11656 out. We're going to search something inside it. */
11657 *type_found = type = TREE_TYPE (decl);
11658 layout_class (type);
11661 /* Fix them all the way down, if any are left. */
11664 list = TREE_CHAIN (q);
11667 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11668 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11669 list = TREE_CHAIN (list);
11675 if (from_super || from_cast)
11676 parse_error_context
11677 ((from_cast ? qual_wfl : wfl),
11678 "No variable `%s' defined in class `%s'",
11679 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11680 lang_printable_name (type, 0));
11682 parse_error_context
11683 (qual_wfl, "Undefined variable or class name: `%s'",
11684 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11689 /* We have a type name. It's been already resolved when the
11690 expression was qualified. */
11691 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11693 if (!(decl = QUAL_RESOLUTION (q)))
11694 return 1; /* Error reported already */
11696 /* Sneak preview. If next we see a `new', we're facing a
11697 qualification with resulted in a type being selected
11698 instead of a field. Report the error */
11700 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11702 parse_error_context (qual_wfl, "Undefined variable `%s'",
11703 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11707 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11709 parse_error_context
11710 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11711 java_accstring_lookup (get_access_flags_from_decl (decl)),
11712 GET_TYPE_NAME (type),
11713 IDENTIFIER_POINTER (DECL_NAME (decl)),
11714 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11717 check_deprecation (qual_wfl, decl);
11719 type = TREE_TYPE (decl);
11722 /* We resolve and expression name */
11725 tree field_decl = NULL_TREE;
11727 /* If there exists an early resolution, use it. That occurs
11728 only once and we know that there are more things to
11729 come. Don't do that when processing something after SUPER
11730 (we need more thing to be put in place below */
11731 if (!from_super && QUAL_RESOLUTION (q))
11733 decl = QUAL_RESOLUTION (q);
11736 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11739 *where_found = current_this;
11742 static_ref_err (qual_wfl, DECL_NAME (decl),
11749 *where_found = TREE_TYPE (decl);
11750 if (TREE_CODE (*where_found) == POINTER_TYPE)
11751 *where_found = TREE_TYPE (*where_found);
11756 /* We have to search for a field, knowing the type of its
11757 container. The flag FROM_TYPE indicates that we resolved
11758 the last member of the expression as a type name, which
11759 means that for the resolution of this field, we'll look
11760 for other errors than if it was resolved as a member of
11765 tree field_decl_type; /* For layout */
11767 if (!from_type && !JREFERENCE_TYPE_P (type))
11769 parse_error_context
11770 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11771 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11772 lang_printable_name (type, 0),
11773 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11777 field_decl = lookup_field_wrapper (type,
11778 EXPR_WFL_NODE (qual_wfl));
11779 if (field_decl == NULL_TREE)
11781 parse_error_context
11782 (qual_wfl, "No variable `%s' defined in type `%s'",
11783 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11784 GET_TYPE_NAME (type));
11787 if (field_decl == error_mark_node)
11790 /* Layout the type of field_decl, since we may need
11791 it. Don't do primitive types or loaded classes. The
11792 situation of non primitive arrays may not handled
11793 properly here. FIXME */
11794 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11795 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11797 field_decl_type = TREE_TYPE (field_decl);
11798 if (!JPRIMITIVE_TYPE_P (field_decl_type)
11799 && !CLASS_LOADED_P (field_decl_type)
11800 && !TYPE_ARRAY_P (field_decl_type))
11801 resolve_and_layout (field_decl_type, NULL_TREE);
11802 if (TYPE_ARRAY_P (field_decl_type))
11803 CLASS_LOADED_P (field_decl_type) = 1;
11805 /* Check on accessibility here */
11806 if (not_accessible_p (type, field_decl, from_super))
11808 parse_error_context
11810 "Can't access %s field `%s.%s' from `%s'",
11811 java_accstring_lookup
11812 (get_access_flags_from_decl (field_decl)),
11813 GET_TYPE_NAME (type),
11814 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11816 (DECL_NAME (TYPE_NAME (current_class))));
11819 check_deprecation (qual_wfl, field_decl);
11821 /* There are things to check when fields are accessed
11822 from type. There are no restrictions on a static
11823 declaration of the field when it is accessed from an
11825 is_static = FIELD_STATIC (field_decl);
11826 if (!from_super && from_type
11827 && !TYPE_INTERFACE_P (type)
11829 && (current_function_decl
11830 && METHOD_STATIC (current_function_decl)))
11832 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11835 from_cast = from_super = 0;
11837 /* It's an access from a type but it isn't static, we
11838 make it relative to `this'. */
11839 if (!is_static && from_type)
11840 decl = current_this;
11842 /* If we need to generate something to get a proper
11843 handle on what this field is accessed from, do it
11847 decl = maybe_access_field (decl, *where_found, *type_found);
11848 if (decl == error_mark_node)
11852 /* We want to keep the location were found it, and the type
11854 *where_found = decl;
11855 *type_found = type;
11857 /* Generate the correct expression for field access from
11859 if (from_qualified_this)
11861 field_decl = build_outer_field_access (qual_wfl, field_decl);
11862 from_qualified_this = 0;
11865 /* This is the decl found and eventually the next one to
11870 type = QUAL_DECL_TYPE (decl);
11872 /* Sneak preview. If decl is qualified by a `new', report
11873 the error here to be accurate on the peculiar construct */
11875 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11876 && !JREFERENCE_TYPE_P (type))
11878 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
11879 lang_printable_name (type, 0));
11883 /* `q' might have changed due to a after package resolution
11884 re-qualification */
11888 *found_decl = decl;
11892 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11893 can't be accessed from REFERENCE (a record type). */
11896 not_accessible_p (reference, member, from_super)
11897 tree reference, member;
11900 int access_flag = get_access_flags_from_decl (member);
11902 /* Access always granted for members declared public */
11903 if (access_flag & ACC_PUBLIC)
11906 /* Check access on protected members */
11907 if (access_flag & ACC_PROTECTED)
11909 /* Access granted if it occurs from within the package
11910 containing the class in which the protected member is
11912 if (class_in_current_package (DECL_CONTEXT (member)))
11915 /* If accessed with the form `super.member', then access is granted */
11919 /* Otherwise, access is granted if occuring from the class where
11920 member is declared or a subclass of it */
11921 if (inherits_from_p (reference, DECL_CONTEXT (member)))
11926 /* Check access on private members. Access is granted only if it
11927 occurs from within the class in which it is declared. Exceptions
11928 are accesses from inner-classes. This section is probably not
11930 if (access_flag & ACC_PRIVATE)
11931 return (current_class == DECL_CONTEXT (member) ? 0 :
11932 (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11934 /* Default access are permitted only when occuring within the
11935 package in which the type (REFERENCE) is declared. In other words,
11936 REFERENCE is defined in the current package */
11938 return !class_in_current_package (reference);
11940 /* Otherwise, access is granted */
11944 /* Test deprecated decl access. */
11946 check_deprecation (wfl, decl)
11949 const char *file = DECL_SOURCE_FILE (decl);
11950 /* Complain if the field is deprecated and the file it was defined
11951 in isn't compiled at the same time the file which contains its
11953 if (DECL_DEPRECATED (decl)
11954 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11957 switch (TREE_CODE (decl))
11959 case FUNCTION_DECL:
11960 strcpy (the, "method");
11963 strcpy (the, "field");
11966 strcpy (the, "class");
11969 fatal ("unexpected DECL code - check_deprecation");
11971 parse_warning_context
11972 (wfl, "The %s `%s' in class `%s' has been deprecated",
11973 the, lang_printable_name (decl, 0),
11974 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11978 /* Returns 1 if class was declared in the current package, 0 otherwise */
11981 class_in_current_package (class)
11984 static tree cache = NULL_TREE;
11985 int qualified_flag;
11988 if (cache == class)
11991 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11993 /* If the current package is empty and the name of CLASS is
11994 qualified, class isn't in the current package. If there is a
11995 current package and the name of the CLASS is not qualified, class
11996 isn't in the current package */
11997 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
12000 /* If there is not package and the name of CLASS isn't qualified,
12001 they belong to the same unnamed package */
12002 if (!ctxp->package && !qualified_flag)
12005 /* Compare the left part of the name of CLASS with the package name */
12006 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
12007 if (ctxp->package == left)
12015 /* This function may generate code to access DECL from WHERE. This is
12016 done only if certain conditions meet. */
12019 maybe_access_field (decl, where, type)
12020 tree decl, where, type;
12022 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
12023 && !FIELD_STATIC (decl))
12024 decl = build_field_ref (where ? where : current_this,
12025 (type ? type : DECL_CONTEXT (decl)),
12030 /* Build a method invocation, by patching PATCH. If non NULL
12031 and according to the situation, PRIMARY and WHERE may be
12032 used. IS_STATIC is set to 1 if the invoked function is static. */
12035 patch_method_invocation (patch, primary, where, is_static, ret_decl)
12036 tree patch, primary, where;
12040 tree wfl = TREE_OPERAND (patch, 0);
12041 tree args = TREE_OPERAND (patch, 1);
12042 tree name = EXPR_WFL_NODE (wfl);
12044 int is_static_flag = 0;
12045 int is_super_init = 0;
12046 tree this_arg = NULL_TREE;
12048 /* Should be overriden if everything goes well. Otherwise, if
12049 something fails, it should keep this value. It stop the
12050 evaluation of a bogus assignment. See java_complete_tree,
12051 MODIFY_EXPR: for the reasons why we sometimes want to keep on
12052 evaluating an assignment */
12053 TREE_TYPE (patch) = error_mark_node;
12055 /* Since lookup functions are messing with line numbers, save the
12057 java_parser_context_save_global ();
12059 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
12061 /* Resolution of qualified name, excluding constructors */
12062 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
12064 tree identifier, identifier_wfl, type, resolved;
12065 /* Extract the last IDENTIFIER of the qualified
12066 expression. This is a wfl and we will use it's location
12067 data during error report. */
12068 identifier_wfl = cut_identifier_in_qualified (wfl);
12069 identifier = EXPR_WFL_NODE (identifier_wfl);
12071 /* Given the context, IDENTIFIER is syntactically qualified
12072 as a MethodName. We need to qualify what's before */
12073 qualify_ambiguous_name (wfl);
12074 resolved = resolve_field_access (wfl, NULL, NULL);
12076 if (resolved == error_mark_node)
12077 PATCH_METHOD_RETURN_ERROR ();
12079 type = GET_SKIP_TYPE (resolved);
12080 resolve_and_layout (type, NULL_TREE);
12081 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12082 args = nreverse (args);
12084 /* We're resolving a call from a type */
12085 if (TREE_CODE (resolved) == TYPE_DECL)
12087 if (CLASS_INTERFACE (resolved))
12089 parse_error_context
12091 "Can't make static reference to method `%s' in interface `%s'",
12092 IDENTIFIER_POINTER (identifier),
12093 IDENTIFIER_POINTER (name));
12094 PATCH_METHOD_RETURN_ERROR ();
12096 if (list && !METHOD_STATIC (list))
12098 char *fct_name = xstrdup (lang_printable_name (list, 0));
12099 parse_error_context
12101 "Can't make static reference to method `%s %s' in class `%s'",
12102 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12103 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12105 PATCH_METHOD_RETURN_ERROR ();
12109 this_arg = primary = resolved;
12111 /* IDENTIFIER_WFL will be used to report any problem further */
12112 wfl = identifier_wfl;
12114 /* Resolution of simple names, names generated after a primary: or
12118 tree class_to_search = NULL_TREE;
12119 int lc; /* Looking for Constructor */
12121 /* We search constructor in their target class */
12122 if (CALL_CONSTRUCTOR_P (patch))
12124 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12125 class_to_search = EXPR_WFL_NODE (wfl);
12126 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12127 this_identifier_node)
12128 class_to_search = NULL_TREE;
12129 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12130 super_identifier_node)
12133 if (CLASSTYPE_SUPER (current_class))
12135 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12138 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12139 PATCH_METHOD_RETURN_ERROR ();
12143 /* Class to search is NULL if we're searching the current one */
12144 if (class_to_search)
12146 class_to_search = resolve_and_layout (class_to_search, wfl);
12148 if (!class_to_search)
12150 parse_error_context
12151 (wfl, "Class `%s' not found in type declaration",
12152 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12153 PATCH_METHOD_RETURN_ERROR ();
12156 /* Can't instantiate an abstract class, but we can
12157 invoke it's constructor. It's use within the `new'
12158 context is denied here. */
12159 if (CLASS_ABSTRACT (class_to_search)
12160 && TREE_CODE (patch) == NEW_CLASS_EXPR)
12162 parse_error_context
12163 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12164 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12165 PATCH_METHOD_RETURN_ERROR ();
12168 class_to_search = TREE_TYPE (class_to_search);
12171 class_to_search = current_class;
12174 /* This is a regular search in the local class, unless an
12175 alternate class is specified. */
12178 class_to_search = (where ? where : current_class);
12182 /* NAME is a simple identifier or comes from a primary. Search
12183 in the class whose declaration contain the method being
12185 resolve_and_layout (class_to_search, NULL_TREE);
12187 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12188 /* Don't continue if no method were found, as the next statement
12189 can't be executed then. */
12191 PATCH_METHOD_RETURN_ERROR ();
12193 /* Check for static reference if non static methods */
12194 if (check_for_static_method_reference (wfl, patch, list,
12195 class_to_search, primary))
12196 PATCH_METHOD_RETURN_ERROR ();
12198 /* Check for inner classes creation from illegal contexts */
12199 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12200 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12201 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12203 parse_error_context
12204 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12205 lang_printable_name (class_to_search, 0),
12206 (!current_this ? "" :
12207 "; an explicit one must be provided when creating this inner class"));
12208 PATCH_METHOD_RETURN_ERROR ();
12211 /* Non static methods are called with the current object extra
12212 argument. If patch a `new TYPE()', the argument is the value
12213 returned by the object allocator. If method is resolved as a
12214 primary, use the primary otherwise use the current THIS. */
12215 args = nreverse (args);
12216 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12218 this_arg = primary ? primary : current_this;
12220 /* If we're using an access method, things are different.
12221 There are two familly of cases:
12223 1) We're not generating bytecodes:
12225 - LIST is non static. It's invocation is transformed from
12226 x(a1,...,an) into this$<n>.x(a1,....an).
12227 - LIST is static. It's invocation is transformed from
12228 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12230 2) We're generating bytecodes:
12232 - LIST is non static. It's invocation is transformed from
12233 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12234 - LIST is static. It's invocation is transformed from
12235 x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12237 Of course, this$<n> can be abitrary complex, ranging from
12238 this$0 (the immediate outer context) to
12239 access$0(access$0(...(this$0))).
12241 maybe_use_access_method returns a non zero value if the
12242 this_arg has to be moved into the (then generated) stub
12243 argument list. In the mean time, the selected function
12244 might have be replaced by a generated stub. */
12245 if (maybe_use_access_method (is_super_init, &list, &this_arg))
12246 args = tree_cons (NULL_TREE, this_arg, args);
12250 /* Merge point of all resolution schemes. If we have nothing, this
12251 is an error, already signaled */
12253 PATCH_METHOD_RETURN_ERROR ();
12255 /* Check accessibility, position the is_static flag, build and
12257 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12259 char *fct_name = xstrdup (lang_printable_name (list, 0));
12260 parse_error_context
12261 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12262 java_accstring_lookup (get_access_flags_from_decl (list)),
12263 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12264 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
12265 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12267 PATCH_METHOD_RETURN_ERROR ();
12269 check_deprecation (wfl, list);
12271 /* If invoking a innerclass constructor, there are hidden parameters
12273 if (TREE_CODE (patch) == NEW_CLASS_EXPR
12274 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12276 /* And make sure we add the accessed local variables to be saved
12277 in field aliases. */
12278 args = build_alias_initializer_parameter_list
12279 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12281 /* We have to reverse things. Find out why. FIXME */
12282 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12283 args = nreverse (args);
12285 /* Secretely pass the current_this/primary as a second argument */
12286 if (primary || current_this)
12287 args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12289 args = tree_cons (NULL_TREE, integer_zero_node, args);
12292 /* This handles the situation where a constructor invocation needs
12293 to have an enclosing context passed as a second parameter (the
12294 constructor is one of an inner class. We extract it from the
12295 current function. */
12296 if (is_super_init && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12298 tree enclosing_decl = DECL_CONTEXT (TYPE_NAME (current_class));
12301 if (ANONYMOUS_CLASS_P (current_class) || !DECL_CONTEXT (enclosing_decl))
12303 extra_arg = DECL_FUNCTION_BODY (current_function_decl);
12304 extra_arg = TREE_CHAIN (BLOCK_EXPR_DECLS (extra_arg));
12308 tree dest = TREE_TYPE (DECL_CONTEXT (enclosing_decl));
12310 build_access_to_thisn (TREE_TYPE (enclosing_decl), dest, 0);
12311 extra_arg = java_complete_tree (extra_arg);
12313 args = tree_cons (NULL_TREE, extra_arg, args);
12316 is_static_flag = METHOD_STATIC (list);
12317 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12318 args = tree_cons (NULL_TREE, this_arg, args);
12320 /* In the context of an explicit constructor invocation, we can't
12321 invoke any method relying on `this'. Exceptions are: we're
12322 invoking a static function, primary exists and is not the current
12323 this, we're creating a new object. */
12324 if (ctxp->explicit_constructor_p
12326 && (!primary || primary == current_this)
12327 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12329 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12330 PATCH_METHOD_RETURN_ERROR ();
12332 java_parser_context_restore_global ();
12334 *is_static = is_static_flag;
12335 /* Sometimes, we want the decl of the selected method. Such as for
12339 patch = patch_invoke (patch, list, args);
12340 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12342 tree finit_parms, finit_call;
12344 /* Prepare to pass hidden parameters to $finit$, if any. */
12345 finit_parms = build_alias_initializer_parameter_list
12346 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12349 build_method_invocation (build_wfl_node (finit_identifier_node),
12352 /* Generate the code used to initialize fields declared with an
12353 initialization statement and build a compound statement along
12354 with the super constructor invocation. */
12355 patch = build (COMPOUND_EXPR, void_type_node, patch,
12356 java_complete_tree (finit_call));
12357 CAN_COMPLETE_NORMALLY (patch) = 1;
12362 /* Check that we're not trying to do a static reference to a method in
12363 non static method. Return 1 if it's the case, 0 otherwise. */
12366 check_for_static_method_reference (wfl, node, method, where, primary)
12367 tree wfl, node, method, where, primary;
12369 if (METHOD_STATIC (current_function_decl)
12370 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12372 char *fct_name = xstrdup (lang_printable_name (method, 0));
12373 parse_error_context
12374 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
12375 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12376 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12383 /* Fix the invocation of *MDECL if necessary in the case of a
12384 invocation from an inner class. *THIS_ARG might be modified
12385 appropriately and an alternative access to *MDECL might be
12389 maybe_use_access_method (is_super_init, mdecl, this_arg)
12391 tree *mdecl, *this_arg;
12394 tree md = *mdecl, ta = *this_arg;
12396 int non_static_context = !METHOD_STATIC (md);
12399 || DECL_CONTEXT (md) == current_class
12400 || !PURE_INNER_CLASS_TYPE_P (current_class)
12401 || DECL_FINIT_P (md))
12404 /* If we're calling a method found in an enclosing class, generate
12405 what it takes to retrieve the right this. Don't do that if we're
12406 invoking a static method. */
12408 if (non_static_context)
12410 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12411 if (ctx == DECL_CONTEXT (md))
12413 ta = build_current_thisn (current_class);
12414 ta = build_wfl_node (ta);
12421 maybe_build_thisn_access_method (type);
12422 if (type == DECL_CONTEXT (md))
12424 ta = build_access_to_thisn (ctx, type, 0);
12427 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
12428 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12431 ta = java_complete_tree (ta);
12434 /* We might have to use an access method to get to MD. We can
12435 break the method access rule as far as we're not generating
12437 if (METHOD_PRIVATE (md) && flag_emit_class_files)
12439 md = build_outer_method_access_method (md);
12446 /* Returnin a non zero value indicates we were doing a non static
12447 method invokation that is now a static invocation. It will have
12448 callee displace `this' to insert it in the regular argument
12450 return (non_static_context && to_return);
12453 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12457 patch_invoke (patch, method, args)
12458 tree patch, method, args;
12461 tree original_call, t, ta;
12462 tree cond = NULL_TREE;
12464 /* Last step for args: convert build-in types. If we're dealing with
12465 a new TYPE() type call, the first argument to the constructor
12466 isn't found in the incoming argument list, but delivered by
12468 t = TYPE_ARG_TYPES (TREE_TYPE (method));
12469 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12470 t = TREE_CHAIN (t);
12471 for (ta = args; t != end_params_node && ta;
12472 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12473 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12474 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12475 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12477 /* Resolve unresolved returned type isses */
12478 t = TREE_TYPE (TREE_TYPE (method));
12479 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12480 resolve_and_layout (TREE_TYPE (t), NULL);
12482 if (flag_emit_class_files || flag_emit_xref)
12486 tree signature = build_java_signature (TREE_TYPE (method));
12487 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12489 case INVOKE_VIRTUAL:
12490 dtable = invoke_build_dtable (0, args);
12491 func = build_invokevirtual (dtable, method);
12494 case INVOKE_NONVIRTUAL:
12495 /* If the object for the method call is null, we throw an
12496 exception. We don't do this if the object is the current
12497 method's `this'. In other cases we just rely on an
12498 optimization pass to eliminate redundant checks. */
12499 if (TREE_VALUE (args) != current_this)
12501 /* We use a SAVE_EXPR here to make sure we only evaluate
12502 the new `self' expression once. */
12503 tree save_arg = save_expr (TREE_VALUE (args));
12504 TREE_VALUE (args) = save_arg;
12505 cond = build (EQ_EXPR, boolean_type_node, save_arg,
12506 null_pointer_node);
12508 /* Fall through. */
12511 case INVOKE_STATIC:
12512 func = build_known_method_ref (method, TREE_TYPE (method),
12513 DECL_CONTEXT (method),
12517 case INVOKE_INTERFACE:
12518 dtable = invoke_build_dtable (1, args);
12519 func = build_invokeinterface (dtable, method);
12523 fatal ("internal error - unknown invocation_mode result");
12526 /* Ensure self_type is initialized, (invokestatic). FIXME */
12527 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12530 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12531 TREE_OPERAND (patch, 0) = func;
12532 TREE_OPERAND (patch, 1) = args;
12533 original_call = patch;
12535 /* We're processing a `new TYPE ()' form. New is called and its
12536 returned value is the first argument to the constructor. We build
12537 a COMPOUND_EXPR and use saved expression so that the overall NEW
12538 expression value is a pointer to a newly created and initialized
12540 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12542 tree class = DECL_CONTEXT (method);
12543 tree c1, saved_new, size, new;
12544 if (flag_emit_class_files || flag_emit_xref)
12546 TREE_TYPE (patch) = build_pointer_type (class);
12549 if (!TYPE_SIZE (class))
12550 safe_layout_class (class);
12551 size = size_in_bytes (class);
12552 new = build (CALL_EXPR, promote_type (class),
12553 build_address_of (alloc_object_node),
12554 tree_cons (NULL_TREE, build_class_ref (class),
12555 build_tree_list (NULL_TREE,
12556 size_in_bytes (class))),
12558 saved_new = save_expr (new);
12559 c1 = build_tree_list (NULL_TREE, saved_new);
12560 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12561 TREE_OPERAND (original_call, 1) = c1;
12562 TREE_SET_CODE (original_call, CALL_EXPR);
12563 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12566 /* If COND is set, then we are building a check to see if the object
12568 if (cond != NULL_TREE)
12570 /* We have to make the `then' branch a compound expression to
12571 make the types turn out right. This seems bizarre. */
12572 patch = build (COND_EXPR, TREE_TYPE (patch), cond,
12573 build (COMPOUND_EXPR, TREE_TYPE (patch),
12574 build (CALL_EXPR, void_type_node,
12575 build_address_of (soft_nullpointer_node),
12576 NULL_TREE, NULL_TREE),
12577 (FLOAT_TYPE_P (TREE_TYPE (patch))
12578 ? build_real (TREE_TYPE (patch), dconst0)
12579 : build1 (CONVERT_EXPR, TREE_TYPE (patch),
12580 integer_zero_node))),
12582 TREE_SIDE_EFFECTS (patch) = 1;
12589 invocation_mode (method, super)
12593 int access = get_access_flags_from_decl (method);
12596 return INVOKE_SUPER;
12598 if (access & ACC_STATIC)
12599 return INVOKE_STATIC;
12601 /* We have to look for a constructor before we handle nonvirtual
12602 calls; otherwise the constructor will look nonvirtual. */
12603 if (DECL_CONSTRUCTOR_P (method))
12604 return INVOKE_STATIC;
12606 if (access & ACC_FINAL || access & ACC_PRIVATE)
12607 return INVOKE_NONVIRTUAL;
12609 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12610 return INVOKE_NONVIRTUAL;
12612 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12613 return INVOKE_INTERFACE;
12615 return INVOKE_VIRTUAL;
12618 /* Retrieve a refined list of matching methods. It covers the step
12619 15.11.2 (Compile-Time Step 2) */
12622 lookup_method_invoke (lc, cl, class, name, arg_list)
12625 tree class, name, arg_list;
12627 tree atl = end_params_node; /* Arg Type List */
12628 tree method, signature, list, node;
12629 const char *candidates; /* Used for error report */
12632 /* Fix the arguments */
12633 for (node = arg_list; node; node = TREE_CHAIN (node))
12635 tree current_arg = TREE_TYPE (TREE_VALUE (node));
12636 /* Non primitive type may have to be resolved */
12637 if (!JPRIMITIVE_TYPE_P (current_arg))
12638 resolve_and_layout (current_arg, NULL_TREE);
12640 if (TREE_CODE (current_arg) == RECORD_TYPE)
12641 current_arg = promote_type (current_arg);
12642 atl = tree_cons (NULL_TREE, current_arg, atl);
12645 /* Presto. If we're dealing with an anonymous class and a
12646 constructor call, generate the right constructor now, since we
12647 know the arguments' types. */
12649 if (lc && ANONYMOUS_CLASS_P (class))
12650 craft_constructor (TYPE_NAME (class), atl);
12652 /* Find all candidates and then refine the list, searching for the
12653 most specific method. */
12654 list = find_applicable_accessible_methods_list (lc, class, name, atl);
12655 list = find_most_specific_methods_list (list);
12656 if (list && !TREE_CHAIN (list))
12657 return TREE_VALUE (list);
12659 /* Issue an error. List candidates if any. Candidates are listed
12660 only if accessible (non accessible methods may end-up here for
12661 the sake of a better error report). */
12666 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12667 for (current = list; current; current = TREE_CHAIN (current))
12669 tree cm = TREE_VALUE (current);
12670 char string [4096];
12671 if (!cm || not_accessible_p (class, cm, 0))
12674 (string, " `%s' in `%s'%s",
12675 get_printable_method_name (cm),
12676 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12677 (TREE_CHAIN (current) ? "\n" : ""));
12678 obstack_grow (&temporary_obstack, string, strlen (string));
12680 obstack_1grow (&temporary_obstack, '\0');
12681 candidates = obstack_finish (&temporary_obstack);
12683 /* Issue the error message */
12684 method = make_node (FUNCTION_TYPE);
12685 TYPE_ARG_TYPES (method) = atl;
12686 signature = build_java_argument_signature (method);
12687 dup = xstrdup (lang_printable_name (class, 0));
12688 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12689 (lc ? "constructor" : "method"),
12690 (lc ? dup : IDENTIFIER_POINTER (name)),
12691 IDENTIFIER_POINTER (signature), dup,
12692 (candidates ? candidates : ""));
12697 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12698 when we're looking for a constructor. */
12701 find_applicable_accessible_methods_list (lc, class, name, arglist)
12703 tree class, name, arglist;
12705 static int object_done = 0;
12706 tree list = NULL_TREE, all_list = NULL_TREE;
12708 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12710 load_class (class, 1);
12711 safe_layout_class (class);
12714 /* Search interfaces */
12715 if (CLASS_INTERFACE (TYPE_NAME (class)))
12717 static struct hash_table t, *searched_interfaces = NULL;
12718 static int search_not_done = 0;
12720 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12722 /* Search in the hash table, otherwise create a new one if
12723 necessary and insert the new entry. */
12725 if (searched_interfaces)
12727 if (hash_lookup (searched_interfaces,
12728 (const hash_table_key) class, FALSE, NULL))
12733 hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12734 java_hash_compare_tree_node);
12735 searched_interfaces = &t;
12738 hash_lookup (searched_interfaces,
12739 (const hash_table_key) class, TRUE, NULL);
12741 search_applicable_methods_list (lc, TYPE_METHODS (class),
12742 name, arglist, &list, &all_list);
12743 n = TREE_VEC_LENGTH (basetype_vec);
12744 for (i = 1; i < n; i++)
12746 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12750 rlist = find_applicable_accessible_methods_list (lc, t, name,
12752 list = chainon (rlist, list);
12756 /* We're done. Reset the searched interfaces list and finally search
12757 java.lang.Object */
12758 if (!search_not_done)
12761 search_applicable_methods_list (lc,
12762 TYPE_METHODS (object_type_node),
12763 name, arglist, &list, &all_list);
12764 hash_table_free (searched_interfaces);
12765 searched_interfaces = NULL;
12768 /* Search classes */
12772 int seen_inner_class = 0;
12773 search_applicable_methods_list (lc, TYPE_METHODS (class),
12774 name, arglist, &list, &all_list);
12776 /* We must search all interfaces of this class */
12779 tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12780 int n = TREE_VEC_LENGTH (basetype_vec), i;
12782 for (i = 1; i < n; i++)
12784 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12785 if (t != object_type_node)
12788 = find_applicable_accessible_methods_list (lc, t,
12790 list = chainon (rlist, list);
12796 /* Search enclosing context of inner classes before looking
12798 while (!lc && INNER_CLASS_TYPE_P (class))
12801 seen_inner_class = 1;
12802 class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12803 rlist = find_applicable_accessible_methods_list (lc, class,
12805 list = chainon (rlist, list);
12808 if (!lc && seen_inner_class
12809 && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12810 class = CLASSTYPE_SUPER (sc);
12814 for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
12815 class; class = CLASSTYPE_SUPER (class))
12816 search_applicable_methods_list (lc, TYPE_METHODS (class),
12817 name, arglist, &list, &all_list);
12820 /* Either return the list obtained or all selected (but
12821 inaccessible) methods for better error report. */
12822 return (!list ? all_list : list);
12825 /* Effectively search for the approriate method in method */
12828 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12830 tree method, name, arglist;
12831 tree *list, *all_list;
12833 for (; method; method = TREE_CHAIN (method))
12835 /* When dealing with constructor, stop here, otherwise search
12837 if (lc && !DECL_CONSTRUCTOR_P (method))
12839 else if (!lc && (DECL_CONSTRUCTOR_P (method)
12840 || (GET_METHOD_NAME (method) != name)))
12843 if (argument_types_convertible (method, arglist))
12845 /* Retain accessible methods only */
12846 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
12848 *list = tree_cons (NULL_TREE, method, *list);
12850 /* Also retain all selected method here */
12851 *all_list = tree_cons (NULL_TREE, method, *list);
12856 /* 15.11.2.2 Choose the Most Specific Method */
12859 find_most_specific_methods_list (list)
12863 tree current, new_list = NULL_TREE;
12864 for (current = list; current; current = TREE_CHAIN (current))
12867 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12869 for (method = list; method; method = TREE_CHAIN (method))
12871 /* Don't test a method against itself */
12872 if (method == current)
12875 /* Compare arguments and location where method where declared */
12876 if (argument_types_convertible (TREE_VALUE (method),
12877 TREE_VALUE (current))
12878 && valid_method_invocation_conversion_p
12879 (DECL_CONTEXT (TREE_VALUE (method)),
12880 DECL_CONTEXT (TREE_VALUE (current))))
12882 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12883 max = (v > max ? v : max);
12888 /* Review the list and select the maximally specific methods */
12889 for (current = list; current; current = TREE_CHAIN (current))
12890 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12891 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12893 /* If we have several and they're all abstract, just pick the
12896 if (new_list && TREE_CHAIN (new_list))
12899 for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c));
12900 c = TREE_CHAIN (c))
12904 new_list = nreverse (new_list);
12905 TREE_CHAIN (new_list) = NULL_TREE;
12909 /* If we can't find one, lower expectations and try to gather multiple
12910 maximally specific methods */
12911 while (!new_list && max)
12915 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12916 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12923 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12924 converted by method invocation conversion (5.3) to the type of the
12925 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12926 to change less often than M1. */
12929 argument_types_convertible (m1, m2_or_arglist)
12930 tree m1, m2_or_arglist;
12932 static tree m2_arg_value = NULL_TREE;
12933 static tree m2_arg_cache = NULL_TREE;
12935 register tree m1_arg, m2_arg;
12937 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12939 if (m2_arg_value == m2_or_arglist)
12940 m2_arg = m2_arg_cache;
12943 /* M2_OR_ARGLIST can be a function DECL or a raw list of
12945 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12947 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12948 if (!METHOD_STATIC (m2_or_arglist))
12949 m2_arg = TREE_CHAIN (m2_arg);
12952 m2_arg = m2_or_arglist;
12954 m2_arg_value = m2_or_arglist;
12955 m2_arg_cache = m2_arg;
12958 while (m1_arg != end_params_node && m2_arg != end_params_node)
12960 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12961 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12962 TREE_VALUE (m2_arg)))
12964 m1_arg = TREE_CHAIN (m1_arg);
12965 m2_arg = TREE_CHAIN (m2_arg);
12967 return m1_arg == end_params_node && m2_arg == end_params_node;
12970 /* Qualification routines */
12973 qualify_ambiguous_name (id)
12976 tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12977 saved_current_class;
12978 int again, super_found = 0, this_found = 0, new_array_found = 0;
12981 /* We first qualify the first element, then derive qualification of
12982 others based on the first one. If the first element is qualified
12983 by a resolution (field or type), this resolution is stored in the
12984 QUAL_RESOLUTION of the qual element being examined. We need to
12985 save the current_class since the use of SUPER might change the
12987 saved_current_class = current_class;
12988 qual = EXPR_WFL_QUALIFICATION (id);
12991 /* Simple qualified expression feature a qual_wfl that is a
12992 WFL. Expression derived from a primary feature more complicated
12993 things like a CALL_EXPR. Expression from primary need to be
12994 worked out to extract the part on which the qualification will
12996 qual_wfl = QUAL_WFL (qual);
12997 switch (TREE_CODE (qual_wfl))
13000 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13001 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
13003 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13004 qual_wfl = QUAL_WFL (qual);
13007 case NEW_ARRAY_EXPR:
13008 case NEW_ANONYMOUS_ARRAY_EXPR:
13009 qual = TREE_CHAIN (qual);
13010 again = new_array_found = 1;
13014 case NEW_CLASS_EXPR:
13015 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13018 while (TREE_CODE (qual_wfl) == ARRAY_REF)
13019 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13022 qual = TREE_CHAIN (qual);
13023 qual_wfl = QUAL_WFL (qual);
13025 case CLASS_LITERAL:
13026 qual = TREE_CHAIN (qual);
13027 qual_wfl = QUAL_WFL (qual);
13030 /* Fix for -Wall. Just break doing nothing */
13034 ptr_type = current_class;
13036 code = TREE_CODE (qual_wfl);
13038 /* Pos evaluation: non WFL leading expression nodes */
13039 if (code == CONVERT_EXPR
13040 && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
13041 name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
13043 else if (code == INTEGER_CST)
13046 else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
13047 TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
13048 name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
13050 else if (code == TREE_LIST)
13051 name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
13053 else if (code == STRING_CST || code == CONDITIONAL_EXPR
13054 || code == PLUS_EXPR)
13056 qual = TREE_CHAIN (qual);
13057 qual_wfl = QUAL_WFL (qual);
13062 name = EXPR_WFL_NODE (qual_wfl);
13065 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13070 /* If we have a THIS (from a primary), we set the context accordingly */
13071 if (name == this_identifier_node)
13073 qual = TREE_CHAIN (qual);
13074 qual_wfl = QUAL_WFL (qual);
13075 if (TREE_CODE (qual_wfl) == CALL_EXPR)
13078 name = EXPR_WFL_NODE (qual_wfl);
13081 /* If we have a SUPER, we set the context accordingly */
13082 if (name == super_identifier_node)
13084 current_class = CLASSTYPE_SUPER (ptr_type);
13085 /* Check that there is such a thing as a super class. If not,
13086 return. The error will be caught later on, during the
13088 if (!current_class)
13090 current_class = saved_current_class;
13093 qual = TREE_CHAIN (qual);
13094 /* Do one more interation to set things up */
13095 super_found = again = 1;
13099 /* If name appears within the scope of a local variable declaration
13100 or parameter declaration, then it is an expression name. We don't
13101 carry this test out if we're in the context of the use of SUPER
13103 if (!this_found && !super_found
13104 && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
13105 && (decl = IDENTIFIER_LOCAL_VALUE (name)))
13107 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13108 QUAL_RESOLUTION (qual) = decl;
13111 /* If within the class/interface NAME was found to be used there
13112 exists a (possibly inherited) field named NAME, then this is an
13113 expression name. If we saw a NEW_ARRAY_EXPR before and want to
13114 address length, it is OK. */
13115 else if ((decl = lookup_field_wrapper (ptr_type, name))
13116 || (new_array_found && name == length_identifier_node))
13118 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13119 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
13122 /* We reclassify NAME as yielding to a type name resolution if:
13123 - NAME is a class/interface declared within the compilation
13124 unit containing NAME,
13125 - NAME is imported via a single-type-import declaration,
13126 - NAME is declared in an another compilation unit of the package
13127 of the compilation unit containing NAME,
13128 - NAME is declared by exactly on type-import-on-demand declaration
13129 of the compilation unit containing NAME.
13130 - NAME is actually a STRING_CST. */
13131 else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
13132 || (decl = resolve_and_layout (name, NULL_TREE)))
13134 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
13135 QUAL_RESOLUTION (qual) = decl;
13138 /* Method call, array references and cast are expression name */
13139 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
13140 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
13141 || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
13142 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13144 /* Check here that NAME isn't declared by more than one
13145 type-import-on-demand declaration of the compilation unit
13146 containing NAME. FIXME */
13148 /* Otherwise, NAME is reclassified as a package name */
13150 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13152 /* Propagate the qualification accross other components of the
13154 for (qual = TREE_CHAIN (qual); qual;
13155 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13157 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13158 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13160 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13163 /* Store the global qualification for the ambiguous part of ID back
13165 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13166 RESOLVE_EXPRESSION_NAME_P (id) = 1;
13167 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13168 RESOLVE_TYPE_NAME_P (id) = 1;
13169 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13170 RESOLVE_PACKAGE_NAME_P (id) = 1;
13172 /* Restore the current class */
13173 current_class = saved_current_class;
13177 breakdown_qualified (left, right, source)
13178 tree *left, *right, source;
13180 char *p = IDENTIFIER_POINTER (source), *base;
13181 int l = IDENTIFIER_LENGTH (source);
13183 /* Breakdown NAME into REMAINDER . IDENTIFIER */
13186 while (*p != '.' && p != base)
13189 /* We didn't find a '.'. Return an error */
13195 *right = get_identifier (p+1);
13196 *left = get_identifier (IDENTIFIER_POINTER (source));
13202 /* Patch tree nodes in a function body. When a BLOCK is found, push
13203 local variable decls if present.
13204 Same as java_complete_lhs, but does resolve static finals to values. */
13207 java_complete_tree (node)
13210 node = java_complete_lhs (node);
13211 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13212 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13213 && !flag_emit_xref)
13215 tree value = DECL_INITIAL (node);
13216 DECL_INITIAL (node) = NULL_TREE;
13217 push_obstacks (&permanent_obstack, &permanent_obstack);
13218 value = fold_constant_for_init (value, node);
13220 DECL_INITIAL (node) = value;
13221 if (value != NULL_TREE)
13223 /* fold_constant_for_init sometimes widen the original type
13224 of the constant (i.e. byte to int.) It's not desirable,
13225 especially if NODE is a function argument. */
13226 if (TREE_CODE (value) == INTEGER_CST
13227 && TREE_TYPE (node) != TREE_TYPE (value))
13228 return convert (TREE_TYPE (node), value);
13237 java_stabilize_reference (node)
13240 if (TREE_CODE (node) == COMPOUND_EXPR)
13242 tree op0 = TREE_OPERAND (node, 0);
13243 tree op1 = TREE_OPERAND (node, 1);
13244 TREE_OPERAND (node, 0) = save_expr (op0);
13245 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13248 return stabilize_reference (node);
13251 /* Patch tree nodes in a function body. When a BLOCK is found, push
13252 local variable decls if present.
13253 Same as java_complete_tree, but does not resolve static finals to values. */
13256 java_complete_lhs (node)
13259 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13262 /* CONVERT_EXPR always has its type set, even though it needs to be
13264 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13267 /* The switch block implements cases processing container nodes
13268 first. Contained nodes are always written back. Leaves come
13269 next and return a value. */
13270 switch (TREE_CODE (node))
13274 /* 1- Block section.
13275 Set the local values on decl names so we can identify them
13276 faster when they're referenced. At that stage, identifiers
13277 are legal so we don't check for declaration errors. */
13278 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13280 DECL_CONTEXT (cn) = current_function_decl;
13281 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13283 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13284 CAN_COMPLETE_NORMALLY (node) = 1;
13287 tree stmt = BLOCK_EXPR_BODY (node);
13289 int error_seen = 0;
13290 if (TREE_CODE (stmt) == COMPOUND_EXPR)
13292 /* Re-order from (((A; B); C); ...; Z) to
13293 (A; (B; (C ; (...; Z)))).
13294 This makes it easier to scan the statements left-to-right
13295 without using recursion (which might overflow the stack
13296 if the block has many statements. */
13299 tree left = TREE_OPERAND (stmt, 0);
13300 if (TREE_CODE (left) != COMPOUND_EXPR)
13302 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13303 TREE_OPERAND (left, 1) = stmt;
13306 BLOCK_EXPR_BODY (node) = stmt;
13309 /* Now do the actual complete, without deep recursion for
13311 ptr = &BLOCK_EXPR_BODY (node);
13312 while (TREE_CODE (*ptr) == COMPOUND_EXPR
13313 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13315 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13316 tree *next = &TREE_OPERAND (*ptr, 1);
13317 TREE_OPERAND (*ptr, 0) = cur;
13318 if (cur == empty_stmt_node)
13320 /* Optimization; makes it easier to detect empty bodies.
13321 Most useful for <clinit> with all-constant initializer. */
13325 if (TREE_CODE (cur) == ERROR_MARK)
13327 else if (! CAN_COMPLETE_NORMALLY (cur))
13332 if (TREE_CODE (wfl_op2) == BLOCK)
13333 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13334 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13335 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13339 if (TREE_CODE (wfl_op2) != CASE_EXPR
13340 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13341 unreachable_stmt_error (*ptr);
13345 *ptr = java_complete_tree (*ptr);
13347 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13348 return error_mark_node;
13349 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13351 /* Turn local bindings to null */
13352 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13353 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13355 TREE_TYPE (node) = void_type_node;
13358 /* 2- They are expressions but ultimately deal with statements */
13361 wfl_op1 = TREE_OPERAND (node, 0);
13362 COMPLETE_CHECK_OP_0 (node);
13363 /* 14.19 A throw statement cannot complete normally. */
13364 CAN_COMPLETE_NORMALLY (node) = 0;
13365 return patch_throw_statement (node, wfl_op1);
13367 case SYNCHRONIZED_EXPR:
13368 wfl_op1 = TREE_OPERAND (node, 0);
13369 return patch_synchronized_statement (node, wfl_op1);
13372 return patch_try_statement (node);
13374 case TRY_FINALLY_EXPR:
13375 COMPLETE_CHECK_OP_0 (node);
13376 COMPLETE_CHECK_OP_1 (node);
13377 CAN_COMPLETE_NORMALLY (node)
13378 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13379 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13380 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13383 case CLEANUP_POINT_EXPR:
13384 COMPLETE_CHECK_OP_0 (node);
13385 TREE_TYPE (node) = void_type_node;
13386 CAN_COMPLETE_NORMALLY (node) =
13387 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13390 case WITH_CLEANUP_EXPR:
13391 COMPLETE_CHECK_OP_0 (node);
13392 COMPLETE_CHECK_OP_2 (node);
13393 CAN_COMPLETE_NORMALLY (node) =
13394 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13395 TREE_TYPE (node) = void_type_node;
13398 case LABELED_BLOCK_EXPR:
13399 PUSH_LABELED_BLOCK (node);
13400 if (LABELED_BLOCK_BODY (node))
13401 COMPLETE_CHECK_OP_1 (node);
13402 TREE_TYPE (node) = void_type_node;
13403 POP_LABELED_BLOCK ();
13405 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13407 LABELED_BLOCK_BODY (node) = NULL_TREE;
13408 CAN_COMPLETE_NORMALLY (node) = 1;
13410 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13411 CAN_COMPLETE_NORMALLY (node) = 1;
13414 case EXIT_BLOCK_EXPR:
13415 /* We don't complete operand 1, because it's the return value of
13416 the EXIT_BLOCK_EXPR which doesn't exist it Java */
13417 return patch_bc_statement (node);
13420 cn = java_complete_tree (TREE_OPERAND (node, 0));
13421 if (cn == error_mark_node)
13424 /* First, the case expression must be constant. Values of final
13425 fields are accepted. */
13427 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13428 && JDECL_P (TREE_OPERAND (cn, 1))
13429 && FIELD_FINAL (TREE_OPERAND (cn, 1))
13430 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13432 push_obstacks (&permanent_obstack, &permanent_obstack);
13433 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13434 TREE_OPERAND (cn, 1));
13438 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13440 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13441 parse_error_context (node, "Constant expression required");
13442 return error_mark_node;
13445 nn = ctxp->current_loop;
13447 /* It must be assignable to the type of the switch expression. */
13448 if (!try_builtin_assignconv (NULL_TREE,
13449 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13451 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13452 parse_error_context
13454 "Incompatible type for case. Can't convert `%s' to `int'",
13455 lang_printable_name (TREE_TYPE (cn), 0));
13456 return error_mark_node;
13459 cn = fold (convert (int_type_node, cn));
13461 /* Multiple instance of a case label bearing the same
13462 value is checked during code generation. The case
13463 expression is allright so far. */
13464 TREE_OPERAND (node, 0) = cn;
13465 TREE_TYPE (node) = void_type_node;
13466 CAN_COMPLETE_NORMALLY (node) = 1;
13467 TREE_SIDE_EFFECTS (node) = 1;
13471 nn = ctxp->current_loop;
13472 /* Only one default label is allowed per switch statement */
13473 if (SWITCH_HAS_DEFAULT (nn))
13475 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13476 parse_error_context (wfl_operator,
13477 "Duplicate case label: `default'");
13478 return error_mark_node;
13481 SWITCH_HAS_DEFAULT (nn) = 1;
13482 TREE_TYPE (node) = void_type_node;
13483 TREE_SIDE_EFFECTS (node) = 1;
13484 CAN_COMPLETE_NORMALLY (node) = 1;
13490 /* Check whether the loop was enclosed in a labeled
13491 statement. If not, create one, insert the loop in it and
13493 nn = patch_loop_statement (node);
13495 /* Anyways, walk the body of the loop */
13496 if (TREE_CODE (node) == LOOP_EXPR)
13497 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13498 /* Switch statement: walk the switch expression and the cases */
13500 node = patch_switch_statement (node);
13502 if (TREE_OPERAND (node, 0) == error_mark_node)
13503 nn = error_mark_node;
13506 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13507 /* If we returned something different, that's because we
13508 inserted a label. Pop the label too. */
13511 if (CAN_COMPLETE_NORMALLY (node))
13512 CAN_COMPLETE_NORMALLY (nn) = 1;
13513 POP_LABELED_BLOCK ();
13520 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13521 return patch_exit_expr (node);
13525 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13526 if (TREE_OPERAND (node, 0) == error_mark_node)
13527 return error_mark_node;
13528 /* then-else branches */
13529 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13530 if (TREE_OPERAND (node, 1) == error_mark_node)
13531 return error_mark_node;
13532 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13533 if (TREE_OPERAND (node, 2) == error_mark_node)
13534 return error_mark_node;
13535 return patch_if_else_statement (node);
13538 case CONDITIONAL_EXPR:
13540 wfl_op1 = TREE_OPERAND (node, 0);
13541 COMPLETE_CHECK_OP_0 (node);
13542 wfl_op2 = TREE_OPERAND (node, 1);
13543 COMPLETE_CHECK_OP_1 (node);
13544 wfl_op3 = TREE_OPERAND (node, 2);
13545 COMPLETE_CHECK_OP_2 (node);
13546 return patch_conditional_expr (node, wfl_op1, wfl_op2);
13548 /* 3- Expression section */
13549 case COMPOUND_EXPR:
13550 wfl_op2 = TREE_OPERAND (node, 1);
13551 TREE_OPERAND (node, 0) = nn =
13552 java_complete_tree (TREE_OPERAND (node, 0));
13553 if (wfl_op2 == empty_stmt_node)
13554 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13557 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13559 /* An unreachable condition in a do-while statement
13560 is *not* (technically) an unreachable statement. */
13562 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13563 nn = EXPR_WFL_NODE (nn);
13564 if (TREE_CODE (nn) != EXIT_EXPR)
13566 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13567 parse_error_context (wfl_operator, "Unreachable statement");
13570 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13571 if (TREE_OPERAND (node, 1) == error_mark_node)
13572 return error_mark_node;
13573 CAN_COMPLETE_NORMALLY (node)
13574 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13576 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13580 /* CAN_COMPLETE_NORMALLY (node) = 0; */
13581 return patch_return (node);
13583 case EXPR_WITH_FILE_LOCATION:
13584 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13585 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13588 node = resolve_expression_name (node, NULL);
13589 if (node == error_mark_node)
13591 /* Keep line number information somewhere were it doesn't
13592 disrupt the completion process. */
13593 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13595 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13596 TREE_OPERAND (node, 1) = wfl;
13598 CAN_COMPLETE_NORMALLY (node) = 1;
13603 int save_lineno = lineno;
13604 lineno = EXPR_WFL_LINENO (node);
13605 body = java_complete_tree (EXPR_WFL_NODE (node));
13606 lineno = save_lineno;
13607 EXPR_WFL_NODE (node) = body;
13608 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13609 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13610 if (body == empty_stmt_node)
13612 /* Optimization; makes it easier to detect empty bodies. */
13615 if (body == error_mark_node)
13617 /* Its important for the evaluation of assignment that
13618 this mark on the TREE_TYPE is propagated. */
13619 TREE_TYPE (node) = error_mark_node;
13620 return error_mark_node;
13623 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13628 case NEW_ARRAY_EXPR:
13629 /* Patch all the dimensions */
13631 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13633 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13634 tree dim = convert (int_type_node,
13635 java_complete_tree (TREE_VALUE (cn)));
13636 if (dim == error_mark_node)
13643 TREE_VALUE (cn) = dim;
13644 /* Setup the location of the current dimension, for
13645 later error report. */
13646 TREE_PURPOSE (cn) =
13647 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13648 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13651 /* They complete the array creation expression, if no errors
13653 CAN_COMPLETE_NORMALLY (node) = 1;
13654 return (flag ? error_mark_node
13655 : force_evaluation_order (patch_newarray (node)));
13657 case NEW_ANONYMOUS_ARRAY_EXPR:
13658 /* Create the array type if necessary. */
13659 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13661 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13662 if (!(type = resolve_type_during_patch (type)))
13663 return error_mark_node;
13664 type = build_array_from_name (type, NULL_TREE,
13665 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13666 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13668 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13669 ANONYMOUS_ARRAY_INITIALIZER (node));
13670 if (node == error_mark_node)
13671 return error_mark_node;
13672 CAN_COMPLETE_NORMALLY (node) = 1;
13675 case NEW_CLASS_EXPR:
13677 /* Complete function's argument(s) first */
13678 if (complete_function_arguments (node))
13679 return error_mark_node;
13682 tree decl, wfl = TREE_OPERAND (node, 0);
13683 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13685 node = patch_method_invocation (node, NULL_TREE,
13686 NULL_TREE, 0, &decl);
13687 if (node == error_mark_node)
13688 return error_mark_node;
13690 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13691 /* If we call this(...), register signature and positions */
13693 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
13694 tree_cons (wfl, decl,
13695 DECL_CONSTRUCTOR_CALLS (current_function_decl));
13696 CAN_COMPLETE_NORMALLY (node) = 1;
13697 return force_evaluation_order (node);
13701 /* Save potential wfls */
13702 wfl_op1 = TREE_OPERAND (node, 0);
13703 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13705 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13706 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13707 && DECL_INITIAL (nn) != NULL_TREE)
13711 push_obstacks (&permanent_obstack, &permanent_obstack);
13712 value = fold_constant_for_init (nn, nn);
13715 if (value != NULL_TREE)
13717 tree type = TREE_TYPE (value);
13718 if (JPRIMITIVE_TYPE_P (type) ||
13719 (type == string_ptr_type_node && ! flag_emit_class_files))
13720 return empty_stmt_node;
13722 DECL_INITIAL (nn) = NULL_TREE;
13724 wfl_op2 = TREE_OPERAND (node, 1);
13726 if (TREE_OPERAND (node, 0) == error_mark_node)
13727 return error_mark_node;
13729 flag = COMPOUND_ASSIGN_P (wfl_op2);
13732 /* This might break when accessing outer field from inner
13733 class. TESTME, FIXME */
13734 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
13736 /* Hand stablize the lhs on both places */
13737 TREE_OPERAND (node, 0) = lvalue;
13738 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
13739 (flag_emit_class_files ? lvalue : save_expr (lvalue));
13741 /* 15.25.2.a: Left hand is not an array access. FIXME */
13742 /* Now complete the RHS. We write it back later on. */
13743 nn = java_complete_tree (TREE_OPERAND (node, 1));
13745 if ((cn = patch_string (nn)))
13748 /* The last part of the rewrite for E1 op= E2 is to have
13749 E1 = (T)(E1 op E2), with T being the type of E1. */
13750 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
13751 TREE_TYPE (lvalue), nn));
13753 /* 15.25.2.b: Left hand is an array access. FIXME */
13756 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13757 function to complete this RHS. Note that a NEW_ARRAY_INIT
13758 might have been already fully expanded if created as a result
13759 of processing an anonymous array initializer. We avoid doing
13760 the operation twice by testing whether the node already bears
13762 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13763 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13764 TREE_OPERAND (node, 1));
13765 /* Otherwise we simply complete the RHS */
13767 nn = java_complete_tree (TREE_OPERAND (node, 1));
13769 if (nn == error_mark_node)
13770 return error_mark_node;
13772 /* Write back the RHS as we evaluated it. */
13773 TREE_OPERAND (node, 1) = nn;
13775 /* In case we're handling = with a String as a RHS, we need to
13776 produce a String out of the RHS (it might still be a
13777 STRING_CST or a StringBuffer at this stage */
13778 if ((nn = patch_string (TREE_OPERAND (node, 1))))
13779 TREE_OPERAND (node, 1) = nn;
13781 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13782 TREE_OPERAND (node, 1))))
13784 /* We return error_mark_node if outer_field_access_fix
13785 detects we write into a final. */
13786 if (nn == error_mark_node)
13787 return error_mark_node;
13792 node = patch_assignment (node, wfl_op1, wfl_op2);
13793 /* Reorganize the tree if necessary. */
13794 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
13795 || JSTRING_P (TREE_TYPE (node))))
13796 node = java_refold (node);
13799 CAN_COMPLETE_NORMALLY (node) = 1;
13811 case TRUNC_MOD_EXPR:
13812 case TRUNC_DIV_EXPR:
13814 case TRUTH_ANDIF_EXPR:
13815 case TRUTH_ORIF_EXPR:
13822 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13823 knows how to handle those cases. */
13824 wfl_op1 = TREE_OPERAND (node, 0);
13825 wfl_op2 = TREE_OPERAND (node, 1);
13827 CAN_COMPLETE_NORMALLY (node) = 1;
13828 /* Don't complete string nodes if dealing with the PLUS operand. */
13829 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13831 nn = java_complete_tree (wfl_op1);
13832 if (nn == error_mark_node)
13833 return error_mark_node;
13835 TREE_OPERAND (node, 0) = nn;
13837 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13839 nn = java_complete_tree (wfl_op2);
13840 if (nn == error_mark_node)
13841 return error_mark_node;
13843 TREE_OPERAND (node, 1) = nn;
13845 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13847 case INSTANCEOF_EXPR:
13848 wfl_op1 = TREE_OPERAND (node, 0);
13849 COMPLETE_CHECK_OP_0 (node);
13850 if (flag_emit_xref)
13852 TREE_TYPE (node) = boolean_type_node;
13855 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13857 case UNARY_PLUS_EXPR:
13859 case TRUTH_NOT_EXPR:
13861 case PREDECREMENT_EXPR:
13862 case PREINCREMENT_EXPR:
13863 case POSTDECREMENT_EXPR:
13864 case POSTINCREMENT_EXPR:
13866 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13867 how to handle those cases. */
13868 wfl_op1 = TREE_OPERAND (node, 0);
13869 CAN_COMPLETE_NORMALLY (node) = 1;
13870 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13871 if (TREE_OPERAND (node, 0) == error_mark_node)
13872 return error_mark_node;
13873 node = patch_unaryop (node, wfl_op1);
13874 CAN_COMPLETE_NORMALLY (node) = 1;
13878 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13879 how to handle those cases. */
13880 wfl_op1 = TREE_OPERAND (node, 0);
13881 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13882 if (TREE_OPERAND (node, 0) == error_mark_node)
13883 return error_mark_node;
13884 if (!flag_emit_class_files && !flag_emit_xref)
13885 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13886 /* The same applies to wfl_op2 */
13887 wfl_op2 = TREE_OPERAND (node, 1);
13888 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13889 if (TREE_OPERAND (node, 1) == error_mark_node)
13890 return error_mark_node;
13891 if (!flag_emit_class_files && !flag_emit_xref)
13892 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13893 return patch_array_ref (node);
13898 case COMPONENT_REF:
13899 /* The first step in the re-write of qualified name handling. FIXME.
13900 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13901 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13902 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13904 tree name = TREE_OPERAND (node, 1);
13905 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13906 if (field == NULL_TREE)
13908 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13909 return error_mark_node;
13911 if (! FIELD_STATIC (field))
13913 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13914 return error_mark_node;
13919 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13923 /* Can't use THIS in a static environment */
13926 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13927 parse_error_context (wfl_operator,
13928 "Keyword `this' used outside allowed context");
13929 TREE_TYPE (node) = error_mark_node;
13930 return error_mark_node;
13932 if (ctxp->explicit_constructor_p)
13934 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13935 parse_error_context
13936 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13937 TREE_TYPE (node) = error_mark_node;
13938 return error_mark_node;
13940 return current_this;
13942 case CLASS_LITERAL:
13943 CAN_COMPLETE_NORMALLY (node) = 1;
13944 node = patch_incomplete_class_ref (node);
13945 if (node == error_mark_node)
13946 return error_mark_node;
13949 case INSTANCE_INITIALIZERS_EXPR:
13950 in_instance_initializer++;
13951 node = java_complete_tree (TREE_OPERAND (node, 0));
13952 in_instance_initializer--;
13953 if (node != error_mark_node)
13954 TREE_TYPE (node) = void_type_node;
13956 return error_mark_node;
13960 CAN_COMPLETE_NORMALLY (node) = 1;
13961 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13962 and it's time to turn it into the appropriate String object */
13963 if ((nn = patch_string (node)))
13966 fatal ("No case for tree code `%s' - java_complete_tree\n",
13967 tree_code_name [TREE_CODE (node)]);
13972 /* Complete function call's argument. Return a non zero value is an
13973 error was found. */
13976 complete_function_arguments (node)
13982 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13983 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13985 tree wfl = TREE_VALUE (cn), parm, temp;
13986 parm = java_complete_tree (wfl);
13988 if (parm == error_mark_node)
13993 /* If have a string literal that we haven't transformed yet or a
13994 crafted string buffer, as a result of use of the the String
13995 `+' operator. Build `parm.toString()' and expand it. */
13996 if ((temp = patch_string (parm)))
13998 /* Inline PRIMTYPE.TYPE read access */
13999 parm = maybe_build_primttype_type_ref (parm, wfl);
14001 TREE_VALUE (cn) = parm;
14003 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14007 /* Sometimes (for loops and variable initialized during their
14008 declaration), we want to wrap a statement around a WFL and turn it
14012 build_debugable_stmt (location, stmt)
14016 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
14018 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
14019 EXPR_WFL_LINECOL (stmt) = location;
14021 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
14026 build_expr_block (body, decls)
14029 tree node = make_node (BLOCK);
14030 BLOCK_EXPR_DECLS (node) = decls;
14031 BLOCK_EXPR_BODY (node) = body;
14033 TREE_TYPE (node) = TREE_TYPE (body);
14034 TREE_SIDE_EFFECTS (node) = 1;
14038 /* Create a new function block and link it approriately to current
14039 function block chain */
14044 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
14047 /* Link block B supercontext to the previous block. The current
14048 function DECL is used as supercontext when enter_a_block is called
14049 for the first time for a given function. The current function body
14050 (DECL_FUNCTION_BODY) is set to be block B. */
14056 tree fndecl = current_function_decl;
14059 BLOCK_SUPERCONTEXT (b) = current_static_block;
14060 current_static_block = b;
14063 else if (!DECL_FUNCTION_BODY (fndecl))
14065 BLOCK_SUPERCONTEXT (b) = fndecl;
14066 DECL_FUNCTION_BODY (fndecl) = b;
14070 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
14071 DECL_FUNCTION_BODY (fndecl) = b;
14076 /* Exit a block by changing the current function body
14077 (DECL_FUNCTION_BODY) to the current block super context, only if
14078 the block being exited isn't the method's top level one. */
14084 if (current_function_decl)
14086 b = DECL_FUNCTION_BODY (current_function_decl);
14087 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
14088 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
14092 b = current_static_block;
14094 if (BLOCK_SUPERCONTEXT (b))
14095 current_static_block = BLOCK_SUPERCONTEXT (b);
14100 /* Lookup for NAME in the nested function's blocks, all the way up to
14101 the current toplevel one. It complies with Java's local variable
14105 lookup_name_in_blocks (name)
14108 tree b = GET_CURRENT_BLOCK (current_function_decl);
14110 while (b != current_function_decl)
14114 /* Paranoid sanity check. To be removed */
14115 if (TREE_CODE (b) != BLOCK)
14116 fatal ("non block expr function body - lookup_name_in_blocks");
14118 for (current = BLOCK_EXPR_DECLS (b); current;
14119 current = TREE_CHAIN (current))
14120 if (DECL_NAME (current) == name)
14122 b = BLOCK_SUPERCONTEXT (b);
14128 maybe_absorb_scoping_blocks ()
14130 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
14132 tree b = exit_block ();
14133 java_method_add_stmt (current_function_decl, b);
14134 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
14139 /* This section of the source is reserved to build_* functions that
14140 are building incomplete tree nodes and the patch_* functions that
14141 are completing them. */
14143 /* Wrap a non WFL node around a WFL. */
14145 build_wfl_wrap (node)
14148 tree wfl, node_to_insert = node;
14150 /* We want to process THIS . xxx symbolicaly, to keep it consistent
14151 with the way we're processing SUPER. A THIS from a primary as a
14152 different form than a SUPER. Turn THIS into something symbolic */
14153 if (TREE_CODE (node) == THIS_EXPR)
14154 node_to_insert = wfl = build_wfl_node (this_identifier_node);
14156 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14158 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
14159 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14164 /* Build a super() constructor invocation. Returns empty_stmt_node if
14165 we're currently dealing with the class java.lang.Object. */
14168 build_super_invocation (mdecl)
14171 if (DECL_CONTEXT (mdecl) == object_type_node)
14172 return empty_stmt_node;
14175 tree super_wfl = build_wfl_node (super_identifier_node);
14176 tree a = NULL_TREE, t;
14177 /* If we're dealing with an anonymous class, pass the arguments
14178 of the crafted constructor along. */
14179 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14181 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14182 for (; t != end_params_node; t = TREE_CHAIN (t))
14183 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14185 return build_method_invocation (super_wfl, a);
14189 /* Build a SUPER/THIS qualified method invocation. */
14192 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14199 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14200 EXPR_WFL_LINECOL (wfl) = lloc;
14201 invok = build_method_invocation (name, args);
14202 return make_qualified_primary (wfl, invok, rloc);
14205 /* Build an incomplete CALL_EXPR node. */
14208 build_method_invocation (name, args)
14212 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14213 TREE_SIDE_EFFECTS (call) = 1;
14214 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14218 /* Build an incomplete new xxx(...) node. */
14221 build_new_invocation (name, args)
14224 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14225 TREE_SIDE_EFFECTS (call) = 1;
14226 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14230 /* Build an incomplete assignment expression. */
14233 build_assignment (op, op_location, lhs, rhs)
14234 int op, op_location;
14238 /* Build the corresponding binop if we deal with a Compound
14239 Assignment operator. Mark the binop sub-tree as part of a
14240 Compound Assignment expression */
14241 if (op != ASSIGN_TK)
14243 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14244 COMPOUND_ASSIGN_P (rhs) = 1;
14246 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14247 TREE_SIDE_EFFECTS (assignment) = 1;
14248 EXPR_WFL_LINECOL (assignment) = op_location;
14252 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14255 print_int_node (node)
14258 static char buffer [80];
14259 if (TREE_CONSTANT_OVERFLOW (node))
14260 sprintf (buffer, "<overflow>");
14262 if (TREE_INT_CST_HIGH (node) == 0)
14263 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14264 TREE_INT_CST_LOW (node));
14265 else if (TREE_INT_CST_HIGH (node) == -1
14266 && TREE_INT_CST_LOW (node) != 0)
14269 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14270 -TREE_INT_CST_LOW (node));
14273 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14274 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14279 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14283 check_final_assignment (lvalue, wfl)
14286 if (TREE_CODE (lvalue) == COMPOUND_EXPR
14287 && JDECL_P (TREE_OPERAND (lvalue, 1)))
14288 lvalue = TREE_OPERAND (lvalue, 1);
14290 /* When generating class files, references to the `length' field
14291 look a bit different. */
14292 if ((flag_emit_class_files
14293 && TREE_CODE (lvalue) == COMPONENT_REF
14294 && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14295 && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14296 || (TREE_CODE (lvalue) == FIELD_DECL
14297 && FIELD_FINAL (lvalue)
14298 && !DECL_CLINIT_P (current_function_decl)
14299 && !DECL_FINIT_P (current_function_decl)))
14301 parse_error_context
14302 (wfl, "Can't assign a value to the final variable `%s'",
14303 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14309 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14310 read. This is needed to avoid circularities in the implementation
14311 of these fields in libjava. */
14314 maybe_build_primttype_type_ref (rhs, wfl)
14317 tree to_return = NULL_TREE;
14318 tree rhs_type = TREE_TYPE (rhs);
14319 if (TREE_CODE (rhs) == COMPOUND_EXPR)
14321 tree n = TREE_OPERAND (rhs, 1);
14322 if (TREE_CODE (n) == VAR_DECL
14323 && DECL_NAME (n) == TYPE_identifier_node
14324 && rhs_type == class_ptr_type)
14326 const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14327 if (!strncmp (self_name, "java.lang.", 10))
14328 to_return = build_primtype_type_ref (self_name);
14331 return (to_return ? to_return : rhs );
14334 /* 15.25 Assignment operators. */
14337 patch_assignment (node, wfl_op1, wfl_op2)
14342 tree rhs = TREE_OPERAND (node, 1);
14343 tree lvalue = TREE_OPERAND (node, 0), llvalue;
14344 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14345 int error_found = 0;
14346 int lvalue_from_array = 0;
14348 /* Can't assign to a (blank) final. */
14349 if (check_final_assignment (lvalue, wfl_op1))
14352 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14354 /* Lhs can be a named variable */
14355 if (JDECL_P (lvalue))
14357 lhs_type = TREE_TYPE (lvalue);
14359 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14360 comment on reason why */
14361 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14363 lhs_type = TREE_TYPE (lvalue);
14364 lvalue_from_array = 1;
14366 /* Or a field access */
14367 else if (TREE_CODE (lvalue) == COMPONENT_REF)
14368 lhs_type = TREE_TYPE (lvalue);
14369 /* Or a function return slot */
14370 else if (TREE_CODE (lvalue) == RESULT_DECL)
14371 lhs_type = TREE_TYPE (lvalue);
14372 /* Otherwise, we might want to try to write into an optimized static
14373 final, this is an of a different nature, reported further on. */
14374 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14375 && resolve_expression_name (wfl_op1, &llvalue))
14377 if (!error_found && check_final_assignment (llvalue, wfl_op1))
14379 /* What we should do instead is resetting the all the flags
14380 previously set, exchange lvalue for llvalue and continue. */
14382 return error_mark_node;
14385 lhs_type = TREE_TYPE (lvalue);
14389 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14393 rhs_type = TREE_TYPE (rhs);
14394 /* 5.1 Try the assignment conversion for builtin type. */
14395 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14397 /* 5.2 If it failed, try a reference conversion */
14398 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14399 lhs_type = promote_type (rhs_type);
14401 /* 15.25.2 If we have a compound assignment, convert RHS into the
14403 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14404 new_rhs = convert (lhs_type, rhs);
14406 /* Explicit cast required. This is an error */
14409 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14410 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14412 char operation [32]; /* Max size known */
14414 /* If the assignment is part of a declaration, we use the WFL of
14415 the declared variable to point out the error and call it a
14416 declaration problem. If the assignment is a genuine =
14417 operator, we call is a operator `=' problem, otherwise we
14418 call it an assignment problem. In both of these last cases,
14419 we use the WFL of the operator to indicate the error. */
14421 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14424 strcpy (operation, "declaration");
14428 wfl = wfl_operator;
14429 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14430 strcpy (operation, "assignment");
14431 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14432 strcpy (operation, "`return'");
14434 strcpy (operation, "`='");
14437 if (!valid_cast_to_p (rhs_type, lhs_type))
14438 parse_error_context
14439 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14440 operation, t1, t2);
14442 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14443 operation, t1, t2);
14444 free (t1); free (t2);
14448 /* Inline read access to java.lang.PRIMTYPE.TYPE */
14450 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14453 return error_mark_node;
14455 /* 10.10: Array Store Exception runtime check */
14456 if (!flag_emit_class_files
14458 && lvalue_from_array
14459 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14462 tree base = lvalue;
14464 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14465 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14466 base = TREE_OPERAND (lvalue, 0);
14469 if (flag_bounds_check)
14470 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14472 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14475 /* Build the invocation of _Jv_CheckArrayStore */
14476 new_rhs = save_expr (new_rhs);
14477 check = build (CALL_EXPR, void_type_node,
14478 build_address_of (soft_checkarraystore_node),
14479 tree_cons (NULL_TREE, base,
14480 build_tree_list (NULL_TREE, new_rhs)),
14482 TREE_SIDE_EFFECTS (check) = 1;
14484 /* We have to decide on an insertion point */
14485 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14488 if (flag_bounds_check)
14490 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14491 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14492 build (COMPOUND_EXPR, void_type_node, t, check);
14495 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14496 check, TREE_OPERAND (lvalue, 1));
14500 /* Make sure the bound check will happen before the store check */
14501 if (flag_bounds_check)
14502 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14503 build (COMPOUND_EXPR, void_type_node,
14504 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14506 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14510 TREE_OPERAND (node, 0) = lvalue;
14511 TREE_OPERAND (node, 1) = new_rhs;
14512 TREE_TYPE (node) = lhs_type;
14516 /* Check that type SOURCE can be cast into type DEST. If the cast
14517 can't occur at all, return 0 otherwise 1. This function is used to
14518 produce accurate error messages on the reasons why an assignment
14522 try_reference_assignconv (lhs_type, rhs)
14523 tree lhs_type, rhs;
14525 tree new_rhs = NULL_TREE;
14526 tree rhs_type = TREE_TYPE (rhs);
14528 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14530 /* `null' may be assigned to any reference type */
14531 if (rhs == null_pointer_node)
14532 new_rhs = null_pointer_node;
14533 /* Try the reference assignment conversion */
14534 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14536 /* This is a magic assignment that we process differently */
14537 else if (rhs == soft_exceptioninfo_call_node)
14543 /* Check that RHS can be converted into LHS_TYPE by the assignment
14544 conversion (5.2), for the cases of RHS being a builtin type. Return
14545 NULL_TREE if the conversion fails or if because RHS isn't of a
14546 builtin type. Return a converted RHS if the conversion is possible. */
14549 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14550 tree wfl_op1, lhs_type, rhs;
14552 tree new_rhs = NULL_TREE;
14553 tree rhs_type = TREE_TYPE (rhs);
14555 /* Zero accepted everywhere */
14556 if (TREE_CODE (rhs) == INTEGER_CST
14557 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14558 && JPRIMITIVE_TYPE_P (rhs_type))
14559 new_rhs = convert (lhs_type, rhs);
14561 /* 5.1.1 Try Identity Conversion,
14562 5.1.2 Try Widening Primitive Conversion */
14563 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14564 new_rhs = convert (lhs_type, rhs);
14566 /* Try a narrowing primitive conversion (5.1.3):
14567 - expression is a constant expression of type int AND
14568 - variable is byte, short or char AND
14569 - The value of the expression is representable in the type of the
14571 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14572 && (lhs_type == byte_type_node || lhs_type == char_type_node
14573 || lhs_type == short_type_node))
14575 if (int_fits_type_p (rhs, lhs_type))
14576 new_rhs = convert (lhs_type, rhs);
14577 else if (wfl_op1) /* Might be called with a NULL */
14578 parse_warning_context
14579 (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'",
14580 print_int_node (rhs), lang_printable_name (lhs_type, 0));
14581 /* Reported a warning that will turn into an error further
14582 down, so we don't return */
14588 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14589 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
14590 0 is the conversion test fails. This implements parts the method
14591 invocation convertion (5.3). */
14594 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14595 tree lhs_type, rhs_type;
14597 /* 5.1.1: This is the identity conversion part. */
14598 if (lhs_type == rhs_type)
14601 /* Reject non primitive types */
14602 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14605 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14606 than a char can't be converted into a char. Short can't too, but
14607 the < test below takes care of that */
14608 if (lhs_type == char_type_node && rhs_type == byte_type_node)
14611 /* Accept all promoted type here. Note, we can't use <= in the test
14612 below, because we still need to bounce out assignments of short
14613 to char and the likes */
14614 if (lhs_type == int_type_node
14615 && (rhs_type == promoted_byte_type_node
14616 || rhs_type == promoted_short_type_node
14617 || rhs_type == promoted_char_type_node
14618 || rhs_type == promoted_boolean_type_node))
14621 /* From here, an integral is widened if its precision is smaller
14622 than the precision of the LHS or if the LHS is a floating point
14623 type, or the RHS is a float and the RHS a double. */
14624 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
14625 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14626 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14627 || (rhs_type == float_type_node && lhs_type == double_type_node))
14633 /* Check that something of SOURCE type can be assigned or cast to
14634 something of DEST type at runtime. Return 1 if the operation is
14635 valid, 0 otherwise. If CAST is set to 1, we're treating the case
14636 were SOURCE is cast into DEST, which borrows a lot of the
14637 assignment check. */
14640 valid_ref_assignconv_cast_p (source, dest, cast)
14645 /* SOURCE or DEST might be null if not from a declared entity. */
14646 if (!source || !dest)
14648 if (JNULLP_TYPE_P (source))
14650 if (TREE_CODE (source) == POINTER_TYPE)
14651 source = TREE_TYPE (source);
14652 if (TREE_CODE (dest) == POINTER_TYPE)
14653 dest = TREE_TYPE (dest);
14654 /* Case where SOURCE is a class type */
14655 if (TYPE_CLASS_P (source))
14657 if (TYPE_CLASS_P (dest))
14658 return (source == dest
14659 || inherits_from_p (source, dest)
14660 || enclosing_context_p (dest, source /*source, dest*/)
14661 || (cast && inherits_from_p (dest, source)));
14662 if (TYPE_INTERFACE_P (dest))
14664 /* If doing a cast and SOURCE is final, the operation is
14665 always correct a compile time (because even if SOURCE
14666 does not implement DEST, a subclass of SOURCE might). */
14667 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14669 /* Otherwise, SOURCE must implement DEST */
14670 return interface_of_p (dest, source);
14672 /* DEST is an array, cast permited if SOURCE is of Object type */
14673 return (cast && source == object_type_node ? 1 : 0);
14675 if (TYPE_INTERFACE_P (source))
14677 if (TYPE_CLASS_P (dest))
14679 /* If not casting, DEST must be the Object type */
14681 return dest == object_type_node;
14682 /* We're doing a cast. The cast is always valid is class
14683 DEST is not final, otherwise, DEST must implement SOURCE */
14684 else if (!CLASS_FINAL (TYPE_NAME (dest)))
14687 return interface_of_p (source, dest);
14689 if (TYPE_INTERFACE_P (dest))
14691 /* If doing a cast, then if SOURCE and DEST contain method
14692 with the same signature but different return type, then
14693 this is a (compile time) error */
14696 tree method_source, method_dest;
14700 for (method_source = TYPE_METHODS (source); method_source;
14701 method_source = TREE_CHAIN (method_source))
14704 build_java_argument_signature (TREE_TYPE (method_source));
14705 source_type = TREE_TYPE (TREE_TYPE (method_source));
14706 source_name = DECL_NAME (method_source);
14707 for (method_dest = TYPE_METHODS (dest);
14708 method_dest; method_dest = TREE_CHAIN (method_dest))
14710 build_java_argument_signature (TREE_TYPE (method_dest))
14711 && source_name == DECL_NAME (method_dest)
14712 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14718 return source == dest || interface_of_p (dest, source);
14722 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14724 if (TYPE_ARRAY_P (source))
14726 if (TYPE_CLASS_P (dest))
14727 return dest == object_type_node;
14728 /* Can't cast an array to an interface unless the interface is
14729 java.lang.Cloneable */
14730 if (TYPE_INTERFACE_P (dest))
14731 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14734 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14735 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14737 /* In case of severe errors, they turn out null */
14738 if (!dest_element_type || !source_element_type)
14740 if (source_element_type == dest_element_type)
14742 return valid_ref_assignconv_cast_p (source_element_type,
14743 dest_element_type, cast);
14751 valid_cast_to_p (source, dest)
14755 if (TREE_CODE (source) == POINTER_TYPE)
14756 source = TREE_TYPE (source);
14757 if (TREE_CODE (dest) == POINTER_TYPE)
14758 dest = TREE_TYPE (dest);
14760 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14761 return valid_ref_assignconv_cast_p (source, dest, 1);
14763 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14769 /* Method invocation conversion test. Return 1 if type SOURCE can be
14770 converted to type DEST through the methond invocation conversion
14774 do_unary_numeric_promotion (arg)
14777 tree type = TREE_TYPE (arg);
14778 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14779 : TREE_CODE (type) == CHAR_TYPE)
14780 arg = convert (int_type_node, arg);
14784 /* Return a non zero value if SOURCE can be converted into DEST using
14785 the method invocation conversion rule (5.3). */
14787 valid_method_invocation_conversion_p (dest, source)
14790 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14791 && valid_builtin_assignconv_identity_widening_p (dest, source))
14792 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14793 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14794 && valid_ref_assignconv_cast_p (source, dest, 0)));
14797 /* Build an incomplete binop expression. */
14800 build_binop (op, op_location, op1, op2)
14805 tree binop = build (op, NULL_TREE, op1, op2);
14806 TREE_SIDE_EFFECTS (binop) = 1;
14807 /* Store the location of the operator, for better error report. The
14808 string of the operator will be rebuild based on the OP value. */
14809 EXPR_WFL_LINECOL (binop) = op_location;
14813 /* Build the string of the operator retained by NODE. If NODE is part
14814 of a compound expression, add an '=' at the end of the string. This
14815 function is called when an error needs to be reported on an
14816 operator. The string is returned as a pointer to a static character
14820 operator_string (node)
14823 #define BUILD_OPERATOR_STRING(S) \
14825 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14829 static char buffer [10];
14830 switch (TREE_CODE (node))
14832 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14833 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14834 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14835 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14836 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14837 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14838 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14839 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14840 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14841 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14842 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14843 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14844 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14845 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14846 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14847 case GT_EXPR: BUILD_OPERATOR_STRING (">");
14848 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14849 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14850 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14851 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14852 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14853 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14854 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14855 case PREINCREMENT_EXPR: /* Fall through */
14856 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14857 case PREDECREMENT_EXPR: /* Fall through */
14858 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14860 fatal ("unregistered operator %s - operator_string",
14861 tree_code_name [TREE_CODE (node)]);
14864 #undef BUILD_OPERATOR_STRING
14867 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
14870 java_decl_equiv (var_acc1, var_acc2)
14871 tree var_acc1, var_acc2;
14873 if (JDECL_P (var_acc1))
14874 return (var_acc1 == var_acc2);
14876 return (TREE_CODE (var_acc1) == COMPONENT_REF
14877 && TREE_CODE (var_acc2) == COMPONENT_REF
14878 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14879 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14880 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14883 /* Return a non zero value if CODE is one of the operators that can be
14884 used in conjunction with the `=' operator in a compound assignment. */
14887 binop_compound_p (code)
14888 enum tree_code code;
14891 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14892 if (binop_lookup [i] == code)
14895 return i < BINOP_COMPOUND_CANDIDATES;
14898 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
14904 tree c, b, ns, decl;
14906 if (TREE_CODE (t) != MODIFY_EXPR)
14909 c = TREE_OPERAND (t, 1);
14910 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14911 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14912 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14915 /* Now the left branch of the binary operator. */
14916 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14917 if (! (b && TREE_CODE (b) == NOP_EXPR
14918 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14921 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14922 if (! (ns && TREE_CODE (ns) == NOP_EXPR
14923 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14926 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14927 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14928 /* It's got to be the an equivalent decl */
14929 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14931 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14932 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14933 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14934 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14935 /* Change the right part of the BINOP_EXPR */
14936 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14942 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14943 errors but we modify NODE so that it contains the type computed
14944 according to the expression, when it's fixed. Otherwise, we write
14945 error_mark_node as the type. It allows us to further the analysis
14946 of remaining nodes and detects more errors in certain cases. */
14949 patch_binop (node, wfl_op1, wfl_op2)
14954 tree op1 = TREE_OPERAND (node, 0);
14955 tree op2 = TREE_OPERAND (node, 1);
14956 tree op1_type = TREE_TYPE (op1);
14957 tree op2_type = TREE_TYPE (op2);
14958 tree prom_type = NULL_TREE, cn;
14959 int code = TREE_CODE (node);
14961 /* If 1, tell the routine that we have to return error_mark_node
14962 after checking for the initialization of the RHS */
14963 int error_found = 0;
14965 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14969 /* 15.16 Multiplicative operators */
14970 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
14971 case RDIV_EXPR: /* 15.16.2 Division Operator / */
14972 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
14973 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
14974 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14976 if (!JPRIMITIVE_TYPE_P (op1_type))
14977 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14978 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14979 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14980 TREE_TYPE (node) = error_mark_node;
14984 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14985 /* Change the division operator if necessary */
14986 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14987 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14989 if (TREE_CODE (prom_type) == INTEGER_TYPE
14990 && flag_use_divide_subroutine
14991 && ! flag_emit_class_files
14992 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14993 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14995 /* This one is more complicated. FLOATs are processed by a
14996 function call to soft_fmod. Duplicate the value of the
14997 COMPOUND_ASSIGN_P flag. */
14998 if (code == TRUNC_MOD_EXPR)
15000 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
15001 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
15002 TREE_SIDE_EFFECTS (mod)
15003 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15008 /* 15.17 Additive Operators */
15009 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
15011 /* Operation is valid if either one argument is a string
15012 constant, a String object or a StringBuffer crafted for the
15013 purpose of the a previous usage of the String concatenation
15016 if (TREE_CODE (op1) == STRING_CST
15017 || TREE_CODE (op2) == STRING_CST
15018 || JSTRING_TYPE_P (op1_type)
15019 || JSTRING_TYPE_P (op2_type)
15020 || IS_CRAFTED_STRING_BUFFER_P (op1)
15021 || IS_CRAFTED_STRING_BUFFER_P (op2))
15022 return build_string_concatenation (op1, op2);
15024 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
15026 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15028 if (!JPRIMITIVE_TYPE_P (op1_type))
15029 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15030 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15031 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15032 TREE_TYPE (node) = error_mark_node;
15036 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15039 /* 15.18 Shift Operators */
15043 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
15045 if (!JINTEGRAL_TYPE_P (op1_type))
15046 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15049 if (JPRIMITIVE_TYPE_P (op2_type))
15050 parse_error_context (wfl_operator,
15051 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
15052 operator_string (node),
15053 lang_printable_name (op2_type, 0));
15055 parse_error_context (wfl_operator,
15056 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
15057 operator_string (node),
15058 lang_printable_name (op2_type, 0));
15060 TREE_TYPE (node) = error_mark_node;
15065 /* Unary numeric promotion (5.6.1) is performed on each operand
15067 op1 = do_unary_numeric_promotion (op1);
15068 op2 = do_unary_numeric_promotion (op2);
15070 /* The type of the shift expression is the type of the promoted
15071 type of the left-hand operand */
15072 prom_type = TREE_TYPE (op1);
15074 /* Shift int only up to 0x1f and long up to 0x3f */
15075 if (prom_type == int_type_node)
15076 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
15077 build_int_2 (0x1f, 0)));
15079 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
15080 build_int_2 (0x3f, 0)));
15082 /* The >>> operator is a >> operating on unsigned quantities */
15083 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
15086 tree utype = unsigned_type (prom_type);
15087 op1 = convert (utype, op1);
15088 TREE_SET_CODE (node, RSHIFT_EXPR);
15089 TREE_OPERAND (node, 0) = op1;
15090 TREE_OPERAND (node, 1) = op2;
15091 TREE_TYPE (node) = utype;
15092 to_return = convert (prom_type, node);
15093 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
15094 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
15095 TREE_SIDE_EFFECTS (to_return)
15096 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15101 /* 15.19.1 Type Comparison Operator instaceof */
15102 case INSTANCEOF_EXPR:
15104 TREE_TYPE (node) = boolean_type_node;
15106 if (!(op2_type = resolve_type_during_patch (op2)))
15107 return error_mark_node;
15109 /* The first operand must be a reference type or the null type */
15110 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
15111 error_found = 1; /* Error reported further below */
15113 /* The second operand must be a reference type */
15114 if (!JREFERENCE_TYPE_P (op2_type))
15116 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
15117 parse_error_context
15118 (wfl_operator, "Invalid argument `%s' for `instanceof'",
15119 lang_printable_name (op2_type, 0));
15123 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
15125 /* If the first operand is null, the result is always false */
15126 if (op1 == null_pointer_node)
15127 return boolean_false_node;
15128 else if (flag_emit_class_files)
15130 TREE_OPERAND (node, 1) = op2_type;
15131 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
15134 /* Otherwise we have to invoke instance of to figure it out */
15136 return build_instanceof (op1, op2_type);
15138 /* There is no way the expression operand can be an instance of
15139 the type operand. This is a compile time error. */
15142 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15143 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15144 parse_error_context
15145 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15146 t1, lang_printable_name (op2_type, 0));
15153 /* 15.21 Bitwise and Logical Operators */
15157 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15158 /* Binary numeric promotion is performed on both operand and the
15159 expression retain that type */
15160 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15162 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
15163 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15164 /* The type of the bitwise operator expression is BOOLEAN */
15165 prom_type = boolean_type_node;
15168 if (!JINTEGRAL_TYPE_P (op1_type))
15169 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15170 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15171 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15172 TREE_TYPE (node) = error_mark_node;
15174 /* Insert a break here if adding thing before the switch's
15175 break for this case */
15179 /* 15.22 Conditional-And Operator */
15180 case TRUTH_ANDIF_EXPR:
15181 /* 15.23 Conditional-Or Operator */
15182 case TRUTH_ORIF_EXPR:
15183 /* Operands must be of BOOLEAN type */
15184 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
15185 TREE_CODE (op2_type) != BOOLEAN_TYPE)
15187 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15188 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15189 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15190 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15191 TREE_TYPE (node) = boolean_type_node;
15195 /* The type of the conditional operators is BOOLEAN */
15196 prom_type = boolean_type_node;
15199 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15204 /* The type of each of the operands must be a primitive numeric
15206 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15208 if (!JNUMERIC_TYPE_P (op1_type))
15209 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15210 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15211 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15212 TREE_TYPE (node) = boolean_type_node;
15216 /* Binary numeric promotion is performed on the operands */
15217 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15218 /* The type of the relation expression is always BOOLEAN */
15219 prom_type = boolean_type_node;
15222 /* 15.20 Equality Operator */
15225 /* It's time for us to patch the strings. */
15226 if ((cn = patch_string (op1)))
15229 op1_type = TREE_TYPE (op1);
15231 if ((cn = patch_string (op2)))
15234 op2_type = TREE_TYPE (op2);
15237 /* 15.20.1 Numerical Equality Operators == and != */
15238 /* Binary numeric promotion is performed on the operands */
15239 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15240 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15242 /* 15.20.2 Boolean Equality Operators == and != */
15243 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15244 TREE_CODE (op2_type) == BOOLEAN_TYPE)
15245 ; /* Nothing to do here */
15247 /* 15.20.3 Reference Equality Operators == and != */
15248 /* Types have to be either references or the null type. If
15249 they're references, it must be possible to convert either
15250 type to the other by casting conversion. */
15251 else if (op1 == null_pointer_node || op2 == null_pointer_node
15252 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15253 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15254 || valid_ref_assignconv_cast_p (op2_type,
15256 ; /* Nothing to do here */
15258 /* Else we have an error figure what can't be converted into
15259 what and report the error */
15263 t1 = xstrdup (lang_printable_name (op1_type, 0));
15264 parse_error_context
15266 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15267 operator_string (node), t1,
15268 lang_printable_name (op2_type, 0));
15270 TREE_TYPE (node) = boolean_type_node;
15274 prom_type = boolean_type_node;
15279 return error_mark_node;
15281 TREE_OPERAND (node, 0) = op1;
15282 TREE_OPERAND (node, 1) = op2;
15283 TREE_TYPE (node) = prom_type;
15284 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15286 if (flag_emit_xref)
15289 /* fold does not respect side-effect order as required for Java but not C.
15290 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15293 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15294 : ! TREE_SIDE_EFFECTS (node))
15295 node = fold (node);
15299 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15300 zero value, the value of CSTE comes after the valude of STRING */
15303 do_merge_string_cste (cste, string, string_len, after)
15305 const char *string;
15306 int string_len, after;
15308 int len = TREE_STRING_LENGTH (cste) + string_len;
15309 const char *old = TREE_STRING_POINTER (cste);
15310 TREE_STRING_LENGTH (cste) = len;
15311 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15314 strcpy (TREE_STRING_POINTER (cste), string);
15315 strcat (TREE_STRING_POINTER (cste), old);
15319 strcpy (TREE_STRING_POINTER (cste), old);
15320 strcat (TREE_STRING_POINTER (cste), string);
15325 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15326 new STRING_CST on success, NULL_TREE on failure */
15329 merge_string_cste (op1, op2, after)
15333 /* Handle two string constants right away */
15334 if (TREE_CODE (op2) == STRING_CST)
15335 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
15336 TREE_STRING_LENGTH (op2), after);
15338 /* Reasonable integer constant can be treated right away */
15339 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15341 static const char *boolean_true = "true";
15342 static const char *boolean_false = "false";
15343 static const char *null_pointer = "null";
15345 const char *string;
15347 if (op2 == boolean_true_node)
15348 string = boolean_true;
15349 else if (op2 == boolean_false_node)
15350 string = boolean_false;
15351 else if (op2 == null_pointer_node)
15352 string = null_pointer;
15353 else if (TREE_TYPE (op2) == char_type_node)
15355 ch[0] = (char )TREE_INT_CST_LOW (op2);
15360 string = print_int_node (op2);
15362 return do_merge_string_cste (op1, string, strlen (string), after);
15367 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15368 has to be a STRING_CST and the other part must be a STRING_CST or a
15369 INTEGRAL constant. Return a new STRING_CST if the operation
15370 succeed, NULL_TREE otherwise.
15372 If the case we want to optimize for space, we might want to return
15373 NULL_TREE for each invocation of this routine. FIXME */
15376 string_constant_concatenation (op1, op2)
15379 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15384 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15385 rest = (string == op1 ? op2 : op1);
15386 invert = (string == op1 ? 0 : 1 );
15388 /* Walk REST, only if it looks reasonable */
15389 if (TREE_CODE (rest) != STRING_CST
15390 && !IS_CRAFTED_STRING_BUFFER_P (rest)
15391 && !JSTRING_TYPE_P (TREE_TYPE (rest))
15392 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15394 rest = java_complete_tree (rest);
15395 if (rest == error_mark_node)
15396 return error_mark_node;
15397 rest = fold (rest);
15399 return merge_string_cste (string, rest, invert);
15404 /* Implement the `+' operator. Does static optimization if possible,
15405 otherwise create (if necessary) and append elements to a
15406 StringBuffer. The StringBuffer will be carried around until it is
15407 used for a function call or an assignment. Then toString() will be
15408 called on it to turn it into a String object. */
15411 build_string_concatenation (op1, op2)
15415 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15417 if (flag_emit_xref)
15418 return build (PLUS_EXPR, string_type_node, op1, op2);
15420 /* Try to do some static optimization */
15421 if ((result = string_constant_concatenation (op1, op2)))
15424 /* Discard empty strings on either side of the expression */
15425 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15430 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15433 /* If operands are string constant, turn then into object references */
15434 if (TREE_CODE (op1) == STRING_CST)
15435 op1 = patch_string_cst (op1);
15436 if (op2 && TREE_CODE (op2) == STRING_CST)
15437 op2 = patch_string_cst (op2);
15439 /* If either one of the constant is null and the other non null
15440 operand is a String object, return it. */
15441 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15444 /* If OP1 isn't already a StringBuffer, create and
15445 initialize a new one */
15446 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15448 /* Two solutions here:
15449 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15450 2) OP1 is something else, we call new StringBuffer().append(OP1). */
15451 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15452 op1 = BUILD_STRING_BUFFER (op1);
15455 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15456 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15462 /* OP1 is no longer the last node holding a crafted StringBuffer */
15463 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15464 /* Create a node for `{new...,xxx}.append (op2)' */
15466 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15469 /* Mark the last node holding a crafted StringBuffer */
15470 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15472 TREE_SIDE_EFFECTS (op1) = side_effects;
15476 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15477 StringBuffer. If no string were found to be patched, return
15481 patch_string (node)
15484 if (node == error_mark_node)
15485 return error_mark_node;
15486 if (TREE_CODE (node) == STRING_CST)
15487 return patch_string_cst (node);
15488 else if (IS_CRAFTED_STRING_BUFFER_P (node))
15490 int saved = ctxp->explicit_constructor_p;
15491 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15493 /* Temporary disable forbid the use of `this'. */
15494 ctxp->explicit_constructor_p = 0;
15495 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15496 /* String concatenation arguments must be evaluated in order too. */
15497 ret = force_evaluation_order (ret);
15498 /* Restore it at its previous value */
15499 ctxp->explicit_constructor_p = saved;
15505 /* Build the internal representation of a string constant. */
15508 patch_string_cst (node)
15512 if (! flag_emit_class_files)
15514 push_obstacks (&permanent_obstack, &permanent_obstack);
15515 node = get_identifier (TREE_STRING_POINTER (node));
15516 location = alloc_name_constant (CONSTANT_String, node);
15517 node = build_ref_from_constant_pool (location);
15520 TREE_TYPE (node) = string_ptr_type_node;
15521 TREE_CONSTANT (node) = 1;
15525 /* Build an incomplete unary operator expression. */
15528 build_unaryop (op_token, op_location, op1)
15529 int op_token, op_location;
15536 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15537 case MINUS_TK: op = NEGATE_EXPR; break;
15538 case NEG_TK: op = TRUTH_NOT_EXPR; break;
15539 case NOT_TK: op = BIT_NOT_EXPR; break;
15540 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15544 unaryop = build1 (op, NULL_TREE, op1);
15545 TREE_SIDE_EFFECTS (unaryop) = 1;
15546 /* Store the location of the operator, for better error report. The
15547 string of the operator will be rebuild based on the OP value. */
15548 EXPR_WFL_LINECOL (unaryop) = op_location;
15552 /* Special case for the ++/-- operators, since they require an extra
15553 argument to build, which is set to NULL and patched
15554 later. IS_POST_P is 1 if the operator, 0 otherwise. */
15557 build_incdec (op_token, op_location, op1, is_post_p)
15558 int op_token, op_location;
15562 static enum tree_code lookup [2][2] =
15564 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15565 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15567 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
15568 NULL_TREE, op1, NULL_TREE);
15569 TREE_SIDE_EFFECTS (node) = 1;
15570 /* Store the location of the operator, for better error report. The
15571 string of the operator will be rebuild based on the OP value. */
15572 EXPR_WFL_LINECOL (node) = op_location;
15576 /* Build an incomplete cast operator, based on the use of the
15577 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15578 set. java_complete_tree is trained to walk a CONVERT_EXPR even
15579 though its type is already set. */
15582 build_cast (location, type, exp)
15586 tree node = build1 (CONVERT_EXPR, type, exp);
15587 EXPR_WFL_LINECOL (node) = location;
15591 /* Build an incomplete class reference operator. */
15593 build_incomplete_class_ref (location, class_name)
15597 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15598 EXPR_WFL_LINECOL (node) = location;
15602 /* Complete an incomplete class reference operator. */
15604 patch_incomplete_class_ref (node)
15607 tree type = TREE_OPERAND (node, 0);
15610 if (!(ref_type = resolve_type_during_patch (type)))
15611 return error_mark_node;
15613 if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15614 return build_class_ref (ref_type);
15616 /* If we're emitting class files and we have to deal with non
15617 primitive types, we invoke (and consider generating) the
15618 synthetic static method `class$'. */
15619 if (!TYPE_DOT_CLASS (current_class))
15620 build_dot_class_method (current_class);
15622 build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15623 return java_complete_tree (ref_type);
15626 /* 15.14 Unary operators. We return error_mark_node in case of error,
15627 but preserve the type of NODE if the type is fixed. */
15630 patch_unaryop (node, wfl_op)
15634 tree op = TREE_OPERAND (node, 0);
15635 tree op_type = TREE_TYPE (op);
15636 tree prom_type = NULL_TREE, value, decl;
15637 int outer_field_flag = 0;
15638 int code = TREE_CODE (node);
15639 int error_found = 0;
15641 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15645 /* 15.13.2 Postfix Increment Operator ++ */
15646 case POSTINCREMENT_EXPR:
15647 /* 15.13.3 Postfix Increment Operator -- */
15648 case POSTDECREMENT_EXPR:
15649 /* 15.14.1 Prefix Increment Operator ++ */
15650 case PREINCREMENT_EXPR:
15651 /* 15.14.2 Prefix Decrement Operator -- */
15652 case PREDECREMENT_EXPR:
15653 op = decl = strip_out_static_field_access_decl (op);
15654 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15655 /* We might be trying to change an outer field accessed using
15657 if (outer_field_flag)
15659 /* Retrieve the decl of the field we're trying to access. We
15660 do that by first retrieving the function we would call to
15661 access the field. It has been already verified that this
15662 field isn't final */
15663 if (flag_emit_class_files)
15664 decl = TREE_OPERAND (op, 0);
15666 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15667 decl = DECL_FUNCTION_ACCESS_DECL (decl);
15669 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15670 else if (!JDECL_P (decl)
15671 && TREE_CODE (decl) != COMPONENT_REF
15672 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15673 && TREE_CODE (decl) != INDIRECT_REF
15674 && !(TREE_CODE (decl) == COMPOUND_EXPR
15675 && TREE_OPERAND (decl, 1)
15676 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15679 /* Before screaming, check that we're not in fact trying to
15680 increment a optimized static final access, in which case
15681 we issue an different error message. */
15682 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15683 && resolve_expression_name (wfl_op, &lvalue)
15684 && check_final_assignment (lvalue, wfl_op)))
15685 parse_error_context (wfl_operator, "Invalid argument to `%s'",
15686 operator_string (node));
15687 TREE_TYPE (node) = error_mark_node;
15691 if (check_final_assignment (op, wfl_op))
15694 /* From now on, we know that op if a variable and that it has a
15695 valid wfl. We use wfl_op to locate errors related to the
15697 else if (!JNUMERIC_TYPE_P (op_type))
15699 parse_error_context
15700 (wfl_op, "Invalid argument type `%s' to `%s'",
15701 lang_printable_name (op_type, 0), operator_string (node));
15702 TREE_TYPE (node) = error_mark_node;
15707 /* Before the addition, binary numeric promotion is performed on
15708 both operands, if really necessary */
15709 if (JINTEGRAL_TYPE_P (op_type))
15711 value = build_int_2 (1, 0);
15712 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15716 value = build_int_2 (1, 0);
15718 binary_numeric_promotion (op_type,
15719 TREE_TYPE (value), &op, &value);
15722 /* We remember we might be accessing an outer field */
15723 if (outer_field_flag)
15725 /* We re-generate an access to the field */
15726 value = build (PLUS_EXPR, TREE_TYPE (op),
15727 build_outer_field_access (wfl_op, decl), value);
15729 /* And we patch the original access$() into a write
15730 with plus_op as a rhs */
15731 return outer_field_access_fix (node, op, value);
15734 /* And write back into the node. */
15735 TREE_OPERAND (node, 0) = op;
15736 TREE_OPERAND (node, 1) = value;
15737 /* Convert the overall back into its original type, if
15738 necessary, and return */
15739 if (JINTEGRAL_TYPE_P (op_type))
15740 return fold (node);
15742 return fold (convert (op_type, node));
15746 /* 15.14.3 Unary Plus Operator + */
15747 case UNARY_PLUS_EXPR:
15748 /* 15.14.4 Unary Minus Operator - */
15750 if (!JNUMERIC_TYPE_P (op_type))
15752 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15753 TREE_TYPE (node) = error_mark_node;
15756 /* Unary numeric promotion is performed on operand */
15759 op = do_unary_numeric_promotion (op);
15760 prom_type = TREE_TYPE (op);
15761 if (code == UNARY_PLUS_EXPR)
15766 /* 15.14.5 Bitwise Complement Operator ~ */
15768 if (!JINTEGRAL_TYPE_P (op_type))
15770 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15771 TREE_TYPE (node) = error_mark_node;
15776 op = do_unary_numeric_promotion (op);
15777 prom_type = TREE_TYPE (op);
15781 /* 15.14.6 Logical Complement Operator ! */
15782 case TRUTH_NOT_EXPR:
15783 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15785 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15786 /* But the type is known. We will report an error if further
15787 attempt of a assignment is made with this rhs */
15788 TREE_TYPE (node) = boolean_type_node;
15792 prom_type = boolean_type_node;
15795 /* 15.15 Cast Expression */
15797 value = patch_cast (node, wfl_operator);
15798 if (value == error_mark_node)
15800 /* If this cast is part of an assignment, we tell the code
15801 that deals with it not to complain about a mismatch,
15802 because things have been cast, anyways */
15803 TREE_TYPE (node) = error_mark_node;
15808 value = fold (value);
15809 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15816 return error_mark_node;
15818 /* There are cases where node has been replaced by something else
15819 and we don't end up returning here: UNARY_PLUS_EXPR,
15820 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15821 TREE_OPERAND (node, 0) = fold (op);
15822 TREE_TYPE (node) = prom_type;
15823 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15824 return fold (node);
15827 /* Generic type resolution that sometimes takes place during node
15828 patching. Returned the resolved type or generate an error
15829 message. Return the resolved type or NULL_TREE. */
15832 resolve_type_during_patch (type)
15835 if (unresolved_type_p (type, NULL))
15837 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15840 parse_error_context (type,
15841 "Class `%s' not found in type declaration",
15842 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15847 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15848 return TREE_TYPE (type_decl);
15853 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15854 found. Otherwise NODE or something meant to replace it is returned. */
15857 patch_cast (node, wfl_operator)
15861 tree op = TREE_OPERAND (node, 0);
15862 tree op_type = TREE_TYPE (op);
15863 tree cast_type = TREE_TYPE (node);
15866 /* First resolve OP_TYPE if unresolved */
15867 if (!(cast_type = resolve_type_during_patch (cast_type)))
15868 return error_mark_node;
15870 /* Check on cast that are proven correct at compile time */
15871 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15874 if (cast_type == op_type)
15877 /* float and double type are converted to the original type main
15878 variant and then to the target type. */
15879 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15880 op = convert (integer_type_node, op);
15882 /* Try widening/narowwing convertion. Potentially, things need
15883 to be worked out in gcc so we implement the extreme cases
15884 correctly. fold_convert() needs to be fixed. */
15885 return convert (cast_type, op);
15888 /* It's also valid to cast a boolean into a boolean */
15889 if (op_type == boolean_type_node && cast_type == boolean_type_node)
15892 /* null can be casted to references */
15893 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15894 return build_null_of_type (cast_type);
15896 /* The remaining legal casts involve conversion between reference
15897 types. Check for their compile time correctness. */
15898 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
15899 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15901 TREE_TYPE (node) = promote_type (cast_type);
15902 /* Now, the case can be determined correct at compile time if
15903 OP_TYPE can be converted into CAST_TYPE by assignment
15904 conversion (5.2) */
15906 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15908 TREE_SET_CODE (node, NOP_EXPR);
15912 if (flag_emit_class_files)
15914 TREE_SET_CODE (node, CONVERT_EXPR);
15918 /* The cast requires a run-time check */
15919 return build (CALL_EXPR, promote_type (cast_type),
15920 build_address_of (soft_checkcast_node),
15921 tree_cons (NULL_TREE, build_class_ref (cast_type),
15922 build_tree_list (NULL_TREE, op)),
15926 /* Any other casts are proven incorrect at compile time */
15927 t1 = xstrdup (lang_printable_name (op_type, 0));
15928 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15929 t1, lang_printable_name (cast_type, 0));
15931 return error_mark_node;
15934 /* Build a null constant and give it the type TYPE. */
15937 build_null_of_type (type)
15940 tree node = build_int_2 (0, 0);
15941 TREE_TYPE (node) = promote_type (type);
15945 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15946 a list of indices. */
15948 build_array_ref (location, array, index)
15952 tree node = build (ARRAY_REF, NULL_TREE, array, index);
15953 EXPR_WFL_LINECOL (node) = location;
15957 /* 15.12 Array Access Expression */
15960 patch_array_ref (node)
15963 tree array = TREE_OPERAND (node, 0);
15964 tree array_type = TREE_TYPE (array);
15965 tree index = TREE_OPERAND (node, 1);
15966 tree index_type = TREE_TYPE (index);
15967 int error_found = 0;
15969 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15971 if (TREE_CODE (array_type) == POINTER_TYPE)
15972 array_type = TREE_TYPE (array_type);
15974 /* The array reference must be an array */
15975 if (!TYPE_ARRAY_P (array_type))
15977 parse_error_context
15979 "`[]' can only be applied to arrays. It can't be applied to `%s'",
15980 lang_printable_name (array_type, 0));
15981 TREE_TYPE (node) = error_mark_node;
15985 /* The array index undergoes unary numeric promotion. The promoted
15986 type must be int */
15987 index = do_unary_numeric_promotion (index);
15988 if (TREE_TYPE (index) != int_type_node)
15990 if (valid_cast_to_p (index_type, int_type_node))
15991 parse_error_context (wfl_operator,
15992 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15993 lang_printable_name (index_type, 0));
15995 parse_error_context (wfl_operator,
15996 "Incompatible type for `[]'. Can't convert `%s' to `int'",
15997 lang_printable_name (index_type, 0));
15998 TREE_TYPE (node) = error_mark_node;
16003 return error_mark_node;
16005 array_type = TYPE_ARRAY_ELEMENT (array_type);
16007 if (flag_emit_class_files || flag_emit_xref)
16009 TREE_OPERAND (node, 0) = array;
16010 TREE_OPERAND (node, 1) = index;
16014 /* The save_expr is for correct evaluation order. It would be cleaner
16015 to use force_evaluation_order (see comment there), but that is
16016 difficult when we also have to deal with bounds checking. */
16017 if (TREE_SIDE_EFFECTS (index))
16018 array = save_expr (array);
16019 node = build_java_arrayaccess (array, array_type, index);
16020 if (TREE_SIDE_EFFECTS (index))
16021 node = build (COMPOUND_EXPR, array_type, array, node);
16023 TREE_TYPE (node) = array_type;
16027 /* 15.9 Array Creation Expressions */
16030 build_newarray_node (type, dims, extra_dims)
16036 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
16037 build_int_2 (extra_dims, 0));
16042 patch_newarray (node)
16045 tree type = TREE_OPERAND (node, 0);
16046 tree dims = TREE_OPERAND (node, 1);
16047 tree cdim, array_type;
16048 int error_found = 0;
16050 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
16052 /* Dimension types are verified. It's better for the types to be
16053 verified in order. */
16054 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
16057 tree dim = TREE_VALUE (cdim);
16059 /* Dim might have been saved during its evaluation */
16060 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
16062 /* The type of each specified dimension must be an integral type. */
16063 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
16066 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
16067 promoted type must be int. */
16070 dim = do_unary_numeric_promotion (dim);
16071 if (TREE_TYPE (dim) != int_type_node)
16075 /* Report errors on types here */
16078 parse_error_context
16079 (TREE_PURPOSE (cdim),
16080 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
16081 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
16082 "Explicit cast needed to" : "Can't"),
16083 lang_printable_name (TREE_TYPE (dim), 0));
16087 TREE_PURPOSE (cdim) = NULL_TREE;
16090 /* Resolve array base type if unresolved */
16091 if (!(type = resolve_type_during_patch (type)))
16096 /* We don't want further evaluation of this bogus array creation
16098 TREE_TYPE (node) = error_mark_node;
16099 return error_mark_node;
16102 /* Set array_type to the actual (promoted) array type of the result. */
16103 if (TREE_CODE (type) == RECORD_TYPE)
16104 type = build_pointer_type (type);
16105 while (--xdims >= 0)
16107 type = promote_type (build_java_array_type (type, -1));
16109 dims = nreverse (dims);
16111 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
16115 = build_java_array_type (type,
16116 TREE_CODE (cdim) == INTEGER_CST
16117 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
16119 array_type = promote_type (array_type);
16121 dims = nreverse (dims);
16123 /* The node is transformed into a function call. Things are done
16124 differently according to the number of dimensions. If the number
16125 of dimension is equal to 1, then the nature of the base type
16126 (primitive or not) matters. */
16128 return build_new_array (type, TREE_VALUE (dims));
16130 /* Can't reuse what's already written in expr.c because it uses the
16131 JVM stack representation. Provide a build_multianewarray. FIXME */
16132 return build (CALL_EXPR, array_type,
16133 build_address_of (soft_multianewarray_node),
16134 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
16135 tree_cons (NULL_TREE,
16136 build_int_2 (ndims, 0), dims )),
16140 /* 10.6 Array initializer. */
16142 /* Build a wfl for array element that don't have one, so we can
16143 pin-point errors. */
16146 maybe_build_array_element_wfl (node)
16149 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16150 return build_expr_wfl (NULL_TREE, ctxp->filename,
16151 ctxp->elc.line, ctxp->elc.prev_col);
16156 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16157 identification of initialized arrays easier to detect during walk
16161 build_new_array_init (location, values)
16165 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16166 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16167 EXPR_WFL_LINECOL (to_return) = location;
16171 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16172 occurred. Otherwise return NODE after having set its type
16176 patch_new_array_init (type, node)
16179 int error_seen = 0;
16180 tree current, element_type;
16181 HOST_WIDE_INT length;
16182 int all_constant = 1;
16183 tree init = TREE_OPERAND (node, 0);
16185 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16187 parse_error_context (node,
16188 "Invalid array initializer for non-array type `%s'",
16189 lang_printable_name (type, 1));
16190 return error_mark_node;
16192 type = TREE_TYPE (type);
16193 element_type = TYPE_ARRAY_ELEMENT (type);
16195 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16197 for (length = 0, current = CONSTRUCTOR_ELTS (init);
16198 current; length++, current = TREE_CHAIN (current))
16200 tree elt = TREE_VALUE (current);
16201 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16203 error_seen |= array_constructor_check_entry (element_type, current);
16204 elt = TREE_VALUE (current);
16205 /* When compiling to native code, STRING_CST is converted to
16206 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16207 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16212 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16213 TREE_PURPOSE (current) = NULL_TREE;
16216 if (elt && TREE_VALUE (elt) == error_mark_node)
16221 return error_mark_node;
16223 /* Create a new type. We can't reuse the one we have here by
16224 patching its dimension because it originally is of dimension -1
16225 hence reused by gcc. This would prevent triangular arrays. */
16226 type = build_java_array_type (element_type, length);
16227 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16228 TREE_TYPE (node) = promote_type (type);
16229 TREE_CONSTANT (init) = all_constant;
16230 TREE_CONSTANT (node) = all_constant;
16234 /* Verify that one entry of the initializer element list can be
16235 assigned to the array base type. Report 1 if an error occurred, 0
16239 array_constructor_check_entry (type, entry)
16242 char *array_type_string = NULL; /* For error reports */
16243 tree value, type_value, new_value, wfl_value, patched;
16244 int error_seen = 0;
16246 new_value = NULL_TREE;
16247 wfl_value = TREE_VALUE (entry);
16249 push_obstacks (&permanent_obstack, &permanent_obstack);
16250 value = java_complete_tree (TREE_VALUE (entry));
16251 /* patch_string return error_mark_node if arg is error_mark_node */
16252 if ((patched = patch_string (value)))
16254 if (value == error_mark_node)
16257 type_value = TREE_TYPE (value);
16259 /* At anytime, try_builtin_assignconv can report a warning on
16260 constant overflow during narrowing. */
16261 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16262 new_value = try_builtin_assignconv (wfl_operator, type, value);
16263 if (!new_value && (new_value = try_reference_assignconv (type, value)))
16264 type_value = promote_type (type);
16267 /* Check and report errors */
16270 const char *msg = (!valid_cast_to_p (type_value, type) ?
16271 "Can't" : "Explicit cast needed to");
16272 if (!array_type_string)
16273 array_type_string = xstrdup (lang_printable_name (type, 1));
16274 parse_error_context
16275 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16276 msg, lang_printable_name (type_value, 1), array_type_string);
16282 new_value = maybe_build_primttype_type_ref (new_value, wfl_value);
16283 TREE_VALUE (entry) = new_value;
16286 if (array_type_string)
16287 free (array_type_string);
16289 TREE_PURPOSE (entry) = NULL_TREE;
16294 build_this (location)
16297 tree node = build_wfl_node (this_identifier_node);
16298 TREE_SET_CODE (node, THIS_EXPR);
16299 EXPR_WFL_LINECOL (node) = location;
16303 /* 14.15 The return statement. It builds a modify expression that
16304 assigns the returned value to the RESULT_DECL that hold the value
16308 build_return (location, op)
16312 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16313 EXPR_WFL_LINECOL (node) = location;
16314 node = build_debugable_stmt (location, node);
16319 patch_return (node)
16322 tree return_exp = TREE_OPERAND (node, 0);
16323 tree meth = current_function_decl;
16324 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16325 int error_found = 0;
16327 TREE_TYPE (node) = error_mark_node;
16328 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16330 /* It's invalid to have a return value within a function that is
16331 declared with the keyword void or that is a constructor */
16332 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16335 /* It's invalid to use a return statement in a static block */
16336 if (DECL_CLINIT_P (current_function_decl))
16339 /* It's invalid to have a no return value within a function that
16340 isn't declared with the keyword `void' */
16341 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16344 if (in_instance_initializer)
16349 if (in_instance_initializer)
16350 parse_error_context (wfl_operator,
16351 "`return' inside instance initializer");
16353 else if (DECL_CLINIT_P (current_function_decl))
16354 parse_error_context (wfl_operator,
16355 "`return' inside static initializer");
16357 else if (!DECL_CONSTRUCTOR_P (meth))
16359 char *t = xstrdup (lang_printable_name (mtype, 0));
16360 parse_error_context (wfl_operator,
16361 "`return' with%s value from `%s %s'",
16362 (error_found == 1 ? "" : "out"),
16363 t, lang_printable_name (meth, 0));
16367 parse_error_context (wfl_operator,
16368 "`return' with value from constructor `%s'",
16369 lang_printable_name (meth, 0));
16370 return error_mark_node;
16373 /* If we have a return_exp, build a modify expression and expand
16374 it. Note: at that point, the assignment is declared valid, but we
16375 may want to carry some more hacks */
16378 tree exp = java_complete_tree (return_exp);
16379 tree modify, patched;
16381 /* If the function returned value and EXP are booleans, EXP has
16382 to be converted into the type of DECL_RESULT, which is integer
16383 (see complete_start_java_method) */
16384 if (TREE_TYPE (exp) == boolean_type_node &&
16385 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16386 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16388 /* `null' can be assigned to a function returning a reference */
16389 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16390 exp == null_pointer_node)
16391 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16393 if ((patched = patch_string (exp)))
16396 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16397 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16398 modify = java_complete_tree (modify);
16400 if (modify != error_mark_node)
16402 TREE_SIDE_EFFECTS (modify) = 1;
16403 TREE_OPERAND (node, 0) = modify;
16406 return error_mark_node;
16408 TREE_TYPE (node) = void_type_node;
16409 TREE_SIDE_EFFECTS (node) = 1;
16413 /* 14.8 The if Statement */
16416 build_if_else_statement (location, expression, if_body, else_body)
16418 tree expression, if_body, else_body;
16422 else_body = empty_stmt_node;
16423 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16424 EXPR_WFL_LINECOL (node) = location;
16425 node = build_debugable_stmt (location, node);
16430 patch_if_else_statement (node)
16433 tree expression = TREE_OPERAND (node, 0);
16435 TREE_TYPE (node) = error_mark_node;
16436 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16438 /* The type of expression must be boolean */
16439 if (TREE_TYPE (expression) != boolean_type_node
16440 && TREE_TYPE (expression) != promoted_boolean_type_node)
16442 parse_error_context
16444 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
16445 lang_printable_name (TREE_TYPE (expression), 0));
16446 return error_mark_node;
16449 TREE_TYPE (node) = void_type_node;
16450 TREE_SIDE_EFFECTS (node) = 1;
16451 CAN_COMPLETE_NORMALLY (node)
16452 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16453 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16457 /* 14.6 Labeled Statements */
16459 /* Action taken when a lableled statement is parsed. a new
16460 LABELED_BLOCK_EXPR is created. No statement is attached to the
16461 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
16464 build_labeled_block (location, label)
16469 tree label_decl, node;
16470 if (label == NULL_TREE || label == continue_identifier_node)
16471 label_name = label;
16474 label_name = merge_qualified_name (label_id, label);
16475 /* Issue an error if we try to reuse a label that was previously
16477 if (IDENTIFIER_LOCAL_VALUE (label_name))
16479 EXPR_WFL_LINECOL (wfl_operator) = location;
16480 parse_error_context (wfl_operator,
16481 "Declaration of `%s' shadows a previous label declaration",
16482 IDENTIFIER_POINTER (label));
16483 EXPR_WFL_LINECOL (wfl_operator) =
16484 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16485 parse_error_context (wfl_operator,
16486 "This is the location of the previous declaration of label `%s'",
16487 IDENTIFIER_POINTER (label));
16488 java_error_count--;
16492 label_decl = create_label_decl (label_name);
16493 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16494 EXPR_WFL_LINECOL (node) = location;
16495 TREE_SIDE_EFFECTS (node) = 1;
16499 /* A labeled statement LBE is attached a statement. */
16502 finish_labeled_statement (lbe, statement)
16503 tree lbe; /* Labeled block expr */
16506 /* In anyways, tie the loop to its statement */
16507 LABELED_BLOCK_BODY (lbe) = statement;
16508 pop_labeled_block ();
16509 POP_LABELED_BLOCK ();
16513 /* 14.10, 14.11, 14.12 Loop Statements */
16515 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16519 build_new_loop (loop_body)
16522 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
16523 TREE_SIDE_EFFECTS (loop) = 1;
16528 /* Create a loop body according to the following structure:
16530 COMPOUND_EXPR (loop main body)
16531 EXIT_EXPR (this order is for while/for loops.
16532 LABELED_BLOCK_EXPR the order is reversed for do loops)
16533 LABEL_DECL (a continue occuring here branches at the
16534 BODY end of this labeled block)
16537 REVERSED, if non zero, tells that the loop condition expr comes
16538 after the body, like in the do-while loop.
16540 To obtain a loop, the loop body structure described above is
16541 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16544 LABEL_DECL (use this label to exit the loop)
16546 <structure described above> */
16549 build_loop_body (location, condition, reversed)
16554 tree first, second, body;
16556 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16557 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16558 condition = build_debugable_stmt (location, condition);
16559 TREE_SIDE_EFFECTS (condition) = 1;
16561 body = build_labeled_block (0, continue_identifier_node);
16562 first = (reversed ? body : condition);
16563 second = (reversed ? condition : body);
16565 build (COMPOUND_EXPR, NULL_TREE,
16566 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16569 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16570 their order) on the current loop. Unlink the current loop from the
16574 finish_loop_body (location, condition, body, reversed)
16576 tree condition, body;
16579 tree to_return = ctxp->current_loop;
16580 tree loop_body = LOOP_EXPR_BODY (to_return);
16583 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16584 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16585 The real EXIT_EXPR is one operand further. */
16586 EXPR_WFL_LINECOL (cnode) = location;
16587 /* This one is for accurate error reports */
16588 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16589 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16591 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16596 /* Tailored version of finish_loop_body for FOR loops, when FOR
16597 loops feature the condition part */
16600 finish_for_loop (location, condition, update, body)
16602 tree condition, update, body;
16604 /* Put the condition and the loop body in place */
16605 tree loop = finish_loop_body (location, condition, body, 0);
16606 /* LOOP is the current loop which has been now popped of the loop
16607 stack. Install the update block */
16608 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16612 /* Try to find the loop a block might be related to. This comprises
16613 the case where the LOOP_EXPR is found as the second operand of a
16614 COMPOUND_EXPR, because the loop happens to have an initialization
16615 part, then expressed as the first operand of the COMPOUND_EXPR. If
16616 the search finds something, 1 is returned. Otherwise, 0 is
16617 returned. The search is assumed to start from a
16618 LABELED_BLOCK_EXPR's block. */
16621 search_loop (statement)
16624 if (TREE_CODE (statement) == LOOP_EXPR)
16627 if (TREE_CODE (statement) == BLOCK)
16628 statement = BLOCK_SUBBLOCKS (statement);
16632 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16633 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16634 statement = TREE_OPERAND (statement, 1);
16636 return (TREE_CODE (statement) == LOOP_EXPR
16637 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16640 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16641 returned otherwise. */
16644 labeled_block_contains_loop_p (block, loop)
16650 if (LABELED_BLOCK_BODY (block) == loop)
16653 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16659 /* If the loop isn't surrounded by a labeled statement, create one and
16660 insert LOOP as its body. */
16663 patch_loop_statement (loop)
16668 TREE_TYPE (loop) = void_type_node;
16669 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16672 loop_label = build_labeled_block (0, NULL_TREE);
16673 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16674 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16675 LABELED_BLOCK_BODY (loop_label) = loop;
16676 PUSH_LABELED_BLOCK (loop_label);
16680 /* 14.13, 14.14: break and continue Statements */
16682 /* Build a break or a continue statement. a null NAME indicates an
16683 unlabeled break/continue statement. */
16686 build_bc_statement (location, is_break, name)
16687 int location, is_break;
16690 tree break_continue, label_block_expr = NULL_TREE;
16694 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
16695 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16696 /* Null means that we don't have a target for this named
16697 break/continue. In this case, we make the target to be the
16698 label name, so that the error can be reported accuratly in
16699 patch_bc_statement. */
16700 label_block_expr = EXPR_WFL_NODE (name);
16702 /* Unlabeled break/continue will be handled during the
16703 break/continue patch operation */
16705 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16707 IS_BREAK_STMT_P (break_continue) = is_break;
16708 TREE_SIDE_EFFECTS (break_continue) = 1;
16709 EXPR_WFL_LINECOL (break_continue) = location;
16710 break_continue = build_debugable_stmt (location, break_continue);
16711 return break_continue;
16714 /* Verification of a break/continue statement. */
16717 patch_bc_statement (node)
16720 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16721 tree labeled_block = ctxp->current_labeled_block;
16722 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16724 /* Having an identifier here means that the target is unknown. */
16725 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16727 parse_error_context (wfl_operator, "No label definition found for `%s'",
16728 IDENTIFIER_POINTER (bc_label));
16729 return error_mark_node;
16731 if (! IS_BREAK_STMT_P (node))
16733 /* It's a continue statement. */
16734 for (;; labeled_block = TREE_CHAIN (labeled_block))
16736 if (labeled_block == NULL_TREE)
16738 if (bc_label == NULL_TREE)
16739 parse_error_context (wfl_operator,
16740 "`continue' must be in loop");
16742 parse_error_context
16743 (wfl_operator, "continue label `%s' does not name a loop",
16744 IDENTIFIER_POINTER (bc_label));
16745 return error_mark_node;
16747 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16748 == continue_identifier_node)
16749 && (bc_label == NULL_TREE
16750 || TREE_CHAIN (labeled_block) == bc_label))
16752 bc_label = labeled_block;
16757 else if (!bc_label)
16759 for (;; labeled_block = TREE_CHAIN (labeled_block))
16761 if (labeled_block == NULL_TREE)
16763 parse_error_context (wfl_operator,
16764 "`break' must be in loop or switch");
16765 return error_mark_node;
16767 target_stmt = LABELED_BLOCK_BODY (labeled_block);
16768 if (TREE_CODE (target_stmt) == SWITCH_EXPR
16769 || search_loop (target_stmt))
16771 bc_label = labeled_block;
16777 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16778 CAN_COMPLETE_NORMALLY (bc_label) = 1;
16780 /* Our break/continue don't return values. */
16781 TREE_TYPE (node) = void_type_node;
16782 /* Encapsulate the break within a compound statement so that it's
16783 expanded all the times by expand_expr (and not clobbered
16784 sometimes, like after a if statement) */
16785 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16786 TREE_SIDE_EFFECTS (node) = 1;
16790 /* Process the exit expression belonging to a loop. Its type must be
16794 patch_exit_expr (node)
16797 tree expression = TREE_OPERAND (node, 0);
16798 TREE_TYPE (node) = error_mark_node;
16799 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16801 /* The type of expression must be boolean */
16802 if (TREE_TYPE (expression) != boolean_type_node)
16804 parse_error_context
16806 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
16807 lang_printable_name (TREE_TYPE (expression), 0));
16808 return error_mark_node;
16810 /* Now we know things are allright, invert the condition, fold and
16812 TREE_OPERAND (node, 0) =
16813 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16815 if (! integer_zerop (TREE_OPERAND (node, 0))
16816 && ctxp->current_loop != NULL_TREE
16817 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16818 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16819 if (! integer_onep (TREE_OPERAND (node, 0)))
16820 CAN_COMPLETE_NORMALLY (node) = 1;
16823 TREE_TYPE (node) = void_type_node;
16827 /* 14.9 Switch statement */
16830 patch_switch_statement (node)
16833 tree se = TREE_OPERAND (node, 0), se_type;
16835 /* Complete the switch expression */
16836 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16837 se_type = TREE_TYPE (se);
16838 /* The type of the switch expression must be char, byte, short or
16840 if (!JINTEGRAL_TYPE_P (se_type))
16842 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16843 parse_error_context (wfl_operator,
16844 "Incompatible type for `switch'. Can't convert `%s' to `int'",
16845 lang_printable_name (se_type, 0));
16846 /* This is what java_complete_tree will check */
16847 TREE_OPERAND (node, 0) = error_mark_node;
16848 return error_mark_node;
16851 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16853 /* Ready to return */
16854 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16856 TREE_TYPE (node) = error_mark_node;
16857 return error_mark_node;
16859 TREE_TYPE (node) = void_type_node;
16860 TREE_SIDE_EFFECTS (node) = 1;
16861 CAN_COMPLETE_NORMALLY (node)
16862 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16863 || ! SWITCH_HAS_DEFAULT (node);
16867 /* 14.18 The try/catch statements */
16870 build_try_statement (location, try_block, catches)
16872 tree try_block, catches;
16874 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16875 EXPR_WFL_LINECOL (node) = location;
16880 build_try_finally_statement (location, try_block, finally)
16882 tree try_block, finally;
16884 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16885 EXPR_WFL_LINECOL (node) = location;
16890 patch_try_statement (node)
16893 int error_found = 0;
16894 tree try = TREE_OPERAND (node, 0);
16895 /* Exception handlers are considered in left to right order */
16896 tree catch = nreverse (TREE_OPERAND (node, 1));
16897 tree current, caught_type_list = NULL_TREE;
16899 /* Check catch clauses, if any. Every time we find an error, we try
16900 to process the next catch clause. We process the catch clause before
16901 the try block so that when processing the try block we can check thrown
16902 exceptions againts the caught type list. */
16903 for (current = catch; current; current = TREE_CHAIN (current))
16905 tree carg_decl, carg_type;
16906 tree sub_current, catch_block, catch_clause;
16909 /* At this point, the structure of the catch clause is
16910 CATCH_EXPR (catch node)
16911 BLOCK (with the decl of the parameter)
16913 MODIFY_EXPR (assignment of the catch parameter)
16914 BLOCK (catch clause block)
16916 catch_clause = TREE_OPERAND (current, 0);
16917 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16918 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16920 /* Catch clauses can't have more than one parameter declared,
16921 but it's already enforced by the grammar. Make sure that the
16922 only parameter of the clause statement in of class Throwable
16923 or a subclass of Throwable, but that was done earlier. The
16924 catch clause parameter type has also been resolved. */
16926 /* Just make sure that the catch clause parameter type inherits
16927 from java.lang.Throwable */
16928 if (!inherits_from_p (carg_type, throwable_type_node))
16930 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16931 parse_error_context (wfl_operator,
16932 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16933 lang_printable_name (carg_type, 0));
16938 /* Partial check for unreachable catch statement: The catch
16939 clause is reachable iff is no earlier catch block A in
16940 the try statement such that the type of the catch
16941 clause's parameter is the same as or a subclass of the
16942 type of A's parameter */
16944 for (sub_current = catch;
16945 sub_current != current; sub_current = TREE_CHAIN (sub_current))
16947 tree sub_catch_clause, decl;
16948 sub_catch_clause = TREE_OPERAND (sub_current, 0);
16949 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16951 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16953 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16954 parse_error_context
16956 "`catch' not reached because of the catch clause at line %d",
16957 EXPR_WFL_LINENO (sub_current));
16958 unreachable = error_found = 1;
16962 /* Complete the catch clause block */
16963 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16964 if (catch_block == error_mark_node)
16969 if (CAN_COMPLETE_NORMALLY (catch_block))
16970 CAN_COMPLETE_NORMALLY (node) = 1;
16971 TREE_OPERAND (current, 0) = catch_block;
16976 /* Things to do here: the exception must be thrown */
16978 /* Link this type to the caught type list */
16979 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16982 PUSH_EXCEPTIONS (caught_type_list);
16983 if ((try = java_complete_tree (try)) == error_mark_node)
16985 if (CAN_COMPLETE_NORMALLY (try))
16986 CAN_COMPLETE_NORMALLY (node) = 1;
16989 /* Verification ends here */
16991 return error_mark_node;
16993 TREE_OPERAND (node, 0) = try;
16994 TREE_OPERAND (node, 1) = catch;
16995 TREE_TYPE (node) = void_type_node;
16999 /* 14.17 The synchronized Statement */
17002 patch_synchronized_statement (node, wfl_op1)
17003 tree node, wfl_op1;
17005 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
17006 tree block = TREE_OPERAND (node, 1);
17008 tree enter, exit, expr_decl, assignment;
17010 if (expr == error_mark_node)
17012 block = java_complete_tree (block);
17016 /* The TYPE of expr must be a reference type */
17017 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
17019 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17020 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
17021 lang_printable_name (TREE_TYPE (expr), 0));
17022 return error_mark_node;
17025 if (flag_emit_xref)
17027 TREE_OPERAND (node, 0) = expr;
17028 TREE_OPERAND (node, 1) = java_complete_tree (block);
17029 CAN_COMPLETE_NORMALLY (node) = 1;
17033 /* Generate a try-finally for the synchronized statement, except
17034 that the handler that catches all throw exception calls
17035 _Jv_MonitorExit and then rethrow the exception.
17036 The synchronized statement is then implemented as:
17039 _Jv_MonitorEnter (expression)
17041 _Jv_MonitorExit (expression)
17045 e = _Jv_exception_info ();
17046 _Jv_MonitorExit (expression)
17050 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
17051 BUILD_MONITOR_ENTER (enter, expr_decl);
17052 BUILD_MONITOR_EXIT (exit, expr_decl);
17053 CAN_COMPLETE_NORMALLY (enter) = 1;
17054 CAN_COMPLETE_NORMALLY (exit) = 1;
17055 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
17056 TREE_SIDE_EFFECTS (assignment) = 1;
17057 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
17058 build (COMPOUND_EXPR, NULL_TREE,
17059 build (WITH_CLEANUP_EXPR, NULL_TREE,
17060 build (COMPOUND_EXPR, NULL_TREE,
17061 assignment, enter),
17064 node = build_expr_block (node, expr_decl);
17066 return java_complete_tree (node);
17069 /* 14.16 The throw Statement */
17072 patch_throw_statement (node, wfl_op1)
17073 tree node, wfl_op1;
17075 tree expr = TREE_OPERAND (node, 0);
17076 tree type = TREE_TYPE (expr);
17077 int unchecked_ok = 0, tryblock_throws_ok = 0;
17079 /* Thrown expression must be assignable to java.lang.Throwable */
17080 if (!try_reference_assignconv (throwable_type_node, expr))
17082 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17083 parse_error_context (wfl_operator,
17084 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
17085 lang_printable_name (type, 0));
17086 /* If the thrown expression was a reference, we further the
17087 compile-time check. */
17088 if (!JREFERENCE_TYPE_P (type))
17089 return error_mark_node;
17092 /* At least one of the following must be true */
17094 /* The type of the throw expression is a not checked exception,
17095 i.e. is a unchecked expression. */
17096 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
17098 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17099 /* An instance can't throw a checked excetion unless that exception
17100 is explicitely declared in the `throws' clause of each
17101 constructor. This doesn't apply to anonymous classes, since they
17102 don't have declared constructors. */
17104 && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
17107 for (current = TYPE_METHODS (current_class); current;
17108 current = TREE_CHAIN (current))
17109 if (DECL_CONSTRUCTOR_P (current)
17110 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
17112 parse_error_context (wfl_operator, "Checked exception `%s' can't be thrown in instance initializer (not all declared constructor are declaring it in their `throws' clause)",
17113 lang_printable_name (TREE_TYPE (expr), 0));
17114 return error_mark_node;
17118 /* Throw is contained in a try statement and at least one catch
17119 clause can receive the thrown expression or the current method is
17120 declared to throw such an exception. Or, the throw statement is
17121 contained in a method or constructor declaration and the type of
17122 the Expression is assignable to at least one type listed in the
17123 throws clause the declaration. */
17125 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
17126 if (!(unchecked_ok || tryblock_throws_ok))
17128 /* If there is a surrounding try block that has no matching
17129 clatch clause, report it first. A surrounding try block exits
17130 only if there is something after the list of checked
17131 exception thrown by the current function (if any). */
17132 if (IN_TRY_BLOCK_P ())
17133 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
17134 lang_printable_name (type, 0));
17135 /* If we have no surrounding try statement and the method doesn't have
17136 any throws, report it now. FIXME */
17138 /* We report that the exception can't be throw from a try block
17139 in all circumstances but when the `throw' is inside a static
17141 else if (!EXCEPTIONS_P (currently_caught_type_list)
17142 && !tryblock_throws_ok)
17144 if (DECL_CLINIT_P (current_function_decl))
17145 parse_error_context (wfl_operator,
17146 "Checked exception `%s' can't be thrown in initializer",
17147 lang_printable_name (type, 0));
17149 parse_error_context (wfl_operator,
17150 "Checked exception `%s' isn't thrown from a `try' block",
17151 lang_printable_name (type, 0));
17153 /* Otherwise, the current method doesn't have the appropriate
17154 throws declaration */
17156 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
17157 lang_printable_name (type, 0));
17158 return error_mark_node;
17161 if (! flag_emit_class_files && ! flag_emit_xref)
17162 BUILD_THROW (node, expr);
17164 /* If doing xrefs, keep the location where the `throw' was seen. */
17165 if (flag_emit_xref)
17166 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17170 /* Check that exception said to be thrown by method DECL can be
17171 effectively caught from where DECL is invoked. */
17174 check_thrown_exceptions (location, decl)
17179 /* For all the unchecked exceptions thrown by DECL */
17180 for (throws = DECL_FUNCTION_THROWS (decl); throws;
17181 throws = TREE_CHAIN (throws))
17182 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17185 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17186 if (DECL_NAME (decl) == get_identifier ("clone"))
17189 EXPR_WFL_LINECOL (wfl_operator) = location;
17190 if (DECL_FINIT_P (current_function_decl))
17191 parse_error_context
17192 (wfl_operator, "Exception `%s' can't be thrown in initializer",
17193 lang_printable_name (TREE_VALUE (throws), 0));
17196 parse_error_context
17197 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
17198 lang_printable_name (TREE_VALUE (throws), 0),
17199 (DECL_INIT_P (current_function_decl) ?
17200 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17201 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17206 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17207 try-catch blocks, OR is listed in the `throws' clause of the
17211 check_thrown_exceptions_do (exception)
17214 tree list = currently_caught_type_list;
17215 resolve_and_layout (exception, NULL_TREE);
17216 /* First, all the nested try-catch-finally at that stage. The
17217 last element contains `throws' clause exceptions, if any. */
17218 if (IS_UNCHECKED_EXCEPTION_P (exception))
17223 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17224 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17226 list = TREE_CHAIN (list);
17232 purge_unchecked_exceptions (mdecl)
17235 tree throws = DECL_FUNCTION_THROWS (mdecl);
17236 tree new = NULL_TREE;
17240 tree next = TREE_CHAIN (throws);
17241 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17243 TREE_CHAIN (throws) = new;
17248 /* List is inverted here, but it doesn't matter */
17249 DECL_FUNCTION_THROWS (mdecl) = new;
17252 /* 15.24 Conditional Operator ?: */
17255 patch_conditional_expr (node, wfl_cond, wfl_op1)
17256 tree node, wfl_cond, wfl_op1;
17258 tree cond = TREE_OPERAND (node, 0);
17259 tree op1 = TREE_OPERAND (node, 1);
17260 tree op2 = TREE_OPERAND (node, 2);
17261 tree resulting_type = NULL_TREE;
17262 tree t1, t2, patched;
17263 int error_found = 0;
17265 /* Operands of ?: might be StringBuffers crafted as a result of a
17266 string concatenation. Obtain a descent operand here. */
17267 if ((patched = patch_string (op1)))
17268 TREE_OPERAND (node, 1) = op1 = patched;
17269 if ((patched = patch_string (op2)))
17270 TREE_OPERAND (node, 2) = op2 = patched;
17272 t1 = TREE_TYPE (op1);
17273 t2 = TREE_TYPE (op2);
17275 /* The first expression must be a boolean */
17276 if (TREE_TYPE (cond) != boolean_type_node)
17278 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17279 parse_error_context (wfl_operator,
17280 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17281 lang_printable_name (TREE_TYPE (cond), 0));
17285 /* Second and third can be numeric, boolean (i.e. primitive),
17286 references or null. Anything else results in an error */
17287 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17288 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
17289 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17290 || (t1 == boolean_type_node && t2 == boolean_type_node)))
17293 /* Determine the type of the conditional expression. Same types are
17294 easy to deal with */
17296 resulting_type = t1;
17298 /* There are different rules for numeric types */
17299 else if (JNUMERIC_TYPE_P (t1))
17301 /* if byte/short found, the resulting type is short */
17302 if ((t1 == byte_type_node && t2 == short_type_node)
17303 || (t1 == short_type_node && t2 == byte_type_node))
17304 resulting_type = short_type_node;
17306 /* If t1 is a constant int and t2 is of type byte, short or char
17307 and t1's value fits in t2, then the resulting type is t2 */
17308 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17309 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17310 resulting_type = t2;
17312 /* If t2 is a constant int and t1 is of type byte, short or char
17313 and t2's value fits in t1, then the resulting type is t1 */
17314 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17315 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17316 resulting_type = t1;
17318 /* Otherwise, binary numeric promotion is applied and the
17319 resulting type is the promoted type of operand 1 and 2 */
17321 resulting_type = binary_numeric_promotion (t1, t2,
17322 &TREE_OPERAND (node, 1),
17323 &TREE_OPERAND (node, 2));
17326 /* Cases of a reference and a null type */
17327 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17328 resulting_type = t1;
17330 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17331 resulting_type = t2;
17333 /* Last case: different reference types. If a type can be converted
17334 into the other one by assignment conversion, the latter
17335 determines the type of the expression */
17336 else if ((resulting_type = try_reference_assignconv (t1, op2)))
17337 resulting_type = promote_type (t1);
17339 else if ((resulting_type = try_reference_assignconv (t2, op1)))
17340 resulting_type = promote_type (t2);
17342 /* If we don't have any resulting type, we're in trouble */
17343 if (!resulting_type)
17345 char *t = xstrdup (lang_printable_name (t1, 0));
17346 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17347 parse_error_context (wfl_operator,
17348 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17349 t, lang_printable_name (t2, 0));
17356 TREE_TYPE (node) = error_mark_node;
17357 return error_mark_node;
17360 TREE_TYPE (node) = resulting_type;
17361 TREE_SET_CODE (node, COND_EXPR);
17362 CAN_COMPLETE_NORMALLY (node) = 1;
17366 /* Try to constant fold NODE.
17367 If NODE is not a constant expression, return NULL_EXPR.
17368 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17371 fold_constant_for_init (node, context)
17375 tree op0, op1, val;
17376 enum tree_code code = TREE_CODE (node);
17378 if (code == STRING_CST)
17381 if (code == INTEGER_CST || code == REAL_CST)
17382 return convert (TREE_TYPE (context), node);
17389 case TRUNC_MOD_EXPR:
17397 case TRUTH_ANDIF_EXPR:
17398 case TRUTH_ORIF_EXPR:
17405 op0 = TREE_OPERAND (node, 0);
17406 op1 = TREE_OPERAND (node, 1);
17407 val = fold_constant_for_init (op0, context);
17408 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17410 TREE_OPERAND (node, 0) = val;
17411 val = fold_constant_for_init (op1, context);
17412 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17414 TREE_OPERAND (node, 1) = val;
17415 return patch_binop (node, op0, op1);
17417 case UNARY_PLUS_EXPR:
17419 case TRUTH_NOT_EXPR:
17422 op0 = TREE_OPERAND (node, 0);
17423 val = fold_constant_for_init (op0, context);
17424 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17426 TREE_OPERAND (node, 0) = val;
17427 return patch_unaryop (node, op0);
17431 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17432 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17434 TREE_OPERAND (node, 0) = val;
17435 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17436 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17438 TREE_OPERAND (node, 1) = val;
17439 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17440 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17442 TREE_OPERAND (node, 2) = val;
17443 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17444 : TREE_OPERAND (node, 2);
17448 if (! FIELD_FINAL (node)
17449 || DECL_INITIAL (node) == NULL_TREE)
17451 val = DECL_INITIAL (node);
17452 /* Guard against infinite recursion. */
17453 DECL_INITIAL (node) = NULL_TREE;
17454 val = fold_constant_for_init (val, node);
17455 DECL_INITIAL (node) = val;
17458 case EXPR_WITH_FILE_LOCATION:
17459 /* Compare java_complete_tree and resolve_expression_name. */
17460 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17461 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17463 tree name = EXPR_WFL_NODE (node);
17465 if (PRIMARY_P (node))
17467 else if (! QUALIFIED_P (name))
17469 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17470 if (decl == NULL_TREE
17471 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17473 return fold_constant_for_init (decl, decl);
17477 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
17478 qualify_ambiguous_name (node);
17479 if (resolve_field_access (node, &decl, NULL)
17480 && decl != NULL_TREE)
17481 return fold_constant_for_init (decl, decl);
17487 op0 = TREE_OPERAND (node, 0);
17488 val = fold_constant_for_init (op0, context);
17489 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17491 TREE_OPERAND (node, 0) = val;
17495 #ifdef USE_COMPONENT_REF
17497 case COMPONENT_REF:
17506 #ifdef USE_COMPONENT_REF
17507 /* Context is 'T' for TypeName, 'P' for PackageName,
17508 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17511 resolve_simple_name (name, context)
17518 resolve_qualified_name (name, context)