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 void find_in_imports PARAMS ((tree));
178 static int check_pkg_class_access PARAMS ((tree, tree));
179 static void register_package PARAMS ((tree));
180 static tree resolve_package PARAMS ((tree, tree *));
181 static tree lookup_package_type PARAMS ((const char *, int));
182 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
183 static tree resolve_class PARAMS ((tree, tree, tree, tree));
184 static void declare_local_variables PARAMS ((int, tree, tree));
185 static void source_start_java_method PARAMS ((tree));
186 static void source_end_java_method PARAMS ((void));
187 static void expand_start_java_method PARAMS ((tree));
188 static tree find_name_in_single_imports PARAMS ((tree));
189 static void check_abstract_method_header PARAMS ((tree));
190 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
191 static tree resolve_expression_name PARAMS ((tree, tree *));
192 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
193 static int check_class_interface_creation PARAMS ((int, int, tree,
195 static tree patch_method_invocation PARAMS ((tree, tree, tree,
197 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
198 static tree resolve_and_layout PARAMS ((tree, tree));
199 static tree qualify_and_find PARAMS ((tree, tree, tree));
200 static tree resolve_no_layout PARAMS ((tree, tree));
201 static int invocation_mode PARAMS ((tree, int));
202 static tree find_applicable_accessible_methods_list PARAMS ((int, tree,
204 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree,
206 static tree find_most_specific_methods_list PARAMS ((tree));
207 static int argument_types_convertible PARAMS ((tree, tree));
208 static tree patch_invoke PARAMS ((tree, tree, tree));
209 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
210 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
211 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
212 static tree obtain_incomplete_type PARAMS ((tree));
213 static tree java_complete_lhs PARAMS ((tree));
214 static tree java_complete_tree PARAMS ((tree));
215 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
216 static int maybe_yank_clinit PARAMS ((tree));
217 static void java_complete_expand_method PARAMS ((tree));
218 static int unresolved_type_p PARAMS ((tree, tree *));
219 static void create_jdep_list PARAMS ((struct parser_ctxt *));
220 static tree build_expr_block PARAMS ((tree, tree));
221 static tree enter_block PARAMS ((void));
222 static tree enter_a_block PARAMS ((tree));
223 static tree exit_block PARAMS ((void));
224 static tree lookup_name_in_blocks PARAMS ((tree));
225 static void maybe_absorb_scoping_blocks PARAMS ((void));
226 static tree build_method_invocation PARAMS ((tree, tree));
227 static tree build_new_invocation PARAMS ((tree, tree));
228 static tree build_assignment PARAMS ((int, int, tree, tree));
229 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
230 static int check_final_assignment PARAMS ((tree ,tree));
231 static tree patch_assignment PARAMS ((tree, tree, tree ));
232 static tree patch_binop PARAMS ((tree, tree, tree));
233 static tree build_unaryop PARAMS ((int, int, tree));
234 static tree build_incdec PARAMS ((int, int, tree, int));
235 static tree patch_unaryop PARAMS ((tree, tree));
236 static tree build_cast PARAMS ((int, tree, tree));
237 static tree build_null_of_type PARAMS ((tree));
238 static tree patch_cast PARAMS ((tree, tree));
239 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
240 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
241 static int valid_cast_to_p PARAMS ((tree, tree));
242 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
243 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
244 static tree try_reference_assignconv PARAMS ((tree, tree));
245 static tree build_unresolved_array_type PARAMS ((tree));
246 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
247 static tree build_array_ref PARAMS ((int, tree, tree));
248 static tree patch_array_ref PARAMS ((tree));
249 static tree make_qualified_name PARAMS ((tree, tree, int));
250 static tree merge_qualified_name PARAMS ((tree, tree));
251 static tree make_qualified_primary PARAMS ((tree, tree, int));
252 static int resolve_qualified_expression_name PARAMS ((tree, tree *,
254 static void qualify_ambiguous_name PARAMS ((tree));
255 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
256 static tree build_newarray_node PARAMS ((tree, tree, int));
257 static tree patch_newarray PARAMS ((tree));
258 static tree resolve_type_during_patch PARAMS ((tree));
259 static tree build_this PARAMS ((int));
260 static tree build_wfl_wrap PARAMS ((tree, int));
261 static tree build_return PARAMS ((int, tree));
262 static tree patch_return PARAMS ((tree));
263 static tree maybe_access_field PARAMS ((tree, tree, tree));
264 static int complete_function_arguments PARAMS ((tree));
265 static int check_for_static_method_reference PARAMS ((tree, tree, tree,
267 static int not_accessible_p PARAMS ((tree, tree, int));
268 static void check_deprecation PARAMS ((tree, tree));
269 static int class_in_current_package PARAMS ((tree));
270 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
271 static tree patch_if_else_statement PARAMS ((tree));
272 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
273 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
274 static tree patch_exit_expr PARAMS ((tree));
275 static tree build_labeled_block PARAMS ((int, tree));
276 static tree finish_labeled_statement PARAMS ((tree, tree));
277 static tree build_bc_statement PARAMS ((int, int, tree));
278 static tree patch_bc_statement PARAMS ((tree));
279 static tree patch_loop_statement PARAMS ((tree));
280 static tree build_new_loop PARAMS ((tree));
281 static tree build_loop_body PARAMS ((int, tree, int));
282 static tree finish_loop_body PARAMS ((int, tree, tree, int));
283 static tree build_debugable_stmt PARAMS ((int, tree));
284 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
285 static tree patch_switch_statement PARAMS ((tree));
286 static tree string_constant_concatenation PARAMS ((tree, tree));
287 static tree build_string_concatenation PARAMS ((tree, tree));
288 static tree patch_string_cst PARAMS ((tree));
289 static tree patch_string PARAMS ((tree));
290 static tree build_try_statement PARAMS ((int, tree, tree));
291 static tree build_try_finally_statement PARAMS ((int, tree, tree));
292 static tree patch_try_statement PARAMS ((tree));
293 static tree patch_synchronized_statement PARAMS ((tree, tree));
294 static tree patch_throw_statement PARAMS ((tree, tree));
295 static void check_thrown_exceptions PARAMS ((int, tree));
296 static int check_thrown_exceptions_do PARAMS ((tree));
297 static void purge_unchecked_exceptions PARAMS ((tree));
298 static void check_throws_clauses PARAMS ((tree, tree, tree));
299 static void finish_method_declaration PARAMS ((tree));
300 static tree build_super_invocation PARAMS ((tree));
301 static int verify_constructor_circularity PARAMS ((tree, tree));
302 static char *constructor_circularity_msg PARAMS ((tree, tree));
303 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
305 static const char *get_printable_method_name PARAMS ((tree));
306 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
307 static tree generate_finit PARAMS ((tree));
308 static void add_instance_initializer PARAMS ((tree));
309 static void fix_constructors PARAMS ((tree));
310 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
312 static void craft_constructor PARAMS ((tree, tree));
313 static int verify_constructor_super PARAMS ((tree));
314 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
315 static void start_artificial_method_body PARAMS ((tree));
316 static void end_artificial_method_body PARAMS ((tree));
317 static int check_method_redefinition PARAMS ((tree, tree));
318 static int reset_method_name PARAMS ((tree));
319 static int check_method_types_complete PARAMS ((tree));
320 static void java_check_regular_methods PARAMS ((tree));
321 static void java_check_abstract_methods PARAMS ((tree));
322 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
323 static void unreachable_stmt_error PARAMS ((tree));
324 static tree find_expr_with_wfl PARAMS ((tree));
325 static void missing_return_error PARAMS ((tree));
326 static tree build_new_array_init PARAMS ((int, tree));
327 static tree patch_new_array_init PARAMS ((tree, tree));
328 static tree maybe_build_array_element_wfl PARAMS ((tree));
329 static int array_constructor_check_entry PARAMS ((tree, tree));
330 static const char *purify_type_name PARAMS ((const char *));
331 static tree fold_constant_for_init PARAMS ((tree, tree));
332 static tree strip_out_static_field_access_decl PARAMS ((tree));
333 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
334 static void static_ref_err PARAMS ((tree, tree, tree));
335 static void parser_add_interface PARAMS ((tree, tree, tree));
336 static void add_superinterfaces PARAMS ((tree, tree));
337 static tree jdep_resolve_class PARAMS ((jdep *));
338 static int note_possible_classname PARAMS ((const char *, int));
339 static void java_complete_expand_classes PARAMS ((void));
340 static void java_complete_expand_class PARAMS ((tree));
341 static void java_complete_expand_methods PARAMS ((tree));
342 static tree cut_identifier_in_qualified PARAMS ((tree));
343 static tree java_stabilize_reference PARAMS ((tree));
344 static tree do_unary_numeric_promotion PARAMS ((tree));
345 static char * operator_string PARAMS ((tree));
346 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
347 static tree merge_string_cste PARAMS ((tree, tree, int));
348 static tree java_refold PARAMS ((tree));
349 static int java_decl_equiv PARAMS ((tree, tree));
350 static int binop_compound_p PARAMS ((enum tree_code));
351 static tree search_loop PARAMS ((tree));
352 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
353 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
354 static void java_check_abstract_method_definitions PARAMS ((tree));
355 static void java_debug_context_do PARAMS ((int));
356 static void java_parser_context_push_initialized_field PARAMS ((void));
357 static void java_parser_context_pop_initialized_field PARAMS ((void));
358 static tree reorder_static_initialized PARAMS ((tree));
359 static void java_parser_context_suspend PARAMS ((void));
360 static void java_parser_context_resume PARAMS ((void));
362 /* JDK 1.1 work. FIXME */
364 static tree maybe_make_nested_class_name PARAMS ((tree));
365 static void make_nested_class_name PARAMS ((tree));
366 static void set_nested_class_simple_name_value PARAMS ((tree, int));
367 static void link_nested_class_to_enclosing PARAMS ((void));
368 static tree find_as_inner_class PARAMS ((tree, tree, tree));
369 static tree find_as_inner_class_do PARAMS ((tree, tree));
370 static int check_inner_class_redefinition PARAMS ((tree, tree));
372 static tree build_thisn_assign PARAMS ((void));
373 static tree build_current_thisn PARAMS ((tree));
374 static tree build_access_to_thisn PARAMS ((tree, tree, int));
375 static tree maybe_build_thisn_access_method PARAMS ((tree));
377 static tree build_outer_field_access PARAMS ((tree, tree));
378 static tree build_outer_field_access_methods PARAMS ((tree));
379 static tree build_outer_field_access_expr PARAMS ((int, tree, tree,
381 static tree build_outer_method_access_method PARAMS ((tree));
382 static tree build_new_access_id PARAMS ((void));
383 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
386 static int outer_field_access_p PARAMS ((tree, tree));
387 static int outer_field_expanded_access_p PARAMS ((tree, tree *,
389 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
390 static tree build_incomplete_class_ref PARAMS ((int, tree));
391 static tree patch_incomplete_class_ref PARAMS ((tree));
392 static tree create_anonymous_class PARAMS ((int, tree));
393 static void patch_anonymous_class PARAMS ((tree, tree, tree));
394 static void add_inner_class_fields PARAMS ((tree, tree));
396 static tree build_dot_class_method PARAMS ((tree));
397 static tree build_dot_class_method_invocation PARAMS ((tree));
398 static void create_new_parser_context PARAMS ((int));
400 /* Number of error found so far. */
401 int java_error_count;
402 /* Number of warning found so far. */
403 int java_warning_count;
404 /* Tell when not to fold, when doing xrefs */
406 /* Cyclic inheritance report, as it can be set by layout_class */
407 char *cyclic_inheritance_report;
409 /* Tell when we're within an instance initializer */
410 static int in_instance_initializer;
412 /* The current parser context */
413 struct parser_ctxt *ctxp;
415 /* List of things that were analyzed for which code will be generated */
416 static struct parser_ctxt *ctxp_for_generation = NULL;
418 /* binop_lookup maps token to tree_code. It is used where binary
419 operations are involved and required by the parser. RDIV_EXPR
420 covers both integral/floating point division. The code is changed
421 once the type of both operator is worked out. */
423 static enum tree_code binop_lookup[19] =
425 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
426 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
427 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
428 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
429 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
431 #define BINOP_LOOKUP(VALUE) \
432 binop_lookup [((VALUE) - PLUS_TK)% \
433 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
435 /* This is the end index for binary operators that can also be used
436 in compound assignements. */
437 #define BINOP_COMPOUND_CANDIDATES 11
439 /* Fake WFL used to report error message. It is initialized once if
440 needed and reused with it's location information is overriden. */
441 tree wfl_operator = NULL_TREE;
443 /* The "$L" identifier we use to create labels. */
444 static tree label_id = NULL_TREE;
446 /* The "StringBuffer" identifier used for the String `+' operator. */
447 static tree wfl_string_buffer = NULL_TREE;
449 /* The "append" identifier used for String `+' operator. */
450 static tree wfl_append = NULL_TREE;
452 /* The "toString" identifier used for String `+' operator. */
453 static tree wfl_to_string = NULL_TREE;
455 /* The "java.lang" import qualified name. */
456 static tree java_lang_id = NULL_TREE;
458 /* The generated `inst$' identifier used for generated enclosing
459 instance/field access functions. */
460 static tree inst_id = NULL_TREE;
462 /* The "java.lang.Cloneable" qualified name. */
463 static tree java_lang_cloneable = NULL_TREE;
465 /* Context and flag for static blocks */
466 static tree current_static_block = NULL_TREE;
468 /* The generated `write_parm_value$' identifier. */
471 /* The list of all packages we've seen so far */
472 static tree package_list = NULL_TREE;
474 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
475 line and point it out. */
476 /* Should point out the one that don't fit. ASCII/unicode, going
479 #define check_modifiers(__message, __value, __mask) do { \
480 if ((__value) & ~(__mask)) \
482 int i, remainder = (__value) & ~(__mask); \
483 for (i = 0; i <= 10; i++) \
484 if ((1 << i) & remainder) \
485 parse_error_context (ctxp->modifier_ctx [i], (__message), \
486 java_accstring_lookup (1 << i)); \
491 #line 417 "./parse.y"
501 #line 427 "./parse.y"
519 #define YYFLAG -32768
522 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
524 static const char yytranslate[] = { 0,
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, 2, 2, 2, 2, 2,
549 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
551 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
552 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
553 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
554 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
555 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
556 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
557 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
558 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
559 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
560 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
565 static const short yyprhs[] = { 0,
566 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
567 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
568 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
569 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
570 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
571 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
572 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
573 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
574 229, 231, 233, 235, 238, 240, 242, 244, 248, 253,
575 255, 259, 263, 265, 269, 273, 278, 280, 284, 287,
576 291, 295, 297, 299, 300, 304, 307, 311, 315, 320,
577 325, 328, 332, 335, 339, 342, 346, 351, 355, 359,
578 363, 365, 369, 373, 376, 380, 383, 387, 389, 390,
579 393, 396, 398, 402, 406, 408, 411, 413, 416, 420,
580 422, 423, 427, 430, 434, 438, 443, 446, 450, 454,
581 459, 461, 464, 469, 475, 483, 490, 492, 494, 495,
582 500, 501, 507, 508, 514, 515, 522, 526, 531, 534,
583 538, 541, 545, 548, 552, 554, 557, 559, 561, 563,
584 565, 567, 570, 573, 576, 580, 585, 587, 591, 595,
585 598, 602, 604, 606, 608, 611, 613, 615, 617, 620,
586 623, 627, 629, 631, 633, 635, 637, 639, 641, 643,
587 645, 647, 649, 651, 653, 655, 657, 659, 661, 663,
588 665, 667, 669, 671, 673, 676, 679, 682, 685, 688,
589 691, 694, 697, 701, 706, 711, 717, 722, 728, 735,
590 743, 750, 752, 754, 756, 758, 760, 762, 764, 770,
591 773, 777, 782, 790, 798, 799, 803, 808, 811, 815,
592 821, 824, 828, 832, 837, 839, 842, 845, 847, 850,
593 854, 857, 860, 864, 867, 872, 875, 878, 882, 887,
594 890, 892, 900, 908, 915, 919, 925, 930, 938, 945,
595 948, 951, 955, 958, 959, 961, 963, 966, 967, 969,
596 971, 975, 979, 982, 986, 989, 993, 996, 1000, 1003,
597 1007, 1010, 1014, 1017, 1021, 1025, 1028, 1032, 1038, 1044,
598 1047, 1052, 1056, 1058, 1062, 1066, 1071, 1074, 1076, 1079,
599 1082, 1087, 1090, 1094, 1099, 1102, 1105, 1107, 1109, 1111,
600 1113, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1135, 1139,
601 1143, 1147, 1151, 1155, 1159, 1163, 1167, 1171, 1177, 1182,
602 1184, 1189, 1195, 1201, 1208, 1212, 1216, 1221, 1227, 1230,
603 1234, 1235, 1243, 1244, 1251, 1255, 1259, 1261, 1265, 1269,
604 1273, 1277, 1282, 1287, 1292, 1297, 1301, 1305, 1307, 1310,
605 1314, 1318, 1321, 1324, 1328, 1332, 1336, 1340, 1343, 1347,
606 1352, 1358, 1365, 1371, 1378, 1383, 1388, 1393, 1398, 1402,
607 1407, 1411, 1416, 1418, 1420, 1422, 1424, 1427, 1430, 1432,
608 1434, 1437, 1440, 1442, 1445, 1448, 1451, 1454, 1457, 1460,
609 1462, 1465, 1468, 1470, 1473, 1476, 1482, 1487, 1492, 1498,
610 1503, 1506, 1512, 1517, 1523, 1525, 1529, 1533, 1537, 1541,
611 1545, 1549, 1551, 1555, 1559, 1563, 1567, 1569, 1573, 1577,
612 1581, 1585, 1589, 1593, 1595, 1599, 1603, 1607, 1611, 1615,
613 1619, 1623, 1627, 1631, 1635, 1637, 1641, 1645, 1649, 1653,
614 1655, 1659, 1663, 1665, 1669, 1673, 1675, 1679, 1683, 1685,
615 1689, 1693, 1695, 1699, 1703, 1705, 1711, 1716, 1720, 1726,
616 1728, 1730, 1734, 1738, 1740, 1742, 1744, 1746, 1748, 1750
619 static const short yyrhs[] = { 123,
620 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
621 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
622 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
623 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
624 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
625 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
626 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
627 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
628 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
629 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
630 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
631 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
632 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
633 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
634 167, 0, 99, 0, 1, 0, 44, 0, 131, 44,
635 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
636 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
637 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
638 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
639 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
640 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
641 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
642 0, 139, 140, 0, 141, 0, 157, 0, 159, 0,
643 180, 0, 142, 0, 142, 99, 0, 147, 0, 132,
644 0, 167, 0, 112, 143, 99, 0, 131, 112, 143,
645 99, 0, 144, 0, 143, 100, 144, 0, 143, 100,
646 1, 0, 145, 0, 145, 92, 146, 0, 145, 92,
647 1, 0, 145, 92, 146, 1, 0, 122, 0, 145,
648 97, 98, 0, 122, 1, 0, 145, 97, 1, 0,
649 145, 98, 1, 0, 270, 0, 178, 0, 0, 149,
650 148, 156, 0, 149, 1, 0, 112, 150, 154, 0,
651 59, 150, 154, 0, 131, 112, 150, 154, 0, 131,
652 59, 150, 154, 0, 112, 1, 0, 131, 112, 1,
653 0, 59, 1, 0, 131, 59, 1, 0, 131, 1,
654 0, 122, 93, 94, 0, 122, 93, 151, 94, 0,
655 150, 97, 98, 0, 122, 93, 1, 0, 150, 97,
656 1, 0, 152, 0, 151, 100, 152, 0, 151, 100,
657 1, 0, 112, 145, 0, 153, 112, 145, 0, 112,
658 1, 0, 153, 112, 1, 0, 131, 0, 0, 53,
659 155, 0, 53, 1, 0, 116, 0, 155, 100, 116,
660 0, 155, 100, 1, 0, 180, 0, 180, 99, 0,
661 99, 0, 158, 180, 0, 158, 180, 99, 0, 131,
662 0, 0, 161, 160, 163, 0, 162, 154, 0, 131,
663 162, 154, 0, 120, 93, 94, 0, 120, 93, 151,
664 94, 0, 181, 164, 0, 181, 165, 164, 0, 181,
665 183, 164, 0, 181, 165, 183, 164, 0, 182, 0,
666 182, 99, 0, 166, 93, 94, 99, 0, 166, 93,
667 239, 94, 99, 0, 119, 101, 65, 93, 239, 94,
668 99, 0, 119, 101, 65, 93, 94, 99, 0, 76,
669 0, 65, 0, 0, 61, 122, 168, 173, 0, 0,
670 131, 61, 122, 169, 173, 0, 0, 61, 122, 172,
671 170, 173, 0, 0, 131, 61, 122, 172, 171, 173,
672 0, 61, 122, 1, 0, 131, 61, 122, 1, 0,
673 63, 117, 0, 172, 100, 117, 0, 63, 1, 0,
674 172, 100, 1, 0, 95, 96, 0, 95, 174, 96,
675 0, 175, 0, 174, 175, 0, 176, 0, 177, 0,
676 132, 0, 167, 0, 142, 0, 149, 99, 0, 149,
677 1, 0, 95, 96, 0, 95, 179, 96, 0, 95,
678 179, 100, 96, 0, 146, 0, 179, 100, 146, 0,
679 179, 100, 1, 0, 95, 96, 0, 181, 183, 182,
680 0, 95, 0, 96, 0, 184, 0, 183, 184, 0,
681 185, 0, 187, 0, 132, 0, 186, 99, 0, 112,
682 143, 0, 153, 112, 143, 0, 189, 0, 192, 0,
683 196, 0, 197, 0, 208, 0, 212, 0, 189, 0,
684 193, 0, 198, 0, 209, 0, 213, 0, 180, 0,
685 190, 0, 194, 0, 199, 0, 211, 0, 219, 0,
686 220, 0, 221, 0, 223, 0, 222, 0, 225, 0,
687 99, 0, 122, 88, 0, 191, 187, 0, 122, 1,
688 0, 191, 188, 0, 195, 99, 0, 1, 99, 0,
689 1, 95, 0, 1, 96, 0, 166, 93, 1, 0,
690 166, 93, 94, 1, 0, 166, 93, 239, 1, 0,
691 166, 93, 239, 94, 1, 0, 119, 101, 65, 1,
692 0, 119, 101, 65, 93, 1, 0, 119, 101, 65,
693 93, 239, 1, 0, 119, 101, 65, 93, 239, 94,
694 1, 0, 119, 101, 65, 93, 94, 1, 0, 267,
695 0, 251, 0, 252, 0, 248, 0, 249, 0, 245,
696 0, 234, 0, 48, 93, 270, 94, 187, 0, 48,
697 1, 0, 48, 93, 1, 0, 48, 93, 270, 1,
698 0, 48, 93, 270, 94, 188, 56, 187, 0, 48,
699 93, 270, 94, 188, 56, 188, 0, 0, 201, 200,
700 202, 0, 68, 93, 270, 94, 0, 68, 1, 0,
701 68, 93, 1, 0, 68, 93, 270, 94, 1, 0,
702 95, 96, 0, 95, 205, 96, 0, 95, 203, 96,
703 0, 95, 203, 205, 96, 0, 204, 0, 203, 204,
704 0, 205, 183, 0, 206, 0, 205, 206, 0, 62,
705 271, 88, 0, 47, 88, 0, 62, 1, 0, 62,
706 271, 1, 0, 47, 1, 0, 66, 93, 270, 94,
707 0, 207, 187, 0, 66, 1, 0, 66, 93, 1,
708 0, 66, 93, 270, 1, 0, 207, 188, 0, 51,
709 0, 210, 187, 66, 93, 270, 94, 99, 0, 215,
710 99, 270, 99, 217, 94, 187, 0, 215, 99, 99,
711 217, 94, 187, 0, 215, 99, 1, 0, 215, 99,
712 270, 99, 1, 0, 215, 99, 99, 1, 0, 215,
713 99, 270, 99, 217, 94, 188, 0, 215, 99, 99,
714 217, 94, 188, 0, 71, 93, 0, 71, 1, 0,
715 71, 93, 1, 0, 214, 216, 0, 0, 218, 0,
716 186, 0, 218, 1, 0, 0, 218, 0, 195, 0,
717 218, 100, 195, 0, 218, 100, 1, 0, 54, 99,
718 0, 54, 122, 99, 0, 54, 1, 0, 54, 122,
719 1, 0, 73, 99, 0, 73, 122, 99, 0, 73,
720 1, 0, 73, 122, 1, 0, 58, 99, 0, 58,
721 270, 99, 0, 58, 1, 0, 58, 270, 1, 0,
722 49, 270, 99, 0, 49, 1, 0, 49, 270, 1,
723 0, 224, 93, 270, 94, 180, 0, 224, 93, 270,
724 94, 1, 0, 224, 1, 0, 224, 93, 1, 94,
725 0, 224, 93, 1, 0, 131, 0, 70, 180, 226,
726 0, 70, 180, 229, 0, 70, 180, 226, 229, 0,
727 70, 1, 0, 227, 0, 226, 227, 0, 228, 180,
728 0, 60, 93, 152, 94, 0, 60, 1, 0, 60,
729 93, 1, 0, 60, 93, 1, 94, 0, 64, 180,
730 0, 64, 1, 0, 231, 0, 240, 0, 111, 0,
731 76, 0, 93, 270, 94, 0, 234, 0, 244, 0,
732 245, 0, 246, 0, 233, 0, 119, 101, 76, 0,
733 93, 270, 1, 0, 119, 101, 1, 0, 113, 101,
734 1, 0, 59, 101, 1, 0, 113, 97, 98, 0,
735 119, 97, 98, 0, 119, 101, 67, 0, 232, 101,
736 67, 0, 113, 101, 67, 0, 59, 101, 67, 0,
737 72, 116, 93, 239, 94, 0, 72, 116, 93, 94,
738 0, 235, 0, 238, 122, 93, 94, 0, 238, 122,
739 93, 94, 138, 0, 238, 122, 93, 239, 94, 0,
740 238, 122, 93, 239, 94, 138, 0, 72, 1, 99,
741 0, 72, 116, 1, 0, 72, 116, 93, 1, 0,
742 72, 116, 93, 239, 1, 0, 238, 1, 0, 238,
743 122, 1, 0, 0, 72, 116, 93, 239, 94, 236,
744 138, 0, 0, 72, 116, 93, 94, 237, 138, 0,
745 119, 101, 72, 0, 230, 101, 72, 0, 270, 0,
746 239, 100, 270, 0, 239, 100, 1, 0, 72, 113,
747 241, 0, 72, 115, 241, 0, 72, 113, 241, 243,
748 0, 72, 115, 241, 243, 0, 72, 115, 243, 178,
749 0, 72, 113, 243, 178, 0, 72, 1, 98, 0,
750 72, 1, 97, 0, 242, 0, 241, 242, 0, 97,
751 270, 98, 0, 97, 270, 1, 0, 97, 1, 0,
752 97, 98, 0, 243, 97, 98, 0, 243, 97, 1,
753 0, 230, 101, 122, 0, 65, 101, 122, 0, 65,
754 1, 0, 119, 93, 94, 0, 119, 93, 239, 94,
755 0, 230, 101, 122, 93, 94, 0, 230, 101, 122,
756 93, 239, 94, 0, 65, 101, 122, 93, 94, 0,
757 65, 101, 122, 93, 239, 94, 0, 65, 101, 1,
758 94, 0, 65, 101, 1, 101, 0, 119, 97, 270,
759 98, 0, 231, 97, 270, 98, 0, 119, 97, 1,
760 0, 119, 97, 270, 1, 0, 231, 97, 1, 0,
761 231, 97, 270, 1, 0, 230, 0, 119, 0, 248,
762 0, 249, 0, 247, 46, 0, 247, 45, 0, 251,
763 0, 252, 0, 3, 250, 0, 4, 250, 0, 253,
764 0, 3, 1, 0, 4, 1, 0, 46, 250, 0,
765 46, 1, 0, 45, 250, 0, 45, 1, 0, 247,
766 0, 89, 250, 0, 90, 250, 0, 254, 0, 89,
767 1, 0, 90, 1, 0, 93, 113, 243, 94, 250,
768 0, 93, 113, 94, 250, 0, 93, 270, 94, 253,
769 0, 93, 119, 243, 94, 253, 0, 93, 113, 97,
770 1, 0, 93, 1, 0, 93, 113, 243, 94, 1,
771 0, 93, 113, 94, 1, 0, 93, 119, 243, 94,
772 1, 0, 250, 0, 255, 5, 250, 0, 255, 6,
773 250, 0, 255, 7, 250, 0, 255, 5, 1, 0,
774 255, 6, 1, 0, 255, 7, 1, 0, 255, 0,
775 256, 3, 255, 0, 256, 4, 255, 0, 256, 3,
776 1, 0, 256, 4, 1, 0, 256, 0, 257, 8,
777 256, 0, 257, 9, 256, 0, 257, 10, 256, 0,
778 257, 8, 1, 0, 257, 9, 1, 0, 257, 10,
779 1, 0, 257, 0, 258, 20, 257, 0, 258, 18,
780 257, 0, 258, 21, 257, 0, 258, 19, 257, 0,
781 258, 57, 114, 0, 258, 20, 1, 0, 258, 18,
782 1, 0, 258, 21, 1, 0, 258, 19, 1, 0,
783 258, 57, 1, 0, 258, 0, 259, 16, 258, 0,
784 259, 17, 258, 0, 259, 16, 1, 0, 259, 17,
785 1, 0, 259, 0, 260, 11, 259, 0, 260, 11,
786 1, 0, 260, 0, 261, 12, 260, 0, 261, 12,
787 1, 0, 261, 0, 262, 13, 261, 0, 262, 13,
788 1, 0, 262, 0, 263, 14, 262, 0, 263, 14,
789 1, 0, 263, 0, 264, 15, 263, 0, 264, 15,
790 1, 0, 264, 0, 264, 87, 270, 88, 265, 0,
791 264, 87, 88, 1, 0, 264, 87, 1, 0, 264,
792 87, 270, 88, 1, 0, 265, 0, 267, 0, 268,
793 269, 266, 0, 268, 269, 1, 0, 119, 0, 244,
794 0, 246, 0, 91, 0, 92, 0, 266, 0, 270,
801 static const short yyrline[] = { 0,
802 576, 582, 584, 585, 586, 587, 588, 592, 594, 597,
803 599, 600, 603, 605, 608, 612, 616, 620, 626, 628,
804 630, 632, 637, 639, 642, 646, 651, 656, 658, 659,
805 660, 661, 662, 663, 664, 667, 672, 678, 680, 683,
806 689, 691, 695, 697, 700, 727, 729, 733, 746, 748,
807 752, 755, 757, 759, 769, 774, 789, 793, 793, 796,
808 796, 798, 800, 805, 809, 811, 813, 815, 819, 821,
809 823, 830, 836, 841, 845, 854, 864, 866, 869, 871,
810 872, 873, 880, 882, 884, 885, 887, 892, 895, 905,
811 908, 910, 914, 917, 924, 930, 938, 940, 942, 944,
812 946, 950, 952, 956, 967, 968, 972, 975, 977, 979,
813 981, 986, 988, 990, 992, 999, 1005, 1007, 1016, 1018,
814 1022, 1027, 1032, 1036, 1041, 1046, 1051, 1058, 1068, 1070,
815 1072, 1076, 1079, 1081, 1085, 1087, 1088, 1093, 1099, 1106,
816 1122, 1129, 1132, 1135, 1139, 1145, 1149, 1158, 1160, 1162,
817 1166, 1168, 1171, 1178, 1186, 1188, 1192, 1199, 1209, 1213,
818 1213, 1216, 1216, 1219, 1219, 1222, 1222, 1224, 1228, 1234,
819 1239, 1241, 1245, 1248, 1252, 1254, 1257, 1259, 1260, 1262,
820 1266, 1270, 1276, 1281, 1284, 1286, 1290, 1296, 1300, 1305,
821 1314, 1318, 1323, 1337, 1339, 1342, 1344, 1346, 1353, 1357,
822 1360, 1364, 1366, 1367, 1368, 1369, 1370, 1374, 1376, 1377,
823 1378, 1379, 1383, 1385, 1386, 1387, 1388, 1389, 1390, 1391,
824 1392, 1393, 1394, 1397, 1402, 1413, 1416, 1420, 1427, 1437,
825 1443, 1449, 1455, 1457, 1462, 1464, 1469, 1471, 1473, 1475,
826 1477, 1481, 1483, 1484, 1485, 1486, 1487, 1488, 1491, 1497,
827 1499, 1501, 1505, 1510, 1515, 1521, 1531, 1537, 1539, 1541,
828 1548, 1551, 1553, 1555, 1559, 1561, 1564, 1568, 1570, 1573,
829 1580, 1586, 1588, 1590, 1594, 1602, 1605, 1607, 1609, 1613,
830 1618, 1627, 1632, 1635, 1642, 1644, 1646, 1650, 1653, 1662,
831 1669, 1671, 1675, 1688, 1690, 1696, 1702, 1706, 1708, 1712,
832 1715, 1717, 1721, 1724, 1726, 1728, 1732, 1735, 1737, 1739,
833 1743, 1746, 1748, 1750, 1754, 1760, 1762, 1766, 1773, 1775,
834 1777, 1779, 1783, 1795, 1798, 1800, 1805, 1809, 1811, 1818,
835 1826, 1843, 1845, 1850, 1854, 1857, 1862, 1864, 1867, 1869,
836 1871, 1873, 1874, 1875, 1876, 1877, 1881, 1886, 1888, 1890,
837 1892, 1899, 1905, 1914, 1917, 1919, 1921, 1925, 1928, 1930,
838 1934, 1940, 1941, 1947, 1948, 1950, 1952, 1954, 1956, 1958,
839 1967, 1971, 2001, 2004, 2018, 2021, 2025, 2031, 2036, 2040,
840 2043, 2045, 2047, 2051, 2060, 2068, 2070, 2074, 2077, 2081,
841 2092, 2094, 2102, 2129, 2131, 2135, 2140, 2147, 2151, 2154,
842 2156, 2167, 2178, 2183, 2192, 2194, 2198, 2201, 2203, 2208,
843 2213, 2218, 2225, 2227, 2228, 2229, 2232, 2237, 2242, 2244,
844 2245, 2247, 2249, 2250, 2252, 2256, 2259, 2263, 2266, 2270,
845 2272, 2274, 2276, 2277, 2279, 2283, 2292, 2294, 2296, 2309,
846 2311, 2317, 2319, 2321, 2325, 2327, 2332, 2337, 2342, 2344,
847 2346, 2350, 2352, 2357, 2362, 2364, 2368, 2370, 2375, 2380,
848 2385, 2387, 2389, 2393, 2395, 2400, 2405, 2410, 2415, 2417,
849 2419, 2421, 2423, 2425, 2429, 2431, 2436, 2441, 2443, 2447,
850 2449, 2454, 2458, 2460, 2465, 2469, 2471, 2476, 2480, 2482,
851 2487, 2491, 2493, 2498, 2502, 2504, 2509, 2515, 2517, 2521,
852 2523, 2526, 2529, 2537, 2539, 2540, 2543, 2545, 2548, 2552
857 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
859 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
860 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
861 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
862 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
863 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
864 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
865 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
866 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
867 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
868 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
869 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
870 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
871 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
872 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
873 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
874 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
875 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
876 "class_type","interface_type","array_type","name","simple_name","qualified_name",
877 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
878 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
879 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
880 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
881 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
882 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
883 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
884 "class_type_list","method_body","static_initializer","static","constructor_declaration",
885 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
886 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
887 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
888 "interface_member_declaration","constant_declaration","abstract_method_declaration",
889 "array_initializer","variable_initializers","block","block_begin","block_end",
890 "block_statements","block_statement","local_variable_declaration_statement",
891 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
892 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
893 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
894 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
895 "switch_block_statement_group","switch_labels","switch_label","while_expression",
896 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
897 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
898 "statement_expression_list","break_statement","continue_statement","return_statement",
899 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
900 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
901 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
902 "@10","@11","something_dot_new","argument_list","array_creation_expression",
903 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
904 "postfix_expression","post_increment_expression","post_decrement_expression",
905 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
906 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
907 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
908 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
909 "conditional_expression","assignment_expression","assignment","left_hand_side",
910 "assignment_operator","expression","constant_expression", NULL
914 static const short yyr1[] = { 0,
915 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
916 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
917 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
918 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
919 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
920 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
921 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
922 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
923 140, 140, 141, 141, 141, 141, 141, 142, 142, 143,
924 143, 143, 144, 144, 144, 144, 145, 145, 145, 145,
925 145, 146, 146, 148, 147, 147, 149, 149, 149, 149,
926 149, 149, 149, 149, 149, 150, 150, 150, 150, 150,
927 151, 151, 151, 152, 152, 152, 152, 153, 154, 154,
928 154, 155, 155, 155, 156, 156, 156, 157, 157, 158,
929 160, 159, 161, 161, 162, 162, 163, 163, 163, 163,
930 164, 164, 165, 165, 165, 165, 166, 166, 168, 167,
931 169, 167, 170, 167, 171, 167, 167, 167, 172, 172,
932 172, 172, 173, 173, 174, 174, 175, 175, 175, 175,
933 176, 177, 177, 178, 178, 178, 179, 179, 179, 180,
934 180, 181, 182, 183, 183, 184, 184, 184, 185, 186,
935 186, 187, 187, 187, 187, 187, 187, 188, 188, 188,
936 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
937 189, 189, 189, 190, 191, 192, 192, 193, 194, 194,
938 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
939 194, 195, 195, 195, 195, 195, 195, 195, 196, 196,
940 196, 196, 197, 198, 200, 199, 201, 201, 201, 201,
941 202, 202, 202, 202, 203, 203, 204, 205, 205, 206,
942 206, 206, 206, 206, 207, 208, 208, 208, 208, 209,
943 210, 211, 212, 212, 212, 212, 212, 213, 213, 214,
944 214, 214, 215, 216, 216, 216, 216, 217, 217, 218,
945 218, 218, 219, 219, 219, 219, 220, 220, 220, 220,
946 221, 221, 221, 221, 222, 222, 222, 223, 223, 223,
947 223, 223, 224, 225, 225, 225, 225, 226, 226, 227,
948 228, 228, 228, 228, 229, 229, 230, 230, 231, 231,
949 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
950 231, 232, 232, 233, 233, 233, 233, 234, 234, 234,
951 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
952 236, 235, 237, 235, 238, 238, 239, 239, 239, 240,
953 240, 240, 240, 240, 240, 240, 240, 241, 241, 242,
954 242, 242, 243, 243, 243, 244, 244, 244, 245, 245,
955 245, 245, 245, 245, 245, 245, 246, 246, 246, 246,
956 246, 246, 247, 247, 247, 247, 248, 249, 250, 250,
957 250, 250, 250, 250, 250, 251, 251, 252, 252, 253,
958 253, 253, 253, 253, 253, 254, 254, 254, 254, 254,
959 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
960 255, 256, 256, 256, 256, 256, 257, 257, 257, 257,
961 257, 257, 257, 258, 258, 258, 258, 258, 258, 258,
962 258, 258, 258, 258, 259, 259, 259, 259, 259, 260,
963 260, 260, 261, 261, 261, 262, 262, 262, 263, 263,
964 263, 264, 264, 264, 265, 265, 265, 265, 265, 266,
965 266, 267, 267, 268, 268, 268, 269, 269, 270, 271
968 static const short yyr2[] = { 0,
969 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
970 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
971 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
972 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
973 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
974 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
975 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
976 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
977 1, 1, 1, 2, 1, 1, 1, 3, 4, 1,
978 3, 3, 1, 3, 3, 4, 1, 3, 2, 3,
979 3, 1, 1, 0, 3, 2, 3, 3, 4, 4,
980 2, 3, 2, 3, 2, 3, 4, 3, 3, 3,
981 1, 3, 3, 2, 3, 2, 3, 1, 0, 2,
982 2, 1, 3, 3, 1, 2, 1, 2, 3, 1,
983 0, 3, 2, 3, 3, 4, 2, 3, 3, 4,
984 1, 2, 4, 5, 7, 6, 1, 1, 0, 4,
985 0, 5, 0, 5, 0, 6, 3, 4, 2, 3,
986 2, 3, 2, 3, 1, 2, 1, 1, 1, 1,
987 1, 2, 2, 2, 3, 4, 1, 3, 3, 2,
988 3, 1, 1, 1, 2, 1, 1, 1, 2, 2,
989 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
990 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
991 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
992 2, 2, 3, 4, 4, 5, 4, 5, 6, 7,
993 6, 1, 1, 1, 1, 1, 1, 1, 5, 2,
994 3, 4, 7, 7, 0, 3, 4, 2, 3, 5,
995 2, 3, 3, 4, 1, 2, 2, 1, 2, 3,
996 2, 2, 3, 2, 4, 2, 2, 3, 4, 2,
997 1, 7, 7, 6, 3, 5, 4, 7, 6, 2,
998 2, 3, 2, 0, 1, 1, 2, 0, 1, 1,
999 3, 3, 2, 3, 2, 3, 2, 3, 2, 3,
1000 2, 3, 2, 3, 3, 2, 3, 5, 5, 2,
1001 4, 3, 1, 3, 3, 4, 2, 1, 2, 2,
1002 4, 2, 3, 4, 2, 2, 1, 1, 1, 1,
1003 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
1004 3, 3, 3, 3, 3, 3, 3, 5, 4, 1,
1005 4, 5, 5, 6, 3, 3, 4, 5, 2, 3,
1006 0, 7, 0, 6, 3, 3, 1, 3, 3, 3,
1007 3, 4, 4, 4, 4, 3, 3, 1, 2, 3,
1008 3, 2, 2, 3, 3, 3, 3, 2, 3, 4,
1009 5, 6, 5, 6, 4, 4, 4, 4, 3, 4,
1010 3, 4, 1, 1, 1, 1, 2, 2, 1, 1,
1011 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,
1012 2, 2, 1, 2, 2, 5, 4, 4, 5, 4,
1013 2, 5, 4, 5, 1, 3, 3, 3, 3, 3,
1014 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
1015 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1016 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
1017 3, 3, 1, 3, 3, 1, 3, 3, 1, 3,
1018 3, 1, 3, 3, 1, 5, 4, 3, 5, 1,
1019 1, 3, 3, 1, 1, 1, 1, 1, 1, 1
1022 static const short yydefact[] = { 0,
1023 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
1024 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
1025 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
1026 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
1027 167, 0, 0, 163, 63, 0, 69, 42, 40, 0,
1028 0, 0, 61, 0, 49, 0, 26, 171, 17, 169,
1029 15, 0, 160, 0, 0, 68, 16, 0, 0, 59,
1030 168, 0, 165, 64, 69, 50, 48, 12, 0, 10,
1031 11, 173, 0, 8, 9, 13, 14, 15, 0, 179,
1032 181, 0, 180, 0, 175, 177, 178, 172, 170, 164,
1033 67, 71, 72, 70, 0, 162, 0, 57, 113, 0,
1034 129, 111, 0, 0, 90, 93, 129, 0, 0, 0,
1035 115, 0, 0, 183, 182, 174, 176, 0, 0, 60,
1036 166, 0, 0, 0, 0, 108, 99, 88, 0, 0,
1037 0, 0, 107, 21, 18, 22, 20, 19, 114, 129,
1038 112, 0, 129, 74, 73, 192, 75, 23, 0, 86,
1039 0, 77, 79, 83, 85, 0, 80, 0, 81, 141,
1040 129, 87, 82, 0, 58, 119, 116, 0, 128, 0,
1041 121, 0, 131, 132, 130, 120, 118, 92, 0, 91,
1042 95, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1043 0, 0, 0, 6, 5, 2, 3, 4, 7, 339,
1044 0, 414, 0, 103, 413, 337, 0, 346, 342, 360,
1045 0, 338, 343, 344, 345, 430, 415, 416, 445, 419,
1046 420, 423, 433, 452, 457, 464, 475, 480, 483, 486,
1047 489, 492, 495, 500, 509, 501, 0, 102, 100, 98,
1048 101, 110, 89, 109, 190, 0, 129, 76, 78, 84,
1049 106, 0, 138, 0, 143, 0, 0, 0, 281, 0,
1050 0, 0, 0, 0, 0, 0, 0, 340, 0, 224,
1051 0, 8, 414, 0, 128, 198, 0, 0, 213, 0,
1052 194, 196, 0, 197, 202, 214, 0, 203, 215, 0,
1053 204, 205, 216, 255, 0, 206, 0, 217, 207, 294,
1054 0, 218, 219, 220, 222, 221, 0, 223, 248, 247,
1055 0, 245, 246, 243, 244, 242, 126, 124, 117, 0,
1056 0, 0, 424, 414, 343, 345, 421, 425, 422, 429,
1057 428, 427, 426, 0, 398, 0, 0, 0, 16, 0,
1058 434, 431, 435, 432, 441, 0, 414, 0, 184, 187,
1059 0, 0, 0, 0, 0, 0, 96, 0, 0, 0,
1060 369, 0, 418, 417, 0, 0, 0, 0, 0, 0,
1061 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1062 0, 0, 0, 0, 0, 507, 508, 0, 145, 0,
1063 144, 137, 105, 135, 139, 192, 142, 0, 231, 232,
1064 230, 250, 0, 316, 0, 305, 303, 0, 313, 311,
1065 0, 277, 0, 258, 0, 327, 0, 291, 0, 309,
1066 307, 0, 0, 200, 0, 0, 0, 227, 225, 0,
1067 0, 193, 191, 195, 199, 414, 323, 226, 229, 0,
1068 276, 0, 414, 296, 300, 293, 0, 0, 320, 0,
1069 123, 122, 127, 125, 134, 133, 351, 357, 0, 397,
1070 387, 386, 365, 0, 380, 388, 0, 381, 0, 366,
1071 0, 0, 0, 0, 0, 0, 348, 341, 185, 0,
1072 352, 350, 356, 399, 0, 377, 409, 353, 0, 349,
1073 354, 375, 347, 376, 396, 411, 0, 355, 370, 0,
1074 449, 446, 450, 447, 451, 448, 455, 453, 456, 454,
1075 461, 458, 462, 459, 463, 460, 471, 466, 473, 468,
1076 470, 465, 472, 467, 474, 0, 469, 478, 476, 479,
1077 477, 482, 481, 485, 484, 488, 487, 491, 490, 494,
1078 493, 498, 0, 0, 503, 502, 146, 136, 414, 147,
1079 0, 0, 151, 0, 251, 0, 317, 315, 306, 304,
1080 314, 312, 278, 0, 259, 0, 0, 0, 324, 328,
1081 0, 325, 292, 310, 308, 341, 18, 19, 0, 201,
1082 233, 0, 0, 0, 256, 0, 297, 0, 285, 0,
1083 0, 322, 0, 405, 406, 0, 392, 393, 0, 389,
1084 382, 0, 385, 383, 384, 367, 359, 0, 443, 437,
1085 440, 393, 0, 393, 0, 438, 189, 186, 188, 400,
1086 0, 410, 407, 0, 412, 408, 361, 0, 497, 0,
1087 0, 148, 0, 0, 152, 149, 252, 0, 279, 275,
1088 0, 332, 0, 336, 335, 329, 326, 330, 237, 0,
1089 234, 235, 0, 0, 0, 261, 0, 265, 0, 268,
1090 0, 302, 301, 287, 0, 299, 0, 321, 0, 403,
1091 0, 391, 390, 395, 394, 0, 368, 358, 442, 436,
1092 444, 439, 379, 378, 401, 0, 362, 363, 499, 496,
1093 0, 150, 0, 0, 0, 249, 0, 202, 0, 209,
1094 210, 0, 211, 212, 0, 260, 333, 0, 238, 0,
1095 0, 236, 274, 271, 272, 510, 0, 263, 266, 0,
1096 262, 0, 269, 0, 0, 286, 0, 319, 318, 404,
1097 374, 0, 402, 364, 0, 153, 0, 0, 0, 228,
1098 280, 0, 334, 331, 241, 239, 0, 273, 270, 264,
1099 0, 284, 0, 372, 0, 0, 154, 0, 253, 0,
1100 0, 240, 282, 283, 156, 0, 0, 0, 0, 155,
1101 0, 0, 0, 0, 289, 0, 254, 288, 0, 0,
1105 static const short yydefgoto[] = { 789,
1106 210, 281, 211, 85, 86, 68, 60, 87, 212, 22,
1107 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
1108 447, 286, 132, 105, 47, 70, 104, 130, 161, 162,
1109 163, 91, 114, 115, 116, 213, 165, 262, 92, 111,
1110 180, 181, 287, 136, 185, 403, 167, 168, 169, 264,
1111 170, 171, 407, 560, 561, 288, 18, 43, 72, 65,
1112 107, 44, 63, 94, 95, 96, 97, 214, 361, 289,
1113 174, 563, 732, 291, 292, 293, 294, 707, 295, 296,
1114 297, 298, 710, 299, 300, 301, 302, 711, 303, 450,
1115 304, 595, 667, 668, 669, 670, 305, 306, 713, 307,
1116 308, 309, 714, 310, 311, 456, 675, 676, 312, 313,
1117 314, 315, 316, 317, 318, 579, 580, 581, 582, 215,
1118 216, 217, 218, 219, 220, 742, 686, 221, 495, 222,
1119 475, 476, 477, 223, 224, 225, 226, 227, 228, 229,
1120 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
1121 240, 241, 242, 243, 244, 245, 246, 247, 398, 496,
1125 static const short yypact[] = { 356,
1126 -32768,-32768, 158, -35, 339, 439,-32768,-32768, 433, 247,
1127 473,-32768,-32768,-32768,-32768, 29,-32768,-32768,-32768,-32768,
1128 12,-32768,-32768,-32768, 331,-32768, 491,-32768, 71, 469,
1129 -32768,-32768, 520, 562,-32768, -35, 510,-32768,-32768, 278,
1130 -32768, 521, -25, -8,-32768, 526, 349,-32768,-32768, -35,
1131 591, 343,-32768, 508,-32768, 25,-32768,-32768,-32768,-32768,
1132 7, 1014,-32768, 568, -25,-32768,-32768, 346, 594,-32768,
1133 -32768, -25, -8,-32768, 349,-32768,-32768,-32768, 597,-32768,
1134 -32768,-32768, 607, 165,-32768,-32768, 315, 181, 676,-32768,
1135 -32768, 30,-32768, 1034,-32768,-32768,-32768,-32768,-32768,-32768,
1136 -32768,-32768,-32768, 328, 354,-32768, -25,-32768,-32768, 370,
1137 -4,-32768, 449, 733,-32768, 201, -4, 122, 208, 377,
1138 -32768, 608, 616,-32768,-32768,-32768,-32768, 617, 938,-32768,
1139 -32768, 354, 629, 630, 215,-32768,-32768,-32768, 648, 2189,
1140 227, 489,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4,
1141 -32768, 743, -4,-32768,-32768, 412,-32768, 425, 577,-32768,
1142 943,-32768,-32768, 438,-32768, 47,-32768, 455,-32768,-32768,
1143 506,-32768,-32768, 1916,-32768,-32768,-32768, 655, 569, 321,
1144 -32768, 589,-32768,-32768, 532,-32768,-32768,-32768, 485,-32768,
1145 -32768, 3001, 3052, 3117, 3168, 533, 18, 615,-32768, 3233,
1146 3284, 3349, 5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1147 302, 915, 63,-32768, 542, 581, 587,-32768,-32768,-32768,
1148 656,-32768, 766,-32768, 780, 846,-32768,-32768,-32768,-32768,
1149 -32768,-32768,-32768, 879, 896, 937, 893, 880, 697, 701,
1150 717, 741, 74,-32768,-32768,-32768, 841,-32768,-32768,-32768,
1151 -32768,-32768,-32768,-32768,-32768, 774, 506,-32768,-32768,-32768,
1152 -32768, 565, 690, 685,-32768, 600, 172, 3400,-32768, 206,
1153 2240, 17, 311, 342, 82, 426, 211, 700, 5597,-32768,
1154 -35, 651, 837, 229, 522,-32768, 589, 705,-32768, 1848,
1155 -32768,-32768, 702,-32768,-32768,-32768, 1984,-32768,-32768, 709,
1156 -32768,-32768,-32768,-32768, 1984,-32768, 1984,-32768,-32768, 5648,
1157 738,-32768,-32768,-32768,-32768,-32768, 436,-32768, 806, 808,
1158 846, 891, 908,-32768,-32768,-32768,-32768, 869,-32768, 654,
1159 684, 686,-32768, 722,-32768,-32768,-32768,-32768,-32768,-32768,
1160 -32768,-32768,-32768, 27,-32768, 691, 860, 724, 724, 452,
1161 -32768,-32768,-32768,-32768,-32768, 694, 1044, 43,-32768,-32768,
1162 669, 747, 222, 5365, 2305, 538,-32768, 279, 3465, 772,
1163 -32768, 458,-32768,-32768, 3516, 3581, 3632, 3697, 3748, 3813,
1164 3864, 3929, 3980, 4045, 4096, 4161, 721, 4212, 4277, 4328,
1165 4393, 4444, 4509, 4560, 2356,-32768,-32768, 4625,-32768, 368,
1166 -32768,-32768,-32768, 750,-32768,-32768,-32768, 1848,-32768,-32768,
1167 -32768,-32768, 4676,-32768, 35,-32768,-32768, 56,-32768,-32768,
1168 70,-32768, 4741,-32768, 4792,-32768, 718,-32768, 5206,-32768,
1169 -32768, 144, 259, 762, 235, 2421, 652,-32768,-32768, -35,
1170 2472,-32768,-32768,-32768,-32768, 1096, 569,-32768,-32768, 779,
1171 -32768, 810, 1032,-32768,-32768,-32768, 76, 2537,-32768, 4857,
1172 -32768,-32768,-32768, 869,-32768,-32768,-32768,-32768, -49, 789,
1173 -32768,-32768,-32768, 2588, 724,-32768, 479, 724, 479,-32768,
1174 2653, 4908, 240, 135, 2704, 657,-32768, 1671,-32768, 2124,
1175 -32768,-32768,-32768,-32768, 547,-32768,-32768,-32768, 244,-32768,
1176 -32768,-32768,-32768,-32768, 801,-32768, 251,-32768,-32768, 5416,
1177 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 879,-32768, 879,
1178 -32768, 896,-32768, 896,-32768, 896,-32768, 937,-32768, 937,
1179 -32768, 937,-32768, 937,-32768, 165,-32768,-32768, 893,-32768,
1180 893,-32768, 880,-32768, 697,-32768, 701,-32768, 717,-32768,
1181 741,-32768, 901, 818,-32768,-32768,-32768,-32768, 1076,-32768,
1182 1848, 815, 811, 1848,-32768, 335,-32768,-32768,-32768,-32768,
1183 -32768,-32768,-32768, 351,-32768, 823, 463, 132, 718,-32768,
1184 455,-32768,-32768,-32768,-32768,-32768, 819, 824, 464, 762,
1185 -32768, 941, 66, -9,-32768, 851,-32768, 5340,-32768, 5231,
1186 840, 854, 857,-32768,-32768, 5481,-32768,-32768, 272,-32768,
1187 864, 294,-32768, 864,-32768,-32768, 878, 94,-32768,-32768,
1188 -32768, 819, 4973, 824, 1120,-32768,-32768,-32768,-32768,-32768,
1189 5024,-32768,-32768, 5532,-32768,-32768, 354, 548,-32768, 5089,
1190 744,-32768, 1848, 2769,-32768,-32768,-32768, 2050,-32768,-32768,
1191 263,-32768, 681,-32768,-32768,-32768,-32768,-32768,-32768, 2820,
1192 -32768,-32768, 963, 212, 5140,-32768, 419,-32768, 1564,-32768,
1193 5597,-32768,-32768,-32768, 881, 886, 5273,-32768, 268,-32768,
1194 728,-32768,-32768,-32768,-32768, 354,-32768, 903,-32768,-32768,
1195 -32768,-32768,-32768,-32768,-32768, 731,-32768, 354,-32768,-32768,
1196 504,-32768, 173, 121, 509,-32768, 940, 944, 2050,-32768,
1197 -32768, 2050,-32768,-32768, 904,-32768, 923, 925,-32768, 1020,
1198 137,-32768,-32768,-32768,-32768,-32768, 262,-32768,-32768, 1646,
1199 -32768, 1780,-32768, 932, 1984,-32768, 942,-32768,-32768,-32768,
1200 -32768, 354,-32768,-32768, 2885,-32768, 182, 4676, 1984,-32768,
1201 -32768, 2936,-32768,-32768,-32768,-32768, 1029,-32768,-32768,-32768,
1202 945,-32768, 1984,-32768, 210, 177,-32768, 401,-32768, 5231,
1203 946,-32768,-32768,-32768,-32768, 224, 2050, 947, 5273,-32768,
1204 975, 2050, 949, 2050,-32768, 2050,-32768,-32768, 1037, 1040,
1208 static const short yypgoto[] = {-32768,
1209 -32768, -54, 157, 660, 16, -122, 582,-32768, -3, 319,
1210 -32768, 64,-32768, 1038, 413,-32768, 69,-32768,-32768, 734,
1211 106, 409,-32768,-32768, 997, 979,-32768, -131,-32768, 898,
1212 -32768, -79, -116, 918, -167, -194,-32768,-32768, -64, 285,
1213 805, -325, -129, -90,-32768,-32768,-32768,-32768,-32768,-32768,
1214 -32768, 907,-32768, -544,-32768, 662, -20,-32768,-32768,-32768,
1215 -32768, 1011, 561,-32768, 978,-32768,-32768, -176,-32768, -127,
1216 813, 784, -168, -276,-32768, 769, -251, 93, -560,-32768,
1217 -528,-32768,-32768,-32768, -263,-32768,-32768,-32768,-32768,-32768,
1218 -32768,-32768,-32768, 415, 416, -632, -527,-32768,-32768,-32768,
1219 -32768,-32768,-32768,-32768, -516,-32768, -667, 770,-32768,-32768,
1220 -32768,-32768,-32768,-32768,-32768,-32768, 511,-32768, 513,-32768,
1221 -32768,-32768,-32768, 186,-32768,-32768,-32768,-32768, -426,-32768,
1222 736, 126, -324, 1163, 192, 1197, 283, 379, 507, -171,
1223 583, 704, -472,-32768, 602, 603, 481, 601, 696, 698,
1224 695, 710, 703,-32768, 454, 706, 745,-32768,-32768, 936,
1232 static const short yytable[] = { 21,
1233 175, 173, 29, 182, 462, 290, 152, 83, 360, 737,
1234 328, 184, 38, 444, 593, 626, 642, 345, 345, 646,
1235 337, 339, 341, 343, 479, 76, 143, 467, 352, 354,
1236 124, 484, 486, 173, 123, 567, 733, 664, 61, 83,
1237 263, 93, 61, 487, 604, 448, 455, 261, 134, 164,
1238 20, 605, 665, 451, 618, 452, 569, 59, 88, 252,
1239 61, 67, 254, 367, 166, 61, 662, 25, 27, 62,
1240 571, 48, 35, 93, 83, 350, 597, 31, 178, 59,
1241 265, 164, 426, 638, 59, 88, 666, 708, 394, 36,
1242 88, 64, 135, 468, 687, 37, 166, 733, 702, 52,
1243 54, 31, 778, 57, 123, 16, 83, 50, 172, -158,
1244 39, 783, 40, 57, 16, 16, 16, 346, 346, 709,
1245 712, 662, 144, 77, 61, 88, 182, 331, 125, 88,
1246 61, 715, 654, 568, 404, 16, 488, 756, 16, 16,
1247 172, -104, 110, 59, 584, -104, 113, 427, 708, 67,
1248 611, 708, 692, 614, 570, 88, 16, 88, 19, 663,
1249 395, -94, -94, 464, 434, 631, 401, 89, 572, 49,
1250 283, 50, 412, 661, -295, 598, 156, 756, 88, 681,
1251 709, 712, 722, 709, 712, 110, 113, 688, 334, 334,
1252 334, 334, 715, 631, 61, 715, 334, 334, 357, 89,
1253 182, 178, 189, 512, 514, 516, 416, 696, 146, 466,
1254 755, 430, 723, 349, 747, 186, 708, 704, 84, 145,
1255 631, 708, 492, 708, 772, 708, 156, 249, 623, 438,
1256 757, 612, 440, 721, 159, 144, 631, 284, 179, 564,
1257 621, 189, 585, 20, 632, 84, -31, 1, 709, 712,
1258 84, 635, 88, 709, 712, 709, 712, 709, 712, 487,
1259 715, 118, 758, 716, 413, 715, 159, 715, 738, 715,
1260 776, 746, 682, -25, -25, 178, 631, 120, 55, 285,
1261 767, 50, 56, 88, 372, 84, 283, 444, 493, 84,
1262 2, 20, 140, 446, 684, 629, 20, 141, 142, 724,
1263 613, 446, 615, 446, 417, 147, 453, 4, 775, 431,
1264 620, 422, 187, 5, -25, 84, 439, 84, 766, -25,
1265 -25, -25, 780, 590, 250, -25, 88, 718, 61, -25,
1266 282, 41, 587, 418, 673, 647, 455, 622, 84, 26,
1267 432, 633, 424, 71, 189, 7, 101, 67, 636, 759,
1268 504, 649, 586, 284, 348, -28, 1, -257, 356, 319,
1269 284, 179, 156, 20, 20, 320, 444, 117, 284, 683,
1270 284, 334, 334, 334, 334, 334, 334, 334, 334, 334,
1271 334, 334, 334, 88, 334, 334, 334, 334, 334, 334,
1272 334, 685, 643, 42, 189, 285, 706, -66, 362, 2,
1273 69, 647, 363, 423, 559, 42, 150, 153, 17, 470,
1274 3, 119, 84, 455, 329, 179, 4, 17, 17, 17,
1275 330, 30, 5, 34, 20, -159, 428, 128, 648, 57,
1276 6, 505, -30, 1, 425, 179, 459, -161, 17, 28,
1277 -66, 17, 17, 84, 650, 51, 282, 158, 129, 137,
1278 655, 690, 480, 658, 7, 444, 321, 448, 509, 17,
1279 451, 557, 133, 652, 659, 664, 282, 330, -34, 1,
1280 90, 284, -29, 1, 148, 319, 2, 158, 334, 158,
1281 665, 320, 319, 762, 334, 137, 84, 3, 320, 251,
1282 319, 45, 319, 4, 777, 319, 320, 769, 320, 5,
1283 57, 320, 90, 189, 659, 697, 455, 255, 74, 412,
1284 53, 774, 2, 285, 728, 455, 2, 256, 429, -32,
1285 1, 58, -323, 182, 20, 706, 66, 3, 460, 4,
1286 762, 7, 769, 4, 774, 5, 260, 160, 500, 5,
1287 -97, 133, -65, 536, 481, -97, -97, -97, -97, 156,
1288 510, 739, 322, 46, 741, 653, 660, 283, 134, -65,
1289 283, -33, 1, 2, 282, 35, 744, 7, 98, 160,
1290 46, 7, 321, 203, 3, 612, -97, 121, -97, 321,
1291 4, -97, -97, -97, -97, -65, 5, 321, 37, 321,
1292 -35, 1, 321, 319, 102, 20, 745, 109, 178, 320,
1293 610, 748, -65, 610, 501, 2, 20, 112, 149, 502,
1294 764, 20, 35, 503, -323, 347, 151, 154, 7, 334,
1295 35, 334, 4, 20, 284, 100, 78, 284, 5, 176,
1296 183, 332, 106, 344, 2, 122, 334, 36, 78, 283,
1297 630, 698, 368, 37, 446, 99, 631, 631, 188, 88,
1298 103, 4, 500, 20, 461, 327, 371, 5, 80, 156,
1299 7, 81, 20, 402, 78, 283, 285, 131, 322, 285,
1300 80, -140, 2, 81, 20, 322, 121, 369, 78, 20,
1301 323, 717, 20, 322, 463, 322, 465, 370, 322, 7,
1302 321, 469, 20, 20, 409, 410, 80, 2, 411, 81,
1303 20, 20, 20, 78, 57, 446, 284, 390, 446, 155,
1304 80, 284, 391, 81, 20, 20, 589, 282, 501, 35,
1305 282, 535, 177, 502, 2, 78, 283, 503, 283, 392,
1306 78, 446, 284, 20, 122, 80, 36, 20, 81, 20,
1307 20, 20, 37, 32, 500, 446, 319, 435, 285, 319,
1308 625, 363, 320, 612, 393, 320, 324, 80, 179, 446,
1309 81, 20, 80, 32, 489, 81, 20, 32, 490, 20,
1310 78, 20, 284, 446, 285, 284, 20, 577, 446, 406,
1311 446, 578, 446, 319, 32, 319, 322, 482, 405, 320,
1312 483, 320, -157, 284, 363, 284, 323, 441, 284, 282,
1313 445, 750, 80, 323, 751, 81, 20, 449, 701, 84,
1314 501, 323, 284, 323, 364, 502, 323, 2, 365, 503,
1315 474, 740, 366, 78, 743, 282, 284, 631, 319, 20,
1316 631, 138, 139, 319, 320, 285, 458, 285, 508, 320,
1317 284, 253, 139, 321, 491, 284, 321, 284, 558, 284,
1318 -342, -342, -344, -344, 319, 80, -505, -505, 81, 20,
1319 320, 139, 319, 528, 530, 532, 534, 399, 320, 781,
1320 -506, -506, 324, 594, 785, 596, 787, 325, 788, 324,
1321 321, 606, 321, 375, 376, 377, 282, 324, 282, 324,
1322 373, 374, 324, 634, 319, 388, 389, 319, 378, 379,
1323 320, 639, -342, 320, -344, 640, -342, 644, -344, 645,
1324 383, 384, 385, 386, 323, 319, 651, 319, 326, -352,
1325 319, 320, -15, 320, -353, 321, 320, -504, -504, 364,
1326 321, 396, 397, 436, 319, -415, -415, 437, 677, 322,
1327 320, 661, 322, 671, 380, 381, 382, 678, 319, 387,
1328 679, 321, -416, -416, 320, 319, 471, 472, 473, 321,
1329 612, 320, 319, 722, 319, 141, 142, 319, 320, 319,
1330 320, 319, -373, 320, 735, 320, 322, 320, 322, 518,
1331 520, 2, 522, 524, 526, 598, 2, 78, 539, 541,
1332 324, 321, 78, 325, 321, 749, 79, -371, 4, -208,
1333 325, 79, 752, 4, 5, -504, -504, 364, 325, 5,
1334 325, 365, 321, 325, 321, 366, 753, 321, 754, 80,
1335 755, 322, 81, 20, 80, 761, 322, 81, 20, 772,
1336 784, 321, 156, 157, 326, 763, 790, 156, 258, 791,
1337 782, 326, 786, 773, 779, 321, 537, 322, 33, 326,
1338 75, 326, 321, 108, 326, 322, 190, 2, 259, 321,
1339 400, 321, 73, 78, 321, 257, 321, 323, 321, 562,
1340 323, 127, 79, 443, 4, 248, 408, 2, 454, 457,
1341 5, 729, 730, 78, 478, 543, 547, 322, 545, 656,
1342 322, 657, 79, 700, 4, 80, 551, 0, 81, 20,
1343 5, 0, 549, 556, 323, 0, 323, 0, 322, 82,
1344 322, 325, 0, 322, 0, 80, 0, -15, 81, 20,
1345 691, 0, -504, -504, 364, 0, 0, 322, 436, 126,
1346 0, 0, 366, 0, -504, -504, 364, 358, 248, 0,
1347 485, 322, 0, 324, 366, 0, 324, 0, 322, 323,
1348 0, 0, 326, 0, 323, 322, 0, 322, 0, 0,
1349 322, -15, 322, 0, 322, 0, -504, -504, 364, 78,
1350 0, 0, 436, 0, 0, 323, 641, 0, 196, 0,
1351 324, 0, 324, 323, 197, 0, -504, -504, 364, 0,
1352 0, 198, 365, 0, 0, 199, 437, 0, 0, 0,
1353 0, 80, 0, 415, 81, 20, 421, 0, 200, 201,
1354 0, 0, 202, 0, 433, 323, 0, 0, 323, 0,
1355 0, 204, 205, 206, 207, 324, 0, 208, 209, 0,
1356 324, 0, 0, 0, 0, 0, 323, 0, 323, 0,
1357 0, 323, 0, 0, 0, 0, 0, 0, 0, 0,
1358 0, 324, 0, 0, 0, 323, 0, 0, 0, 324,
1359 0, 0, 0, 0, 325, 0, 0, 325, 0, 323,
1360 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
1361 0, 0, 0, 323, 0, 323, 0, 0, 323, 0,
1362 323, 324, 323, 0, 324, 0, 0, 0, 0, 0,
1363 499, 325, 0, 325, 507, 326, 0, 0, 326, 0,
1364 0, 0, 324, 0, 324, 0, 0, 324, 0, 0,
1365 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1366 554, 324, 0, 0, 0, 0, 0, 0, 0, 0,
1367 0, 0, 326, 0, 326, 324, 325, 0, 566, 0,
1368 0, 325, 324, 0, 335, 335, 335, 335, 574, 324,
1369 576, 324, 335, 335, 324, 0, 324, 0, 324, 0,
1370 0, 499, 325, 0, 0, 0, 0, 0, 0, 0,
1371 325, 0, 0, 0, 0, 0, 0, 326, 336, 336,
1372 336, 336, 326, 601, 0, 603, 336, 336, 0, 0,
1373 0, 0, 0, 0, 0, 0, 0, 0, 0, 609,
1374 0, 0, 325, 326, 0, 325, 0, 0, 0, 0,
1375 499, 326, 0, 0, 0, 248, 0, 0, 0, 0,
1376 0, 0, 0, 325, 0, 325, 0, 0, 325, 0,
1377 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1378 0, 0, 325, 326, 0, 0, 326, 0, 0, 0,
1379 0, 0, 0, 0, 0, 0, 325, 0, 0, 0,
1380 0, 0, 0, 325, 326, 0, 326, 0, 0, 326,
1381 325, 0, 325, 0, 0, 325, 0, 325, 0, 325,
1382 0, 0, 0, 326, 0, 0, 0, 0, 0, 0,
1383 0, 0, 0, 0, 0, 0, 0, 326, 0, 0,
1384 0, 0, 0, 0, 326, 0, 0, 0, 0, 0,
1385 0, 326, 0, 326, 0, 0, 326, 0, 326, 0,
1386 326, 0, 0, 0, 0, 0, 0, 335, 335, 335,
1387 335, 335, 335, 335, 335, 335, 335, 335, 335, 0,
1388 335, 335, 335, 335, 335, 335, 335, 0, 0, 0,
1389 0, 0, 0, 0, 266, 0, 694, 0, 0, 0,
1390 0, 336, 336, 336, 336, 336, 336, 336, 336, 336,
1391 336, 336, 336, 0, 336, 336, 336, 336, 336, 336,
1392 336, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1393 726, 0, 0, 0, 0, 0, 734, 2, 194, 195,
1394 664, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1395 0, 271, 196, 0, 0, 665, 0, 0, 272, 273,
1396 5, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1397 0, 0, 0, 0, 335, 80, 266, 0, 81, 20,
1398 335, 0, 0, 0, 0, 0, 279, 0, 156, 731,
1399 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1400 0, 208, 209, 0, 0, 0, 0, 0, 336, 0,
1401 0, 0, 0, 768, 336, 0, 0, 771, 0, 2,
1402 194, 195, 664, 267, 268, 78, 269, 0, 0, 270,
1403 0, 0, 0, 271, 196, 0, 0, 665, 0, 0,
1404 272, 273, 5, 274, 0, 275, 276, 198, 277, 0,
1405 78, 278, 0, 0, 0, 0, 0, 80, 0, 196,
1406 81, 20, 0, 0, 0, 197, 0, 0, 279, 0,
1407 156, 760, 198, 0, 280, 0, 199, 204, 205, 206,
1408 207, 0, 80, 208, 209, 81, 20, 0, 0, 200,
1409 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1410 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1411 266, 0, 0, 0, 0, 335, 0, 335, 0, 0,
1412 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1413 0, 0, 335, 0, 0, 0, 0, 0, 0, 0,
1414 0, 0, 0, 0, 0, 0, 0, 0, 0, 336,
1415 0, 336, 0, 2, 194, 195, -267, 267, 268, 78,
1416 269, 0, 0, 270, 0, 0, 336, 271, 196, 0,
1417 0, -267, 0, 0, 272, 273, 5, 274, 266, 275,
1418 276, 198, 277, 0, 0, 278, 0, 0, 0, 0,
1419 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1420 0, 0, 279, 0, 156, -267, 0, 0, 280, 0,
1421 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1422 0, 2, 194, 195, 0, 267, 268, 78, 269, 0,
1423 0, 270, 0, 0, 0, 271, 196, 0, 0, 0,
1424 0, 0, 272, 273, 5, 274, 266, 275, 276, 198,
1425 277, 0, 0, 278, 0, 0, 0, 0, 0, 80,
1426 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1427 279, 0, 156, 442, 0, 0, 280, 0, 0, 204,
1428 205, 206, 207, 0, 0, 208, 209, 0, 0, 2,
1429 194, 195, 0, 267, 268, 78, 269, 0, 0, 270,
1430 0, 0, 0, 271, 196, 0, 0, 0, 0, 0,
1431 272, 273, 5, 274, 266, 275, 276, 198, 277, 0,
1432 0, 278, 0, 0, 0, 0, 0, 80, 0, 0,
1433 81, 20, 0, 0, 0, 0, 0, 0, 279, 0,
1434 156, 0, 0, 0, 280, 0, 0, 204, 205, 206,
1435 207, 0, 0, 208, 209, 0, 0, 2, 194, 195,
1436 0, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1437 0, 271, 196, 0, 0, 0, 0, 0, 272, 273,
1438 266, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1439 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1440 0, 0, 0, 0, 0, 0, 279, 0, 156, 0,
1441 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1442 0, 208, 209, 2, 194, 195, 0, 705, 268, 78,
1443 269, 0, 0, 270, 0, 0, 0, 271, 196, 0,
1444 0, 0, 0, 0, 272, 273, 0, 274, 0, 275,
1445 276, 198, 277, 0, 627, 278, 192, 193, 0, 0,
1446 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1447 0, 0, 279, 0, 156, 0, 0, 0, 280, 0,
1448 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1449 0, 0, 0, 0, 0, 0, 0, 0, 194, 195,
1450 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1451 0, 0, 196, 0, 0, 0, 0, 0, 197, 191,
1452 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1453 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1454 0, 0, 200, 201, 0, 0, 202, 0, 203, 628,
1455 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1456 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1457 419, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1458 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1459 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1460 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1461 0, 202, 0, 203, 194, 195, 0, 0, 0, 78,
1462 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1463 0, 0, 0, 0, 197, 497, 0, 192, 193, 0,
1464 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1465 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1466 0, 0, 202, 0, 0, 0, 0, 0, 420, 0,
1467 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1468 195, 0, 0, 0, 78, 0, 552, 0, 192, 193,
1469 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1470 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1471 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1472 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1473 194, 195, 498, 0, 0, 78, 204, 205, 206, 207,
1474 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1475 197, 497, 0, 192, 193, 0, 0, 198, 0, 0,
1476 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1477 81, 20, 0, 553, 200, 201, 0, 0, 202, 0,
1478 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1479 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1480 78, 0, 591, 0, 192, 193, 0, 0, 0, 196,
1481 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1482 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1483 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1484 201, 0, 0, 202, 0, 0, 194, 195, 588, 0,
1485 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1486 196, 0, 0, 0, 0, 0, 197, 599, 0, 192,
1487 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1488 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1489 200, 201, 0, 0, 202, 592, 0, 0, 0, 0,
1490 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1491 209, 194, 195, 0, 0, 0, 78, 0, 607, 0,
1492 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1493 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1494 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1495 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1496 0, 0, 194, 195, 0, 600, 0, 78, 204, 205,
1497 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1498 0, 0, 197, 616, 0, 192, 193, 0, 0, 198,
1499 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1500 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1501 202, 0, 0, 0, 0, 608, 0, 0, 0, 204,
1502 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1503 0, 0, 78, 0, 497, 0, 192, 193, 0, 0,
1504 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1505 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1506 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1507 0, 200, 201, 0, 0, 202, 617, 0, 194, 195,
1508 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1509 208, 209, 196, 0, 0, 0, 0, 0, 197, 591,
1510 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1511 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1512 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1513 0, 624, 0, 0, 0, 204, 205, 206, 207, 0,
1514 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1515 719, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1516 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1517 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1518 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1519 0, 202, 703, 0, 194, 195, 0, 0, 0, 78,
1520 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1521 0, 0, 0, 0, 197, 719, 0, 192, 193, 0,
1522 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1523 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1524 0, 0, 202, 720, 0, 0, 0, 0, 0, 0,
1525 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1526 195, 0, 0, 0, 78, 0, 599, 0, 192, 193,
1527 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1528 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1529 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1530 20, 0, 0, 200, 201, 0, 0, 202, 765, 0,
1531 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1532 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1533 197, 333, 0, 192, 193, 0, 0, 198, 0, 0,
1534 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1535 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1536 0, 0, 0, 0, 770, 0, 0, 204, 205, 206,
1537 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1538 78, 0, 338, 0, 192, 193, 0, 0, 0, 196,
1539 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1540 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1541 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1542 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1543 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1544 196, 0, 0, 0, 0, 0, 197, 340, 0, 192,
1545 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1546 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1547 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1548 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1549 209, 194, 195, 0, 0, 0, 78, 0, 342, 0,
1550 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1551 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1552 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1553 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1554 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1555 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1556 0, 0, 197, 351, 0, 192, 193, 0, 0, 198,
1557 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1558 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1559 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1560 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1561 0, 0, 78, 0, 353, 0, 192, 193, 0, 0,
1562 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1563 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1564 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1565 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1566 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1567 208, 209, 196, 0, 0, 0, 0, 0, 197, 355,
1568 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1569 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1570 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1571 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1572 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1573 414, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1574 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1575 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1576 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1577 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1578 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1579 0, 0, 0, 0, 197, 506, 0, 192, 193, 0,
1580 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1581 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1582 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1583 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1584 195, 0, 0, 0, 78, 0, 511, 0, 192, 193,
1585 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1586 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1587 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1588 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1589 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1590 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1591 197, 513, 0, 192, 193, 0, 0, 198, 0, 0,
1592 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1593 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1594 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1595 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1596 78, 0, 515, 0, 192, 193, 0, 0, 0, 196,
1597 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1598 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1599 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1600 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1601 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1602 196, 0, 0, 0, 0, 0, 197, 517, 0, 192,
1603 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1604 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1605 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1606 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1607 209, 194, 195, 0, 0, 0, 78, 0, 519, 0,
1608 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1609 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1610 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1611 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1612 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1613 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1614 0, 0, 197, 521, 0, 192, 193, 0, 0, 198,
1615 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1616 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1617 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1618 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1619 0, 0, 78, 0, 523, 0, 192, 193, 0, 0,
1620 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1621 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1622 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1623 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1624 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1625 208, 209, 196, 0, 0, 0, 0, 0, 197, 525,
1626 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1627 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1628 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1629 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1630 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1631 527, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1632 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1633 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1634 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1635 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1636 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1637 0, 0, 0, 0, 197, 529, 0, 192, 193, 0,
1638 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1639 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1640 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1641 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1642 195, 0, 0, 0, 78, 0, 531, 0, 192, 193,
1643 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1644 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1645 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1646 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1647 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1648 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1649 197, 533, 0, 192, 193, 0, 0, 198, 0, 0,
1650 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1651 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1652 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1653 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1654 78, 0, 538, 0, 192, 193, 0, 0, 0, 196,
1655 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1656 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1657 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1658 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1659 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1660 196, 0, 0, 0, 0, 0, 197, 540, 0, 192,
1661 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1662 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1663 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1664 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1665 209, 194, 195, 0, 0, 0, 78, 0, 542, 0,
1666 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1667 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1668 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1669 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1670 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1671 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1672 0, 0, 197, 544, 0, 192, 193, 0, 0, 198,
1673 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1674 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1675 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1676 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1677 0, 0, 78, 0, 546, 0, 192, 193, 0, 0,
1678 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1679 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1680 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1681 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1682 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1683 208, 209, 196, 0, 0, 0, 0, 0, 197, 548,
1684 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1685 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1686 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1687 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1688 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1689 550, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1690 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1691 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1692 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1693 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1694 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1695 0, 0, 0, 0, 197, 555, 0, 192, 193, 0,
1696 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1697 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1698 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1699 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1700 195, 0, 0, 0, 78, 0, 565, 0, 192, 193,
1701 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1702 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1703 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1704 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1705 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1706 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1707 197, 573, 0, 192, 193, 0, 0, 198, 0, 0,
1708 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1709 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1710 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1711 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1712 78, 0, 575, 0, 192, 193, 0, 0, 0, 196,
1713 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1714 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1715 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1716 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1717 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1718 196, 0, 0, 0, 0, 0, 197, 602, 0, 192,
1719 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1720 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1721 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1722 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1723 209, 194, 195, 0, 0, 0, 78, 0, 619, 0,
1724 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1725 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1726 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1727 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1728 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1729 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1730 0, 0, 197, 689, 0, 192, 193, 0, 0, 198,
1731 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1732 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1733 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1734 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1735 0, 0, 78, 0, 693, 0, 192, 193, 0, 0,
1736 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1737 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1738 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1739 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1740 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1741 208, 209, 196, 0, 0, 0, 0, 0, 197, 699,
1742 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1743 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1744 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1745 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1746 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1747 725, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1748 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1749 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1750 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1751 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1752 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1753 0, 0, 0, 0, 197, 0, 583, 0, 0, 0,
1754 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1755 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1756 0, 674, 202, 0, 0, 0, 0, 0, 0, 0,
1757 0, 204, 205, 206, 207, 0, 0, 208, 209, -290,
1758 -290, -290, 0, 0, 0, -290, 0, 0, 0, 0,
1759 0, 0, 0, 0, -290, 0, 0, 0, 0, 0,
1760 -290, 0, 0, 736, 0, 194, 195, -290, 0, 0,
1761 78, -290, 0, 0, 0, 0, 0, -290, 0, 196,
1762 -290, -290, 0, 0, 0, 197, 0, 0, -290, 0,
1763 192, 193, 198, 0, -290, 0, 199, -290, -290, -290,
1764 -290, 0, 80, -290, -290, 81, 20, 194, 195, 0,
1765 0, 0, 78, 279, -298, 0, 0, 0, 0, 0,
1766 0, 196, 204, 205, 206, 207, 0, 197, 208, 209,
1767 672, 0, 194, 195, 198, 0, 0, 78, 199, 0,
1768 0, 0, 0, 0, 80, 0, 196, 81, 20, 0,
1769 0, 0, 197, 0, 0, 279, -298, 192, 193, 198,
1770 0, 0, 0, 199, 204, 205, 206, 207, 0, 80,
1771 208, 209, 81, 20, 194, 195, 200, 201, 0, 78,
1772 202, 0, 203, 359, 0, 0, 0, 0, 196, 204,
1773 205, 206, 207, 0, 197, 208, 209, 0, 0, 194,
1774 195, 198, 0, 0, 78, 199, 0, 0, 192, 193,
1775 0, 80, 0, 196, 81, 20, 0, 0, 0, 197,
1776 0, 0, 279, 0, 0, 0, 198, 0, 0, 0,
1777 199, 204, 205, 206, 207, 0, 80, 208, 209, 81,
1778 20, 0, 0, 200, 201, 0, 0, 202, 494, 0,
1779 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1780 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1781 197, 0, 0, 192, 193, 0, 0, 198, 0, 0,
1782 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1783 81, 20, 0, 0, 200, 201, 0, 0, 202, 637,
1784 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1785 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1786 78, 0, 0, 0, 192, 193, 0, 0, 0, 196,
1787 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1788 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1789 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1790 201, 0, 0, 202, 680, 0, 194, 195, 0, 0,
1791 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1792 196, 0, 0, 0, 0, 0, 197, 0, 0, 192,
1793 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1794 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1795 200, 201, 0, 0, 202, 695, 0, 0, 0, 0,
1796 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1797 209, 194, 195, 0, 0, 0, 78, 0, 0, 0,
1798 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1799 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1800 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1801 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1802 0, 2, 194, 195, 0, 0, 0, 78, 204, 205,
1803 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1804 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1805 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1806 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1807 279, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1808 205, 206, 207, 0, 0, 208, 209
1811 static const short yycheck[] = { 3,
1812 132, 129, 6, 133, 330, 174, 123, 62, 203, 677,
1813 178, 134, 1, 290, 441, 488, 561, 1, 1, 564,
1814 192, 193, 194, 195, 349, 1, 117, 1, 200, 201,
1815 1, 356, 357, 161, 89, 1, 669, 47, 42, 94,
1816 168, 62, 46, 1, 94, 297, 310, 1, 53, 129,
1817 86, 101, 62, 305, 481, 307, 1, 42, 62, 150,
1818 64, 46, 153, 1, 129, 69, 1, 4, 5, 95,
1819 1, 1, 44, 94, 129, 198, 1, 9, 133, 64,
1820 171, 161, 1, 510, 69, 89, 96, 648, 15, 61,
1821 94, 100, 97, 67, 1, 67, 161, 730, 643, 36,
1822 37, 33, 770, 40, 159, 0, 161, 101, 129, 93,
1823 99, 779, 101, 50, 9, 10, 11, 101, 101, 648,
1824 648, 1, 1, 99, 128, 129, 256, 182, 99, 133,
1825 134, 648, 1, 99, 262, 30, 94, 1, 33, 34,
1826 161, 95, 79, 128, 1, 99, 83, 275, 709, 134,
1827 475, 712, 625, 478, 99, 159, 51, 161, 1, 94,
1828 87, 99, 100, 331, 281, 100, 257, 62, 99, 99,
1829 174, 101, 1, 1, 99, 100, 95, 1, 182, 606,
1830 709, 709, 1, 712, 712, 122, 123, 94, 192, 193,
1831 194, 195, 709, 100, 198, 712, 200, 201, 202, 94,
1832 330, 256, 139, 375, 376, 377, 1, 634, 1, 332,
1833 1, 1, 1, 198, 94, 1, 777, 644, 62, 98,
1834 100, 782, 1, 784, 1, 786, 95, 1, 94, 1,
1835 94, 97, 287, 660, 129, 1, 100, 174, 133, 408,
1836 1, 178, 99, 86, 1, 89, 0, 1, 777, 777,
1837 94, 1, 256, 782, 782, 784, 784, 786, 786, 1,
1838 777, 97, 1, 1, 93, 782, 161, 784, 1, 786,
1839 94, 99, 1, 45, 46, 330, 100, 97, 1, 174,
1840 99, 101, 5, 287, 221, 129, 290, 564, 67, 133,
1841 44, 86, 92, 297, 1, 490, 86, 97, 98, 88,
1842 477, 305, 479, 307, 99, 98, 310, 61, 99, 99,
1843 482, 1, 98, 67, 86, 159, 88, 161, 745, 91,
1844 92, 93, 99, 440, 98, 97, 330, 653, 332, 101,
1845 174, 1, 98, 270, 598, 1, 600, 98, 182, 1,
1846 277, 98, 1, 1, 281, 99, 1, 332, 98, 88,
1847 72, 1, 94, 290, 198, 0, 1, 95, 202, 174,
1848 297, 256, 95, 86, 86, 174, 643, 83, 305, 98,
1849 307, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1850 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
1851 394, 98, 561, 63, 331, 290, 648, 52, 97, 44,
1852 52, 1, 101, 93, 408, 63, 122, 123, 0, 346,
1853 55, 97, 256, 677, 94, 310, 61, 9, 10, 11,
1854 100, 9, 67, 11, 86, 95, 1, 100, 94, 366,
1855 75, 368, 0, 1, 93, 330, 1, 95, 30, 1,
1856 95, 33, 34, 287, 94, 33, 290, 129, 95, 1,
1857 578, 623, 1, 581, 99, 732, 174, 709, 1, 51,
1858 712, 94, 93, 1, 1, 47, 310, 100, 0, 1,
1859 62, 408, 0, 1, 98, 290, 44, 159, 482, 161,
1860 62, 290, 297, 735, 488, 1, 330, 55, 297, 1,
1861 305, 1, 307, 61, 94, 310, 305, 749, 307, 67,
1862 437, 310, 94, 440, 1, 637, 770, 96, 1, 1,
1863 1, 763, 44, 408, 96, 779, 44, 93, 93, 0,
1864 1, 1, 1, 653, 86, 777, 1, 55, 93, 61,
1865 782, 99, 784, 61, 786, 67, 99, 129, 1, 67,
1866 92, 93, 52, 387, 93, 97, 98, 99, 100, 95,
1867 93, 679, 174, 63, 686, 93, 93, 561, 53, 52,
1868 564, 0, 1, 44, 408, 44, 698, 99, 1, 161,
1869 63, 99, 290, 95, 55, 97, 92, 1, 94, 297,
1870 61, 97, 98, 99, 100, 95, 67, 305, 67, 307,
1871 0, 1, 310, 408, 1, 86, 93, 1, 653, 408,
1872 475, 93, 95, 478, 67, 44, 86, 1, 1, 72,
1873 742, 86, 44, 76, 93, 1, 1, 1, 99, 623,
1874 44, 625, 61, 86, 561, 65, 50, 564, 67, 1,
1875 1, 100, 72, 101, 44, 59, 640, 61, 50, 643,
1876 94, 94, 101, 67, 648, 64, 100, 100, 1, 653,
1877 69, 61, 1, 86, 1, 1, 1, 67, 82, 95,
1878 99, 85, 86, 99, 50, 669, 561, 107, 290, 564,
1879 82, 95, 44, 85, 86, 297, 1, 97, 50, 86,
1880 174, 1, 86, 305, 1, 307, 1, 101, 310, 99,
1881 408, 1, 86, 86, 95, 96, 82, 44, 99, 85,
1882 86, 86, 86, 50, 641, 709, 643, 11, 712, 128,
1883 82, 648, 12, 85, 86, 86, 65, 561, 67, 44,
1884 564, 1, 94, 72, 44, 50, 730, 76, 732, 13,
1885 50, 735, 669, 86, 59, 82, 61, 86, 85, 86,
1886 86, 86, 67, 10, 1, 749, 561, 97, 643, 564,
1887 94, 101, 561, 97, 14, 564, 174, 82, 653, 763,
1888 85, 86, 82, 30, 96, 85, 86, 34, 100, 86,
1889 50, 86, 709, 777, 669, 712, 86, 60, 782, 95,
1890 784, 64, 786, 598, 51, 600, 408, 94, 99, 598,
1891 97, 600, 93, 730, 101, 732, 290, 93, 735, 643,
1892 99, 709, 82, 297, 712, 85, 86, 99, 65, 653,
1893 67, 305, 749, 307, 93, 72, 310, 44, 97, 76,
1894 97, 94, 101, 50, 94, 669, 763, 100, 643, 86,
1895 100, 99, 100, 648, 643, 730, 99, 732, 67, 648,
1896 777, 99, 100, 561, 98, 782, 564, 784, 99, 786,
1897 45, 46, 45, 46, 669, 82, 91, 92, 85, 86,
1898 669, 100, 677, 383, 384, 385, 386, 94, 677, 777,
1899 91, 92, 290, 95, 782, 66, 784, 174, 786, 297,
1900 598, 93, 600, 5, 6, 7, 730, 305, 732, 307,
1901 45, 46, 310, 93, 709, 16, 17, 712, 3, 4,
1902 709, 1, 97, 712, 97, 88, 101, 93, 101, 99,
1903 18, 19, 20, 21, 408, 730, 94, 732, 174, 101,
1904 735, 730, 86, 732, 101, 643, 735, 91, 92, 93,
1905 648, 91, 92, 97, 749, 45, 46, 101, 99, 561,
1906 749, 1, 564, 93, 8, 9, 10, 94, 763, 57,
1907 94, 669, 45, 46, 763, 770, 97, 98, 99, 677,
1908 97, 770, 777, 1, 779, 97, 98, 782, 777, 784,
1909 779, 786, 95, 782, 94, 784, 598, 786, 600, 378,
1910 379, 44, 380, 381, 382, 100, 44, 50, 388, 389,
1911 408, 709, 50, 290, 712, 56, 59, 95, 61, 56,
1912 297, 59, 99, 61, 67, 91, 92, 93, 305, 67,
1913 307, 97, 730, 310, 732, 101, 94, 735, 94, 82,
1914 1, 643, 85, 86, 82, 94, 648, 85, 86, 1,
1915 56, 749, 95, 96, 290, 94, 0, 95, 96, 0,
1916 94, 297, 94, 99, 99, 763, 387, 669, 11, 305,
1917 54, 307, 770, 75, 310, 677, 139, 44, 161, 777,
1918 256, 779, 52, 50, 782, 159, 784, 561, 786, 408,
1919 564, 94, 59, 290, 61, 140, 264, 44, 310, 310,
1920 67, 667, 667, 50, 349, 390, 392, 709, 391, 579,
1921 712, 579, 59, 640, 61, 82, 394, -1, 85, 86,
1922 67, -1, 393, 398, 598, -1, 600, -1, 730, 96,
1923 732, 408, -1, 735, -1, 82, -1, 86, 85, 86,
1924 1, -1, 91, 92, 93, -1, -1, 749, 97, 96,
1925 -1, -1, 101, -1, 91, 92, 93, 202, 203, -1,
1926 97, 763, -1, 561, 101, -1, 564, -1, 770, 643,
1927 -1, -1, 408, -1, 648, 777, -1, 779, -1, -1,
1928 782, 86, 784, -1, 786, -1, 91, 92, 93, 50,
1929 -1, -1, 97, -1, -1, 669, 101, -1, 59, -1,
1930 598, -1, 600, 677, 65, -1, 91, 92, 93, -1,
1931 -1, 72, 97, -1, -1, 76, 101, -1, -1, -1,
1932 -1, 82, -1, 268, 85, 86, 271, -1, 89, 90,
1933 -1, -1, 93, -1, 279, 709, -1, -1, 712, -1,
1934 -1, 102, 103, 104, 105, 643, -1, 108, 109, -1,
1935 648, -1, -1, -1, -1, -1, 730, -1, 732, -1,
1936 -1, 735, -1, -1, -1, -1, -1, -1, -1, -1,
1937 -1, 669, -1, -1, -1, 749, -1, -1, -1, 677,
1938 -1, -1, -1, -1, 561, -1, -1, 564, -1, 763,
1939 -1, -1, -1, -1, -1, -1, 770, -1, -1, -1,
1940 -1, -1, -1, 777, -1, 779, -1, -1, 782, -1,
1941 784, 709, 786, -1, 712, -1, -1, -1, -1, -1,
1942 365, 598, -1, 600, 369, 561, -1, -1, 564, -1,
1943 -1, -1, 730, -1, 732, -1, -1, 735, -1, -1,
1944 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1945 395, 749, -1, -1, -1, -1, -1, -1, -1, -1,
1946 -1, -1, 598, -1, 600, 763, 643, -1, 413, -1,
1947 -1, 648, 770, -1, 192, 193, 194, 195, 423, 777,
1948 425, 779, 200, 201, 782, -1, 784, -1, 786, -1,
1949 -1, 436, 669, -1, -1, -1, -1, -1, -1, -1,
1950 677, -1, -1, -1, -1, -1, -1, 643, 192, 193,
1951 194, 195, 648, 458, -1, 460, 200, 201, -1, -1,
1952 -1, -1, -1, -1, -1, -1, -1, -1, -1, 474,
1953 -1, -1, 709, 669, -1, 712, -1, -1, -1, -1,
1954 485, 677, -1, -1, -1, 490, -1, -1, -1, -1,
1955 -1, -1, -1, 730, -1, 732, -1, -1, 735, -1,
1956 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1957 -1, -1, 749, 709, -1, -1, 712, -1, -1, -1,
1958 -1, -1, -1, -1, -1, -1, 763, -1, -1, -1,
1959 -1, -1, -1, 770, 730, -1, 732, -1, -1, 735,
1960 777, -1, 779, -1, -1, 782, -1, 784, -1, 786,
1961 -1, -1, -1, 749, -1, -1, -1, -1, -1, -1,
1962 -1, -1, -1, -1, -1, -1, -1, 763, -1, -1,
1963 -1, -1, -1, -1, 770, -1, -1, -1, -1, -1,
1964 -1, 777, -1, 779, -1, -1, 782, -1, 784, -1,
1965 786, -1, -1, -1, -1, -1, -1, 375, 376, 377,
1966 378, 379, 380, 381, 382, 383, 384, 385, 386, -1,
1967 388, 389, 390, 391, 392, 393, 394, -1, -1, -1,
1968 -1, -1, -1, -1, 1, -1, 631, -1, -1, -1,
1969 -1, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1970 384, 385, 386, -1, 388, 389, 390, 391, 392, 393,
1971 394, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1972 665, -1, -1, -1, -1, -1, 671, 44, 45, 46,
1973 47, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1974 -1, 58, 59, -1, -1, 62, -1, -1, 65, 66,
1975 67, 68, -1, 70, 71, 72, 73, -1, -1, 76,
1976 -1, -1, -1, -1, 482, 82, 1, -1, 85, 86,
1977 488, -1, -1, -1, -1, -1, 93, -1, 95, 96,
1978 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1979 -1, 108, 109, -1, -1, -1, -1, -1, 482, -1,
1980 -1, -1, -1, 748, 488, -1, -1, 752, -1, 44,
1981 45, 46, 47, 48, 49, 50, 51, -1, -1, 54,
1982 -1, -1, -1, 58, 59, -1, -1, 62, -1, -1,
1983 65, 66, 67, 68, -1, 70, 71, 72, 73, -1,
1984 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
1985 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
1986 95, 96, 72, -1, 99, -1, 76, 102, 103, 104,
1987 105, -1, 82, 108, 109, 85, 86, -1, -1, 89,
1988 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
1989 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1990 1, -1, -1, -1, -1, 623, -1, 625, -1, -1,
1991 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1992 -1, -1, 640, -1, -1, -1, -1, -1, -1, -1,
1993 -1, -1, -1, -1, -1, -1, -1, -1, -1, 623,
1994 -1, 625, -1, 44, 45, 46, 47, 48, 49, 50,
1995 51, -1, -1, 54, -1, -1, 640, 58, 59, -1,
1996 -1, 62, -1, -1, 65, 66, 67, 68, 1, 70,
1997 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1998 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1999 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
2000 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
2001 -1, 44, 45, 46, -1, 48, 49, 50, 51, -1,
2002 -1, 54, -1, -1, -1, 58, 59, -1, -1, -1,
2003 -1, -1, 65, 66, 67, 68, 1, 70, 71, 72,
2004 73, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2005 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2006 93, -1, 95, 96, -1, -1, 99, -1, -1, 102,
2007 103, 104, 105, -1, -1, 108, 109, -1, -1, 44,
2008 45, 46, -1, 48, 49, 50, 51, -1, -1, 54,
2009 -1, -1, -1, 58, 59, -1, -1, -1, -1, -1,
2010 65, 66, 67, 68, 1, 70, 71, 72, 73, -1,
2011 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2012 85, 86, -1, -1, -1, -1, -1, -1, 93, -1,
2013 95, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2014 105, -1, -1, 108, 109, -1, -1, 44, 45, 46,
2015 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
2016 -1, 58, 59, -1, -1, -1, -1, -1, 65, 66,
2017 1, 68, -1, 70, 71, 72, 73, -1, -1, 76,
2018 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2019 -1, -1, -1, -1, -1, -1, 93, -1, 95, -1,
2020 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
2021 -1, 108, 109, 44, 45, 46, -1, 48, 49, 50,
2022 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
2023 -1, -1, -1, -1, 65, 66, -1, 68, -1, 70,
2024 71, 72, 73, -1, 1, 76, 3, 4, -1, -1,
2025 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
2026 -1, -1, 93, -1, 95, -1, -1, -1, 99, -1,
2027 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
2028 -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,
2029 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2030 -1, -1, 59, -1, -1, -1, -1, -1, 65, 1,
2031 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2032 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2033 -1, -1, 89, 90, -1, -1, 93, -1, 95, 96,
2034 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2035 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2036 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2037 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2038 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2039 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2040 -1, 93, -1, 95, 45, 46, -1, -1, -1, 50,
2041 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2042 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2043 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2044 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2045 -1, -1, 93, -1, -1, -1, -1, -1, 99, -1,
2046 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2047 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2048 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2049 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2050 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2051 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2052 45, 46, 98, -1, -1, 50, 102, 103, 104, 105,
2053 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2054 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2055 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2056 85, 86, -1, 88, 89, 90, -1, -1, 93, -1,
2057 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2058 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2059 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2060 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2061 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2062 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2063 90, -1, -1, 93, -1, -1, 45, 46, 98, -1,
2064 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2065 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2066 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2067 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2068 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2069 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2070 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2071 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2072 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2073 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2074 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2075 -1, -1, 45, 46, -1, 99, -1, 50, 102, 103,
2076 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2077 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2078 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2079 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2080 93, -1, -1, -1, -1, 98, -1, -1, -1, 102,
2081 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2082 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2083 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2084 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2085 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2086 -1, 89, 90, -1, -1, 93, 94, -1, 45, 46,
2087 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2088 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2089 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2090 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2091 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2092 -1, 98, -1, -1, -1, 102, 103, 104, 105, -1,
2093 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2094 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2095 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2096 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2097 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2098 -1, 93, 94, -1, 45, 46, -1, -1, -1, 50,
2099 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2100 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2101 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2102 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2103 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
2104 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2105 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2106 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2107 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2108 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2109 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2110 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2111 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2112 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2113 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2114 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2115 -1, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2116 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2117 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2118 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2119 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2120 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2121 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2122 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2123 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2124 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2125 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2126 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2127 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2128 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2129 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2130 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2131 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2132 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2133 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2134 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2135 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2136 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2137 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2138 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2139 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2140 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2141 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2142 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2143 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2144 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2145 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2146 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2147 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2148 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2149 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2150 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2151 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2152 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2153 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2154 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2155 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2156 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2157 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2158 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2159 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2160 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2161 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2162 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2163 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2164 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2165 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2166 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2167 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2168 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2169 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2170 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2171 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2172 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2173 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2174 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2175 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2176 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2177 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2178 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2179 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2180 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2181 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2182 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2183 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2184 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2185 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2186 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2187 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2188 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2189 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2190 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2191 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2192 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2193 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2194 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2195 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2196 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2197 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2198 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2199 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2200 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2201 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2202 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2203 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2204 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2205 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2206 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2207 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2208 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2209 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2210 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2211 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2212 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2213 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2214 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2215 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2216 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2217 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2218 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2219 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2220 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2221 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2222 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2223 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2224 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2225 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2226 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2227 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2228 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2229 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2230 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2231 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2232 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2233 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2234 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2235 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2236 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2237 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2238 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2239 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2240 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2241 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2242 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2243 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2244 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2245 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2246 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2247 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2248 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2249 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2250 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2251 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2252 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2253 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2254 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2255 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2256 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2257 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2258 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2259 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2260 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2261 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2262 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2263 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2264 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2265 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2266 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2267 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2268 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2269 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2270 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2271 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2272 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2273 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2274 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2275 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2276 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2277 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2278 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2279 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2280 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2281 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2282 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2283 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2284 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2285 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2286 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2287 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2288 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2289 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2290 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2291 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2292 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2293 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2294 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2295 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2296 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2297 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2298 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2299 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2300 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2301 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2302 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2303 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2304 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2305 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2306 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2307 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2308 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2309 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2310 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2311 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2312 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2313 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2314 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2315 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2316 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2317 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2318 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2319 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2320 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2321 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2322 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2323 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2324 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2325 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2326 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2327 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2328 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2329 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2330 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2331 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2332 -1, -1, -1, -1, 65, -1, 1, -1, -1, -1,
2333 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2334 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2335 -1, 1, 93, -1, -1, -1, -1, -1, -1, -1,
2336 -1, 102, 103, 104, 105, -1, -1, 108, 109, 44,
2337 45, 46, -1, -1, -1, 50, -1, -1, -1, -1,
2338 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2339 65, -1, -1, 1, -1, 45, 46, 72, -1, -1,
2340 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
2341 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
2342 3, 4, 72, -1, 99, -1, 76, 102, 103, 104,
2343 105, -1, 82, 108, 109, 85, 86, 45, 46, -1,
2344 -1, -1, 50, 93, 94, -1, -1, -1, -1, -1,
2345 -1, 59, 102, 103, 104, 105, -1, 65, 108, 109,
2346 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2347 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2348 -1, -1, 65, -1, -1, 93, 94, 3, 4, 72,
2349 -1, -1, -1, 76, 102, 103, 104, 105, -1, 82,
2350 108, 109, 85, 86, 45, 46, 89, 90, -1, 50,
2351 93, -1, 95, 96, -1, -1, -1, -1, 59, 102,
2352 103, 104, 105, -1, 65, 108, 109, -1, -1, 45,
2353 46, 72, -1, -1, 50, 76, -1, -1, 3, 4,
2354 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2355 -1, -1, 93, -1, -1, -1, 72, -1, -1, -1,
2356 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2357 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2358 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2359 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2360 65, -1, -1, 3, 4, -1, -1, 72, -1, -1,
2361 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2362 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
2363 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2364 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2365 50, -1, -1, -1, 3, 4, -1, -1, -1, 59,
2366 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2367 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2368 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2369 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
2370 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2371 59, -1, -1, -1, -1, -1, 65, -1, -1, 3,
2372 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2373 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2374 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2375 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2376 109, 45, 46, -1, -1, -1, 50, -1, -1, -1,
2377 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
2378 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2379 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2380 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2381 -1, 44, 45, 46, -1, -1, -1, 50, 102, 103,
2382 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2383 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2384 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2385 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2386 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2387 103, 104, 105, -1, -1, 108, 109
2391 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2392 #line 3 "/usr/lib/bison.simple"
2393 /* This file comes from bison-1.28. */
2395 /* Skeleton output parser for bison,
2396 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2398 This program is free software; you can redistribute it and/or modify
2399 it under the terms of the GNU General Public License as published by
2400 the Free Software Foundation; either version 2, or (at your option)
2403 This program is distributed in the hope that it will be useful,
2404 but WITHOUT ANY WARRANTY; without even the implied warranty of
2405 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2406 GNU General Public License for more details.
2408 You should have received a copy of the GNU General Public License
2409 along with this program; if not, write to the Free Software
2410 Foundation, Inc., 59 Temple Place - Suite 330,
2411 Boston, MA 02111-1307, USA. */
2413 /* As a special exception, when this file is copied by Bison into a
2414 Bison output file, you may use that output file without restriction.
2415 This special exception was added by the Free Software Foundation
2416 in version 1.24 of Bison. */
2418 /* This is the parser code that is written into each bison parser
2419 when the %semantic_parser declaration is not specified in the grammar.
2420 It was written by Richard Stallman by simplifying the hairy parser
2421 used when %semantic_parser is specified. */
2423 #ifndef YYSTACK_USE_ALLOCA
2425 #define YYSTACK_USE_ALLOCA
2426 #else /* alloca not defined */
2428 #define YYSTACK_USE_ALLOCA
2429 #define alloca __builtin_alloca
2430 #else /* not GNU C. */
2431 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2432 #define YYSTACK_USE_ALLOCA
2434 #else /* not sparc */
2435 /* We think this test detects Watcom and Microsoft C. */
2436 /* This used to test MSDOS, but that is a bad idea
2437 since that symbol is in the user namespace. */
2438 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2439 #if 0 /* No need for malloc.h, which pollutes the namespace;
2440 instead, just don't use alloca. */
2443 #else /* not MSDOS, or __TURBOC__ */
2445 /* I don't know what this was needed for, but it pollutes the namespace.
2446 So I turned it off. rms, 2 May 1997. */
2447 /* #include <malloc.h> */
2449 #define YYSTACK_USE_ALLOCA
2450 #else /* not MSDOS, or __TURBOC__, or _AIX */
2452 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2453 and on HPUX 10. Eventually we can turn this on. */
2454 #define YYSTACK_USE_ALLOCA
2455 #define alloca __builtin_alloca
2458 #endif /* not _AIX */
2459 #endif /* not MSDOS, or __TURBOC__ */
2460 #endif /* not sparc */
2461 #endif /* not GNU C */
2462 #endif /* alloca not defined */
2463 #endif /* YYSTACK_USE_ALLOCA not defined */
2465 #ifdef YYSTACK_USE_ALLOCA
2466 #define YYSTACK_ALLOC alloca
2468 #define YYSTACK_ALLOC malloc
2471 /* Note: there must be only one dollar sign in this file.
2472 It is replaced by the list of actions, each action
2473 as one case of the switch. */
2475 #define yyerrok (yyerrstatus = 0)
2476 #define yyclearin (yychar = YYEMPTY)
2479 #define YYACCEPT goto yyacceptlab
2480 #define YYABORT goto yyabortlab
2481 #define YYERROR goto yyerrlab1
2482 /* Like YYERROR except do call yyerror.
2483 This remains here temporarily to ease the
2484 transition to the new meaning of YYERROR, for GCC.
2485 Once GCC version 2 has supplanted version 1, this can go. */
2486 #define YYFAIL goto yyerrlab
2487 #define YYRECOVERING() (!!yyerrstatus)
2488 #define YYBACKUP(token, value) \
2490 if (yychar == YYEMPTY && yylen == 1) \
2491 { yychar = (token), yylval = (value); \
2492 yychar1 = YYTRANSLATE (yychar); \
2497 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2501 #define YYERRCODE 256
2504 #define YYLEX yylex()
2510 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2512 #define YYLEX yylex(&yylval, &yylloc)
2514 #else /* not YYLSP_NEEDED */
2516 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2518 #define YYLEX yylex(&yylval)
2520 #endif /* not YYLSP_NEEDED */
2523 /* If nonreentrant, generate the variables here */
2527 int yychar; /* the lookahead symbol */
2528 YYSTYPE yylval; /* the semantic value of the */
2529 /* lookahead symbol */
2532 YYLTYPE yylloc; /* location data for the lookahead */
2536 int yynerrs; /* number of parse errors so far */
2537 #endif /* not YYPURE */
2540 int yydebug; /* nonzero means print parse trace */
2541 /* Since this is uninitialized, it does not stop multiple parsers
2545 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2548 #define YYINITDEPTH 200
2551 /* YYMAXDEPTH is the maximum size the stacks can grow to
2552 (effective only if the built-in stack extension method is used). */
2559 #define YYMAXDEPTH 10000
2562 /* Define __yy_memcpy. Note that the size argument
2563 should be passed with type unsigned int, because that is what the non-GCC
2564 definitions require. With GCC, __builtin_memcpy takes an arg
2565 of type size_t, but it can handle unsigned int. */
2567 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2568 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2569 #else /* not GNU C or C++ */
2572 /* This is the most reliable way to avoid incompatibilities
2573 in available built-in functions on various systems. */
2575 __yy_memcpy (to, from, count)
2580 register char *f = from;
2581 register char *t = to;
2582 register int i = count;
2588 #else /* __cplusplus */
2590 /* This is the most reliable way to avoid incompatibilities
2591 in available built-in functions on various systems. */
2593 __yy_memcpy (char *to, char *from, unsigned int count)
2595 register char *t = to;
2596 register char *f = from;
2597 register int i = count;
2606 #line 217 "/usr/lib/bison.simple"
2608 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2609 into yyparse. The argument should have type void *.
2610 It should actually point to an object.
2611 Grammar actions can access the variable by casting it
2612 to the proper pointer type. */
2614 #ifdef YYPARSE_PARAM
2616 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2617 #define YYPARSE_PARAM_DECL
2618 #else /* not __cplusplus */
2619 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2620 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2621 #endif /* not __cplusplus */
2622 #else /* not YYPARSE_PARAM */
2623 #define YYPARSE_PARAM_ARG
2624 #define YYPARSE_PARAM_DECL
2625 #endif /* not YYPARSE_PARAM */
2627 /* Prevent warning if -Wstrict-prototypes. */
2629 #ifdef YYPARSE_PARAM
2630 int yyparse (void *);
2637 yyparse(YYPARSE_PARAM_ARG)
2640 register int yystate;
2642 register short *yyssp;
2643 register YYSTYPE *yyvsp;
2644 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2645 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2647 short yyssa[YYINITDEPTH]; /* the state stack */
2648 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2650 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2651 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2654 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2655 YYLTYPE *yyls = yylsa;
2658 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2660 #define YYPOPSTACK (yyvsp--, yyssp--)
2663 int yystacksize = YYINITDEPTH;
2664 int yyfree_stacks = 0;
2675 YYSTYPE yyval; /* the variable used to return */
2676 /* semantic values from the action */
2683 fprintf(stderr, "Starting parse\n");
2689 yychar = YYEMPTY; /* Cause a token to be read. */
2691 /* Initialize stack pointers.
2692 Waste one element of value and location stack
2693 so that they stay on the same level as the state stack.
2694 The wasted elements are never initialized. */
2702 /* Push a new state, which is found in yystate . */
2703 /* In all cases, when you get here, the value and location stacks
2704 have just been pushed. so pushing a state here evens the stacks. */
2709 if (yyssp >= yyss + yystacksize - 1)
2711 /* Give user a chance to reallocate the stack */
2712 /* Use copies of these so that the &'s don't force the real ones into memory. */
2713 YYSTYPE *yyvs1 = yyvs;
2714 short *yyss1 = yyss;
2716 YYLTYPE *yyls1 = yyls;
2719 /* Get the current used size of the three stacks, in elements. */
2720 int size = yyssp - yyss + 1;
2723 /* Each stack pointer address is followed by the size of
2724 the data in use in that stack, in bytes. */
2726 /* This used to be a conditional around just the two extra args,
2727 but that might be undefined if yyoverflow is a macro. */
2728 yyoverflow("parser stack overflow",
2729 &yyss1, size * sizeof (*yyssp),
2730 &yyvs1, size * sizeof (*yyvsp),
2731 &yyls1, size * sizeof (*yylsp),
2734 yyoverflow("parser stack overflow",
2735 &yyss1, size * sizeof (*yyssp),
2736 &yyvs1, size * sizeof (*yyvsp),
2740 yyss = yyss1; yyvs = yyvs1;
2744 #else /* no yyoverflow */
2745 /* Extend the stack our own way. */
2746 if (yystacksize >= YYMAXDEPTH)
2748 yyerror("parser stack overflow");
2760 if (yystacksize > YYMAXDEPTH)
2761 yystacksize = YYMAXDEPTH;
2762 #ifndef YYSTACK_USE_ALLOCA
2765 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2766 __yy_memcpy ((char *)yyss, (char *)yyss1,
2767 size * (unsigned int) sizeof (*yyssp));
2768 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2769 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2770 size * (unsigned int) sizeof (*yyvsp));
2772 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2773 __yy_memcpy ((char *)yyls, (char *)yyls1,
2774 size * (unsigned int) sizeof (*yylsp));
2776 #endif /* no yyoverflow */
2778 yyssp = yyss + size - 1;
2779 yyvsp = yyvs + size - 1;
2781 yylsp = yyls + size - 1;
2786 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2789 if (yyssp >= yyss + yystacksize - 1)
2795 fprintf(stderr, "Entering state %d\n", yystate);
2801 /* Do appropriate processing given the current state. */
2802 /* Read a lookahead token if we need one and don't already have one. */
2805 /* First try to decide what to do without reference to lookahead token. */
2807 yyn = yypact[yystate];
2811 /* Not known => get a lookahead token if don't already have one. */
2813 /* yychar is either YYEMPTY or YYEOF
2814 or a valid token in external form. */
2816 if (yychar == YYEMPTY)
2820 fprintf(stderr, "Reading a token: ");
2825 /* Convert token to internal form (in yychar1) for indexing tables with */
2827 if (yychar <= 0) /* This means end of input. */
2830 yychar = YYEOF; /* Don't call YYLEX any more */
2834 fprintf(stderr, "Now at end of input.\n");
2839 yychar1 = YYTRANSLATE(yychar);
2844 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2845 /* Give the individual parser a way to print the precise meaning
2846 of a token, for further debugging info. */
2848 YYPRINT (stderr, yychar, yylval);
2850 fprintf (stderr, ")\n");
2856 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2861 /* yyn is what to do for this token type in this state.
2862 Negative => reduce, -yyn is rule number.
2863 Positive => shift, yyn is new state.
2864 New state is final state => don't bother to shift,
2865 just return success.
2866 0, or most negative number => error. */
2881 /* Shift the lookahead token. */
2885 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2888 /* Discard the token being shifted unless it is eof. */
2889 if (yychar != YYEOF)
2897 /* count tokens shifted since error; after three, turn off error status. */
2898 if (yyerrstatus) yyerrstatus--;
2903 /* Do the default action for the current state. */
2906 yyn = yydefact[yystate];
2910 /* Do a reduction. yyn is the number of a rule to reduce with. */
2914 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2921 fprintf (stderr, "Reducing via rule %d (line %d), ",
2924 /* Print the symbols being reduced, and their result. */
2925 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2926 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2927 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2935 #line 578 "./parse.y"
2939 #line 622 "./parse.y"
2941 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2942 CLASS_LOADED_P (yyval.node) = 1;
2946 #line 627 "./parse.y"
2947 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2950 #line 629 "./parse.y"
2951 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2954 #line 631 "./parse.y"
2955 {RULE ("']' expected"); RECOVER;;
2958 #line 633 "./parse.y"
2959 {RULE ("']' expected"); RECOVER;;
2962 #line 648 "./parse.y"
2963 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2966 #line 657 "./parse.y"
2967 {yyval.node = NULL;;
2970 #line 669 "./parse.y"
2976 #line 673 "./parse.y"
2982 #line 685 "./parse.y"
2984 ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2985 register_package (ctxp->package);
2989 #line 690 "./parse.y"
2990 {yyerror ("Missing name"); RECOVER;;
2993 #line 692 "./parse.y"
2994 {yyerror ("';' expected"); RECOVER;;
2997 #line 702 "./parse.y"
2999 tree name = EXPR_WFL_NODE (yyvsp[-1].node), last_name;
3000 int i = IDENTIFIER_LENGTH (name)-1;
3001 const char *last = &IDENTIFIER_POINTER (name)[i];
3002 while (last != IDENTIFIER_POINTER (name))
3004 if (last [0] == '.')
3008 last_name = get_identifier (++last);
3009 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3011 tree err = find_name_in_single_imports (last_name);
3012 if (err && err != name)
3014 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3015 IDENTIFIER_POINTER (name),
3016 IDENTIFIER_POINTER (err));
3018 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3021 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3025 #line 728 "./parse.y"
3026 {yyerror ("Missing name"); RECOVER;;
3029 #line 730 "./parse.y"
3030 {yyerror ("';' expected"); RECOVER;;
3033 #line 735 "./parse.y"
3035 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3036 /* Don't import java.lang.* twice. */
3037 if (name != java_lang_id)
3039 read_import_dir (yyvsp[-3].node);
3040 ctxp->import_demand_list =
3041 chainon (ctxp->import_demand_list,
3042 build_tree_list (yyvsp[-3].node, NULL_TREE));
3047 #line 747 "./parse.y"
3048 {yyerror ("'*' expected"); RECOVER;;
3051 #line 749 "./parse.y"
3052 {yyerror ("';' expected"); RECOVER;;
3055 #line 754 "./parse.y"
3056 { end_class_declaration (0); ;
3059 #line 756 "./parse.y"
3060 { end_class_declaration (0); ;
3063 #line 758 "./parse.y"
3064 { yyval.node = NULL; ;
3067 #line 760 "./parse.y"
3070 yyerror ("Class or interface declaration expected");
3074 #line 771 "./parse.y"
3076 yyval.value = (1 << yyvsp[0].value);
3080 #line 775 "./parse.y"
3082 int acc = (1 << yyvsp[0].value);
3083 if (yyval.value & acc)
3085 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3086 java_accstring_lookup (acc));
3094 #line 791 "./parse.y"
3095 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3098 #line 794 "./parse.y"
3099 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3102 #line 797 "./parse.y"
3103 {yyerror ("Missing class name"); RECOVER;;
3106 #line 799 "./parse.y"
3107 {yyerror ("Missing class name"); RECOVER;;
3110 #line 801 "./parse.y"
3112 if (!ctxp->class_err) yyerror ("'{' expected");
3117 #line 806 "./parse.y"
3118 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3121 #line 810 "./parse.y"
3122 { yyval.node = NULL; ;
3125 #line 812 "./parse.y"
3126 { yyval.node = yyvsp[0].node; ;
3129 #line 814 "./parse.y"
3130 {yyerror ("'{' expected"); ctxp->class_err=1;;
3133 #line 816 "./parse.y"
3134 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3137 #line 820 "./parse.y"
3138 { yyval.node = NULL_TREE; ;
3141 #line 822 "./parse.y"
3142 { yyval.node = yyvsp[0].node; ;
3145 #line 824 "./parse.y"
3148 yyerror ("Missing interface name");
3152 #line 832 "./parse.y"
3154 ctxp->interface_number = 1;
3155 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3159 #line 837 "./parse.y"
3161 ctxp->interface_number++;
3162 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3166 #line 842 "./parse.y"
3167 {yyerror ("Missing interface name"); RECOVER;;
3170 #line 847 "./parse.y"
3172 /* Store the location of the `}' when doing xrefs */
3174 DECL_END_SOURCE_LINE (GET_CPC ()) =
3175 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3176 yyval.node = GET_CPC ();
3180 #line 855 "./parse.y"
3182 /* Store the location of the `}' when doing xrefs */
3184 DECL_END_SOURCE_LINE (GET_CPC ()) =
3185 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3186 yyval.node = GET_CPC ();
3190 #line 874 "./parse.y"
3192 TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3193 SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3197 #line 883 "./parse.y"
3198 { yyval.node = yyvsp[-1].node; ;
3201 #line 886 "./parse.y"
3202 { end_class_declaration (1); ;
3205 #line 888 "./parse.y"
3206 { end_class_declaration (1); ;
3209 #line 894 "./parse.y"
3210 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3213 #line 896 "./parse.y"
3216 ("Illegal modifier `%s' for field declaration",
3217 yyvsp[-3].value, FIELD_MODIFIERS);
3218 check_modifiers_consistency (yyvsp[-3].value);
3219 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3223 #line 909 "./parse.y"
3224 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3227 #line 911 "./parse.y"
3228 {yyerror ("Missing term"); RECOVER;;
3231 #line 916 "./parse.y"
3232 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3235 #line 918 "./parse.y"
3237 if (java_error_count)
3238 yyvsp[0].node = NULL_TREE;
3239 yyval.node = build_tree_list
3240 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3244 #line 925 "./parse.y"
3246 yyerror ("Missing variable initializer");
3247 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3252 #line 931 "./parse.y"
3254 yyerror ("';' expected");
3255 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3260 #line 941 "./parse.y"
3261 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3264 #line 943 "./parse.y"
3265 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3268 #line 945 "./parse.y"
3269 {yyerror ("']' expected"); DRECOVER(vdi);;
3272 #line 947 "./parse.y"
3273 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3276 #line 958 "./parse.y"
3278 current_function_decl = yyvsp[0].node;
3279 if (current_function_decl
3280 && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3281 source_start_java_method (current_function_decl);
3283 current_function_decl = NULL_TREE;
3287 #line 967 "./parse.y"
3288 { finish_method_declaration (yyvsp[0].node); ;
3291 #line 969 "./parse.y"
3292 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3295 #line 974 "./parse.y"
3296 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3299 #line 976 "./parse.y"
3300 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3303 #line 978 "./parse.y"
3304 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3307 #line 980 "./parse.y"
3308 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3311 #line 982 "./parse.y"
3313 yyerror ("Invalid method declaration, method name required");
3318 #line 987 "./parse.y"
3322 #line 989 "./parse.y"
3323 {yyerror ("Identifier expected"); RECOVER;;
3326 #line 991 "./parse.y"
3327 {yyerror ("Identifier expected"); RECOVER;;
3330 #line 993 "./parse.y"
3332 yyerror ("Invalid method declaration, return type required");
3337 #line 1001 "./parse.y"
3339 ctxp->formal_parameter_number = 0;
3340 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3344 #line 1006 "./parse.y"
3345 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3348 #line 1008 "./parse.y"
3350 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3351 TREE_PURPOSE (yyvsp[-2].node) =
3352 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3353 parse_warning_context
3355 "Discouraged form of returned type specification");
3359 #line 1017 "./parse.y"
3360 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3363 #line 1019 "./parse.y"
3364 {yyerror ("']' expected"); RECOVER;;
3367 #line 1024 "./parse.y"
3369 ctxp->formal_parameter_number = 1;
3373 #line 1028 "./parse.y"
3375 ctxp->formal_parameter_number += 1;
3376 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3380 #line 1033 "./parse.y"
3381 { yyerror ("Missing formal parameter term"); RECOVER; ;
3384 #line 1038 "./parse.y"
3386 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3390 #line 1042 "./parse.y"
3392 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3393 ARG_FINAL_P (yyval.node) = 1;
3397 #line 1047 "./parse.y"
3399 yyerror ("Missing identifier"); RECOVER;
3400 yyval.node = NULL_TREE;
3404 #line 1052 "./parse.y"
3406 yyerror ("Missing identifier"); RECOVER;
3407 yyval.node = NULL_TREE;
3411 #line 1060 "./parse.y"
3413 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3414 yyvsp[0].value, ACC_FINAL);
3415 if (yyvsp[0].value != ACC_FINAL)
3416 MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3420 #line 1069 "./parse.y"
3421 { yyval.node = NULL_TREE; ;
3424 #line 1071 "./parse.y"
3425 { yyval.node = yyvsp[0].node; ;
3428 #line 1073 "./parse.y"
3429 {yyerror ("Missing class type term"); RECOVER;;
3432 #line 1078 "./parse.y"
3433 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3436 #line 1080 "./parse.y"
3437 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3440 #line 1082 "./parse.y"
3441 {yyerror ("Missing class type term"); RECOVER;;
3444 #line 1089 "./parse.y"
3445 { yyval.node = NULL_TREE; ;
3448 #line 1095 "./parse.y"
3450 TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3451 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3455 #line 1100 "./parse.y"
3457 TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3458 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3462 #line 1108 "./parse.y"
3464 check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3465 /* Can't have a static initializer in an innerclass */
3466 if (yyvsp[0].value | ACC_STATIC &&
3467 GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3469 (MODIFIER_WFL (STATIC_TK),
3470 "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3471 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3472 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3476 #line 1124 "./parse.y"
3478 current_function_decl = yyvsp[0].node;
3479 source_start_java_method (current_function_decl);
3483 #line 1129 "./parse.y"
3484 { finish_method_declaration (yyvsp[0].node); ;
3487 #line 1134 "./parse.y"
3488 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3491 #line 1136 "./parse.y"
3492 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3495 #line 1141 "./parse.y"
3497 ctxp->formal_parameter_number = 0;
3498 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3502 #line 1146 "./parse.y"
3503 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3506 #line 1154 "./parse.y"
3508 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3509 yyval.node = yyvsp[0].node;
3513 #line 1159 "./parse.y"
3514 { yyval.node = yyvsp[0].node; ;
3517 #line 1161 "./parse.y"
3518 { yyval.node = yyvsp[0].node; ;
3521 #line 1163 "./parse.y"
3522 { yyval.node = yyvsp[0].node; ;
3525 #line 1173 "./parse.y"
3527 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3528 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3529 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3533 #line 1179 "./parse.y"
3535 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3536 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3537 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3541 #line 1187 "./parse.y"
3542 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3545 #line 1189 "./parse.y"
3546 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3549 #line 1194 "./parse.y"
3551 tree wfl = build_wfl_node (this_identifier_node);
3552 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3557 #line 1200 "./parse.y"
3559 tree wfl = build_wfl_node (super_identifier_node);
3560 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3565 #line 1211 "./parse.y"
3566 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3569 #line 1214 "./parse.y"
3570 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3573 #line 1217 "./parse.y"
3574 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3577 #line 1220 "./parse.y"
3578 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3581 #line 1223 "./parse.y"
3582 {yyerror ("'{' expected"); RECOVER;;
3585 #line 1225 "./parse.y"
3586 {yyerror ("'{' expected"); RECOVER;;
3589 #line 1230 "./parse.y"
3591 ctxp->interface_number = 1;
3592 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3596 #line 1235 "./parse.y"
3598 ctxp->interface_number++;
3599 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3603 #line 1240 "./parse.y"
3604 {yyerror ("Invalid interface type"); RECOVER;;
3607 #line 1242 "./parse.y"
3608 {yyerror ("Missing term"); RECOVER;;
3611 #line 1247 "./parse.y"
3612 { yyval.node = NULL_TREE; ;
3615 #line 1249 "./parse.y"
3616 { yyval.node = NULL_TREE; ;
3619 #line 1261 "./parse.y"
3620 { end_class_declaration (1); ;
3623 #line 1263 "./parse.y"
3624 { end_class_declaration (1); ;
3627 #line 1272 "./parse.y"
3629 check_abstract_method_header (yyvsp[-1].node);
3630 current_function_decl = NULL_TREE; /* FIXME ? */
3634 #line 1277 "./parse.y"
3635 {yyerror ("';' expected"); RECOVER;;
3638 #line 1283 "./parse.y"
3639 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3642 #line 1285 "./parse.y"
3643 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3646 #line 1287 "./parse.y"
3647 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3650 #line 1292 "./parse.y"
3652 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3653 yyvsp[0].node, NULL_TREE);
3657 #line 1297 "./parse.y"
3659 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3663 #line 1301 "./parse.y"
3664 {yyerror ("Missing term"); RECOVER;;
3667 #line 1307 "./parse.y"
3669 /* Store the location of the `}' when doing xrefs */
3670 if (current_function_decl && flag_emit_xref)
3671 DECL_END_SOURCE_LINE (current_function_decl) =
3672 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3673 yyval.node = empty_stmt_node;
3677 #line 1315 "./parse.y"
3678 { yyval.node = yyvsp[0].node; ;
3681 #line 1320 "./parse.y"
3685 #line 1325 "./parse.y"
3687 maybe_absorb_scoping_blocks ();
3688 /* Store the location of the `}' when doing xrefs */
3689 if (current_function_decl && flag_emit_xref)
3690 DECL_END_SOURCE_LINE (current_function_decl) =
3691 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3692 yyval.node = exit_block ();
3693 if (!BLOCK_SUBBLOCKS (yyval.node))
3694 BLOCK_SUBBLOCKS (yyval.node) = empty_stmt_node;
3698 #line 1345 "./parse.y"
3699 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3702 #line 1347 "./parse.y"
3704 LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3705 end_class_declaration (1);
3709 #line 1359 "./parse.y"
3710 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3713 #line 1361 "./parse.y"
3714 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3717 #line 1371 "./parse.y"
3718 { yyval.node = exit_block (); ;
3721 #line 1380 "./parse.y"
3722 { yyval.node = exit_block (); ;
3725 #line 1399 "./parse.y"
3726 { yyval.node = empty_stmt_node; ;
3729 #line 1404 "./parse.y"
3731 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3732 EXPR_WFL_NODE (yyvsp[-1].node));
3734 push_labeled_block (yyval.node);
3735 PUSH_LABELED_BLOCK (yyval.node);
3739 #line 1415 "./parse.y"
3740 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3743 #line 1417 "./parse.y"
3744 {yyerror ("':' expected"); RECOVER;;
3747 #line 1422 "./parse.y"
3748 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3751 #line 1429 "./parse.y"
3753 /* We have a statement. Generate a WFL around it so
3755 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3756 /* We know we have a statement, so set the debug
3757 info to be eventually generate here. */
3758 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3762 #line 1438 "./parse.y"
3764 if (ctxp->prevent_ese != lineno)
3765 yyerror ("Invalid expression statement");
3766 DRECOVER (expr_stmt);
3770 #line 1444 "./parse.y"
3772 if (ctxp->prevent_ese != lineno)
3773 yyerror ("Invalid expression statement");
3774 DRECOVER (expr_stmt);
3778 #line 1450 "./parse.y"
3780 if (ctxp->prevent_ese != lineno)
3781 yyerror ("Invalid expression statement");
3782 DRECOVER (expr_stmt);
3786 #line 1456 "./parse.y"
3787 {yyerror ("')' expected"); RECOVER;;
3790 #line 1458 "./parse.y"
3792 parse_ctor_invocation_error ();
3797 #line 1463 "./parse.y"
3798 {yyerror ("')' expected"); RECOVER;;
3801 #line 1465 "./parse.y"
3803 parse_ctor_invocation_error ();
3808 #line 1470 "./parse.y"
3809 {yyerror ("'(' expected"); RECOVER;;
3812 #line 1472 "./parse.y"
3813 {yyerror ("')' expected"); RECOVER;;
3816 #line 1474 "./parse.y"
3817 {yyerror ("')' expected"); RECOVER;;
3820 #line 1476 "./parse.y"
3821 {yyerror ("';' expected"); RECOVER;;
3824 #line 1478 "./parse.y"
3825 {yyerror ("';' expected"); RECOVER;;
3828 #line 1493 "./parse.y"
3830 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
3831 yyvsp[0].node, NULL_TREE);
3835 #line 1498 "./parse.y"
3836 {yyerror ("'(' expected"); RECOVER;;
3839 #line 1500 "./parse.y"
3840 {yyerror ("Missing term"); RECOVER;;
3843 #line 1502 "./parse.y"
3844 {yyerror ("')' expected"); RECOVER;;
3847 #line 1507 "./parse.y"
3848 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3851 #line 1512 "./parse.y"
3852 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3855 #line 1517 "./parse.y"
3861 #line 1521 "./parse.y"
3863 /* Make into "proper list" of COMPOUND_EXPRs.
3864 I.e. make the last statment also have its own
3866 maybe_absorb_scoping_blocks ();
3867 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3868 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3872 #line 1533 "./parse.y"
3874 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3875 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3879 #line 1538 "./parse.y"
3880 {yyerror ("'(' expected"); RECOVER;;
3883 #line 1540 "./parse.y"
3884 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3887 #line 1542 "./parse.y"
3888 {yyerror ("'{' expected"); RECOVER;;
3891 #line 1550 "./parse.y"
3892 { yyval.node = NULL_TREE; ;
3895 #line 1552 "./parse.y"
3896 { yyval.node = NULL_TREE; ;
3899 #line 1554 "./parse.y"
3900 { yyval.node = NULL_TREE; ;
3903 #line 1556 "./parse.y"
3904 { yyval.node = NULL_TREE; ;
3907 #line 1575 "./parse.y"
3909 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3910 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3911 java_method_add_stmt (current_function_decl, lab);
3915 #line 1581 "./parse.y"
3917 tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3918 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3919 java_method_add_stmt (current_function_decl, lab);
3923 #line 1587 "./parse.y"
3924 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3927 #line 1589 "./parse.y"
3928 {yyerror ("':' expected"); RECOVER;;
3931 #line 1591 "./parse.y"
3932 {yyerror ("':' expected"); RECOVER;;
3935 #line 1596 "./parse.y"
3937 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3938 yyval.node = build_new_loop (body);
3942 #line 1604 "./parse.y"
3943 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3946 #line 1606 "./parse.y"
3947 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3950 #line 1608 "./parse.y"
3951 {yyerror ("Missing term and ')' expected"); RECOVER;;
3954 #line 1610 "./parse.y"
3955 {yyerror ("')' expected"); RECOVER;;
3958 #line 1615 "./parse.y"
3959 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3962 #line 1620 "./parse.y"
3964 tree body = build_loop_body (0, NULL_TREE, 1);
3965 yyval.node = build_new_loop (body);
3969 #line 1629 "./parse.y"
3970 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3973 #line 1634 "./parse.y"
3974 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3977 #line 1636 "./parse.y"
3979 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3980 /* We have not condition, so we get rid of the EXIT_EXPR */
3981 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3986 #line 1643 "./parse.y"
3987 {yyerror ("Invalid control expression"); RECOVER;;
3990 #line 1645 "./parse.y"
3991 {yyerror ("Invalid update expression"); RECOVER;;
3994 #line 1647 "./parse.y"
3995 {yyerror ("Invalid update expression"); RECOVER;;
3998 #line 1652 "./parse.y"
3999 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
4002 #line 1654 "./parse.y"
4004 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4005 /* We have not condition, so we get rid of the EXIT_EXPR */
4006 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
4011 #line 1664 "./parse.y"
4013 /* This scope defined for local variable that may be
4014 defined within the scope of the for loop */
4019 #line 1670 "./parse.y"
4020 {yyerror ("'(' expected"); DRECOVER(for_1);;
4023 #line 1672 "./parse.y"
4024 {yyerror ("Invalid init statement"); RECOVER;;
4027 #line 1677 "./parse.y"
4029 /* We now declare the loop body. The loop is
4030 declared as a for loop. */
4031 tree body = build_loop_body (0, NULL_TREE, 0);
4032 yyval.node = build_new_loop (body);
4033 FOR_LOOP_P (yyval.node) = 1;
4034 /* The loop is added to the current block the for
4035 statement is defined within */
4036 java_method_add_stmt (current_function_decl, yyval.node);
4040 #line 1689 "./parse.y"
4041 { yyval.node = empty_stmt_node; ;
4044 #line 1691 "./parse.y"
4046 /* Init statement recorded within the previously
4047 defined block scope */
4048 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4052 #line 1697 "./parse.y"
4054 /* Local variable are recorded within the previously
4055 defined block scope */
4056 yyval.node = NULL_TREE;
4060 #line 1703 "./parse.y"
4061 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4064 #line 1707 "./parse.y"
4065 {yyval.node = empty_stmt_node;;
4068 #line 1709 "./parse.y"
4069 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4072 #line 1714 "./parse.y"
4073 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4076 #line 1716 "./parse.y"
4077 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4080 #line 1718 "./parse.y"
4081 {yyerror ("Missing term"); RECOVER;;
4084 #line 1723 "./parse.y"
4085 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4088 #line 1725 "./parse.y"
4089 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4092 #line 1727 "./parse.y"
4093 {yyerror ("Missing term"); RECOVER;;
4096 #line 1729 "./parse.y"
4097 {yyerror ("';' expected"); RECOVER;;
4100 #line 1734 "./parse.y"
4101 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4104 #line 1736 "./parse.y"
4105 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4108 #line 1738 "./parse.y"
4109 {yyerror ("Missing term"); RECOVER;;
4112 #line 1740 "./parse.y"
4113 {yyerror ("';' expected"); RECOVER;;
4116 #line 1745 "./parse.y"
4117 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4120 #line 1747 "./parse.y"
4121 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4124 #line 1749 "./parse.y"
4125 {yyerror ("Missing term"); RECOVER;;
4128 #line 1751 "./parse.y"
4129 {yyerror ("';' expected"); RECOVER;;
4132 #line 1756 "./parse.y"
4134 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4135 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4139 #line 1761 "./parse.y"
4140 {yyerror ("Missing term"); RECOVER;;
4143 #line 1763 "./parse.y"
4144 {yyerror ("';' expected"); RECOVER;;
4147 #line 1768 "./parse.y"
4149 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4150 EXPR_WFL_LINECOL (yyval.node) =
4151 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4155 #line 1774 "./parse.y"
4156 {yyerror ("'{' expected"); RECOVER;;
4159 #line 1776 "./parse.y"
4160 {yyerror ("'(' expected"); RECOVER;;
4163 #line 1778 "./parse.y"
4164 {yyerror ("Missing term"); RECOVER;;
4167 #line 1780 "./parse.y"
4168 {yyerror ("Missing term"); RECOVER;;
4171 #line 1785 "./parse.y"
4174 "Illegal modifier `%s'. Only `synchronized' was expected here",
4175 yyvsp[0].value, ACC_SYNCHRONIZED);
4176 if (yyvsp[0].value != ACC_SYNCHRONIZED)
4177 MODIFIER_WFL (SYNCHRONIZED_TK) =
4178 build_wfl_node (NULL_TREE);
4182 #line 1797 "./parse.y"
4183 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4186 #line 1799 "./parse.y"
4187 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4190 #line 1801 "./parse.y"
4191 { yyval.node = build_try_finally_statement
4192 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4193 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4197 #line 1806 "./parse.y"
4198 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4201 #line 1812 "./parse.y"
4203 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4204 yyval.node = yyvsp[0].node;
4208 #line 1820 "./parse.y"
4210 java_method_add_stmt (current_function_decl, yyvsp[0].node);
4212 yyval.node = yyvsp[-1].node;
4216 #line 1828 "./parse.y"
4218 /* We add a block to define a scope for
4219 formal_parameter (CCBP). The formal parameter is
4220 declared initialized by the appropriate function
4222 tree ccpb = enter_block ();
4223 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
4224 TREE_PURPOSE (yyvsp[-1].node),
4225 soft_exceptioninfo_call_node);
4226 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4227 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4229 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4230 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4234 #line 1844 "./parse.y"
4235 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4238 #line 1846 "./parse.y"
4240 yyerror ("Missing term or ')' expected");
4241 RECOVER; yyval.node = NULL_TREE;
4245 #line 1851 "./parse.y"
4246 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4249 #line 1856 "./parse.y"
4250 { yyval.node = yyvsp[0].node; ;
4253 #line 1858 "./parse.y"
4254 {yyerror ("'{' expected"); RECOVER; ;
4257 #line 1870 "./parse.y"
4258 { yyval.node = build_this (yyvsp[0].operator.location); ;
4261 #line 1872 "./parse.y"
4262 {yyval.node = yyvsp[-1].node;;
4265 #line 1882 "./parse.y"
4267 tree wfl = build_wfl_node (this_identifier_node);
4268 yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4272 #line 1887 "./parse.y"
4273 {yyerror ("')' expected"); RECOVER;;
4276 #line 1889 "./parse.y"
4277 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4280 #line 1891 "./parse.y"
4281 {yyerror ("'class' expected" ); RECOVER;;
4284 #line 1893 "./parse.y"
4285 {yyerror ("'class' expected" ); RECOVER;;
4288 #line 1901 "./parse.y"
4290 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4291 CLASS_LOADED_P (yyval.node) = 1;
4295 #line 1906 "./parse.y"
4296 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4299 #line 1916 "./parse.y"
4300 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4303 #line 1918 "./parse.y"
4304 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4307 #line 1920 "./parse.y"
4308 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4311 #line 1922 "./parse.y"
4312 { yyval.node = build_class_ref (void_type_node); ;
4315 #line 1927 "./parse.y"
4316 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4319 #line 1929 "./parse.y"
4320 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4323 #line 1935 "./parse.y"
4325 tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4326 yyval.node = make_qualified_primary (yyvsp[-3].node, ctor,
4327 EXPR_WFL_LINECOL (yyvsp[-3].node));
4331 #line 1942 "./parse.y"
4333 tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4334 yyval.node = make_qualified_primary (yyvsp[-4].node, ctor,
4335 EXPR_WFL_LINECOL (yyvsp[-4].node));
4339 #line 1949 "./parse.y"
4340 {yyerror ("'(' expected"); DRECOVER(new_1);;
4343 #line 1951 "./parse.y"
4344 {yyerror ("'(' expected"); RECOVER;;
4347 #line 1953 "./parse.y"
4348 {yyerror ("')' or term expected"); RECOVER;;
4351 #line 1955 "./parse.y"
4352 {yyerror ("')' expected"); RECOVER;;
4355 #line 1957 "./parse.y"
4356 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4359 #line 1959 "./parse.y"
4360 {yyerror ("'(' expected"); RECOVER;;
4363 #line 1969 "./parse.y"
4364 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4367 #line 1971 "./parse.y"
4369 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4370 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4372 end_class_declaration (1);
4374 /* Now we can craft the new expression */
4375 yyval.node = build_new_invocation (id, yyvsp[-3].node);
4377 /* Note that we can't possibly be here if
4378 `class_type' is an interface (in which case the
4379 anonymous class extends Object and implements
4380 `class_type', hence its constructor can't have
4383 /* Otherwise, the innerclass must feature a
4384 constructor matching `argument_list'. Anonymous
4385 classes are a bit special: it's impossible to
4386 define constructor for them, hence constructors
4387 must be generated following the hints provided by
4388 the `new' expression. Whether a super constructor
4389 of that nature exists or not is to be verified
4390 later on in verify_constructor_super.
4392 It's during the expansion of a `new' statement
4393 refering to an anonymous class that a ctor will
4394 be generated for the anonymous class, with the
4400 #line 2002 "./parse.y"
4401 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4404 #line 2004 "./parse.y"
4406 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4407 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4409 end_class_declaration (1);
4411 /* Now we can craft the new expression. The
4412 statement doesn't need to be remember so that a
4413 constructor can be generated, since its signature
4414 is already known. */
4415 yyval.node = build_new_invocation (id, NULL_TREE);
4419 #line 2020 "./parse.y"
4420 { yyval.node = yyvsp[-2].node; ;
4423 #line 2022 "./parse.y"
4424 { yyval.node = yyvsp[-2].node; ;
4427 #line 2027 "./parse.y"
4429 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4430 ctxp->formal_parameter_number = 1;
4434 #line 2032 "./parse.y"
4436 ctxp->formal_parameter_number += 1;
4437 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4441 #line 2037 "./parse.y"
4442 {yyerror ("Missing term"); RECOVER;;
4445 #line 2042 "./parse.y"
4446 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4449 #line 2044 "./parse.y"
4450 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4453 #line 2046 "./parse.y"
4454 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4457 #line 2048 "./parse.y"
4458 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4461 #line 2052 "./parse.y"
4464 while (CURRENT_OSB (ctxp)--)
4465 obstack_1grow (&temporary_obstack, '[');
4466 sig = obstack_finish (&temporary_obstack);
4467 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4468 yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4472 #line 2061 "./parse.y"
4474 tree type = yyvsp[-2].node;
4475 while (CURRENT_OSB (ctxp)--)
4476 type = build_java_array_type (type, -1);
4477 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4478 build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4482 #line 2069 "./parse.y"
4483 {yyerror ("'[' expected"); DRECOVER ("]");;
4486 #line 2071 "./parse.y"
4487 {yyerror ("']' expected"); RECOVER;;
4490 #line 2076 "./parse.y"
4491 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4494 #line 2078 "./parse.y"
4495 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4498 #line 2083 "./parse.y"
4500 if (JNUMERIC_TYPE_P (TREE_TYPE (yyvsp[-1].node)))
4502 yyvsp[-1].node = build_wfl_node (yyvsp[-1].node);
4503 TREE_TYPE (yyvsp[-1].node) = NULL_TREE;
4505 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4506 yyval.node = yyvsp[-1].node;
4510 #line 2093 "./parse.y"
4511 {yyerror ("']' expected"); RECOVER;;
4514 #line 2095 "./parse.y"
4516 yyerror ("Missing term");
4517 yyerror ("']' expected");
4522 #line 2104 "./parse.y"
4525 /* If not initialized, allocate memory for the osb
4527 if (!ctxp->osb_limit)
4529 allocate = ctxp->osb_limit = 32;
4530 ctxp->osb_depth = -1;
4532 /* If capacity overflown, reallocate a bigger chunk */
4533 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4534 allocate = ctxp->osb_limit << 1;
4538 allocate *= sizeof (int);
4539 if (ctxp->osb_number)
4540 ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4543 ctxp->osb_number = (int *)xmalloc (allocate);
4546 CURRENT_OSB (ctxp) = 1;
4550 #line 2130 "./parse.y"
4551 { CURRENT_OSB (ctxp)++; ;
4554 #line 2132 "./parse.y"
4555 { yyerror ("']' expected"); RECOVER;;
4558 #line 2137 "./parse.y"
4559 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4562 #line 2141 "./parse.y"
4565 build_wfl_node (super_identifier_node);
4566 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4567 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4571 #line 2148 "./parse.y"
4572 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4575 #line 2153 "./parse.y"
4576 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4579 #line 2155 "./parse.y"
4580 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4583 #line 2157 "./parse.y"
4585 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4586 yyval.node = build_this_super_qualified_invocation
4587 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4590 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4591 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4596 #line 2168 "./parse.y"
4598 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4599 yyval.node = build_this_super_qualified_invocation
4600 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4603 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4604 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4609 #line 2179 "./parse.y"
4611 yyval.node = build_this_super_qualified_invocation
4612 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4616 #line 2184 "./parse.y"
4618 yyval.node = build_this_super_qualified_invocation
4619 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4623 #line 2193 "./parse.y"
4624 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4627 #line 2195 "./parse.y"
4628 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4631 #line 2200 "./parse.y"
4632 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4635 #line 2202 "./parse.y"
4636 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4639 #line 2204 "./parse.y"
4641 yyerror ("Missing term and ']' expected");
4642 DRECOVER(array_access);
4646 #line 2209 "./parse.y"
4648 yyerror ("']' expected");
4649 DRECOVER(array_access);
4653 #line 2214 "./parse.y"
4655 yyerror ("Missing term and ']' expected");
4656 DRECOVER(array_access);
4660 #line 2219 "./parse.y"
4662 yyerror ("']' expected");
4663 DRECOVER(array_access);
4667 #line 2234 "./parse.y"
4668 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4671 #line 2239 "./parse.y"
4672 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4675 #line 2246 "./parse.y"
4676 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4679 #line 2248 "./parse.y"
4680 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4683 #line 2251 "./parse.y"
4684 {yyerror ("Missing term"); RECOVER;
4687 #line 2253 "./parse.y"
4688 {yyerror ("Missing term"); RECOVER;
4691 #line 2258 "./parse.y"
4692 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4695 #line 2260 "./parse.y"
4696 {yyerror ("Missing term"); RECOVER;
4699 #line 2265 "./parse.y"
4700 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4703 #line 2267 "./parse.y"
4704 {yyerror ("Missing term"); RECOVER;
4707 #line 2273 "./parse.y"
4708 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4711 #line 2275 "./parse.y"
4712 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4715 #line 2278 "./parse.y"
4716 {yyerror ("Missing term"); RECOVER;
4719 #line 2280 "./parse.y"
4720 {yyerror ("Missing term"); RECOVER;
4723 #line 2285 "./parse.y"
4725 tree type = yyvsp[-3].node;
4726 while (CURRENT_OSB (ctxp)--)
4727 type = build_java_array_type (type, -1);
4729 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4733 #line 2293 "./parse.y"
4734 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4737 #line 2295 "./parse.y"
4738 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4741 #line 2297 "./parse.y"
4744 while (CURRENT_OSB (ctxp)--)
4745 obstack_1grow (&temporary_obstack, '[');
4747 obstack_grow0 (&temporary_obstack,
4748 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4749 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4750 ptr = obstack_finish (&temporary_obstack);
4751 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4752 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4756 #line 2310 "./parse.y"
4757 {yyerror ("']' expected, invalid type expression");;
4760 #line 2312 "./parse.y"
4762 if (ctxp->prevent_ese != lineno)
4763 yyerror ("Invalid type expression"); RECOVER;
4768 #line 2318 "./parse.y"
4769 {yyerror ("Missing term"); RECOVER;;
4772 #line 2320 "./parse.y"
4773 {yyerror ("Missing term"); RECOVER;;
4776 #line 2322 "./parse.y"
4777 {yyerror ("Missing term"); RECOVER;;
4780 #line 2328 "./parse.y"
4782 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4783 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4787 #line 2333 "./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 2338 "./parse.y"
4796 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4797 yyvsp[-2].node, yyvsp[0].node);
4801 #line 2343 "./parse.y"
4802 {yyerror ("Missing term"); RECOVER;;
4805 #line 2345 "./parse.y"
4806 {yyerror ("Missing term"); RECOVER;;
4809 #line 2347 "./parse.y"
4810 {yyerror ("Missing term"); RECOVER;;
4813 #line 2353 "./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 2358 "./parse.y"
4822 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4823 yyvsp[-2].node, yyvsp[0].node);
4827 #line 2363 "./parse.y"
4828 {yyerror ("Missing term"); RECOVER;;
4831 #line 2365 "./parse.y"
4832 {yyerror ("Missing term"); RECOVER;;
4835 #line 2371 "./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 2376 "./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 2381 "./parse.y"
4851 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4852 yyvsp[-2].node, yyvsp[0].node);
4856 #line 2386 "./parse.y"
4857 {yyerror ("Missing term"); RECOVER;;
4860 #line 2388 "./parse.y"
4861 {yyerror ("Missing term"); RECOVER;;
4864 #line 2390 "./parse.y"
4865 {yyerror ("Missing term"); RECOVER;;
4868 #line 2396 "./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 2401 "./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 2406 "./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 2411 "./parse.y"
4891 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4892 yyvsp[-2].node, yyvsp[0].node);
4896 #line 2416 "./parse.y"
4897 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4900 #line 2418 "./parse.y"
4901 {yyerror ("Missing term"); RECOVER;;
4904 #line 2420 "./parse.y"
4905 {yyerror ("Missing term"); RECOVER;;
4908 #line 2422 "./parse.y"
4909 {yyerror ("Missing term"); RECOVER;;
4912 #line 2424 "./parse.y"
4913 {yyerror ("Missing term"); RECOVER;;
4916 #line 2426 "./parse.y"
4917 {yyerror ("Invalid reference type"); RECOVER;;
4920 #line 2432 "./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 2437 "./parse.y"
4929 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4930 yyvsp[-2].node, yyvsp[0].node);
4934 #line 2442 "./parse.y"
4935 {yyerror ("Missing term"); RECOVER;;
4938 #line 2444 "./parse.y"
4939 {yyerror ("Missing term"); RECOVER;;
4942 #line 2450 "./parse.y"
4944 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4945 yyvsp[-2].node, yyvsp[0].node);
4949 #line 2455 "./parse.y"
4950 {yyerror ("Missing term"); RECOVER;;
4953 #line 2461 "./parse.y"
4955 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4956 yyvsp[-2].node, yyvsp[0].node);
4960 #line 2466 "./parse.y"
4961 {yyerror ("Missing term"); RECOVER;;
4964 #line 2472 "./parse.y"
4966 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4967 yyvsp[-2].node, yyvsp[0].node);
4971 #line 2477 "./parse.y"
4972 {yyerror ("Missing term"); RECOVER;;
4975 #line 2483 "./parse.y"
4977 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4978 yyvsp[-2].node, yyvsp[0].node);
4982 #line 2488 "./parse.y"
4983 {yyerror ("Missing term"); RECOVER;;
4986 #line 2494 "./parse.y"
4988 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4989 yyvsp[-2].node, yyvsp[0].node);
4993 #line 2499 "./parse.y"
4994 {yyerror ("Missing term"); RECOVER;;
4997 #line 2505 "./parse.y"
4999 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
5000 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
5004 #line 2510 "./parse.y"
5007 yyerror ("Missing term");
5012 #line 2516 "./parse.y"
5013 {yyerror ("Missing term"); DRECOVER (2);;
5016 #line 2518 "./parse.y"
5017 {yyerror ("Missing term"); DRECOVER (3);;
5020 #line 2528 "./parse.y"
5021 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5024 #line 2530 "./parse.y"
5026 if (ctxp->prevent_ese != lineno)
5027 yyerror ("Missing term");
5032 /* the action file gets copied in in place of this dollarsign */
5033 #line 543 "/usr/lib/bison.simple"
5044 short *ssp1 = yyss - 1;
5045 fprintf (stderr, "state stack now");
5046 while (ssp1 != yyssp)
5047 fprintf (stderr, " %d", *++ssp1);
5048 fprintf (stderr, "\n");
5058 yylsp->first_line = yylloc.first_line;
5059 yylsp->first_column = yylloc.first_column;
5060 yylsp->last_line = (yylsp-1)->last_line;
5061 yylsp->last_column = (yylsp-1)->last_column;
5066 yylsp->last_line = (yylsp+yylen-1)->last_line;
5067 yylsp->last_column = (yylsp+yylen-1)->last_column;
5071 /* Now "shift" the result of the reduction.
5072 Determine what state that goes to,
5073 based on the state we popped back to
5074 and the rule number reduced by. */
5078 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5079 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5080 yystate = yytable[yystate];
5082 yystate = yydefgoto[yyn - YYNTBASE];
5086 yyerrlab: /* here on detecting error */
5089 /* If not already recovering from an error, report this error. */
5093 #ifdef YYERROR_VERBOSE
5094 yyn = yypact[yystate];
5096 if (yyn > YYFLAG && yyn < YYLAST)
5103 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5104 for (x = (yyn < 0 ? -yyn : 0);
5105 x < (sizeof(yytname) / sizeof(char *)); x++)
5106 if (yycheck[x + yyn] == x)
5107 size += strlen(yytname[x]) + 15, count++;
5108 msg = (char *) malloc(size + 15);
5111 strcpy(msg, "parse error");
5116 for (x = (yyn < 0 ? -yyn : 0);
5117 x < (sizeof(yytname) / sizeof(char *)); x++)
5118 if (yycheck[x + yyn] == x)
5120 strcat(msg, count == 0 ? ", expecting `" : " or `");
5121 strcat(msg, yytname[x]);
5130 yyerror ("parse error; also virtual memory exceeded");
5133 #endif /* YYERROR_VERBOSE */
5134 yyerror("parse error");
5138 yyerrlab1: /* here on error raised explicitly by an action */
5140 if (yyerrstatus == 3)
5142 /* if just tried and failed to reuse lookahead token after an error, discard it. */
5144 /* return failure if at end of input */
5145 if (yychar == YYEOF)
5150 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5156 /* Else will try to reuse lookahead token
5157 after shifting the error token. */
5159 yyerrstatus = 3; /* Each real token shifted decrements this */
5163 yyerrdefault: /* current state does not do anything special for the error token. */
5166 /* This is wrong; only states that explicitly want error tokens
5167 should shift them. */
5168 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5169 if (yyn) goto yydefault;
5172 yyerrpop: /* pop the current state because it cannot handle the error token */
5174 if (yyssp == yyss) YYABORT;
5184 short *ssp1 = yyss - 1;
5185 fprintf (stderr, "Error: state stack now");
5186 while (ssp1 != yyssp)
5187 fprintf (stderr, " %d", *++ssp1);
5188 fprintf (stderr, "\n");
5194 yyn = yypact[yystate];
5199 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5218 fprintf(stderr, "Shifting error token, ");
5230 /* YYACCEPT comes here. */
5242 /* YYABORT comes here. */
5253 #line 2556 "./parse.y"
5257 /* This section of the code deal with save/restoring parser contexts.
5258 Add mode documentation here. FIXME */
5260 /* Helper function. Create a new parser context. With
5261 COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5262 context is copied, otherwise, the new context is zeroed. The newly
5263 created context becomes the current one. */
5266 create_new_parser_context (copy_from_previous)
5267 int copy_from_previous;
5269 struct parser_ctxt *new;
5271 new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5272 if (copy_from_previous)
5274 memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5275 new->saved_data_ctx = 1;
5278 bzero ((PTR) new, sizeof (struct parser_ctxt));
5284 /* Create a new parser context and make it the current one. */
5287 java_push_parser_context ()
5289 create_new_parser_context (0);
5292 ctxp->incomplete_class = ctxp->next->incomplete_class;
5293 ctxp->gclass_list = ctxp->next->gclass_list;
5298 java_pop_parser_context (generate)
5302 struct parser_ctxt *toFree, *next;
5311 next->incomplete_class = ctxp->incomplete_class;
5312 next->gclass_list = ctxp->gclass_list;
5313 lineno = ctxp->lineno;
5314 finput = ctxp->finput;
5315 current_class = ctxp->current_class;
5318 /* Set the single import class file flag to 0 for the current list
5319 of imported things */
5320 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5321 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5323 /* And restore those of the previous context */
5324 if ((ctxp = next)) /* Assignment is really meant here */
5325 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5326 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5328 /* If we pushed a context to parse a class intended to be generated,
5329 we keep it so we can remember the class. What we could actually
5330 do is to just update a list of class names. */
5333 toFree->next = ctxp_for_generation;
5334 ctxp_for_generation = toFree;
5340 /* Create a parser context for the use of saving some global
5344 java_parser_context_save_global ()
5348 java_push_parser_context ();
5349 ctxp->saved_data_ctx = 1;
5352 /* If this context already stores data, create a new one suitable
5353 for data storage. */
5354 else if (ctxp->saved_data)
5355 create_new_parser_context (1);
5357 ctxp->finput = finput;
5358 ctxp->lineno = lineno;
5359 ctxp->current_class = current_class;
5360 ctxp->filename = input_filename;
5361 ctxp->current_function_decl = current_function_decl;
5362 ctxp->saved_data = 1;
5365 /* Restore some global variables from the previous context. Make the
5366 previous context the current one. */
5369 java_parser_context_restore_global ()
5371 finput = ctxp->finput;
5372 lineno = ctxp->lineno;
5373 current_class = ctxp->current_class;
5374 input_filename = ctxp->filename;
5375 current_function_decl = ctxp->current_function_decl;
5376 ctxp->saved_data = 0;
5377 if (ctxp->saved_data_ctx)
5378 java_pop_parser_context (0);
5381 /* Suspend vital data for the current class/function being parsed so
5382 that an other class can be parsed. Used to let local/anonymous
5383 classes be parsed. */
5386 java_parser_context_suspend ()
5388 /* This makes debugging through java_debug_context easier */
5389 static const char *name = "<inner buffer context>";
5391 /* Duplicate the previous context, use it to save the globals we're
5393 create_new_parser_context (1);
5394 ctxp->current_function_decl = current_function_decl;
5395 ctxp->current_class = current_class;
5397 /* Then create a new context which inherits all data from the
5398 previous one. This will be the new current context */
5399 create_new_parser_context (1);
5401 /* Help debugging */
5402 ctxp->next->filename = name;
5405 /* Resume vital data for the current class/function being parsed so
5406 that an other class can be parsed. Used to let local/anonymous
5407 classes be parsed. The trick is the data storing file position
5408 informations must be restored to their current value, so parsing
5409 can resume as if no context was ever saved. */
5412 java_parser_context_resume ()
5414 struct parser_ctxt *old = ctxp; /* This one is to be discarded */
5415 struct parser_ctxt *saver = old->next; /* This one contain saved info */
5416 struct parser_ctxt *restored = saver->next; /* This one is the old current */
5418 /* We need to inherit the list of classes to complete/generate */
5419 restored->incomplete_class = old->incomplete_class;
5420 restored->gclass_list = old->gclass_list;
5421 restored->classd_list = old->classd_list;
5422 restored->class_list = old->class_list;
5424 /* Restore the current class and function from the saver */
5425 current_class = saver->current_class;
5426 current_function_decl = saver->current_function_decl;
5428 /* Retrive the restored context */
5431 /* Re-installed the data for the parsing to carry on */
5432 bcopy (&old->marker_begining, &ctxp->marker_begining,
5433 (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5435 /* Buffer context can now be discarded */
5440 /* Add a new anchor node to which all statement(s) initializing static
5441 and non static initialized upon declaration field(s) will be
5445 java_parser_context_push_initialized_field ()
5449 node = build_tree_list (NULL_TREE, NULL_TREE);
5450 TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5451 CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5453 node = build_tree_list (NULL_TREE, NULL_TREE);
5454 TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5455 CPC_INITIALIZER_LIST (ctxp) = node;
5457 node = build_tree_list (NULL_TREE, NULL_TREE);
5458 TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5459 CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5462 /* Pop the lists of initialized field. If this lists aren't empty,
5463 remember them so we can use it to create and populate the $finit$
5464 or <clinit> functions. */
5467 java_parser_context_pop_initialized_field ()
5470 tree class_type = TREE_TYPE (GET_CPC ());
5472 if (CPC_INITIALIZER_LIST (ctxp))
5474 stmts = CPC_INITIALIZER_STMT (ctxp);
5475 CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5476 if (stmts && !java_error_count)
5477 TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5480 if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5482 stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5483 CPC_STATIC_INITIALIZER_LIST (ctxp) =
5484 TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5485 /* Keep initialization in order to enforce 8.5 */
5486 if (stmts && !java_error_count)
5487 TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5490 /* JDK 1.1 instance initializers */
5491 if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5493 stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5494 CPC_INSTANCE_INITIALIZER_LIST (ctxp) =
5495 TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5496 if (stmts && !java_error_count)
5497 TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5502 reorder_static_initialized (list)
5505 /* We have to keep things in order. The alias initializer have to
5506 come first, then the initialized regular field, in reverse to
5507 keep them in lexical order. */
5508 tree marker, previous = NULL_TREE;
5509 for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5510 if (TREE_CODE (marker) == TREE_LIST
5511 && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5514 /* No static initialized, the list is fine as is */
5516 list = TREE_CHAIN (marker);
5518 /* No marker? reverse the whole list */
5520 list = nreverse (list);
5522 /* Otherwise, reverse what's after the marker and the new reordered
5523 sublist will replace the marker. */
5526 TREE_CHAIN (previous) = NULL_TREE;
5527 list = nreverse (list);
5528 list = chainon (TREE_CHAIN (marker), list);
5533 /* Helper functions to dump the parser context stack. */
5535 #define TAB_CONTEXT(C) \
5536 {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5539 java_debug_context_do (tab)
5542 struct parser_ctxt *copy = ctxp;
5546 fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5548 fprintf (stderr, "filename: %s\n", copy->filename);
5550 fprintf (stderr, "lineno: %d\n", copy->lineno);
5552 fprintf (stderr, "package: %s\n",
5554 IDENTIFIER_POINTER (copy->package) : "<none>"));
5556 fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5558 fprintf (stderr, "saved data: %d\n", copy->saved_data);
5564 /* Dump the stacked up parser contexts. Intended to be called from a
5568 java_debug_context ()
5570 java_debug_context_do (0);
5575 /* Flag for the error report routine to issue the error the first time
5576 it's called (overriding the default behavior which is to drop the
5577 first invocation and honor the second one, taking advantage of a
5579 static int force_error = 0;
5581 /* Reporting an constructor invocation error. */
5583 parse_ctor_invocation_error ()
5585 if (DECL_CONSTRUCTOR_P (current_function_decl))
5586 yyerror ("Constructor invocation must be first thing in a constructor");
5588 yyerror ("Only constructors can invoke constructors");
5591 /* Reporting JDK1.1 features not implemented. */
5594 parse_jdk1_1_error (msg)
5597 sorry (": `%s' JDK1.1(TM) feature", msg);
5599 return empty_stmt_node;
5602 static int do_warning = 0;
5609 static int prev_lineno;
5610 static const char *prev_msg;
5613 char *remainder, *code_from_source;
5614 extern struct obstack temporary_obstack;
5616 if (!force_error && prev_lineno == lineno)
5619 /* Save current error location but report latter, when the context is
5621 if (ctxp->java_error_flag == 0)
5623 ctxp->java_error_flag = 1;
5625 /* Do something to use the previous line if we're reaching the
5626 end of the file... */
5627 #ifdef VERBOSE_SKELETON
5628 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5633 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5634 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5637 ctxp->java_error_flag = 0;
5639 java_warning_count++;
5643 if (elc.col == 0 && msg && msg[1] == ';')
5645 elc.col = ctxp->p_line->char_col-1;
5646 elc.line = ctxp->p_line->lineno;
5649 save_lineno = lineno;
5650 prev_lineno = lineno = elc.line;
5653 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5654 obstack_grow0 (&temporary_obstack,
5655 code_from_source, strlen (code_from_source));
5656 remainder = obstack_finish (&temporary_obstack);
5658 warning ("%s.\n%s", msg, remainder);
5660 error ("%s.\n%s", msg, remainder);
5662 /* This allow us to cheaply avoid an extra 'Invalid expression
5663 statement' error report when errors have been already reported on
5664 the same line. This occurs when we report an error but don't have
5665 a synchronization point other than ';', which
5666 expression_statement is the only one to take care of. */
5667 ctxp->prevent_ese = lineno = save_lineno;
5671 issue_warning_error_from_context (cl, msg, ap)
5676 const char *saved, *saved_input_filename;
5678 vsprintf (buffer, msg, ap);
5681 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5682 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5683 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5685 /* We have a CL, that's a good reason for using it if it contains data */
5686 saved = ctxp->filename;
5687 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5688 ctxp->filename = EXPR_WFL_FILENAME (cl);
5689 saved_input_filename = input_filename;
5690 input_filename = ctxp->filename;
5692 java_error (buffer);
5693 ctxp->filename = saved;
5694 input_filename = saved_input_filename;
5698 /* Issue an error message at a current source line CL */
5701 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5703 #ifndef ANSI_PROTOTYPES
5710 #ifndef ANSI_PROTOTYPES
5711 cl = va_arg (ap, tree);
5712 msg = va_arg (ap, const char *);
5714 issue_warning_error_from_context (cl, msg, ap);
5718 /* Issue a warning at a current source line CL */
5721 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5723 #ifndef ANSI_PROTOTYPES
5730 #ifndef ANSI_PROTOTYPES
5731 cl = va_arg (ap, tree);
5732 msg = va_arg (ap, const char *);
5735 force_error = do_warning = 1;
5736 issue_warning_error_from_context (cl, msg, ap);
5737 do_warning = force_error = 0;
5742 find_expr_with_wfl (node)
5750 switch (TREE_CODE (node))
5753 node = BLOCK_EXPR_BODY (node);
5757 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5760 node = TREE_OPERAND (node, 1);
5764 node = TREE_OPERAND (node, 0);
5767 case LABELED_BLOCK_EXPR:
5768 node = TREE_OPERAND (node, 1);
5772 code = TREE_CODE_CLASS (TREE_CODE (node));
5773 if (((code == '1') || (code == '2') || (code == 'e'))
5774 && EXPR_WFL_LINECOL (node))
5782 /* Issue a missing return statement error. Uses METHOD to figure the
5783 last line of the method the error occurs in. */
5786 missing_return_error (method)
5789 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5790 parse_error_context (wfl_operator, "Missing return statement");
5793 /* Issue an unreachable statement error. From NODE, find the next
5794 statement to report appropriately. */
5796 unreachable_stmt_error (node)
5799 /* Browse node to find the next expression node that has a WFL. Use
5800 the location to report the error */
5801 if (TREE_CODE (node) == COMPOUND_EXPR)
5802 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5804 node = find_expr_with_wfl (node);
5808 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5809 parse_error_context (wfl_operator, "Unreachable statement");
5812 fatal ("Can't get valid statement - unreachable_stmt_error");
5816 java_report_errors ()
5818 if (java_error_count)
5819 fprintf (stderr, "%d error%s",
5820 java_error_count, (java_error_count == 1 ? "" : "s"));
5821 if (java_warning_count)
5822 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5823 java_warning_count, (java_warning_count == 1 ? "" : "s"));
5824 if (java_error_count || java_warning_count)
5825 putc ('\n', stderr);
5826 return java_error_count;
5830 java_accstring_lookup (flags)
5833 static char buffer [80];
5834 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5836 /* Access modifier looked-up first for easier report on forbidden
5838 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5839 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5840 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5841 if (flags & ACC_STATIC) COPY_RETURN ("static");
5842 if (flags & ACC_FINAL) COPY_RETURN ("final");
5843 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5844 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5845 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5846 if (flags & ACC_NATIVE) COPY_RETURN ("native");
5847 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5848 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5855 /* Issuing error messages upon redefinition of classes, interfaces or
5859 classitf_redefinition_error (context, id, decl, cl)
5860 const char *context;
5863 parse_error_context (cl, "%s `%s' already defined in %s:%d",
5864 context, IDENTIFIER_POINTER (id),
5865 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5866 /* Here we should point out where its redefined. It's a unicode. FIXME */
5870 variable_redefinition_error (context, name, type, line)
5871 tree context, name, type;
5874 const char *type_name;
5876 /* Figure a proper name for type. We might haven't resolved it */
5877 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5878 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5880 type_name = lang_printable_name (type, 0);
5882 parse_error_context (context,
5883 "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
5884 IDENTIFIER_POINTER (name),
5885 type_name, IDENTIFIER_POINTER (name), line);
5889 build_array_from_name (type, type_wfl, name, ret_name)
5890 tree type, type_wfl, name, *ret_name;
5895 /* Eventually get more dims */
5896 string = IDENTIFIER_POINTER (name);
5897 while (string [more_dims] == '[')
5900 /* If we have, then craft a new type for this variable */
5903 name = get_identifier (&string [more_dims]);
5905 /* If we have a pointer, use its type */
5906 if (TREE_CODE (type) == POINTER_TYPE)
5907 type = TREE_TYPE (type);
5909 /* Building the first dimension of a primitive type uses this
5911 if (JPRIMITIVE_TYPE_P (type))
5913 type = build_java_array_type (type, -1);
5914 CLASS_LOADED_P (type) = 1;
5917 /* Otherwise, if we have a WFL for this type, use it (the type
5918 is already an array on an unresolved type, and we just keep
5919 on adding dimensions) */
5923 /* Add all the dimensions */
5925 type = build_unresolved_array_type (type);
5927 /* The type may have been incomplete in the first place */
5929 type = obtain_incomplete_type (type);
5937 /* Build something that the type identifier resolver will identify as
5938 being an array to an unresolved type. TYPE_WFL is a WFL on a
5942 build_unresolved_array_type (type_or_wfl)
5947 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5948 just create a array type */
5949 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5951 tree type = build_java_array_type (type_or_wfl, -1);
5952 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5956 obstack_1grow (&temporary_obstack, '[');
5957 obstack_grow0 (&temporary_obstack,
5958 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5959 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5960 ptr = obstack_finish (&temporary_obstack);
5961 return build_expr_wfl (get_identifier (ptr),
5962 EXPR_WFL_FILENAME (type_or_wfl),
5963 EXPR_WFL_LINENO (type_or_wfl),
5964 EXPR_WFL_COLNO (type_or_wfl));
5968 parser_add_interface (class_decl, interface_decl, wfl)
5969 tree class_decl, interface_decl, wfl;
5971 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5972 parse_error_context (wfl, "Interface `%s' repeated",
5973 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5976 /* Bulk of common class/interface checks. Return 1 if an error was
5977 encountered. TAG is 0 for a class, 1 for an interface. */
5980 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5981 int is_interface, flags;
5982 tree raw_name, qualified_name, decl, cl;
5985 int sca = 0; /* Static class allowed */
5986 int icaf = 0; /* Inner class allowed flags */
5987 int uaaf = CLASS_MODIFIERS; /* Usually allowed access flags */
5990 fprintf (stderr, " %s%s %s",
5991 (CPC_INNER_P () ? "inner" : ""),
5992 (is_interface ? "interface" : "class"),
5993 IDENTIFIER_POINTER (qualified_name));
5995 /* Scope of an interface/class type name:
5996 - Can't be imported by a single type import
5997 - Can't already exists in the package */
5998 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5999 && (node = find_name_in_single_imports (raw_name)))
6002 (cl, "%s name `%s' clashes with imported type `%s'",
6003 (is_interface ? "Interface" : "Class"),
6004 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
6007 if (decl && CLASS_COMPLETE_P (decl))
6009 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
6010 qualified_name, decl, cl);
6014 if (check_inner_class_redefinition (raw_name, cl))
6017 /* If public, file name should match class/interface name, except
6018 when dealing with an inner class */
6019 if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6023 /* Contains OS dependent assumption on path separator. FIXME */
6024 for (f = &input_filename [strlen (input_filename)];
6025 f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6028 if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6030 if (strncmp (IDENTIFIER_POINTER (raw_name),
6031 f , IDENTIFIER_LENGTH (raw_name)) ||
6032 f [IDENTIFIER_LENGTH (raw_name)] != '.')
6034 (cl, "Public %s `%s' must be defined in a file called `%s.java'",
6035 (is_interface ? "interface" : "class"),
6036 IDENTIFIER_POINTER (qualified_name),
6037 IDENTIFIER_POINTER (raw_name));
6040 /* Static classes can be declared only in top level classes. Note:
6041 once static, a inner class is a top level class. */
6042 if (flags & ACC_STATIC)
6044 /* Catch the specific error of declaring an class inner class
6045 with no toplevel enclosing class. Prevent check_modifiers from
6046 complaining a second time */
6047 if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6049 parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
6050 IDENTIFIER_POINTER (qualified_name));
6053 /* Else, in the context of a top-level class declaration, let
6054 `check_modifiers' do its job, otherwise, give it a go */
6056 sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6059 /* Inner classes can be declared private or protected
6060 within their enclosing classes. */
6063 /* A class which is local to a block can't be public, private,
6064 protected or static. But it is created final, so allow this
6066 if (current_function_decl)
6067 icaf = sca = uaaf = ACC_FINAL;
6070 check_modifiers_consistency (flags);
6071 icaf = ACC_PRIVATE|ACC_PROTECTED;
6078 uaaf = INTERFACE_INNER_MODIFIERS;
6080 uaaf = INTERFACE_MODIFIERS;
6082 check_modifiers ("Illegal modifier `%s' for interface declaration",
6086 check_modifiers ((current_function_decl ?
6087 "Illegal modifier `%s' for local class declaration" :
6088 "Illegal modifier `%s' for class declaration"),
6089 flags, uaaf|sca|icaf);
6094 make_nested_class_name (cpc_list)
6102 make_nested_class_name (TREE_CHAIN (cpc_list));
6104 /* Pick the qualified name when dealing with the first upmost
6106 name = (TREE_CHAIN (cpc_list) ?
6107 TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6108 obstack_grow (&temporary_obstack,
6109 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6110 /* Why is NO_DOLLAR_IN_LABEL defined? */
6112 #ifdef NO_DOLLAR_IN_LABEL
6113 fatal ("make_nested_class_name: Can't use '$' as a separator "
6114 "for inner classes");
6117 obstack_1grow (&temporary_obstack, '$');
6120 /* Can't redefine a class already defined in an earlier scope. */
6123 check_inner_class_redefinition (raw_name, cl)
6128 for (scope_list = GET_CPC_LIST (); scope_list;
6129 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6130 if (raw_name == GET_CPC_UN_NODE (scope_list))
6133 (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",
6134 IDENTIFIER_POINTER (raw_name));
6141 find_as_inner_class (enclosing, name, cl)
6142 tree enclosing, name, cl;
6144 tree qual, to_return;
6148 name = TYPE_NAME (name);
6150 /* First search: within the scope of `enclosing', search for name */
6151 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6152 qual = EXPR_WFL_QUALIFICATION (cl);
6154 qual = build_tree_list (cl, NULL_TREE);
6156 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6158 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6161 /* We're dealing with a qualified name. Try to resolve thing until
6162 we get something that is an enclosing class. */
6163 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6165 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6167 for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6168 qual = TREE_CHAIN (qual))
6170 acc = merge_qualified_name (acc,
6171 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6172 BUILD_PTR_FROM_NAME (ptr, acc);
6173 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6176 /* A NULL qual and a decl means that the search ended
6177 successfully?!? We have to do something then. FIXME */
6182 qual = EXPR_WFL_QUALIFICATION (cl);
6184 /* Otherwise, create a qual for the other part of the resolution. */
6186 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6188 return find_as_inner_class_do (qual, enclosing);
6191 /* We go inside the list of sub classes and try to find a way
6195 find_as_inner_class_do (qual, enclosing)
6196 tree qual, enclosing;
6201 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6203 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6204 tree next_enclosing = NULL_TREE;
6207 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6208 inner_list; inner_list = TREE_CHAIN (inner_list))
6210 if (TREE_VALUE (inner_list) == name_to_match)
6212 next_enclosing = TREE_PURPOSE (inner_list);
6216 enclosing = next_enclosing;
6219 return (!qual && enclosing ? enclosing : NULL_TREE);
6222 /* Reach all inner classes and tie their unqualified name to a
6226 set_nested_class_simple_name_value (outer, set)
6232 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6233 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6234 TREE_PURPOSE (l) : NULL_TREE);
6238 link_nested_class_to_enclosing ()
6240 if (GET_ENCLOSING_CPC ())
6242 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6243 DECL_INNER_CLASS_LIST (enclosing) =
6244 tree_cons (GET_CPC (), GET_CPC_UN (),
6245 DECL_INNER_CLASS_LIST (enclosing));
6246 enclosing = enclosing;
6251 maybe_make_nested_class_name (name)
6254 tree id = NULL_TREE;
6258 make_nested_class_name (GET_CPC_LIST ());
6259 obstack_grow0 (&temporary_obstack,
6260 IDENTIFIER_POINTER (name),
6261 IDENTIFIER_LENGTH (name));
6262 id = get_identifier (obstack_finish (&temporary_obstack));
6264 QUALIFIED_P (id) = 1;
6269 /* If DECL is NULL, create and push a new DECL, record the current
6270 line CL and do other maintenance things. */
6273 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6274 tree decl, raw_name, qualified_name, cl;
6277 decl = push_class (make_class (), qualified_name);
6279 /* Take care of the file and line business */
6280 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6281 /* If we're emiting xrefs, store the line/col number information */
6283 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6285 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6286 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6287 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6288 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6290 PUSH_CPC (decl, raw_name);
6291 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6293 /* Link the declaration to the already seen ones */
6294 TREE_CHAIN (decl) = ctxp->class_list;
6295 ctxp->class_list = decl;
6297 /* Create a new nodes in the global lists */
6298 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6299 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6301 /* Install a new dependency list element */
6302 create_jdep_list (ctxp);
6304 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6305 IDENTIFIER_POINTER (qualified_name)));
6310 add_superinterfaces (decl, interface_list)
6311 tree decl, interface_list;
6314 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6315 takes care of ensuring that:
6316 - This is an accessible interface type,
6317 - Circularity detection.
6318 parser_add_interface is then called. If present but not defined,
6319 the check operation is delayed until the super interface gets
6321 for (node = interface_list; node; node = TREE_CHAIN (node))
6323 tree current = TREE_PURPOSE (node);
6324 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6325 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6327 if (!parser_check_super_interface (idecl, decl, current))
6328 parser_add_interface (decl, idecl, current);
6331 register_incomplete_type (JDEP_INTERFACE,
6332 current, decl, NULL_TREE);
6336 /* Create an interface in pass1 and return its decl. Return the
6337 interface's decl in pass 2. */
6340 create_interface (flags, id, super)
6344 tree raw_name = EXPR_WFL_NODE (id);
6345 tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6346 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6348 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6350 /* Basic checks: scope, redefinition, modifiers */
6351 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6357 /* Suspend the current parsing context if we're parsing an inner
6360 java_parser_context_suspend ();
6362 /* Push a new context for (static) initialized upon declaration fields */
6363 java_parser_context_push_initialized_field ();
6365 /* Interface modifiers check
6366 - public/abstract allowed (already done at that point)
6367 - abstract is obsolete (comes first, it's a warning, or should be)
6368 - Can't use twice the same (checked in the modifier rule) */
6369 if ((flags & ACC_ABSTRACT) && flag_redundant)
6370 parse_warning_context
6371 (MODIFIER_WFL (ABSTRACT_TK),
6372 "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6374 /* Create a new decl if DECL is NULL, otherwise fix it */
6375 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6377 /* Set super info and mark the class a complete */
6378 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6379 object_type_node, ctxp->interface_number);
6380 ctxp->interface_number = 0;
6381 CLASS_COMPLETE_P (decl) = 1;
6382 add_superinterfaces (decl, super);
6387 /* Anonymous class counter. Will be reset to 1 every time a non
6388 anonymous class gets created. */
6389 static int anonymous_class_counter = 1;
6391 /* Patch anonymous class CLASS, by either extending or implementing
6395 patch_anonymous_class (type_decl, class_decl, wfl)
6396 tree type_decl, class_decl, wfl;
6398 tree class = TREE_TYPE (class_decl);
6399 tree type = TREE_TYPE (type_decl);
6400 tree binfo = TYPE_BINFO (class);
6402 /* If it's an interface, implement it */
6403 if (CLASS_INTERFACE (type_decl))
6408 if (parser_check_super_interface (type_decl, class_decl, wfl))
6411 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6412 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6413 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6414 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6415 /* And add the interface */
6416 parser_add_interface (class_decl, type_decl, wfl);
6418 /* Otherwise, it's a type we want to extend */
6421 if (parser_check_super (type_decl, class_decl, wfl))
6423 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6428 create_anonymous_class (location, type_name)
6433 tree super = NULL_TREE, itf = NULL_TREE;
6434 tree id, type_decl, class;
6436 /* The unqualified name of the anonymous class. It's just a number. */
6437 sprintf (buffer, "%d", anonymous_class_counter++);
6438 id = build_wfl_node (get_identifier (buffer));
6439 EXPR_WFL_LINECOL (id) = location;
6441 /* We know about the type to extend/implement. We go ahead */
6442 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6444 /* Create a class which either implements on extends the designated
6445 class. The class bears an innacessible name. */
6446 if (CLASS_INTERFACE (type_decl))
6448 /* It's OK to modify it here. It's been already used and
6449 shouldn't be reused */
6450 ctxp->interface_number = 1;
6451 /* Interfaces should presented as a list of WFLs */
6452 itf = build_tree_list (type_name, NULL_TREE);
6458 class = create_class (ACC_FINAL, id, super, itf);
6460 /* We didn't know anything about the stuff. We register a dependence. */
6462 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6464 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6468 /* Create a class in pass1 and return its decl. Return class
6469 interface's decl in pass 2. */
6472 create_class (flags, id, super, interfaces)
6474 tree id, super, interfaces;
6476 tree raw_name = EXPR_WFL_NODE (id);
6477 tree class_id, decl;
6478 tree super_decl_type;
6480 class_id = parser_qualified_classname (0, raw_name);
6481 decl = IDENTIFIER_CLASS_VALUE (class_id);
6482 EXPR_WFL_NODE (id) = class_id;
6484 /* Basic check: scope, redefinition, modifiers */
6485 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6491 /* Suspend the current parsing context if we're parsing an inner
6492 class or an anonymous class. */
6494 java_parser_context_suspend ();
6495 /* Push a new context for (static) initialized upon declaration fields */
6496 java_parser_context_push_initialized_field ();
6498 /* Class modifier check:
6499 - Allowed modifier (already done at that point)
6500 - abstract AND final forbidden
6501 - Public classes defined in the correct file */
6502 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6504 (id, "Class `%s' can't be declared both abstract and final",
6505 IDENTIFIER_POINTER (raw_name));
6507 /* Create a new decl if DECL is NULL, otherwise fix it */
6508 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6510 /* If SUPER exists, use it, otherwise use Object */
6513 /* Can't extend java.lang.Object */
6514 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6516 parse_error_context (id, "Can't extend `java.lang.Object'");
6521 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6523 else if (TREE_TYPE (decl) != object_type_node)
6524 super_decl_type = object_type_node;
6525 /* We're defining java.lang.Object */
6527 super_decl_type = NULL_TREE;
6529 /* Set super info and mark the class a complete */
6530 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6531 ctxp->interface_number);
6532 ctxp->interface_number = 0;
6533 CLASS_COMPLETE_P (decl) = 1;
6534 add_superinterfaces (decl, interfaces);
6536 /* If the class is a top level inner class, install an alias. */
6537 if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6539 tree alias = parser_qualified_classname (1, raw_name);
6540 IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6543 /* Add the private this$<n> field, Replicate final locals still in
6544 scope as private final fields mangled like val$<local_name>.
6545 This doesn't not occur for top level (static) inner classes. */
6546 if (PURE_INNER_CLASS_DECL_P (decl))
6547 add_inner_class_fields (decl, current_function_decl);
6549 /* If doing xref, store the location at which the inherited class
6550 (if any) was seen. */
6551 if (flag_emit_xref && super)
6552 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6554 /* Eventually sets the @deprecated tag flag */
6555 CHECK_DEPRECATED (decl);
6557 /* Reset the anonymous class counter when declaring non inner classes */
6558 if (!INNER_CLASS_DECL_P (decl))
6559 anonymous_class_counter = 1;
6564 /* End a class declaration: register the statements used to create
6565 $finit$ and <clinit>, pop the current class and resume the prior
6566 parser context if necessary. */
6569 end_class_declaration (resume)
6572 /* If an error occured, context weren't pushed and won't need to be
6573 popped by a resume. */
6574 int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6576 java_parser_context_pop_initialized_field ();
6578 if (resume && no_error_occured)
6579 java_parser_context_resume ();
6581 /* We're ending a class declaration, this is a good time to reset
6582 the interface cout. Note that might have been already done in
6583 create_interface, but if at that time an inner class was being
6584 dealt with, the interface count was reset in a context created
6585 for the sake of handling inner classes declaration. */
6586 ctxp->interface_number = 0;
6590 add_inner_class_fields (class_decl, fct_decl)
6594 tree block, marker, f;
6596 f = add_field (TREE_TYPE (class_decl),
6597 build_current_thisn (TREE_TYPE (class_decl)),
6598 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
6600 FIELD_THISN (f) = 1;
6605 for (block = GET_CURRENT_BLOCK (fct_decl);
6606 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6609 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6612 tree wfl, init, list;
6614 /* Avoid non final arguments. */
6615 if (!LOCAL_FINAL (decl))
6618 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6619 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6620 wfl = build_wfl_node (get_identifier (name));
6621 init = build_wfl_node (get_identifier (pname));
6622 /* Build an initialization for the field: it will be
6623 initialized by a parameter added to $finit$, bearing a
6624 mangled name of the field itself (param$<n>.) The
6625 parameter is provided to $finit$ by the constructor
6626 invoking it (hence the constructor will also feature a
6627 hidden parameter, set to the value of the outer context
6628 local at the time the inner class is created.)
6630 Note: we take into account all possible locals that can
6631 be accessed by the inner class. It's actually not trivial
6632 to minimize these aliases down to the ones really
6633 used. One way to do that would be to expand all regular
6634 methods first, then $finit$ to get a picture of what's
6635 used. It works with the exception that we would have to
6636 go back on all constructor invoked in regular methods to
6637 have their invokation reworked (to include the right amount
6638 of alias initializer parameters.)
6640 The only real way around, I think, is a first pass to
6641 identify locals really used in the inner class. We leave
6642 the flag FIELD_LOCAL_ALIAS_USED around for that future
6645 On the other hand, it only affect local inner classes,
6646 whose constructors (and $finit$ call) will be featuring
6647 unecessary arguments. It's easy for a developper to keep
6648 this number of parameter down by using the `final'
6649 keyword only when necessary. For the time being, we can
6650 issue a warning on unecessary finals. FIXME */
6651 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
6654 /* Register the field. The TREE_LIST holding the part
6655 initialized/initializer will be marked ARG_FINAL_P so
6656 that the created field can be marked
6657 FIELD_LOCAL_ALIAS. */
6658 list = build_tree_list (wfl, init);
6659 ARG_FINAL_P (list) = 1;
6660 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6664 if (!CPC_INITIALIZER_STMT (ctxp))
6667 /* If we ever registered an alias field, insert and marker to
6668 remeber where the list ends. The second part of the list (the one
6669 featuring initialized fields) so it can be later reversed to
6670 enforce 8.5. The marker will be removed during that operation. */
6671 marker = build_tree_list (NULL_TREE, NULL_TREE);
6672 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6673 SET_CPC_INITIALIZER_STMT (ctxp, marker);
6676 /* Can't use lookup_field () since we don't want to load the class and
6677 can't set the CLASS_LOADED_P flag */
6680 find_field (class, name)
6685 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6687 if (DECL_NAME (decl) == name)
6693 /* Wrap around lookup_field that doesn't potentially upset the value
6697 lookup_field_wrapper (class, name)
6701 tree decl = NULL_TREE;
6702 java_parser_context_save_global ();
6704 /* Last chance: if we're within the context of an inner class, we
6705 might be trying to access a local variable defined in an outer
6706 context. We try to look for it now. */
6707 if (INNER_CLASS_TYPE_P (class))
6711 MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6712 new_name = get_identifier (alias_buffer);
6713 decl = lookup_field (&type, new_name);
6714 if (decl && decl != error_mark_node)
6715 FIELD_LOCAL_ALIAS_USED (decl) = 1;
6717 if (!decl || decl == error_mark_node)
6720 decl = lookup_field (&type, name);
6723 java_parser_context_restore_global ();
6724 return decl == error_mark_node ? NULL : decl;
6727 /* Find duplicate field within the same class declarations and report
6728 the error. Returns 1 if a duplicated field was found, 0
6732 duplicate_declaration_error_p (new_field_name, new_type, cl)
6733 tree new_field_name, new_type, cl;
6735 /* This might be modified to work with method decl as well */
6736 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6739 char *t1 = xstrdup (purify_type_name
6740 ((TREE_CODE (new_type) == POINTER_TYPE
6741 && TREE_TYPE (new_type) == NULL_TREE) ?
6742 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6743 lang_printable_name (new_type, 1)));
6744 /* The type may not have been completed by the time we report
6746 char *t2 = xstrdup (purify_type_name
6747 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
6748 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6749 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6750 lang_printable_name (TREE_TYPE (decl), 1)));
6752 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
6753 t1, IDENTIFIER_POINTER (new_field_name),
6754 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6755 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6763 /* Field registration routine. If TYPE doesn't exist, field
6764 declarations are linked to the undefined TYPE dependency list, to
6765 be later resolved in java_complete_class () */
6768 register_fields (flags, type, variable_list)
6770 tree type, variable_list;
6772 tree current, saved_type;
6773 tree class_type = NULL_TREE;
6774 int saved_lineno = lineno;
6776 tree wfl = NULL_TREE;
6779 class_type = TREE_TYPE (GET_CPC ());
6781 if (!class_type || class_type == error_mark_node)
6784 /* If we're adding fields to interfaces, those fields are public,
6786 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6788 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6789 flags, ACC_PUBLIC, "interface field(s)");
6790 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6791 flags, ACC_STATIC, "interface field(s)");
6792 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6793 flags, ACC_FINAL, "interface field(s)");
6794 check_modifiers ("Illegal interface member modifier `%s'", flags,
6795 INTERFACE_FIELD_MODIFIERS);
6796 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6799 /* Obtain a suitable type for resolution, if necessary */
6800 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6802 /* If TYPE is fully resolved and we don't have a reference, make one */
6803 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6805 for (current = variable_list, saved_type = type; current;
6806 current = TREE_CHAIN (current), type = saved_type)
6810 tree cl = TREE_PURPOSE (current);
6811 tree init = TREE_VALUE (current);
6812 tree current_name = EXPR_WFL_NODE (cl);
6814 /* Can't declare static fields in inner classes */
6815 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6816 && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6818 (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6819 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6820 lang_printable_name (class_type, 0));
6822 /* Process NAME, as it may specify extra dimension(s) for it */
6823 type = build_array_from_name (type, wfl, current_name, ¤t_name);
6825 /* Type adjustment. We may have just readjusted TYPE because
6826 the variable specified more dimensions. Make sure we have
6827 a reference if we can and don't have one already. Also
6828 change the name if we have an init. */
6829 if (type != saved_type)
6831 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6833 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6836 real_type = GET_REAL_TYPE (type);
6837 /* Check for redeclarations */
6838 if (duplicate_declaration_error_p (current_name, real_type, cl))
6841 /* Set lineno to the line the field was found and create a
6842 declaration for it. Eventually sets the @deprecated tag flag. */
6844 lineno = EXPR_WFL_LINECOL (cl);
6846 lineno = EXPR_WFL_LINENO (cl);
6847 field_decl = add_field (class_type, current_name, real_type, flags);
6848 CHECK_DEPRECATED (field_decl);
6850 /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6851 mark the created field FIELD_LOCAL_ALIAS, so that we can
6852 hide parameters to this inner class $finit$ and constructors. */
6853 if (ARG_FINAL_P (current))
6854 FIELD_LOCAL_ALIAS (field_decl) = 1;
6856 /* Check if we must chain. */
6858 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6860 /* If we have an initialization value tied to the field */
6863 /* The field is declared static */
6864 if (flags & ACC_STATIC)
6866 /* We include the field and its initialization part into
6867 a list used to generate <clinit>. After <clinit> is
6868 walked, field initializations will be processed and
6869 fields initialized with known constants will be taken
6870 out of <clinit> and have their DECL_INITIAL set
6872 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6873 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6874 if (TREE_OPERAND (init, 1)
6875 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6876 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6878 /* A non-static field declared with an immediate initialization is
6879 to be initialized in <init>, if any. This field is remembered
6880 to be processed at the time of the generation of <init>. */
6883 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6884 SET_CPC_INITIALIZER_STMT (ctxp, init);
6886 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6887 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6890 lineno = saved_lineno;
6893 /* Generate $finit$, using the list of initialized fields to populate
6894 its body. $finit$'s parameter(s) list is adjusted to include the
6895 one(s) used to initialized the field(s) caching outer context
6899 generate_finit (class_type)
6903 tree list = TYPE_FINIT_STMT_LIST (class_type);
6904 tree mdecl, current, parms;
6906 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
6907 class_type, NULL_TREE,
6909 CRAFTED_PARAM_LIST_FIXUP (parms);
6910 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6911 finit_identifier_node, parms);
6912 fix_method_argument_names (parms, mdecl);
6913 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6915 DECL_FUNCTION_NAP (mdecl) = count;
6916 start_artificial_method_body (mdecl);
6918 for (current = list; current; current = TREE_CHAIN (current))
6919 java_method_add_stmt (mdecl,
6920 build_debugable_stmt (EXPR_WFL_LINECOL (current),
6922 end_artificial_method_body (mdecl);
6927 add_instance_initializer (mdecl)
6931 tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6932 tree compound = NULL_TREE;
6936 for (current = stmt_list; current; current = TREE_CHAIN (current))
6937 compound = add_stmt_to_compound (compound, NULL_TREE, current);
6939 java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6940 NULL_TREE, compound));
6944 /* Shared accros method_declarator and method_header to remember the
6945 patch stage that was reached during the declaration of the method.
6946 A method DECL is built differently is there is no patch
6947 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6948 pending on the currently defined method. */
6950 static int patch_stage;
6952 /* Check the method declaration and add the method to its current
6953 class. If the argument list is known to contain incomplete types,
6954 the method is partially added and the registration will be resume
6955 once the method arguments resolved. If TYPE is NULL, we're dealing
6956 with a constructor. */
6959 method_header (flags, type, mdecl, throws)
6961 tree type, mdecl, throws;
6963 tree meth = TREE_VALUE (mdecl);
6964 tree id = TREE_PURPOSE (mdecl);
6965 tree type_wfl = NULL_TREE;
6966 tree meth_name = NULL_TREE;
6967 tree current, orig_arg, this_class = NULL;
6969 int constructor_ok = 0, must_chain;
6972 check_modifiers_consistency (flags);
6975 this_class = TREE_TYPE (GET_CPC ());
6977 if (!this_class || this_class == error_mark_node)
6980 /* There are some forbidden modifiers for an abstract method and its
6981 class must be abstract as well. */
6982 if (type && (flags & ACC_ABSTRACT))
6984 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6985 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6986 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6987 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6988 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6989 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6990 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6992 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
6993 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6994 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6997 /* Things to be checked when declaring a constructor */
7000 int ec = java_error_count;
7001 /* 8.6: Constructor declarations: we might be trying to define a
7002 method without specifying a return type. */
7003 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
7005 (id, "Invalid method declaration, return type required");
7006 /* 8.6.3: Constructor modifiers */
7009 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
7010 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
7011 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
7012 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
7013 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
7015 /* If we found error here, we don't consider it's OK to tread
7016 the method definition as a constructor, for the rest of this
7018 if (ec == java_error_count)
7022 /* Method declared within the scope of an interface are implicitly
7023 abstract and public. Conflicts with other erroneously provided
7024 modifiers are checked right after. */
7026 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7028 /* If FLAGS isn't set because of a modifier, turn the
7029 corresponding modifier WFL to NULL so we issue a warning on
7030 the obsolete use of the modifier */
7031 if (!(flags & ACC_PUBLIC))
7032 MODIFIER_WFL (PUBLIC_TK) = NULL;
7033 if (!(flags & ACC_ABSTRACT))
7034 MODIFIER_WFL (ABSTRACT_TK) = NULL;
7035 flags |= ACC_PUBLIC;
7036 flags |= ACC_ABSTRACT;
7039 /* Inner class can't declare static methods */
7040 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7043 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7044 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7045 lang_printable_name (this_class, 0));
7048 /* Modifiers context reset moved up, so abstract method declaration
7049 modifiers can be later checked. */
7051 /* Set constructor returned type to void and method name to <init>,
7052 unless we found an error identifier the constructor (in which
7053 case we retain the original name) */
7056 type = void_type_node;
7058 meth_name = init_identifier_node;
7061 meth_name = EXPR_WFL_NODE (id);
7063 /* Do the returned type resolution and registration if necessary */
7064 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7067 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7068 EXPR_WFL_NODE (id) = meth_name;
7069 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7073 patch_stage = JDEP_METHOD_RETURN;
7074 register_incomplete_type (patch_stage, type_wfl, id, type);
7075 TREE_TYPE (meth) = GET_REAL_TYPE (type);
7078 TREE_TYPE (meth) = type;
7080 saved_lineno = lineno;
7081 /* When defining an abstract or interface method, the curly
7082 bracket at level 1 doesn't exist because there is no function
7084 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
7085 EXPR_WFL_LINENO (id));
7087 /* Remember the original argument list */
7088 orig_arg = TYPE_ARG_TYPES (meth);
7090 if (patch_stage) /* includes ret type and/or all args */
7093 meth = add_method_1 (this_class, flags, meth_name, meth);
7094 /* Patch for the return type */
7095 if (patch_stage == JDEP_METHOD_RETURN)
7097 jdep = CLASSD_LAST (ctxp->classd_list);
7098 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7100 /* This is the stop JDEP. METH allows the function's signature
7102 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7105 meth = add_method (this_class, flags, meth_name,
7106 build_java_signature (meth));
7108 /* Remember final parameters */
7109 MARK_FINAL_PARMS (meth, orig_arg);
7111 /* Fix the method argument list so we have the argument name
7113 fix_method_argument_names (orig_arg, meth);
7115 /* Register the parameter number and re-install the current line
7117 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7118 lineno = saved_lineno;
7120 /* Register exception specified by the `throws' keyword for
7121 resolution and set the method decl appropriate field to the list.
7122 Note: the grammar ensures that what we get here are class
7126 throws = nreverse (throws);
7127 for (current = throws; current; current = TREE_CHAIN (current))
7129 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7130 NULL_TREE, NULL_TREE);
7131 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7132 &TREE_VALUE (current);
7134 DECL_FUNCTION_THROWS (meth) = throws;
7137 /* We set the DECL_NAME to ID so we can track the location where
7138 the function was declared. This allow us to report
7139 redefinition error accurately. When method are verified,
7140 DECL_NAME is reinstalled properly (using the content of the
7141 WFL node ID) (see check_method_redefinition). We don't do that
7142 when Object is being defined. Constructor <init> names will be
7143 reinstalled the same way. */
7144 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7145 DECL_NAME (meth) = id;
7147 /* Set the flag if we correctly processed a constructor */
7150 DECL_CONSTRUCTOR_P (meth) = 1;
7151 /* Compute and store the number of artificial parameters declared
7152 for this constructor */
7153 for (count = 0, current = TYPE_FIELDS (this_class); current;
7154 current = TREE_CHAIN (current))
7155 if (FIELD_LOCAL_ALIAS (current))
7157 DECL_FUNCTION_NAP (meth) = count;
7160 /* Eventually set the @deprecated tag flag */
7161 CHECK_DEPRECATED (meth);
7163 /* If doing xref, store column and line number information instead
7164 of the line number only. */
7166 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7172 fix_method_argument_names (orig_arg, meth)
7173 tree orig_arg, meth;
7175 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7176 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7178 TREE_PURPOSE (arg) = this_identifier_node;
7179 arg = TREE_CHAIN (arg);
7181 while (orig_arg != end_params_node)
7183 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7184 orig_arg = TREE_CHAIN (orig_arg);
7185 arg = TREE_CHAIN (arg);
7189 /* Complete the method declaration with METHOD_BODY. */
7192 finish_method_declaration (method_body)
7197 if (!current_function_decl)
7200 flags = get_access_flags_from_decl (current_function_decl);
7202 /* 8.4.5 Method Body */
7203 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7205 tree wfl = DECL_NAME (current_function_decl);
7206 parse_error_context (wfl,
7207 "%s method `%s' can't have a body defined",
7208 (METHOD_NATIVE (current_function_decl) ?
7209 "Native" : "Abstract"),
7210 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7211 method_body = NULL_TREE;
7213 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7215 tree wfl = DECL_NAME (current_function_decl);
7218 "Non native and non abstract method `%s' must have a body defined",
7219 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7220 method_body = NULL_TREE;
7223 if (flag_emit_class_files && method_body
7224 && TREE_CODE (method_body) == NOP_EXPR
7225 && TREE_TYPE (current_function_decl)
7226 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7227 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7229 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7230 maybe_absorb_scoping_blocks ();
7231 /* Exit function's body */
7233 /* Merge last line of the function with first line, directly in the
7234 function decl. It will be used to emit correct debug info. */
7235 if (!flag_emit_xref)
7236 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7238 /* Since function's argument's list are shared, reset the
7239 ARG_FINAL_P parameter that might have been set on some of this
7240 function parameters. */
7241 UNMARK_FINAL_PARMS (current_function_decl);
7243 /* So we don't have an irrelevant function declaration context for
7244 the next static block we'll see. */
7245 current_function_decl = NULL_TREE;
7248 /* Build a an error message for constructor circularity errors. */
7251 constructor_circularity_msg (from, to)
7254 static char string [4096];
7255 char *t = xstrdup (lang_printable_name (from, 0));
7256 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7261 /* Verify a circular call to METH. Return 1 if an error is found, 0
7265 verify_constructor_circularity (meth, current)
7268 static tree list = NULL_TREE;
7270 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7272 if (TREE_VALUE (c) == meth)
7278 list = nreverse (list);
7279 for (liste = list; liste; liste = TREE_CHAIN (liste))
7282 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7283 constructor_circularity_msg
7284 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7288 t = xstrdup (lang_printable_name (meth, 0));
7289 parse_error_context (TREE_PURPOSE (c),
7290 "%s: recursive invocation of constructor `%s'",
7291 constructor_circularity_msg (current, meth), t);
7297 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7299 list = tree_cons (c, current, list);
7300 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7302 list = TREE_CHAIN (list);
7307 /* Check modifiers that can be declared but exclusively */
7310 check_modifiers_consistency (flags)
7314 tree cl = NULL_TREE;
7316 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7317 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7318 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7321 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7325 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK, acc_count, cl);
7326 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK, acc_count, cl);
7328 parse_error_context (cl,
7329 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7332 /* Check the methode header METH for abstract specifics features */
7335 check_abstract_method_header (meth)
7338 int flags = get_access_flags_from_decl (meth);
7339 /* DECL_NAME might still be a WFL node */
7340 tree name = GET_METHOD_NAME (meth);
7342 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7343 ACC_ABSTRACT, "abstract method",
7344 IDENTIFIER_POINTER (name));
7345 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7346 ACC_PUBLIC, "abstract method",
7347 IDENTIFIER_POINTER (name));
7349 check_modifiers ("Illegal modifier `%s' for interface method",
7350 flags, INTERFACE_METHOD_MODIFIERS);
7353 /* Create a FUNCTION_TYPE node and start augmenting it with the
7354 declared function arguments. Arguments type that can't be resolved
7355 are left as they are, but the returned node is marked as containing
7356 incomplete types. */
7359 method_declarator (id, list)
7362 tree arg_types = NULL_TREE, current, node;
7363 tree meth = make_node (FUNCTION_TYPE);
7366 patch_stage = JDEP_NO_PATCH;
7368 /* If we're dealing with an inner class constructor, we hide the
7369 this$<n> decl in the name field of its parameter declaration. We
7370 also might have to hide the outer context local alias
7371 initializers. Not done when the class is a toplevel class. */
7372 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7373 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7375 tree aliases_list, type, thisn;
7376 /* First the aliases, linked to the regular parameters */
7378 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7379 TREE_TYPE (GET_CPC ()),
7381 list = chainon (nreverse (aliases_list), list);
7384 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7385 thisn = build_current_thisn (TREE_TYPE (GET_CPC ()));
7386 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7390 for (current = list; current; current = TREE_CHAIN (current))
7393 tree wfl_name = TREE_PURPOSE (current);
7394 tree type = TREE_VALUE (current);
7395 tree name = EXPR_WFL_NODE (wfl_name);
7396 tree already, arg_node;
7397 tree type_wfl = NULL_TREE;
7400 /* Obtain a suitable type for resolution, if necessary */
7401 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7403 /* Process NAME, as it may specify extra dimension(s) for it */
7404 type = build_array_from_name (type, type_wfl, name, &name);
7405 EXPR_WFL_NODE (wfl_name) = name;
7407 real_type = GET_REAL_TYPE (type);
7408 if (TREE_CODE (real_type) == RECORD_TYPE)
7410 real_type = promote_type (real_type);
7411 if (TREE_CODE (type) == TREE_LIST)
7412 TREE_PURPOSE (type) = real_type;
7415 /* Check redefinition */
7416 for (already = arg_types; already; already = TREE_CHAIN (already))
7417 if (TREE_PURPOSE (already) == name)
7420 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7421 IDENTIFIER_POINTER (name),
7422 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7426 /* If we've an incomplete argument type, we know there is a location
7427 to patch when the type get resolved, later. */
7431 patch_stage = JDEP_METHOD;
7432 type = register_incomplete_type (patch_stage,
7433 type_wfl, wfl_name, type);
7434 jdep = CLASSD_LAST (ctxp->classd_list);
7435 JDEP_MISC (jdep) = id;
7438 /* The argument node: a name and a (possibly) incomplete type. */
7439 arg_node = build_tree_list (name, real_type);
7440 /* Remeber arguments declared final. */
7441 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7444 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7445 TREE_CHAIN (arg_node) = arg_types;
7446 arg_types = arg_node;
7448 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7449 node = build_tree_list (id, meth);
7454 unresolved_type_p (wfl, returned)
7459 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7463 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7464 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7465 *returned = TREE_TYPE (decl);
7466 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7467 *returned = TREE_TYPE (GET_CPC ());
7469 *returned = NULL_TREE;
7478 /* From NAME, build a qualified identifier node using the
7479 qualification from the current package definition. */
7482 parser_qualified_classname (is_static, name)
7486 tree nested_class_name;
7489 && (nested_class_name = maybe_make_nested_class_name (name)))
7490 return nested_class_name;
7493 return merge_qualified_name (ctxp->package, name);
7498 /* Called once the type a interface extends is resolved. Returns 0 if
7499 everything is OK. */
7502 parser_check_super_interface (super_decl, this_decl, this_wfl)
7503 tree super_decl, this_decl, this_wfl;
7505 tree super_type = TREE_TYPE (super_decl);
7507 /* Has to be an interface */
7508 if (!CLASS_INTERFACE (super_decl))
7511 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7512 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7513 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7514 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7515 "interface" : "class"),
7516 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7520 /* Check scope: same package OK, other package: OK if public */
7521 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7524 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7525 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7526 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7530 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7531 0 if everthing is OK. */
7534 parser_check_super (super_decl, this_decl, wfl)
7535 tree super_decl, this_decl, wfl;
7537 tree super_type = TREE_TYPE (super_decl);
7539 /* SUPER should be a CLASS (neither an array nor an interface) */
7540 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7543 (wfl, "Class `%s' can't subclass %s `%s'",
7544 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7545 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7546 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7550 if (CLASS_FINAL (TYPE_NAME (super_type)))
7552 parse_error_context (wfl, "Can't subclass final classes: %s",
7553 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7557 /* Check scope: same package OK, other package: OK if public */
7558 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7561 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7562 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7563 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7567 /* Create a new dependency list and link it (in a LIFO manner) to the
7568 CTXP list of type dependency list. */
7571 create_jdep_list (ctxp)
7572 struct parser_ctxt *ctxp;
7574 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
7575 new->first = new->last = NULL;
7576 new->next = ctxp->classd_list;
7577 ctxp->classd_list = new;
7581 reverse_jdep_list (ctxp)
7582 struct parser_ctxt *ctxp;
7584 register jdeplist *prev = NULL, *current, *next;
7585 for (current = ctxp->classd_list; current; current = next)
7587 next = current->next;
7588 current->next = prev;
7594 /* Create a fake pointer based on the ID stored in
7595 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7596 registered again. */
7599 obtain_incomplete_type (type_name)
7604 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7605 name = EXPR_WFL_NODE (type_name);
7606 else if (INCOMPLETE_TYPE_P (type_name))
7607 name = TYPE_NAME (type_name);
7609 fatal ("invalid type name - obtain_incomplete_type");
7611 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7612 if (TYPE_NAME (ptr) == name)
7617 push_obstacks (&permanent_obstack, &permanent_obstack);
7618 BUILD_PTR_FROM_NAME (ptr, name);
7621 TREE_CHAIN (ptr) = ctxp->incomplete_class;
7622 ctxp->incomplete_class = ptr;
7628 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7629 non NULL instead of computing a new fake type based on WFL. The new
7630 dependency is inserted in the current type dependency list, in FIFO
7634 register_incomplete_type (kind, wfl, decl, ptr)
7636 tree wfl, decl, ptr;
7638 jdep *new = (jdep *)xmalloc (sizeof (jdep));
7640 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7641 ptr = obtain_incomplete_type (wfl);
7643 JDEP_KIND (new) = kind;
7644 JDEP_DECL (new) = decl;
7645 JDEP_SOLV (new) = ptr;
7646 JDEP_WFL (new) = wfl;
7647 JDEP_CHAIN (new) = NULL;
7648 JDEP_MISC (new) = NULL_TREE;
7649 /* For some dependencies, set the enclosing class of the current
7650 class to be the enclosing context */
7651 if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS)
7652 && GET_ENCLOSING_CPC ())
7653 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7655 JDEP_ENCLOSING (new) = GET_CPC ();
7656 JDEP_GET_PATCH (new) = (tree *)NULL;
7658 JDEP_INSERT (ctxp->classd_list, new);
7664 java_check_circular_reference ()
7667 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7669 tree type = TREE_TYPE (current);
7670 if (CLASS_INTERFACE (current))
7672 /* Check all interfaces this class extends */
7673 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7678 n = TREE_VEC_LENGTH (basetype_vec);
7679 for (i = 0; i < n; i++)
7681 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7682 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
7683 && interface_of_p (type, BINFO_TYPE (vec_elt)))
7684 parse_error_context (lookup_cl (current),
7685 "Cyclic interface inheritance");
7689 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7690 parse_error_context (lookup_cl (current),
7691 "Cyclic class inheritance%s",
7692 (cyclic_inheritance_report ?
7693 cyclic_inheritance_report : ""));
7697 /* Augment the parameter list PARM with parameters crafted to
7698 initialize outer context locals aliases. Through ARTIFICIAL, a
7699 count is kept of the number of crafted parameters. MODE governs
7700 what eventually gets created: something suitable for a function
7701 creation or a function invocation, either the constructor or
7705 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7707 tree class_type, parm;
7711 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7712 if (FIELD_LOCAL_ALIAS (field))
7714 char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7715 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7719 case AIPL_FUNCTION_DECLARATION:
7720 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7721 purpose = build_wfl_node (get_identifier (buffer));
7722 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7723 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7725 value = TREE_TYPE (field);
7728 case AIPL_FUNCTION_CREATION:
7729 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7730 purpose = get_identifier (buffer);
7731 value = TREE_TYPE (field);
7734 case AIPL_FUNCTION_FINIT_INVOCATION:
7735 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7736 /* Now, this is wrong. purpose should always be the NAME
7737 of something and value its matching value (decl, type,
7738 etc...) FIXME -- but there is a lot to fix. */
7740 /* When invoked for this kind of operation, we already
7741 know whether a field is used or not. */
7742 purpose = TREE_TYPE (field);
7743 value = build_wfl_node (get_identifier (buffer));
7746 case AIPL_FUNCTION_CTOR_INVOCATION:
7747 /* There are two case: the constructor invokation happends
7748 outside the local inner, in which case, locales from the outer
7749 context are directly used.
7751 Otherwise, we fold to using the alias directly. */
7752 if (class_type == current_class)
7756 name = get_identifier (&buffer[4]);
7757 value = IDENTIFIER_LOCAL_VALUE (name);
7761 parm = tree_cons (purpose, value, parm);
7768 /* Craft a constructor for CLASS_DECL -- what we should do when none
7769 where found. ARGS is non NULL when a special signature must be
7770 enforced. This is the case for anonymous classes. */
7773 craft_constructor (class_decl, args)
7774 tree class_decl, args;
7776 tree class_type = TREE_TYPE (class_decl);
7777 tree parm = NULL_TREE;
7778 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7780 int i = 0, artificial = 0;
7781 tree decl, ctor_name;
7784 push_obstacks (&permanent_obstack, &permanent_obstack);
7786 /* The constructor name is <init> unless we're dealing with an
7787 anonymous class, in which case the name will be fixed after having
7789 if (ANONYMOUS_CLASS_P (class_type))
7790 ctor_name = DECL_NAME (class_decl);
7792 ctor_name = init_identifier_node;
7794 /* If we're dealing with an inner class constructor, we hide the
7795 this$<n> decl in the name field of its parameter declaration. */
7796 if (PURE_INNER_CLASS_TYPE_P (class_type))
7798 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7799 parm = tree_cons (build_current_thisn (class_type),
7800 build_pointer_type (type), parm);
7802 /* Some more arguments to be hidden here. The values of the local
7803 variables of the outer context that the inner class needs to see. */
7804 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7809 /* Then if there are any args to be enforced, enforce them now */
7810 for (; args && args != end_params_node; args = TREE_CHAIN (args))
7812 sprintf (buffer, "parm%d", i++);
7813 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7816 CRAFTED_PARAM_LIST_FIXUP (parm);
7817 decl = create_artificial_method (class_type, flags, void_type_node,
7819 fix_method_argument_names (parm, decl);
7820 /* Now, mark the artificial parameters. */
7821 DECL_FUNCTION_NAP (decl) = artificial;
7824 DECL_CONSTRUCTOR_P (decl) = 1;
7828 /* Fix the constructors. This will be called right after circular
7829 references have been checked. It is necessary to fix constructors
7830 early even if no code generation will take place for that class:
7831 some generated constructor might be required by the class whose
7832 compilation triggered this one to be simply loaded. */
7835 java_fix_constructors ()
7839 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7841 tree class_type = TREE_TYPE (current);
7845 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7848 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7850 if (DECL_CONSTRUCTOR_P (decl))
7852 fix_constructors (decl);
7857 /* Anonymous class constructor can't be generated that early. */
7858 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7859 craft_constructor (current, NULL_TREE);
7863 /* safe_layout_class just makes sure that we can load a class without
7864 disrupting the current_class, input_file, lineno, etc, information
7865 about the class processed currently. */
7868 safe_layout_class (class)
7871 tree save_current_class = current_class;
7872 const char *save_input_filename = input_filename;
7873 int save_lineno = lineno;
7875 push_obstacks (&permanent_obstack, &permanent_obstack);
7877 layout_class (class);
7880 current_class = save_current_class;
7881 input_filename = save_input_filename;
7882 lineno = save_lineno;
7883 CLASS_LOADED_P (class) = 1;
7887 jdep_resolve_class (dep)
7892 if (JDEP_RESOLVED_P (dep))
7893 decl = JDEP_RESOLVED_DECL (dep);
7896 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7897 JDEP_DECL (dep), JDEP_WFL (dep));
7898 JDEP_RESOLVED (dep, decl);
7902 complete_class_report_errors (dep);
7907 /* Complete unsatisfied class declaration and their dependencies */
7910 java_complete_class ()
7917 push_obstacks (&permanent_obstack, &permanent_obstack);
7919 /* Process imports */
7922 /* Rever things so we have the right order */
7923 ctxp->class_list = nreverse (ctxp->class_list);
7924 ctxp->classd_list = reverse_jdep_list (ctxp);
7926 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
7928 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7931 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7934 if (!(decl = jdep_resolve_class (dep)))
7937 /* Now it's time to patch */
7938 switch (JDEP_KIND (dep))
7941 /* Simply patch super */
7942 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7944 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
7945 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7950 /* We do part of the job done in add_field */
7951 tree field_decl = JDEP_DECL (dep);
7952 tree field_type = TREE_TYPE (decl);
7953 push_obstacks (&permanent_obstack, &permanent_obstack);
7954 if (TREE_CODE (field_type) == RECORD_TYPE)
7955 field_type = promote_type (field_type);
7957 TREE_TYPE (field_decl) = field_type;
7958 DECL_ALIGN (field_decl) = 0;
7959 DECL_USER_ALIGN (field_decl) = 0;
7960 layout_decl (field_decl, 0);
7961 SOURCE_FRONTEND_DEBUG
7962 (("Completed field/var decl `%s' with `%s'",
7963 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7964 IDENTIFIER_POINTER (DECL_NAME (decl))));
7967 case JDEP_METHOD: /* We start patching a method */
7968 case JDEP_METHOD_RETURN:
7974 type = TREE_TYPE(decl);
7975 if (TREE_CODE (type) == RECORD_TYPE)
7976 type = promote_type (type);
7977 JDEP_APPLY_PATCH (dep, type);
7978 SOURCE_FRONTEND_DEBUG
7979 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7980 "Completing fct `%s' with ret type `%s'":
7981 "Completing arg `%s' with type `%s'"),
7982 IDENTIFIER_POINTER (EXPR_WFL_NODE
7983 (JDEP_DECL_WFL (dep))),
7984 IDENTIFIER_POINTER (DECL_NAME (decl))));
7988 dep = JDEP_CHAIN (dep);
7989 if (JDEP_KIND (dep) == JDEP_METHOD_END)
7992 decl = jdep_resolve_class (dep);
7996 tree mdecl = JDEP_DECL (dep), signature;
7997 push_obstacks (&permanent_obstack, &permanent_obstack);
7998 /* Recompute and reset the signature, check first that
7999 all types are now defined. If they're not,
8000 dont build the signature. */
8001 if (check_method_types_complete (mdecl))
8003 signature = build_java_signature (TREE_TYPE (mdecl));
8004 set_java_signature (TREE_TYPE (mdecl), signature);
8012 case JDEP_INTERFACE:
8013 if (parser_check_super_interface (decl, JDEP_DECL (dep),
8016 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8021 type = TREE_TYPE(decl);
8022 if (TREE_CODE (type) == RECORD_TYPE)
8023 type = promote_type (type);
8024 JDEP_APPLY_PATCH (dep, type);
8028 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8029 SOURCE_FRONTEND_DEBUG
8030 (("Completing a random type dependency on a '%s' node",
8031 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8034 case JDEP_EXCEPTION:
8035 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8036 SOURCE_FRONTEND_DEBUG
8037 (("Completing `%s' `throws' argument node",
8038 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8041 case JDEP_ANONYMOUS:
8042 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8046 fatal ("Can't handle patch code %d - java_complete_class",
8055 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8059 resolve_class (enclosing, class_type, decl, cl)
8060 tree enclosing, class_type, decl, cl;
8062 const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8063 const char *base = name;
8064 tree resolved_type = TREE_TYPE (class_type);
8065 tree resolved_type_decl;
8067 if (resolved_type != NULL_TREE)
8069 tree resolved_type_decl = TYPE_NAME (resolved_type);
8070 if (resolved_type_decl == NULL_TREE
8071 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8073 resolved_type_decl = build_decl (TYPE_DECL,
8074 TYPE_NAME (class_type),
8077 return resolved_type_decl;
8080 /* 1- Check to see if we have an array. If true, find what we really
8082 while (name[0] == '[')
8085 TYPE_NAME (class_type) = get_identifier (name);
8087 /* 2- Resolve the bare type */
8088 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
8091 resolved_type = TREE_TYPE (resolved_type_decl);
8093 /* 3- If we have and array, reconstruct the array down to its nesting */
8096 while (base != name)
8098 if (TREE_CODE (resolved_type) == RECORD_TYPE)
8099 resolved_type = promote_type (resolved_type);
8100 resolved_type = build_java_array_type (resolved_type, -1);
8101 CLASS_LOADED_P (resolved_type) = 1;
8104 /* Build a fake decl for this, since this is what is expected to
8106 resolved_type_decl =
8107 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8108 /* Figure how those two things are important for error report. FIXME */
8109 DECL_SOURCE_LINE (resolved_type_decl) = 0;
8110 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8111 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8113 TREE_TYPE (class_type) = resolved_type;
8114 return resolved_type_decl;
8117 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8118 are used to report error messages. */
8121 do_resolve_class (enclosing, class_type, decl, cl)
8122 tree enclosing, class_type, decl, cl;
8124 tree new_class_decl;
8126 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8127 it is changed by find_in_imports{_on_demand} and (but it doesn't
8128 really matter) qualify_and_find */
8130 /* 0- Search in the current class as an inner class */
8132 /* Maybe some code here should be added to load the class or
8133 something, at least if the class isn't an inner class and ended
8134 being loaded from class file. FIXME. */
8139 if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8140 return new_class_decl;
8142 /* Now go to the upper classes, bail out if necessary. */
8143 enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8144 if (!enclosing || enclosing == object_type_node)
8147 if (TREE_CODE (enclosing) == RECORD_TYPE)
8149 enclosing = TYPE_NAME (enclosing);
8153 if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8155 BUILD_PTR_FROM_NAME (name, enclosing);
8159 enclosing = do_resolve_class (NULL, name, NULL, NULL);
8162 /* 1- Check for the type in single imports. This will change
8163 TYPE_NAME() if something relevant is found */
8164 find_in_imports (class_type);
8166 /* 2- And check for the type in the current compilation unit */
8167 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8169 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8170 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8171 load_class (TYPE_NAME (class_type), 0);
8172 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8175 /* 3- Search according to the current package definition */
8176 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8178 if ((new_class_decl = qualify_and_find (class_type, ctxp->package,
8179 TYPE_NAME (class_type))))
8180 return new_class_decl;
8183 /* 4- Check the import on demands. Don't allow bar.baz to be
8184 imported from foo.* */
8185 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8186 if (find_in_imports_on_demand (class_type))
8189 /* If found in find_in_imports_on_demant, the type has already been
8191 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8192 return new_class_decl;
8194 /* 5- Try with a name qualified with the package name we've seen so far */
8195 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8199 /* If there is a current package (ctxp->package), it's the first
8200 element of package_list and we can skip it. */
8201 for (package = (ctxp->package ?
8202 TREE_CHAIN (package_list) : package_list);
8203 package; package = TREE_CHAIN (package))
8204 if ((new_class_decl = qualify_and_find (class_type,
8205 TREE_PURPOSE (package),
8206 TYPE_NAME (class_type))))
8207 return new_class_decl;
8210 /* 5- Check an other compilation unit that bears the name of type */
8211 load_class (TYPE_NAME (class_type), 0);
8212 if (check_pkg_class_access (TYPE_NAME (class_type),
8213 (cl ? cl : lookup_cl (decl))))
8216 /* 6- Last call for a resolution */
8217 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8221 qualify_and_find (class_type, package, name)
8222 tree class_type, package, name;
8224 tree new_qualified = merge_qualified_name (package, name);
8225 tree new_class_decl;
8227 if (!IDENTIFIER_CLASS_VALUE (new_qualified))
8228 load_class (new_qualified, 0);
8229 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
8231 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8232 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8233 load_class (new_qualified, 0);
8234 TYPE_NAME (class_type) = new_qualified;
8235 return IDENTIFIER_CLASS_VALUE (new_qualified);
8240 /* Resolve NAME and lay it out (if not done and if not the current
8241 parsed class). Return a decl node. This function is meant to be
8242 called when type resolution is necessary during the walk pass. */
8245 resolve_and_layout (something, cl)
8251 /* Don't do that on the current class */
8252 if (something == current_class)
8253 return TYPE_NAME (current_class);
8255 /* Don't do anything for void and other primitive types */
8256 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8259 /* Pointer types can be reall pointer types or fake pointers. When
8260 finding a real pointer, recheck for primitive types */
8261 if (TREE_CODE (something) == POINTER_TYPE)
8263 if (TREE_TYPE (something))
8265 something = TREE_TYPE (something);
8266 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8270 something = TYPE_NAME (something);
8273 /* Don't do anything for arrays of primitive types */
8274 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8275 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8278 /* Something might be a WFL */
8279 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8280 something = EXPR_WFL_NODE (something);
8282 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8283 TYPE_DECL or a real TYPE */
8284 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8285 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8286 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8288 if (!(decl = resolve_no_layout (something, cl)))
8291 /* Resolve and layout if necessary */
8292 layout_class_methods (TREE_TYPE (decl));
8293 /* Check methods, but only once */
8294 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
8295 && !CLASS_LOADED_P (TREE_TYPE (decl)))
8296 CHECK_METHODS (decl);
8297 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8298 safe_layout_class (TREE_TYPE (decl));
8303 /* Resolve a class, returns its decl but doesn't perform any
8304 layout. The current parsing context is saved and restored */
8307 resolve_no_layout (name, cl)
8311 BUILD_PTR_FROM_NAME (ptr, name);
8312 java_parser_context_save_global ();
8313 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8314 java_parser_context_restore_global ();
8319 /* Called when reporting errors. Skip leader '[' in a complex array
8320 type description that failed to be resolved. */
8323 purify_type_name (name)
8326 while (*name && *name == '[')
8331 /* The type CURRENT refers to can't be found. We print error messages. */
8334 complete_class_report_errors (dep)
8339 if (!JDEP_WFL (dep))
8342 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8343 switch (JDEP_KIND (dep))
8347 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8348 purify_type_name (name),
8349 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8353 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8354 purify_type_name (name),
8355 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8357 case JDEP_METHOD: /* Covers arguments */
8359 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8360 purify_type_name (name),
8361 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8362 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8364 case JDEP_METHOD_RETURN: /* Covers return type */
8366 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8367 purify_type_name (name),
8368 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8370 case JDEP_INTERFACE:
8372 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8373 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8374 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8375 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8379 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8380 purify_type_name (IDENTIFIER_POINTER
8381 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8382 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8384 case JDEP_EXCEPTION: /* As specified by `throws' */
8386 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8387 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8390 /* Fix for -Wall. Just break doing nothing. The error will be
8396 /* Return a static string containing the DECL prototype string. If
8397 DECL is a constructor, use the class name instead of the form
8401 get_printable_method_name (decl)
8404 const char *to_return;
8405 tree name = NULL_TREE;
8407 if (DECL_CONSTRUCTOR_P (decl))
8409 name = DECL_NAME (decl);
8410 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8413 to_return = lang_printable_name (decl, 0);
8414 if (DECL_CONSTRUCTOR_P (decl))
8415 DECL_NAME (decl) = name;
8420 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8421 nevertheless needs to be verfied, 1 otherwise. */
8424 reset_method_name (method)
8427 if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8429 /* NAME is just the plain name when Object is being defined */
8430 if (DECL_CONTEXT (method) != object_type_node)
8431 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
8432 init_identifier_node : GET_METHOD_NAME (method));
8439 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8442 java_get_real_method_name (method_decl)
8445 tree method_name = DECL_NAME (method_decl);
8446 if (DECL_CONSTRUCTOR_P (method_decl))
8447 return init_identifier_node;
8449 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8450 and still can be a constructor. FIXME */
8452 /* Don't confuse method only bearing the name of their class as
8454 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8456 && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8457 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8458 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8459 return init_identifier_node;
8461 return EXPR_WFL_NODE (method_name);
8464 /* Track method being redefined inside the same class. As a side
8465 effect, set DECL_NAME to an IDENTIFIER (prior entering this
8466 function it's a FWL, so we can track errors more accurately.) */
8469 check_method_redefinition (class, method)
8473 tree cl = DECL_NAME (method);
8474 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8475 /* decl name of artificial <clinit> and $finit$ doesn't need to be
8476 fixed and checked */
8478 /* Reset the method name before running the check. If it returns 1,
8479 the method doesn't need to be verified with respect to method
8480 redeclaration and we return 0 */
8481 if (reset_method_name (method))
8484 name = DECL_NAME (method);
8485 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8487 if (redef == method)
8489 if (DECL_NAME (redef) == name
8490 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8493 (cl, "Duplicate %s declaration `%s'",
8494 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8495 get_printable_method_name (redef));
8503 check_abstract_method_definitions (do_interface, class_decl, type)
8505 tree class_decl, type;
8507 tree class = TREE_TYPE (class_decl);
8508 tree method, end_type;
8510 end_type = (do_interface ? object_type_node : type);
8511 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8513 tree other_super, other_method, method_sig, method_name;
8515 int end_type_reached = 0;
8517 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8520 /* Now verify that somewhere in between TYPE and CLASS,
8521 abstract method METHOD gets a non abstract definition
8522 that is inherited by CLASS. */
8524 method_sig = build_java_signature (TREE_TYPE (method));
8525 method_name = DECL_NAME (method);
8526 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8527 method_name = EXPR_WFL_NODE (method_name);
8529 other_super = class;
8531 if (other_super == end_type)
8532 end_type_reached = 1;
8535 for (other_method = TYPE_METHODS (other_super); other_method;
8536 other_method = TREE_CHAIN (other_method))
8538 tree s = build_java_signature (TREE_TYPE (other_method));
8539 tree other_name = DECL_NAME (other_method);
8541 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8542 other_name = EXPR_WFL_NODE (other_name);
8543 if (!DECL_CLINIT_P (other_method)
8544 && !DECL_CONSTRUCTOR_P (other_method)
8545 && method_name == other_name
8547 && !METHOD_ABSTRACT (other_method))
8553 other_super = CLASSTYPE_SUPER (other_super);
8554 } while (!end_type_reached);
8556 /* Report that abstract METHOD didn't find an implementation
8557 that CLASS can use. */
8560 char *t = xstrdup (lang_printable_name
8561 (TREE_TYPE (TREE_TYPE (method)), 0));
8562 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8563 tree saved_wfl = NULL_TREE;
8565 if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8567 saved_wfl = DECL_NAME (method);
8568 DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8572 (lookup_cl (class_decl),
8573 "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",
8574 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8575 t, lang_printable_name (method, 0),
8576 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
8577 "interface" : "class"),
8578 IDENTIFIER_POINTER (ccn),
8579 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8580 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8585 DECL_NAME (method) = saved_wfl;
8590 /* Check that CLASS_DECL somehow implements all inherited abstract
8594 java_check_abstract_method_definitions (class_decl)
8597 tree class = TREE_TYPE (class_decl);
8601 if (CLASS_ABSTRACT (class_decl))
8604 /* Check for inherited types */
8607 super = CLASSTYPE_SUPER (super);
8608 check_abstract_method_definitions (0, class_decl, super);
8609 } while (super != object_type_node);
8611 /* Check for implemented interfaces. */
8612 vector = TYPE_BINFO_BASETYPES (class);
8613 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8615 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8616 check_abstract_method_definitions (1, class_decl, super);
8620 /* Check all the types method DECL uses and return 1 if all of them
8621 are now complete, 0 otherwise. This is used to check whether its
8622 safe to build a method signature or not. */
8625 check_method_types_complete (decl)
8628 tree type = TREE_TYPE (decl);
8631 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8634 args = TYPE_ARG_TYPES (type);
8635 if (TREE_CODE (type) == METHOD_TYPE)
8636 args = TREE_CHAIN (args);
8637 for (; args != end_params_node; args = TREE_CHAIN (args))
8638 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8644 /* Check all the methods of CLASS_DECL. Methods are first completed
8645 then checked according to regular method existance rules. If no
8646 constructor for CLASS_DECL were encountered, then build its
8650 java_check_regular_methods (class_decl)
8653 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8655 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8656 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8659 /* It is not necessary to check methods defined in java.lang.Object */
8660 if (class == object_type_node)
8663 if (!TYPE_NVIRTUALS (class))
8664 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8666 /* Should take interfaces into account. FIXME */
8667 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8670 tree method_wfl = DECL_NAME (method);
8673 /* If we previously found something and its name was saved,
8675 if (found && saved_found_wfl)
8677 DECL_NAME (found) = saved_found_wfl;
8678 saved_found_wfl = NULL_TREE;
8681 /* Check for redefinitions */
8682 if (check_method_redefinition (class, method))
8685 /* If we see one constructor a mark so we don't generate the
8686 default one. Also skip other verifications: constructors
8687 can't be inherited hence hiden or overriden */
8688 if (DECL_CONSTRUCTOR_P (method))
8690 saw_constructor = 1;
8694 /* We verify things thrown by the method. They must inherits from
8695 java.lang.Throwable */
8696 for (mthrows = DECL_FUNCTION_THROWS (method);
8697 mthrows; mthrows = TREE_CHAIN (mthrows))
8699 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8701 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8703 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8706 sig = build_java_argument_signature (TREE_TYPE (method));
8707 found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8709 /* Inner class can't declare static methods */
8710 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8712 char *t = xstrdup (lang_printable_name (class, 0));
8714 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8715 lang_printable_name (method, 0), t);
8719 /* Nothing overrides or it's a private method. */
8722 if (METHOD_PRIVATE (found))
8728 /* If found wasn't verified, it's DECL_NAME won't be set properly.
8729 We set it temporarily for the sake of the error report. */
8730 saved_found_wfl = DECL_NAME (found);
8731 reset_method_name (found);
8733 /* If `found' is declared in an interface, make sure the
8734 modifier matches. */
8735 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8736 && clinit_identifier_node != DECL_NAME (found)
8737 && !METHOD_PUBLIC (method))
8739 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8740 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8741 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8742 lang_printable_name (method, 0),
8743 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8746 /* Can't override a method with the same name and different return
8748 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8751 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8754 "Method `%s' was defined with return type `%s' in class `%s'",
8755 lang_printable_name (found, 0), t,
8757 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8761 aflags = get_access_flags_from_decl (found);
8762 /* If the method has default, access in an other package, then
8763 issue a warning that the current method doesn't override the
8764 one that was found elsewhere. Do not issue this warning when
8765 the match was found in java.lang.Object. */
8766 if (DECL_CONTEXT (found) != object_type_node
8767 && ((aflags & ACC_VISIBILITY) == 0)
8768 && !class_in_current_package (DECL_CONTEXT (found))
8769 && !DECL_CLINIT_P (found)
8770 && flag_not_overriding)
8772 parse_warning_context
8773 (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8774 lang_printable_name (found, 0),
8775 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8776 IDENTIFIER_POINTER (DECL_NAME
8777 (TYPE_NAME (DECL_CONTEXT (found)))));
8781 /* Can't override final. Can't override static. */
8782 if (METHOD_FINAL (found) || METHOD_STATIC (found))
8784 /* Static *can* override static */
8785 if (METHOD_STATIC (found) && METHOD_STATIC (method))
8789 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8790 (METHOD_FINAL (found) ? "Final" : "Static"),
8791 lang_printable_name (found, 0),
8792 (METHOD_FINAL (found) ? "final" : "static"),
8794 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8798 /* Static method can't override instance method. */
8799 if (METHOD_STATIC (method))
8803 "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8804 lang_printable_name (found, 0),
8806 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8810 /* - Overriding/hiding public must be public
8811 - Overriding/hiding protected must be protected or public
8812 - If the overriden or hidden method has default (package)
8813 access, then the overriding or hiding method must not be
8814 private; otherwise, a compile-time error occurs. If
8815 `found' belongs to an interface, things have been already
8817 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8818 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8819 || (METHOD_PROTECTED (found)
8820 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8821 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8822 && METHOD_PRIVATE (method))))
8826 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8827 (METHOD_PUBLIC (method) ? "public" :
8828 (METHOD_PRIVATE (method) ? "private" : "protected")),
8829 IDENTIFIER_POINTER (DECL_NAME
8830 (TYPE_NAME (DECL_CONTEXT (found)))));
8834 /* Overriding methods must have compatible `throws' clauses on checked
8835 exceptions, if any */
8836 check_throws_clauses (method, method_wfl, found);
8838 /* Inheriting multiple methods with the same signature. FIXME */
8841 /* Don't forget eventual pending found and saved_found_wfl. Take
8842 into account that we might have exited because we saw an
8843 artificial method as the last entry. */
8845 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8846 DECL_NAME (found) = saved_found_wfl;
8848 if (!TYPE_NVIRTUALS (class))
8849 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8851 /* Search for inherited abstract method not yet implemented in this
8853 java_check_abstract_method_definitions (class_decl);
8855 if (!saw_constructor)
8856 fatal ("No constructor found");
8859 /* Return a non zero value if the `throws' clause of METHOD (if any)
8860 is incompatible with the `throws' clause of FOUND (if any). */
8863 check_throws_clauses (method, method_wfl, found)
8864 tree method, method_wfl, found;
8866 tree mthrows, fthrows;
8868 /* Can't check these things with class loaded from bytecode. FIXME */
8869 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8872 for (mthrows = DECL_FUNCTION_THROWS (method);
8873 mthrows; mthrows = TREE_CHAIN (mthrows))
8875 /* We don't verify unchecked expressions */
8876 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8878 /* Checked expression must be compatible */
8879 for (fthrows = DECL_FUNCTION_THROWS (found);
8880 fthrows; fthrows = TREE_CHAIN (fthrows))
8881 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8886 (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'",
8887 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8888 lang_printable_name (found, 0),
8890 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8895 /* Check abstract method of interface INTERFACE */
8898 java_check_abstract_methods (interface_decl)
8899 tree interface_decl;
8902 tree method, basetype_vec, found;
8903 tree interface = TREE_TYPE (interface_decl);
8905 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8907 tree method_wfl = DECL_NAME (method);
8909 /* 2- Check for double definition inside the defining interface */
8910 if (check_method_redefinition (interface, method))
8913 /* 3- Overriding is OK as far as we preserve the return type and
8914 the thrown exceptions (FIXME) */
8915 found = lookup_java_interface_method2 (interface, method);
8919 tree saved_found_wfl = DECL_NAME (found);
8920 reset_method_name (found);
8921 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8924 "Method `%s' was defined with return type `%s' in class `%s'",
8925 lang_printable_name (found, 0), t,
8927 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8929 DECL_NAME (found) = saved_found_wfl;
8934 /* 4- Inherited methods can't differ by their returned types */
8935 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8937 n = TREE_VEC_LENGTH (basetype_vec);
8938 for (i = 0; i < n; i++)
8940 tree sub_interface_method, sub_interface;
8941 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8944 sub_interface = BINFO_TYPE (vec_elt);
8945 for (sub_interface_method = TYPE_METHODS (sub_interface);
8946 sub_interface_method;
8947 sub_interface_method = TREE_CHAIN (sub_interface_method))
8949 found = lookup_java_interface_method2 (interface,
8950 sub_interface_method);
8951 if (found && (found != sub_interface_method))
8953 tree saved_found_wfl = DECL_NAME (found);
8954 reset_method_name (found);
8956 (lookup_cl (sub_interface_method),
8957 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8958 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8959 lang_printable_name (found, 0),
8961 (DECL_NAME (TYPE_NAME
8962 (DECL_CONTEXT (sub_interface_method)))),
8964 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8965 DECL_NAME (found) = saved_found_wfl;
8971 /* Lookup methods in interfaces using their name and partial
8972 signature. Return a matching method only if their types differ. */
8975 lookup_java_interface_method2 (class, method_decl)
8976 tree class, method_decl;
8979 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8984 n = TREE_VEC_LENGTH (basetype_vec);
8985 for (i = 0; i < n; i++)
8987 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8988 if ((BINFO_TYPE (vec_elt) != object_type_node)
8990 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8993 for (i = 0; i < n; i++)
8995 to_return = lookup_java_interface_method2
8996 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
9004 /* Lookup method using their name and partial signature. Return a
9005 matching method only if their types differ. */
9008 lookup_java_method2 (clas, method_decl, do_interface)
9009 tree clas, method_decl;
9012 tree method, method_signature, method_name, method_type, name;
9014 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
9015 name = DECL_NAME (method_decl);
9016 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9017 EXPR_WFL_NODE (name) : name);
9018 method_type = TREE_TYPE (TREE_TYPE (method_decl));
9020 while (clas != NULL_TREE)
9022 for (method = TYPE_METHODS (clas);
9023 method != NULL_TREE; method = TREE_CHAIN (method))
9025 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
9026 tree name = DECL_NAME (method);
9027 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9028 EXPR_WFL_NODE (name) : name) == method_name
9029 && method_sig == method_signature
9030 && TREE_TYPE (TREE_TYPE (method)) != method_type)
9033 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
9038 /* Return the line that matches DECL line number, and try its best to
9039 position the column number. Used during error reports. */
9045 static tree cl = NULL_TREE;
9051 if (cl == NULL_TREE)
9052 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9054 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9055 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9057 line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9058 EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9060 found = strstr ((const char *)line,
9061 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9063 EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9068 /* Look for a simple name in the single-type import list */
9071 find_name_in_single_imports (name)
9076 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9077 if (TREE_VALUE (node) == name)
9078 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9083 /* Process all single-type import. */
9091 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9093 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9095 /* Don't load twice something already defined. */
9096 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9098 QUALIFIED_P (to_be_found) = 1;
9099 load_class (to_be_found, 0);
9101 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9102 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9104 parse_error_context (TREE_PURPOSE (import),
9105 "Class or interface `%s' not found in import",
9106 IDENTIFIER_POINTER (to_be_found));
9115 /* Possibly find and mark a class imported by a single-type import
9119 find_in_imports (class_type)
9124 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9125 if (TREE_VALUE (import) == TYPE_NAME (class_type))
9127 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9128 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9133 note_possible_classname (name, len)
9138 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9140 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9144 node = ident_subst (name, len, "", '/', '.', "");
9145 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9146 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9150 /* Read a import directory, gathering potential match for further type
9151 references. Indifferently reads a filesystem or a ZIP archive
9155 read_import_dir (wfl)
9158 tree package_id = EXPR_WFL_NODE (wfl);
9159 const char *package_name = IDENTIFIER_POINTER (package_id);
9160 int package_length = IDENTIFIER_LENGTH (package_id);
9162 JCF *saved_jcf = current_jcf;
9167 struct buffer filename[1];
9170 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9172 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9174 BUFFER_INIT (filename);
9175 buffer_grow (filename, package_length + 100);
9177 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9179 const char *entry_name = jcf_path_name (entry);
9180 int entry_length = strlen (entry_name);
9181 if (jcf_path_is_zipfile (entry))
9184 buffer_grow (filename, entry_length);
9185 memcpy (filename->data, entry_name, entry_length - 1);
9186 filename->data[entry_length-1] = '\0';
9187 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9189 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9192 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9193 BUFFER_RESET (filename);
9194 for (k = 0; k < package_length; k++)
9196 char ch = package_name[k];
9197 *filename->ptr++ = ch == '.' ? '/' : ch;
9199 *filename->ptr++ = '/';
9201 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9203 const char *current_entry = ZIPDIR_FILENAME (zipd);
9204 int current_entry_len = zipd->filename_length;
9206 if (current_entry_len >= BUFFER_LENGTH (filename)
9207 && strncmp (filename->data, current_entry,
9208 BUFFER_LENGTH (filename)) != 0)
9210 found |= note_possible_classname (current_entry,
9217 BUFFER_RESET (filename);
9218 buffer_grow (filename, entry_length + package_length + 4);
9219 strcpy (filename->data, entry_name);
9220 filename->ptr = filename->data + entry_length;
9221 for (k = 0; k < package_length; k++)
9223 char ch = package_name[k];
9224 *filename->ptr++ = ch == '.' ? '/' : ch;
9226 *filename->ptr = '\0';
9228 dirp = opendir (filename->data);
9231 *filename->ptr++ = '/';
9236 struct dirent *direntp = readdir (dirp);
9239 d_name = direntp->d_name;
9240 len = strlen (direntp->d_name);
9241 buffer_grow (filename, len+1);
9242 strcpy (filename->ptr, d_name);
9243 found |= note_possible_classname (filename->data + entry_length,
9244 package_length+len+1);
9251 free (filename->data);
9253 /* Here we should have a unified way of retrieving an entry, to be
9257 static int first = 1;
9260 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9265 parse_error_context (wfl, "Package `%s' not found in import",
9267 current_jcf = saved_jcf;
9270 current_jcf = saved_jcf;
9273 /* Possibly find a type in the import on demands specified
9274 types. Returns 1 if an error occured, 0 otherwise. Run throught the
9275 entire list, to detected potential double definitions. */
9278 find_in_imports_on_demand (class_type)
9281 tree node, import, node_to_use = NULL_TREE;
9283 tree cl = NULL_TREE;
9285 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9287 const char *id_name;
9288 obstack_grow (&temporary_obstack,
9289 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9290 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9291 obstack_1grow (&temporary_obstack, '.');
9292 obstack_grow0 (&temporary_obstack,
9293 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9294 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9295 id_name = obstack_finish (&temporary_obstack);
9297 node = maybe_get_identifier (id_name);
9298 if (node && IS_A_CLASSFILE_NAME (node))
9302 cl = TREE_PURPOSE (import);
9310 (import, "Type `%s' also potentially defined in package `%s'",
9311 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9312 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9319 /* Setup lineno so that it refers to the line of the import (in
9320 case we parse a class file and encounter errors */
9322 int saved_lineno = lineno;
9323 lineno = EXPR_WFL_LINENO (cl);
9324 TYPE_NAME (class_type) = node_to_use;
9325 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9326 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9327 /* If there is no DECL set for the class or if the class isn't
9328 loaded and not seen in source yet, the load */
9329 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9330 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9331 load_class (node_to_use, 0);
9332 lineno = saved_lineno;
9333 return check_pkg_class_access (TYPE_NAME (class_type), cl);
9336 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9339 /* Add package NAME to the list of package encountered so far. To
9340 speed up class lookup in do_resolve_class, we make sure a
9341 particular package is added only once. */
9344 register_package (name)
9347 static struct hash_table _pht, *pht = NULL;
9351 hash_table_init (&_pht, hash_newfunc,
9352 java_hash_hash_tree_node, java_hash_compare_tree_node);
9356 if (!hash_lookup (pht, (const hash_table_key) name, FALSE, NULL))
9358 package_list = chainon (package_list, build_tree_list (name, NULL));
9359 hash_lookup (pht, (const hash_table_key) name, TRUE, NULL);
9364 resolve_package (pkg, next)
9368 tree type_name = NULL_TREE;
9369 const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9371 /* The trick is to determine when the package name stops and were
9372 the name of something contained in the package starts. Then we
9373 return a fully qualified name of what we want to get. */
9375 /* Do a quick search on well known package names */
9376 if (!strncmp (name, "java.lang.reflect", 17))
9379 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9380 type_name = lookup_package_type (name, 17);
9382 else if (!strncmp (name, "java.lang", 9))
9384 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9385 type_name = lookup_package_type (name, 9);
9388 /* If we found something here, return */
9392 *next = EXPR_WFL_QUALIFICATION (pkg);
9394 /* Try the current package. */
9395 if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),
9396 IDENTIFIER_LENGTH (ctxp->package)))
9399 lookup_package_type_and_set_next (name,
9400 IDENTIFIER_LENGTH (ctxp->package),
9406 /* Search in imported package */
9407 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9409 tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9410 int len = IDENTIFIER_LENGTH (current_pkg_name);
9411 if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9415 breakdown_qualified (&left, &dummy, current_pkg_name);
9416 len = IDENTIFIER_LENGTH (left);
9417 type_name = lookup_package_type_and_set_next (name, len, next);
9423 /* Try to progressively construct a type name */
9424 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9425 for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg);
9426 current; current = TREE_CHAIN (current))
9428 acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9429 if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9432 /* resolve_package should be used in a loop, hence we
9433 point at this one to naturally process the next one at
9434 the next iteration. */
9443 lookup_package_type_and_set_next (name, len, next)
9449 tree type_name = lookup_package_type (name, len);
9454 ptr = IDENTIFIER_POINTER (type_name);
9455 while (ptr && (ptr = strchr (ptr, '.')))
9457 *next = TREE_CHAIN (*next);
9464 lookup_package_type (name, from)
9469 const char *sub = &name[from+1];
9470 while (*sub != '.' && *sub)
9472 strncpy (subname, name, sub-name);
9473 subname [sub-name] = '\0';
9474 return get_identifier (subname);
9477 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9478 access violations were found, 1 otherwise. */
9481 check_pkg_class_access (class_name, cl)
9487 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9490 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9493 if (!CLASS_PUBLIC (TYPE_NAME (type)))
9495 /* Access to a private class within the same package is
9498 breakdown_qualified (&l, &r, class_name);
9499 if (l == ctxp->package)
9503 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9504 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9505 IDENTIFIER_POINTER (class_name));
9511 /* Local variable declaration. */
9514 declare_local_variables (modifier, type, vlist)
9519 tree decl, current, saved_type;
9520 tree type_wfl = NULL_TREE;
9524 /* Push a new block if statements were seen between the last time we
9525 pushed a block and now. Keep a cound of block to close */
9526 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9528 tree body = GET_CURRENT_BLOCK (current_function_decl);
9529 tree b = enter_block ();
9530 BLOCK_EXPR_ORIGIN (b) = body;
9536 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9537 if (modifier == ACC_FINAL)
9542 (ctxp->modifier_ctx [i],
9543 "Only `final' is allowed as a local variables modifier");
9548 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9549 hold the TYPE value if a new incomplete has to be created (as
9550 opposed to being found already existing and reused). */
9551 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9553 /* If TYPE is fully resolved and we don't have a reference, make one */
9554 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9556 /* Go through all the declared variables */
9557 for (current = vlist, saved_type = type; current;
9558 current = TREE_CHAIN (current), type = saved_type)
9560 tree other, real_type;
9561 tree wfl = TREE_PURPOSE (current);
9562 tree name = EXPR_WFL_NODE (wfl);
9563 tree init = TREE_VALUE (current);
9565 /* Process NAME, as it may specify extra dimension(s) for it */
9566 type = build_array_from_name (type, type_wfl, name, &name);
9568 /* Variable redefinition check */
9569 if ((other = lookup_name_in_blocks (name)))
9571 variable_redefinition_error (wfl, name, TREE_TYPE (other),
9572 DECL_SOURCE_LINE (other));
9576 /* Type adjustment. We may have just readjusted TYPE because
9577 the variable specified more dimensions. Make sure we have
9578 a reference if we can and don't have one already. */
9579 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9581 real_type = GET_REAL_TYPE (type);
9582 /* Never layout this decl. This will be done when its scope
9584 decl = build_decl (VAR_DECL, name, real_type);
9585 LOCAL_FINAL (decl) = final_p;
9586 BLOCK_CHAIN_DECL (decl);
9588 /* If doing xreferencing, replace the line number with the WFL
9591 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9593 /* Don't try to use an INIT statement when an error was found */
9594 if (init && java_error_count)
9597 /* Add the initialization function to the current function's code */
9600 /* Name might have been readjusted */
9601 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9602 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9603 java_method_add_stmt (current_function_decl,
9604 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9608 /* Setup dependency the type of the decl */
9612 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9613 dep = CLASSD_LAST (ctxp->classd_list);
9614 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9617 SOURCE_FRONTEND_DEBUG (("Defined locals"));
9620 /* Called during parsing. Build decls from argument list. */
9623 source_start_java_method (fndecl)
9633 current_function_decl = fndecl;
9635 /* New scope for the function */
9637 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9638 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9640 tree type = TREE_VALUE (tem);
9641 tree name = TREE_PURPOSE (tem);
9643 /* If type is incomplete. Create an incomplete decl and ask for
9644 the decl to be patched later */
9645 if (INCOMPLETE_TYPE_P (type))
9648 tree real_type = GET_REAL_TYPE (type);
9649 parm_decl = build_decl (PARM_DECL, name, real_type);
9650 type = obtain_incomplete_type (type);
9651 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9652 jdep = CLASSD_LAST (ctxp->classd_list);
9653 JDEP_MISC (jdep) = name;
9654 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9657 parm_decl = build_decl (PARM_DECL, name, type);
9659 /* Remember if a local variable was declared final (via its
9660 TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9661 if (ARG_FINAL_P (tem))
9662 LOCAL_FINAL (parm_decl) = 1;
9664 BLOCK_CHAIN_DECL (parm_decl);
9666 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9667 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9669 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9670 DECL_MAX_LOCALS (current_function_decl) = i;
9673 /* Called during parsing. Creates an artificial method declaration. */
9676 create_artificial_method (class, flags, type, name, args)
9679 tree type, name, args;
9683 java_parser_context_save_global ();
9685 mdecl = make_node (FUNCTION_TYPE);
9686 TREE_TYPE (mdecl) = type;
9687 TYPE_ARG_TYPES (mdecl) = args;
9688 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
9689 java_parser_context_restore_global ();
9690 DECL_ARTIFICIAL (mdecl) = 1;
9694 /* Starts the body if an artifical method. */
9697 start_artificial_method_body (mdecl)
9700 DECL_SOURCE_LINE (mdecl) = 1;
9701 DECL_SOURCE_LINE_MERGE (mdecl, 1);
9702 source_start_java_method (mdecl);
9707 end_artificial_method_body (mdecl)
9710 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9714 /* Called during expansion. Push decls formerly built from argument
9715 list so they're usable during expansion. */
9718 expand_start_java_method (fndecl)
9723 current_function_decl = fndecl;
9726 fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9727 announce_function (fndecl);
9729 fprintf (stderr, "]");
9731 pushlevel (1); /* Prepare for a parameter push */
9732 ptr = &DECL_ARGUMENTS (fndecl);
9733 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9736 tree next = TREE_CHAIN (tem);
9737 tree type = TREE_TYPE (tem);
9738 if (PROMOTE_PROTOTYPES
9739 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9740 && INTEGRAL_TYPE_P (type))
9741 type = integer_type_node;
9742 DECL_ARG_TYPE (tem) = type;
9743 layout_decl (tem, 0);
9746 ptr = &TREE_CHAIN (tem);
9750 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9751 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9754 /* Terminate a function and expand its body. */
9757 source_end_java_method ()
9759 tree fndecl = current_function_decl;
9760 int flag_asynchronous_exceptions = asynchronous_exceptions;
9765 java_parser_context_save_global ();
9766 lineno = ctxp->last_ccb_indent1;
9768 /* Set EH language codes */
9769 java_set_exception_lang_code ();
9771 /* Turn function bodies with only a NOP expr null, so they don't get
9772 generated at all and we won't get warnings when using the -W
9774 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9775 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9777 /* Generate function's code */
9778 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9779 && ! flag_emit_class_files
9780 && ! flag_emit_xref)
9781 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9783 /* pop out of its parameters */
9784 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9786 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9788 /* Generate rtl for function exit. */
9789 if (! flag_emit_class_files && ! flag_emit_xref)
9791 lineno = DECL_SOURCE_LINE_LAST (fndecl);
9792 /* Emit catch-finally clauses */
9794 expand_function_end (input_filename, lineno, 0);
9796 /* FIXME: If the current method contains any exception handlers,
9797 force asynchronous_exceptions: this is necessary because signal
9798 handlers in libjava may throw exceptions. This is far from being
9799 a perfect solution, but it's better than doing nothing at all.*/
9801 asynchronous_exceptions = 1;
9803 /* Run the optimizers and output assembler code for this function. */
9804 rest_of_compilation (fndecl);
9807 current_function_decl = NULL_TREE;
9808 permanent_allocation (1);
9809 java_parser_context_restore_global ();
9810 asynchronous_exceptions = flag_asynchronous_exceptions;
9813 /* Record EXPR in the current function block. Complements compound
9814 expression second operand if necessary. */
9817 java_method_add_stmt (fndecl, expr)
9820 if (!GET_CURRENT_BLOCK (fndecl))
9822 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9826 add_stmt_to_block (b, type, stmt)
9829 tree body = BLOCK_EXPR_BODY (b), c;
9831 if (java_error_count)
9834 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9837 BLOCK_EXPR_BODY (b) = c;
9838 TREE_SIDE_EFFECTS (c) = 1;
9842 /* Add STMT to EXISTING if possible, otherwise create a new
9843 COMPOUND_EXPR and add STMT to it. */
9846 add_stmt_to_compound (existing, type, stmt)
9847 tree existing, type, stmt;
9850 return build (COMPOUND_EXPR, type, existing, stmt);
9855 /* Hold THIS for the scope of the current public method decl. */
9856 static tree current_this;
9858 void java_layout_seen_class_methods ()
9860 tree previous_list = all_class_list;
9861 tree end = NULL_TREE;
9866 for (current = previous_list;
9867 current != end; current = TREE_CHAIN (current))
9868 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9870 if (previous_list != all_class_list)
9872 end = previous_list;
9873 previous_list = all_class_list;
9881 java_reorder_fields ()
9883 static tree stop_reordering = NULL_TREE;
9886 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9888 current_class = TREE_TYPE (TREE_VALUE (current));
9890 if (current_class == stop_reordering)
9893 /* Reverse the fields, but leave the dummy field in front.
9894 Fields are already ordered for Object and Class */
9895 if (TYPE_FIELDS (current_class) && current_class != object_type_node
9896 && current_class != class_type_node)
9898 /* If the dummy field is there, reverse the right fields and
9899 just layout the type for proper fields offset */
9900 if (!DECL_NAME (TYPE_FIELDS (current_class)))
9902 tree fields = TYPE_FIELDS (current_class);
9903 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9904 TYPE_SIZE (current_class) = NULL_TREE;
9906 /* We don't have a dummy field, we need to layout the class,
9907 after having reversed the fields */
9910 TYPE_FIELDS (current_class) =
9911 nreverse (TYPE_FIELDS (current_class));
9912 TYPE_SIZE (current_class) = NULL_TREE;
9916 stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9919 /* Layout the methods of all classes loaded in one way on an
9920 other. Check methods of source parsed classes. Then reorder the
9921 fields and layout the classes or the type of all source parsed
9925 java_layout_classes ()
9928 int save_error_count = java_error_count;
9930 /* Layout the methods of all classes seen so far */
9931 java_layout_seen_class_methods ();
9932 java_parse_abort_on_error ();
9933 all_class_list = NULL_TREE;
9935 /* Then check the methods of all parsed classes */
9936 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9937 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9938 CHECK_METHODS (TREE_VALUE (current));
9939 java_parse_abort_on_error ();
9941 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9943 current_class = TREE_TYPE (TREE_VALUE (current));
9944 layout_class (current_class);
9946 /* From now on, the class is considered completely loaded */
9947 CLASS_LOADED_P (current_class) = 1;
9949 /* Error reported by the caller */
9950 if (java_error_count)
9954 /* We might have reloaded classes durign the process of laying out
9955 classes for code generation. We must layout the methods of those
9956 late additions, as constructor checks might use them */
9957 java_layout_seen_class_methods ();
9958 java_parse_abort_on_error ();
9961 /* Expand methods in the current set of classes rememebered for
9965 java_complete_expand_classes ()
9969 do_not_fold = flag_emit_xref;
9971 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9972 if (!INNER_CLASS_DECL_P (current))
9973 java_complete_expand_class (current);
9976 /* Expand the methods found in OUTER, starting first by OUTER's inner
9980 java_complete_expand_class (outer)
9985 set_nested_class_simple_name_value (outer, 1); /* Set */
9987 /* We need to go after all inner classes and start expanding them,
9988 starting with most nested ones. We have to do that because nested
9989 classes might add functions to outer classes */
9991 for (inner_list = DECL_INNER_CLASS_LIST (outer);
9992 inner_list; inner_list = TREE_CHAIN (inner_list))
9993 java_complete_expand_class (TREE_PURPOSE (inner_list));
9995 java_complete_expand_methods (outer);
9996 set_nested_class_simple_name_value (outer, 0); /* Reset */
9999 /* Expand methods registered in CLASS_DECL. The general idea is that
10000 we expand regular methods first. This allows us get an estimate on
10001 how outer context local alias fields are really used so we can add
10002 to the constructor just enough code to initialize them properly (it
10003 also lets us generate $finit$ correctly.) Then we expand the
10004 constructors and then <clinit>. */
10007 java_complete_expand_methods (class_decl)
10010 tree clinit, finit, decl, first_decl;
10012 current_class = TREE_TYPE (class_decl);
10014 /* Initialize a new constant pool */
10015 init_outgoing_cpool ();
10017 /* Pre-expand <clinit> to figure whether we really need it or
10018 not. If we do need it, we pre-expand the static fields so they're
10019 ready to be used somewhere else. <clinit> will be fully expanded
10020 after we processed the constructors. */
10021 first_decl = TYPE_METHODS (current_class);
10022 clinit = maybe_generate_pre_expand_clinit (current_class);
10024 /* Then generate $finit$ (if we need to) because constructor will
10026 if (TYPE_FINIT_STMT_LIST (current_class))
10028 finit = generate_finit (current_class);
10029 java_complete_expand_method (finit);
10032 /* Now do the constructors */
10033 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
10037 if (!DECL_CONSTRUCTOR_P (decl))
10040 no_body = !DECL_FUNCTION_BODY (decl);
10041 /* Don't generate debug info on line zero when expanding a
10042 generated constructor. */
10044 restore_line_number_status (1);
10046 java_complete_expand_method (decl);
10049 restore_line_number_status (0);
10052 /* First, do the ordinary methods. */
10053 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
10055 /* Skip abstract or native methods -- but do handle native
10056 methods when generating JNI stubs. */
10057 if (METHOD_ABSTRACT (decl)
10058 || (! flag_jni && METHOD_NATIVE (decl))
10059 || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
10062 if (METHOD_NATIVE (decl))
10064 tree body = build_jni_stub (decl);
10065 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl)) = body;
10068 java_complete_expand_method (decl);
10071 /* If there is indeed a <clinit>, fully expand it now */
10074 /* Prevent the use of `this' inside <clinit> */
10075 ctxp->explicit_constructor_p = 1;
10076 java_complete_expand_method (clinit);
10077 ctxp->explicit_constructor_p = 0;
10080 /* We might have generated a class$ that we now want to expand */
10081 if (TYPE_DOT_CLASS (current_class))
10082 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10084 /* Now verify constructor circularity (stop after the first one we
10086 if (!CLASS_INTERFACE (class_decl))
10087 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10088 if (DECL_CONSTRUCTOR_P (decl)
10089 && verify_constructor_circularity (decl, decl))
10092 /* Save the constant pool. We'll need to restore it later. */
10093 TYPE_CPOOL (current_class) = outgoing_cpool;
10096 /* Hold a list of catch clauses list. The first element of this list is
10097 the list of the catch clauses of the currently analysed try block. */
10098 static tree currently_caught_type_list;
10100 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10101 safely used in some other methods/constructors. */
10104 maybe_generate_pre_expand_clinit (class_type)
10107 tree current, mdecl;
10109 if (!TYPE_CLINIT_STMT_LIST (class_type))
10112 /* Go through all static fields and pre expand them */
10113 for (current = TYPE_FIELDS (class_type); current;
10114 current = TREE_CHAIN (current))
10115 if (FIELD_STATIC (current))
10116 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10118 /* Then build the <clinit> method */
10119 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10120 clinit_identifier_node, end_params_node);
10121 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10123 start_artificial_method_body (mdecl);
10125 /* We process the list of assignment we produced as the result of
10126 the declaration of initialized static field and add them as
10127 statement to the <clinit> method. */
10128 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10129 current = TREE_CHAIN (current))
10131 tree stmt = current;
10132 /* We build the assignment expression that will initialize the
10133 field to its value. There are strict rules on static
10134 initializers (8.5). FIXME */
10135 if (TREE_CODE (stmt) != BLOCK)
10136 stmt = build_debugable_stmt (EXPR_WFL_LINECOL (stmt), stmt);
10137 java_method_add_stmt (mdecl, stmt);
10140 end_artificial_method_body (mdecl);
10142 /* Now we want to place <clinit> as the last method (because we need
10143 it at least for interface so that it doesn't interfere with the
10144 dispatch table based lookup. */
10145 if (TREE_CHAIN (TYPE_METHODS (class_type)))
10147 current = TREE_CHAIN (TYPE_METHODS (class_type));
10148 TYPE_METHODS (class_type) = current;
10150 while (TREE_CHAIN (current))
10151 current = TREE_CHAIN (current);
10153 TREE_CHAIN (current) = mdecl;
10154 TREE_CHAIN (mdecl) = NULL_TREE;
10160 /* See whether we could get rid of <clinit>. Criteria are: all static
10161 final fields have constant initial values and the body of <clinit>
10162 is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
10165 maybe_yank_clinit (mdecl)
10168 tree type, current;
10171 if (!DECL_CLINIT_P (mdecl))
10174 /* If the body isn't empty, then we keep <clinit> */
10175 fbody = DECL_FUNCTION_BODY (mdecl);
10176 if ((bbody = BLOCK_EXPR_BODY (fbody)))
10177 bbody = BLOCK_EXPR_BODY (bbody);
10178 if (bbody && bbody != empty_stmt_node)
10181 type = DECL_CONTEXT (mdecl);
10182 current = TYPE_FIELDS (type);
10184 for (current = (current ? TREE_CHAIN (current) : current);
10185 current; current = TREE_CHAIN (current))
10186 if (!(FIELD_STATIC (current) && FIELD_FINAL (current)
10187 && DECL_INITIAL (current) && TREE_CONSTANT (DECL_INITIAL (current))))
10193 /* Get rid of <clinit> in the class' list of methods */
10194 if (TYPE_METHODS (type) == mdecl)
10195 TYPE_METHODS (type) = TREE_CHAIN (mdecl);
10197 for (current = TYPE_METHODS (type); current;
10198 current = TREE_CHAIN (current))
10199 if (TREE_CHAIN (current) == mdecl)
10201 TREE_CHAIN (current) = TREE_CHAIN (mdecl);
10209 /* Complete and expand a method. */
10212 java_complete_expand_method (mdecl)
10215 int yank_clinit = 0;
10217 current_function_decl = mdecl;
10218 /* Fix constructors before expanding them */
10219 if (DECL_CONSTRUCTOR_P (mdecl))
10220 fix_constructors (mdecl);
10222 /* Expand functions that have a body */
10223 if (DECL_FUNCTION_BODY (mdecl))
10225 tree fbody = DECL_FUNCTION_BODY (mdecl);
10226 tree block_body = BLOCK_EXPR_BODY (fbody);
10227 tree exception_copy = NULL_TREE;
10228 expand_start_java_method (mdecl);
10229 build_result_decl (mdecl);
10232 = (!METHOD_STATIC (mdecl) ?
10233 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10235 /* Purge the `throws' list of unchecked exceptions. If we're
10236 doing xref, save a copy of the list and re-install it
10238 if (flag_emit_xref)
10239 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10241 purge_unchecked_exceptions (mdecl);
10243 /* Install exceptions thrown with `throws' */
10244 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10246 if (block_body != NULL_TREE)
10248 block_body = java_complete_tree (block_body);
10250 if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
10251 check_for_initialization (block_body);
10252 ctxp->explicit_constructor_p = 0;
10255 BLOCK_EXPR_BODY (fbody) = block_body;
10257 /* If we saw a return but couldn't evaluate it properly, we'll
10258 have an error_mark_node here. */
10259 if (block_body != error_mark_node
10260 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10261 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10262 && !flag_emit_xref)
10263 missing_return_error (current_function_decl);
10265 /* Check wether we could just get rid of clinit, now the picture
10267 if (!(yank_clinit = maybe_yank_clinit (mdecl)))
10268 complete_start_java_method (mdecl);
10270 /* Don't go any further if we've found error(s) during the
10272 if (!java_error_count && !yank_clinit)
10273 source_end_java_method ();
10276 if (java_error_count)
10277 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10278 poplevel (1, 0, 1);
10281 /* Pop the exceptions and sanity check */
10283 if (currently_caught_type_list)
10284 fatal ("Exception list non empty - java_complete_expand_method");
10286 if (flag_emit_xref)
10287 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10293 /* This section of the code deals with accessing enclosing context
10294 fields either directly by using the relevant access to this$<n> or
10295 by invoking an access method crafted for that purpose. */
10297 /* Build the necessary access from an inner class to an outer
10298 class. This routine could be optimized to cache previous result
10299 (decl, current_class and returned access). When an access method
10300 needs to be generated, it always takes the form of a read. It might
10301 be later turned into a write by calling outer_field_access_fix. */
10304 build_outer_field_access (id, decl)
10307 tree access = NULL_TREE;
10308 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10310 /* If decl's class is the direct outer class of the current_class,
10311 build the access as `this$<n>.<field>'. Not that we will break
10312 the `private' barrier if we're not emitting bytecodes. */
10313 if (ctx == DECL_CONTEXT (decl)
10314 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10316 tree thisn = build_current_thisn (current_class);
10317 access = make_qualified_primary (build_wfl_node (thisn),
10318 id, EXPR_WFL_LINECOL (id));
10320 /* Otherwise, generate access methods to outer this and access the
10321 field (either using an access method or by direct access.) */
10324 int lc = EXPR_WFL_LINECOL (id);
10326 /* Now we chain the required number of calls to the access$0 to
10327 get a hold to the enclosing instance we need, and the we
10328 build the field access. */
10329 access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10331 /* If the field is private and we're generating bytecode, then
10332 we generate an access method */
10333 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10335 tree name = build_outer_field_access_methods (decl);
10336 access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10337 name, access, NULL_TREE);
10339 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10340 Once again we break the `private' access rule from a foreign
10343 access = make_qualified_primary (access, id, lc);
10345 return resolve_expression_name (access, NULL);
10348 /* Return a non zero value if NODE describes an outer field inner
10352 outer_field_access_p (type, decl)
10355 if (!INNER_CLASS_TYPE_P (type)
10356 || TREE_CODE (decl) != FIELD_DECL
10357 || DECL_CONTEXT (decl) == type)
10360 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10361 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10363 if (type == DECL_CONTEXT (decl))
10365 if (!DECL_CONTEXT (TYPE_NAME (type)))
10372 /* Return a non zero value if NODE represents an outer field inner
10373 access that was been already expanded. As a side effect, it returns
10374 the name of the field being accessed and the argument passed to the
10375 access function, suitable for a regeneration of the access method
10376 call if necessary. */
10379 outer_field_expanded_access_p (node, name, arg_type, arg)
10380 tree node, *name, *arg_type, *arg;
10382 int identified = 0;
10384 if (TREE_CODE (node) != CALL_EXPR)
10387 /* Well, gcj generates slightly different tree nodes when compiling
10388 to native or bytecodes. It's the case for function calls. */
10390 if (flag_emit_class_files
10391 && TREE_CODE (node) == CALL_EXPR
10392 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10394 else if (!flag_emit_class_files)
10396 node = TREE_OPERAND (node, 0);
10398 if (node && TREE_OPERAND (node, 0)
10399 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10401 node = TREE_OPERAND (node, 0);
10402 if (TREE_OPERAND (node, 0)
10403 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10404 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
10405 (DECL_NAME (TREE_OPERAND (node, 0)))))
10410 if (identified && name && arg_type && arg)
10412 tree argument = TREE_OPERAND (node, 1);
10413 *name = DECL_NAME (TREE_OPERAND (node, 0));
10414 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10415 *arg = TREE_VALUE (argument);
10420 /* Detect in NODE an outer field read access from an inner class and
10421 transform it into a write with RHS as an argument. This function is
10422 called from the java_complete_lhs when an assignment to a LHS can
10426 outer_field_access_fix (wfl, node, rhs)
10427 tree wfl, node, rhs;
10429 tree name, arg_type, arg;
10431 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10433 /* At any rate, check whether we're trying to assign a value to
10435 tree accessed = (JDECL_P (node) ? node :
10436 (TREE_CODE (node) == COMPONENT_REF ?
10437 TREE_OPERAND (node, 1) : node));
10438 if (check_final_assignment (accessed, wfl))
10439 return error_mark_node;
10441 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
10442 arg_type, name, arg, rhs);
10443 return java_complete_tree (node);
10448 /* Construct the expression that calls an access method:
10449 <type>.access$<n>(<arg1> [, <arg2>]);
10451 ARG2 can be NULL and will be omitted in that case. It will denote a
10455 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10457 tree type, access_method_name, arg1, arg2;
10459 tree args, cn, access;
10461 args = arg1 ? arg1 :
10462 build_wfl_node (build_current_thisn (current_class));
10463 args = build_tree_list (NULL_TREE, args);
10466 args = tree_cons (NULL_TREE, arg2, args);
10468 access = build_method_invocation (build_wfl_node (access_method_name), args);
10469 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10470 return make_qualified_primary (cn, access, lc);
10474 build_new_access_id ()
10476 static int access_n_counter = 1;
10479 sprintf (buffer, "access$%d", access_n_counter++);
10480 return get_identifier (buffer);
10483 /* Create the static access functions for the outer field DECL. We define a
10485 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10486 return inst$.field;
10488 and a write access:
10489 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10490 TREE_TYPE (<field>) value$) {
10491 return inst$.field = value$;
10493 We should have a usage flags on the DECL so we can lazily turn the ones
10494 we're using for code generation. FIXME.
10498 build_outer_field_access_methods (decl)
10501 tree id, args, stmt, mdecl;
10503 /* Check point, to be removed. FIXME */
10504 if (FIELD_INNER_ACCESS (decl)
10505 && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10508 if (FIELD_INNER_ACCESS (decl))
10509 return FIELD_INNER_ACCESS (decl);
10511 push_obstacks (&permanent_obstack, &permanent_obstack);
10513 /* Create the identifier and a function named after it. */
10514 id = build_new_access_id ();
10516 /* The identifier is marked as bearing the name of a generated write
10517 access function for outer field accessed from inner classes. */
10518 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10520 /* Create the read access */
10521 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10522 TREE_CHAIN (args) = end_params_node;
10523 stmt = make_qualified_primary (build_wfl_node (inst_id),
10524 build_wfl_node (DECL_NAME (decl)), 0);
10525 stmt = build_return (0, stmt);
10526 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10527 TREE_TYPE (decl), id, args, stmt);
10528 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10530 /* Create the write access method */
10531 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10532 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10533 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10534 stmt = make_qualified_primary (build_wfl_node (inst_id),
10535 build_wfl_node (DECL_NAME (decl)), 0);
10536 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10537 build_wfl_node (wpv_id)));
10539 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10540 TREE_TYPE (decl), id, args, stmt);
10541 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10544 /* Return the access name */
10545 return FIELD_INNER_ACCESS (decl) = id;
10548 /* Build an field access method NAME. */
10551 build_outer_field_access_method (class, type, name, args, body)
10552 tree class, type, name, args, body;
10554 tree saved_current_function_decl, mdecl;
10556 /* Create the method */
10557 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10558 fix_method_argument_names (args, mdecl);
10559 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10561 /* Attach the method body. */
10562 saved_current_function_decl = current_function_decl;
10563 start_artificial_method_body (mdecl);
10564 java_method_add_stmt (mdecl, body);
10565 end_artificial_method_body (mdecl);
10566 current_function_decl = saved_current_function_decl;
10572 /* This section deals with building access function necessary for
10573 certain kinds of method invocation from inner classes. */
10576 build_outer_method_access_method (decl)
10579 tree saved_current_function_decl, mdecl;
10580 tree args = NULL_TREE, call_args = NULL_TREE;
10581 tree carg, id, body, class;
10583 int parm_id_count = 0;
10585 /* Test this abort with an access to a private field */
10586 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10589 /* Check the cache first */
10590 if (DECL_FUNCTION_INNER_ACCESS (decl))
10591 return DECL_FUNCTION_INNER_ACCESS (decl);
10593 class = DECL_CONTEXT (decl);
10595 /* Obtain an access identifier and mark it */
10596 id = build_new_access_id ();
10597 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10599 push_obstacks (&permanent_obstack, &permanent_obstack);
10601 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10602 /* Create the arguments, as much as the original */
10603 for (; carg && carg != end_params_node;
10604 carg = TREE_CHAIN (carg))
10606 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10607 args = chainon (args, build_tree_list (get_identifier (buffer),
10608 TREE_VALUE (carg)));
10610 args = chainon (args, end_params_node);
10612 /* Create the method */
10613 mdecl = create_artificial_method (class, ACC_STATIC,
10614 TREE_TYPE (TREE_TYPE (decl)), id, args);
10615 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10616 /* There is a potential bug here. We should be able to use
10617 fix_method_argument_names, but then arg names get mixed up and
10618 eventually a constructor will have its this$0 altered and the
10619 outer context won't be assignment properly. The test case is
10621 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10623 /* Attach the method body. */
10624 saved_current_function_decl = current_function_decl;
10625 start_artificial_method_body (mdecl);
10627 /* The actual method invocation uses the same args. When invoking a
10628 static methods that way, we don't want to skip the first
10631 if (!METHOD_STATIC (decl))
10632 carg = TREE_CHAIN (carg);
10633 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10634 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10637 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
10639 if (!METHOD_STATIC (decl))
10640 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
10642 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10643 body = build_return (0, body);
10644 java_method_add_stmt (mdecl,body);
10645 end_artificial_method_body (mdecl);
10646 current_function_decl = saved_current_function_decl;
10649 /* Back tag the access function so it know what it accesses */
10650 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10652 /* Tag the current method so it knows it has an access generated */
10653 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10657 /* This section of the code deals with building expressions to access
10658 the enclosing instance of an inner class. The enclosing instance is
10659 kept in a generated field called this$<n>, with <n> being the
10660 inner class nesting level (starting from 0.) */
10662 /* Build an access to a given this$<n>, possibly by chaining access
10663 call to others. Access methods to this$<n> are build on the fly if
10667 build_access_to_thisn (from, to, lc)
10671 tree access = NULL_TREE;
10675 tree access0_wfl, cn;
10677 maybe_build_thisn_access_method (from);
10678 access0_wfl = build_wfl_node (access0_identifier_node);
10679 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10680 EXPR_WFL_LINECOL (access0_wfl) = lc;
10684 access = build_current_thisn (current_class);
10685 access = build_wfl_node (access);
10687 access = build_tree_list (NULL_TREE, access);
10688 access = build_method_invocation (access0_wfl, access);
10689 access = make_qualified_primary (cn, access, lc);
10691 from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10696 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10697 is returned if nothing needs to be generated. Otherwise, the method
10698 generated and a method decl is returned.
10700 NOTE: These generated methods should be declared in a class file
10701 attribute so that they can't be referred to directly. */
10704 maybe_build_thisn_access_method (type)
10707 tree mdecl, args, stmt, rtype;
10708 tree saved_current_function_decl;
10710 /* If TYPE is a top-level class, no access method is required.
10711 If there already is such an access method, bail out. */
10712 if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10715 /* We generate the method. The method looks like:
10716 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10718 push_obstacks (&permanent_obstack, &permanent_obstack);
10719 args = build_tree_list (inst_id, build_pointer_type (type));
10720 TREE_CHAIN (args) = end_params_node;
10721 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10722 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10723 access0_identifier_node, args);
10724 fix_method_argument_names (args, mdecl);
10725 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10726 stmt = build_current_thisn (type);
10727 stmt = make_qualified_primary (build_wfl_node (inst_id),
10728 build_wfl_node (stmt), 0);
10729 stmt = build_return (0, stmt);
10731 saved_current_function_decl = current_function_decl;
10732 start_artificial_method_body (mdecl);
10733 java_method_add_stmt (mdecl, stmt);
10734 end_artificial_method_body (mdecl);
10735 current_function_decl = saved_current_function_decl;
10738 CLASS_ACCESS0_GENERATED_P (type) = 1;
10743 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10744 the first level of innerclassing. this$1 for the next one, etc...
10745 This function can be invoked with TYPE to NULL, available and then
10746 has to count the parser context. */
10749 build_current_thisn (type)
10752 static int saved_i = -1;
10753 static tree saved_thisn = NULL_TREE;
10761 static tree saved_type = NULL_TREE;
10762 static int saved_type_i = 0;
10764 if (type == saved_type)
10768 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
10769 decl; decl = DECL_CONTEXT (decl), i++)
10777 i = list_length (GET_CPC_LIST ())-2;
10780 return saved_thisn;
10782 sprintf (buffer, "this$%d", i);
10784 saved_thisn = get_identifier (buffer);
10785 return saved_thisn;
10788 /* Return the assignement to the hidden enclosing context `this$<n>'
10789 by the second incoming parameter to the innerclass constructor. The
10790 form used is `this.this$<n> = this$<n>;'. */
10793 build_thisn_assign ()
10795 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10797 tree thisn = build_current_thisn (current_class);
10798 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10799 build_wfl_node (thisn), 0);
10800 tree rhs = build_wfl_node (thisn);
10801 EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10802 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10808 /* Building the synthetic `class$' used to implement the `.class' 1.1
10809 extension for non primitive types. This method looks like:
10811 static Class class$(String type) throws NoClassDefFoundError
10813 try {return (java.lang.Class.forName (String));}
10814 catch (ClassNotFoundException e) {
10815 throw new NoClassDefFoundError(e.getMessage());}
10819 build_dot_class_method (class)
10822 #define BWF(S) build_wfl_node (get_identifier ((S)))
10823 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10824 tree args, tmp, saved_current_function_decl, mdecl;
10825 tree stmt, throw_stmt, catch, catch_block, try_block;
10826 tree catch_clause_param;
10827 tree class_not_found_exception, no_class_def_found_error;
10829 static tree get_message_wfl, type_parm_wfl;
10831 if (!get_message_wfl)
10833 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10834 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10837 /* Build the arguments */
10838 args = build_tree_list (get_identifier ("type$"),
10839 build_pointer_type (string_type_node));
10840 TREE_CHAIN (args) = end_params_node;
10842 /* Build the qualified name java.lang.Class.forName */
10843 tmp = MQN (MQN (MQN (BWF ("java"),
10844 BWF ("lang")), BWF ("Class")), BWF ("forName"));
10846 /* For things we have to catch and throw */
10847 class_not_found_exception =
10848 lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10849 no_class_def_found_error =
10850 lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10851 load_class (class_not_found_exception, 1);
10852 load_class (no_class_def_found_error, 1);
10854 /* Create the "class$" function */
10855 mdecl = create_artificial_method (class, ACC_STATIC,
10856 build_pointer_type (class_type_node),
10857 get_identifier ("class$"), args);
10858 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10859 no_class_def_found_error);
10861 /* We start by building the try block. We need to build:
10862 return (java.lang.Class.forName (type)); */
10863 stmt = build_method_invocation (tmp,
10864 build_tree_list (NULL_TREE, type_parm_wfl));
10865 stmt = build_return (0, stmt);
10866 /* Put it in a block. That's the try block */
10867 try_block = build_expr_block (stmt, NULL_TREE);
10869 /* Now onto the catch block. We start by building the expression
10870 throwing a new exception:
10871 throw new NoClassDefFoundError (_.getMessage); */
10872 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
10873 get_message_wfl, 0);
10874 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10876 /* Build new NoClassDefFoundError (_.getMessage) */
10877 throw_stmt = build_new_invocation
10878 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10879 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10881 /* Build the throw, (it's too early to use BUILD_THROW) */
10882 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10884 /* Build the catch block to encapsulate all this. We begin by
10885 building an decl for the catch clause parameter and link it to
10886 newly created block, the catch block. */
10887 catch_clause_param =
10888 build_decl (VAR_DECL, wpv_id,
10889 build_pointer_type (class_not_found_exception));
10890 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10892 /* We initialize the variable with the exception handler. */
10893 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10894 soft_exceptioninfo_call_node);
10895 add_stmt_to_block (catch_block, NULL_TREE, catch);
10897 /* We add the statement throwing the new exception */
10898 add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10900 /* Build a catch expression for all this */
10901 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10903 /* Build the try/catch sequence */
10904 stmt = build_try_statement (0, try_block, catch_block);
10906 fix_method_argument_names (args, mdecl);
10907 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10908 saved_current_function_decl = current_function_decl;
10909 start_artificial_method_body (mdecl);
10910 java_method_add_stmt (mdecl, stmt);
10911 end_artificial_method_body (mdecl);
10912 current_function_decl = saved_current_function_decl;
10913 TYPE_DOT_CLASS (class) = mdecl;
10919 build_dot_class_method_invocation (name)
10922 tree s = make_node (STRING_CST);
10923 TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10924 TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10925 TREE_STRING_LENGTH (s)+1);
10926 strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10927 return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10928 build_tree_list (NULL_TREE, s));
10931 /* This section of the code deals with constructor. */
10933 /* Craft a body for default constructor. Patch existing constructor
10934 bodies with call to super() and field initialization statements if
10938 fix_constructors (mdecl)
10941 tree body = DECL_FUNCTION_BODY (mdecl);
10942 tree thisn_assign, compound = NULL_TREE;
10943 tree class_type = DECL_CONTEXT (mdecl);
10947 /* It is an error for the compiler to generate a default
10948 constructor if the superclass doesn't have a constructor that
10949 takes no argument, or the same args for an anonymous class */
10950 if (verify_constructor_super (mdecl))
10952 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10953 tree save = DECL_NAME (mdecl);
10954 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10955 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10956 parse_error_context
10957 (lookup_cl (TYPE_NAME (class_type)),
10958 "No constructor matching `%s' found in class `%s'",
10959 lang_printable_name (mdecl, 0), n);
10960 DECL_NAME (mdecl) = save;
10963 /* The constructor body must be crafted by hand. It's the
10964 constructor we defined when we realize we didn't have the
10965 CLASSNAME() constructor */
10966 start_artificial_method_body (mdecl);
10968 /* We don't generate a super constructor invocation if we're
10969 compiling java.lang.Object. build_super_invocation takes care
10971 compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10973 /* Insert the instance initializer block right here, after the
10974 super invocation. */
10975 add_instance_initializer (mdecl);
10977 /* Insert an assignment to the this$<n> hidden field, if
10979 if ((thisn_assign = build_thisn_assign ()))
10980 java_method_add_stmt (mdecl, thisn_assign);
10982 end_artificial_method_body (mdecl);
10984 /* Search for an explicit constructor invocation */
10988 tree main_block = BLOCK_EXPR_BODY (body);
10991 switch (TREE_CODE (body))
10994 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10997 case COMPOUND_EXPR:
10998 case EXPR_WITH_FILE_LOCATION:
10999 body = TREE_OPERAND (body, 0);
11002 body = BLOCK_EXPR_BODY (body);
11008 /* The constructor is missing an invocation of super() */
11010 compound = add_stmt_to_compound (compound, NULL_TREE,
11011 build_super_invocation (mdecl));
11013 /* Insert the instance initializer block right here, after the
11014 super invocation. */
11015 add_instance_initializer (mdecl);
11017 /* Generate the assignment to this$<n>, if necessary */
11018 if ((thisn_assign = build_thisn_assign ()))
11019 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
11021 /* Fix the constructor main block if we're adding extra stmts */
11024 compound = add_stmt_to_compound (compound, NULL_TREE,
11025 BLOCK_EXPR_BODY (main_block));
11026 BLOCK_EXPR_BODY (main_block) = compound;
11031 /* Browse constructors in the super class, searching for a constructor
11032 that doesn't take any argument. Return 0 if one is found, 1
11033 otherwise. If the current class is an anonymous inner class, look
11034 for something that has the same signature. */
11037 verify_constructor_super (mdecl)
11040 tree class = CLASSTYPE_SUPER (current_class);
11041 int super_inner = PURE_INNER_CLASS_TYPE_P (class);
11047 if (ANONYMOUS_CLASS_P (current_class))
11049 tree mdecl_arg_type;
11050 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
11051 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11052 if (DECL_CONSTRUCTOR_P (sdecl))
11054 tree arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11056 arg_type = TREE_CHAIN (arg_type);
11057 for (; (arg_type != end_params_node
11058 && mdecl_arg_type != end_params_node);
11059 arg_type = TREE_CHAIN (arg_type),
11060 mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
11061 if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
11064 if (arg_type == end_params_node &&
11065 mdecl_arg_type == end_params_node)
11071 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11073 tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11075 arg = TREE_CHAIN (arg);
11076 if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
11083 /* Generate code for all context remembered for code generation. */
11086 java_expand_classes ()
11088 int save_error_count = 0;
11089 static struct parser_ctxt *saved_ctxp = NULL;
11091 java_parse_abort_on_error ();
11092 if (!(ctxp = ctxp_for_generation))
11094 java_layout_classes ();
11095 java_parse_abort_on_error ();
11097 saved_ctxp = ctxp_for_generation;
11098 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11100 ctxp = ctxp_for_generation;
11101 lang_init_source (2); /* Error msgs have method prototypes */
11102 java_complete_expand_classes (); /* Complete and expand classes */
11103 java_parse_abort_on_error ();
11106 /* Find anonymous classes and expand their constructor, now they
11107 have been fixed. */
11108 for (ctxp_for_generation = saved_ctxp;
11109 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11112 ctxp = ctxp_for_generation;
11113 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11115 current_class = TREE_TYPE (current);
11116 if (ANONYMOUS_CLASS_P (current_class))
11119 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
11121 if (DECL_CONSTRUCTOR_P (d))
11123 restore_line_number_status (1);
11124 reset_method_name (d);
11125 java_complete_expand_method (d);
11126 restore_line_number_status (0);
11127 break; /* We now there are no other ones */
11134 /* If we've found error at that stage, don't try to generate
11135 anything, unless we're emitting xrefs or checking the syntax only
11136 (but not using -fsyntax-only for the purpose of generating
11138 if (java_error_count && !flag_emit_xref
11139 && (!flag_syntax_only && !flag_emit_class_files))
11142 /* Now things are stable, go for generation of the class data. */
11143 for (ctxp_for_generation = saved_ctxp;
11144 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11147 ctxp = ctxp_for_generation;
11148 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11150 current_class = TREE_TYPE (current);
11151 outgoing_cpool = TYPE_CPOOL (current_class);
11152 if (flag_emit_class_files)
11153 write_classfile (current_class);
11154 if (flag_emit_xref)
11155 expand_xref (current_class);
11156 else if (! flag_syntax_only)
11162 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11163 a tree list node containing RIGHT. Fore coming RIGHTs will be
11164 chained to this hook. LOCATION contains the location of the
11165 separating `.' operator. */
11168 make_qualified_primary (primary, right, location)
11169 tree primary, right;
11174 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11175 wfl = build_wfl_wrap (primary, location);
11179 /* If wfl wasn't qualified, we build a first anchor */
11180 if (!EXPR_WFL_QUALIFICATION (wfl))
11181 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11184 /* And chain them */
11185 EXPR_WFL_LINECOL (right) = location;
11186 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11187 PRIMARY_P (wfl) = 1;
11191 /* Simple merge of two name separated by a `.' */
11194 merge_qualified_name (left, right)
11198 if (!left && !right)
11207 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11208 IDENTIFIER_LENGTH (left));
11209 obstack_1grow (&temporary_obstack, '.');
11210 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11211 IDENTIFIER_LENGTH (right));
11212 node = get_identifier (obstack_base (&temporary_obstack));
11213 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11214 QUALIFIED_P (node) = 1;
11218 /* Merge the two parts of a qualified name into LEFT. Set the
11219 location information of the resulting node to LOCATION, usually
11220 inherited from the location information of the `.' operator. */
11223 make_qualified_name (left, right, location)
11227 #ifdef USE_COMPONENT_REF
11228 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11229 EXPR_WFL_LINECOL (node) = location;
11232 tree left_id = EXPR_WFL_NODE (left);
11233 tree right_id = EXPR_WFL_NODE (right);
11236 merge = merge_qualified_name (left_id, right_id);
11238 /* Left wasn't qualified and is now qualified */
11239 if (!QUALIFIED_P (left_id))
11241 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11242 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11243 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11246 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11247 EXPR_WFL_LINECOL (wfl) = location;
11248 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11250 EXPR_WFL_NODE (left) = merge;
11255 /* Extract the last identifier component of the qualified in WFL. The
11256 last identifier is removed from the linked list */
11259 cut_identifier_in_qualified (wfl)
11263 tree previous = NULL_TREE;
11264 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11265 if (!TREE_CHAIN (q))
11268 fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11269 TREE_CHAIN (previous) = NULL_TREE;
11270 return TREE_PURPOSE (q);
11274 /* Resolve the expression name NAME. Return its decl. */
11277 resolve_expression_name (id, orig)
11281 tree name = EXPR_WFL_NODE (id);
11284 /* 6.5.5.1: Simple expression names */
11285 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11287 /* 15.13.1: NAME can appear within the scope of a local variable
11289 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11292 /* 15.13.1: NAME can appear within a class declaration */
11295 decl = lookup_field_wrapper (current_class, name);
11298 tree access = NULL_TREE;
11299 int fs = FIELD_STATIC (decl);
11301 /* If we're accessing an outer scope local alias, make
11302 sure we change the name of the field we're going to
11303 build access to. */
11304 if (FIELD_LOCAL_ALIAS_USED (decl))
11305 name = DECL_NAME (decl);
11307 /* Instance variable (8.3.1.1) can't appear within
11308 static method, static initializer or initializer for
11309 a static variable. */
11310 if (!fs && METHOD_STATIC (current_function_decl))
11312 static_ref_err (id, name, current_class);
11313 return error_mark_node;
11315 /* Instance variables can't appear as an argument of
11316 an explicit constructor invocation */
11317 if (!fs && ctxp->explicit_constructor_p)
11319 parse_error_context
11320 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11321 return error_mark_node;
11324 /* If we're processing an inner class and we're trying
11325 to access a field belonging to an outer class, build
11326 the access to the field */
11327 if (!fs && outer_field_access_p (current_class, decl))
11328 return build_outer_field_access (id, decl);
11330 /* Otherwise build what it takes to access the field */
11331 access = build_field_ref ((fs ? NULL_TREE : current_this),
11332 DECL_CONTEXT (decl), name);
11333 if (fs && !flag_emit_class_files && !flag_emit_xref)
11334 access = build_class_init (DECL_CONTEXT (access), access);
11335 /* We may be asked to save the real field access node */
11338 /* And we return what we got */
11341 /* Fall down to error report on undefined variable */
11344 /* 6.5.5.2 Qualified Expression Names */
11349 qualify_ambiguous_name (id);
11350 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11351 /* 15.10.2: Accessing Superclass Members using super */
11352 return resolve_field_access (id, orig, NULL);
11355 /* We've got an error here */
11356 parse_error_context (id, "Undefined variable `%s'",
11357 IDENTIFIER_POINTER (name));
11359 return error_mark_node;
11363 static_ref_err (wfl, field_id, class_type)
11364 tree wfl, field_id, class_type;
11366 parse_error_context
11368 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11369 IDENTIFIER_POINTER (field_id),
11370 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11373 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11374 We return something suitable to generate the field access. We also
11375 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
11376 recipient's address can be null. */
11379 resolve_field_access (qual_wfl, field_decl, field_type)
11381 tree *field_decl, *field_type;
11385 tree decl, where_found, type_found;
11387 if (resolve_qualified_expression_name (qual_wfl, &decl,
11388 &where_found, &type_found))
11389 return error_mark_node;
11391 /* Resolve the LENGTH field of an array here */
11392 if (DECL_P (decl) && DECL_NAME (decl) == length_identifier_node
11393 && TYPE_ARRAY_P (type_found)
11394 && ! flag_emit_class_files && ! flag_emit_xref)
11396 tree length = build_java_array_length_access (where_found);
11398 build_java_arraynull_check (type_found, length, int_type_node);
11400 /* In case we're dealing with a static array, we need to
11401 initialize its class before the array length can be fetched.
11402 It's also a good time to create a DECL_RTL for the field if
11403 none already exists, otherwise if the field was declared in a
11404 class found in an external file and hasn't been (and won't
11405 be) accessed for its value, none will be created. */
11406 if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
11408 build_static_field_ref (where_found);
11409 field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
11412 /* We might have been trying to resolve field.method(). In which
11413 case, the resolution is over and decl is the answer */
11414 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11416 else if (JDECL_P (decl))
11418 int static_final_found = 0;
11420 type_found = DECL_CONTEXT (decl);
11421 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11422 if (FIELD_FINAL (decl)
11423 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11424 && DECL_INITIAL (decl))
11426 field_ref = java_complete_tree (DECL_INITIAL (decl));
11427 static_final_found = 1;
11430 field_ref = build_field_ref ((is_static && !flag_emit_xref?
11431 NULL_TREE : where_found),
11432 type_found, DECL_NAME (decl));
11433 if (field_ref == error_mark_node)
11434 return error_mark_node;
11435 if (is_static && !static_final_found
11436 && !flag_emit_class_files && !flag_emit_xref)
11437 field_ref = build_class_init (DECL_CONTEXT (decl), field_ref);
11443 *field_decl = decl;
11445 *field_type = (QUAL_DECL_TYPE (decl) ?
11446 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11450 /* If NODE is an access to f static field, strip out the class
11451 initialization part and return the field decl, otherwise, return
11455 strip_out_static_field_access_decl (node)
11458 if (TREE_CODE (node) == COMPOUND_EXPR)
11460 tree op1 = TREE_OPERAND (node, 1);
11461 if (TREE_CODE (op1) == COMPOUND_EXPR)
11463 tree call = TREE_OPERAND (op1, 0);
11464 if (TREE_CODE (call) == CALL_EXPR
11465 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11466 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11467 == soft_initclass_node)
11468 return TREE_OPERAND (op1, 1);
11470 else if (JDECL_P (op1))
11476 /* 6.5.5.2: Qualified Expression Names */
11479 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11481 tree *found_decl, *type_found, *where_found;
11483 int from_type = 0; /* Field search initiated from a type */
11484 int from_super = 0, from_cast = 0, from_qualified_this = 0;
11485 int previous_call_static = 0;
11487 tree decl = NULL_TREE, type = NULL_TREE, q;
11488 /* For certain for of inner class instantiation */
11489 tree saved_current, saved_this;
11490 #define RESTORE_THIS_AND_CURRENT_CLASS \
11491 { current_class = saved_current; current_this = saved_this;}
11493 *type_found = *where_found = NULL_TREE;
11495 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11497 tree qual_wfl = QUAL_WFL (q);
11498 tree ret_decl; /* for EH checking */
11499 int location; /* for EH checking */
11501 /* 15.10.1 Field Access Using a Primary */
11502 switch (TREE_CODE (qual_wfl))
11505 case NEW_CLASS_EXPR:
11506 /* If the access to the function call is a non static field,
11507 build the code to access it. */
11508 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11510 decl = maybe_access_field (decl, *where_found,
11511 DECL_CONTEXT (decl));
11512 if (decl == error_mark_node)
11516 /* And code for the function call */
11517 if (complete_function_arguments (qual_wfl))
11520 /* We might have to setup a new current class and a new this
11521 for the search of an inner class, relative to the type of
11522 a expression resolved as `decl'. The current values are
11523 saved and restored shortly after */
11524 saved_current = current_class;
11525 saved_this = current_this;
11526 if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11528 current_class = type;
11529 current_this = decl;
11532 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11533 CALL_USING_SUPER (qual_wfl) = 1;
11534 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11535 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11536 *where_found = patch_method_invocation (qual_wfl, decl, type,
11537 &is_static, &ret_decl);
11538 if (*where_found == error_mark_node)
11540 RESTORE_THIS_AND_CURRENT_CLASS;
11543 *type_found = type = QUAL_DECL_TYPE (*where_found);
11545 /* If we're creating an inner class instance, check for that
11546 an enclosing instance is in scope */
11547 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11548 && INNER_ENCLOSING_SCOPE_CHECK (type))
11550 parse_error_context
11551 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11552 lang_printable_name (type, 0),
11553 (!current_this ? "" :
11554 "; an explicit one must be provided when creating this inner class"));
11555 RESTORE_THIS_AND_CURRENT_CLASS;
11559 /* In case we had to change then to resolve a inner class
11560 instantiation using a primary qualified by a `new' */
11561 RESTORE_THIS_AND_CURRENT_CLASS;
11565 check_thrown_exceptions (location, ret_decl);
11567 /* If the previous call was static and this one is too,
11568 build a compound expression to hold the two (because in
11569 that case, previous function calls aren't transported as
11570 forcoming function's argument. */
11571 if (previous_call_static && is_static)
11573 decl = build (COMPOUND_EXPR, type, decl, *where_found);
11574 TREE_SIDE_EFFECTS (decl) = 1;
11578 previous_call_static = is_static;
11579 decl = *where_found;
11584 case NEW_ARRAY_EXPR:
11585 case NEW_ANONYMOUS_ARRAY_EXPR:
11586 *where_found = decl = java_complete_tree (qual_wfl);
11587 if (decl == error_mark_node)
11589 *type_found = type = QUAL_DECL_TYPE (decl);
11590 CLASS_LOADED_P (type) = 1;
11594 *where_found = decl = java_complete_tree (qual_wfl);
11595 if (decl == error_mark_node)
11597 *type_found = type = QUAL_DECL_TYPE (decl);
11601 case CONDITIONAL_EXPR:
11604 *where_found = decl = java_complete_tree (qual_wfl);
11605 if (decl == error_mark_node)
11607 *type_found = type = QUAL_DECL_TYPE (decl);
11611 /* If the access to the function call is a non static field,
11612 build the code to access it. */
11613 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11615 decl = maybe_access_field (decl, *where_found, type);
11616 if (decl == error_mark_node)
11619 /* And code for the array reference expression */
11620 decl = java_complete_tree (qual_wfl);
11621 if (decl == error_mark_node)
11623 type = QUAL_DECL_TYPE (decl);
11627 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11629 if ((type = patch_string (decl)))
11631 *where_found = QUAL_RESOLUTION (q) = decl;
11632 *type_found = type = TREE_TYPE (decl);
11635 case CLASS_LITERAL:
11636 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11638 *where_found = QUAL_RESOLUTION (q) = decl;
11639 *type_found = type = TREE_TYPE (decl);
11643 /* Fix for -Wall Just go to the next statement. Don't
11648 /* If we fall here, we weren't processing a (static) function call. */
11649 previous_call_static = 0;
11651 /* It can be the keyword THIS */
11652 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11656 parse_error_context
11657 (wfl, "Keyword `this' used outside allowed context");
11660 if (ctxp->explicit_constructor_p)
11662 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11665 /* We have to generate code for intermediate acess */
11666 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11668 *where_found = decl = current_this;
11669 *type_found = type = QUAL_DECL_TYPE (decl);
11671 /* We're trying to access the this from somewhere else... */
11674 *where_found = decl = build_current_thisn (type);
11675 from_qualified_this = 1;
11682 /* 15.10.2 Accessing Superclass Members using SUPER */
11683 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11686 /* Check on the restricted use of SUPER */
11687 if (METHOD_STATIC (current_function_decl)
11688 || current_class == object_type_node)
11690 parse_error_context
11691 (wfl, "Keyword `super' used outside allowed context");
11694 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11695 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
11696 CLASSTYPE_SUPER (current_class),
11697 build_this (EXPR_WFL_LINECOL (qual_wfl)));
11698 *where_found = decl = java_complete_tree (node);
11699 if (decl == error_mark_node)
11701 *type_found = type = QUAL_DECL_TYPE (decl);
11702 from_super = from_type = 1;
11706 /* 15.13.1: Can't search for field name in packages, so we
11707 assume a variable/class name was meant. */
11708 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11710 tree name = resolve_package (wfl, &q);
11714 *where_found = decl = resolve_no_layout (name, qual_wfl);
11715 /* We want to be absolutely sure that the class is laid
11716 out. We're going to search something inside it. */
11717 *type_found = type = TREE_TYPE (decl);
11718 layout_class (type);
11721 /* Fix them all the way down, if any are left. */
11724 list = TREE_CHAIN (q);
11727 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11728 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11729 list = TREE_CHAIN (list);
11735 if (from_super || from_cast)
11736 parse_error_context
11737 ((from_cast ? qual_wfl : wfl),
11738 "No variable `%s' defined in class `%s'",
11739 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11740 lang_printable_name (type, 0));
11742 parse_error_context
11743 (qual_wfl, "Undefined variable or class name: `%s'",
11744 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11749 /* We have a type name. It's been already resolved when the
11750 expression was qualified. */
11751 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11753 if (!(decl = QUAL_RESOLUTION (q)))
11754 return 1; /* Error reported already */
11756 /* Sneak preview. If next we see a `new', we're facing a
11757 qualification with resulted in a type being selected
11758 instead of a field. Report the error */
11760 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11762 parse_error_context (qual_wfl, "Undefined variable `%s'",
11763 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11767 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11769 parse_error_context
11770 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11771 java_accstring_lookup (get_access_flags_from_decl (decl)),
11772 GET_TYPE_NAME (type),
11773 IDENTIFIER_POINTER (DECL_NAME (decl)),
11774 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11777 check_deprecation (qual_wfl, decl);
11779 type = TREE_TYPE (decl);
11782 /* We resolve and expression name */
11785 tree field_decl = NULL_TREE;
11787 /* If there exists an early resolution, use it. That occurs
11788 only once and we know that there are more things to
11789 come. Don't do that when processing something after SUPER
11790 (we need more thing to be put in place below */
11791 if (!from_super && QUAL_RESOLUTION (q))
11793 decl = QUAL_RESOLUTION (q);
11796 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11799 *where_found = current_this;
11802 static_ref_err (qual_wfl, DECL_NAME (decl),
11809 *where_found = TREE_TYPE (decl);
11810 if (TREE_CODE (*where_found) == POINTER_TYPE)
11811 *where_found = TREE_TYPE (*where_found);
11816 /* We have to search for a field, knowing the type of its
11817 container. The flag FROM_TYPE indicates that we resolved
11818 the last member of the expression as a type name, which
11819 means that for the resolution of this field, we'll look
11820 for other errors than if it was resolved as a member of
11825 tree field_decl_type; /* For layout */
11827 if (!from_type && !JREFERENCE_TYPE_P (type))
11829 parse_error_context
11830 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11831 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11832 lang_printable_name (type, 0),
11833 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11837 field_decl = lookup_field_wrapper (type,
11838 EXPR_WFL_NODE (qual_wfl));
11839 if (field_decl == NULL_TREE)
11841 parse_error_context
11842 (qual_wfl, "No variable `%s' defined in type `%s'",
11843 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11844 GET_TYPE_NAME (type));
11847 if (field_decl == error_mark_node)
11850 /* Layout the type of field_decl, since we may need
11851 it. Don't do primitive types or loaded classes. The
11852 situation of non primitive arrays may not handled
11853 properly here. FIXME */
11854 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11855 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11857 field_decl_type = TREE_TYPE (field_decl);
11858 if (!JPRIMITIVE_TYPE_P (field_decl_type)
11859 && !CLASS_LOADED_P (field_decl_type)
11860 && !TYPE_ARRAY_P (field_decl_type))
11861 resolve_and_layout (field_decl_type, NULL_TREE);
11862 if (TYPE_ARRAY_P (field_decl_type))
11863 CLASS_LOADED_P (field_decl_type) = 1;
11865 /* Check on accessibility here */
11866 if (not_accessible_p (type, field_decl, from_super))
11868 parse_error_context
11870 "Can't access %s field `%s.%s' from `%s'",
11871 java_accstring_lookup
11872 (get_access_flags_from_decl (field_decl)),
11873 GET_TYPE_NAME (type),
11874 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11876 (DECL_NAME (TYPE_NAME (current_class))));
11879 check_deprecation (qual_wfl, field_decl);
11881 /* There are things to check when fields are accessed
11882 from type. There are no restrictions on a static
11883 declaration of the field when it is accessed from an
11885 is_static = FIELD_STATIC (field_decl);
11886 if (!from_super && from_type
11887 && !TYPE_INTERFACE_P (type)
11889 && (current_function_decl
11890 && METHOD_STATIC (current_function_decl)))
11892 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11895 from_cast = from_super = 0;
11897 /* It's an access from a type but it isn't static, we
11898 make it relative to `this'. */
11899 if (!is_static && from_type)
11900 decl = current_this;
11902 /* If we need to generate something to get a proper
11903 handle on what this field is accessed from, do it
11907 decl = maybe_access_field (decl, *where_found, *type_found);
11908 if (decl == error_mark_node)
11912 /* We want to keep the location were found it, and the type
11914 *where_found = decl;
11915 *type_found = type;
11917 /* Generate the correct expression for field access from
11919 if (from_qualified_this)
11921 field_decl = build_outer_field_access (qual_wfl, field_decl);
11922 from_qualified_this = 0;
11925 /* This is the decl found and eventually the next one to
11930 type = QUAL_DECL_TYPE (decl);
11932 /* Sneak preview. If decl is qualified by a `new', report
11933 the error here to be accurate on the peculiar construct */
11935 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11936 && !JREFERENCE_TYPE_P (type))
11938 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
11939 lang_printable_name (type, 0));
11943 /* `q' might have changed due to a after package resolution
11944 re-qualification */
11948 *found_decl = decl;
11952 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11953 can't be accessed from REFERENCE (a record type). */
11956 not_accessible_p (reference, member, from_super)
11957 tree reference, member;
11960 int access_flag = get_access_flags_from_decl (member);
11962 /* Access always granted for members declared public */
11963 if (access_flag & ACC_PUBLIC)
11966 /* Check access on protected members */
11967 if (access_flag & ACC_PROTECTED)
11969 /* Access granted if it occurs from within the package
11970 containing the class in which the protected member is
11972 if (class_in_current_package (DECL_CONTEXT (member)))
11975 /* If accessed with the form `super.member', then access is granted */
11979 /* Otherwise, access is granted if occuring from the class where
11980 member is declared or a subclass of it */
11981 if (inherits_from_p (reference, DECL_CONTEXT (member)))
11986 /* Check access on private members. Access is granted only if it
11987 occurs from within the class in which it is declared. Exceptions
11988 are accesses from inner-classes. This section is probably not
11990 if (access_flag & ACC_PRIVATE)
11991 return (current_class == DECL_CONTEXT (member) ? 0 :
11992 (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11994 /* Default access are permitted only when occuring within the
11995 package in which the type (REFERENCE) is declared. In other words,
11996 REFERENCE is defined in the current package */
11998 return !class_in_current_package (reference);
12000 /* Otherwise, access is granted */
12004 /* Test deprecated decl access. */
12006 check_deprecation (wfl, decl)
12009 const char *file = DECL_SOURCE_FILE (decl);
12010 /* Complain if the field is deprecated and the file it was defined
12011 in isn't compiled at the same time the file which contains its
12013 if (DECL_DEPRECATED (decl)
12014 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
12017 switch (TREE_CODE (decl))
12019 case FUNCTION_DECL:
12020 strcpy (the, "method");
12023 strcpy (the, "field");
12026 strcpy (the, "class");
12029 fatal ("unexpected DECL code - check_deprecation");
12031 parse_warning_context
12032 (wfl, "The %s `%s' in class `%s' has been deprecated",
12033 the, lang_printable_name (decl, 0),
12034 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
12038 /* Returns 1 if class was declared in the current package, 0 otherwise */
12041 class_in_current_package (class)
12044 static tree cache = NULL_TREE;
12045 int qualified_flag;
12048 if (cache == class)
12051 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
12053 /* If the current package is empty and the name of CLASS is
12054 qualified, class isn't in the current package. If there is a
12055 current package and the name of the CLASS is not qualified, class
12056 isn't in the current package */
12057 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
12060 /* If there is not package and the name of CLASS isn't qualified,
12061 they belong to the same unnamed package */
12062 if (!ctxp->package && !qualified_flag)
12065 /* Compare the left part of the name of CLASS with the package name */
12066 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
12067 if (ctxp->package == left)
12075 /* This function may generate code to access DECL from WHERE. This is
12076 done only if certain conditions meet. */
12079 maybe_access_field (decl, where, type)
12080 tree decl, where, type;
12082 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
12083 && !FIELD_STATIC (decl))
12084 decl = build_field_ref (where ? where : current_this,
12085 (type ? type : DECL_CONTEXT (decl)),
12090 /* Build a method invocation, by patching PATCH. If non NULL
12091 and according to the situation, PRIMARY and WHERE may be
12092 used. IS_STATIC is set to 1 if the invoked function is static. */
12095 patch_method_invocation (patch, primary, where, is_static, ret_decl)
12096 tree patch, primary, where;
12100 tree wfl = TREE_OPERAND (patch, 0);
12101 tree args = TREE_OPERAND (patch, 1);
12102 tree name = EXPR_WFL_NODE (wfl);
12104 int is_static_flag = 0;
12105 int is_super_init = 0;
12106 tree this_arg = NULL_TREE;
12108 /* Should be overriden if everything goes well. Otherwise, if
12109 something fails, it should keep this value. It stop the
12110 evaluation of a bogus assignment. See java_complete_tree,
12111 MODIFY_EXPR: for the reasons why we sometimes want to keep on
12112 evaluating an assignment */
12113 TREE_TYPE (patch) = error_mark_node;
12115 /* Since lookup functions are messing with line numbers, save the
12117 java_parser_context_save_global ();
12119 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
12121 /* Resolution of qualified name, excluding constructors */
12122 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
12124 tree identifier, identifier_wfl, type, resolved;
12125 /* Extract the last IDENTIFIER of the qualified
12126 expression. This is a wfl and we will use it's location
12127 data during error report. */
12128 identifier_wfl = cut_identifier_in_qualified (wfl);
12129 identifier = EXPR_WFL_NODE (identifier_wfl);
12131 /* Given the context, IDENTIFIER is syntactically qualified
12132 as a MethodName. We need to qualify what's before */
12133 qualify_ambiguous_name (wfl);
12134 resolved = resolve_field_access (wfl, NULL, NULL);
12136 if (resolved == error_mark_node)
12137 PATCH_METHOD_RETURN_ERROR ();
12139 type = GET_SKIP_TYPE (resolved);
12140 resolve_and_layout (type, NULL_TREE);
12142 if (JPRIMITIVE_TYPE_P (type))
12144 parse_error_context
12146 "Can't invoke a method on primitive type `%s'",
12147 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12148 PATCH_METHOD_RETURN_ERROR ();
12151 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12152 args = nreverse (args);
12154 /* We're resolving a call from a type */
12155 if (TREE_CODE (resolved) == TYPE_DECL)
12157 if (CLASS_INTERFACE (resolved))
12159 parse_error_context
12161 "Can't make static reference to method `%s' in interface `%s'",
12162 IDENTIFIER_POINTER (identifier),
12163 IDENTIFIER_POINTER (name));
12164 PATCH_METHOD_RETURN_ERROR ();
12166 if (list && !METHOD_STATIC (list))
12168 char *fct_name = xstrdup (lang_printable_name (list, 0));
12169 parse_error_context
12171 "Can't make static reference to method `%s %s' in class `%s'",
12172 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12173 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12175 PATCH_METHOD_RETURN_ERROR ();
12179 this_arg = primary = resolved;
12181 /* IDENTIFIER_WFL will be used to report any problem further */
12182 wfl = identifier_wfl;
12184 /* Resolution of simple names, names generated after a primary: or
12188 tree class_to_search = NULL_TREE;
12189 int lc; /* Looking for Constructor */
12191 /* We search constructor in their target class */
12192 if (CALL_CONSTRUCTOR_P (patch))
12194 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12195 class_to_search = EXPR_WFL_NODE (wfl);
12196 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12197 this_identifier_node)
12198 class_to_search = NULL_TREE;
12199 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12200 super_identifier_node)
12203 if (CLASSTYPE_SUPER (current_class))
12205 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12208 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12209 PATCH_METHOD_RETURN_ERROR ();
12213 /* Class to search is NULL if we're searching the current one */
12214 if (class_to_search)
12216 class_to_search = resolve_and_layout (class_to_search, wfl);
12218 if (!class_to_search)
12220 parse_error_context
12221 (wfl, "Class `%s' not found in type declaration",
12222 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12223 PATCH_METHOD_RETURN_ERROR ();
12226 /* Can't instantiate an abstract class, but we can
12227 invoke it's constructor. It's use within the `new'
12228 context is denied here. */
12229 if (CLASS_ABSTRACT (class_to_search)
12230 && TREE_CODE (patch) == NEW_CLASS_EXPR)
12232 parse_error_context
12233 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12234 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12235 PATCH_METHOD_RETURN_ERROR ();
12238 class_to_search = TREE_TYPE (class_to_search);
12241 class_to_search = current_class;
12244 /* This is a regular search in the local class, unless an
12245 alternate class is specified. */
12248 class_to_search = (where ? where : current_class);
12252 /* NAME is a simple identifier or comes from a primary. Search
12253 in the class whose declaration contain the method being
12255 resolve_and_layout (class_to_search, NULL_TREE);
12257 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12258 /* Don't continue if no method were found, as the next statement
12259 can't be executed then. */
12261 PATCH_METHOD_RETURN_ERROR ();
12263 /* Check for static reference if non static methods */
12264 if (check_for_static_method_reference (wfl, patch, list,
12265 class_to_search, primary))
12266 PATCH_METHOD_RETURN_ERROR ();
12268 /* Check for inner classes creation from illegal contexts */
12269 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12270 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12271 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12273 parse_error_context
12274 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12275 lang_printable_name (class_to_search, 0),
12276 (!current_this ? "" :
12277 "; an explicit one must be provided when creating this inner class"));
12278 PATCH_METHOD_RETURN_ERROR ();
12281 /* Non static methods are called with the current object extra
12282 argument. If patch a `new TYPE()', the argument is the value
12283 returned by the object allocator. If method is resolved as a
12284 primary, use the primary otherwise use the current THIS. */
12285 args = nreverse (args);
12286 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12288 this_arg = primary ? primary : current_this;
12290 /* If we're using an access method, things are different.
12291 There are two familly of cases:
12293 1) We're not generating bytecodes:
12295 - LIST is non static. It's invocation is transformed from
12296 x(a1,...,an) into this$<n>.x(a1,....an).
12297 - LIST is static. It's invocation is transformed from
12298 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12300 2) We're generating bytecodes:
12302 - LIST is non static. It's invocation is transformed from
12303 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12304 - LIST is static. It's invocation is transformed from
12305 x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12307 Of course, this$<n> can be abitrary complex, ranging from
12308 this$0 (the immediate outer context) to
12309 access$0(access$0(...(this$0))).
12311 maybe_use_access_method returns a non zero value if the
12312 this_arg has to be moved into the (then generated) stub
12313 argument list. In the mean time, the selected function
12314 might have be replaced by a generated stub. */
12315 if (maybe_use_access_method (is_super_init, &list, &this_arg))
12316 args = tree_cons (NULL_TREE, this_arg, args);
12320 /* Merge point of all resolution schemes. If we have nothing, this
12321 is an error, already signaled */
12323 PATCH_METHOD_RETURN_ERROR ();
12325 /* Check accessibility, position the is_static flag, build and
12327 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12329 char *fct_name = xstrdup (lang_printable_name (list, 0));
12330 parse_error_context
12331 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12332 java_accstring_lookup (get_access_flags_from_decl (list)),
12333 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12334 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
12335 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12337 PATCH_METHOD_RETURN_ERROR ();
12339 check_deprecation (wfl, list);
12341 /* If invoking a innerclass constructor, there are hidden parameters
12343 if (TREE_CODE (patch) == NEW_CLASS_EXPR
12344 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12346 /* And make sure we add the accessed local variables to be saved
12347 in field aliases. */
12348 args = build_alias_initializer_parameter_list
12349 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12351 /* We have to reverse things. Find out why. FIXME */
12352 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12353 args = nreverse (args);
12355 /* Secretely pass the current_this/primary as a second argument */
12356 if (primary || current_this)
12357 args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12359 args = tree_cons (NULL_TREE, integer_zero_node, args);
12362 /* This handles the situation where a constructor invocation needs
12363 to have an enclosing context passed as a second parameter (the
12364 constructor is one of an inner class. We extract it from the
12365 current function. */
12366 if (is_super_init && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12368 tree enclosing_decl = DECL_CONTEXT (TYPE_NAME (current_class));
12371 if (ANONYMOUS_CLASS_P (current_class) || !DECL_CONTEXT (enclosing_decl))
12373 extra_arg = DECL_FUNCTION_BODY (current_function_decl);
12374 extra_arg = TREE_CHAIN (BLOCK_EXPR_DECLS (extra_arg));
12378 tree dest = TREE_TYPE (DECL_CONTEXT (enclosing_decl));
12380 build_access_to_thisn (TREE_TYPE (enclosing_decl), dest, 0);
12381 extra_arg = java_complete_tree (extra_arg);
12383 args = tree_cons (NULL_TREE, extra_arg, args);
12386 is_static_flag = METHOD_STATIC (list);
12387 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12388 args = tree_cons (NULL_TREE, this_arg, args);
12390 /* In the context of an explicit constructor invocation, we can't
12391 invoke any method relying on `this'. Exceptions are: we're
12392 invoking a static function, primary exists and is not the current
12393 this, we're creating a new object. */
12394 if (ctxp->explicit_constructor_p
12396 && (!primary || primary == current_this)
12397 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12399 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12400 PATCH_METHOD_RETURN_ERROR ();
12402 java_parser_context_restore_global ();
12404 *is_static = is_static_flag;
12405 /* Sometimes, we want the decl of the selected method. Such as for
12409 patch = patch_invoke (patch, list, args);
12410 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12412 tree finit_parms, finit_call;
12414 /* Prepare to pass hidden parameters to $finit$, if any. */
12415 finit_parms = build_alias_initializer_parameter_list
12416 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12419 build_method_invocation (build_wfl_node (finit_identifier_node),
12422 /* Generate the code used to initialize fields declared with an
12423 initialization statement and build a compound statement along
12424 with the super constructor invocation. */
12425 patch = build (COMPOUND_EXPR, void_type_node, patch,
12426 java_complete_tree (finit_call));
12427 CAN_COMPLETE_NORMALLY (patch) = 1;
12432 /* Check that we're not trying to do a static reference to a method in
12433 non static method. Return 1 if it's the case, 0 otherwise. */
12436 check_for_static_method_reference (wfl, node, method, where, primary)
12437 tree wfl, node, method, where, primary;
12439 if (METHOD_STATIC (current_function_decl)
12440 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12442 char *fct_name = xstrdup (lang_printable_name (method, 0));
12443 parse_error_context
12444 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
12445 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12446 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12453 /* Fix the invocation of *MDECL if necessary in the case of a
12454 invocation from an inner class. *THIS_ARG might be modified
12455 appropriately and an alternative access to *MDECL might be
12459 maybe_use_access_method (is_super_init, mdecl, this_arg)
12461 tree *mdecl, *this_arg;
12464 tree md = *mdecl, ta = *this_arg;
12466 int non_static_context = !METHOD_STATIC (md);
12469 || DECL_CONTEXT (md) == current_class
12470 || !PURE_INNER_CLASS_TYPE_P (current_class)
12471 || DECL_FINIT_P (md))
12474 /* If we're calling a method found in an enclosing class, generate
12475 what it takes to retrieve the right this. Don't do that if we're
12476 invoking a static method. */
12478 if (non_static_context)
12480 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12481 if (ctx == DECL_CONTEXT (md))
12483 ta = build_current_thisn (current_class);
12484 ta = build_wfl_node (ta);
12491 maybe_build_thisn_access_method (type);
12492 if (type == DECL_CONTEXT (md))
12494 ta = build_access_to_thisn (ctx, type, 0);
12497 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
12498 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12501 ta = java_complete_tree (ta);
12504 /* We might have to use an access method to get to MD. We can
12505 break the method access rule as far as we're not generating
12507 if (METHOD_PRIVATE (md) && flag_emit_class_files)
12509 md = build_outer_method_access_method (md);
12516 /* Returnin a non zero value indicates we were doing a non static
12517 method invokation that is now a static invocation. It will have
12518 callee displace `this' to insert it in the regular argument
12520 return (non_static_context && to_return);
12523 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12527 patch_invoke (patch, method, args)
12528 tree patch, method, args;
12531 tree original_call, t, ta;
12532 tree cond = NULL_TREE;
12534 /* Last step for args: convert build-in types. If we're dealing with
12535 a new TYPE() type call, the first argument to the constructor
12536 isn't found in the incoming argument list, but delivered by
12538 t = TYPE_ARG_TYPES (TREE_TYPE (method));
12539 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12540 t = TREE_CHAIN (t);
12541 for (ta = args; t != end_params_node && ta;
12542 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12543 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12544 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12545 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12547 /* Resolve unresolved returned type isses */
12548 t = TREE_TYPE (TREE_TYPE (method));
12549 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12550 resolve_and_layout (TREE_TYPE (t), NULL);
12552 if (flag_emit_class_files || flag_emit_xref)
12556 tree signature = build_java_signature (TREE_TYPE (method));
12557 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12559 case INVOKE_VIRTUAL:
12560 dtable = invoke_build_dtable (0, args);
12561 func = build_invokevirtual (dtable, method);
12564 case INVOKE_NONVIRTUAL:
12565 /* If the object for the method call is null, we throw an
12566 exception. We don't do this if the object is the current
12567 method's `this'. In other cases we just rely on an
12568 optimization pass to eliminate redundant checks. */
12569 if (TREE_VALUE (args) != current_this)
12571 /* We use a SAVE_EXPR here to make sure we only evaluate
12572 the new `self' expression once. */
12573 tree save_arg = save_expr (TREE_VALUE (args));
12574 TREE_VALUE (args) = save_arg;
12575 cond = build (EQ_EXPR, boolean_type_node, save_arg,
12576 null_pointer_node);
12578 /* Fall through. */
12581 case INVOKE_STATIC:
12582 func = build_known_method_ref (method, TREE_TYPE (method),
12583 DECL_CONTEXT (method),
12587 case INVOKE_INTERFACE:
12588 dtable = invoke_build_dtable (1, args);
12589 func = build_invokeinterface (dtable, method);
12593 fatal ("internal error - unknown invocation_mode result");
12596 /* Ensure self_type is initialized, (invokestatic). FIXME */
12597 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12600 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12601 TREE_OPERAND (patch, 0) = func;
12602 TREE_OPERAND (patch, 1) = args;
12603 original_call = patch;
12605 /* We're processing a `new TYPE ()' form. New is called and its
12606 returned value is the first argument to the constructor. We build
12607 a COMPOUND_EXPR and use saved expression so that the overall NEW
12608 expression value is a pointer to a newly created and initialized
12610 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12612 tree class = DECL_CONTEXT (method);
12613 tree c1, saved_new, size, new;
12614 if (flag_emit_class_files || flag_emit_xref)
12616 TREE_TYPE (patch) = build_pointer_type (class);
12619 if (!TYPE_SIZE (class))
12620 safe_layout_class (class);
12621 size = size_in_bytes (class);
12622 new = build (CALL_EXPR, promote_type (class),
12623 build_address_of (alloc_object_node),
12624 tree_cons (NULL_TREE, build_class_ref (class),
12625 build_tree_list (NULL_TREE,
12626 size_in_bytes (class))),
12628 saved_new = save_expr (new);
12629 c1 = build_tree_list (NULL_TREE, saved_new);
12630 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12631 TREE_OPERAND (original_call, 1) = c1;
12632 TREE_SET_CODE (original_call, CALL_EXPR);
12633 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12636 /* If COND is set, then we are building a check to see if the object
12638 if (cond != NULL_TREE)
12640 /* We have to make the `then' branch a compound expression to
12641 make the types turn out right. This seems bizarre. */
12642 patch = build (COND_EXPR, TREE_TYPE (patch), cond,
12643 build (COMPOUND_EXPR, TREE_TYPE (patch),
12644 build (CALL_EXPR, void_type_node,
12645 build_address_of (soft_nullpointer_node),
12646 NULL_TREE, NULL_TREE),
12647 (FLOAT_TYPE_P (TREE_TYPE (patch))
12648 ? build_real (TREE_TYPE (patch), dconst0)
12649 : build1 (CONVERT_EXPR, TREE_TYPE (patch),
12650 integer_zero_node))),
12652 TREE_SIDE_EFFECTS (patch) = 1;
12659 invocation_mode (method, super)
12663 int access = get_access_flags_from_decl (method);
12666 return INVOKE_SUPER;
12668 if (access & ACC_STATIC)
12669 return INVOKE_STATIC;
12671 /* We have to look for a constructor before we handle nonvirtual
12672 calls; otherwise the constructor will look nonvirtual. */
12673 if (DECL_CONSTRUCTOR_P (method))
12674 return INVOKE_STATIC;
12676 if (access & ACC_FINAL || access & ACC_PRIVATE)
12677 return INVOKE_NONVIRTUAL;
12679 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12680 return INVOKE_NONVIRTUAL;
12682 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12683 return INVOKE_INTERFACE;
12685 return INVOKE_VIRTUAL;
12688 /* Retrieve a refined list of matching methods. It covers the step
12689 15.11.2 (Compile-Time Step 2) */
12692 lookup_method_invoke (lc, cl, class, name, arg_list)
12695 tree class, name, arg_list;
12697 tree atl = end_params_node; /* Arg Type List */
12698 tree method, signature, list, node;
12699 const char *candidates; /* Used for error report */
12702 /* Fix the arguments */
12703 for (node = arg_list; node; node = TREE_CHAIN (node))
12705 tree current_arg = TREE_TYPE (TREE_VALUE (node));
12706 /* Non primitive type may have to be resolved */
12707 if (!JPRIMITIVE_TYPE_P (current_arg))
12708 resolve_and_layout (current_arg, NULL_TREE);
12710 if (TREE_CODE (current_arg) == RECORD_TYPE)
12711 current_arg = promote_type (current_arg);
12712 atl = tree_cons (NULL_TREE, current_arg, atl);
12715 /* Presto. If we're dealing with an anonymous class and a
12716 constructor call, generate the right constructor now, since we
12717 know the arguments' types. */
12719 if (lc && ANONYMOUS_CLASS_P (class))
12720 craft_constructor (TYPE_NAME (class), atl);
12722 /* Find all candidates and then refine the list, searching for the
12723 most specific method. */
12724 list = find_applicable_accessible_methods_list (lc, class, name, atl);
12725 list = find_most_specific_methods_list (list);
12726 if (list && !TREE_CHAIN (list))
12727 return TREE_VALUE (list);
12729 /* Issue an error. List candidates if any. Candidates are listed
12730 only if accessible (non accessible methods may end-up here for
12731 the sake of a better error report). */
12736 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12737 for (current = list; current; current = TREE_CHAIN (current))
12739 tree cm = TREE_VALUE (current);
12740 char string [4096];
12741 if (!cm || not_accessible_p (class, cm, 0))
12744 (string, " `%s' in `%s'%s",
12745 get_printable_method_name (cm),
12746 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12747 (TREE_CHAIN (current) ? "\n" : ""));
12748 obstack_grow (&temporary_obstack, string, strlen (string));
12750 obstack_1grow (&temporary_obstack, '\0');
12751 candidates = obstack_finish (&temporary_obstack);
12753 /* Issue the error message */
12754 method = make_node (FUNCTION_TYPE);
12755 TYPE_ARG_TYPES (method) = atl;
12756 signature = build_java_argument_signature (method);
12757 dup = xstrdup (lang_printable_name (class, 0));
12758 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12759 (lc ? "constructor" : "method"),
12760 (lc ? dup : IDENTIFIER_POINTER (name)),
12761 IDENTIFIER_POINTER (signature), dup,
12762 (candidates ? candidates : ""));
12767 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12768 when we're looking for a constructor. */
12771 find_applicable_accessible_methods_list (lc, class, name, arglist)
12773 tree class, name, arglist;
12775 static int object_done = 0;
12776 tree list = NULL_TREE, all_list = NULL_TREE;
12778 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12780 load_class (class, 1);
12781 safe_layout_class (class);
12784 /* Search interfaces */
12785 if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
12786 && CLASS_INTERFACE (TYPE_NAME (class)))
12788 static struct hash_table t, *searched_interfaces = NULL;
12789 static int search_not_done = 0;
12791 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12793 /* Search in the hash table, otherwise create a new one if
12794 necessary and insert the new entry. */
12796 if (searched_interfaces)
12798 if (hash_lookup (searched_interfaces,
12799 (const hash_table_key) class, FALSE, NULL))
12804 hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12805 java_hash_compare_tree_node);
12806 searched_interfaces = &t;
12809 hash_lookup (searched_interfaces,
12810 (const hash_table_key) class, TRUE, NULL);
12812 search_applicable_methods_list (lc, TYPE_METHODS (class),
12813 name, arglist, &list, &all_list);
12814 n = TREE_VEC_LENGTH (basetype_vec);
12815 for (i = 1; i < n; i++)
12817 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12821 rlist = find_applicable_accessible_methods_list (lc, t, name,
12823 list = chainon (rlist, list);
12827 /* We're done. Reset the searched interfaces list and finally search
12828 java.lang.Object */
12829 if (!search_not_done)
12832 search_applicable_methods_list (lc,
12833 TYPE_METHODS (object_type_node),
12834 name, arglist, &list, &all_list);
12835 hash_table_free (searched_interfaces);
12836 searched_interfaces = NULL;
12839 /* Search classes */
12843 int seen_inner_class = 0;
12844 search_applicable_methods_list (lc, TYPE_METHODS (class),
12845 name, arglist, &list, &all_list);
12847 /* We must search all interfaces of this class */
12850 tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12851 int n = TREE_VEC_LENGTH (basetype_vec), i;
12853 for (i = 1; i < n; i++)
12855 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12856 if (t != object_type_node)
12859 = find_applicable_accessible_methods_list (lc, t,
12861 list = chainon (rlist, list);
12867 /* Search enclosing context of inner classes before looking
12869 while (!lc && INNER_CLASS_TYPE_P (class))
12872 seen_inner_class = 1;
12873 class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12874 rlist = find_applicable_accessible_methods_list (lc, class,
12876 list = chainon (rlist, list);
12879 if (!lc && seen_inner_class
12880 && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12881 class = CLASSTYPE_SUPER (sc);
12885 for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
12886 class; class = CLASSTYPE_SUPER (class))
12887 search_applicable_methods_list (lc, TYPE_METHODS (class),
12888 name, arglist, &list, &all_list);
12891 /* Either return the list obtained or all selected (but
12892 inaccessible) methods for better error report. */
12893 return (!list ? all_list : list);
12896 /* Effectively search for the approriate method in method */
12899 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12901 tree method, name, arglist;
12902 tree *list, *all_list;
12904 for (; method; method = TREE_CHAIN (method))
12906 /* When dealing with constructor, stop here, otherwise search
12908 if (lc && !DECL_CONSTRUCTOR_P (method))
12910 else if (!lc && (DECL_CONSTRUCTOR_P (method)
12911 || (GET_METHOD_NAME (method) != name)))
12914 if (argument_types_convertible (method, arglist))
12916 /* Retain accessible methods only */
12917 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
12919 *list = tree_cons (NULL_TREE, method, *list);
12921 /* Also retain all selected method here */
12922 *all_list = tree_cons (NULL_TREE, method, *list);
12927 /* 15.11.2.2 Choose the Most Specific Method */
12930 find_most_specific_methods_list (list)
12934 int abstract, candidates;
12935 tree current, new_list = NULL_TREE;
12936 for (current = list; current; current = TREE_CHAIN (current))
12939 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12941 for (method = list; method; method = TREE_CHAIN (method))
12943 /* Don't test a method against itself */
12944 if (method == current)
12947 /* Compare arguments and location where method where declared */
12948 if (argument_types_convertible (TREE_VALUE (method),
12949 TREE_VALUE (current))
12950 && valid_method_invocation_conversion_p
12951 (DECL_CONTEXT (TREE_VALUE (method)),
12952 DECL_CONTEXT (TREE_VALUE (current))))
12954 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12955 max = (v > max ? v : max);
12960 /* Review the list and select the maximally specific methods */
12961 for (current = list, abstract = -1, candidates = -1;
12962 current; current = TREE_CHAIN (current))
12963 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12965 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12966 abstract += (METHOD_ABSTRACT (TREE_VALUE (current)) ? 1 : 0);
12970 /* If we have several and they're all abstract, just pick the
12972 if (candidates > 0 && (candidates == abstract))
12974 new_list = nreverse (new_list);
12975 TREE_CHAIN (new_list) = NULL_TREE;
12978 /* We have several, we couldn't find a most specific, all but one are
12979 abstract, we pick the only non abstract one. */
12980 if (candidates > 0 && !max && (candidates == abstract+1))
12982 for (current = new_list; current; current = TREE_CHAIN (current))
12983 if (!METHOD_ABSTRACT (TREE_VALUE (current)))
12985 TREE_CHAIN (current) = NULL_TREE;
12986 new_list = current;
12990 /* If we can't find one, lower expectations and try to gather multiple
12991 maximally specific methods */
12992 while (!new_list && max)
12996 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12997 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
13004 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
13005 converted by method invocation conversion (5.3) to the type of the
13006 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
13007 to change less often than M1. */
13010 argument_types_convertible (m1, m2_or_arglist)
13011 tree m1, m2_or_arglist;
13013 static tree m2_arg_value = NULL_TREE;
13014 static tree m2_arg_cache = NULL_TREE;
13016 register tree m1_arg, m2_arg;
13018 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
13020 if (m2_arg_value == m2_or_arglist)
13021 m2_arg = m2_arg_cache;
13024 /* M2_OR_ARGLIST can be a function DECL or a raw list of
13026 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
13028 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
13029 if (!METHOD_STATIC (m2_or_arglist))
13030 m2_arg = TREE_CHAIN (m2_arg);
13033 m2_arg = m2_or_arglist;
13035 m2_arg_value = m2_or_arglist;
13036 m2_arg_cache = m2_arg;
13039 while (m1_arg != end_params_node && m2_arg != end_params_node)
13041 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
13042 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
13043 TREE_VALUE (m2_arg)))
13045 m1_arg = TREE_CHAIN (m1_arg);
13046 m2_arg = TREE_CHAIN (m2_arg);
13048 return m1_arg == end_params_node && m2_arg == end_params_node;
13051 /* Qualification routines */
13054 qualify_ambiguous_name (id)
13057 tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
13058 saved_current_class;
13059 int again, super_found = 0, this_found = 0, new_array_found = 0;
13062 /* We first qualify the first element, then derive qualification of
13063 others based on the first one. If the first element is qualified
13064 by a resolution (field or type), this resolution is stored in the
13065 QUAL_RESOLUTION of the qual element being examined. We need to
13066 save the current_class since the use of SUPER might change the
13068 saved_current_class = current_class;
13069 qual = EXPR_WFL_QUALIFICATION (id);
13072 /* Simple qualified expression feature a qual_wfl that is a
13073 WFL. Expression derived from a primary feature more complicated
13074 things like a CALL_EXPR. Expression from primary need to be
13075 worked out to extract the part on which the qualification will
13077 qual_wfl = QUAL_WFL (qual);
13078 switch (TREE_CODE (qual_wfl))
13081 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13082 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
13084 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13085 qual_wfl = QUAL_WFL (qual);
13088 case NEW_ARRAY_EXPR:
13089 case NEW_ANONYMOUS_ARRAY_EXPR:
13090 qual = TREE_CHAIN (qual);
13091 again = new_array_found = 1;
13095 case NEW_CLASS_EXPR:
13096 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13099 while (TREE_CODE (qual_wfl) == ARRAY_REF)
13100 qual_wfl = TREE_OPERAND (qual_wfl, 0);
13103 qual = TREE_CHAIN (qual);
13104 qual_wfl = QUAL_WFL (qual);
13106 case CLASS_LITERAL:
13107 qual = TREE_CHAIN (qual);
13108 qual_wfl = QUAL_WFL (qual);
13111 /* Fix for -Wall. Just break doing nothing */
13115 ptr_type = current_class;
13117 code = TREE_CODE (qual_wfl);
13119 /* Pos evaluation: non WFL leading expression nodes */
13120 if (code == CONVERT_EXPR
13121 && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
13122 name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
13124 else if (code == INTEGER_CST)
13127 else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
13128 TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
13129 name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
13131 else if (code == TREE_LIST)
13132 name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
13134 else if (code == STRING_CST || code == CONDITIONAL_EXPR
13135 || code == PLUS_EXPR)
13137 qual = TREE_CHAIN (qual);
13138 qual_wfl = QUAL_WFL (qual);
13143 name = EXPR_WFL_NODE (qual_wfl);
13146 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
13151 /* If we have a THIS (from a primary), we set the context accordingly */
13152 if (name == this_identifier_node)
13154 qual = TREE_CHAIN (qual);
13155 qual_wfl = QUAL_WFL (qual);
13156 if (TREE_CODE (qual_wfl) == CALL_EXPR)
13159 name = EXPR_WFL_NODE (qual_wfl);
13162 /* If we have a SUPER, we set the context accordingly */
13163 if (name == super_identifier_node)
13165 current_class = CLASSTYPE_SUPER (ptr_type);
13166 /* Check that there is such a thing as a super class. If not,
13167 return. The error will be caught later on, during the
13169 if (!current_class)
13171 current_class = saved_current_class;
13174 qual = TREE_CHAIN (qual);
13175 /* Do one more interation to set things up */
13176 super_found = again = 1;
13180 /* If name appears within the scope of a local variable declaration
13181 or parameter declaration, then it is an expression name. We don't
13182 carry this test out if we're in the context of the use of SUPER
13184 if (!this_found && !super_found
13185 && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
13186 && (decl = IDENTIFIER_LOCAL_VALUE (name)))
13188 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13189 QUAL_RESOLUTION (qual) = decl;
13192 /* If within the class/interface NAME was found to be used there
13193 exists a (possibly inherited) field named NAME, then this is an
13194 expression name. If we saw a NEW_ARRAY_EXPR before and want to
13195 address length, it is OK. */
13196 else if ((decl = lookup_field_wrapper (ptr_type, name))
13197 || (new_array_found && name == length_identifier_node))
13199 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13200 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
13203 /* We reclassify NAME as yielding to a type name resolution if:
13204 - NAME is a class/interface declared within the compilation
13205 unit containing NAME,
13206 - NAME is imported via a single-type-import declaration,
13207 - NAME is declared in an another compilation unit of the package
13208 of the compilation unit containing NAME,
13209 - NAME is declared by exactly on type-import-on-demand declaration
13210 of the compilation unit containing NAME.
13211 - NAME is actually a STRING_CST. */
13212 else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
13213 || (decl = resolve_and_layout (name, NULL_TREE)))
13215 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
13216 QUAL_RESOLUTION (qual) = decl;
13219 /* Method call, array references and cast are expression name */
13220 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
13221 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
13222 || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
13223 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
13225 /* Check here that NAME isn't declared by more than one
13226 type-import-on-demand declaration of the compilation unit
13227 containing NAME. FIXME */
13229 /* Otherwise, NAME is reclassified as a package name */
13231 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13233 /* Propagate the qualification accross other components of the
13235 for (qual = TREE_CHAIN (qual); qual;
13236 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13238 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13239 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13241 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13244 /* Store the global qualification for the ambiguous part of ID back
13246 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13247 RESOLVE_EXPRESSION_NAME_P (id) = 1;
13248 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13249 RESOLVE_TYPE_NAME_P (id) = 1;
13250 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13251 RESOLVE_PACKAGE_NAME_P (id) = 1;
13253 /* Restore the current class */
13254 current_class = saved_current_class;
13258 breakdown_qualified (left, right, source)
13259 tree *left, *right, source;
13261 char *p = IDENTIFIER_POINTER (source), *base;
13262 int l = IDENTIFIER_LENGTH (source);
13264 /* Breakdown NAME into REMAINDER . IDENTIFIER */
13267 while (*p != '.' && p != base)
13270 /* We didn't find a '.'. Return an error */
13276 *right = get_identifier (p+1);
13277 *left = get_identifier (IDENTIFIER_POINTER (source));
13283 /* Patch tree nodes in a function body. When a BLOCK is found, push
13284 local variable decls if present.
13285 Same as java_complete_lhs, but does resolve static finals to values. */
13288 java_complete_tree (node)
13291 node = java_complete_lhs (node);
13292 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13293 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13294 && !flag_emit_xref)
13296 tree value = DECL_INITIAL (node);
13297 DECL_INITIAL (node) = NULL_TREE;
13298 push_obstacks (&permanent_obstack, &permanent_obstack);
13299 value = fold_constant_for_init (value, node);
13301 DECL_INITIAL (node) = value;
13302 if (value != NULL_TREE)
13304 /* fold_constant_for_init sometimes widen the original type
13305 of the constant (i.e. byte to int.) It's not desirable,
13306 especially if NODE is a function argument. */
13307 if (TREE_CODE (value) == INTEGER_CST
13308 && TREE_TYPE (node) != TREE_TYPE (value))
13309 return convert (TREE_TYPE (node), value);
13318 java_stabilize_reference (node)
13321 if (TREE_CODE (node) == COMPOUND_EXPR)
13323 tree op0 = TREE_OPERAND (node, 0);
13324 tree op1 = TREE_OPERAND (node, 1);
13325 TREE_OPERAND (node, 0) = save_expr (op0);
13326 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13329 return stabilize_reference (node);
13332 /* Patch tree nodes in a function body. When a BLOCK is found, push
13333 local variable decls if present.
13334 Same as java_complete_tree, but does not resolve static finals to values. */
13337 java_complete_lhs (node)
13340 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13343 /* CONVERT_EXPR always has its type set, even though it needs to be
13345 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13348 /* The switch block implements cases processing container nodes
13349 first. Contained nodes are always written back. Leaves come
13350 next and return a value. */
13351 switch (TREE_CODE (node))
13355 /* 1- Block section.
13356 Set the local values on decl names so we can identify them
13357 faster when they're referenced. At that stage, identifiers
13358 are legal so we don't check for declaration errors. */
13359 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13361 DECL_CONTEXT (cn) = current_function_decl;
13362 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13364 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13365 CAN_COMPLETE_NORMALLY (node) = 1;
13368 tree stmt = BLOCK_EXPR_BODY (node);
13370 int error_seen = 0;
13371 if (TREE_CODE (stmt) == COMPOUND_EXPR)
13373 /* Re-order from (((A; B); C); ...; Z) to
13374 (A; (B; (C ; (...; Z)))).
13375 This makes it easier to scan the statements left-to-right
13376 without using recursion (which might overflow the stack
13377 if the block has many statements. */
13380 tree left = TREE_OPERAND (stmt, 0);
13381 if (TREE_CODE (left) != COMPOUND_EXPR)
13383 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13384 TREE_OPERAND (left, 1) = stmt;
13387 BLOCK_EXPR_BODY (node) = stmt;
13390 /* Now do the actual complete, without deep recursion for
13392 ptr = &BLOCK_EXPR_BODY (node);
13393 while (TREE_CODE (*ptr) == COMPOUND_EXPR
13394 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13396 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13397 tree *next = &TREE_OPERAND (*ptr, 1);
13398 TREE_OPERAND (*ptr, 0) = cur;
13399 if (cur == empty_stmt_node)
13401 /* Optimization; makes it easier to detect empty bodies.
13402 Most useful for <clinit> with all-constant initializer. */
13406 if (TREE_CODE (cur) == ERROR_MARK)
13408 else if (! CAN_COMPLETE_NORMALLY (cur))
13413 if (TREE_CODE (wfl_op2) == BLOCK)
13414 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13415 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13416 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13420 if (TREE_CODE (wfl_op2) != CASE_EXPR
13421 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13422 unreachable_stmt_error (*ptr);
13426 *ptr = java_complete_tree (*ptr);
13428 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13429 return error_mark_node;
13430 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13432 /* Turn local bindings to null */
13433 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13434 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13436 TREE_TYPE (node) = void_type_node;
13439 /* 2- They are expressions but ultimately deal with statements */
13442 wfl_op1 = TREE_OPERAND (node, 0);
13443 COMPLETE_CHECK_OP_0 (node);
13444 /* 14.19 A throw statement cannot complete normally. */
13445 CAN_COMPLETE_NORMALLY (node) = 0;
13446 return patch_throw_statement (node, wfl_op1);
13448 case SYNCHRONIZED_EXPR:
13449 wfl_op1 = TREE_OPERAND (node, 0);
13450 return patch_synchronized_statement (node, wfl_op1);
13453 return patch_try_statement (node);
13455 case TRY_FINALLY_EXPR:
13456 COMPLETE_CHECK_OP_0 (node);
13457 COMPLETE_CHECK_OP_1 (node);
13458 CAN_COMPLETE_NORMALLY (node)
13459 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13460 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13461 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13464 case CLEANUP_POINT_EXPR:
13465 COMPLETE_CHECK_OP_0 (node);
13466 TREE_TYPE (node) = void_type_node;
13467 CAN_COMPLETE_NORMALLY (node) =
13468 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13471 case WITH_CLEANUP_EXPR:
13472 COMPLETE_CHECK_OP_0 (node);
13473 COMPLETE_CHECK_OP_2 (node);
13474 CAN_COMPLETE_NORMALLY (node) =
13475 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13476 TREE_TYPE (node) = void_type_node;
13479 case LABELED_BLOCK_EXPR:
13480 PUSH_LABELED_BLOCK (node);
13481 if (LABELED_BLOCK_BODY (node))
13482 COMPLETE_CHECK_OP_1 (node);
13483 TREE_TYPE (node) = void_type_node;
13484 POP_LABELED_BLOCK ();
13486 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13488 LABELED_BLOCK_BODY (node) = NULL_TREE;
13489 CAN_COMPLETE_NORMALLY (node) = 1;
13491 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13492 CAN_COMPLETE_NORMALLY (node) = 1;
13495 case EXIT_BLOCK_EXPR:
13496 /* We don't complete operand 1, because it's the return value of
13497 the EXIT_BLOCK_EXPR which doesn't exist it Java */
13498 return patch_bc_statement (node);
13501 cn = java_complete_tree (TREE_OPERAND (node, 0));
13502 if (cn == error_mark_node)
13505 /* First, the case expression must be constant. Values of final
13506 fields are accepted. */
13508 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13509 && JDECL_P (TREE_OPERAND (cn, 1))
13510 && FIELD_FINAL (TREE_OPERAND (cn, 1))
13511 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13513 push_obstacks (&permanent_obstack, &permanent_obstack);
13514 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13515 TREE_OPERAND (cn, 1));
13519 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13521 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13522 parse_error_context (node, "Constant expression required");
13523 return error_mark_node;
13526 nn = ctxp->current_loop;
13528 /* It must be assignable to the type of the switch expression. */
13529 if (!try_builtin_assignconv (NULL_TREE,
13530 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13532 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13533 parse_error_context
13535 "Incompatible type for case. Can't convert `%s' to `int'",
13536 lang_printable_name (TREE_TYPE (cn), 0));
13537 return error_mark_node;
13540 cn = fold (convert (int_type_node, cn));
13542 /* Multiple instance of a case label bearing the same
13543 value is checked during code generation. The case
13544 expression is allright so far. */
13545 TREE_OPERAND (node, 0) = cn;
13546 TREE_TYPE (node) = void_type_node;
13547 CAN_COMPLETE_NORMALLY (node) = 1;
13548 TREE_SIDE_EFFECTS (node) = 1;
13552 nn = ctxp->current_loop;
13553 /* Only one default label is allowed per switch statement */
13554 if (SWITCH_HAS_DEFAULT (nn))
13556 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13557 parse_error_context (wfl_operator,
13558 "Duplicate case label: `default'");
13559 return error_mark_node;
13562 SWITCH_HAS_DEFAULT (nn) = 1;
13563 TREE_TYPE (node) = void_type_node;
13564 TREE_SIDE_EFFECTS (node) = 1;
13565 CAN_COMPLETE_NORMALLY (node) = 1;
13571 /* Check whether the loop was enclosed in a labeled
13572 statement. If not, create one, insert the loop in it and
13574 nn = patch_loop_statement (node);
13576 /* Anyways, walk the body of the loop */
13577 if (TREE_CODE (node) == LOOP_EXPR)
13578 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13579 /* Switch statement: walk the switch expression and the cases */
13581 node = patch_switch_statement (node);
13583 if (TREE_OPERAND (node, 0) == error_mark_node)
13584 nn = error_mark_node;
13587 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13588 /* If we returned something different, that's because we
13589 inserted a label. Pop the label too. */
13592 if (CAN_COMPLETE_NORMALLY (node))
13593 CAN_COMPLETE_NORMALLY (nn) = 1;
13594 POP_LABELED_BLOCK ();
13601 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13602 return patch_exit_expr (node);
13606 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13607 if (TREE_OPERAND (node, 0) == error_mark_node)
13608 return error_mark_node;
13609 /* then-else branches */
13610 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13611 if (TREE_OPERAND (node, 1) == error_mark_node)
13612 return error_mark_node;
13613 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13614 if (TREE_OPERAND (node, 2) == error_mark_node)
13615 return error_mark_node;
13616 return patch_if_else_statement (node);
13619 case CONDITIONAL_EXPR:
13621 wfl_op1 = TREE_OPERAND (node, 0);
13622 COMPLETE_CHECK_OP_0 (node);
13623 wfl_op2 = TREE_OPERAND (node, 1);
13624 COMPLETE_CHECK_OP_1 (node);
13625 wfl_op3 = TREE_OPERAND (node, 2);
13626 COMPLETE_CHECK_OP_2 (node);
13627 return patch_conditional_expr (node, wfl_op1, wfl_op2);
13629 /* 3- Expression section */
13630 case COMPOUND_EXPR:
13631 wfl_op2 = TREE_OPERAND (node, 1);
13632 TREE_OPERAND (node, 0) = nn =
13633 java_complete_tree (TREE_OPERAND (node, 0));
13634 if (wfl_op2 == empty_stmt_node)
13635 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13638 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13640 /* An unreachable condition in a do-while statement
13641 is *not* (technically) an unreachable statement. */
13643 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13644 nn = EXPR_WFL_NODE (nn);
13645 if (TREE_CODE (nn) != EXIT_EXPR)
13647 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13648 parse_error_context (wfl_operator, "Unreachable statement");
13651 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13652 if (TREE_OPERAND (node, 1) == error_mark_node)
13653 return error_mark_node;
13654 CAN_COMPLETE_NORMALLY (node)
13655 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13657 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13661 /* CAN_COMPLETE_NORMALLY (node) = 0; */
13662 return patch_return (node);
13664 case EXPR_WITH_FILE_LOCATION:
13665 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13666 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13669 node = resolve_expression_name (node, NULL);
13670 if (node == error_mark_node)
13672 /* Keep line number information somewhere were it doesn't
13673 disrupt the completion process. */
13674 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13676 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13677 TREE_OPERAND (node, 1) = wfl;
13679 CAN_COMPLETE_NORMALLY (node) = 1;
13684 int save_lineno = lineno;
13685 lineno = EXPR_WFL_LINENO (node);
13686 body = java_complete_tree (EXPR_WFL_NODE (node));
13687 lineno = save_lineno;
13688 EXPR_WFL_NODE (node) = body;
13689 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13690 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13691 if (body == empty_stmt_node)
13693 /* Optimization; makes it easier to detect empty bodies. */
13696 if (body == error_mark_node)
13698 /* Its important for the evaluation of assignment that
13699 this mark on the TREE_TYPE is propagated. */
13700 TREE_TYPE (node) = error_mark_node;
13701 return error_mark_node;
13704 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13709 case NEW_ARRAY_EXPR:
13710 /* Patch all the dimensions */
13712 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13714 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13715 tree dim = convert (int_type_node,
13716 java_complete_tree (TREE_VALUE (cn)));
13717 if (dim == error_mark_node)
13724 TREE_VALUE (cn) = dim;
13725 /* Setup the location of the current dimension, for
13726 later error report. */
13727 TREE_PURPOSE (cn) =
13728 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13729 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13732 /* They complete the array creation expression, if no errors
13734 CAN_COMPLETE_NORMALLY (node) = 1;
13735 return (flag ? error_mark_node
13736 : force_evaluation_order (patch_newarray (node)));
13738 case NEW_ANONYMOUS_ARRAY_EXPR:
13739 /* Create the array type if necessary. */
13740 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13742 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13743 if (!(type = resolve_type_during_patch (type)))
13744 return error_mark_node;
13745 type = build_array_from_name (type, NULL_TREE,
13746 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13747 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13749 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13750 ANONYMOUS_ARRAY_INITIALIZER (node));
13751 if (node == error_mark_node)
13752 return error_mark_node;
13753 CAN_COMPLETE_NORMALLY (node) = 1;
13756 case NEW_CLASS_EXPR:
13758 /* Complete function's argument(s) first */
13759 if (complete_function_arguments (node))
13760 return error_mark_node;
13763 tree decl, wfl = TREE_OPERAND (node, 0);
13764 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13766 node = patch_method_invocation (node, NULL_TREE,
13767 NULL_TREE, 0, &decl);
13768 if (node == error_mark_node)
13769 return error_mark_node;
13771 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13772 /* If we call this(...), register signature and positions */
13774 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
13775 tree_cons (wfl, decl,
13776 DECL_CONSTRUCTOR_CALLS (current_function_decl));
13777 CAN_COMPLETE_NORMALLY (node) = 1;
13778 return force_evaluation_order (node);
13782 /* Save potential wfls */
13783 wfl_op1 = TREE_OPERAND (node, 0);
13784 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13786 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13787 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13788 && DECL_INITIAL (nn) != NULL_TREE)
13792 push_obstacks (&permanent_obstack, &permanent_obstack);
13793 value = fold_constant_for_init (nn, nn);
13796 if (value != NULL_TREE)
13798 tree type = TREE_TYPE (value);
13799 if (JPRIMITIVE_TYPE_P (type) ||
13800 (type == string_ptr_type_node && ! flag_emit_class_files))
13801 return empty_stmt_node;
13803 DECL_INITIAL (nn) = NULL_TREE;
13805 wfl_op2 = TREE_OPERAND (node, 1);
13807 if (TREE_OPERAND (node, 0) == error_mark_node)
13808 return error_mark_node;
13810 flag = COMPOUND_ASSIGN_P (wfl_op2);
13813 /* This might break when accessing outer field from inner
13814 class. TESTME, FIXME */
13815 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
13817 /* Hand stablize the lhs on both places */
13818 TREE_OPERAND (node, 0) = lvalue;
13819 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
13820 (flag_emit_class_files ? lvalue : save_expr (lvalue));
13822 /* 15.25.2.a: Left hand is not an array access. FIXME */
13823 /* Now complete the RHS. We write it back later on. */
13824 nn = java_complete_tree (TREE_OPERAND (node, 1));
13826 if ((cn = patch_string (nn)))
13829 /* The last part of the rewrite for E1 op= E2 is to have
13830 E1 = (T)(E1 op E2), with T being the type of E1. */
13831 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
13832 TREE_TYPE (lvalue), nn));
13834 /* 15.25.2.b: Left hand is an array access. FIXME */
13837 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13838 function to complete this RHS. Note that a NEW_ARRAY_INIT
13839 might have been already fully expanded if created as a result
13840 of processing an anonymous array initializer. We avoid doing
13841 the operation twice by testing whether the node already bears
13843 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13844 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13845 TREE_OPERAND (node, 1));
13846 /* Otherwise we simply complete the RHS */
13848 nn = java_complete_tree (TREE_OPERAND (node, 1));
13850 if (nn == error_mark_node)
13851 return error_mark_node;
13853 /* Write back the RHS as we evaluated it. */
13854 TREE_OPERAND (node, 1) = nn;
13856 /* In case we're handling = with a String as a RHS, we need to
13857 produce a String out of the RHS (it might still be a
13858 STRING_CST or a StringBuffer at this stage */
13859 if ((nn = patch_string (TREE_OPERAND (node, 1))))
13860 TREE_OPERAND (node, 1) = nn;
13862 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13863 TREE_OPERAND (node, 1))))
13865 /* We return error_mark_node if outer_field_access_fix
13866 detects we write into a final. */
13867 if (nn == error_mark_node)
13868 return error_mark_node;
13873 node = patch_assignment (node, wfl_op1, wfl_op2);
13874 /* Reorganize the tree if necessary. */
13875 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
13876 || JSTRING_P (TREE_TYPE (node))))
13877 node = java_refold (node);
13880 CAN_COMPLETE_NORMALLY (node) = 1;
13892 case TRUNC_MOD_EXPR:
13893 case TRUNC_DIV_EXPR:
13895 case TRUTH_ANDIF_EXPR:
13896 case TRUTH_ORIF_EXPR:
13903 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13904 knows how to handle those cases. */
13905 wfl_op1 = TREE_OPERAND (node, 0);
13906 wfl_op2 = TREE_OPERAND (node, 1);
13908 CAN_COMPLETE_NORMALLY (node) = 1;
13909 /* Don't complete string nodes if dealing with the PLUS operand. */
13910 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13912 nn = java_complete_tree (wfl_op1);
13913 if (nn == error_mark_node)
13914 return error_mark_node;
13916 TREE_OPERAND (node, 0) = nn;
13918 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13920 nn = java_complete_tree (wfl_op2);
13921 if (nn == error_mark_node)
13922 return error_mark_node;
13924 TREE_OPERAND (node, 1) = nn;
13926 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13928 case INSTANCEOF_EXPR:
13929 wfl_op1 = TREE_OPERAND (node, 0);
13930 COMPLETE_CHECK_OP_0 (node);
13931 if (flag_emit_xref)
13933 TREE_TYPE (node) = boolean_type_node;
13936 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13938 case UNARY_PLUS_EXPR:
13940 case TRUTH_NOT_EXPR:
13942 case PREDECREMENT_EXPR:
13943 case PREINCREMENT_EXPR:
13944 case POSTDECREMENT_EXPR:
13945 case POSTINCREMENT_EXPR:
13947 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13948 how to handle those cases. */
13949 wfl_op1 = TREE_OPERAND (node, 0);
13950 CAN_COMPLETE_NORMALLY (node) = 1;
13951 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13952 if (TREE_OPERAND (node, 0) == error_mark_node)
13953 return error_mark_node;
13954 node = patch_unaryop (node, wfl_op1);
13955 CAN_COMPLETE_NORMALLY (node) = 1;
13959 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13960 how to handle those cases. */
13961 wfl_op1 = TREE_OPERAND (node, 0);
13962 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13963 if (TREE_OPERAND (node, 0) == error_mark_node)
13964 return error_mark_node;
13965 if (!flag_emit_class_files && !flag_emit_xref)
13966 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13967 /* The same applies to wfl_op2 */
13968 wfl_op2 = TREE_OPERAND (node, 1);
13969 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13970 if (TREE_OPERAND (node, 1) == error_mark_node)
13971 return error_mark_node;
13972 if (!flag_emit_class_files && !flag_emit_xref)
13973 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13974 return patch_array_ref (node);
13979 case COMPONENT_REF:
13980 /* The first step in the re-write of qualified name handling. FIXME.
13981 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13982 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13983 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13985 tree name = TREE_OPERAND (node, 1);
13986 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13987 if (field == NULL_TREE)
13989 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13990 return error_mark_node;
13992 if (! FIELD_STATIC (field))
13994 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13995 return error_mark_node;
14000 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
14004 /* Can't use THIS in a static environment */
14007 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14008 parse_error_context (wfl_operator,
14009 "Keyword `this' used outside allowed context");
14010 TREE_TYPE (node) = error_mark_node;
14011 return error_mark_node;
14013 if (ctxp->explicit_constructor_p)
14015 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14016 parse_error_context
14017 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
14018 TREE_TYPE (node) = error_mark_node;
14019 return error_mark_node;
14021 return current_this;
14023 case CLASS_LITERAL:
14024 CAN_COMPLETE_NORMALLY (node) = 1;
14025 node = patch_incomplete_class_ref (node);
14026 if (node == error_mark_node)
14027 return error_mark_node;
14030 case INSTANCE_INITIALIZERS_EXPR:
14031 in_instance_initializer++;
14032 node = java_complete_tree (TREE_OPERAND (node, 0));
14033 in_instance_initializer--;
14034 if (node != error_mark_node)
14035 TREE_TYPE (node) = void_type_node;
14037 return error_mark_node;
14041 CAN_COMPLETE_NORMALLY (node) = 1;
14042 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
14043 and it's time to turn it into the appropriate String object */
14044 if ((nn = patch_string (node)))
14047 fatal ("No case for tree code `%s' - java_complete_tree\n",
14048 tree_code_name [TREE_CODE (node)]);
14053 /* Complete function call's argument. Return a non zero value is an
14054 error was found. */
14057 complete_function_arguments (node)
14063 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14064 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
14066 tree wfl = TREE_VALUE (cn), parm, temp;
14067 parm = java_complete_tree (wfl);
14069 if (parm == error_mark_node)
14074 /* If have a string literal that we haven't transformed yet or a
14075 crafted string buffer, as a result of use of the the String
14076 `+' operator. Build `parm.toString()' and expand it. */
14077 if ((temp = patch_string (parm)))
14079 /* Inline PRIMTYPE.TYPE read access */
14080 parm = maybe_build_primttype_type_ref (parm, wfl);
14082 TREE_VALUE (cn) = parm;
14084 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
14088 /* Sometimes (for loops and variable initialized during their
14089 declaration), we want to wrap a statement around a WFL and turn it
14093 build_debugable_stmt (location, stmt)
14097 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
14099 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
14100 EXPR_WFL_LINECOL (stmt) = location;
14102 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
14107 build_expr_block (body, decls)
14110 tree node = make_node (BLOCK);
14111 BLOCK_EXPR_DECLS (node) = decls;
14112 BLOCK_EXPR_BODY (node) = body;
14114 TREE_TYPE (node) = TREE_TYPE (body);
14115 TREE_SIDE_EFFECTS (node) = 1;
14119 /* Create a new function block and link it approriately to current
14120 function block chain */
14125 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
14128 /* Link block B supercontext to the previous block. The current
14129 function DECL is used as supercontext when enter_a_block is called
14130 for the first time for a given function. The current function body
14131 (DECL_FUNCTION_BODY) is set to be block B. */
14137 tree fndecl = current_function_decl;
14140 BLOCK_SUPERCONTEXT (b) = current_static_block;
14141 current_static_block = b;
14144 else if (!DECL_FUNCTION_BODY (fndecl))
14146 BLOCK_SUPERCONTEXT (b) = fndecl;
14147 DECL_FUNCTION_BODY (fndecl) = b;
14151 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
14152 DECL_FUNCTION_BODY (fndecl) = b;
14157 /* Exit a block by changing the current function body
14158 (DECL_FUNCTION_BODY) to the current block super context, only if
14159 the block being exited isn't the method's top level one. */
14165 if (current_function_decl)
14167 b = DECL_FUNCTION_BODY (current_function_decl);
14168 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
14169 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
14173 b = current_static_block;
14175 if (BLOCK_SUPERCONTEXT (b))
14176 current_static_block = BLOCK_SUPERCONTEXT (b);
14181 /* Lookup for NAME in the nested function's blocks, all the way up to
14182 the current toplevel one. It complies with Java's local variable
14186 lookup_name_in_blocks (name)
14189 tree b = GET_CURRENT_BLOCK (current_function_decl);
14191 while (b != current_function_decl)
14195 /* Paranoid sanity check. To be removed */
14196 if (TREE_CODE (b) != BLOCK)
14197 fatal ("non block expr function body - lookup_name_in_blocks");
14199 for (current = BLOCK_EXPR_DECLS (b); current;
14200 current = TREE_CHAIN (current))
14201 if (DECL_NAME (current) == name)
14203 b = BLOCK_SUPERCONTEXT (b);
14209 maybe_absorb_scoping_blocks ()
14211 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
14213 tree b = exit_block ();
14214 java_method_add_stmt (current_function_decl, b);
14215 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
14220 /* This section of the source is reserved to build_* functions that
14221 are building incomplete tree nodes and the patch_* functions that
14222 are completing them. */
14224 /* Wrap a non WFL node around a WFL. */
14226 build_wfl_wrap (node, location)
14230 tree wfl, node_to_insert = node;
14232 /* We want to process THIS . xxx symbolicaly, to keep it consistent
14233 with the way we're processing SUPER. A THIS from a primary as a
14234 different form than a SUPER. Turn THIS into something symbolic */
14235 if (TREE_CODE (node) == THIS_EXPR)
14236 node_to_insert = wfl = build_wfl_node (this_identifier_node);
14238 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14240 EXPR_WFL_LINECOL (wfl) = location;
14241 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14246 /* Build a super() constructor invocation. Returns empty_stmt_node if
14247 we're currently dealing with the class java.lang.Object. */
14250 build_super_invocation (mdecl)
14253 if (DECL_CONTEXT (mdecl) == object_type_node)
14254 return empty_stmt_node;
14257 tree super_wfl = build_wfl_node (super_identifier_node);
14258 tree a = NULL_TREE, t;
14259 /* If we're dealing with an anonymous class, pass the arguments
14260 of the crafted constructor along. */
14261 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14263 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14264 for (; t != end_params_node; t = TREE_CHAIN (t))
14265 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14267 return build_method_invocation (super_wfl, a);
14271 /* Build a SUPER/THIS qualified method invocation. */
14274 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14281 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14282 EXPR_WFL_LINECOL (wfl) = lloc;
14283 invok = build_method_invocation (name, args);
14284 return make_qualified_primary (wfl, invok, rloc);
14287 /* Build an incomplete CALL_EXPR node. */
14290 build_method_invocation (name, args)
14294 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14295 TREE_SIDE_EFFECTS (call) = 1;
14296 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14300 /* Build an incomplete new xxx(...) node. */
14303 build_new_invocation (name, args)
14306 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14307 TREE_SIDE_EFFECTS (call) = 1;
14308 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14312 /* Build an incomplete assignment expression. */
14315 build_assignment (op, op_location, lhs, rhs)
14316 int op, op_location;
14320 /* Build the corresponding binop if we deal with a Compound
14321 Assignment operator. Mark the binop sub-tree as part of a
14322 Compound Assignment expression */
14323 if (op != ASSIGN_TK)
14325 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14326 COMPOUND_ASSIGN_P (rhs) = 1;
14328 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14329 TREE_SIDE_EFFECTS (assignment) = 1;
14330 EXPR_WFL_LINECOL (assignment) = op_location;
14334 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14337 print_int_node (node)
14340 static char buffer [80];
14341 if (TREE_CONSTANT_OVERFLOW (node))
14342 sprintf (buffer, "<overflow>");
14344 if (TREE_INT_CST_HIGH (node) == 0)
14345 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14346 TREE_INT_CST_LOW (node));
14347 else if (TREE_INT_CST_HIGH (node) == -1
14348 && TREE_INT_CST_LOW (node) != 0)
14351 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14352 -TREE_INT_CST_LOW (node));
14355 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14356 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14361 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14365 check_final_assignment (lvalue, wfl)
14368 if (TREE_CODE (lvalue) == COMPOUND_EXPR
14369 && JDECL_P (TREE_OPERAND (lvalue, 1)))
14370 lvalue = TREE_OPERAND (lvalue, 1);
14372 /* When generating class files, references to the `length' field
14373 look a bit different. */
14374 if ((flag_emit_class_files
14375 && TREE_CODE (lvalue) == COMPONENT_REF
14376 && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14377 && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14378 || (TREE_CODE (lvalue) == FIELD_DECL
14379 && FIELD_FINAL (lvalue)
14380 && !DECL_CLINIT_P (current_function_decl)
14381 && !DECL_FINIT_P (current_function_decl)))
14383 parse_error_context
14384 (wfl, "Can't assign a value to the final variable `%s'",
14385 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14391 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14392 read. This is needed to avoid circularities in the implementation
14393 of these fields in libjava. */
14396 maybe_build_primttype_type_ref (rhs, wfl)
14399 tree to_return = NULL_TREE;
14400 tree rhs_type = TREE_TYPE (rhs);
14401 if (TREE_CODE (rhs) == COMPOUND_EXPR)
14403 tree n = TREE_OPERAND (rhs, 1);
14404 if (TREE_CODE (n) == VAR_DECL
14405 && DECL_NAME (n) == TYPE_identifier_node
14406 && rhs_type == class_ptr_type
14407 && TREE_CODE (EXPR_WFL_NODE (wfl)) == IDENTIFIER_NODE)
14409 const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14410 if (!strncmp (self_name, "java.lang.", 10))
14411 to_return = build_primtype_type_ref (self_name);
14414 return (to_return ? to_return : rhs );
14417 /* 15.25 Assignment operators. */
14420 patch_assignment (node, wfl_op1, wfl_op2)
14425 tree rhs = TREE_OPERAND (node, 1);
14426 tree lvalue = TREE_OPERAND (node, 0), llvalue;
14427 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14428 int error_found = 0;
14429 int lvalue_from_array = 0;
14431 /* Can't assign to a (blank) final. */
14432 if (check_final_assignment (lvalue, wfl_op1))
14435 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14437 /* Lhs can be a named variable */
14438 if (JDECL_P (lvalue))
14440 lhs_type = TREE_TYPE (lvalue);
14442 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14443 comment on reason why */
14444 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14446 lhs_type = TREE_TYPE (lvalue);
14447 lvalue_from_array = 1;
14449 /* Or a field access */
14450 else if (TREE_CODE (lvalue) == COMPONENT_REF)
14451 lhs_type = TREE_TYPE (lvalue);
14452 /* Or a function return slot */
14453 else if (TREE_CODE (lvalue) == RESULT_DECL)
14454 lhs_type = TREE_TYPE (lvalue);
14455 /* Otherwise, we might want to try to write into an optimized static
14456 final, this is an of a different nature, reported further on. */
14457 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14458 && resolve_expression_name (wfl_op1, &llvalue))
14460 if (!error_found && check_final_assignment (llvalue, wfl_op1))
14462 /* What we should do instead is resetting the all the flags
14463 previously set, exchange lvalue for llvalue and continue. */
14465 return error_mark_node;
14468 lhs_type = TREE_TYPE (lvalue);
14472 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14476 rhs_type = TREE_TYPE (rhs);
14477 /* 5.1 Try the assignment conversion for builtin type. */
14478 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14480 /* 5.2 If it failed, try a reference conversion */
14481 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14482 lhs_type = promote_type (rhs_type);
14484 /* 15.25.2 If we have a compound assignment, convert RHS into the
14486 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14487 new_rhs = convert (lhs_type, rhs);
14489 /* Explicit cast required. This is an error */
14492 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14493 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14495 char operation [32]; /* Max size known */
14497 /* If the assignment is part of a declaration, we use the WFL of
14498 the declared variable to point out the error and call it a
14499 declaration problem. If the assignment is a genuine =
14500 operator, we call is a operator `=' problem, otherwise we
14501 call it an assignment problem. In both of these last cases,
14502 we use the WFL of the operator to indicate the error. */
14504 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14507 strcpy (operation, "declaration");
14511 wfl = wfl_operator;
14512 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14513 strcpy (operation, "assignment");
14514 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14515 strcpy (operation, "`return'");
14517 strcpy (operation, "`='");
14520 if (!valid_cast_to_p (rhs_type, lhs_type))
14521 parse_error_context
14522 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14523 operation, t1, t2);
14525 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14526 operation, t1, t2);
14527 free (t1); free (t2);
14531 /* Inline read access to java.lang.PRIMTYPE.TYPE */
14533 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14536 return error_mark_node;
14538 /* 10.10: Array Store Exception runtime check */
14539 if (!flag_emit_class_files
14541 && lvalue_from_array
14542 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14545 tree base = lvalue;
14547 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14548 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14549 base = TREE_OPERAND (lvalue, 0);
14552 if (flag_bounds_check)
14553 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14555 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14558 /* Build the invocation of _Jv_CheckArrayStore */
14559 new_rhs = save_expr (new_rhs);
14560 check = build (CALL_EXPR, void_type_node,
14561 build_address_of (soft_checkarraystore_node),
14562 tree_cons (NULL_TREE, base,
14563 build_tree_list (NULL_TREE, new_rhs)),
14565 TREE_SIDE_EFFECTS (check) = 1;
14567 /* We have to decide on an insertion point */
14568 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14571 if (flag_bounds_check)
14573 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14574 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14575 build (COMPOUND_EXPR, void_type_node, t, check);
14578 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14579 check, TREE_OPERAND (lvalue, 1));
14583 /* Make sure the bound check will happen before the store check */
14584 if (flag_bounds_check)
14585 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14586 build (COMPOUND_EXPR, void_type_node,
14587 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14589 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14593 TREE_OPERAND (node, 0) = lvalue;
14594 TREE_OPERAND (node, 1) = new_rhs;
14595 TREE_TYPE (node) = lhs_type;
14599 /* Check that type SOURCE can be cast into type DEST. If the cast
14600 can't occur at all, return 0 otherwise 1. This function is used to
14601 produce accurate error messages on the reasons why an assignment
14605 try_reference_assignconv (lhs_type, rhs)
14606 tree lhs_type, rhs;
14608 tree new_rhs = NULL_TREE;
14609 tree rhs_type = TREE_TYPE (rhs);
14611 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14613 /* `null' may be assigned to any reference type */
14614 if (rhs == null_pointer_node)
14615 new_rhs = null_pointer_node;
14616 /* Try the reference assignment conversion */
14617 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14619 /* This is a magic assignment that we process differently */
14620 else if (rhs == soft_exceptioninfo_call_node)
14626 /* Check that RHS can be converted into LHS_TYPE by the assignment
14627 conversion (5.2), for the cases of RHS being a builtin type. Return
14628 NULL_TREE if the conversion fails or if because RHS isn't of a
14629 builtin type. Return a converted RHS if the conversion is possible. */
14632 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14633 tree wfl_op1, lhs_type, rhs;
14635 tree new_rhs = NULL_TREE;
14636 tree rhs_type = TREE_TYPE (rhs);
14638 /* Zero accepted everywhere */
14639 if (TREE_CODE (rhs) == INTEGER_CST
14640 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14641 && JPRIMITIVE_TYPE_P (rhs_type))
14642 new_rhs = convert (lhs_type, rhs);
14644 /* 5.1.1 Try Identity Conversion,
14645 5.1.2 Try Widening Primitive Conversion */
14646 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14647 new_rhs = convert (lhs_type, rhs);
14649 /* Try a narrowing primitive conversion (5.1.3):
14650 - expression is a constant expression of type int AND
14651 - variable is byte, short or char AND
14652 - The value of the expression is representable in the type of the
14654 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14655 && (lhs_type == byte_type_node || lhs_type == char_type_node
14656 || lhs_type == short_type_node))
14658 if (int_fits_type_p (rhs, lhs_type))
14659 new_rhs = convert (lhs_type, rhs);
14660 else if (wfl_op1) /* Might be called with a NULL */
14661 parse_warning_context
14662 (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'",
14663 print_int_node (rhs), lang_printable_name (lhs_type, 0));
14664 /* Reported a warning that will turn into an error further
14665 down, so we don't return */
14671 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14672 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
14673 0 is the conversion test fails. This implements parts the method
14674 invocation convertion (5.3). */
14677 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14678 tree lhs_type, rhs_type;
14680 /* 5.1.1: This is the identity conversion part. */
14681 if (lhs_type == rhs_type)
14684 /* Reject non primitive types */
14685 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14688 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14689 than a char can't be converted into a char. Short can't too, but
14690 the < test below takes care of that */
14691 if (lhs_type == char_type_node && rhs_type == byte_type_node)
14694 /* Accept all promoted type here. Note, we can't use <= in the test
14695 below, because we still need to bounce out assignments of short
14696 to char and the likes */
14697 if (lhs_type == int_type_node
14698 && (rhs_type == promoted_byte_type_node
14699 || rhs_type == promoted_short_type_node
14700 || rhs_type == promoted_char_type_node
14701 || rhs_type == promoted_boolean_type_node))
14704 /* From here, an integral is widened if its precision is smaller
14705 than the precision of the LHS or if the LHS is a floating point
14706 type, or the RHS is a float and the RHS a double. */
14707 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
14708 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14709 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14710 || (rhs_type == float_type_node && lhs_type == double_type_node))
14716 /* Check that something of SOURCE type can be assigned or cast to
14717 something of DEST type at runtime. Return 1 if the operation is
14718 valid, 0 otherwise. If CAST is set to 1, we're treating the case
14719 were SOURCE is cast into DEST, which borrows a lot of the
14720 assignment check. */
14723 valid_ref_assignconv_cast_p (source, dest, cast)
14728 /* SOURCE or DEST might be null if not from a declared entity. */
14729 if (!source || !dest)
14731 if (JNULLP_TYPE_P (source))
14733 if (TREE_CODE (source) == POINTER_TYPE)
14734 source = TREE_TYPE (source);
14735 if (TREE_CODE (dest) == POINTER_TYPE)
14736 dest = TREE_TYPE (dest);
14737 /* Case where SOURCE is a class type */
14738 if (TYPE_CLASS_P (source))
14740 if (TYPE_CLASS_P (dest))
14741 return (source == dest
14742 || inherits_from_p (source, dest)
14743 || enclosing_context_p (source, dest)
14744 || (cast && inherits_from_p (dest, source)));
14745 if (TYPE_INTERFACE_P (dest))
14747 /* If doing a cast and SOURCE is final, the operation is
14748 always correct a compile time (because even if SOURCE
14749 does not implement DEST, a subclass of SOURCE might). */
14750 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14752 /* Otherwise, SOURCE must implement DEST */
14753 return interface_of_p (dest, source);
14755 /* DEST is an array, cast permited if SOURCE is of Object type */
14756 return (cast && source == object_type_node ? 1 : 0);
14758 if (TYPE_INTERFACE_P (source))
14760 if (TYPE_CLASS_P (dest))
14762 /* If not casting, DEST must be the Object type */
14764 return dest == object_type_node;
14765 /* We're doing a cast. The cast is always valid is class
14766 DEST is not final, otherwise, DEST must implement SOURCE */
14767 else if (!CLASS_FINAL (TYPE_NAME (dest)))
14770 return interface_of_p (source, dest);
14772 if (TYPE_INTERFACE_P (dest))
14774 /* If doing a cast, then if SOURCE and DEST contain method
14775 with the same signature but different return type, then
14776 this is a (compile time) error */
14779 tree method_source, method_dest;
14783 for (method_source = TYPE_METHODS (source); method_source;
14784 method_source = TREE_CHAIN (method_source))
14787 build_java_argument_signature (TREE_TYPE (method_source));
14788 source_type = TREE_TYPE (TREE_TYPE (method_source));
14789 source_name = DECL_NAME (method_source);
14790 for (method_dest = TYPE_METHODS (dest);
14791 method_dest; method_dest = TREE_CHAIN (method_dest))
14793 build_java_argument_signature (TREE_TYPE (method_dest))
14794 && source_name == DECL_NAME (method_dest)
14795 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14801 return source == dest || interface_of_p (dest, source);
14805 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14807 if (TYPE_ARRAY_P (source))
14809 if (TYPE_CLASS_P (dest))
14810 return dest == object_type_node;
14811 /* Can't cast an array to an interface unless the interface is
14812 java.lang.Cloneable */
14813 if (TYPE_INTERFACE_P (dest))
14814 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14817 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14818 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14820 /* In case of severe errors, they turn out null */
14821 if (!dest_element_type || !source_element_type)
14823 if (source_element_type == dest_element_type)
14825 return valid_ref_assignconv_cast_p (source_element_type,
14826 dest_element_type, cast);
14834 valid_cast_to_p (source, dest)
14838 if (TREE_CODE (source) == POINTER_TYPE)
14839 source = TREE_TYPE (source);
14840 if (TREE_CODE (dest) == POINTER_TYPE)
14841 dest = TREE_TYPE (dest);
14843 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14844 return valid_ref_assignconv_cast_p (source, dest, 1);
14846 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14852 /* Method invocation conversion test. Return 1 if type SOURCE can be
14853 converted to type DEST through the methond invocation conversion
14857 do_unary_numeric_promotion (arg)
14860 tree type = TREE_TYPE (arg);
14861 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14862 : TREE_CODE (type) == CHAR_TYPE)
14863 arg = convert (int_type_node, arg);
14867 /* Return a non zero value if SOURCE can be converted into DEST using
14868 the method invocation conversion rule (5.3). */
14870 valid_method_invocation_conversion_p (dest, source)
14873 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14874 && valid_builtin_assignconv_identity_widening_p (dest, source))
14875 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14876 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14877 && valid_ref_assignconv_cast_p (source, dest, 0)));
14880 /* Build an incomplete binop expression. */
14883 build_binop (op, op_location, op1, op2)
14888 tree binop = build (op, NULL_TREE, op1, op2);
14889 TREE_SIDE_EFFECTS (binop) = 1;
14890 /* Store the location of the operator, for better error report. The
14891 string of the operator will be rebuild based on the OP value. */
14892 EXPR_WFL_LINECOL (binop) = op_location;
14896 /* Build the string of the operator retained by NODE. If NODE is part
14897 of a compound expression, add an '=' at the end of the string. This
14898 function is called when an error needs to be reported on an
14899 operator. The string is returned as a pointer to a static character
14903 operator_string (node)
14906 #define BUILD_OPERATOR_STRING(S) \
14908 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14912 static char buffer [10];
14913 switch (TREE_CODE (node))
14915 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14916 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14917 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14918 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14919 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14920 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14921 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14922 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14923 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14924 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14925 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14926 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14927 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14928 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14929 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14930 case GT_EXPR: BUILD_OPERATOR_STRING (">");
14931 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14932 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14933 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14934 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14935 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14936 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14937 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14938 case PREINCREMENT_EXPR: /* Fall through */
14939 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14940 case PREDECREMENT_EXPR: /* Fall through */
14941 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14943 fatal ("unregistered operator %s - operator_string",
14944 tree_code_name [TREE_CODE (node)]);
14947 #undef BUILD_OPERATOR_STRING
14950 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
14953 java_decl_equiv (var_acc1, var_acc2)
14954 tree var_acc1, var_acc2;
14956 if (JDECL_P (var_acc1))
14957 return (var_acc1 == var_acc2);
14959 return (TREE_CODE (var_acc1) == COMPONENT_REF
14960 && TREE_CODE (var_acc2) == COMPONENT_REF
14961 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14962 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14963 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14966 /* Return a non zero value if CODE is one of the operators that can be
14967 used in conjunction with the `=' operator in a compound assignment. */
14970 binop_compound_p (code)
14971 enum tree_code code;
14974 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14975 if (binop_lookup [i] == code)
14978 return i < BINOP_COMPOUND_CANDIDATES;
14981 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
14987 tree c, b, ns, decl;
14989 if (TREE_CODE (t) != MODIFY_EXPR)
14992 c = TREE_OPERAND (t, 1);
14993 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14994 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14995 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14998 /* Now the left branch of the binary operator. */
14999 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
15000 if (! (b && TREE_CODE (b) == NOP_EXPR
15001 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
15004 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
15005 if (! (ns && TREE_CODE (ns) == NOP_EXPR
15006 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
15009 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
15010 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
15011 /* It's got to be the an equivalent decl */
15012 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
15014 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
15015 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
15016 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
15017 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
15018 /* Change the right part of the BINOP_EXPR */
15019 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
15025 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
15026 errors but we modify NODE so that it contains the type computed
15027 according to the expression, when it's fixed. Otherwise, we write
15028 error_mark_node as the type. It allows us to further the analysis
15029 of remaining nodes and detects more errors in certain cases. */
15032 patch_binop (node, wfl_op1, wfl_op2)
15037 tree op1 = TREE_OPERAND (node, 0);
15038 tree op2 = TREE_OPERAND (node, 1);
15039 tree op1_type = TREE_TYPE (op1);
15040 tree op2_type = TREE_TYPE (op2);
15041 tree prom_type = NULL_TREE, cn;
15042 int code = TREE_CODE (node);
15044 /* If 1, tell the routine that we have to return error_mark_node
15045 after checking for the initialization of the RHS */
15046 int error_found = 0;
15048 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15052 /* 15.16 Multiplicative operators */
15053 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
15054 case RDIV_EXPR: /* 15.16.2 Division Operator / */
15055 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
15056 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
15057 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15059 if (!JPRIMITIVE_TYPE_P (op1_type))
15060 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15061 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15062 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15063 TREE_TYPE (node) = error_mark_node;
15067 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15068 /* Change the division operator if necessary */
15069 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
15070 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
15072 if (TREE_CODE (prom_type) == INTEGER_TYPE
15073 && flag_use_divide_subroutine
15074 && ! flag_emit_class_files
15075 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
15076 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
15078 /* This one is more complicated. FLOATs are processed by a
15079 function call to soft_fmod. Duplicate the value of the
15080 COMPOUND_ASSIGN_P flag. */
15081 if (code == TRUNC_MOD_EXPR)
15083 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
15084 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
15085 TREE_SIDE_EFFECTS (mod)
15086 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15091 /* 15.17 Additive Operators */
15092 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
15094 /* Operation is valid if either one argument is a string
15095 constant, a String object or a StringBuffer crafted for the
15096 purpose of the a previous usage of the String concatenation
15099 if (TREE_CODE (op1) == STRING_CST
15100 || TREE_CODE (op2) == STRING_CST
15101 || JSTRING_TYPE_P (op1_type)
15102 || JSTRING_TYPE_P (op2_type)
15103 || IS_CRAFTED_STRING_BUFFER_P (op1)
15104 || IS_CRAFTED_STRING_BUFFER_P (op2))
15105 return build_string_concatenation (op1, op2);
15107 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
15109 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
15111 if (!JPRIMITIVE_TYPE_P (op1_type))
15112 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15113 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
15114 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15115 TREE_TYPE (node) = error_mark_node;
15119 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15122 /* 15.18 Shift Operators */
15126 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
15128 if (!JINTEGRAL_TYPE_P (op1_type))
15129 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15132 if (JPRIMITIVE_TYPE_P (op2_type))
15133 parse_error_context (wfl_operator,
15134 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
15135 operator_string (node),
15136 lang_printable_name (op2_type, 0));
15138 parse_error_context (wfl_operator,
15139 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
15140 operator_string (node),
15141 lang_printable_name (op2_type, 0));
15143 TREE_TYPE (node) = error_mark_node;
15148 /* Unary numeric promotion (5.6.1) is performed on each operand
15150 op1 = do_unary_numeric_promotion (op1);
15151 op2 = do_unary_numeric_promotion (op2);
15153 /* The type of the shift expression is the type of the promoted
15154 type of the left-hand operand */
15155 prom_type = TREE_TYPE (op1);
15157 /* Shift int only up to 0x1f and long up to 0x3f */
15158 if (prom_type == int_type_node)
15159 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
15160 build_int_2 (0x1f, 0)));
15162 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
15163 build_int_2 (0x3f, 0)));
15165 /* The >>> operator is a >> operating on unsigned quantities */
15166 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
15169 tree utype = unsigned_type (prom_type);
15170 op1 = convert (utype, op1);
15171 TREE_SET_CODE (node, RSHIFT_EXPR);
15172 TREE_OPERAND (node, 0) = op1;
15173 TREE_OPERAND (node, 1) = op2;
15174 TREE_TYPE (node) = utype;
15175 to_return = convert (prom_type, node);
15176 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
15177 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
15178 TREE_SIDE_EFFECTS (to_return)
15179 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15184 /* 15.19.1 Type Comparison Operator instaceof */
15185 case INSTANCEOF_EXPR:
15187 TREE_TYPE (node) = boolean_type_node;
15189 if (!(op2_type = resolve_type_during_patch (op2)))
15190 return error_mark_node;
15192 /* The first operand must be a reference type or the null type */
15193 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
15194 error_found = 1; /* Error reported further below */
15196 /* The second operand must be a reference type */
15197 if (!JREFERENCE_TYPE_P (op2_type))
15199 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
15200 parse_error_context
15201 (wfl_operator, "Invalid argument `%s' for `instanceof'",
15202 lang_printable_name (op2_type, 0));
15206 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
15208 /* If the first operand is null, the result is always false */
15209 if (op1 == null_pointer_node)
15210 return boolean_false_node;
15211 else if (flag_emit_class_files)
15213 TREE_OPERAND (node, 1) = op2_type;
15214 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
15217 /* Otherwise we have to invoke instance of to figure it out */
15219 return build_instanceof (op1, op2_type);
15221 /* There is no way the expression operand can be an instance of
15222 the type operand. This is a compile time error. */
15225 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15226 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15227 parse_error_context
15228 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15229 t1, lang_printable_name (op2_type, 0));
15236 /* 15.21 Bitwise and Logical Operators */
15240 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15241 /* Binary numeric promotion is performed on both operand and the
15242 expression retain that type */
15243 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15245 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
15246 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15247 /* The type of the bitwise operator expression is BOOLEAN */
15248 prom_type = boolean_type_node;
15251 if (!JINTEGRAL_TYPE_P (op1_type))
15252 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15253 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15254 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15255 TREE_TYPE (node) = error_mark_node;
15257 /* Insert a break here if adding thing before the switch's
15258 break for this case */
15262 /* 15.22 Conditional-And Operator */
15263 case TRUTH_ANDIF_EXPR:
15264 /* 15.23 Conditional-Or Operator */
15265 case TRUTH_ORIF_EXPR:
15266 /* Operands must be of BOOLEAN type */
15267 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
15268 TREE_CODE (op2_type) != BOOLEAN_TYPE)
15270 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15271 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15272 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15273 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15274 TREE_TYPE (node) = boolean_type_node;
15278 /* The type of the conditional operators is BOOLEAN */
15279 prom_type = boolean_type_node;
15282 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15287 /* The type of each of the operands must be a primitive numeric
15289 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15291 if (!JNUMERIC_TYPE_P (op1_type))
15292 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15293 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15294 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15295 TREE_TYPE (node) = boolean_type_node;
15299 /* Binary numeric promotion is performed on the operands */
15300 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15301 /* The type of the relation expression is always BOOLEAN */
15302 prom_type = boolean_type_node;
15305 /* 15.20 Equality Operator */
15308 /* It's time for us to patch the strings. */
15309 if ((cn = patch_string (op1)))
15312 op1_type = TREE_TYPE (op1);
15314 if ((cn = patch_string (op2)))
15317 op2_type = TREE_TYPE (op2);
15320 /* 15.20.1 Numerical Equality Operators == and != */
15321 /* Binary numeric promotion is performed on the operands */
15322 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15323 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15325 /* 15.20.2 Boolean Equality Operators == and != */
15326 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15327 TREE_CODE (op2_type) == BOOLEAN_TYPE)
15328 ; /* Nothing to do here */
15330 /* 15.20.3 Reference Equality Operators == and != */
15331 /* Types have to be either references or the null type. If
15332 they're references, it must be possible to convert either
15333 type to the other by casting conversion. */
15334 else if (op1 == null_pointer_node || op2 == null_pointer_node
15335 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15336 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15337 || valid_ref_assignconv_cast_p (op2_type,
15339 ; /* Nothing to do here */
15341 /* Else we have an error figure what can't be converted into
15342 what and report the error */
15346 t1 = xstrdup (lang_printable_name (op1_type, 0));
15347 parse_error_context
15349 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15350 operator_string (node), t1,
15351 lang_printable_name (op2_type, 0));
15353 TREE_TYPE (node) = boolean_type_node;
15357 prom_type = boolean_type_node;
15362 return error_mark_node;
15364 TREE_OPERAND (node, 0) = op1;
15365 TREE_OPERAND (node, 1) = op2;
15366 TREE_TYPE (node) = prom_type;
15367 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15369 if (flag_emit_xref)
15372 /* fold does not respect side-effect order as required for Java but not C.
15373 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15376 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15377 : ! TREE_SIDE_EFFECTS (node))
15378 node = fold (node);
15382 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15383 zero value, the value of CSTE comes after the valude of STRING */
15386 do_merge_string_cste (cste, string, string_len, after)
15388 const char *string;
15389 int string_len, after;
15391 int len = TREE_STRING_LENGTH (cste) + string_len;
15392 const char *old = TREE_STRING_POINTER (cste);
15393 TREE_STRING_LENGTH (cste) = len;
15394 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15397 strcpy (TREE_STRING_POINTER (cste), string);
15398 strcat (TREE_STRING_POINTER (cste), old);
15402 strcpy (TREE_STRING_POINTER (cste), old);
15403 strcat (TREE_STRING_POINTER (cste), string);
15408 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15409 new STRING_CST on success, NULL_TREE on failure */
15412 merge_string_cste (op1, op2, after)
15416 /* Handle two string constants right away */
15417 if (TREE_CODE (op2) == STRING_CST)
15418 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
15419 TREE_STRING_LENGTH (op2), after);
15421 /* Reasonable integer constant can be treated right away */
15422 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15424 static const char *boolean_true = "true";
15425 static const char *boolean_false = "false";
15426 static const char *null_pointer = "null";
15428 const char *string;
15430 if (op2 == boolean_true_node)
15431 string = boolean_true;
15432 else if (op2 == boolean_false_node)
15433 string = boolean_false;
15434 else if (op2 == null_pointer_node)
15435 string = null_pointer;
15436 else if (TREE_TYPE (op2) == char_type_node)
15438 ch[0] = (char )TREE_INT_CST_LOW (op2);
15443 string = print_int_node (op2);
15445 return do_merge_string_cste (op1, string, strlen (string), after);
15450 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15451 has to be a STRING_CST and the other part must be a STRING_CST or a
15452 INTEGRAL constant. Return a new STRING_CST if the operation
15453 succeed, NULL_TREE otherwise.
15455 If the case we want to optimize for space, we might want to return
15456 NULL_TREE for each invocation of this routine. FIXME */
15459 string_constant_concatenation (op1, op2)
15462 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15467 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15468 rest = (string == op1 ? op2 : op1);
15469 invert = (string == op1 ? 0 : 1 );
15471 /* Walk REST, only if it looks reasonable */
15472 if (TREE_CODE (rest) != STRING_CST
15473 && !IS_CRAFTED_STRING_BUFFER_P (rest)
15474 && !JSTRING_TYPE_P (TREE_TYPE (rest))
15475 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15477 rest = java_complete_tree (rest);
15478 if (rest == error_mark_node)
15479 return error_mark_node;
15480 rest = fold (rest);
15482 return merge_string_cste (string, rest, invert);
15487 /* Implement the `+' operator. Does static optimization if possible,
15488 otherwise create (if necessary) and append elements to a
15489 StringBuffer. The StringBuffer will be carried around until it is
15490 used for a function call or an assignment. Then toString() will be
15491 called on it to turn it into a String object. */
15494 build_string_concatenation (op1, op2)
15498 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15500 if (flag_emit_xref)
15501 return build (PLUS_EXPR, string_type_node, op1, op2);
15503 /* Try to do some static optimization */
15504 if ((result = string_constant_concatenation (op1, op2)))
15507 /* Discard empty strings on either side of the expression */
15508 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15513 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15516 /* If operands are string constant, turn then into object references */
15517 if (TREE_CODE (op1) == STRING_CST)
15518 op1 = patch_string_cst (op1);
15519 if (op2 && TREE_CODE (op2) == STRING_CST)
15520 op2 = patch_string_cst (op2);
15522 /* If either one of the constant is null and the other non null
15523 operand is a String object, return it. */
15524 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15527 /* If OP1 isn't already a StringBuffer, create and
15528 initialize a new one */
15529 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15531 /* Two solutions here:
15532 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15533 2) OP1 is something else, we call new StringBuffer().append(OP1). */
15534 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15535 op1 = BUILD_STRING_BUFFER (op1);
15538 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15539 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15545 /* OP1 is no longer the last node holding a crafted StringBuffer */
15546 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15547 /* Create a node for `{new...,xxx}.append (op2)' */
15549 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15552 /* Mark the last node holding a crafted StringBuffer */
15553 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15555 TREE_SIDE_EFFECTS (op1) = side_effects;
15559 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15560 StringBuffer. If no string were found to be patched, return
15564 patch_string (node)
15567 if (node == error_mark_node)
15568 return error_mark_node;
15569 if (TREE_CODE (node) == STRING_CST)
15570 return patch_string_cst (node);
15571 else if (IS_CRAFTED_STRING_BUFFER_P (node))
15573 int saved = ctxp->explicit_constructor_p;
15574 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15576 /* Temporary disable forbid the use of `this'. */
15577 ctxp->explicit_constructor_p = 0;
15578 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15579 /* String concatenation arguments must be evaluated in order too. */
15580 ret = force_evaluation_order (ret);
15581 /* Restore it at its previous value */
15582 ctxp->explicit_constructor_p = saved;
15588 /* Build the internal representation of a string constant. */
15591 patch_string_cst (node)
15595 if (! flag_emit_class_files)
15597 push_obstacks (&permanent_obstack, &permanent_obstack);
15598 node = get_identifier (TREE_STRING_POINTER (node));
15599 location = alloc_name_constant (CONSTANT_String, node);
15600 node = build_ref_from_constant_pool (location);
15603 TREE_TYPE (node) = string_ptr_type_node;
15604 TREE_CONSTANT (node) = 1;
15608 /* Build an incomplete unary operator expression. */
15611 build_unaryop (op_token, op_location, op1)
15612 int op_token, op_location;
15619 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15620 case MINUS_TK: op = NEGATE_EXPR; break;
15621 case NEG_TK: op = TRUTH_NOT_EXPR; break;
15622 case NOT_TK: op = BIT_NOT_EXPR; break;
15623 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15627 unaryop = build1 (op, NULL_TREE, op1);
15628 TREE_SIDE_EFFECTS (unaryop) = 1;
15629 /* Store the location of the operator, for better error report. The
15630 string of the operator will be rebuild based on the OP value. */
15631 EXPR_WFL_LINECOL (unaryop) = op_location;
15635 /* Special case for the ++/-- operators, since they require an extra
15636 argument to build, which is set to NULL and patched
15637 later. IS_POST_P is 1 if the operator, 0 otherwise. */
15640 build_incdec (op_token, op_location, op1, is_post_p)
15641 int op_token, op_location;
15645 static enum tree_code lookup [2][2] =
15647 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15648 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15650 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
15651 NULL_TREE, op1, NULL_TREE);
15652 TREE_SIDE_EFFECTS (node) = 1;
15653 /* Store the location of the operator, for better error report. The
15654 string of the operator will be rebuild based on the OP value. */
15655 EXPR_WFL_LINECOL (node) = op_location;
15659 /* Build an incomplete cast operator, based on the use of the
15660 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15661 set. java_complete_tree is trained to walk a CONVERT_EXPR even
15662 though its type is already set. */
15665 build_cast (location, type, exp)
15669 tree node = build1 (CONVERT_EXPR, type, exp);
15670 EXPR_WFL_LINECOL (node) = location;
15674 /* Build an incomplete class reference operator. */
15676 build_incomplete_class_ref (location, class_name)
15680 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15681 EXPR_WFL_LINECOL (node) = location;
15685 /* Complete an incomplete class reference operator. */
15687 patch_incomplete_class_ref (node)
15690 tree type = TREE_OPERAND (node, 0);
15693 if (!(ref_type = resolve_type_during_patch (type)))
15694 return error_mark_node;
15696 if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15698 /* A class referenced by `foo.class' is initialized. */
15699 return build_class_init (ref_type, build_class_ref (ref_type));
15702 /* If we're emitting class files and we have to deal with non
15703 primitive types, we invoke (and consider generating) the
15704 synthetic static method `class$'. */
15705 if (!TYPE_DOT_CLASS (current_class))
15706 build_dot_class_method (current_class);
15708 build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15709 return java_complete_tree (ref_type);
15712 /* 15.14 Unary operators. We return error_mark_node in case of error,
15713 but preserve the type of NODE if the type is fixed. */
15716 patch_unaryop (node, wfl_op)
15720 tree op = TREE_OPERAND (node, 0);
15721 tree op_type = TREE_TYPE (op);
15722 tree prom_type = NULL_TREE, value, decl;
15723 int outer_field_flag = 0;
15724 int code = TREE_CODE (node);
15725 int error_found = 0;
15727 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15731 /* 15.13.2 Postfix Increment Operator ++ */
15732 case POSTINCREMENT_EXPR:
15733 /* 15.13.3 Postfix Increment Operator -- */
15734 case POSTDECREMENT_EXPR:
15735 /* 15.14.1 Prefix Increment Operator ++ */
15736 case PREINCREMENT_EXPR:
15737 /* 15.14.2 Prefix Decrement Operator -- */
15738 case PREDECREMENT_EXPR:
15739 op = decl = strip_out_static_field_access_decl (op);
15740 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15741 /* We might be trying to change an outer field accessed using
15743 if (outer_field_flag)
15745 /* Retrieve the decl of the field we're trying to access. We
15746 do that by first retrieving the function we would call to
15747 access the field. It has been already verified that this
15748 field isn't final */
15749 if (flag_emit_class_files)
15750 decl = TREE_OPERAND (op, 0);
15752 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15753 decl = DECL_FUNCTION_ACCESS_DECL (decl);
15755 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15756 else if (!JDECL_P (decl)
15757 && TREE_CODE (decl) != COMPONENT_REF
15758 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15759 && TREE_CODE (decl) != INDIRECT_REF
15760 && !(TREE_CODE (decl) == COMPOUND_EXPR
15761 && TREE_OPERAND (decl, 1)
15762 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15765 /* Before screaming, check that we're not in fact trying to
15766 increment a optimized static final access, in which case
15767 we issue an different error message. */
15768 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15769 && resolve_expression_name (wfl_op, &lvalue)
15770 && check_final_assignment (lvalue, wfl_op)))
15771 parse_error_context (wfl_operator, "Invalid argument to `%s'",
15772 operator_string (node));
15773 TREE_TYPE (node) = error_mark_node;
15777 if (check_final_assignment (op, wfl_op))
15780 /* From now on, we know that op if a variable and that it has a
15781 valid wfl. We use wfl_op to locate errors related to the
15783 else if (!JNUMERIC_TYPE_P (op_type))
15785 parse_error_context
15786 (wfl_op, "Invalid argument type `%s' to `%s'",
15787 lang_printable_name (op_type, 0), operator_string (node));
15788 TREE_TYPE (node) = error_mark_node;
15793 /* Before the addition, binary numeric promotion is performed on
15794 both operands, if really necessary */
15795 if (JINTEGRAL_TYPE_P (op_type))
15797 value = build_int_2 (1, 0);
15798 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15802 value = build_int_2 (1, 0);
15804 binary_numeric_promotion (op_type,
15805 TREE_TYPE (value), &op, &value);
15808 /* We remember we might be accessing an outer field */
15809 if (outer_field_flag)
15811 /* We re-generate an access to the field */
15812 value = build (PLUS_EXPR, TREE_TYPE (op),
15813 build_outer_field_access (wfl_op, decl), value);
15815 /* And we patch the original access$() into a write
15816 with plus_op as a rhs */
15817 return outer_field_access_fix (node, op, value);
15820 /* And write back into the node. */
15821 TREE_OPERAND (node, 0) = op;
15822 TREE_OPERAND (node, 1) = value;
15823 /* Convert the overall back into its original type, if
15824 necessary, and return */
15825 if (JINTEGRAL_TYPE_P (op_type))
15826 return fold (node);
15828 return fold (convert (op_type, node));
15832 /* 15.14.3 Unary Plus Operator + */
15833 case UNARY_PLUS_EXPR:
15834 /* 15.14.4 Unary Minus Operator - */
15836 if (!JNUMERIC_TYPE_P (op_type))
15838 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15839 TREE_TYPE (node) = error_mark_node;
15842 /* Unary numeric promotion is performed on operand */
15845 op = do_unary_numeric_promotion (op);
15846 prom_type = TREE_TYPE (op);
15847 if (code == UNARY_PLUS_EXPR)
15852 /* 15.14.5 Bitwise Complement Operator ~ */
15854 if (!JINTEGRAL_TYPE_P (op_type))
15856 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15857 TREE_TYPE (node) = error_mark_node;
15862 op = do_unary_numeric_promotion (op);
15863 prom_type = TREE_TYPE (op);
15867 /* 15.14.6 Logical Complement Operator ! */
15868 case TRUTH_NOT_EXPR:
15869 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15871 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15872 /* But the type is known. We will report an error if further
15873 attempt of a assignment is made with this rhs */
15874 TREE_TYPE (node) = boolean_type_node;
15878 prom_type = boolean_type_node;
15881 /* 15.15 Cast Expression */
15883 value = patch_cast (node, wfl_operator);
15884 if (value == error_mark_node)
15886 /* If this cast is part of an assignment, we tell the code
15887 that deals with it not to complain about a mismatch,
15888 because things have been cast, anyways */
15889 TREE_TYPE (node) = error_mark_node;
15894 value = fold (value);
15895 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15902 return error_mark_node;
15904 /* There are cases where node has been replaced by something else
15905 and we don't end up returning here: UNARY_PLUS_EXPR,
15906 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15907 TREE_OPERAND (node, 0) = fold (op);
15908 TREE_TYPE (node) = prom_type;
15909 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15910 return fold (node);
15913 /* Generic type resolution that sometimes takes place during node
15914 patching. Returned the resolved type or generate an error
15915 message. Return the resolved type or NULL_TREE. */
15918 resolve_type_during_patch (type)
15921 if (unresolved_type_p (type, NULL))
15923 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15926 parse_error_context (type,
15927 "Class `%s' not found in type declaration",
15928 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15933 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15934 return TREE_TYPE (type_decl);
15939 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15940 found. Otherwise NODE or something meant to replace it is returned. */
15943 patch_cast (node, wfl_operator)
15947 tree op = TREE_OPERAND (node, 0);
15948 tree op_type = TREE_TYPE (op);
15949 tree cast_type = TREE_TYPE (node);
15952 /* First resolve OP_TYPE if unresolved */
15953 if (!(cast_type = resolve_type_during_patch (cast_type)))
15954 return error_mark_node;
15956 /* Check on cast that are proven correct at compile time */
15957 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15960 if (cast_type == op_type)
15963 /* float and double type are converted to the original type main
15964 variant and then to the target type. */
15965 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15966 op = convert (integer_type_node, op);
15968 /* Try widening/narowwing convertion. Potentially, things need
15969 to be worked out in gcc so we implement the extreme cases
15970 correctly. fold_convert() needs to be fixed. */
15971 return convert (cast_type, op);
15974 /* It's also valid to cast a boolean into a boolean */
15975 if (op_type == boolean_type_node && cast_type == boolean_type_node)
15978 /* null can be casted to references */
15979 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15980 return build_null_of_type (cast_type);
15982 /* The remaining legal casts involve conversion between reference
15983 types. Check for their compile time correctness. */
15984 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
15985 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15987 TREE_TYPE (node) = promote_type (cast_type);
15988 /* Now, the case can be determined correct at compile time if
15989 OP_TYPE can be converted into CAST_TYPE by assignment
15990 conversion (5.2) */
15992 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15994 TREE_SET_CODE (node, NOP_EXPR);
15998 if (flag_emit_class_files)
16000 TREE_SET_CODE (node, CONVERT_EXPR);
16004 /* The cast requires a run-time check */
16005 return build (CALL_EXPR, promote_type (cast_type),
16006 build_address_of (soft_checkcast_node),
16007 tree_cons (NULL_TREE, build_class_ref (cast_type),
16008 build_tree_list (NULL_TREE, op)),
16012 /* Any other casts are proven incorrect at compile time */
16013 t1 = xstrdup (lang_printable_name (op_type, 0));
16014 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
16015 t1, lang_printable_name (cast_type, 0));
16017 return error_mark_node;
16020 /* Build a null constant and give it the type TYPE. */
16023 build_null_of_type (type)
16026 tree node = build_int_2 (0, 0);
16027 TREE_TYPE (node) = promote_type (type);
16031 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
16032 a list of indices. */
16034 build_array_ref (location, array, index)
16038 tree node = build (ARRAY_REF, NULL_TREE, array, index);
16039 EXPR_WFL_LINECOL (node) = location;
16043 /* 15.12 Array Access Expression */
16046 patch_array_ref (node)
16049 tree array = TREE_OPERAND (node, 0);
16050 tree array_type = TREE_TYPE (array);
16051 tree index = TREE_OPERAND (node, 1);
16052 tree index_type = TREE_TYPE (index);
16053 int error_found = 0;
16055 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16057 if (TREE_CODE (array_type) == POINTER_TYPE)
16058 array_type = TREE_TYPE (array_type);
16060 /* The array reference must be an array */
16061 if (!TYPE_ARRAY_P (array_type))
16063 parse_error_context
16065 "`[]' can only be applied to arrays. It can't be applied to `%s'",
16066 lang_printable_name (array_type, 0));
16067 TREE_TYPE (node) = error_mark_node;
16071 /* The array index undergoes unary numeric promotion. The promoted
16072 type must be int */
16073 index = do_unary_numeric_promotion (index);
16074 if (TREE_TYPE (index) != int_type_node)
16076 if (valid_cast_to_p (index_type, int_type_node))
16077 parse_error_context (wfl_operator,
16078 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
16079 lang_printable_name (index_type, 0));
16081 parse_error_context (wfl_operator,
16082 "Incompatible type for `[]'. Can't convert `%s' to `int'",
16083 lang_printable_name (index_type, 0));
16084 TREE_TYPE (node) = error_mark_node;
16089 return error_mark_node;
16091 array_type = TYPE_ARRAY_ELEMENT (array_type);
16093 if (flag_emit_class_files || flag_emit_xref)
16095 TREE_OPERAND (node, 0) = array;
16096 TREE_OPERAND (node, 1) = index;
16100 /* The save_expr is for correct evaluation order. It would be cleaner
16101 to use force_evaluation_order (see comment there), but that is
16102 difficult when we also have to deal with bounds checking. */
16103 if (TREE_SIDE_EFFECTS (index))
16104 array = save_expr (array);
16105 node = build_java_arrayaccess (array, array_type, index);
16106 if (TREE_SIDE_EFFECTS (index))
16107 node = build (COMPOUND_EXPR, array_type, array, node);
16109 TREE_TYPE (node) = array_type;
16113 /* 15.9 Array Creation Expressions */
16116 build_newarray_node (type, dims, extra_dims)
16122 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
16123 build_int_2 (extra_dims, 0));
16128 patch_newarray (node)
16131 tree type = TREE_OPERAND (node, 0);
16132 tree dims = TREE_OPERAND (node, 1);
16133 tree cdim, array_type;
16134 int error_found = 0;
16136 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
16138 /* Dimension types are verified. It's better for the types to be
16139 verified in order. */
16140 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
16143 tree dim = TREE_VALUE (cdim);
16145 /* Dim might have been saved during its evaluation */
16146 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
16148 /* The type of each specified dimension must be an integral type. */
16149 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
16152 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
16153 promoted type must be int. */
16156 dim = do_unary_numeric_promotion (dim);
16157 if (TREE_TYPE (dim) != int_type_node)
16161 /* Report errors on types here */
16164 parse_error_context
16165 (TREE_PURPOSE (cdim),
16166 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
16167 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
16168 "Explicit cast needed to" : "Can't"),
16169 lang_printable_name (TREE_TYPE (dim), 0));
16173 TREE_PURPOSE (cdim) = NULL_TREE;
16176 /* Resolve array base type if unresolved */
16177 if (!(type = resolve_type_during_patch (type)))
16182 /* We don't want further evaluation of this bogus array creation
16184 TREE_TYPE (node) = error_mark_node;
16185 return error_mark_node;
16188 /* Set array_type to the actual (promoted) array type of the result. */
16189 if (TREE_CODE (type) == RECORD_TYPE)
16190 type = build_pointer_type (type);
16191 while (--xdims >= 0)
16193 type = promote_type (build_java_array_type (type, -1));
16195 dims = nreverse (dims);
16197 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
16201 = build_java_array_type (type,
16202 TREE_CODE (cdim) == INTEGER_CST
16203 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
16205 array_type = promote_type (array_type);
16207 dims = nreverse (dims);
16209 /* The node is transformed into a function call. Things are done
16210 differently according to the number of dimensions. If the number
16211 of dimension is equal to 1, then the nature of the base type
16212 (primitive or not) matters. */
16214 return build_new_array (type, TREE_VALUE (dims));
16216 /* Can't reuse what's already written in expr.c because it uses the
16217 JVM stack representation. Provide a build_multianewarray. FIXME */
16218 return build (CALL_EXPR, array_type,
16219 build_address_of (soft_multianewarray_node),
16220 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
16221 tree_cons (NULL_TREE,
16222 build_int_2 (ndims, 0), dims )),
16226 /* 10.6 Array initializer. */
16228 /* Build a wfl for array element that don't have one, so we can
16229 pin-point errors. */
16232 maybe_build_array_element_wfl (node)
16235 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16236 return build_expr_wfl (NULL_TREE, ctxp->filename,
16237 ctxp->elc.line, ctxp->elc.prev_col);
16242 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16243 identification of initialized arrays easier to detect during walk
16247 build_new_array_init (location, values)
16251 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16252 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16253 EXPR_WFL_LINECOL (to_return) = location;
16257 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16258 occurred. Otherwise return NODE after having set its type
16262 patch_new_array_init (type, node)
16265 int error_seen = 0;
16266 tree current, element_type;
16267 HOST_WIDE_INT length;
16268 int all_constant = 1;
16269 tree init = TREE_OPERAND (node, 0);
16271 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16273 parse_error_context (node,
16274 "Invalid array initializer for non-array type `%s'",
16275 lang_printable_name (type, 1));
16276 return error_mark_node;
16278 type = TREE_TYPE (type);
16279 element_type = TYPE_ARRAY_ELEMENT (type);
16281 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16283 for (length = 0, current = CONSTRUCTOR_ELTS (init);
16284 current; length++, current = TREE_CHAIN (current))
16286 tree elt = TREE_VALUE (current);
16287 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16289 error_seen |= array_constructor_check_entry (element_type, current);
16290 elt = TREE_VALUE (current);
16291 /* When compiling to native code, STRING_CST is converted to
16292 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16293 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16298 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16299 TREE_PURPOSE (current) = NULL_TREE;
16302 if (elt && TREE_CODE (elt) == TREE_LIST
16303 && TREE_VALUE (elt) == error_mark_node)
16308 return error_mark_node;
16310 /* Create a new type. We can't reuse the one we have here by
16311 patching its dimension because it originally is of dimension -1
16312 hence reused by gcc. This would prevent triangular arrays. */
16313 type = build_java_array_type (element_type, length);
16314 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16315 TREE_TYPE (node) = promote_type (type);
16316 TREE_CONSTANT (init) = all_constant;
16317 TREE_CONSTANT (node) = all_constant;
16321 /* Verify that one entry of the initializer element list can be
16322 assigned to the array base type. Report 1 if an error occurred, 0
16326 array_constructor_check_entry (type, entry)
16329 char *array_type_string = NULL; /* For error reports */
16330 tree value, type_value, new_value, wfl_value, patched;
16331 int error_seen = 0;
16333 new_value = NULL_TREE;
16334 wfl_value = TREE_VALUE (entry);
16336 push_obstacks (&permanent_obstack, &permanent_obstack);
16337 value = java_complete_tree (TREE_VALUE (entry));
16338 /* patch_string return error_mark_node if arg is error_mark_node */
16339 if ((patched = patch_string (value)))
16341 if (value == error_mark_node)
16344 type_value = TREE_TYPE (value);
16346 /* At anytime, try_builtin_assignconv can report a warning on
16347 constant overflow during narrowing. */
16348 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16349 new_value = try_builtin_assignconv (wfl_operator, type, value);
16350 if (!new_value && (new_value = try_reference_assignconv (type, value)))
16351 type_value = promote_type (type);
16354 /* Check and report errors */
16357 const char *msg = (!valid_cast_to_p (type_value, type) ?
16358 "Can't" : "Explicit cast needed to");
16359 if (!array_type_string)
16360 array_type_string = xstrdup (lang_printable_name (type, 1));
16361 parse_error_context
16362 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16363 msg, lang_printable_name (type_value, 1), array_type_string);
16369 new_value = maybe_build_primttype_type_ref (new_value, wfl_value);
16370 TREE_VALUE (entry) = new_value;
16373 if (array_type_string)
16374 free (array_type_string);
16376 TREE_PURPOSE (entry) = NULL_TREE;
16381 build_this (location)
16384 tree node = build_wfl_node (this_identifier_node);
16385 TREE_SET_CODE (node, THIS_EXPR);
16386 EXPR_WFL_LINECOL (node) = location;
16390 /* 14.15 The return statement. It builds a modify expression that
16391 assigns the returned value to the RESULT_DECL that hold the value
16395 build_return (location, op)
16399 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16400 EXPR_WFL_LINECOL (node) = location;
16401 node = build_debugable_stmt (location, node);
16406 patch_return (node)
16409 tree return_exp = TREE_OPERAND (node, 0);
16410 tree meth = current_function_decl;
16411 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16412 int error_found = 0;
16414 TREE_TYPE (node) = error_mark_node;
16415 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16417 /* It's invalid to have a return value within a function that is
16418 declared with the keyword void or that is a constructor */
16419 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16422 /* It's invalid to use a return statement in a static block */
16423 if (DECL_CLINIT_P (current_function_decl))
16426 /* It's invalid to have a no return value within a function that
16427 isn't declared with the keyword `void' */
16428 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16431 if (in_instance_initializer)
16436 if (in_instance_initializer)
16437 parse_error_context (wfl_operator,
16438 "`return' inside instance initializer");
16440 else if (DECL_CLINIT_P (current_function_decl))
16441 parse_error_context (wfl_operator,
16442 "`return' inside static initializer");
16444 else if (!DECL_CONSTRUCTOR_P (meth))
16446 char *t = xstrdup (lang_printable_name (mtype, 0));
16447 parse_error_context (wfl_operator,
16448 "`return' with%s value from `%s %s'",
16449 (error_found == 1 ? "" : "out"),
16450 t, lang_printable_name (meth, 0));
16454 parse_error_context (wfl_operator,
16455 "`return' with value from constructor `%s'",
16456 lang_printable_name (meth, 0));
16457 return error_mark_node;
16460 /* If we have a return_exp, build a modify expression and expand
16461 it. Note: at that point, the assignment is declared valid, but we
16462 may want to carry some more hacks */
16465 tree exp = java_complete_tree (return_exp);
16466 tree modify, patched;
16468 /* If the function returned value and EXP are booleans, EXP has
16469 to be converted into the type of DECL_RESULT, which is integer
16470 (see complete_start_java_method) */
16471 if (TREE_TYPE (exp) == boolean_type_node &&
16472 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16473 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16475 /* `null' can be assigned to a function returning a reference */
16476 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16477 exp == null_pointer_node)
16478 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16480 if ((patched = patch_string (exp)))
16483 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16484 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16485 modify = java_complete_tree (modify);
16487 if (modify != error_mark_node)
16489 TREE_SIDE_EFFECTS (modify) = 1;
16490 TREE_OPERAND (node, 0) = modify;
16493 return error_mark_node;
16495 TREE_TYPE (node) = void_type_node;
16496 TREE_SIDE_EFFECTS (node) = 1;
16500 /* 14.8 The if Statement */
16503 build_if_else_statement (location, expression, if_body, else_body)
16505 tree expression, if_body, else_body;
16509 else_body = empty_stmt_node;
16510 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16511 EXPR_WFL_LINECOL (node) = location;
16512 node = build_debugable_stmt (location, node);
16517 patch_if_else_statement (node)
16520 tree expression = TREE_OPERAND (node, 0);
16522 TREE_TYPE (node) = error_mark_node;
16523 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16525 /* The type of expression must be boolean */
16526 if (TREE_TYPE (expression) != boolean_type_node
16527 && TREE_TYPE (expression) != promoted_boolean_type_node)
16529 parse_error_context
16531 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
16532 lang_printable_name (TREE_TYPE (expression), 0));
16533 return error_mark_node;
16536 TREE_TYPE (node) = void_type_node;
16537 TREE_SIDE_EFFECTS (node) = 1;
16538 CAN_COMPLETE_NORMALLY (node)
16539 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16540 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16544 /* 14.6 Labeled Statements */
16546 /* Action taken when a lableled statement is parsed. a new
16547 LABELED_BLOCK_EXPR is created. No statement is attached to the
16548 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
16551 build_labeled_block (location, label)
16556 tree label_decl, node;
16557 if (label == NULL_TREE || label == continue_identifier_node)
16558 label_name = label;
16561 label_name = merge_qualified_name (label_id, label);
16562 /* Issue an error if we try to reuse a label that was previously
16564 if (IDENTIFIER_LOCAL_VALUE (label_name))
16566 EXPR_WFL_LINECOL (wfl_operator) = location;
16567 parse_error_context (wfl_operator,
16568 "Declaration of `%s' shadows a previous label declaration",
16569 IDENTIFIER_POINTER (label));
16570 EXPR_WFL_LINECOL (wfl_operator) =
16571 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16572 parse_error_context (wfl_operator,
16573 "This is the location of the previous declaration of label `%s'",
16574 IDENTIFIER_POINTER (label));
16575 java_error_count--;
16579 label_decl = create_label_decl (label_name);
16580 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16581 EXPR_WFL_LINECOL (node) = location;
16582 TREE_SIDE_EFFECTS (node) = 1;
16586 /* A labeled statement LBE is attached a statement. */
16589 finish_labeled_statement (lbe, statement)
16590 tree lbe; /* Labeled block expr */
16593 /* In anyways, tie the loop to its statement */
16594 LABELED_BLOCK_BODY (lbe) = statement;
16595 pop_labeled_block ();
16596 POP_LABELED_BLOCK ();
16600 /* 14.10, 14.11, 14.12 Loop Statements */
16602 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16606 build_new_loop (loop_body)
16609 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
16610 TREE_SIDE_EFFECTS (loop) = 1;
16615 /* Create a loop body according to the following structure:
16617 COMPOUND_EXPR (loop main body)
16618 EXIT_EXPR (this order is for while/for loops.
16619 LABELED_BLOCK_EXPR the order is reversed for do loops)
16620 LABEL_DECL (a continue occuring here branches at the
16621 BODY end of this labeled block)
16624 REVERSED, if non zero, tells that the loop condition expr comes
16625 after the body, like in the do-while loop.
16627 To obtain a loop, the loop body structure described above is
16628 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16631 LABEL_DECL (use this label to exit the loop)
16633 <structure described above> */
16636 build_loop_body (location, condition, reversed)
16641 tree first, second, body;
16643 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16644 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16645 condition = build_debugable_stmt (location, condition);
16646 TREE_SIDE_EFFECTS (condition) = 1;
16648 body = build_labeled_block (0, continue_identifier_node);
16649 first = (reversed ? body : condition);
16650 second = (reversed ? condition : body);
16652 build (COMPOUND_EXPR, NULL_TREE,
16653 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16656 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16657 their order) on the current loop. Unlink the current loop from the
16661 finish_loop_body (location, condition, body, reversed)
16663 tree condition, body;
16666 tree to_return = ctxp->current_loop;
16667 tree loop_body = LOOP_EXPR_BODY (to_return);
16670 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16671 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16672 The real EXIT_EXPR is one operand further. */
16673 EXPR_WFL_LINECOL (cnode) = location;
16674 /* This one is for accurate error reports */
16675 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16676 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16678 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16683 /* Tailored version of finish_loop_body for FOR loops, when FOR
16684 loops feature the condition part */
16687 finish_for_loop (location, condition, update, body)
16689 tree condition, update, body;
16691 /* Put the condition and the loop body in place */
16692 tree loop = finish_loop_body (location, condition, body, 0);
16693 /* LOOP is the current loop which has been now popped of the loop
16694 stack. Install the update block */
16695 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16699 /* Try to find the loop a block might be related to. This comprises
16700 the case where the LOOP_EXPR is found as the second operand of a
16701 COMPOUND_EXPR, because the loop happens to have an initialization
16702 part, then expressed as the first operand of the COMPOUND_EXPR. If
16703 the search finds something, 1 is returned. Otherwise, 0 is
16704 returned. The search is assumed to start from a
16705 LABELED_BLOCK_EXPR's block. */
16708 search_loop (statement)
16711 if (TREE_CODE (statement) == LOOP_EXPR)
16714 if (TREE_CODE (statement) == BLOCK)
16715 statement = BLOCK_SUBBLOCKS (statement);
16719 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16720 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16721 statement = TREE_OPERAND (statement, 1);
16723 return (TREE_CODE (statement) == LOOP_EXPR
16724 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16727 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16728 returned otherwise. */
16731 labeled_block_contains_loop_p (block, loop)
16737 if (LABELED_BLOCK_BODY (block) == loop)
16740 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16746 /* If the loop isn't surrounded by a labeled statement, create one and
16747 insert LOOP as its body. */
16750 patch_loop_statement (loop)
16755 TREE_TYPE (loop) = void_type_node;
16756 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16759 loop_label = build_labeled_block (0, NULL_TREE);
16760 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16761 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16762 LABELED_BLOCK_BODY (loop_label) = loop;
16763 PUSH_LABELED_BLOCK (loop_label);
16767 /* 14.13, 14.14: break and continue Statements */
16769 /* Build a break or a continue statement. a null NAME indicates an
16770 unlabeled break/continue statement. */
16773 build_bc_statement (location, is_break, name)
16774 int location, is_break;
16777 tree break_continue, label_block_expr = NULL_TREE;
16781 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
16782 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16783 /* Null means that we don't have a target for this named
16784 break/continue. In this case, we make the target to be the
16785 label name, so that the error can be reported accuratly in
16786 patch_bc_statement. */
16787 label_block_expr = EXPR_WFL_NODE (name);
16789 /* Unlabeled break/continue will be handled during the
16790 break/continue patch operation */
16792 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16794 IS_BREAK_STMT_P (break_continue) = is_break;
16795 TREE_SIDE_EFFECTS (break_continue) = 1;
16796 EXPR_WFL_LINECOL (break_continue) = location;
16797 break_continue = build_debugable_stmt (location, break_continue);
16798 return break_continue;
16801 /* Verification of a break/continue statement. */
16804 patch_bc_statement (node)
16807 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16808 tree labeled_block = ctxp->current_labeled_block;
16809 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16811 /* Having an identifier here means that the target is unknown. */
16812 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16814 parse_error_context (wfl_operator, "No label definition found for `%s'",
16815 IDENTIFIER_POINTER (bc_label));
16816 return error_mark_node;
16818 if (! IS_BREAK_STMT_P (node))
16820 /* It's a continue statement. */
16821 for (;; labeled_block = TREE_CHAIN (labeled_block))
16823 if (labeled_block == NULL_TREE)
16825 if (bc_label == NULL_TREE)
16826 parse_error_context (wfl_operator,
16827 "`continue' must be in loop");
16829 parse_error_context
16830 (wfl_operator, "continue label `%s' does not name a loop",
16831 IDENTIFIER_POINTER (bc_label));
16832 return error_mark_node;
16834 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16835 == continue_identifier_node)
16836 && (bc_label == NULL_TREE
16837 || TREE_CHAIN (labeled_block) == bc_label))
16839 bc_label = labeled_block;
16844 else if (!bc_label)
16846 for (;; labeled_block = TREE_CHAIN (labeled_block))
16848 if (labeled_block == NULL_TREE)
16850 parse_error_context (wfl_operator,
16851 "`break' must be in loop or switch");
16852 return error_mark_node;
16854 target_stmt = LABELED_BLOCK_BODY (labeled_block);
16855 if (TREE_CODE (target_stmt) == SWITCH_EXPR
16856 || search_loop (target_stmt))
16858 bc_label = labeled_block;
16864 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16865 CAN_COMPLETE_NORMALLY (bc_label) = 1;
16867 /* Our break/continue don't return values. */
16868 TREE_TYPE (node) = void_type_node;
16869 /* Encapsulate the break within a compound statement so that it's
16870 expanded all the times by expand_expr (and not clobbered
16871 sometimes, like after a if statement) */
16872 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16873 TREE_SIDE_EFFECTS (node) = 1;
16877 /* Process the exit expression belonging to a loop. Its type must be
16881 patch_exit_expr (node)
16884 tree expression = TREE_OPERAND (node, 0);
16885 TREE_TYPE (node) = error_mark_node;
16886 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16888 /* The type of expression must be boolean */
16889 if (TREE_TYPE (expression) != boolean_type_node)
16891 parse_error_context
16893 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
16894 lang_printable_name (TREE_TYPE (expression), 0));
16895 return error_mark_node;
16897 /* Now we know things are allright, invert the condition, fold and
16899 TREE_OPERAND (node, 0) =
16900 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16902 if (! integer_zerop (TREE_OPERAND (node, 0))
16903 && ctxp->current_loop != NULL_TREE
16904 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16905 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16906 if (! integer_onep (TREE_OPERAND (node, 0)))
16907 CAN_COMPLETE_NORMALLY (node) = 1;
16910 TREE_TYPE (node) = void_type_node;
16914 /* 14.9 Switch statement */
16917 patch_switch_statement (node)
16920 tree se = TREE_OPERAND (node, 0), se_type;
16922 /* Complete the switch expression */
16923 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16924 se_type = TREE_TYPE (se);
16925 /* The type of the switch expression must be char, byte, short or
16927 if (!JINTEGRAL_TYPE_P (se_type))
16929 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16930 parse_error_context (wfl_operator,
16931 "Incompatible type for `switch'. Can't convert `%s' to `int'",
16932 lang_printable_name (se_type, 0));
16933 /* This is what java_complete_tree will check */
16934 TREE_OPERAND (node, 0) = error_mark_node;
16935 return error_mark_node;
16938 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16940 /* Ready to return */
16941 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16943 TREE_TYPE (node) = error_mark_node;
16944 return error_mark_node;
16946 TREE_TYPE (node) = void_type_node;
16947 TREE_SIDE_EFFECTS (node) = 1;
16948 CAN_COMPLETE_NORMALLY (node)
16949 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16950 || ! SWITCH_HAS_DEFAULT (node);
16954 /* 14.18 The try/catch statements */
16957 build_try_statement (location, try_block, catches)
16959 tree try_block, catches;
16961 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16962 EXPR_WFL_LINECOL (node) = location;
16967 build_try_finally_statement (location, try_block, finally)
16969 tree try_block, finally;
16971 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16972 EXPR_WFL_LINECOL (node) = location;
16977 patch_try_statement (node)
16980 int error_found = 0;
16981 tree try = TREE_OPERAND (node, 0);
16982 /* Exception handlers are considered in left to right order */
16983 tree catch = nreverse (TREE_OPERAND (node, 1));
16984 tree current, caught_type_list = NULL_TREE;
16986 /* Check catch clauses, if any. Every time we find an error, we try
16987 to process the next catch clause. We process the catch clause before
16988 the try block so that when processing the try block we can check thrown
16989 exceptions againts the caught type list. */
16990 for (current = catch; current; current = TREE_CHAIN (current))
16992 tree carg_decl, carg_type;
16993 tree sub_current, catch_block, catch_clause;
16996 /* At this point, the structure of the catch clause is
16997 CATCH_EXPR (catch node)
16998 BLOCK (with the decl of the parameter)
17000 MODIFY_EXPR (assignment of the catch parameter)
17001 BLOCK (catch clause block)
17003 catch_clause = TREE_OPERAND (current, 0);
17004 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
17005 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
17007 /* Catch clauses can't have more than one parameter declared,
17008 but it's already enforced by the grammar. Make sure that the
17009 only parameter of the clause statement in of class Throwable
17010 or a subclass of Throwable, but that was done earlier. The
17011 catch clause parameter type has also been resolved. */
17013 /* Just make sure that the catch clause parameter type inherits
17014 from java.lang.Throwable */
17015 if (!inherits_from_p (carg_type, throwable_type_node))
17017 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
17018 parse_error_context (wfl_operator,
17019 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
17020 lang_printable_name (carg_type, 0));
17025 /* Partial check for unreachable catch statement: The catch
17026 clause is reachable iff is no earlier catch block A in
17027 the try statement such that the type of the catch
17028 clause's parameter is the same as or a subclass of the
17029 type of A's parameter */
17031 for (sub_current = catch;
17032 sub_current != current; sub_current = TREE_CHAIN (sub_current))
17034 tree sub_catch_clause, decl;
17035 sub_catch_clause = TREE_OPERAND (sub_current, 0);
17036 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
17038 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
17040 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
17041 parse_error_context
17043 "`catch' not reached because of the catch clause at line %d",
17044 EXPR_WFL_LINENO (sub_current));
17045 unreachable = error_found = 1;
17049 /* Complete the catch clause block */
17050 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
17051 if (catch_block == error_mark_node)
17056 if (CAN_COMPLETE_NORMALLY (catch_block))
17057 CAN_COMPLETE_NORMALLY (node) = 1;
17058 TREE_OPERAND (current, 0) = catch_block;
17063 /* Things to do here: the exception must be thrown */
17065 /* Link this type to the caught type list */
17066 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
17069 PUSH_EXCEPTIONS (caught_type_list);
17070 if ((try = java_complete_tree (try)) == error_mark_node)
17072 if (CAN_COMPLETE_NORMALLY (try))
17073 CAN_COMPLETE_NORMALLY (node) = 1;
17076 /* Verification ends here */
17078 return error_mark_node;
17080 TREE_OPERAND (node, 0) = try;
17081 TREE_OPERAND (node, 1) = catch;
17082 TREE_TYPE (node) = void_type_node;
17086 /* 14.17 The synchronized Statement */
17089 patch_synchronized_statement (node, wfl_op1)
17090 tree node, wfl_op1;
17092 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
17093 tree block = TREE_OPERAND (node, 1);
17095 tree enter, exit, expr_decl, assignment;
17097 if (expr == error_mark_node)
17099 block = java_complete_tree (block);
17103 /* The TYPE of expr must be a reference type */
17104 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
17106 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17107 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
17108 lang_printable_name (TREE_TYPE (expr), 0));
17109 return error_mark_node;
17112 if (flag_emit_xref)
17114 TREE_OPERAND (node, 0) = expr;
17115 TREE_OPERAND (node, 1) = java_complete_tree (block);
17116 CAN_COMPLETE_NORMALLY (node) = 1;
17120 /* Generate a try-finally for the synchronized statement, except
17121 that the handler that catches all throw exception calls
17122 _Jv_MonitorExit and then rethrow the exception.
17123 The synchronized statement is then implemented as:
17126 _Jv_MonitorEnter (expression)
17128 _Jv_MonitorExit (expression)
17132 e = _Jv_exception_info ();
17133 _Jv_MonitorExit (expression)
17137 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
17138 BUILD_MONITOR_ENTER (enter, expr_decl);
17139 BUILD_MONITOR_EXIT (exit, expr_decl);
17140 CAN_COMPLETE_NORMALLY (enter) = 1;
17141 CAN_COMPLETE_NORMALLY (exit) = 1;
17142 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
17143 TREE_SIDE_EFFECTS (assignment) = 1;
17144 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
17145 build (COMPOUND_EXPR, NULL_TREE,
17146 build (WITH_CLEANUP_EXPR, NULL_TREE,
17147 build (COMPOUND_EXPR, NULL_TREE,
17148 assignment, enter),
17151 node = build_expr_block (node, expr_decl);
17153 return java_complete_tree (node);
17156 /* 14.16 The throw Statement */
17159 patch_throw_statement (node, wfl_op1)
17160 tree node, wfl_op1;
17162 tree expr = TREE_OPERAND (node, 0);
17163 tree type = TREE_TYPE (expr);
17164 int unchecked_ok = 0, tryblock_throws_ok = 0;
17166 /* Thrown expression must be assignable to java.lang.Throwable */
17167 if (!try_reference_assignconv (throwable_type_node, expr))
17169 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17170 parse_error_context (wfl_operator,
17171 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
17172 lang_printable_name (type, 0));
17173 /* If the thrown expression was a reference, we further the
17174 compile-time check. */
17175 if (!JREFERENCE_TYPE_P (type))
17176 return error_mark_node;
17179 /* At least one of the following must be true */
17181 /* The type of the throw expression is a not checked exception,
17182 i.e. is a unchecked expression. */
17183 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
17185 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17186 /* An instance can't throw a checked excetion unless that exception
17187 is explicitely declared in the `throws' clause of each
17188 constructor. This doesn't apply to anonymous classes, since they
17189 don't have declared constructors. */
17191 && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
17194 for (current = TYPE_METHODS (current_class); current;
17195 current = TREE_CHAIN (current))
17196 if (DECL_CONSTRUCTOR_P (current)
17197 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
17199 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)",
17200 lang_printable_name (TREE_TYPE (expr), 0));
17201 return error_mark_node;
17205 /* Throw is contained in a try statement and at least one catch
17206 clause can receive the thrown expression or the current method is
17207 declared to throw such an exception. Or, the throw statement is
17208 contained in a method or constructor declaration and the type of
17209 the Expression is assignable to at least one type listed in the
17210 throws clause the declaration. */
17212 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
17213 if (!(unchecked_ok || tryblock_throws_ok))
17215 /* If there is a surrounding try block that has no matching
17216 clatch clause, report it first. A surrounding try block exits
17217 only if there is something after the list of checked
17218 exception thrown by the current function (if any). */
17219 if (IN_TRY_BLOCK_P ())
17220 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
17221 lang_printable_name (type, 0));
17222 /* If we have no surrounding try statement and the method doesn't have
17223 any throws, report it now. FIXME */
17225 /* We report that the exception can't be throw from a try block
17226 in all circumstances but when the `throw' is inside a static
17228 else if (!EXCEPTIONS_P (currently_caught_type_list)
17229 && !tryblock_throws_ok)
17231 if (DECL_CLINIT_P (current_function_decl))
17232 parse_error_context (wfl_operator,
17233 "Checked exception `%s' can't be thrown in initializer",
17234 lang_printable_name (type, 0));
17236 parse_error_context (wfl_operator,
17237 "Checked exception `%s' isn't thrown from a `try' block",
17238 lang_printable_name (type, 0));
17240 /* Otherwise, the current method doesn't have the appropriate
17241 throws declaration */
17243 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
17244 lang_printable_name (type, 0));
17245 return error_mark_node;
17248 if (! flag_emit_class_files && ! flag_emit_xref)
17249 BUILD_THROW (node, expr);
17251 /* If doing xrefs, keep the location where the `throw' was seen. */
17252 if (flag_emit_xref)
17253 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17257 /* Check that exception said to be thrown by method DECL can be
17258 effectively caught from where DECL is invoked. */
17261 check_thrown_exceptions (location, decl)
17266 /* For all the unchecked exceptions thrown by DECL */
17267 for (throws = DECL_FUNCTION_THROWS (decl); throws;
17268 throws = TREE_CHAIN (throws))
17269 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17272 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17273 if (DECL_NAME (decl) == get_identifier ("clone"))
17276 EXPR_WFL_LINECOL (wfl_operator) = location;
17277 if (DECL_FINIT_P (current_function_decl))
17278 parse_error_context
17279 (wfl_operator, "Exception `%s' can't be thrown in initializer",
17280 lang_printable_name (TREE_VALUE (throws), 0));
17283 parse_error_context
17284 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
17285 lang_printable_name (TREE_VALUE (throws), 0),
17286 (DECL_INIT_P (current_function_decl) ?
17287 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17288 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17293 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17294 try-catch blocks, OR is listed in the `throws' clause of the
17298 check_thrown_exceptions_do (exception)
17301 tree list = currently_caught_type_list;
17302 resolve_and_layout (exception, NULL_TREE);
17303 /* First, all the nested try-catch-finally at that stage. The
17304 last element contains `throws' clause exceptions, if any. */
17305 if (IS_UNCHECKED_EXCEPTION_P (exception))
17310 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17311 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17313 list = TREE_CHAIN (list);
17319 purge_unchecked_exceptions (mdecl)
17322 tree throws = DECL_FUNCTION_THROWS (mdecl);
17323 tree new = NULL_TREE;
17327 tree next = TREE_CHAIN (throws);
17328 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17330 TREE_CHAIN (throws) = new;
17335 /* List is inverted here, but it doesn't matter */
17336 DECL_FUNCTION_THROWS (mdecl) = new;
17339 /* 15.24 Conditional Operator ?: */
17342 patch_conditional_expr (node, wfl_cond, wfl_op1)
17343 tree node, wfl_cond, wfl_op1;
17345 tree cond = TREE_OPERAND (node, 0);
17346 tree op1 = TREE_OPERAND (node, 1);
17347 tree op2 = TREE_OPERAND (node, 2);
17348 tree resulting_type = NULL_TREE;
17349 tree t1, t2, patched;
17350 int error_found = 0;
17352 /* Operands of ?: might be StringBuffers crafted as a result of a
17353 string concatenation. Obtain a descent operand here. */
17354 if ((patched = patch_string (op1)))
17355 TREE_OPERAND (node, 1) = op1 = patched;
17356 if ((patched = patch_string (op2)))
17357 TREE_OPERAND (node, 2) = op2 = patched;
17359 t1 = TREE_TYPE (op1);
17360 t2 = TREE_TYPE (op2);
17362 /* The first expression must be a boolean */
17363 if (TREE_TYPE (cond) != boolean_type_node)
17365 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17366 parse_error_context (wfl_operator,
17367 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17368 lang_printable_name (TREE_TYPE (cond), 0));
17372 /* Second and third can be numeric, boolean (i.e. primitive),
17373 references or null. Anything else results in an error */
17374 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17375 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
17376 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17377 || (t1 == boolean_type_node && t2 == boolean_type_node)))
17380 /* Determine the type of the conditional expression. Same types are
17381 easy to deal with */
17383 resulting_type = t1;
17385 /* There are different rules for numeric types */
17386 else if (JNUMERIC_TYPE_P (t1))
17388 /* if byte/short found, the resulting type is short */
17389 if ((t1 == byte_type_node && t2 == short_type_node)
17390 || (t1 == short_type_node && t2 == byte_type_node))
17391 resulting_type = short_type_node;
17393 /* If t1 is a constant int and t2 is of type byte, short or char
17394 and t1's value fits in t2, then the resulting type is t2 */
17395 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17396 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17397 resulting_type = t2;
17399 /* If t2 is a constant int and t1 is of type byte, short or char
17400 and t2's value fits in t1, then the resulting type is t1 */
17401 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17402 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17403 resulting_type = t1;
17405 /* Otherwise, binary numeric promotion is applied and the
17406 resulting type is the promoted type of operand 1 and 2 */
17408 resulting_type = binary_numeric_promotion (t1, t2,
17409 &TREE_OPERAND (node, 1),
17410 &TREE_OPERAND (node, 2));
17413 /* Cases of a reference and a null type */
17414 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17415 resulting_type = t1;
17417 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17418 resulting_type = t2;
17420 /* Last case: different reference types. If a type can be converted
17421 into the other one by assignment conversion, the latter
17422 determines the type of the expression */
17423 else if ((resulting_type = try_reference_assignconv (t1, op2)))
17424 resulting_type = promote_type (t1);
17426 else if ((resulting_type = try_reference_assignconv (t2, op1)))
17427 resulting_type = promote_type (t2);
17429 /* If we don't have any resulting type, we're in trouble */
17430 if (!resulting_type)
17432 char *t = xstrdup (lang_printable_name (t1, 0));
17433 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17434 parse_error_context (wfl_operator,
17435 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17436 t, lang_printable_name (t2, 0));
17443 TREE_TYPE (node) = error_mark_node;
17444 return error_mark_node;
17447 TREE_TYPE (node) = resulting_type;
17448 TREE_SET_CODE (node, COND_EXPR);
17449 CAN_COMPLETE_NORMALLY (node) = 1;
17453 /* Try to constant fold NODE.
17454 If NODE is not a constant expression, return NULL_EXPR.
17455 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17458 fold_constant_for_init (node, context)
17462 tree op0, op1, val;
17463 enum tree_code code = TREE_CODE (node);
17465 if (code == STRING_CST)
17468 if (code == INTEGER_CST || code == REAL_CST)
17469 return convert (TREE_TYPE (context), node);
17476 case TRUNC_MOD_EXPR:
17484 case TRUTH_ANDIF_EXPR:
17485 case TRUTH_ORIF_EXPR:
17492 op0 = TREE_OPERAND (node, 0);
17493 op1 = TREE_OPERAND (node, 1);
17494 val = fold_constant_for_init (op0, context);
17495 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17497 TREE_OPERAND (node, 0) = val;
17498 val = fold_constant_for_init (op1, context);
17499 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17501 TREE_OPERAND (node, 1) = val;
17502 return patch_binop (node, op0, op1);
17504 case UNARY_PLUS_EXPR:
17506 case TRUTH_NOT_EXPR:
17509 op0 = TREE_OPERAND (node, 0);
17510 val = fold_constant_for_init (op0, context);
17511 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17513 TREE_OPERAND (node, 0) = val;
17514 return patch_unaryop (node, op0);
17518 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17519 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17521 TREE_OPERAND (node, 0) = val;
17522 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17523 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17525 TREE_OPERAND (node, 1) = val;
17526 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17527 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17529 TREE_OPERAND (node, 2) = val;
17530 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17531 : TREE_OPERAND (node, 2);
17535 if (! FIELD_FINAL (node)
17536 || DECL_INITIAL (node) == NULL_TREE)
17538 val = DECL_INITIAL (node);
17539 /* Guard against infinite recursion. */
17540 DECL_INITIAL (node) = NULL_TREE;
17541 val = fold_constant_for_init (val, node);
17542 DECL_INITIAL (node) = val;
17545 case EXPR_WITH_FILE_LOCATION:
17546 /* Compare java_complete_tree and resolve_expression_name. */
17547 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17548 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17550 tree name = EXPR_WFL_NODE (node);
17552 if (PRIMARY_P (node))
17554 else if (! QUALIFIED_P (name))
17556 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17557 if (decl == NULL_TREE
17558 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17560 return fold_constant_for_init (decl, decl);
17564 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
17565 qualify_ambiguous_name (node);
17566 if (resolve_field_access (node, &decl, NULL)
17567 && decl != NULL_TREE)
17568 return fold_constant_for_init (decl, decl);
17574 op0 = TREE_OPERAND (node, 0);
17575 val = fold_constant_for_init (op0, context);
17576 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17578 TREE_OPERAND (node, 0) = val;
17582 #ifdef USE_COMPONENT_REF
17584 case COMPONENT_REF:
17593 #ifdef USE_COMPONENT_REF
17594 /* Context is 'T' for TypeName, 'P' for PackageName,
17595 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17598 resolve_simple_name (name, context)
17605 resolve_qualified_name (name, context)