2 /* A Bison parser, made from ./parse.y
3 by GNU Bison version 1.28 */
5 #define YYBISON 1 /* Identify Bison output. */
7 #define yyparse java_parse
9 #define yyerror java_error
10 #define yylval java_lval
11 #define yychar java_char
12 #define yydebug java_debug
13 #define yynerrs java_nerrs
25 #define BOOL_AND_TK 268
26 #define BOOL_OR_TK 269
33 #define PLUS_ASSIGN_TK 276
34 #define MINUS_ASSIGN_TK 277
35 #define MULT_ASSIGN_TK 278
36 #define DIV_ASSIGN_TK 279
37 #define REM_ASSIGN_TK 280
38 #define LS_ASSIGN_TK 281
39 #define SRS_ASSIGN_TK 282
40 #define ZRS_ASSIGN_TK 283
41 #define AND_ASSIGN_TK 284
42 #define XOR_ASSIGN_TK 285
43 #define OR_ASSIGN_TK 286
45 #define PRIVATE_TK 288
46 #define PROTECTED_TK 289
49 #define SYNCHRONIZED_TK 292
50 #define VOLATILE_TK 293
51 #define TRANSIENT_TK 294
54 #define ABSTRACT_TK 297
55 #define MODIFIER_TK 298
58 #define DEFAULT_TK 301
61 #define BOOLEAN_TK 304
63 #define IMPLEMENTS_TK 306
68 #define INSTANCEOF_TK 311
72 #define INTERFACE_TK 315
74 #define EXTENDS_TK 317
75 #define FINALLY_TK 318
84 #define CONTINUE_TK 327
86 #define PACKAGE_TK 329
93 #define INTEGRAL_TK 336
102 #define ASSIGN_ANY_TK 345
103 #define ASSIGN_TK 346
113 #define STRING_LIT_TK 356
114 #define CHAR_LIT_TK 357
115 #define INT_LIT_TK 358
116 #define FP_LIT_TK 359
119 #define BOOL_LIT_TK 362
132 #include "java-tree.h"
140 #include "function.h"
142 #include "defaults.h"
144 #ifndef DIR_SEPARATOR
145 #define DIR_SEPARATOR '/'
148 /* Local function prototypes */
149 static char *java_accstring_lookup PARAMS ((int));
150 static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
151 static void variable_redefinition_error PARAMS ((tree, tree, tree, int));
152 static tree create_class PARAMS ((int, tree, tree, tree));
153 static tree create_interface PARAMS ((int, tree, tree));
154 static void end_class_declaration PARAMS ((int));
155 static tree find_field PARAMS ((tree, tree));
156 static tree lookup_field_wrapper PARAMS ((tree, tree));
157 static int duplicate_declaration_error_p PARAMS ((tree, tree, tree));
158 static void register_fields PARAMS ((int, tree, tree));
159 static tree parser_qualified_classname PARAMS ((int, tree));
160 static int parser_check_super PARAMS ((tree, tree, tree));
161 static int parser_check_super_interface PARAMS ((tree, tree, tree));
162 static void check_modifiers_consistency PARAMS ((int));
163 static tree lookup_cl PARAMS ((tree));
164 static tree lookup_java_method2 PARAMS ((tree, tree, int));
165 static tree method_header PARAMS ((int, tree, tree, tree));
166 static void fix_method_argument_names PARAMS ((tree ,tree));
167 static tree method_declarator PARAMS ((tree, tree));
168 static void parse_warning_context PARAMS ((tree cl, const char *msg, ...))
170 static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list));
171 static void parse_ctor_invocation_error PARAMS ((void));
172 static tree parse_jdk1_1_error PARAMS ((const char *));
173 static void complete_class_report_errors PARAMS ((jdep *));
174 static int process_imports PARAMS ((void));
175 static void read_import_dir PARAMS ((tree));
176 static int find_in_imports_on_demand PARAMS ((tree));
177 static int find_in_imports PARAMS ((tree));
178 static int check_pkg_class_access PARAMS ((tree, tree));
179 static tree resolve_package PARAMS ((tree, tree *));
180 static tree lookup_package_type PARAMS ((const char *, int));
181 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
182 static tree resolve_class PARAMS ((tree, tree, tree, tree));
183 static void declare_local_variables PARAMS ((int, tree, tree));
184 static void source_start_java_method PARAMS ((tree));
185 static void source_end_java_method PARAMS ((void));
186 static void expand_start_java_method PARAMS ((tree));
187 static tree find_name_in_single_imports PARAMS ((tree));
188 static void check_abstract_method_header PARAMS ((tree));
189 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
190 static tree resolve_expression_name PARAMS ((tree, tree *));
191 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
192 static int check_class_interface_creation PARAMS ((int, int, tree,
194 static tree patch_method_invocation PARAMS ((tree, tree, tree,
196 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
197 static tree resolve_and_layout PARAMS ((tree, tree));
198 static tree resolve_no_layout PARAMS ((tree, tree));
199 static int invocation_mode PARAMS ((tree, int));
200 static tree find_applicable_accessible_methods_list PARAMS ((int, tree,
202 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree,
204 static tree find_most_specific_methods_list PARAMS ((tree));
205 static int argument_types_convertible PARAMS ((tree, tree));
206 static tree patch_invoke PARAMS ((tree, tree, tree));
207 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
208 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
209 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
210 static tree obtain_incomplete_type PARAMS ((tree));
211 static tree java_complete_lhs PARAMS ((tree));
212 static tree java_complete_tree PARAMS ((tree));
213 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
214 static void java_complete_expand_method PARAMS ((tree));
215 static int unresolved_type_p PARAMS ((tree, tree *));
216 static void create_jdep_list PARAMS ((struct parser_ctxt *));
217 static tree build_expr_block PARAMS ((tree, tree));
218 static tree enter_block PARAMS ((void));
219 static tree enter_a_block PARAMS ((tree));
220 static tree exit_block PARAMS ((void));
221 static tree lookup_name_in_blocks PARAMS ((tree));
222 static void maybe_absorb_scoping_blocks PARAMS ((void));
223 static tree build_method_invocation PARAMS ((tree, tree));
224 static tree build_new_invocation PARAMS ((tree, tree));
225 static tree build_assignment PARAMS ((int, int, tree, tree));
226 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
227 static int check_final_assignment PARAMS ((tree ,tree));
228 static tree patch_assignment PARAMS ((tree, tree, tree ));
229 static tree patch_binop PARAMS ((tree, tree, tree));
230 static tree build_unaryop PARAMS ((int, int, tree));
231 static tree build_incdec PARAMS ((int, int, tree, int));
232 static tree patch_unaryop PARAMS ((tree, tree));
233 static tree build_cast PARAMS ((int, tree, tree));
234 static tree build_null_of_type PARAMS ((tree));
235 static tree patch_cast PARAMS ((tree, tree));
236 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
237 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
238 static int valid_cast_to_p PARAMS ((tree, tree));
239 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
240 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
241 static tree try_reference_assignconv PARAMS ((tree, tree));
242 static tree build_unresolved_array_type PARAMS ((tree));
243 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
244 static tree build_array_ref PARAMS ((int, tree, tree));
245 static tree patch_array_ref PARAMS ((tree));
246 static tree make_qualified_name PARAMS ((tree, tree, int));
247 static tree merge_qualified_name PARAMS ((tree, tree));
248 static tree make_qualified_primary PARAMS ((tree, tree, int));
249 static int resolve_qualified_expression_name PARAMS ((tree, tree *,
251 static void qualify_ambiguous_name PARAMS ((tree));
252 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
253 static tree build_newarray_node PARAMS ((tree, tree, int));
254 static tree patch_newarray PARAMS ((tree));
255 static tree resolve_type_during_patch PARAMS ((tree));
256 static tree build_this PARAMS ((int));
257 static tree build_wfl_wrap PARAMS ((tree));
258 static tree build_return PARAMS ((int, tree));
259 static tree patch_return PARAMS ((tree));
260 static tree maybe_access_field PARAMS ((tree, tree, tree));
261 static int complete_function_arguments PARAMS ((tree));
262 static int check_for_static_method_reference PARAMS ((tree, tree, tree,
264 static int not_accessible_p PARAMS ((tree, tree, int));
265 static void check_deprecation PARAMS ((tree, tree));
266 static int class_in_current_package PARAMS ((tree));
267 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
268 static tree patch_if_else_statement PARAMS ((tree));
269 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
270 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
271 static tree patch_exit_expr PARAMS ((tree));
272 static tree build_labeled_block PARAMS ((int, tree));
273 static tree finish_labeled_statement PARAMS ((tree, tree));
274 static tree build_bc_statement PARAMS ((int, int, tree));
275 static tree patch_bc_statement PARAMS ((tree));
276 static tree patch_loop_statement PARAMS ((tree));
277 static tree build_new_loop PARAMS ((tree));
278 static tree build_loop_body PARAMS ((int, tree, int));
279 static tree finish_loop_body PARAMS ((int, tree, tree, int));
280 static tree build_debugable_stmt PARAMS ((int, tree));
281 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
282 static tree patch_switch_statement PARAMS ((tree));
283 static tree string_constant_concatenation PARAMS ((tree, tree));
284 static tree build_string_concatenation PARAMS ((tree, tree));
285 static tree patch_string_cst PARAMS ((tree));
286 static tree patch_string PARAMS ((tree));
287 static tree build_try_statement PARAMS ((int, tree, tree));
288 static tree build_try_finally_statement PARAMS ((int, tree, tree));
289 static tree patch_try_statement PARAMS ((tree));
290 static tree patch_synchronized_statement PARAMS ((tree, tree));
291 static tree patch_throw_statement PARAMS ((tree, tree));
292 static void check_thrown_exceptions PARAMS ((int, tree));
293 static int check_thrown_exceptions_do PARAMS ((tree));
294 static void purge_unchecked_exceptions PARAMS ((tree));
295 static void check_throws_clauses PARAMS ((tree, tree, tree));
296 static void finish_method_declaration PARAMS ((tree));
297 static tree build_super_invocation PARAMS ((tree));
298 static int verify_constructor_circularity PARAMS ((tree, tree));
299 static char *constructor_circularity_msg PARAMS ((tree, tree));
300 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
302 static const char *get_printable_method_name PARAMS ((tree));
303 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
304 static tree generate_finit PARAMS ((tree));
305 static void add_instance_initializer PARAMS ((tree));
306 static void fix_constructors PARAMS ((tree));
307 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
309 static void craft_constructor PARAMS ((tree, tree));
310 static int verify_constructor_super PARAMS ((tree));
311 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
312 static void start_artificial_method_body PARAMS ((tree));
313 static void end_artificial_method_body PARAMS ((tree));
314 static int check_method_redefinition PARAMS ((tree, tree));
315 static int reset_method_name PARAMS ((tree));
316 static int check_method_types_complete PARAMS ((tree));
317 static void java_check_regular_methods PARAMS ((tree));
318 static void java_check_abstract_methods PARAMS ((tree));
319 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
320 static void unreachable_stmt_error PARAMS ((tree));
321 static tree find_expr_with_wfl PARAMS ((tree));
322 static void missing_return_error PARAMS ((tree));
323 static tree build_new_array_init PARAMS ((int, tree));
324 static tree patch_new_array_init PARAMS ((tree, tree));
325 static tree maybe_build_array_element_wfl PARAMS ((tree));
326 static int array_constructor_check_entry PARAMS ((tree, tree));
327 static const char *purify_type_name PARAMS ((const char *));
328 static tree fold_constant_for_init PARAMS ((tree, tree));
329 static tree strip_out_static_field_access_decl PARAMS ((tree));
330 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
331 static void static_ref_err PARAMS ((tree, tree, tree));
332 static void parser_add_interface PARAMS ((tree, tree, tree));
333 static void add_superinterfaces PARAMS ((tree, tree));
334 static tree jdep_resolve_class PARAMS ((jdep *));
335 static int note_possible_classname PARAMS ((const char *, int));
336 static void java_complete_expand_classes PARAMS ((void));
337 static void java_complete_expand_class PARAMS ((tree));
338 static void java_complete_expand_methods PARAMS ((tree));
339 static tree cut_identifier_in_qualified PARAMS ((tree));
340 static tree java_stabilize_reference PARAMS ((tree));
341 static tree do_unary_numeric_promotion PARAMS ((tree));
342 static char * operator_string PARAMS ((tree));
343 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
344 static tree merge_string_cste PARAMS ((tree, tree, int));
345 static tree java_refold PARAMS ((tree));
346 static int java_decl_equiv PARAMS ((tree, tree));
347 static int binop_compound_p PARAMS ((enum tree_code));
348 static tree search_loop PARAMS ((tree));
349 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
350 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
351 static void java_check_abstract_method_definitions PARAMS ((tree));
352 static void java_debug_context_do PARAMS ((int));
353 static void java_parser_context_push_initialized_field PARAMS ((void));
354 static void java_parser_context_pop_initialized_field PARAMS ((void));
355 static tree reorder_static_initialized PARAMS ((tree));
356 static void java_parser_context_suspend PARAMS ((void));
357 static void java_parser_context_resume PARAMS ((void));
359 /* JDK 1.1 work. FIXME */
361 static tree maybe_make_nested_class_name PARAMS ((tree));
362 static void make_nested_class_name PARAMS ((tree));
363 static void set_nested_class_simple_name_value PARAMS ((tree, int));
364 static void link_nested_class_to_enclosing PARAMS ((void));
365 static tree find_as_inner_class PARAMS ((tree, tree, tree));
366 static tree find_as_inner_class_do PARAMS ((tree, tree));
367 static int check_inner_class_redefinition PARAMS ((tree, tree));
369 static tree build_thisn_assign PARAMS ((void));
370 static tree build_current_thisn PARAMS ((tree));
371 static tree build_access_to_thisn PARAMS ((tree, tree, int));
372 static tree maybe_build_thisn_access_method PARAMS ((tree));
374 static tree build_outer_field_access PARAMS ((tree, tree));
375 static tree build_outer_field_access_methods PARAMS ((tree));
376 static tree build_outer_field_access_expr PARAMS ((int, tree, tree,
378 static tree build_outer_method_access_method PARAMS ((tree));
379 static tree build_new_access_id PARAMS ((void));
380 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
383 static int outer_field_access_p PARAMS ((tree, tree));
384 static int outer_field_expanded_access_p PARAMS ((tree, tree *,
386 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
387 static tree build_incomplete_class_ref PARAMS ((int, tree));
388 static tree patch_incomplete_class_ref PARAMS ((tree));
389 static tree create_anonymous_class PARAMS ((int, tree));
390 static void patch_anonymous_class PARAMS ((tree, tree, tree));
391 static void add_inner_class_fields PARAMS ((tree, tree));
393 static tree build_dot_class_method PARAMS ((tree));
394 static tree build_dot_class_method_invocation PARAMS ((tree));
395 static void create_new_parser_context PARAMS ((int));
397 /* Number of error found so far. */
398 int java_error_count;
399 /* Number of warning found so far. */
400 int java_warning_count;
401 /* Tell when not to fold, when doing xrefs */
403 /* Cyclic inheritance report, as it can be set by layout_class */
404 char *cyclic_inheritance_report;
406 /* Tell when we're within an instance initializer */
407 static int in_instance_initializer;
409 /* The current parser context */
410 struct parser_ctxt *ctxp;
412 /* List of things that were analyzed for which code will be generated */
413 static struct parser_ctxt *ctxp_for_generation = NULL;
415 /* binop_lookup maps token to tree_code. It is used where binary
416 operations are involved and required by the parser. RDIV_EXPR
417 covers both integral/floating point division. The code is changed
418 once the type of both operator is worked out. */
420 static enum tree_code binop_lookup[19] =
422 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
423 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
424 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
425 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
426 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
428 #define BINOP_LOOKUP(VALUE) \
429 binop_lookup [((VALUE) - PLUS_TK)% \
430 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
432 /* This is the end index for binary operators that can also be used
433 in compound assignements. */
434 #define BINOP_COMPOUND_CANDIDATES 11
436 /* Fake WFL used to report error message. It is initialized once if
437 needed and reused with it's location information is overriden. */
438 tree wfl_operator = NULL_TREE;
440 /* The "$L" identifier we use to create labels. */
441 static tree label_id = NULL_TREE;
443 /* The "StringBuffer" identifier used for the String `+' operator. */
444 static tree wfl_string_buffer = NULL_TREE;
446 /* The "append" identifier used for String `+' operator. */
447 static tree wfl_append = NULL_TREE;
449 /* The "toString" identifier used for String `+' operator. */
450 static tree wfl_to_string = NULL_TREE;
452 /* The "java.lang" import qualified name. */
453 static tree java_lang_id = NULL_TREE;
455 /* The generated `inst$' identifier used for generated enclosing
456 instance/field access functions. */
457 static tree inst_id = NULL_TREE;
459 /* The "java.lang.Cloneable" qualified name. */
460 static tree java_lang_cloneable = NULL_TREE;
462 /* Context and flag for static blocks */
463 static tree current_static_block = NULL_TREE;
465 /* The generated `write_parm_value$' identifier. */
468 /* The list of all packages we've seen so far */
469 static tree package_list = NULL_TREE;
471 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
472 line and point it out. */
473 /* Should point out the one that don't fit. ASCII/unicode, going
476 #define check_modifiers(__message, __value, __mask) do { \
477 if ((__value) & ~(__mask)) \
479 int i, remainder = (__value) & ~(__mask); \
480 for (i = 0; i <= 10; i++) \
481 if ((1 << i) & remainder) \
482 parse_error_context (ctxp->modifier_ctx [i], (__message), \
483 java_accstring_lookup (1 << i)); \
488 #line 414 "./parse.y"
498 #line 424 "./parse.y"
516 #define YYFLAG -32768
519 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
521 static const char yytranslate[] = { 0,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
548 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
549 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
550 27, 28, 29, 30, 31, 32, 33, 34, 35, 36,
551 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
552 47, 48, 49, 50, 51, 52, 53, 54, 55, 56,
553 57, 58, 59, 60, 61, 62, 63, 64, 65, 66,
554 67, 68, 69, 70, 71, 72, 73, 74, 75, 76,
555 77, 78, 79, 80, 81, 82, 83, 84, 85, 86,
556 87, 88, 89, 90, 91, 92, 93, 94, 95, 96,
557 97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
562 static const short yyprhs[] = { 0,
563 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
564 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
565 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
566 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
567 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
568 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
569 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
570 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
571 229, 231, 233, 235, 238, 240, 242, 244, 248, 253,
572 255, 259, 263, 265, 269, 273, 278, 280, 284, 287,
573 291, 295, 297, 299, 300, 304, 307, 311, 315, 320,
574 325, 328, 332, 335, 339, 342, 346, 351, 355, 359,
575 363, 365, 369, 373, 376, 380, 383, 387, 389, 390,
576 393, 396, 398, 402, 406, 408, 411, 413, 416, 420,
577 422, 423, 427, 430, 434, 438, 443, 446, 450, 454,
578 459, 461, 464, 469, 475, 483, 490, 492, 494, 495,
579 500, 501, 507, 508, 514, 515, 522, 526, 531, 534,
580 538, 541, 545, 548, 552, 554, 557, 559, 561, 563,
581 565, 567, 570, 573, 576, 580, 585, 587, 591, 595,
582 598, 602, 604, 606, 608, 611, 613, 615, 617, 620,
583 623, 627, 629, 631, 633, 635, 637, 639, 641, 643,
584 645, 647, 649, 651, 653, 655, 657, 659, 661, 663,
585 665, 667, 669, 671, 673, 676, 679, 682, 685, 688,
586 691, 694, 697, 701, 706, 711, 717, 722, 728, 735,
587 743, 750, 752, 754, 756, 758, 760, 762, 764, 770,
588 773, 777, 782, 790, 798, 799, 803, 808, 811, 815,
589 821, 824, 828, 832, 837, 839, 842, 845, 847, 850,
590 854, 857, 860, 864, 867, 872, 875, 878, 882, 887,
591 890, 892, 900, 908, 915, 919, 925, 930, 938, 945,
592 948, 951, 955, 958, 959, 961, 963, 966, 967, 969,
593 971, 975, 979, 982, 986, 989, 993, 996, 1000, 1003,
594 1007, 1010, 1014, 1017, 1021, 1025, 1028, 1032, 1038, 1044,
595 1047, 1052, 1056, 1058, 1062, 1066, 1071, 1074, 1076, 1079,
596 1082, 1087, 1090, 1094, 1099, 1102, 1105, 1107, 1109, 1111,
597 1113, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1135, 1139,
598 1143, 1147, 1151, 1155, 1159, 1163, 1167, 1171, 1177, 1182,
599 1184, 1189, 1195, 1201, 1208, 1212, 1216, 1221, 1227, 1230,
600 1234, 1235, 1243, 1244, 1251, 1255, 1259, 1261, 1265, 1269,
601 1273, 1277, 1282, 1287, 1292, 1297, 1301, 1305, 1307, 1310,
602 1314, 1318, 1321, 1324, 1328, 1332, 1336, 1340, 1343, 1347,
603 1352, 1358, 1365, 1371, 1378, 1383, 1388, 1393, 1398, 1402,
604 1407, 1411, 1416, 1418, 1420, 1422, 1424, 1427, 1430, 1432,
605 1434, 1437, 1440, 1442, 1445, 1448, 1451, 1454, 1457, 1460,
606 1462, 1465, 1468, 1470, 1473, 1476, 1482, 1487, 1492, 1498,
607 1503, 1506, 1512, 1517, 1523, 1525, 1529, 1533, 1537, 1541,
608 1545, 1549, 1551, 1555, 1559, 1563, 1567, 1569, 1573, 1577,
609 1581, 1585, 1589, 1593, 1595, 1599, 1603, 1607, 1611, 1615,
610 1619, 1623, 1627, 1631, 1635, 1637, 1641, 1645, 1649, 1653,
611 1655, 1659, 1663, 1665, 1669, 1673, 1675, 1679, 1683, 1685,
612 1689, 1693, 1695, 1699, 1703, 1705, 1711, 1716, 1720, 1726,
613 1728, 1730, 1734, 1738, 1740, 1742, 1744, 1746, 1748, 1750
616 static const short yyrhs[] = { 123,
617 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
618 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
619 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
620 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
621 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
622 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
623 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
624 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
625 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
626 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
627 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
628 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
629 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
630 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
631 167, 0, 99, 0, 1, 0, 44, 0, 131, 44,
632 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
633 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
634 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
635 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
636 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
637 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
638 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
639 0, 139, 140, 0, 141, 0, 157, 0, 159, 0,
640 180, 0, 142, 0, 142, 99, 0, 147, 0, 132,
641 0, 167, 0, 112, 143, 99, 0, 131, 112, 143,
642 99, 0, 144, 0, 143, 100, 144, 0, 143, 100,
643 1, 0, 145, 0, 145, 92, 146, 0, 145, 92,
644 1, 0, 145, 92, 146, 1, 0, 122, 0, 145,
645 97, 98, 0, 122, 1, 0, 145, 97, 1, 0,
646 145, 98, 1, 0, 270, 0, 178, 0, 0, 149,
647 148, 156, 0, 149, 1, 0, 112, 150, 154, 0,
648 59, 150, 154, 0, 131, 112, 150, 154, 0, 131,
649 59, 150, 154, 0, 112, 1, 0, 131, 112, 1,
650 0, 59, 1, 0, 131, 59, 1, 0, 131, 1,
651 0, 122, 93, 94, 0, 122, 93, 151, 94, 0,
652 150, 97, 98, 0, 122, 93, 1, 0, 150, 97,
653 1, 0, 152, 0, 151, 100, 152, 0, 151, 100,
654 1, 0, 112, 145, 0, 153, 112, 145, 0, 112,
655 1, 0, 153, 112, 1, 0, 131, 0, 0, 53,
656 155, 0, 53, 1, 0, 116, 0, 155, 100, 116,
657 0, 155, 100, 1, 0, 180, 0, 180, 99, 0,
658 99, 0, 158, 180, 0, 158, 180, 99, 0, 131,
659 0, 0, 161, 160, 163, 0, 162, 154, 0, 131,
660 162, 154, 0, 120, 93, 94, 0, 120, 93, 151,
661 94, 0, 181, 164, 0, 181, 165, 164, 0, 181,
662 183, 164, 0, 181, 165, 183, 164, 0, 182, 0,
663 182, 99, 0, 166, 93, 94, 99, 0, 166, 93,
664 239, 94, 99, 0, 119, 101, 65, 93, 239, 94,
665 99, 0, 119, 101, 65, 93, 94, 99, 0, 76,
666 0, 65, 0, 0, 61, 122, 168, 173, 0, 0,
667 131, 61, 122, 169, 173, 0, 0, 61, 122, 172,
668 170, 173, 0, 0, 131, 61, 122, 172, 171, 173,
669 0, 61, 122, 1, 0, 131, 61, 122, 1, 0,
670 63, 117, 0, 172, 100, 117, 0, 63, 1, 0,
671 172, 100, 1, 0, 95, 96, 0, 95, 174, 96,
672 0, 175, 0, 174, 175, 0, 176, 0, 177, 0,
673 132, 0, 167, 0, 142, 0, 149, 99, 0, 149,
674 1, 0, 95, 96, 0, 95, 179, 96, 0, 95,
675 179, 100, 96, 0, 146, 0, 179, 100, 146, 0,
676 179, 100, 1, 0, 95, 96, 0, 181, 183, 182,
677 0, 95, 0, 96, 0, 184, 0, 183, 184, 0,
678 185, 0, 187, 0, 132, 0, 186, 99, 0, 112,
679 143, 0, 153, 112, 143, 0, 189, 0, 192, 0,
680 196, 0, 197, 0, 208, 0, 212, 0, 189, 0,
681 193, 0, 198, 0, 209, 0, 213, 0, 180, 0,
682 190, 0, 194, 0, 199, 0, 211, 0, 219, 0,
683 220, 0, 221, 0, 223, 0, 222, 0, 225, 0,
684 99, 0, 122, 88, 0, 191, 187, 0, 122, 1,
685 0, 191, 188, 0, 195, 99, 0, 1, 99, 0,
686 1, 95, 0, 1, 96, 0, 166, 93, 1, 0,
687 166, 93, 94, 1, 0, 166, 93, 239, 1, 0,
688 166, 93, 239, 94, 1, 0, 119, 101, 65, 1,
689 0, 119, 101, 65, 93, 1, 0, 119, 101, 65,
690 93, 239, 1, 0, 119, 101, 65, 93, 239, 94,
691 1, 0, 119, 101, 65, 93, 94, 1, 0, 267,
692 0, 251, 0, 252, 0, 248, 0, 249, 0, 245,
693 0, 234, 0, 48, 93, 270, 94, 187, 0, 48,
694 1, 0, 48, 93, 1, 0, 48, 93, 270, 1,
695 0, 48, 93, 270, 94, 188, 56, 187, 0, 48,
696 93, 270, 94, 188, 56, 188, 0, 0, 201, 200,
697 202, 0, 68, 93, 270, 94, 0, 68, 1, 0,
698 68, 93, 1, 0, 68, 93, 270, 94, 1, 0,
699 95, 96, 0, 95, 205, 96, 0, 95, 203, 96,
700 0, 95, 203, 205, 96, 0, 204, 0, 203, 204,
701 0, 205, 183, 0, 206, 0, 205, 206, 0, 62,
702 271, 88, 0, 47, 88, 0, 62, 1, 0, 62,
703 271, 1, 0, 47, 1, 0, 66, 93, 270, 94,
704 0, 207, 187, 0, 66, 1, 0, 66, 93, 1,
705 0, 66, 93, 270, 1, 0, 207, 188, 0, 51,
706 0, 210, 187, 66, 93, 270, 94, 99, 0, 215,
707 99, 270, 99, 217, 94, 187, 0, 215, 99, 99,
708 217, 94, 187, 0, 215, 99, 1, 0, 215, 99,
709 270, 99, 1, 0, 215, 99, 99, 1, 0, 215,
710 99, 270, 99, 217, 94, 188, 0, 215, 99, 99,
711 217, 94, 188, 0, 71, 93, 0, 71, 1, 0,
712 71, 93, 1, 0, 214, 216, 0, 0, 218, 0,
713 186, 0, 218, 1, 0, 0, 218, 0, 195, 0,
714 218, 100, 195, 0, 218, 100, 1, 0, 54, 99,
715 0, 54, 122, 99, 0, 54, 1, 0, 54, 122,
716 1, 0, 73, 99, 0, 73, 122, 99, 0, 73,
717 1, 0, 73, 122, 1, 0, 58, 99, 0, 58,
718 270, 99, 0, 58, 1, 0, 58, 270, 1, 0,
719 49, 270, 99, 0, 49, 1, 0, 49, 270, 1,
720 0, 224, 93, 270, 94, 180, 0, 224, 93, 270,
721 94, 1, 0, 224, 1, 0, 224, 93, 1, 94,
722 0, 224, 93, 1, 0, 131, 0, 70, 180, 226,
723 0, 70, 180, 229, 0, 70, 180, 226, 229, 0,
724 70, 1, 0, 227, 0, 226, 227, 0, 228, 180,
725 0, 60, 93, 152, 94, 0, 60, 1, 0, 60,
726 93, 1, 0, 60, 93, 1, 94, 0, 64, 180,
727 0, 64, 1, 0, 231, 0, 240, 0, 111, 0,
728 76, 0, 93, 270, 94, 0, 234, 0, 244, 0,
729 245, 0, 246, 0, 233, 0, 119, 101, 76, 0,
730 93, 270, 1, 0, 119, 101, 1, 0, 113, 101,
731 1, 0, 59, 101, 1, 0, 113, 97, 98, 0,
732 119, 97, 98, 0, 119, 101, 67, 0, 232, 101,
733 67, 0, 113, 101, 67, 0, 59, 101, 67, 0,
734 72, 116, 93, 239, 94, 0, 72, 116, 93, 94,
735 0, 235, 0, 238, 122, 93, 94, 0, 238, 122,
736 93, 94, 138, 0, 238, 122, 93, 239, 94, 0,
737 238, 122, 93, 239, 94, 138, 0, 72, 1, 99,
738 0, 72, 116, 1, 0, 72, 116, 93, 1, 0,
739 72, 116, 93, 239, 1, 0, 238, 1, 0, 238,
740 122, 1, 0, 0, 72, 116, 93, 239, 94, 236,
741 138, 0, 0, 72, 116, 93, 94, 237, 138, 0,
742 119, 101, 72, 0, 230, 101, 72, 0, 270, 0,
743 239, 100, 270, 0, 239, 100, 1, 0, 72, 113,
744 241, 0, 72, 115, 241, 0, 72, 113, 241, 243,
745 0, 72, 115, 241, 243, 0, 72, 115, 243, 178,
746 0, 72, 113, 243, 178, 0, 72, 1, 98, 0,
747 72, 1, 97, 0, 242, 0, 241, 242, 0, 97,
748 270, 98, 0, 97, 270, 1, 0, 97, 1, 0,
749 97, 98, 0, 243, 97, 98, 0, 243, 97, 1,
750 0, 230, 101, 122, 0, 65, 101, 122, 0, 65,
751 1, 0, 119, 93, 94, 0, 119, 93, 239, 94,
752 0, 230, 101, 122, 93, 94, 0, 230, 101, 122,
753 93, 239, 94, 0, 65, 101, 122, 93, 94, 0,
754 65, 101, 122, 93, 239, 94, 0, 65, 101, 1,
755 94, 0, 65, 101, 1, 101, 0, 119, 97, 270,
756 98, 0, 231, 97, 270, 98, 0, 119, 97, 1,
757 0, 119, 97, 270, 1, 0, 231, 97, 1, 0,
758 231, 97, 270, 1, 0, 230, 0, 119, 0, 248,
759 0, 249, 0, 247, 46, 0, 247, 45, 0, 251,
760 0, 252, 0, 3, 250, 0, 4, 250, 0, 253,
761 0, 3, 1, 0, 4, 1, 0, 46, 250, 0,
762 46, 1, 0, 45, 250, 0, 45, 1, 0, 247,
763 0, 89, 250, 0, 90, 250, 0, 254, 0, 89,
764 1, 0, 90, 1, 0, 93, 113, 243, 94, 250,
765 0, 93, 113, 94, 250, 0, 93, 270, 94, 253,
766 0, 93, 119, 243, 94, 253, 0, 93, 113, 97,
767 1, 0, 93, 1, 0, 93, 113, 243, 94, 1,
768 0, 93, 113, 94, 1, 0, 93, 119, 243, 94,
769 1, 0, 250, 0, 255, 5, 250, 0, 255, 6,
770 250, 0, 255, 7, 250, 0, 255, 5, 1, 0,
771 255, 6, 1, 0, 255, 7, 1, 0, 255, 0,
772 256, 3, 255, 0, 256, 4, 255, 0, 256, 3,
773 1, 0, 256, 4, 1, 0, 256, 0, 257, 8,
774 256, 0, 257, 9, 256, 0, 257, 10, 256, 0,
775 257, 8, 1, 0, 257, 9, 1, 0, 257, 10,
776 1, 0, 257, 0, 258, 20, 257, 0, 258, 18,
777 257, 0, 258, 21, 257, 0, 258, 19, 257, 0,
778 258, 57, 114, 0, 258, 20, 1, 0, 258, 18,
779 1, 0, 258, 21, 1, 0, 258, 19, 1, 0,
780 258, 57, 1, 0, 258, 0, 259, 16, 258, 0,
781 259, 17, 258, 0, 259, 16, 1, 0, 259, 17,
782 1, 0, 259, 0, 260, 11, 259, 0, 260, 11,
783 1, 0, 260, 0, 261, 12, 260, 0, 261, 12,
784 1, 0, 261, 0, 262, 13, 261, 0, 262, 13,
785 1, 0, 262, 0, 263, 14, 262, 0, 263, 14,
786 1, 0, 263, 0, 264, 15, 263, 0, 264, 15,
787 1, 0, 264, 0, 264, 87, 270, 88, 265, 0,
788 264, 87, 88, 1, 0, 264, 87, 1, 0, 264,
789 87, 270, 88, 1, 0, 265, 0, 267, 0, 268,
790 269, 266, 0, 268, 269, 1, 0, 119, 0, 244,
791 0, 246, 0, 91, 0, 92, 0, 266, 0, 270,
798 static const short yyrline[] = { 0,
799 573, 579, 581, 582, 583, 584, 585, 589, 591, 594,
800 596, 597, 600, 602, 605, 609, 613, 617, 623, 625,
801 627, 629, 634, 636, 639, 643, 648, 653, 655, 656,
802 657, 658, 659, 660, 661, 664, 669, 675, 677, 680,
803 686, 688, 692, 694, 697, 724, 726, 730, 743, 745,
804 749, 752, 754, 756, 766, 771, 786, 790, 790, 793,
805 793, 795, 797, 802, 806, 808, 810, 812, 816, 818,
806 820, 827, 833, 838, 842, 851, 861, 863, 866, 868,
807 869, 870, 877, 879, 881, 882, 884, 889, 892, 902,
808 905, 907, 911, 914, 921, 927, 935, 937, 939, 941,
809 943, 947, 949, 953, 964, 965, 969, 972, 974, 976,
810 978, 983, 985, 987, 989, 996, 1002, 1004, 1013, 1015,
811 1019, 1024, 1029, 1033, 1038, 1043, 1048, 1055, 1065, 1067,
812 1069, 1073, 1076, 1078, 1082, 1084, 1085, 1090, 1096, 1103,
813 1119, 1126, 1129, 1132, 1136, 1142, 1146, 1155, 1157, 1159,
814 1163, 1165, 1168, 1175, 1183, 1185, 1189, 1196, 1206, 1210,
815 1210, 1213, 1213, 1216, 1216, 1219, 1219, 1221, 1225, 1231,
816 1236, 1238, 1242, 1245, 1249, 1251, 1254, 1256, 1257, 1259,
817 1263, 1267, 1273, 1278, 1281, 1283, 1287, 1293, 1297, 1302,
818 1311, 1315, 1320, 1332, 1334, 1337, 1339, 1341, 1348, 1352,
819 1355, 1359, 1361, 1362, 1363, 1364, 1365, 1369, 1371, 1372,
820 1373, 1374, 1378, 1380, 1381, 1382, 1383, 1384, 1385, 1386,
821 1387, 1388, 1389, 1392, 1397, 1408, 1411, 1415, 1422, 1432,
822 1438, 1444, 1450, 1452, 1457, 1459, 1464, 1466, 1468, 1470,
823 1472, 1476, 1478, 1479, 1480, 1481, 1482, 1483, 1486, 1492,
824 1494, 1496, 1500, 1505, 1510, 1516, 1526, 1532, 1534, 1536,
825 1543, 1546, 1548, 1550, 1554, 1556, 1559, 1563, 1565, 1568,
826 1575, 1581, 1583, 1585, 1589, 1597, 1600, 1602, 1604, 1608,
827 1613, 1622, 1627, 1630, 1637, 1639, 1641, 1645, 1648, 1657,
828 1664, 1666, 1670, 1683, 1685, 1691, 1697, 1701, 1703, 1707,
829 1710, 1712, 1716, 1719, 1721, 1723, 1727, 1730, 1732, 1734,
830 1738, 1741, 1743, 1745, 1749, 1755, 1757, 1761, 1768, 1770,
831 1772, 1774, 1778, 1790, 1793, 1795, 1800, 1804, 1806, 1813,
832 1821, 1838, 1840, 1845, 1849, 1852, 1857, 1859, 1862, 1864,
833 1866, 1868, 1869, 1870, 1871, 1872, 1876, 1881, 1883, 1885,
834 1887, 1894, 1900, 1909, 1912, 1914, 1916, 1920, 1923, 1925,
835 1929, 1935, 1936, 1942, 1943, 1945, 1947, 1949, 1951, 1953,
836 1962, 1966, 1996, 1999, 2013, 2016, 2020, 2026, 2031, 2035,
837 2038, 2040, 2042, 2046, 2055, 2063, 2065, 2069, 2072, 2076,
838 2082, 2084, 2092, 2119, 2121, 2125, 2130, 2137, 2141, 2144,
839 2146, 2157, 2168, 2173, 2182, 2184, 2188, 2191, 2193, 2198,
840 2203, 2208, 2215, 2217, 2218, 2219, 2222, 2227, 2232, 2234,
841 2235, 2237, 2239, 2240, 2242, 2246, 2249, 2253, 2256, 2260,
842 2262, 2264, 2266, 2267, 2269, 2273, 2282, 2284, 2286, 2299,
843 2301, 2307, 2309, 2311, 2315, 2317, 2322, 2327, 2332, 2334,
844 2336, 2340, 2342, 2347, 2352, 2354, 2358, 2360, 2365, 2370,
845 2375, 2377, 2379, 2383, 2385, 2390, 2395, 2400, 2405, 2407,
846 2409, 2411, 2413, 2415, 2419, 2421, 2426, 2431, 2433, 2437,
847 2439, 2444, 2448, 2450, 2455, 2459, 2461, 2466, 2470, 2472,
848 2477, 2481, 2483, 2488, 2492, 2494, 2499, 2505, 2507, 2511,
849 2513, 2516, 2519, 2527, 2529, 2530, 2533, 2535, 2538, 2542
854 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
856 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
857 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
858 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
859 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
860 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
861 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
862 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
863 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
864 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
865 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
866 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
867 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
868 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
869 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
870 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
871 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
872 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
873 "class_type","interface_type","array_type","name","simple_name","qualified_name",
874 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
875 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
876 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
877 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
878 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
879 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
880 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
881 "class_type_list","method_body","static_initializer","static","constructor_declaration",
882 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
883 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
884 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
885 "interface_member_declaration","constant_declaration","abstract_method_declaration",
886 "array_initializer","variable_initializers","block","block_begin","block_end",
887 "block_statements","block_statement","local_variable_declaration_statement",
888 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
889 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
890 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
891 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
892 "switch_block_statement_group","switch_labels","switch_label","while_expression",
893 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
894 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
895 "statement_expression_list","break_statement","continue_statement","return_statement",
896 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
897 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
898 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
899 "@10","@11","something_dot_new","argument_list","array_creation_expression",
900 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
901 "postfix_expression","post_increment_expression","post_decrement_expression",
902 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
903 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
904 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
905 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
906 "conditional_expression","assignment_expression","assignment","left_hand_side",
907 "assignment_operator","expression","constant_expression", NULL
911 static const short yyr1[] = { 0,
912 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
913 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
914 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
915 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
916 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
917 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
918 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
919 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
920 140, 140, 141, 141, 141, 141, 141, 142, 142, 143,
921 143, 143, 144, 144, 144, 144, 145, 145, 145, 145,
922 145, 146, 146, 148, 147, 147, 149, 149, 149, 149,
923 149, 149, 149, 149, 149, 150, 150, 150, 150, 150,
924 151, 151, 151, 152, 152, 152, 152, 153, 154, 154,
925 154, 155, 155, 155, 156, 156, 156, 157, 157, 158,
926 160, 159, 161, 161, 162, 162, 163, 163, 163, 163,
927 164, 164, 165, 165, 165, 165, 166, 166, 168, 167,
928 169, 167, 170, 167, 171, 167, 167, 167, 172, 172,
929 172, 172, 173, 173, 174, 174, 175, 175, 175, 175,
930 176, 177, 177, 178, 178, 178, 179, 179, 179, 180,
931 180, 181, 182, 183, 183, 184, 184, 184, 185, 186,
932 186, 187, 187, 187, 187, 187, 187, 188, 188, 188,
933 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
934 189, 189, 189, 190, 191, 192, 192, 193, 194, 194,
935 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
936 194, 195, 195, 195, 195, 195, 195, 195, 196, 196,
937 196, 196, 197, 198, 200, 199, 201, 201, 201, 201,
938 202, 202, 202, 202, 203, 203, 204, 205, 205, 206,
939 206, 206, 206, 206, 207, 208, 208, 208, 208, 209,
940 210, 211, 212, 212, 212, 212, 212, 213, 213, 214,
941 214, 214, 215, 216, 216, 216, 216, 217, 217, 218,
942 218, 218, 219, 219, 219, 219, 220, 220, 220, 220,
943 221, 221, 221, 221, 222, 222, 222, 223, 223, 223,
944 223, 223, 224, 225, 225, 225, 225, 226, 226, 227,
945 228, 228, 228, 228, 229, 229, 230, 230, 231, 231,
946 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
947 231, 232, 232, 233, 233, 233, 233, 234, 234, 234,
948 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
949 236, 235, 237, 235, 238, 238, 239, 239, 239, 240,
950 240, 240, 240, 240, 240, 240, 240, 241, 241, 242,
951 242, 242, 243, 243, 243, 244, 244, 244, 245, 245,
952 245, 245, 245, 245, 245, 245, 246, 246, 246, 246,
953 246, 246, 247, 247, 247, 247, 248, 249, 250, 250,
954 250, 250, 250, 250, 250, 251, 251, 252, 252, 253,
955 253, 253, 253, 253, 253, 254, 254, 254, 254, 254,
956 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
957 255, 256, 256, 256, 256, 256, 257, 257, 257, 257,
958 257, 257, 257, 258, 258, 258, 258, 258, 258, 258,
959 258, 258, 258, 258, 259, 259, 259, 259, 259, 260,
960 260, 260, 261, 261, 261, 262, 262, 262, 263, 263,
961 263, 264, 264, 264, 265, 265, 265, 265, 265, 266,
962 266, 267, 267, 268, 268, 268, 269, 269, 270, 271
965 static const short yyr2[] = { 0,
966 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
967 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
968 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
969 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
970 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
971 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
972 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
973 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
974 1, 1, 1, 2, 1, 1, 1, 3, 4, 1,
975 3, 3, 1, 3, 3, 4, 1, 3, 2, 3,
976 3, 1, 1, 0, 3, 2, 3, 3, 4, 4,
977 2, 3, 2, 3, 2, 3, 4, 3, 3, 3,
978 1, 3, 3, 2, 3, 2, 3, 1, 0, 2,
979 2, 1, 3, 3, 1, 2, 1, 2, 3, 1,
980 0, 3, 2, 3, 3, 4, 2, 3, 3, 4,
981 1, 2, 4, 5, 7, 6, 1, 1, 0, 4,
982 0, 5, 0, 5, 0, 6, 3, 4, 2, 3,
983 2, 3, 2, 3, 1, 2, 1, 1, 1, 1,
984 1, 2, 2, 2, 3, 4, 1, 3, 3, 2,
985 3, 1, 1, 1, 2, 1, 1, 1, 2, 2,
986 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
987 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
988 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
989 2, 2, 3, 4, 4, 5, 4, 5, 6, 7,
990 6, 1, 1, 1, 1, 1, 1, 1, 5, 2,
991 3, 4, 7, 7, 0, 3, 4, 2, 3, 5,
992 2, 3, 3, 4, 1, 2, 2, 1, 2, 3,
993 2, 2, 3, 2, 4, 2, 2, 3, 4, 2,
994 1, 7, 7, 6, 3, 5, 4, 7, 6, 2,
995 2, 3, 2, 0, 1, 1, 2, 0, 1, 1,
996 3, 3, 2, 3, 2, 3, 2, 3, 2, 3,
997 2, 3, 2, 3, 3, 2, 3, 5, 5, 2,
998 4, 3, 1, 3, 3, 4, 2, 1, 2, 2,
999 4, 2, 3, 4, 2, 2, 1, 1, 1, 1,
1000 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
1001 3, 3, 3, 3, 3, 3, 3, 5, 4, 1,
1002 4, 5, 5, 6, 3, 3, 4, 5, 2, 3,
1003 0, 7, 0, 6, 3, 3, 1, 3, 3, 3,
1004 3, 4, 4, 4, 4, 3, 3, 1, 2, 3,
1005 3, 2, 2, 3, 3, 3, 3, 2, 3, 4,
1006 5, 6, 5, 6, 4, 4, 4, 4, 3, 4,
1007 3, 4, 1, 1, 1, 1, 2, 2, 1, 1,
1008 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,
1009 2, 2, 1, 2, 2, 5, 4, 4, 5, 4,
1010 2, 5, 4, 5, 1, 3, 3, 3, 3, 3,
1011 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
1012 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1013 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
1014 3, 3, 1, 3, 3, 1, 3, 3, 1, 3,
1015 3, 1, 3, 3, 1, 5, 4, 3, 5, 1,
1016 1, 3, 3, 1, 1, 1, 1, 1, 1, 1
1019 static const short yydefact[] = { 0,
1020 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
1021 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
1022 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
1023 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
1024 167, 0, 0, 163, 63, 0, 69, 42, 40, 0,
1025 0, 0, 61, 0, 49, 0, 26, 171, 17, 169,
1026 15, 0, 160, 0, 0, 68, 16, 0, 0, 59,
1027 168, 0, 165, 64, 69, 50, 48, 12, 0, 10,
1028 11, 173, 0, 8, 9, 13, 14, 15, 0, 179,
1029 181, 0, 180, 0, 175, 177, 178, 172, 170, 164,
1030 67, 71, 72, 70, 0, 162, 0, 57, 113, 0,
1031 129, 111, 0, 0, 90, 93, 129, 0, 0, 0,
1032 115, 0, 0, 183, 182, 174, 176, 0, 0, 60,
1033 166, 0, 0, 0, 0, 108, 99, 88, 0, 0,
1034 0, 0, 107, 21, 18, 22, 20, 19, 114, 129,
1035 112, 0, 129, 74, 73, 192, 75, 23, 0, 86,
1036 0, 77, 79, 83, 85, 0, 80, 0, 81, 141,
1037 129, 87, 82, 0, 58, 119, 116, 0, 128, 0,
1038 121, 0, 131, 132, 130, 120, 118, 92, 0, 91,
1039 95, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1040 0, 0, 0, 6, 5, 2, 3, 4, 7, 339,
1041 0, 414, 0, 103, 413, 337, 0, 346, 342, 360,
1042 0, 338, 343, 344, 345, 430, 415, 416, 445, 419,
1043 420, 423, 433, 452, 457, 464, 475, 480, 483, 486,
1044 489, 492, 495, 500, 509, 501, 0, 102, 100, 98,
1045 101, 110, 89, 109, 190, 0, 129, 76, 78, 84,
1046 106, 0, 138, 0, 143, 0, 0, 0, 281, 0,
1047 0, 0, 0, 0, 0, 0, 0, 340, 0, 224,
1048 0, 8, 414, 0, 128, 198, 0, 0, 213, 0,
1049 194, 196, 0, 197, 202, 214, 0, 203, 215, 0,
1050 204, 205, 216, 255, 0, 206, 0, 217, 207, 294,
1051 0, 218, 219, 220, 222, 221, 0, 223, 248, 247,
1052 0, 245, 246, 243, 244, 242, 126, 124, 117, 0,
1053 0, 0, 424, 414, 343, 345, 421, 425, 422, 429,
1054 428, 427, 426, 0, 398, 0, 0, 0, 16, 0,
1055 434, 431, 435, 432, 441, 0, 414, 0, 184, 187,
1056 0, 0, 0, 0, 0, 0, 96, 0, 0, 0,
1057 369, 0, 418, 417, 0, 0, 0, 0, 0, 0,
1058 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1059 0, 0, 0, 0, 0, 507, 508, 0, 145, 0,
1060 144, 137, 105, 135, 139, 192, 142, 0, 231, 232,
1061 230, 250, 0, 316, 0, 305, 303, 0, 313, 311,
1062 0, 277, 0, 258, 0, 327, 0, 291, 0, 309,
1063 307, 0, 0, 200, 0, 0, 0, 227, 225, 0,
1064 0, 193, 191, 195, 199, 414, 323, 226, 229, 0,
1065 276, 0, 414, 296, 300, 293, 0, 0, 320, 0,
1066 123, 122, 127, 125, 134, 133, 351, 357, 0, 397,
1067 387, 386, 365, 0, 380, 388, 0, 381, 0, 366,
1068 0, 0, 0, 0, 0, 0, 348, 341, 185, 0,
1069 352, 350, 356, 399, 0, 377, 409, 353, 0, 349,
1070 354, 375, 347, 376, 396, 411, 0, 355, 370, 0,
1071 449, 446, 450, 447, 451, 448, 455, 453, 456, 454,
1072 461, 458, 462, 459, 463, 460, 471, 466, 473, 468,
1073 470, 465, 472, 467, 474, 0, 469, 478, 476, 479,
1074 477, 482, 481, 485, 484, 488, 487, 491, 490, 494,
1075 493, 498, 0, 0, 503, 502, 146, 136, 414, 147,
1076 0, 0, 151, 0, 251, 0, 317, 315, 306, 304,
1077 314, 312, 278, 0, 259, 0, 0, 0, 324, 328,
1078 0, 325, 292, 310, 308, 341, 18, 19, 0, 201,
1079 233, 0, 0, 0, 256, 0, 297, 0, 285, 0,
1080 0, 322, 0, 405, 406, 0, 392, 393, 0, 389,
1081 382, 0, 385, 383, 384, 367, 359, 0, 443, 437,
1082 440, 393, 0, 393, 0, 438, 189, 186, 188, 400,
1083 0, 410, 407, 0, 412, 408, 361, 0, 497, 0,
1084 0, 148, 0, 0, 152, 149, 252, 0, 279, 275,
1085 0, 332, 0, 336, 335, 329, 326, 330, 237, 0,
1086 234, 235, 0, 0, 0, 261, 0, 265, 0, 268,
1087 0, 302, 301, 287, 0, 299, 0, 321, 0, 403,
1088 0, 391, 390, 395, 394, 0, 368, 358, 442, 436,
1089 444, 439, 379, 378, 401, 0, 362, 363, 499, 496,
1090 0, 150, 0, 0, 0, 249, 0, 202, 0, 209,
1091 210, 0, 211, 212, 0, 260, 333, 0, 238, 0,
1092 0, 236, 274, 271, 272, 510, 0, 263, 266, 0,
1093 262, 0, 269, 0, 0, 286, 0, 319, 318, 404,
1094 374, 0, 402, 364, 0, 153, 0, 0, 0, 228,
1095 280, 0, 334, 331, 241, 239, 0, 273, 270, 264,
1096 0, 284, 0, 372, 0, 0, 154, 0, 253, 0,
1097 0, 240, 282, 283, 156, 0, 0, 0, 0, 155,
1098 0, 0, 0, 0, 289, 0, 254, 288, 0, 0,
1102 static const short yydefgoto[] = { 789,
1103 210, 281, 211, 85, 86, 68, 60, 87, 212, 22,
1104 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
1105 447, 286, 132, 105, 47, 70, 104, 130, 161, 162,
1106 163, 91, 114, 115, 116, 213, 165, 262, 92, 111,
1107 180, 181, 287, 136, 185, 403, 167, 168, 169, 264,
1108 170, 171, 407, 560, 561, 288, 18, 43, 72, 65,
1109 107, 44, 63, 94, 95, 96, 97, 214, 361, 289,
1110 174, 563, 732, 291, 292, 293, 294, 707, 295, 296,
1111 297, 298, 710, 299, 300, 301, 302, 711, 303, 450,
1112 304, 595, 667, 668, 669, 670, 305, 306, 713, 307,
1113 308, 309, 714, 310, 311, 456, 675, 676, 312, 313,
1114 314, 315, 316, 317, 318, 579, 580, 581, 582, 215,
1115 216, 217, 218, 219, 220, 742, 686, 221, 495, 222,
1116 475, 476, 477, 223, 224, 225, 226, 227, 228, 229,
1117 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
1118 240, 241, 242, 243, 244, 245, 246, 247, 398, 496,
1122 static const short yypact[] = { 356,
1123 -32768,-32768, 158, -35, 339, 439,-32768,-32768, 433, 247,
1124 473,-32768,-32768,-32768,-32768, 29,-32768,-32768,-32768,-32768,
1125 12,-32768,-32768,-32768, 331,-32768, 491,-32768, 71, 469,
1126 -32768,-32768, 520, 562,-32768, -35, 510,-32768,-32768, 278,
1127 -32768, 521, -25, -8,-32768, 526, 349,-32768,-32768, -35,
1128 591, 343,-32768, 508,-32768, 25,-32768,-32768,-32768,-32768,
1129 7, 1014,-32768, 568, -25,-32768,-32768, 346, 594,-32768,
1130 -32768, -25, -8,-32768, 349,-32768,-32768,-32768, 597,-32768,
1131 -32768,-32768, 607, 165,-32768,-32768, 315, 181, 676,-32768,
1132 -32768, 30,-32768, 1034,-32768,-32768,-32768,-32768,-32768,-32768,
1133 -32768,-32768,-32768, 328, 354,-32768, -25,-32768,-32768, 370,
1134 -4,-32768, 449, 733,-32768, 201, -4, 122, 208, 377,
1135 -32768, 608, 616,-32768,-32768,-32768,-32768, 617, 938,-32768,
1136 -32768, 354, 629, 630, 215,-32768,-32768,-32768, 648, 2189,
1137 227, 489,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4,
1138 -32768, 743, -4,-32768,-32768, 412,-32768, 425, 577,-32768,
1139 943,-32768,-32768, 438,-32768, 47,-32768, 455,-32768,-32768,
1140 506,-32768,-32768, 1916,-32768,-32768,-32768, 655, 569, 321,
1141 -32768, 589,-32768,-32768, 532,-32768,-32768,-32768, 485,-32768,
1142 -32768, 3001, 3052, 3117, 3168, 533, 18, 615,-32768, 3233,
1143 3284, 3349, 5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1144 302, 915, 63,-32768, 542, 581, 587,-32768,-32768,-32768,
1145 656,-32768, 766,-32768, 780, 846,-32768,-32768,-32768,-32768,
1146 -32768,-32768,-32768, 879, 896, 937, 893, 880, 697, 701,
1147 717, 741, 74,-32768,-32768,-32768, 841,-32768,-32768,-32768,
1148 -32768,-32768,-32768,-32768,-32768, 774, 506,-32768,-32768,-32768,
1149 -32768, 565, 690, 685,-32768, 600, 172, 3400,-32768, 206,
1150 2240, 17, 311, 342, 82, 426, 211, 700, 5597,-32768,
1151 -35, 651, 837, 229, 522,-32768, 589, 705,-32768, 1848,
1152 -32768,-32768, 702,-32768,-32768,-32768, 1984,-32768,-32768, 709,
1153 -32768,-32768,-32768,-32768, 1984,-32768, 1984,-32768,-32768, 5648,
1154 738,-32768,-32768,-32768,-32768,-32768, 436,-32768, 806, 808,
1155 846, 891, 908,-32768,-32768,-32768,-32768, 869,-32768, 654,
1156 684, 686,-32768, 722,-32768,-32768,-32768,-32768,-32768,-32768,
1157 -32768,-32768,-32768, 27,-32768, 691, 860, 724, 724, 452,
1158 -32768,-32768,-32768,-32768,-32768, 694, 1044, 43,-32768,-32768,
1159 669, 747, 222, 5365, 2305, 538,-32768, 279, 3465, 772,
1160 -32768, 458,-32768,-32768, 3516, 3581, 3632, 3697, 3748, 3813,
1161 3864, 3929, 3980, 4045, 4096, 4161, 721, 4212, 4277, 4328,
1162 4393, 4444, 4509, 4560, 2356,-32768,-32768, 4625,-32768, 368,
1163 -32768,-32768,-32768, 750,-32768,-32768,-32768, 1848,-32768,-32768,
1164 -32768,-32768, 4676,-32768, 35,-32768,-32768, 56,-32768,-32768,
1165 70,-32768, 4741,-32768, 4792,-32768, 718,-32768, 5206,-32768,
1166 -32768, 144, 259, 762, 235, 2421, 652,-32768,-32768, -35,
1167 2472,-32768,-32768,-32768,-32768, 1096, 569,-32768,-32768, 779,
1168 -32768, 810, 1032,-32768,-32768,-32768, 76, 2537,-32768, 4857,
1169 -32768,-32768,-32768, 869,-32768,-32768,-32768,-32768, -49, 789,
1170 -32768,-32768,-32768, 2588, 724,-32768, 479, 724, 479,-32768,
1171 2653, 4908, 240, 135, 2704, 657,-32768, 1671,-32768, 2124,
1172 -32768,-32768,-32768,-32768, 547,-32768,-32768,-32768, 244,-32768,
1173 -32768,-32768,-32768,-32768, 801,-32768, 251,-32768,-32768, 5416,
1174 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 879,-32768, 879,
1175 -32768, 896,-32768, 896,-32768, 896,-32768, 937,-32768, 937,
1176 -32768, 937,-32768, 937,-32768, 165,-32768,-32768, 893,-32768,
1177 893,-32768, 880,-32768, 697,-32768, 701,-32768, 717,-32768,
1178 741,-32768, 901, 818,-32768,-32768,-32768,-32768, 1076,-32768,
1179 1848, 815, 811, 1848,-32768, 335,-32768,-32768,-32768,-32768,
1180 -32768,-32768,-32768, 351,-32768, 823, 463, 132, 718,-32768,
1181 455,-32768,-32768,-32768,-32768,-32768, 819, 824, 464, 762,
1182 -32768, 941, 66, -9,-32768, 851,-32768, 5340,-32768, 5231,
1183 840, 854, 857,-32768,-32768, 5481,-32768,-32768, 272,-32768,
1184 864, 294,-32768, 864,-32768,-32768, 878, 94,-32768,-32768,
1185 -32768, 819, 4973, 824, 1120,-32768,-32768,-32768,-32768,-32768,
1186 5024,-32768,-32768, 5532,-32768,-32768, 354, 548,-32768, 5089,
1187 744,-32768, 1848, 2769,-32768,-32768,-32768, 2050,-32768,-32768,
1188 263,-32768, 681,-32768,-32768,-32768,-32768,-32768,-32768, 2820,
1189 -32768,-32768, 963, 212, 5140,-32768, 419,-32768, 1564,-32768,
1190 5597,-32768,-32768,-32768, 881, 886, 5273,-32768, 268,-32768,
1191 728,-32768,-32768,-32768,-32768, 354,-32768, 903,-32768,-32768,
1192 -32768,-32768,-32768,-32768,-32768, 731,-32768, 354,-32768,-32768,
1193 504,-32768, 173, 121, 509,-32768, 940, 944, 2050,-32768,
1194 -32768, 2050,-32768,-32768, 904,-32768, 923, 925,-32768, 1020,
1195 137,-32768,-32768,-32768,-32768,-32768, 262,-32768,-32768, 1646,
1196 -32768, 1780,-32768, 932, 1984,-32768, 942,-32768,-32768,-32768,
1197 -32768, 354,-32768,-32768, 2885,-32768, 182, 4676, 1984,-32768,
1198 -32768, 2936,-32768,-32768,-32768,-32768, 1029,-32768,-32768,-32768,
1199 945,-32768, 1984,-32768, 210, 177,-32768, 401,-32768, 5231,
1200 946,-32768,-32768,-32768,-32768, 224, 2050, 947, 5273,-32768,
1201 975, 2050, 949, 2050,-32768, 2050,-32768,-32768, 1037, 1040,
1205 static const short yypgoto[] = {-32768,
1206 -32768, -54, 157, 660, 16, -122, 582,-32768, -3, 319,
1207 -32768, 64,-32768, 1038, 413,-32768, 69,-32768,-32768, 734,
1208 106, 409,-32768,-32768, 997, 979,-32768, -131,-32768, 898,
1209 -32768, -79, -116, 918, -167, -194,-32768,-32768, -64, 285,
1210 805, -325, -129, -90,-32768,-32768,-32768,-32768,-32768,-32768,
1211 -32768, 907,-32768, -544,-32768, 662, -20,-32768,-32768,-32768,
1212 -32768, 1011, 561,-32768, 978,-32768,-32768, -176,-32768, -127,
1213 813, 784, -168, -276,-32768, 769, -251, 93, -560,-32768,
1214 -528,-32768,-32768,-32768, -263,-32768,-32768,-32768,-32768,-32768,
1215 -32768,-32768,-32768, 415, 416, -632, -527,-32768,-32768,-32768,
1216 -32768,-32768,-32768,-32768, -516,-32768, -667, 770,-32768,-32768,
1217 -32768,-32768,-32768,-32768,-32768,-32768, 511,-32768, 513,-32768,
1218 -32768,-32768,-32768, 186,-32768,-32768,-32768,-32768, -426,-32768,
1219 736, 126, -324, 1163, 192, 1197, 283, 379, 507, -171,
1220 583, 704, -472,-32768, 602, 603, 481, 601, 696, 698,
1221 695, 710, 703,-32768, 454, 706, 745,-32768,-32768, 936,
1229 static const short yytable[] = { 21,
1230 175, 173, 29, 182, 462, 290, 152, 83, 360, 737,
1231 328, 184, 38, 444, 593, 626, 642, 345, 345, 646,
1232 337, 339, 341, 343, 479, 76, 143, 467, 352, 354,
1233 124, 484, 486, 173, 123, 567, 733, 664, 61, 83,
1234 263, 93, 61, 487, 604, 448, 455, 261, 134, 164,
1235 20, 605, 665, 451, 618, 452, 569, 59, 88, 252,
1236 61, 67, 254, 367, 166, 61, 662, 25, 27, 62,
1237 571, 48, 35, 93, 83, 350, 597, 31, 178, 59,
1238 265, 164, 426, 638, 59, 88, 666, 708, 394, 36,
1239 88, 64, 135, 468, 687, 37, 166, 733, 702, 52,
1240 54, 31, 778, 57, 123, 16, 83, 50, 172, -158,
1241 39, 783, 40, 57, 16, 16, 16, 346, 346, 709,
1242 712, 662, 144, 77, 61, 88, 182, 331, 125, 88,
1243 61, 715, 654, 568, 404, 16, 488, 756, 16, 16,
1244 172, -104, 110, 59, 584, -104, 113, 427, 708, 67,
1245 611, 708, 692, 614, 570, 88, 16, 88, 19, 663,
1246 395, -94, -94, 464, 434, 631, 401, 89, 572, 49,
1247 283, 50, 412, 661, -295, 598, 156, 756, 88, 681,
1248 709, 712, 722, 709, 712, 110, 113, 688, 334, 334,
1249 334, 334, 715, 631, 61, 715, 334, 334, 357, 89,
1250 182, 178, 189, 512, 514, 516, 416, 696, 146, 466,
1251 755, 430, 723, 349, 747, 186, 708, 704, 84, 145,
1252 631, 708, 492, 708, 772, 708, 156, 249, 623, 438,
1253 757, 612, 440, 721, 159, 144, 631, 284, 179, 564,
1254 621, 189, 585, 20, 632, 84, -31, 1, 709, 712,
1255 84, 635, 88, 709, 712, 709, 712, 709, 712, 487,
1256 715, 118, 758, 716, 413, 715, 159, 715, 738, 715,
1257 776, 746, 682, -25, -25, 178, 631, 120, 55, 285,
1258 767, 50, 56, 88, 372, 84, 283, 444, 493, 84,
1259 2, 20, 140, 446, 684, 629, 20, 141, 142, 724,
1260 613, 446, 615, 446, 417, 147, 453, 4, 775, 431,
1261 620, 422, 187, 5, -25, 84, 439, 84, 766, -25,
1262 -25, -25, 780, 590, 250, -25, 88, 718, 61, -25,
1263 282, 41, 587, 418, 673, 647, 455, 622, 84, 26,
1264 432, 633, 424, 71, 189, 7, 101, 67, 636, 759,
1265 504, 649, 586, 284, 348, -28, 1, -257, 356, 319,
1266 284, 179, 156, 20, 20, 320, 444, 117, 284, 683,
1267 284, 334, 334, 334, 334, 334, 334, 334, 334, 334,
1268 334, 334, 334, 88, 334, 334, 334, 334, 334, 334,
1269 334, 685, 643, 42, 189, 285, 706, -66, 362, 2,
1270 69, 647, 363, 423, 559, 42, 150, 153, 17, 470,
1271 3, 119, 84, 455, 329, 179, 4, 17, 17, 17,
1272 330, 30, 5, 34, 20, -159, 428, 128, 648, 57,
1273 6, 505, -30, 1, 425, 179, 459, -161, 17, 28,
1274 -66, 17, 17, 84, 650, 51, 282, 158, 129, 137,
1275 655, 690, 480, 658, 7, 444, 321, 448, 509, 17,
1276 451, 557, 133, 652, 659, 664, 282, 330, -34, 1,
1277 90, 284, -29, 1, 148, 319, 2, 158, 334, 158,
1278 665, 320, 319, 762, 334, 137, 84, 3, 320, 251,
1279 319, 45, 319, 4, 777, 319, 320, 769, 320, 5,
1280 57, 320, 90, 189, 659, 697, 455, 255, 74, 412,
1281 53, 774, 2, 285, 728, 455, 2, 256, 429, -32,
1282 1, 58, -323, 182, 20, 706, 66, 3, 460, 4,
1283 762, 7, 769, 4, 774, 5, 260, 160, 500, 5,
1284 -97, 133, -65, 536, 481, -97, -97, -97, -97, 156,
1285 510, 739, 322, 46, 741, 653, 660, 283, 134, -65,
1286 283, -33, 1, 2, 282, 35, 744, 7, 98, 160,
1287 46, 7, 321, 203, 3, 612, -97, 121, -97, 321,
1288 4, -97, -97, -97, -97, -65, 5, 321, 37, 321,
1289 -35, 1, 321, 319, 102, 20, 745, 109, 178, 320,
1290 610, 748, -65, 610, 501, 2, 20, 112, 149, 502,
1291 764, 20, 35, 503, -323, 347, 151, 154, 7, 334,
1292 35, 334, 4, 20, 284, 100, 78, 284, 5, 176,
1293 183, 332, 106, 344, 2, 122, 334, 36, 78, 283,
1294 630, 698, 368, 37, 446, 99, 631, 631, 188, 88,
1295 103, 4, 500, 20, 461, 327, 371, 5, 80, 156,
1296 7, 81, 20, 402, 78, 283, 285, 131, 322, 285,
1297 80, -140, 2, 81, 20, 322, 121, 369, 78, 20,
1298 323, 717, 20, 322, 463, 322, 465, 370, 322, 7,
1299 321, 469, 20, 20, 409, 410, 80, 2, 411, 81,
1300 20, 20, 20, 78, 57, 446, 284, 390, 446, 155,
1301 80, 284, 391, 81, 20, 20, 589, 282, 501, 35,
1302 282, 535, 177, 502, 2, 78, 283, 503, 283, 392,
1303 78, 446, 284, 20, 122, 80, 36, 20, 81, 20,
1304 20, 20, 37, 32, 500, 446, 319, 435, 285, 319,
1305 625, 363, 320, 612, 393, 320, 324, 80, 179, 446,
1306 81, 20, 80, 32, 489, 81, 20, 32, 490, 20,
1307 78, 20, 284, 446, 285, 284, 20, 577, 446, 406,
1308 446, 578, 446, 319, 32, 319, 322, 482, 405, 320,
1309 483, 320, -157, 284, 363, 284, 323, 441, 284, 282,
1310 445, 750, 80, 323, 751, 81, 20, 449, 701, 84,
1311 501, 323, 284, 323, 364, 502, 323, 2, 365, 503,
1312 474, 740, 366, 78, 743, 282, 284, 631, 319, 20,
1313 631, 138, 139, 319, 320, 285, 458, 285, 508, 320,
1314 284, 253, 139, 321, 491, 284, 321, 284, 558, 284,
1315 -342, -342, -344, -344, 319, 80, -505, -505, 81, 20,
1316 320, 139, 319, 528, 530, 532, 534, 399, 320, 781,
1317 -506, -506, 324, 594, 785, 596, 787, 325, 788, 324,
1318 321, 606, 321, 375, 376, 377, 282, 324, 282, 324,
1319 373, 374, 324, 634, 319, 388, 389, 319, 378, 379,
1320 320, 639, -342, 320, -344, 640, -342, 644, -344, 645,
1321 383, 384, 385, 386, 323, 319, 651, 319, 326, -352,
1322 319, 320, -15, 320, -353, 321, 320, -504, -504, 364,
1323 321, 396, 397, 436, 319, -415, -415, 437, 677, 322,
1324 320, 661, 322, 671, 380, 381, 382, 678, 319, 387,
1325 679, 321, -416, -416, 320, 319, 471, 472, 473, 321,
1326 612, 320, 319, 722, 319, 141, 142, 319, 320, 319,
1327 320, 319, -373, 320, 735, 320, 322, 320, 322, 518,
1328 520, 2, 522, 524, 526, 598, 2, 78, 539, 541,
1329 324, 321, 78, 325, 321, 749, 79, -371, 4, -208,
1330 325, 79, 752, 4, 5, -504, -504, 364, 325, 5,
1331 325, 365, 321, 325, 321, 366, 753, 321, 754, 80,
1332 755, 322, 81, 20, 80, 761, 322, 81, 20, 772,
1333 784, 321, 156, 157, 326, 763, 790, 156, 258, 791,
1334 782, 326, 786, 773, 779, 321, 537, 322, 33, 326,
1335 75, 326, 321, 108, 326, 322, 190, 2, 259, 321,
1336 400, 321, 73, 78, 321, 257, 321, 323, 321, 562,
1337 323, 127, 79, 443, 4, 248, 408, 2, 454, 457,
1338 5, 729, 730, 78, 478, 543, 547, 322, 545, 656,
1339 322, 657, 79, 700, 4, 80, 551, 0, 81, 20,
1340 5, 0, 549, 556, 323, 0, 323, 0, 322, 82,
1341 322, 325, 0, 322, 0, 80, 0, -15, 81, 20,
1342 691, 0, -504, -504, 364, 0, 0, 322, 436, 126,
1343 0, 0, 366, 0, -504, -504, 364, 358, 248, 0,
1344 485, 322, 0, 324, 366, 0, 324, 0, 322, 323,
1345 0, 0, 326, 0, 323, 322, 0, 322, 0, 0,
1346 322, -15, 322, 0, 322, 0, -504, -504, 364, 78,
1347 0, 0, 436, 0, 0, 323, 641, 0, 196, 0,
1348 324, 0, 324, 323, 197, 0, -504, -504, 364, 0,
1349 0, 198, 365, 0, 0, 199, 437, 0, 0, 0,
1350 0, 80, 0, 415, 81, 20, 421, 0, 200, 201,
1351 0, 0, 202, 0, 433, 323, 0, 0, 323, 0,
1352 0, 204, 205, 206, 207, 324, 0, 208, 209, 0,
1353 324, 0, 0, 0, 0, 0, 323, 0, 323, 0,
1354 0, 323, 0, 0, 0, 0, 0, 0, 0, 0,
1355 0, 324, 0, 0, 0, 323, 0, 0, 0, 324,
1356 0, 0, 0, 0, 325, 0, 0, 325, 0, 323,
1357 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
1358 0, 0, 0, 323, 0, 323, 0, 0, 323, 0,
1359 323, 324, 323, 0, 324, 0, 0, 0, 0, 0,
1360 499, 325, 0, 325, 507, 326, 0, 0, 326, 0,
1361 0, 0, 324, 0, 324, 0, 0, 324, 0, 0,
1362 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1363 554, 324, 0, 0, 0, 0, 0, 0, 0, 0,
1364 0, 0, 326, 0, 326, 324, 325, 0, 566, 0,
1365 0, 325, 324, 0, 335, 335, 335, 335, 574, 324,
1366 576, 324, 335, 335, 324, 0, 324, 0, 324, 0,
1367 0, 499, 325, 0, 0, 0, 0, 0, 0, 0,
1368 325, 0, 0, 0, 0, 0, 0, 326, 336, 336,
1369 336, 336, 326, 601, 0, 603, 336, 336, 0, 0,
1370 0, 0, 0, 0, 0, 0, 0, 0, 0, 609,
1371 0, 0, 325, 326, 0, 325, 0, 0, 0, 0,
1372 499, 326, 0, 0, 0, 248, 0, 0, 0, 0,
1373 0, 0, 0, 325, 0, 325, 0, 0, 325, 0,
1374 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1375 0, 0, 325, 326, 0, 0, 326, 0, 0, 0,
1376 0, 0, 0, 0, 0, 0, 325, 0, 0, 0,
1377 0, 0, 0, 325, 326, 0, 326, 0, 0, 326,
1378 325, 0, 325, 0, 0, 325, 0, 325, 0, 325,
1379 0, 0, 0, 326, 0, 0, 0, 0, 0, 0,
1380 0, 0, 0, 0, 0, 0, 0, 326, 0, 0,
1381 0, 0, 0, 0, 326, 0, 0, 0, 0, 0,
1382 0, 326, 0, 326, 0, 0, 326, 0, 326, 0,
1383 326, 0, 0, 0, 0, 0, 0, 335, 335, 335,
1384 335, 335, 335, 335, 335, 335, 335, 335, 335, 0,
1385 335, 335, 335, 335, 335, 335, 335, 0, 0, 0,
1386 0, 0, 0, 0, 266, 0, 694, 0, 0, 0,
1387 0, 336, 336, 336, 336, 336, 336, 336, 336, 336,
1388 336, 336, 336, 0, 336, 336, 336, 336, 336, 336,
1389 336, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1390 726, 0, 0, 0, 0, 0, 734, 2, 194, 195,
1391 664, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1392 0, 271, 196, 0, 0, 665, 0, 0, 272, 273,
1393 5, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1394 0, 0, 0, 0, 335, 80, 266, 0, 81, 20,
1395 335, 0, 0, 0, 0, 0, 279, 0, 156, 731,
1396 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1397 0, 208, 209, 0, 0, 0, 0, 0, 336, 0,
1398 0, 0, 0, 768, 336, 0, 0, 771, 0, 2,
1399 194, 195, 664, 267, 268, 78, 269, 0, 0, 270,
1400 0, 0, 0, 271, 196, 0, 0, 665, 0, 0,
1401 272, 273, 5, 274, 0, 275, 276, 198, 277, 0,
1402 78, 278, 0, 0, 0, 0, 0, 80, 0, 196,
1403 81, 20, 0, 0, 0, 197, 0, 0, 279, 0,
1404 156, 760, 198, 0, 280, 0, 199, 204, 205, 206,
1405 207, 0, 80, 208, 209, 81, 20, 0, 0, 200,
1406 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1407 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1408 266, 0, 0, 0, 0, 335, 0, 335, 0, 0,
1409 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1410 0, 0, 335, 0, 0, 0, 0, 0, 0, 0,
1411 0, 0, 0, 0, 0, 0, 0, 0, 0, 336,
1412 0, 336, 0, 2, 194, 195, -267, 267, 268, 78,
1413 269, 0, 0, 270, 0, 0, 336, 271, 196, 0,
1414 0, -267, 0, 0, 272, 273, 5, 274, 266, 275,
1415 276, 198, 277, 0, 0, 278, 0, 0, 0, 0,
1416 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1417 0, 0, 279, 0, 156, -267, 0, 0, 280, 0,
1418 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1419 0, 2, 194, 195, 0, 267, 268, 78, 269, 0,
1420 0, 270, 0, 0, 0, 271, 196, 0, 0, 0,
1421 0, 0, 272, 273, 5, 274, 266, 275, 276, 198,
1422 277, 0, 0, 278, 0, 0, 0, 0, 0, 80,
1423 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1424 279, 0, 156, 442, 0, 0, 280, 0, 0, 204,
1425 205, 206, 207, 0, 0, 208, 209, 0, 0, 2,
1426 194, 195, 0, 267, 268, 78, 269, 0, 0, 270,
1427 0, 0, 0, 271, 196, 0, 0, 0, 0, 0,
1428 272, 273, 5, 274, 266, 275, 276, 198, 277, 0,
1429 0, 278, 0, 0, 0, 0, 0, 80, 0, 0,
1430 81, 20, 0, 0, 0, 0, 0, 0, 279, 0,
1431 156, 0, 0, 0, 280, 0, 0, 204, 205, 206,
1432 207, 0, 0, 208, 209, 0, 0, 2, 194, 195,
1433 0, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1434 0, 271, 196, 0, 0, 0, 0, 0, 272, 273,
1435 266, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1436 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1437 0, 0, 0, 0, 0, 0, 279, 0, 156, 0,
1438 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1439 0, 208, 209, 2, 194, 195, 0, 705, 268, 78,
1440 269, 0, 0, 270, 0, 0, 0, 271, 196, 0,
1441 0, 0, 0, 0, 272, 273, 0, 274, 0, 275,
1442 276, 198, 277, 0, 627, 278, 192, 193, 0, 0,
1443 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1444 0, 0, 279, 0, 156, 0, 0, 0, 280, 0,
1445 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1446 0, 0, 0, 0, 0, 0, 0, 0, 194, 195,
1447 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1448 0, 0, 196, 0, 0, 0, 0, 0, 197, 191,
1449 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1450 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1451 0, 0, 200, 201, 0, 0, 202, 0, 203, 628,
1452 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1453 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1454 419, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1455 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1456 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1457 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1458 0, 202, 0, 203, 194, 195, 0, 0, 0, 78,
1459 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1460 0, 0, 0, 0, 197, 497, 0, 192, 193, 0,
1461 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1462 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1463 0, 0, 202, 0, 0, 0, 0, 0, 420, 0,
1464 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1465 195, 0, 0, 0, 78, 0, 552, 0, 192, 193,
1466 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1467 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1468 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1469 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1470 194, 195, 498, 0, 0, 78, 204, 205, 206, 207,
1471 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1472 197, 497, 0, 192, 193, 0, 0, 198, 0, 0,
1473 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1474 81, 20, 0, 553, 200, 201, 0, 0, 202, 0,
1475 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1476 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1477 78, 0, 591, 0, 192, 193, 0, 0, 0, 196,
1478 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1479 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1480 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1481 201, 0, 0, 202, 0, 0, 194, 195, 588, 0,
1482 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1483 196, 0, 0, 0, 0, 0, 197, 599, 0, 192,
1484 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1485 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1486 200, 201, 0, 0, 202, 592, 0, 0, 0, 0,
1487 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1488 209, 194, 195, 0, 0, 0, 78, 0, 607, 0,
1489 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1490 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1491 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1492 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1493 0, 0, 194, 195, 0, 600, 0, 78, 204, 205,
1494 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1495 0, 0, 197, 616, 0, 192, 193, 0, 0, 198,
1496 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1497 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1498 202, 0, 0, 0, 0, 608, 0, 0, 0, 204,
1499 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1500 0, 0, 78, 0, 497, 0, 192, 193, 0, 0,
1501 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1502 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1503 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1504 0, 200, 201, 0, 0, 202, 617, 0, 194, 195,
1505 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1506 208, 209, 196, 0, 0, 0, 0, 0, 197, 591,
1507 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1508 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1509 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1510 0, 624, 0, 0, 0, 204, 205, 206, 207, 0,
1511 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1512 719, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1513 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1514 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1515 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1516 0, 202, 703, 0, 194, 195, 0, 0, 0, 78,
1517 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1518 0, 0, 0, 0, 197, 719, 0, 192, 193, 0,
1519 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1520 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1521 0, 0, 202, 720, 0, 0, 0, 0, 0, 0,
1522 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1523 195, 0, 0, 0, 78, 0, 599, 0, 192, 193,
1524 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1525 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1526 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1527 20, 0, 0, 200, 201, 0, 0, 202, 765, 0,
1528 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1529 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1530 197, 333, 0, 192, 193, 0, 0, 198, 0, 0,
1531 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1532 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1533 0, 0, 0, 0, 770, 0, 0, 204, 205, 206,
1534 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1535 78, 0, 338, 0, 192, 193, 0, 0, 0, 196,
1536 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1537 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1538 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1539 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1540 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1541 196, 0, 0, 0, 0, 0, 197, 340, 0, 192,
1542 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1543 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1544 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1545 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1546 209, 194, 195, 0, 0, 0, 78, 0, 342, 0,
1547 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1548 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1549 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1550 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1551 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1552 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1553 0, 0, 197, 351, 0, 192, 193, 0, 0, 198,
1554 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1555 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1556 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1557 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1558 0, 0, 78, 0, 353, 0, 192, 193, 0, 0,
1559 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1560 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1561 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1562 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1563 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1564 208, 209, 196, 0, 0, 0, 0, 0, 197, 355,
1565 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1566 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1567 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1568 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1569 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1570 414, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1571 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1572 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1573 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1574 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1575 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1576 0, 0, 0, 0, 197, 506, 0, 192, 193, 0,
1577 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1578 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1579 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1580 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1581 195, 0, 0, 0, 78, 0, 511, 0, 192, 193,
1582 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1583 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1584 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1585 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1586 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1587 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1588 197, 513, 0, 192, 193, 0, 0, 198, 0, 0,
1589 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1590 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1591 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1592 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1593 78, 0, 515, 0, 192, 193, 0, 0, 0, 196,
1594 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1595 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1596 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1597 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1598 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1599 196, 0, 0, 0, 0, 0, 197, 517, 0, 192,
1600 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1601 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1602 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1603 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1604 209, 194, 195, 0, 0, 0, 78, 0, 519, 0,
1605 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1606 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1607 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1608 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1609 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1610 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1611 0, 0, 197, 521, 0, 192, 193, 0, 0, 198,
1612 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1613 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1614 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1615 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1616 0, 0, 78, 0, 523, 0, 192, 193, 0, 0,
1617 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1618 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1619 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1620 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1621 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1622 208, 209, 196, 0, 0, 0, 0, 0, 197, 525,
1623 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1624 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1625 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1626 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1627 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1628 527, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1629 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1630 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1631 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1632 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1633 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1634 0, 0, 0, 0, 197, 529, 0, 192, 193, 0,
1635 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1636 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1637 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1638 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1639 195, 0, 0, 0, 78, 0, 531, 0, 192, 193,
1640 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1641 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1642 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1643 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1644 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1645 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1646 197, 533, 0, 192, 193, 0, 0, 198, 0, 0,
1647 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1648 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1649 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1650 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1651 78, 0, 538, 0, 192, 193, 0, 0, 0, 196,
1652 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1653 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1654 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1655 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1656 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1657 196, 0, 0, 0, 0, 0, 197, 540, 0, 192,
1658 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1659 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1660 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1661 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1662 209, 194, 195, 0, 0, 0, 78, 0, 542, 0,
1663 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1664 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1665 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1666 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1667 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1668 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1669 0, 0, 197, 544, 0, 192, 193, 0, 0, 198,
1670 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1671 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1672 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1673 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1674 0, 0, 78, 0, 546, 0, 192, 193, 0, 0,
1675 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1676 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1677 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1678 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1679 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1680 208, 209, 196, 0, 0, 0, 0, 0, 197, 548,
1681 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1682 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1683 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1684 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1685 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1686 550, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1687 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1688 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1689 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1690 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1691 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1692 0, 0, 0, 0, 197, 555, 0, 192, 193, 0,
1693 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1694 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1695 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1696 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1697 195, 0, 0, 0, 78, 0, 565, 0, 192, 193,
1698 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1699 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1700 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1701 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1702 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1703 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1704 197, 573, 0, 192, 193, 0, 0, 198, 0, 0,
1705 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1706 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1707 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1708 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1709 78, 0, 575, 0, 192, 193, 0, 0, 0, 196,
1710 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1711 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1712 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1713 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1714 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1715 196, 0, 0, 0, 0, 0, 197, 602, 0, 192,
1716 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1717 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1718 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1719 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1720 209, 194, 195, 0, 0, 0, 78, 0, 619, 0,
1721 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1722 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1723 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1724 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1725 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1726 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1727 0, 0, 197, 689, 0, 192, 193, 0, 0, 198,
1728 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1729 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1730 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1731 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1732 0, 0, 78, 0, 693, 0, 192, 193, 0, 0,
1733 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1734 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1735 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1736 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1737 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1738 208, 209, 196, 0, 0, 0, 0, 0, 197, 699,
1739 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1740 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1741 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1742 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1743 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1744 725, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1745 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1746 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1747 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1748 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1749 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1750 0, 0, 0, 0, 197, 0, 583, 0, 0, 0,
1751 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1752 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1753 0, 674, 202, 0, 0, 0, 0, 0, 0, 0,
1754 0, 204, 205, 206, 207, 0, 0, 208, 209, -290,
1755 -290, -290, 0, 0, 0, -290, 0, 0, 0, 0,
1756 0, 0, 0, 0, -290, 0, 0, 0, 0, 0,
1757 -290, 0, 0, 736, 0, 194, 195, -290, 0, 0,
1758 78, -290, 0, 0, 0, 0, 0, -290, 0, 196,
1759 -290, -290, 0, 0, 0, 197, 0, 0, -290, 0,
1760 192, 193, 198, 0, -290, 0, 199, -290, -290, -290,
1761 -290, 0, 80, -290, -290, 81, 20, 194, 195, 0,
1762 0, 0, 78, 279, -298, 0, 0, 0, 0, 0,
1763 0, 196, 204, 205, 206, 207, 0, 197, 208, 209,
1764 672, 0, 194, 195, 198, 0, 0, 78, 199, 0,
1765 0, 0, 0, 0, 80, 0, 196, 81, 20, 0,
1766 0, 0, 197, 0, 0, 279, -298, 192, 193, 198,
1767 0, 0, 0, 199, 204, 205, 206, 207, 0, 80,
1768 208, 209, 81, 20, 194, 195, 200, 201, 0, 78,
1769 202, 0, 203, 359, 0, 0, 0, 0, 196, 204,
1770 205, 206, 207, 0, 197, 208, 209, 0, 0, 194,
1771 195, 198, 0, 0, 78, 199, 0, 0, 192, 193,
1772 0, 80, 0, 196, 81, 20, 0, 0, 0, 197,
1773 0, 0, 279, 0, 0, 0, 198, 0, 0, 0,
1774 199, 204, 205, 206, 207, 0, 80, 208, 209, 81,
1775 20, 0, 0, 200, 201, 0, 0, 202, 494, 0,
1776 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1777 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1778 197, 0, 0, 192, 193, 0, 0, 198, 0, 0,
1779 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1780 81, 20, 0, 0, 200, 201, 0, 0, 202, 637,
1781 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1782 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1783 78, 0, 0, 0, 192, 193, 0, 0, 0, 196,
1784 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1785 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1786 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1787 201, 0, 0, 202, 680, 0, 194, 195, 0, 0,
1788 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1789 196, 0, 0, 0, 0, 0, 197, 0, 0, 192,
1790 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1791 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1792 200, 201, 0, 0, 202, 695, 0, 0, 0, 0,
1793 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1794 209, 194, 195, 0, 0, 0, 78, 0, 0, 0,
1795 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1796 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1797 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1798 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1799 0, 2, 194, 195, 0, 0, 0, 78, 204, 205,
1800 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1801 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1802 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1803 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1804 279, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1805 205, 206, 207, 0, 0, 208, 209
1808 static const short yycheck[] = { 3,
1809 132, 129, 6, 133, 330, 174, 123, 62, 203, 677,
1810 178, 134, 1, 290, 441, 488, 561, 1, 1, 564,
1811 192, 193, 194, 195, 349, 1, 117, 1, 200, 201,
1812 1, 356, 357, 161, 89, 1, 669, 47, 42, 94,
1813 168, 62, 46, 1, 94, 297, 310, 1, 53, 129,
1814 86, 101, 62, 305, 481, 307, 1, 42, 62, 150,
1815 64, 46, 153, 1, 129, 69, 1, 4, 5, 95,
1816 1, 1, 44, 94, 129, 198, 1, 9, 133, 64,
1817 171, 161, 1, 510, 69, 89, 96, 648, 15, 61,
1818 94, 100, 97, 67, 1, 67, 161, 730, 643, 36,
1819 37, 33, 770, 40, 159, 0, 161, 101, 129, 93,
1820 99, 779, 101, 50, 9, 10, 11, 101, 101, 648,
1821 648, 1, 1, 99, 128, 129, 256, 182, 99, 133,
1822 134, 648, 1, 99, 262, 30, 94, 1, 33, 34,
1823 161, 95, 79, 128, 1, 99, 83, 275, 709, 134,
1824 475, 712, 625, 478, 99, 159, 51, 161, 1, 94,
1825 87, 99, 100, 331, 281, 100, 257, 62, 99, 99,
1826 174, 101, 1, 1, 99, 100, 95, 1, 182, 606,
1827 709, 709, 1, 712, 712, 122, 123, 94, 192, 193,
1828 194, 195, 709, 100, 198, 712, 200, 201, 202, 94,
1829 330, 256, 139, 375, 376, 377, 1, 634, 1, 332,
1830 1, 1, 1, 198, 94, 1, 777, 644, 62, 98,
1831 100, 782, 1, 784, 1, 786, 95, 1, 94, 1,
1832 94, 97, 287, 660, 129, 1, 100, 174, 133, 408,
1833 1, 178, 99, 86, 1, 89, 0, 1, 777, 777,
1834 94, 1, 256, 782, 782, 784, 784, 786, 786, 1,
1835 777, 97, 1, 1, 93, 782, 161, 784, 1, 786,
1836 94, 99, 1, 45, 46, 330, 100, 97, 1, 174,
1837 99, 101, 5, 287, 221, 129, 290, 564, 67, 133,
1838 44, 86, 92, 297, 1, 490, 86, 97, 98, 88,
1839 477, 305, 479, 307, 99, 98, 310, 61, 99, 99,
1840 482, 1, 98, 67, 86, 159, 88, 161, 745, 91,
1841 92, 93, 99, 440, 98, 97, 330, 653, 332, 101,
1842 174, 1, 98, 270, 598, 1, 600, 98, 182, 1,
1843 277, 98, 1, 1, 281, 99, 1, 332, 98, 88,
1844 72, 1, 94, 290, 198, 0, 1, 95, 202, 174,
1845 297, 256, 95, 86, 86, 174, 643, 83, 305, 98,
1846 307, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1847 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
1848 394, 98, 561, 63, 331, 290, 648, 52, 97, 44,
1849 52, 1, 101, 93, 408, 63, 122, 123, 0, 346,
1850 55, 97, 256, 677, 94, 310, 61, 9, 10, 11,
1851 100, 9, 67, 11, 86, 95, 1, 100, 94, 366,
1852 75, 368, 0, 1, 93, 330, 1, 95, 30, 1,
1853 95, 33, 34, 287, 94, 33, 290, 129, 95, 1,
1854 578, 623, 1, 581, 99, 732, 174, 709, 1, 51,
1855 712, 94, 93, 1, 1, 47, 310, 100, 0, 1,
1856 62, 408, 0, 1, 98, 290, 44, 159, 482, 161,
1857 62, 290, 297, 735, 488, 1, 330, 55, 297, 1,
1858 305, 1, 307, 61, 94, 310, 305, 749, 307, 67,
1859 437, 310, 94, 440, 1, 637, 770, 96, 1, 1,
1860 1, 763, 44, 408, 96, 779, 44, 93, 93, 0,
1861 1, 1, 1, 653, 86, 777, 1, 55, 93, 61,
1862 782, 99, 784, 61, 786, 67, 99, 129, 1, 67,
1863 92, 93, 52, 387, 93, 97, 98, 99, 100, 95,
1864 93, 679, 174, 63, 686, 93, 93, 561, 53, 52,
1865 564, 0, 1, 44, 408, 44, 698, 99, 1, 161,
1866 63, 99, 290, 95, 55, 97, 92, 1, 94, 297,
1867 61, 97, 98, 99, 100, 95, 67, 305, 67, 307,
1868 0, 1, 310, 408, 1, 86, 93, 1, 653, 408,
1869 475, 93, 95, 478, 67, 44, 86, 1, 1, 72,
1870 742, 86, 44, 76, 93, 1, 1, 1, 99, 623,
1871 44, 625, 61, 86, 561, 65, 50, 564, 67, 1,
1872 1, 100, 72, 101, 44, 59, 640, 61, 50, 643,
1873 94, 94, 101, 67, 648, 64, 100, 100, 1, 653,
1874 69, 61, 1, 86, 1, 1, 1, 67, 82, 95,
1875 99, 85, 86, 99, 50, 669, 561, 107, 290, 564,
1876 82, 95, 44, 85, 86, 297, 1, 97, 50, 86,
1877 174, 1, 86, 305, 1, 307, 1, 101, 310, 99,
1878 408, 1, 86, 86, 95, 96, 82, 44, 99, 85,
1879 86, 86, 86, 50, 641, 709, 643, 11, 712, 128,
1880 82, 648, 12, 85, 86, 86, 65, 561, 67, 44,
1881 564, 1, 94, 72, 44, 50, 730, 76, 732, 13,
1882 50, 735, 669, 86, 59, 82, 61, 86, 85, 86,
1883 86, 86, 67, 10, 1, 749, 561, 97, 643, 564,
1884 94, 101, 561, 97, 14, 564, 174, 82, 653, 763,
1885 85, 86, 82, 30, 96, 85, 86, 34, 100, 86,
1886 50, 86, 709, 777, 669, 712, 86, 60, 782, 95,
1887 784, 64, 786, 598, 51, 600, 408, 94, 99, 598,
1888 97, 600, 93, 730, 101, 732, 290, 93, 735, 643,
1889 99, 709, 82, 297, 712, 85, 86, 99, 65, 653,
1890 67, 305, 749, 307, 93, 72, 310, 44, 97, 76,
1891 97, 94, 101, 50, 94, 669, 763, 100, 643, 86,
1892 100, 99, 100, 648, 643, 730, 99, 732, 67, 648,
1893 777, 99, 100, 561, 98, 782, 564, 784, 99, 786,
1894 45, 46, 45, 46, 669, 82, 91, 92, 85, 86,
1895 669, 100, 677, 383, 384, 385, 386, 94, 677, 777,
1896 91, 92, 290, 95, 782, 66, 784, 174, 786, 297,
1897 598, 93, 600, 5, 6, 7, 730, 305, 732, 307,
1898 45, 46, 310, 93, 709, 16, 17, 712, 3, 4,
1899 709, 1, 97, 712, 97, 88, 101, 93, 101, 99,
1900 18, 19, 20, 21, 408, 730, 94, 732, 174, 101,
1901 735, 730, 86, 732, 101, 643, 735, 91, 92, 93,
1902 648, 91, 92, 97, 749, 45, 46, 101, 99, 561,
1903 749, 1, 564, 93, 8, 9, 10, 94, 763, 57,
1904 94, 669, 45, 46, 763, 770, 97, 98, 99, 677,
1905 97, 770, 777, 1, 779, 97, 98, 782, 777, 784,
1906 779, 786, 95, 782, 94, 784, 598, 786, 600, 378,
1907 379, 44, 380, 381, 382, 100, 44, 50, 388, 389,
1908 408, 709, 50, 290, 712, 56, 59, 95, 61, 56,
1909 297, 59, 99, 61, 67, 91, 92, 93, 305, 67,
1910 307, 97, 730, 310, 732, 101, 94, 735, 94, 82,
1911 1, 643, 85, 86, 82, 94, 648, 85, 86, 1,
1912 56, 749, 95, 96, 290, 94, 0, 95, 96, 0,
1913 94, 297, 94, 99, 99, 763, 387, 669, 11, 305,
1914 54, 307, 770, 75, 310, 677, 139, 44, 161, 777,
1915 256, 779, 52, 50, 782, 159, 784, 561, 786, 408,
1916 564, 94, 59, 290, 61, 140, 264, 44, 310, 310,
1917 67, 667, 667, 50, 349, 390, 392, 709, 391, 579,
1918 712, 579, 59, 640, 61, 82, 394, -1, 85, 86,
1919 67, -1, 393, 398, 598, -1, 600, -1, 730, 96,
1920 732, 408, -1, 735, -1, 82, -1, 86, 85, 86,
1921 1, -1, 91, 92, 93, -1, -1, 749, 97, 96,
1922 -1, -1, 101, -1, 91, 92, 93, 202, 203, -1,
1923 97, 763, -1, 561, 101, -1, 564, -1, 770, 643,
1924 -1, -1, 408, -1, 648, 777, -1, 779, -1, -1,
1925 782, 86, 784, -1, 786, -1, 91, 92, 93, 50,
1926 -1, -1, 97, -1, -1, 669, 101, -1, 59, -1,
1927 598, -1, 600, 677, 65, -1, 91, 92, 93, -1,
1928 -1, 72, 97, -1, -1, 76, 101, -1, -1, -1,
1929 -1, 82, -1, 268, 85, 86, 271, -1, 89, 90,
1930 -1, -1, 93, -1, 279, 709, -1, -1, 712, -1,
1931 -1, 102, 103, 104, 105, 643, -1, 108, 109, -1,
1932 648, -1, -1, -1, -1, -1, 730, -1, 732, -1,
1933 -1, 735, -1, -1, -1, -1, -1, -1, -1, -1,
1934 -1, 669, -1, -1, -1, 749, -1, -1, -1, 677,
1935 -1, -1, -1, -1, 561, -1, -1, 564, -1, 763,
1936 -1, -1, -1, -1, -1, -1, 770, -1, -1, -1,
1937 -1, -1, -1, 777, -1, 779, -1, -1, 782, -1,
1938 784, 709, 786, -1, 712, -1, -1, -1, -1, -1,
1939 365, 598, -1, 600, 369, 561, -1, -1, 564, -1,
1940 -1, -1, 730, -1, 732, -1, -1, 735, -1, -1,
1941 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1942 395, 749, -1, -1, -1, -1, -1, -1, -1, -1,
1943 -1, -1, 598, -1, 600, 763, 643, -1, 413, -1,
1944 -1, 648, 770, -1, 192, 193, 194, 195, 423, 777,
1945 425, 779, 200, 201, 782, -1, 784, -1, 786, -1,
1946 -1, 436, 669, -1, -1, -1, -1, -1, -1, -1,
1947 677, -1, -1, -1, -1, -1, -1, 643, 192, 193,
1948 194, 195, 648, 458, -1, 460, 200, 201, -1, -1,
1949 -1, -1, -1, -1, -1, -1, -1, -1, -1, 474,
1950 -1, -1, 709, 669, -1, 712, -1, -1, -1, -1,
1951 485, 677, -1, -1, -1, 490, -1, -1, -1, -1,
1952 -1, -1, -1, 730, -1, 732, -1, -1, 735, -1,
1953 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1954 -1, -1, 749, 709, -1, -1, 712, -1, -1, -1,
1955 -1, -1, -1, -1, -1, -1, 763, -1, -1, -1,
1956 -1, -1, -1, 770, 730, -1, 732, -1, -1, 735,
1957 777, -1, 779, -1, -1, 782, -1, 784, -1, 786,
1958 -1, -1, -1, 749, -1, -1, -1, -1, -1, -1,
1959 -1, -1, -1, -1, -1, -1, -1, 763, -1, -1,
1960 -1, -1, -1, -1, 770, -1, -1, -1, -1, -1,
1961 -1, 777, -1, 779, -1, -1, 782, -1, 784, -1,
1962 786, -1, -1, -1, -1, -1, -1, 375, 376, 377,
1963 378, 379, 380, 381, 382, 383, 384, 385, 386, -1,
1964 388, 389, 390, 391, 392, 393, 394, -1, -1, -1,
1965 -1, -1, -1, -1, 1, -1, 631, -1, -1, -1,
1966 -1, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1967 384, 385, 386, -1, 388, 389, 390, 391, 392, 393,
1968 394, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1969 665, -1, -1, -1, -1, -1, 671, 44, 45, 46,
1970 47, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1971 -1, 58, 59, -1, -1, 62, -1, -1, 65, 66,
1972 67, 68, -1, 70, 71, 72, 73, -1, -1, 76,
1973 -1, -1, -1, -1, 482, 82, 1, -1, 85, 86,
1974 488, -1, -1, -1, -1, -1, 93, -1, 95, 96,
1975 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1976 -1, 108, 109, -1, -1, -1, -1, -1, 482, -1,
1977 -1, -1, -1, 748, 488, -1, -1, 752, -1, 44,
1978 45, 46, 47, 48, 49, 50, 51, -1, -1, 54,
1979 -1, -1, -1, 58, 59, -1, -1, 62, -1, -1,
1980 65, 66, 67, 68, -1, 70, 71, 72, 73, -1,
1981 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
1982 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
1983 95, 96, 72, -1, 99, -1, 76, 102, 103, 104,
1984 105, -1, 82, 108, 109, 85, 86, -1, -1, 89,
1985 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
1986 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1987 1, -1, -1, -1, -1, 623, -1, 625, -1, -1,
1988 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1989 -1, -1, 640, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, -1, -1, -1, -1, -1, -1, -1, 623,
1991 -1, 625, -1, 44, 45, 46, 47, 48, 49, 50,
1992 51, -1, -1, 54, -1, -1, 640, 58, 59, -1,
1993 -1, 62, -1, -1, 65, 66, 67, 68, 1, 70,
1994 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1995 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1996 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
1997 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1998 -1, 44, 45, 46, -1, 48, 49, 50, 51, -1,
1999 -1, 54, -1, -1, -1, 58, 59, -1, -1, -1,
2000 -1, -1, 65, 66, 67, 68, 1, 70, 71, 72,
2001 73, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2002 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2003 93, -1, 95, 96, -1, -1, 99, -1, -1, 102,
2004 103, 104, 105, -1, -1, 108, 109, -1, -1, 44,
2005 45, 46, -1, 48, 49, 50, 51, -1, -1, 54,
2006 -1, -1, -1, 58, 59, -1, -1, -1, -1, -1,
2007 65, 66, 67, 68, 1, 70, 71, 72, 73, -1,
2008 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2009 85, 86, -1, -1, -1, -1, -1, -1, 93, -1,
2010 95, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2011 105, -1, -1, 108, 109, -1, -1, 44, 45, 46,
2012 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
2013 -1, 58, 59, -1, -1, -1, -1, -1, 65, 66,
2014 1, 68, -1, 70, 71, 72, 73, -1, -1, 76,
2015 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2016 -1, -1, -1, -1, -1, -1, 93, -1, 95, -1,
2017 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
2018 -1, 108, 109, 44, 45, 46, -1, 48, 49, 50,
2019 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
2020 -1, -1, -1, -1, 65, 66, -1, 68, -1, 70,
2021 71, 72, 73, -1, 1, 76, 3, 4, -1, -1,
2022 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
2023 -1, -1, 93, -1, 95, -1, -1, -1, 99, -1,
2024 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
2025 -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,
2026 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2027 -1, -1, 59, -1, -1, -1, -1, -1, 65, 1,
2028 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2029 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2030 -1, -1, 89, 90, -1, -1, 93, -1, 95, 96,
2031 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2032 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2033 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2034 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2035 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2036 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2037 -1, 93, -1, 95, 45, 46, -1, -1, -1, 50,
2038 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2039 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2040 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2041 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2042 -1, -1, 93, -1, -1, -1, -1, -1, 99, -1,
2043 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2044 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2045 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2046 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2047 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2048 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2049 45, 46, 98, -1, -1, 50, 102, 103, 104, 105,
2050 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2051 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2052 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2053 85, 86, -1, 88, 89, 90, -1, -1, 93, -1,
2054 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2055 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2056 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2057 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2058 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2059 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2060 90, -1, -1, 93, -1, -1, 45, 46, 98, -1,
2061 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2062 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2063 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2064 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2065 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2066 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2067 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2068 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2069 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2070 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2071 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2072 -1, -1, 45, 46, -1, 99, -1, 50, 102, 103,
2073 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2074 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2075 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2076 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2077 93, -1, -1, -1, -1, 98, -1, -1, -1, 102,
2078 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2079 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2080 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2081 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2082 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2083 -1, 89, 90, -1, -1, 93, 94, -1, 45, 46,
2084 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2085 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2086 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2087 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2088 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2089 -1, 98, -1, -1, -1, 102, 103, 104, 105, -1,
2090 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2091 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2092 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2093 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2094 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2095 -1, 93, 94, -1, 45, 46, -1, -1, -1, 50,
2096 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2097 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2098 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2099 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2100 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
2101 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2102 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2103 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2104 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2105 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2106 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2107 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2108 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2109 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2110 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2111 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2112 -1, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2113 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2114 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2115 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2116 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2117 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2118 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2119 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2120 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2121 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2122 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2123 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2124 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2125 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2126 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2127 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2128 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2129 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2130 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2131 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2132 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2133 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2134 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2135 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2136 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2137 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2138 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2139 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2140 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2141 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2142 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2143 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2144 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2145 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2146 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2147 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2148 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2149 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2150 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2151 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2152 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2153 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2154 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2155 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2156 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2157 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2158 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2159 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2160 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2161 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2162 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2163 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2164 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2165 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2166 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2167 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2168 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2169 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2170 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2171 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2172 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2173 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2174 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2175 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2176 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2177 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2178 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2179 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2180 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2181 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2182 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2183 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2184 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2185 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2186 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2187 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2188 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2189 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2190 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2191 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2192 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2193 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2194 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2195 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2196 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2197 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2198 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2199 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2200 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2201 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2202 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2203 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2204 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2205 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2206 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2207 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2208 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2209 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2210 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2211 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2212 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2213 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2214 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2215 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2216 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2217 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2218 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2219 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2220 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2221 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2222 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2223 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2224 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2225 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2226 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2227 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2228 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2229 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2230 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2231 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2232 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2233 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2234 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2235 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2236 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2237 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2238 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2239 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2240 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2241 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2242 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2243 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2244 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2245 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2246 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2247 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2248 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2249 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2250 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2251 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2252 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2253 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2254 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2255 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2256 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2257 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2258 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2259 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2260 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2261 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2262 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2263 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2264 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2265 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2266 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2267 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2268 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2269 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2270 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2271 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2272 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2273 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2274 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2275 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2276 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2277 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2278 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2279 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2280 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2281 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2282 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2283 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2284 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2285 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2286 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2287 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2288 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2289 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2290 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2291 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2292 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2293 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2294 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2295 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2296 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2297 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2298 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2299 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2300 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2301 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2302 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2303 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2304 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2305 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2306 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2307 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2308 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2309 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2310 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2311 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2312 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2313 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2314 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2315 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2316 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2317 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2318 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2319 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2320 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2321 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2322 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2323 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2324 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2325 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2326 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2327 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2328 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2329 -1, -1, -1, -1, 65, -1, 1, -1, -1, -1,
2330 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2331 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2332 -1, 1, 93, -1, -1, -1, -1, -1, -1, -1,
2333 -1, 102, 103, 104, 105, -1, -1, 108, 109, 44,
2334 45, 46, -1, -1, -1, 50, -1, -1, -1, -1,
2335 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2336 65, -1, -1, 1, -1, 45, 46, 72, -1, -1,
2337 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
2338 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
2339 3, 4, 72, -1, 99, -1, 76, 102, 103, 104,
2340 105, -1, 82, 108, 109, 85, 86, 45, 46, -1,
2341 -1, -1, 50, 93, 94, -1, -1, -1, -1, -1,
2342 -1, 59, 102, 103, 104, 105, -1, 65, 108, 109,
2343 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2344 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2345 -1, -1, 65, -1, -1, 93, 94, 3, 4, 72,
2346 -1, -1, -1, 76, 102, 103, 104, 105, -1, 82,
2347 108, 109, 85, 86, 45, 46, 89, 90, -1, 50,
2348 93, -1, 95, 96, -1, -1, -1, -1, 59, 102,
2349 103, 104, 105, -1, 65, 108, 109, -1, -1, 45,
2350 46, 72, -1, -1, 50, 76, -1, -1, 3, 4,
2351 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2352 -1, -1, 93, -1, -1, -1, 72, -1, -1, -1,
2353 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2354 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2355 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2356 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2357 65, -1, -1, 3, 4, -1, -1, 72, -1, -1,
2358 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2359 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
2360 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2361 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2362 50, -1, -1, -1, 3, 4, -1, -1, -1, 59,
2363 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2364 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2365 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2366 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
2367 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2368 59, -1, -1, -1, -1, -1, 65, -1, -1, 3,
2369 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2370 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2371 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2372 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2373 109, 45, 46, -1, -1, -1, 50, -1, -1, -1,
2374 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
2375 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2376 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2377 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2378 -1, 44, 45, 46, -1, -1, -1, 50, 102, 103,
2379 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2380 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2381 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2382 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2383 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2384 103, 104, 105, -1, -1, 108, 109
2388 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2389 #line 3 "/usr/lib/bison.simple"
2390 /* This file comes from bison-1.28. */
2392 /* Skeleton output parser for bison,
2393 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2395 This program is free software; you can redistribute it and/or modify
2396 it under the terms of the GNU General Public License as published by
2397 the Free Software Foundation; either version 2, or (at your option)
2400 This program is distributed in the hope that it will be useful,
2401 but WITHOUT ANY WARRANTY; without even the implied warranty of
2402 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2403 GNU General Public License for more details.
2405 You should have received a copy of the GNU General Public License
2406 along with this program; if not, write to the Free Software
2407 Foundation, Inc., 59 Temple Place - Suite 330,
2408 Boston, MA 02111-1307, USA. */
2410 /* As a special exception, when this file is copied by Bison into a
2411 Bison output file, you may use that output file without restriction.
2412 This special exception was added by the Free Software Foundation
2413 in version 1.24 of Bison. */
2415 /* This is the parser code that is written into each bison parser
2416 when the %semantic_parser declaration is not specified in the grammar.
2417 It was written by Richard Stallman by simplifying the hairy parser
2418 used when %semantic_parser is specified. */
2420 #ifndef YYSTACK_USE_ALLOCA
2422 #define YYSTACK_USE_ALLOCA
2423 #else /* alloca not defined */
2425 #define YYSTACK_USE_ALLOCA
2426 #define alloca __builtin_alloca
2427 #else /* not GNU C. */
2428 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2429 #define YYSTACK_USE_ALLOCA
2431 #else /* not sparc */
2432 /* We think this test detects Watcom and Microsoft C. */
2433 /* This used to test MSDOS, but that is a bad idea
2434 since that symbol is in the user namespace. */
2435 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2436 #if 0 /* No need for malloc.h, which pollutes the namespace;
2437 instead, just don't use alloca. */
2440 #else /* not MSDOS, or __TURBOC__ */
2442 /* I don't know what this was needed for, but it pollutes the namespace.
2443 So I turned it off. rms, 2 May 1997. */
2444 /* #include <malloc.h> */
2446 #define YYSTACK_USE_ALLOCA
2447 #else /* not MSDOS, or __TURBOC__, or _AIX */
2449 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2450 and on HPUX 10. Eventually we can turn this on. */
2451 #define YYSTACK_USE_ALLOCA
2452 #define alloca __builtin_alloca
2455 #endif /* not _AIX */
2456 #endif /* not MSDOS, or __TURBOC__ */
2457 #endif /* not sparc */
2458 #endif /* not GNU C */
2459 #endif /* alloca not defined */
2460 #endif /* YYSTACK_USE_ALLOCA not defined */
2462 #ifdef YYSTACK_USE_ALLOCA
2463 #define YYSTACK_ALLOC alloca
2465 #define YYSTACK_ALLOC malloc
2468 /* Note: there must be only one dollar sign in this file.
2469 It is replaced by the list of actions, each action
2470 as one case of the switch. */
2472 #define yyerrok (yyerrstatus = 0)
2473 #define yyclearin (yychar = YYEMPTY)
2476 #define YYACCEPT goto yyacceptlab
2477 #define YYABORT goto yyabortlab
2478 #define YYERROR goto yyerrlab1
2479 /* Like YYERROR except do call yyerror.
2480 This remains here temporarily to ease the
2481 transition to the new meaning of YYERROR, for GCC.
2482 Once GCC version 2 has supplanted version 1, this can go. */
2483 #define YYFAIL goto yyerrlab
2484 #define YYRECOVERING() (!!yyerrstatus)
2485 #define YYBACKUP(token, value) \
2487 if (yychar == YYEMPTY && yylen == 1) \
2488 { yychar = (token), yylval = (value); \
2489 yychar1 = YYTRANSLATE (yychar); \
2494 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2498 #define YYERRCODE 256
2501 #define YYLEX yylex()
2507 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2509 #define YYLEX yylex(&yylval, &yylloc)
2511 #else /* not YYLSP_NEEDED */
2513 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2515 #define YYLEX yylex(&yylval)
2517 #endif /* not YYLSP_NEEDED */
2520 /* If nonreentrant, generate the variables here */
2524 int yychar; /* the lookahead symbol */
2525 YYSTYPE yylval; /* the semantic value of the */
2526 /* lookahead symbol */
2529 YYLTYPE yylloc; /* location data for the lookahead */
2533 int yynerrs; /* number of parse errors so far */
2534 #endif /* not YYPURE */
2537 int yydebug; /* nonzero means print parse trace */
2538 /* Since this is uninitialized, it does not stop multiple parsers
2542 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2545 #define YYINITDEPTH 200
2548 /* YYMAXDEPTH is the maximum size the stacks can grow to
2549 (effective only if the built-in stack extension method is used). */
2556 #define YYMAXDEPTH 10000
2559 /* Define __yy_memcpy. Note that the size argument
2560 should be passed with type unsigned int, because that is what the non-GCC
2561 definitions require. With GCC, __builtin_memcpy takes an arg
2562 of type size_t, but it can handle unsigned int. */
2564 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2565 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2566 #else /* not GNU C or C++ */
2569 /* This is the most reliable way to avoid incompatibilities
2570 in available built-in functions on various systems. */
2572 __yy_memcpy (to, from, count)
2577 register char *f = from;
2578 register char *t = to;
2579 register int i = count;
2585 #else /* __cplusplus */
2587 /* This is the most reliable way to avoid incompatibilities
2588 in available built-in functions on various systems. */
2590 __yy_memcpy (char *to, char *from, unsigned int count)
2592 register char *t = to;
2593 register char *f = from;
2594 register int i = count;
2603 #line 217 "/usr/lib/bison.simple"
2605 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2606 into yyparse. The argument should have type void *.
2607 It should actually point to an object.
2608 Grammar actions can access the variable by casting it
2609 to the proper pointer type. */
2611 #ifdef YYPARSE_PARAM
2613 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2614 #define YYPARSE_PARAM_DECL
2615 #else /* not __cplusplus */
2616 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2617 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2618 #endif /* not __cplusplus */
2619 #else /* not YYPARSE_PARAM */
2620 #define YYPARSE_PARAM_ARG
2621 #define YYPARSE_PARAM_DECL
2622 #endif /* not YYPARSE_PARAM */
2624 /* Prevent warning if -Wstrict-prototypes. */
2626 #ifdef YYPARSE_PARAM
2627 int yyparse (void *);
2634 yyparse(YYPARSE_PARAM_ARG)
2637 register int yystate;
2639 register short *yyssp;
2640 register YYSTYPE *yyvsp;
2641 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2642 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2644 short yyssa[YYINITDEPTH]; /* the state stack */
2645 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2647 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2648 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2651 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2652 YYLTYPE *yyls = yylsa;
2655 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2657 #define YYPOPSTACK (yyvsp--, yyssp--)
2660 int yystacksize = YYINITDEPTH;
2661 int yyfree_stacks = 0;
2672 YYSTYPE yyval; /* the variable used to return */
2673 /* semantic values from the action */
2680 fprintf(stderr, "Starting parse\n");
2686 yychar = YYEMPTY; /* Cause a token to be read. */
2688 /* Initialize stack pointers.
2689 Waste one element of value and location stack
2690 so that they stay on the same level as the state stack.
2691 The wasted elements are never initialized. */
2699 /* Push a new state, which is found in yystate . */
2700 /* In all cases, when you get here, the value and location stacks
2701 have just been pushed. so pushing a state here evens the stacks. */
2706 if (yyssp >= yyss + yystacksize - 1)
2708 /* Give user a chance to reallocate the stack */
2709 /* Use copies of these so that the &'s don't force the real ones into memory. */
2710 YYSTYPE *yyvs1 = yyvs;
2711 short *yyss1 = yyss;
2713 YYLTYPE *yyls1 = yyls;
2716 /* Get the current used size of the three stacks, in elements. */
2717 int size = yyssp - yyss + 1;
2720 /* Each stack pointer address is followed by the size of
2721 the data in use in that stack, in bytes. */
2723 /* This used to be a conditional around just the two extra args,
2724 but that might be undefined if yyoverflow is a macro. */
2725 yyoverflow("parser stack overflow",
2726 &yyss1, size * sizeof (*yyssp),
2727 &yyvs1, size * sizeof (*yyvsp),
2728 &yyls1, size * sizeof (*yylsp),
2731 yyoverflow("parser stack overflow",
2732 &yyss1, size * sizeof (*yyssp),
2733 &yyvs1, size * sizeof (*yyvsp),
2737 yyss = yyss1; yyvs = yyvs1;
2741 #else /* no yyoverflow */
2742 /* Extend the stack our own way. */
2743 if (yystacksize >= YYMAXDEPTH)
2745 yyerror("parser stack overflow");
2757 if (yystacksize > YYMAXDEPTH)
2758 yystacksize = YYMAXDEPTH;
2759 #ifndef YYSTACK_USE_ALLOCA
2762 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2763 __yy_memcpy ((char *)yyss, (char *)yyss1,
2764 size * (unsigned int) sizeof (*yyssp));
2765 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2766 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2767 size * (unsigned int) sizeof (*yyvsp));
2769 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2770 __yy_memcpy ((char *)yyls, (char *)yyls1,
2771 size * (unsigned int) sizeof (*yylsp));
2773 #endif /* no yyoverflow */
2775 yyssp = yyss + size - 1;
2776 yyvsp = yyvs + size - 1;
2778 yylsp = yyls + size - 1;
2783 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2786 if (yyssp >= yyss + yystacksize - 1)
2792 fprintf(stderr, "Entering state %d\n", yystate);
2798 /* Do appropriate processing given the current state. */
2799 /* Read a lookahead token if we need one and don't already have one. */
2802 /* First try to decide what to do without reference to lookahead token. */
2804 yyn = yypact[yystate];
2808 /* Not known => get a lookahead token if don't already have one. */
2810 /* yychar is either YYEMPTY or YYEOF
2811 or a valid token in external form. */
2813 if (yychar == YYEMPTY)
2817 fprintf(stderr, "Reading a token: ");
2822 /* Convert token to internal form (in yychar1) for indexing tables with */
2824 if (yychar <= 0) /* This means end of input. */
2827 yychar = YYEOF; /* Don't call YYLEX any more */
2831 fprintf(stderr, "Now at end of input.\n");
2836 yychar1 = YYTRANSLATE(yychar);
2841 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2842 /* Give the individual parser a way to print the precise meaning
2843 of a token, for further debugging info. */
2845 YYPRINT (stderr, yychar, yylval);
2847 fprintf (stderr, ")\n");
2853 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2858 /* yyn is what to do for this token type in this state.
2859 Negative => reduce, -yyn is rule number.
2860 Positive => shift, yyn is new state.
2861 New state is final state => don't bother to shift,
2862 just return success.
2863 0, or most negative number => error. */
2878 /* Shift the lookahead token. */
2882 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2885 /* Discard the token being shifted unless it is eof. */
2886 if (yychar != YYEOF)
2894 /* count tokens shifted since error; after three, turn off error status. */
2895 if (yyerrstatus) yyerrstatus--;
2900 /* Do the default action for the current state. */
2903 yyn = yydefact[yystate];
2907 /* Do a reduction. yyn is the number of a rule to reduce with. */
2911 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2918 fprintf (stderr, "Reducing via rule %d (line %d), ",
2921 /* Print the symbols being reduced, and their result. */
2922 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2923 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2924 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2932 #line 575 "./parse.y"
2936 #line 619 "./parse.y"
2938 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2939 CLASS_LOADED_P (yyval.node) = 1;
2943 #line 624 "./parse.y"
2944 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2947 #line 626 "./parse.y"
2948 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2951 #line 628 "./parse.y"
2952 {RULE ("']' expected"); RECOVER;;
2955 #line 630 "./parse.y"
2956 {RULE ("']' expected"); RECOVER;;
2959 #line 645 "./parse.y"
2960 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2963 #line 654 "./parse.y"
2964 {yyval.node = NULL;;
2967 #line 666 "./parse.y"
2973 #line 670 "./parse.y"
2979 #line 682 "./parse.y"
2981 ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2982 package_list = tree_cons (ctxp->package, NULL, package_list);
2986 #line 687 "./parse.y"
2987 {yyerror ("Missing name"); RECOVER;;
2990 #line 689 "./parse.y"
2991 {yyerror ("';' expected"); RECOVER;;
2994 #line 699 "./parse.y"
2996 tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2997 int i = IDENTIFIER_LENGTH (name)-1;
2998 const char *last = &IDENTIFIER_POINTER (name)[i];
2999 while (last != IDENTIFIER_POINTER (name))
3001 if (last [0] == '.')
3005 last_name = get_identifier (++last);
3006 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3008 tree err = find_name_in_single_imports (last_name);
3009 if (err && err != name)
3011 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3012 IDENTIFIER_POINTER (name),
3013 IDENTIFIER_POINTER (err));
3015 REGISTER_IMPORT (yyvsp[-1].node, last_name)
3018 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3022 #line 725 "./parse.y"
3023 {yyerror ("Missing name"); RECOVER;;
3026 #line 727 "./parse.y"
3027 {yyerror ("';' expected"); RECOVER;;
3030 #line 732 "./parse.y"
3032 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3033 /* Don't import java.lang.* twice. */
3034 if (name != java_lang_id)
3036 tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3037 read_import_dir (yyvsp[-3].node);
3038 TREE_CHAIN (node) = ctxp->import_demand_list;
3039 ctxp->import_demand_list = node;
3044 #line 744 "./parse.y"
3045 {yyerror ("'*' expected"); RECOVER;;
3048 #line 746 "./parse.y"
3049 {yyerror ("';' expected"); RECOVER;;
3052 #line 751 "./parse.y"
3053 { end_class_declaration (0); ;
3056 #line 753 "./parse.y"
3057 { end_class_declaration (0); ;
3060 #line 755 "./parse.y"
3061 { yyval.node = NULL; ;
3064 #line 757 "./parse.y"
3067 yyerror ("Class or interface declaration expected");
3071 #line 768 "./parse.y"
3073 yyval.value = (1 << yyvsp[0].value);
3077 #line 772 "./parse.y"
3079 int acc = (1 << yyvsp[0].value);
3080 if (yyval.value & acc)
3082 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3083 java_accstring_lookup (acc));
3091 #line 788 "./parse.y"
3092 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3095 #line 791 "./parse.y"
3096 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3099 #line 794 "./parse.y"
3100 {yyerror ("Missing class name"); RECOVER;;
3103 #line 796 "./parse.y"
3104 {yyerror ("Missing class name"); RECOVER;;
3107 #line 798 "./parse.y"
3109 if (!ctxp->class_err) yyerror ("'{' expected");
3114 #line 803 "./parse.y"
3115 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3118 #line 807 "./parse.y"
3119 { yyval.node = NULL; ;
3122 #line 809 "./parse.y"
3123 { yyval.node = yyvsp[0].node; ;
3126 #line 811 "./parse.y"
3127 {yyerror ("'{' expected"); ctxp->class_err=1;;
3130 #line 813 "./parse.y"
3131 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3134 #line 817 "./parse.y"
3135 { yyval.node = NULL_TREE; ;
3138 #line 819 "./parse.y"
3139 { yyval.node = yyvsp[0].node; ;
3142 #line 821 "./parse.y"
3145 yyerror ("Missing interface name");
3149 #line 829 "./parse.y"
3151 ctxp->interface_number = 1;
3152 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3156 #line 834 "./parse.y"
3158 ctxp->interface_number++;
3159 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3163 #line 839 "./parse.y"
3164 {yyerror ("Missing interface name"); RECOVER;;
3167 #line 844 "./parse.y"
3169 /* Store the location of the `}' when doing xrefs */
3171 DECL_END_SOURCE_LINE (GET_CPC ()) =
3172 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3173 yyval.node = GET_CPC ();
3177 #line 852 "./parse.y"
3179 /* Store the location of the `}' when doing xrefs */
3181 DECL_END_SOURCE_LINE (GET_CPC ()) =
3182 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3183 yyval.node = GET_CPC ();
3187 #line 871 "./parse.y"
3189 TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3190 SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3194 #line 880 "./parse.y"
3195 { yyval.node = yyvsp[-1].node; ;
3198 #line 883 "./parse.y"
3199 { end_class_declaration (1); ;
3202 #line 885 "./parse.y"
3203 { end_class_declaration (1); ;
3206 #line 891 "./parse.y"
3207 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3210 #line 893 "./parse.y"
3213 ("Illegal modifier `%s' for field declaration",
3214 yyvsp[-3].value, FIELD_MODIFIERS);
3215 check_modifiers_consistency (yyvsp[-3].value);
3216 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3220 #line 906 "./parse.y"
3221 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3224 #line 908 "./parse.y"
3225 {yyerror ("Missing term"); RECOVER;;
3228 #line 913 "./parse.y"
3229 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3232 #line 915 "./parse.y"
3234 if (java_error_count)
3235 yyvsp[0].node = NULL_TREE;
3236 yyval.node = build_tree_list
3237 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3241 #line 922 "./parse.y"
3243 yyerror ("Missing variable initializer");
3244 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3249 #line 928 "./parse.y"
3251 yyerror ("';' expected");
3252 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3257 #line 938 "./parse.y"
3258 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3261 #line 940 "./parse.y"
3262 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3265 #line 942 "./parse.y"
3266 {yyerror ("']' expected"); DRECOVER(vdi);;
3269 #line 944 "./parse.y"
3270 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3273 #line 955 "./parse.y"
3275 current_function_decl = yyvsp[0].node;
3276 if (current_function_decl
3277 && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3278 source_start_java_method (current_function_decl);
3280 current_function_decl = NULL_TREE;
3284 #line 964 "./parse.y"
3285 { finish_method_declaration (yyvsp[0].node); ;
3288 #line 966 "./parse.y"
3289 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3292 #line 971 "./parse.y"
3293 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3296 #line 973 "./parse.y"
3297 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3300 #line 975 "./parse.y"
3301 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3304 #line 977 "./parse.y"
3305 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3308 #line 979 "./parse.y"
3310 yyerror ("Invalid method declaration, method name required");
3315 #line 984 "./parse.y"
3319 #line 986 "./parse.y"
3320 {yyerror ("Identifier expected"); RECOVER;;
3323 #line 988 "./parse.y"
3324 {yyerror ("Identifier expected"); RECOVER;;
3327 #line 990 "./parse.y"
3329 yyerror ("Invalid method declaration, return type required");
3334 #line 998 "./parse.y"
3336 ctxp->formal_parameter_number = 0;
3337 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3341 #line 1003 "./parse.y"
3342 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3345 #line 1005 "./parse.y"
3347 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3348 TREE_PURPOSE (yyvsp[-2].node) =
3349 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3350 parse_warning_context
3352 "Discouraged form of returned type specification");
3356 #line 1014 "./parse.y"
3357 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3360 #line 1016 "./parse.y"
3361 {yyerror ("']' expected"); RECOVER;;
3364 #line 1021 "./parse.y"
3366 ctxp->formal_parameter_number = 1;
3370 #line 1025 "./parse.y"
3372 ctxp->formal_parameter_number += 1;
3373 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3377 #line 1030 "./parse.y"
3378 { yyerror ("Missing formal parameter term"); RECOVER; ;
3381 #line 1035 "./parse.y"
3383 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3387 #line 1039 "./parse.y"
3389 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3390 ARG_FINAL_P (yyval.node) = 1;
3394 #line 1044 "./parse.y"
3396 yyerror ("Missing identifier"); RECOVER;
3397 yyval.node = NULL_TREE;
3401 #line 1049 "./parse.y"
3403 yyerror ("Missing identifier"); RECOVER;
3404 yyval.node = NULL_TREE;
3408 #line 1057 "./parse.y"
3410 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3411 yyvsp[0].value, ACC_FINAL);
3412 if (yyvsp[0].value != ACC_FINAL)
3413 MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3417 #line 1066 "./parse.y"
3418 { yyval.node = NULL_TREE; ;
3421 #line 1068 "./parse.y"
3422 { yyval.node = yyvsp[0].node; ;
3425 #line 1070 "./parse.y"
3426 {yyerror ("Missing class type term"); RECOVER;;
3429 #line 1075 "./parse.y"
3430 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3433 #line 1077 "./parse.y"
3434 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3437 #line 1079 "./parse.y"
3438 {yyerror ("Missing class type term"); RECOVER;;
3441 #line 1086 "./parse.y"
3442 { yyval.node = NULL_TREE; ;
3445 #line 1092 "./parse.y"
3447 TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3448 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3452 #line 1097 "./parse.y"
3454 TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3455 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3459 #line 1105 "./parse.y"
3461 check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3462 /* Can't have a static initializer in an innerclass */
3463 if (yyvsp[0].value | ACC_STATIC &&
3464 GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3466 (MODIFIER_WFL (STATIC_TK),
3467 "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3468 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3469 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3473 #line 1121 "./parse.y"
3475 current_function_decl = yyvsp[0].node;
3476 source_start_java_method (current_function_decl);
3480 #line 1126 "./parse.y"
3481 { finish_method_declaration (yyvsp[0].node); ;
3484 #line 1131 "./parse.y"
3485 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3488 #line 1133 "./parse.y"
3489 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3492 #line 1138 "./parse.y"
3494 ctxp->formal_parameter_number = 0;
3495 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3499 #line 1143 "./parse.y"
3500 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3503 #line 1151 "./parse.y"
3505 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3506 yyval.node = yyvsp[0].node;
3510 #line 1156 "./parse.y"
3511 { yyval.node = yyvsp[0].node; ;
3514 #line 1158 "./parse.y"
3515 { yyval.node = yyvsp[0].node; ;
3518 #line 1160 "./parse.y"
3519 { yyval.node = yyvsp[0].node; ;
3522 #line 1170 "./parse.y"
3524 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3525 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3526 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3530 #line 1176 "./parse.y"
3532 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3533 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3534 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3538 #line 1184 "./parse.y"
3539 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3542 #line 1186 "./parse.y"
3543 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3546 #line 1191 "./parse.y"
3548 tree wfl = build_wfl_node (this_identifier_node);
3549 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3554 #line 1197 "./parse.y"
3556 tree wfl = build_wfl_node (super_identifier_node);
3557 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3562 #line 1208 "./parse.y"
3563 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3566 #line 1211 "./parse.y"
3567 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3570 #line 1214 "./parse.y"
3571 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3574 #line 1217 "./parse.y"
3575 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3578 #line 1220 "./parse.y"
3579 {yyerror ("'{' expected"); RECOVER;;
3582 #line 1222 "./parse.y"
3583 {yyerror ("'{' expected"); RECOVER;;
3586 #line 1227 "./parse.y"
3588 ctxp->interface_number = 1;
3589 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3593 #line 1232 "./parse.y"
3595 ctxp->interface_number++;
3596 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3600 #line 1237 "./parse.y"
3601 {yyerror ("Invalid interface type"); RECOVER;;
3604 #line 1239 "./parse.y"
3605 {yyerror ("Missing term"); RECOVER;;
3608 #line 1244 "./parse.y"
3609 { yyval.node = NULL_TREE; ;
3612 #line 1246 "./parse.y"
3613 { yyval.node = NULL_TREE; ;
3616 #line 1258 "./parse.y"
3617 { end_class_declaration (1); ;
3620 #line 1260 "./parse.y"
3621 { end_class_declaration (1); ;
3624 #line 1269 "./parse.y"
3626 check_abstract_method_header (yyvsp[-1].node);
3627 current_function_decl = NULL_TREE; /* FIXME ? */
3631 #line 1274 "./parse.y"
3632 {yyerror ("';' expected"); RECOVER;;
3635 #line 1280 "./parse.y"
3636 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3639 #line 1282 "./parse.y"
3640 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3643 #line 1284 "./parse.y"
3644 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3647 #line 1289 "./parse.y"
3649 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3650 yyvsp[0].node, NULL_TREE);
3654 #line 1294 "./parse.y"
3656 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3660 #line 1298 "./parse.y"
3661 {yyerror ("Missing term"); RECOVER;;
3664 #line 1304 "./parse.y"
3666 /* Store the location of the `}' when doing xrefs */
3667 if (current_function_decl && flag_emit_xref)
3668 DECL_END_SOURCE_LINE (current_function_decl) =
3669 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3670 yyval.node = empty_stmt_node;
3674 #line 1312 "./parse.y"
3675 { yyval.node = yyvsp[0].node; ;
3678 #line 1317 "./parse.y"
3682 #line 1322 "./parse.y"
3684 maybe_absorb_scoping_blocks ();
3685 /* Store the location of the `}' when doing xrefs */
3686 if (current_function_decl && flag_emit_xref)
3687 DECL_END_SOURCE_LINE (current_function_decl) =
3688 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3689 yyval.node = exit_block ();
3693 #line 1340 "./parse.y"
3694 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3697 #line 1342 "./parse.y"
3699 LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3700 end_class_declaration (1);
3704 #line 1354 "./parse.y"
3705 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3708 #line 1356 "./parse.y"
3709 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3712 #line 1366 "./parse.y"
3713 { yyval.node = exit_block (); ;
3716 #line 1375 "./parse.y"
3717 { yyval.node = exit_block (); ;
3720 #line 1394 "./parse.y"
3721 { yyval.node = empty_stmt_node; ;
3724 #line 1399 "./parse.y"
3726 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3727 EXPR_WFL_NODE (yyvsp[-1].node));
3729 push_labeled_block (yyval.node);
3730 PUSH_LABELED_BLOCK (yyval.node);
3734 #line 1410 "./parse.y"
3735 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3738 #line 1412 "./parse.y"
3739 {yyerror ("':' expected"); RECOVER;;
3742 #line 1417 "./parse.y"
3743 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3746 #line 1424 "./parse.y"
3748 /* We have a statement. Generate a WFL around it so
3750 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3751 /* We know we have a statement, so set the debug
3752 info to be eventually generate here. */
3753 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3757 #line 1433 "./parse.y"
3759 if (ctxp->prevent_ese != lineno)
3760 yyerror ("Invalid expression statement");
3761 DRECOVER (expr_stmt);
3765 #line 1439 "./parse.y"
3767 if (ctxp->prevent_ese != lineno)
3768 yyerror ("Invalid expression statement");
3769 DRECOVER (expr_stmt);
3773 #line 1445 "./parse.y"
3775 if (ctxp->prevent_ese != lineno)
3776 yyerror ("Invalid expression statement");
3777 DRECOVER (expr_stmt);
3781 #line 1451 "./parse.y"
3782 {yyerror ("')' expected"); RECOVER;;
3785 #line 1453 "./parse.y"
3787 parse_ctor_invocation_error ();
3792 #line 1458 "./parse.y"
3793 {yyerror ("')' expected"); RECOVER;;
3796 #line 1460 "./parse.y"
3798 parse_ctor_invocation_error ();
3803 #line 1465 "./parse.y"
3804 {yyerror ("'(' expected"); RECOVER;;
3807 #line 1467 "./parse.y"
3808 {yyerror ("')' expected"); RECOVER;;
3811 #line 1469 "./parse.y"
3812 {yyerror ("')' expected"); RECOVER;;
3815 #line 1471 "./parse.y"
3816 {yyerror ("';' expected"); RECOVER;;
3819 #line 1473 "./parse.y"
3820 {yyerror ("';' expected"); RECOVER;;
3823 #line 1488 "./parse.y"
3825 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
3826 yyvsp[0].node, NULL_TREE);
3830 #line 1493 "./parse.y"
3831 {yyerror ("'(' expected"); RECOVER;;
3834 #line 1495 "./parse.y"
3835 {yyerror ("Missing term"); RECOVER;;
3838 #line 1497 "./parse.y"
3839 {yyerror ("')' expected"); RECOVER;;
3842 #line 1502 "./parse.y"
3843 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3846 #line 1507 "./parse.y"
3847 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3850 #line 1512 "./parse.y"
3856 #line 1516 "./parse.y"
3858 /* Make into "proper list" of COMPOUND_EXPRs.
3859 I.e. make the last statment also have its own
3861 maybe_absorb_scoping_blocks ();
3862 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3863 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3867 #line 1528 "./parse.y"
3869 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3870 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3874 #line 1533 "./parse.y"
3875 {yyerror ("'(' expected"); RECOVER;;
3878 #line 1535 "./parse.y"
3879 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3882 #line 1537 "./parse.y"
3883 {yyerror ("'{' expected"); RECOVER;;
3886 #line 1545 "./parse.y"
3887 { yyval.node = NULL_TREE; ;
3890 #line 1547 "./parse.y"
3891 { yyval.node = NULL_TREE; ;
3894 #line 1549 "./parse.y"
3895 { yyval.node = NULL_TREE; ;
3898 #line 1551 "./parse.y"
3899 { yyval.node = NULL_TREE; ;
3902 #line 1570 "./parse.y"
3904 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3905 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3906 java_method_add_stmt (current_function_decl, lab);
3910 #line 1576 "./parse.y"
3912 tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3913 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3914 java_method_add_stmt (current_function_decl, lab);
3918 #line 1582 "./parse.y"
3919 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3922 #line 1584 "./parse.y"
3923 {yyerror ("':' expected"); RECOVER;;
3926 #line 1586 "./parse.y"
3927 {yyerror ("':' expected"); RECOVER;;
3930 #line 1591 "./parse.y"
3932 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3933 yyval.node = build_new_loop (body);
3937 #line 1599 "./parse.y"
3938 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3941 #line 1601 "./parse.y"
3942 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3945 #line 1603 "./parse.y"
3946 {yyerror ("Missing term and ')' expected"); RECOVER;;
3949 #line 1605 "./parse.y"
3950 {yyerror ("')' expected"); RECOVER;;
3953 #line 1610 "./parse.y"
3954 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3957 #line 1615 "./parse.y"
3959 tree body = build_loop_body (0, NULL_TREE, 1);
3960 yyval.node = build_new_loop (body);
3964 #line 1624 "./parse.y"
3965 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3968 #line 1629 "./parse.y"
3969 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3972 #line 1631 "./parse.y"
3974 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3975 /* We have not condition, so we get rid of the EXIT_EXPR */
3976 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3981 #line 1638 "./parse.y"
3982 {yyerror ("Invalid control expression"); RECOVER;;
3985 #line 1640 "./parse.y"
3986 {yyerror ("Invalid update expression"); RECOVER;;
3989 #line 1642 "./parse.y"
3990 {yyerror ("Invalid update expression"); RECOVER;;
3993 #line 1647 "./parse.y"
3994 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3997 #line 1649 "./parse.y"
3999 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4000 /* We have not condition, so we get rid of the EXIT_EXPR */
4001 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
4006 #line 1659 "./parse.y"
4008 /* This scope defined for local variable that may be
4009 defined within the scope of the for loop */
4014 #line 1665 "./parse.y"
4015 {yyerror ("'(' expected"); DRECOVER(for_1);;
4018 #line 1667 "./parse.y"
4019 {yyerror ("Invalid init statement"); RECOVER;;
4022 #line 1672 "./parse.y"
4024 /* We now declare the loop body. The loop is
4025 declared as a for loop. */
4026 tree body = build_loop_body (0, NULL_TREE, 0);
4027 yyval.node = build_new_loop (body);
4028 FOR_LOOP_P (yyval.node) = 1;
4029 /* The loop is added to the current block the for
4030 statement is defined within */
4031 java_method_add_stmt (current_function_decl, yyval.node);
4035 #line 1684 "./parse.y"
4036 { yyval.node = empty_stmt_node; ;
4039 #line 1686 "./parse.y"
4041 /* Init statement recorded within the previously
4042 defined block scope */
4043 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4047 #line 1692 "./parse.y"
4049 /* Local variable are recorded within the previously
4050 defined block scope */
4051 yyval.node = NULL_TREE;
4055 #line 1698 "./parse.y"
4056 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4059 #line 1702 "./parse.y"
4060 {yyval.node = empty_stmt_node;;
4063 #line 1704 "./parse.y"
4064 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4067 #line 1709 "./parse.y"
4068 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4071 #line 1711 "./parse.y"
4072 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4075 #line 1713 "./parse.y"
4076 {yyerror ("Missing term"); RECOVER;;
4079 #line 1718 "./parse.y"
4080 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4083 #line 1720 "./parse.y"
4084 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4087 #line 1722 "./parse.y"
4088 {yyerror ("Missing term"); RECOVER;;
4091 #line 1724 "./parse.y"
4092 {yyerror ("';' expected"); RECOVER;;
4095 #line 1729 "./parse.y"
4096 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4099 #line 1731 "./parse.y"
4100 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4103 #line 1733 "./parse.y"
4104 {yyerror ("Missing term"); RECOVER;;
4107 #line 1735 "./parse.y"
4108 {yyerror ("';' expected"); RECOVER;;
4111 #line 1740 "./parse.y"
4112 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4115 #line 1742 "./parse.y"
4116 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4119 #line 1744 "./parse.y"
4120 {yyerror ("Missing term"); RECOVER;;
4123 #line 1746 "./parse.y"
4124 {yyerror ("';' expected"); RECOVER;;
4127 #line 1751 "./parse.y"
4129 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4130 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4134 #line 1756 "./parse.y"
4135 {yyerror ("Missing term"); RECOVER;;
4138 #line 1758 "./parse.y"
4139 {yyerror ("';' expected"); RECOVER;;
4142 #line 1763 "./parse.y"
4144 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4145 EXPR_WFL_LINECOL (yyval.node) =
4146 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4150 #line 1769 "./parse.y"
4151 {yyerror ("'{' expected"); RECOVER;;
4154 #line 1771 "./parse.y"
4155 {yyerror ("'(' expected"); RECOVER;;
4158 #line 1773 "./parse.y"
4159 {yyerror ("Missing term"); RECOVER;;
4162 #line 1775 "./parse.y"
4163 {yyerror ("Missing term"); RECOVER;;
4166 #line 1780 "./parse.y"
4169 "Illegal modifier `%s'. Only `synchronized' was expected here",
4170 yyvsp[0].value, ACC_SYNCHRONIZED);
4171 if (yyvsp[0].value != ACC_SYNCHRONIZED)
4172 MODIFIER_WFL (SYNCHRONIZED_TK) =
4173 build_wfl_node (NULL_TREE);
4177 #line 1792 "./parse.y"
4178 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4181 #line 1794 "./parse.y"
4182 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4185 #line 1796 "./parse.y"
4186 { yyval.node = build_try_finally_statement
4187 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4188 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4192 #line 1801 "./parse.y"
4193 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4196 #line 1807 "./parse.y"
4198 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4199 yyval.node = yyvsp[0].node;
4203 #line 1815 "./parse.y"
4205 java_method_add_stmt (current_function_decl, yyvsp[0].node);
4207 yyval.node = yyvsp[-1].node;
4211 #line 1823 "./parse.y"
4213 /* We add a block to define a scope for
4214 formal_parameter (CCBP). The formal parameter is
4215 declared initialized by the appropriate function
4217 tree ccpb = enter_block ();
4218 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
4219 TREE_PURPOSE (yyvsp[-1].node),
4220 soft_exceptioninfo_call_node);
4221 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4222 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4224 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4225 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4229 #line 1839 "./parse.y"
4230 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4233 #line 1841 "./parse.y"
4235 yyerror ("Missing term or ')' expected");
4236 RECOVER; yyval.node = NULL_TREE;
4240 #line 1846 "./parse.y"
4241 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4244 #line 1851 "./parse.y"
4245 { yyval.node = yyvsp[0].node; ;
4248 #line 1853 "./parse.y"
4249 {yyerror ("'{' expected"); RECOVER; ;
4252 #line 1865 "./parse.y"
4253 { yyval.node = build_this (yyvsp[0].operator.location); ;
4256 #line 1867 "./parse.y"
4257 {yyval.node = yyvsp[-1].node;;
4260 #line 1877 "./parse.y"
4262 tree wfl = build_wfl_node (this_identifier_node);
4263 yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4267 #line 1882 "./parse.y"
4268 {yyerror ("')' expected"); RECOVER;;
4271 #line 1884 "./parse.y"
4272 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4275 #line 1886 "./parse.y"
4276 {yyerror ("'class' expected" ); RECOVER;;
4279 #line 1888 "./parse.y"
4280 {yyerror ("'class' expected" ); RECOVER;;
4283 #line 1896 "./parse.y"
4285 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4286 CLASS_LOADED_P (yyval.node) = 1;
4290 #line 1901 "./parse.y"
4291 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4294 #line 1911 "./parse.y"
4295 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4298 #line 1913 "./parse.y"
4299 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4302 #line 1915 "./parse.y"
4303 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4306 #line 1917 "./parse.y"
4307 { yyval.node = build_class_ref (void_type_node); ;
4310 #line 1922 "./parse.y"
4311 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4314 #line 1924 "./parse.y"
4315 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4318 #line 1930 "./parse.y"
4320 tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4321 yyval.node = make_qualified_primary (yyvsp[-3].node, ctor,
4322 EXPR_WFL_LINECOL (yyvsp[-3].node));
4326 #line 1937 "./parse.y"
4328 tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4329 yyval.node = make_qualified_primary (yyvsp[-4].node, ctor,
4330 EXPR_WFL_LINECOL (yyvsp[-4].node));
4334 #line 1944 "./parse.y"
4335 {yyerror ("'(' expected"); DRECOVER(new_1);;
4338 #line 1946 "./parse.y"
4339 {yyerror ("'(' expected"); RECOVER;;
4342 #line 1948 "./parse.y"
4343 {yyerror ("')' or term expected"); RECOVER;;
4346 #line 1950 "./parse.y"
4347 {yyerror ("')' expected"); RECOVER;;
4350 #line 1952 "./parse.y"
4351 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4354 #line 1954 "./parse.y"
4355 {yyerror ("'(' expected"); RECOVER;;
4358 #line 1964 "./parse.y"
4359 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4362 #line 1966 "./parse.y"
4364 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4365 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4367 end_class_declaration (1);
4369 /* Now we can craft the new expression */
4370 yyval.node = build_new_invocation (id, yyvsp[-3].node);
4372 /* Note that we can't possibly be here if
4373 `class_type' is an interface (in which case the
4374 anonymous class extends Object and implements
4375 `class_type', hence its constructor can't have
4378 /* Otherwise, the innerclass must feature a
4379 constructor matching `argument_list'. Anonymous
4380 classes are a bit special: it's impossible to
4381 define constructor for them, hence constructors
4382 must be generated following the hints provided by
4383 the `new' expression. Whether a super constructor
4384 of that nature exists or not is to be verified
4385 later on in verify_constructor_super.
4387 It's during the expansion of a `new' statement
4388 refering to an anonymous class that a ctor will
4389 be generated for the anonymous class, with the
4395 #line 1997 "./parse.y"
4396 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4399 #line 1999 "./parse.y"
4401 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4402 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4404 end_class_declaration (1);
4406 /* Now we can craft the new expression. The
4407 statement doesn't need to be remember so that a
4408 constructor can be generated, since its signature
4409 is already known. */
4410 yyval.node = build_new_invocation (id, NULL_TREE);
4414 #line 2015 "./parse.y"
4415 { yyval.node = yyvsp[-2].node; ;
4418 #line 2017 "./parse.y"
4419 { yyval.node = yyvsp[-2].node; ;
4422 #line 2022 "./parse.y"
4424 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4425 ctxp->formal_parameter_number = 1;
4429 #line 2027 "./parse.y"
4431 ctxp->formal_parameter_number += 1;
4432 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4436 #line 2032 "./parse.y"
4437 {yyerror ("Missing term"); RECOVER;;
4440 #line 2037 "./parse.y"
4441 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4444 #line 2039 "./parse.y"
4445 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4448 #line 2041 "./parse.y"
4449 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4452 #line 2043 "./parse.y"
4453 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4456 #line 2047 "./parse.y"
4459 while (CURRENT_OSB (ctxp)--)
4460 obstack_1grow (&temporary_obstack, '[');
4461 sig = obstack_finish (&temporary_obstack);
4462 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4463 yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4467 #line 2056 "./parse.y"
4469 tree type = yyvsp[-2].node;
4470 while (CURRENT_OSB (ctxp)--)
4471 type = build_java_array_type (type, -1);
4472 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4473 build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4477 #line 2064 "./parse.y"
4478 {yyerror ("'[' expected"); DRECOVER ("]");;
4481 #line 2066 "./parse.y"
4482 {yyerror ("']' expected"); RECOVER;;
4485 #line 2071 "./parse.y"
4486 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4489 #line 2073 "./parse.y"
4490 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4493 #line 2078 "./parse.y"
4495 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4496 yyval.node = yyvsp[-1].node;
4500 #line 2083 "./parse.y"
4501 {yyerror ("']' expected"); RECOVER;;
4504 #line 2085 "./parse.y"
4506 yyerror ("Missing term");
4507 yyerror ("']' expected");
4512 #line 2094 "./parse.y"
4515 /* If not initialized, allocate memory for the osb
4517 if (!ctxp->osb_limit)
4519 allocate = ctxp->osb_limit = 32;
4520 ctxp->osb_depth = -1;
4522 /* If capacity overflown, reallocate a bigger chunk */
4523 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4524 allocate = ctxp->osb_limit << 1;
4528 allocate *= sizeof (int);
4529 if (ctxp->osb_number)
4530 ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4533 ctxp->osb_number = (int *)xmalloc (allocate);
4536 CURRENT_OSB (ctxp) = 1;
4540 #line 2120 "./parse.y"
4541 { CURRENT_OSB (ctxp)++; ;
4544 #line 2122 "./parse.y"
4545 { yyerror ("']' expected"); RECOVER;;
4548 #line 2127 "./parse.y"
4549 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4552 #line 2131 "./parse.y"
4555 build_wfl_node (super_identifier_node);
4556 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4557 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4561 #line 2138 "./parse.y"
4562 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4565 #line 2143 "./parse.y"
4566 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4569 #line 2145 "./parse.y"
4570 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4573 #line 2147 "./parse.y"
4575 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4576 yyval.node = build_this_super_qualified_invocation
4577 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4580 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4581 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4586 #line 2158 "./parse.y"
4588 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4589 yyval.node = build_this_super_qualified_invocation
4590 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4593 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4594 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4599 #line 2169 "./parse.y"
4601 yyval.node = build_this_super_qualified_invocation
4602 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4606 #line 2174 "./parse.y"
4608 yyval.node = build_this_super_qualified_invocation
4609 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4613 #line 2183 "./parse.y"
4614 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4617 #line 2185 "./parse.y"
4618 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4621 #line 2190 "./parse.y"
4622 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4625 #line 2192 "./parse.y"
4626 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4629 #line 2194 "./parse.y"
4631 yyerror ("Missing term and ']' expected");
4632 DRECOVER(array_access);
4636 #line 2199 "./parse.y"
4638 yyerror ("']' expected");
4639 DRECOVER(array_access);
4643 #line 2204 "./parse.y"
4645 yyerror ("Missing term and ']' expected");
4646 DRECOVER(array_access);
4650 #line 2209 "./parse.y"
4652 yyerror ("']' expected");
4653 DRECOVER(array_access);
4657 #line 2224 "./parse.y"
4658 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4661 #line 2229 "./parse.y"
4662 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4665 #line 2236 "./parse.y"
4666 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4669 #line 2238 "./parse.y"
4670 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4673 #line 2241 "./parse.y"
4674 {yyerror ("Missing term"); RECOVER;
4677 #line 2243 "./parse.y"
4678 {yyerror ("Missing term"); RECOVER;
4681 #line 2248 "./parse.y"
4682 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4685 #line 2250 "./parse.y"
4686 {yyerror ("Missing term"); RECOVER;
4689 #line 2255 "./parse.y"
4690 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4693 #line 2257 "./parse.y"
4694 {yyerror ("Missing term"); RECOVER;
4697 #line 2263 "./parse.y"
4698 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4701 #line 2265 "./parse.y"
4702 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4705 #line 2268 "./parse.y"
4706 {yyerror ("Missing term"); RECOVER;
4709 #line 2270 "./parse.y"
4710 {yyerror ("Missing term"); RECOVER;
4713 #line 2275 "./parse.y"
4715 tree type = yyvsp[-3].node;
4716 while (CURRENT_OSB (ctxp)--)
4717 type = build_java_array_type (type, -1);
4719 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4723 #line 2283 "./parse.y"
4724 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4727 #line 2285 "./parse.y"
4728 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4731 #line 2287 "./parse.y"
4734 while (CURRENT_OSB (ctxp)--)
4735 obstack_1grow (&temporary_obstack, '[');
4737 obstack_grow0 (&temporary_obstack,
4738 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4739 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4740 ptr = obstack_finish (&temporary_obstack);
4741 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4742 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4746 #line 2300 "./parse.y"
4747 {yyerror ("']' expected, invalid type expression");;
4750 #line 2302 "./parse.y"
4752 if (ctxp->prevent_ese != lineno)
4753 yyerror ("Invalid type expression"); RECOVER;
4758 #line 2308 "./parse.y"
4759 {yyerror ("Missing term"); RECOVER;;
4762 #line 2310 "./parse.y"
4763 {yyerror ("Missing term"); RECOVER;;
4766 #line 2312 "./parse.y"
4767 {yyerror ("Missing term"); RECOVER;;
4770 #line 2318 "./parse.y"
4772 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4773 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4777 #line 2323 "./parse.y"
4779 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4780 yyvsp[-2].node, yyvsp[0].node);
4784 #line 2328 "./parse.y"
4786 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4787 yyvsp[-2].node, yyvsp[0].node);
4791 #line 2333 "./parse.y"
4792 {yyerror ("Missing term"); RECOVER;;
4795 #line 2335 "./parse.y"
4796 {yyerror ("Missing term"); RECOVER;;
4799 #line 2337 "./parse.y"
4800 {yyerror ("Missing term"); RECOVER;;
4803 #line 2343 "./parse.y"
4805 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4806 yyvsp[-2].node, yyvsp[0].node);
4810 #line 2348 "./parse.y"
4812 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4813 yyvsp[-2].node, yyvsp[0].node);
4817 #line 2353 "./parse.y"
4818 {yyerror ("Missing term"); RECOVER;;
4821 #line 2355 "./parse.y"
4822 {yyerror ("Missing term"); RECOVER;;
4825 #line 2361 "./parse.y"
4827 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4828 yyvsp[-2].node, yyvsp[0].node);
4832 #line 2366 "./parse.y"
4834 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4835 yyvsp[-2].node, yyvsp[0].node);
4839 #line 2371 "./parse.y"
4841 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4842 yyvsp[-2].node, yyvsp[0].node);
4846 #line 2376 "./parse.y"
4847 {yyerror ("Missing term"); RECOVER;;
4850 #line 2378 "./parse.y"
4851 {yyerror ("Missing term"); RECOVER;;
4854 #line 2380 "./parse.y"
4855 {yyerror ("Missing term"); RECOVER;;
4858 #line 2386 "./parse.y"
4860 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4861 yyvsp[-2].node, yyvsp[0].node);
4865 #line 2391 "./parse.y"
4867 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4868 yyvsp[-2].node, yyvsp[0].node);
4872 #line 2396 "./parse.y"
4874 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4875 yyvsp[-2].node, yyvsp[0].node);
4879 #line 2401 "./parse.y"
4881 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4882 yyvsp[-2].node, yyvsp[0].node);
4886 #line 2406 "./parse.y"
4887 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4890 #line 2408 "./parse.y"
4891 {yyerror ("Missing term"); RECOVER;;
4894 #line 2410 "./parse.y"
4895 {yyerror ("Missing term"); RECOVER;;
4898 #line 2412 "./parse.y"
4899 {yyerror ("Missing term"); RECOVER;;
4902 #line 2414 "./parse.y"
4903 {yyerror ("Missing term"); RECOVER;;
4906 #line 2416 "./parse.y"
4907 {yyerror ("Invalid reference type"); RECOVER;;
4910 #line 2422 "./parse.y"
4912 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4913 yyvsp[-2].node, yyvsp[0].node);
4917 #line 2427 "./parse.y"
4919 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4920 yyvsp[-2].node, yyvsp[0].node);
4924 #line 2432 "./parse.y"
4925 {yyerror ("Missing term"); RECOVER;;
4928 #line 2434 "./parse.y"
4929 {yyerror ("Missing term"); RECOVER;;
4932 #line 2440 "./parse.y"
4934 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4935 yyvsp[-2].node, yyvsp[0].node);
4939 #line 2445 "./parse.y"
4940 {yyerror ("Missing term"); RECOVER;;
4943 #line 2451 "./parse.y"
4945 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4946 yyvsp[-2].node, yyvsp[0].node);
4950 #line 2456 "./parse.y"
4951 {yyerror ("Missing term"); RECOVER;;
4954 #line 2462 "./parse.y"
4956 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4957 yyvsp[-2].node, yyvsp[0].node);
4961 #line 2467 "./parse.y"
4962 {yyerror ("Missing term"); RECOVER;;
4965 #line 2473 "./parse.y"
4967 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4968 yyvsp[-2].node, yyvsp[0].node);
4972 #line 2478 "./parse.y"
4973 {yyerror ("Missing term"); RECOVER;;
4976 #line 2484 "./parse.y"
4978 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4979 yyvsp[-2].node, yyvsp[0].node);
4983 #line 2489 "./parse.y"
4984 {yyerror ("Missing term"); RECOVER;;
4987 #line 2495 "./parse.y"
4989 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4990 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4994 #line 2500 "./parse.y"
4997 yyerror ("Missing term");
5002 #line 2506 "./parse.y"
5003 {yyerror ("Missing term"); DRECOVER (2);;
5006 #line 2508 "./parse.y"
5007 {yyerror ("Missing term"); DRECOVER (3);;
5010 #line 2518 "./parse.y"
5011 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5014 #line 2520 "./parse.y"
5016 if (ctxp->prevent_ese != lineno)
5017 yyerror ("Missing term");
5022 /* the action file gets copied in in place of this dollarsign */
5023 #line 543 "/usr/lib/bison.simple"
5034 short *ssp1 = yyss - 1;
5035 fprintf (stderr, "state stack now");
5036 while (ssp1 != yyssp)
5037 fprintf (stderr, " %d", *++ssp1);
5038 fprintf (stderr, "\n");
5048 yylsp->first_line = yylloc.first_line;
5049 yylsp->first_column = yylloc.first_column;
5050 yylsp->last_line = (yylsp-1)->last_line;
5051 yylsp->last_column = (yylsp-1)->last_column;
5056 yylsp->last_line = (yylsp+yylen-1)->last_line;
5057 yylsp->last_column = (yylsp+yylen-1)->last_column;
5061 /* Now "shift" the result of the reduction.
5062 Determine what state that goes to,
5063 based on the state we popped back to
5064 and the rule number reduced by. */
5068 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5069 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5070 yystate = yytable[yystate];
5072 yystate = yydefgoto[yyn - YYNTBASE];
5076 yyerrlab: /* here on detecting error */
5079 /* If not already recovering from an error, report this error. */
5083 #ifdef YYERROR_VERBOSE
5084 yyn = yypact[yystate];
5086 if (yyn > YYFLAG && yyn < YYLAST)
5093 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5094 for (x = (yyn < 0 ? -yyn : 0);
5095 x < (sizeof(yytname) / sizeof(char *)); x++)
5096 if (yycheck[x + yyn] == x)
5097 size += strlen(yytname[x]) + 15, count++;
5098 msg = (char *) malloc(size + 15);
5101 strcpy(msg, "parse error");
5106 for (x = (yyn < 0 ? -yyn : 0);
5107 x < (sizeof(yytname) / sizeof(char *)); x++)
5108 if (yycheck[x + yyn] == x)
5110 strcat(msg, count == 0 ? ", expecting `" : " or `");
5111 strcat(msg, yytname[x]);
5120 yyerror ("parse error; also virtual memory exceeded");
5123 #endif /* YYERROR_VERBOSE */
5124 yyerror("parse error");
5128 yyerrlab1: /* here on error raised explicitly by an action */
5130 if (yyerrstatus == 3)
5132 /* if just tried and failed to reuse lookahead token after an error, discard it. */
5134 /* return failure if at end of input */
5135 if (yychar == YYEOF)
5140 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5146 /* Else will try to reuse lookahead token
5147 after shifting the error token. */
5149 yyerrstatus = 3; /* Each real token shifted decrements this */
5153 yyerrdefault: /* current state does not do anything special for the error token. */
5156 /* This is wrong; only states that explicitly want error tokens
5157 should shift them. */
5158 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5159 if (yyn) goto yydefault;
5162 yyerrpop: /* pop the current state because it cannot handle the error token */
5164 if (yyssp == yyss) YYABORT;
5174 short *ssp1 = yyss - 1;
5175 fprintf (stderr, "Error: state stack now");
5176 while (ssp1 != yyssp)
5177 fprintf (stderr, " %d", *++ssp1);
5178 fprintf (stderr, "\n");
5184 yyn = yypact[yystate];
5189 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5208 fprintf(stderr, "Shifting error token, ");
5220 /* YYACCEPT comes here. */
5232 /* YYABORT comes here. */
5243 #line 2546 "./parse.y"
5247 /* This section of the code deal with save/restoring parser contexts.
5248 Add mode documentation here. FIXME */
5250 /* Helper function. Create a new parser context. With
5251 COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5252 context is copied, otherwise, the new context is zeroed. The newly
5253 created context becomes the current one. */
5256 create_new_parser_context (copy_from_previous)
5257 int copy_from_previous;
5259 struct parser_ctxt *new;
5261 new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5262 if (copy_from_previous)
5264 memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5265 new->saved_data_ctx = 1;
5268 bzero ((PTR) new, sizeof (struct parser_ctxt));
5274 /* Create a new parser context and make it the current one. */
5277 java_push_parser_context ()
5279 create_new_parser_context (0);
5282 ctxp->incomplete_class = ctxp->next->incomplete_class;
5283 ctxp->gclass_list = ctxp->next->gclass_list;
5288 java_pop_parser_context (generate)
5292 struct parser_ctxt *toFree, *next;
5301 next->incomplete_class = ctxp->incomplete_class;
5302 next->gclass_list = ctxp->gclass_list;
5303 lineno = ctxp->lineno;
5304 finput = ctxp->finput;
5305 current_class = ctxp->current_class;
5308 /* Set the single import class file flag to 0 for the current list
5309 of imported things */
5310 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5311 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5313 /* And restore those of the previous context */
5314 if ((ctxp = next)) /* Assignment is really meant here */
5315 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5316 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5318 /* If we pushed a context to parse a class intended to be generated,
5319 we keep it so we can remember the class. What we could actually
5320 do is to just update a list of class names. */
5323 toFree->next = ctxp_for_generation;
5324 ctxp_for_generation = toFree;
5330 /* Create a parser context for the use of saving some global
5334 java_parser_context_save_global ()
5338 java_push_parser_context ();
5339 ctxp->saved_data_ctx = 1;
5342 /* If this context already stores data, create a new one suitable
5343 for data storage. */
5344 else if (ctxp->saved_data)
5345 create_new_parser_context (1);
5347 ctxp->finput = finput;
5348 ctxp->lineno = lineno;
5349 ctxp->current_class = current_class;
5350 ctxp->filename = input_filename;
5351 ctxp->current_function_decl = current_function_decl;
5352 ctxp->saved_data = 1;
5355 /* Restore some global variables from the previous context. Make the
5356 previous context the current one. */
5359 java_parser_context_restore_global ()
5361 finput = ctxp->finput;
5362 lineno = ctxp->lineno;
5363 current_class = ctxp->current_class;
5364 input_filename = ctxp->filename;
5365 current_function_decl = ctxp->current_function_decl;
5366 ctxp->saved_data = 0;
5367 if (ctxp->saved_data_ctx)
5368 java_pop_parser_context (0);
5371 /* Suspend vital data for the current class/function being parsed so
5372 that an other class can be parsed. Used to let local/anonymous
5373 classes be parsed. */
5376 java_parser_context_suspend ()
5378 /* This makes debugging through java_debug_context easier */
5379 static char *name = "<inner buffer context>";
5381 /* Duplicate the previous context, use it to save the globals we're
5383 create_new_parser_context (1);
5384 ctxp->current_function_decl = current_function_decl;
5385 ctxp->current_class = current_class;
5387 /* Then create a new context which inherits all data from the
5388 previous one. This will be the new current context */
5389 create_new_parser_context (1);
5391 /* Help debugging */
5392 ctxp->next->filename = name;
5395 /* Resume vital data for the current class/function being parsed so
5396 that an other class can be parsed. Used to let local/anonymous
5397 classes be parsed. The trick is the data storing file position
5398 informations must be restored to their current value, so parsing
5399 can resume as if no context was ever saved. */
5402 java_parser_context_resume ()
5404 struct parser_ctxt *old = ctxp; /* This one is to be discarded */
5405 struct parser_ctxt *saver = old->next; /* This one contain saved info */
5406 struct parser_ctxt *restored = saver->next; /* This one is the old current */
5408 /* We need to inherit the list of classes to complete/generate */
5409 restored->incomplete_class = old->incomplete_class;
5410 restored->gclass_list = old->gclass_list;
5411 restored->classd_list = old->classd_list;
5412 restored->class_list = old->class_list;
5414 /* Restore the current class and function from the saver */
5415 current_class = saver->current_class;
5416 current_function_decl = saver->current_function_decl;
5418 /* Retrive the restored context */
5421 /* Re-installed the data for the parsing to carry on */
5422 bcopy (&old->marker_begining, &ctxp->marker_begining,
5423 (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5425 /* Buffer context can now be discarded */
5430 /* Add a new anchor node to which all statement(s) initializing static
5431 and non static initialized upon declaration field(s) will be
5435 java_parser_context_push_initialized_field ()
5439 node = build_tree_list (NULL_TREE, NULL_TREE);
5440 TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5441 CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5443 node = build_tree_list (NULL_TREE, NULL_TREE);
5444 TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5445 CPC_INITIALIZER_LIST (ctxp) = node;
5447 node = build_tree_list (NULL_TREE, NULL_TREE);
5448 TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5449 CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5452 /* Pop the lists of initialized field. If this lists aren't empty,
5453 remember them so we can use it to create and populate the $finit$
5454 or <clinit> functions. */
5457 java_parser_context_pop_initialized_field ()
5460 tree class_type = TREE_TYPE (GET_CPC ());
5462 if (CPC_INITIALIZER_LIST (ctxp))
5464 stmts = CPC_INITIALIZER_STMT (ctxp);
5465 CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5466 if (stmts && !java_error_count)
5467 TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5470 if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5472 stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5473 CPC_STATIC_INITIALIZER_LIST (ctxp) =
5474 TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5475 /* Keep initialization in order to enforce 8.5 */
5476 if (stmts && !java_error_count)
5477 TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5480 /* JDK 1.1 instance initializers */
5481 if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5483 stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5484 CPC_INSTANCE_INITIALIZER_LIST (ctxp) =
5485 TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5486 if (stmts && !java_error_count)
5487 TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5492 reorder_static_initialized (list)
5495 /* We have to keep things in order. The alias initializer have to
5496 come first, then the initialized regular field, in reverse to
5497 keep them in lexical order. */
5498 tree marker, previous = NULL_TREE;
5499 for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5500 if (TREE_CODE (marker) == TREE_LIST
5501 && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5504 /* No static initialized, the list is fine as is */
5506 list = TREE_CHAIN (marker);
5508 /* No marker? reverse the whole list */
5510 list = nreverse (list);
5512 /* Otherwise, reverse what's after the marker and the new reordered
5513 sublist will replace the marker. */
5516 TREE_CHAIN (previous) = NULL_TREE;
5517 list = nreverse (list);
5518 list = chainon (TREE_CHAIN (marker), list);
5523 /* Helper functions to dump the parser context stack. */
5525 #define TAB_CONTEXT(C) \
5526 {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5529 java_debug_context_do (tab)
5532 struct parser_ctxt *copy = ctxp;
5536 fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5538 fprintf (stderr, "filename: %s\n", copy->filename);
5540 fprintf (stderr, "lineno: %d\n", copy->lineno);
5542 fprintf (stderr, "package: %s\n",
5544 IDENTIFIER_POINTER (copy->package) : "<none>"));
5546 fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5548 fprintf (stderr, "saved data: %d\n", copy->saved_data);
5554 /* Dump the stacked up parser contexts. Intended to be called from a
5558 java_debug_context ()
5560 java_debug_context_do (0);
5565 /* Flag for the error report routine to issue the error the first time
5566 it's called (overriding the default behavior which is to drop the
5567 first invocation and honor the second one, taking advantage of a
5569 static int force_error = 0;
5571 /* Reporting an constructor invocation error. */
5573 parse_ctor_invocation_error ()
5575 if (DECL_CONSTRUCTOR_P (current_function_decl))
5576 yyerror ("Constructor invocation must be first thing in a constructor");
5578 yyerror ("Only constructors can invoke constructors");
5581 /* Reporting JDK1.1 features not implemented. */
5584 parse_jdk1_1_error (msg)
5587 sorry (": `%s' JDK1.1(TM) feature", msg);
5589 return empty_stmt_node;
5592 static int do_warning = 0;
5599 static int prev_lineno;
5600 static const char *prev_msg;
5603 char *remainder, *code_from_source;
5604 extern struct obstack temporary_obstack;
5606 if (!force_error && prev_lineno == lineno)
5609 /* Save current error location but report latter, when the context is
5611 if (ctxp->java_error_flag == 0)
5613 ctxp->java_error_flag = 1;
5615 /* Do something to use the previous line if we're reaching the
5616 end of the file... */
5617 #ifdef VERBOSE_SKELETON
5618 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5623 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5624 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5627 ctxp->java_error_flag = 0;
5629 java_warning_count++;
5633 if (elc.col == 0 && msg && msg[1] == ';')
5635 elc.col = ctxp->p_line->char_col-1;
5636 elc.line = ctxp->p_line->lineno;
5639 save_lineno = lineno;
5640 prev_lineno = lineno = elc.line;
5643 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5644 obstack_grow0 (&temporary_obstack,
5645 code_from_source, strlen (code_from_source));
5646 remainder = obstack_finish (&temporary_obstack);
5648 warning ("%s.\n%s", msg, remainder);
5650 error ("%s.\n%s", msg, remainder);
5652 /* This allow us to cheaply avoid an extra 'Invalid expression
5653 statement' error report when errors have been already reported on
5654 the same line. This occurs when we report an error but don't have
5655 a synchronization point other than ';', which
5656 expression_statement is the only one to take care of. */
5657 ctxp->prevent_ese = lineno = save_lineno;
5661 issue_warning_error_from_context (cl, msg, ap)
5666 char *saved, *saved_input_filename;
5668 vsprintf (buffer, msg, ap);
5671 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5672 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5673 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5675 /* We have a CL, that's a good reason for using it if it contains data */
5676 saved = ctxp->filename;
5677 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5678 ctxp->filename = EXPR_WFL_FILENAME (cl);
5679 saved_input_filename = input_filename;
5680 input_filename = ctxp->filename;
5682 java_error (buffer);
5683 ctxp->filename = saved;
5684 input_filename = saved_input_filename;
5688 /* Issue an error message at a current source line CL */
5691 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5693 #ifndef ANSI_PROTOTYPES
5700 #ifndef ANSI_PROTOTYPES
5701 cl = va_arg (ap, tree);
5702 msg = va_arg (ap, const char *);
5704 issue_warning_error_from_context (cl, msg, ap);
5708 /* Issue a warning at a current source line CL */
5711 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5713 #ifndef ANSI_PROTOTYPES
5720 #ifndef ANSI_PROTOTYPES
5721 cl = va_arg (ap, tree);
5722 msg = va_arg (ap, const char *);
5725 force_error = do_warning = 1;
5726 issue_warning_error_from_context (cl, msg, ap);
5727 do_warning = force_error = 0;
5732 find_expr_with_wfl (node)
5740 switch (TREE_CODE (node))
5743 node = BLOCK_EXPR_BODY (node);
5747 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5750 node = TREE_OPERAND (node, 1);
5754 node = TREE_OPERAND (node, 0);
5757 case LABELED_BLOCK_EXPR:
5758 node = TREE_OPERAND (node, 1);
5762 code = TREE_CODE_CLASS (TREE_CODE (node));
5763 if (((code == '1') || (code == '2') || (code == 'e'))
5764 && EXPR_WFL_LINECOL (node))
5772 /* Issue a missing return statement error. Uses METHOD to figure the
5773 last line of the method the error occurs in. */
5776 missing_return_error (method)
5779 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5780 parse_error_context (wfl_operator, "Missing return statement");
5783 /* Issue an unreachable statement error. From NODE, find the next
5784 statement to report appropriately. */
5786 unreachable_stmt_error (node)
5789 /* Browse node to find the next expression node that has a WFL. Use
5790 the location to report the error */
5791 if (TREE_CODE (node) == COMPOUND_EXPR)
5792 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5794 node = find_expr_with_wfl (node);
5798 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5799 parse_error_context (wfl_operator, "Unreachable statement");
5802 fatal ("Can't get valid statement - unreachable_stmt_error");
5806 java_report_errors ()
5808 if (java_error_count)
5809 fprintf (stderr, "%d error%s",
5810 java_error_count, (java_error_count == 1 ? "" : "s"));
5811 if (java_warning_count)
5812 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5813 java_warning_count, (java_warning_count == 1 ? "" : "s"));
5814 if (java_error_count || java_warning_count)
5815 putc ('\n', stderr);
5816 return java_error_count;
5820 java_accstring_lookup (flags)
5823 static char buffer [80];
5824 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5826 /* Access modifier looked-up first for easier report on forbidden
5828 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5829 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5830 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5831 if (flags & ACC_STATIC) COPY_RETURN ("static");
5832 if (flags & ACC_FINAL) COPY_RETURN ("final");
5833 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5834 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5835 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5836 if (flags & ACC_NATIVE) COPY_RETURN ("native");
5837 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5838 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5845 /* Issuing error messages upon redefinition of classes, interfaces or
5849 classitf_redefinition_error (context, id, decl, cl)
5850 const char *context;
5853 parse_error_context (cl, "%s `%s' already defined in %s:%d",
5854 context, IDENTIFIER_POINTER (id),
5855 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5856 /* Here we should point out where its redefined. It's a unicode. FIXME */
5860 variable_redefinition_error (context, name, type, line)
5861 tree context, name, type;
5864 const char *type_name;
5866 /* Figure a proper name for type. We might haven't resolved it */
5867 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5868 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5870 type_name = lang_printable_name (type, 0);
5872 parse_error_context (context,
5873 "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
5874 IDENTIFIER_POINTER (name),
5875 type_name, IDENTIFIER_POINTER (name), line);
5879 build_array_from_name (type, type_wfl, name, ret_name)
5880 tree type, type_wfl, name, *ret_name;
5885 /* Eventually get more dims */
5886 string = IDENTIFIER_POINTER (name);
5887 while (string [more_dims] == '[')
5890 /* If we have, then craft a new type for this variable */
5893 name = get_identifier (&string [more_dims]);
5895 /* If we have a pointer, use its type */
5896 if (TREE_CODE (type) == POINTER_TYPE)
5897 type = TREE_TYPE (type);
5899 /* Building the first dimension of a primitive type uses this
5901 if (JPRIMITIVE_TYPE_P (type))
5903 type = build_java_array_type (type, -1);
5904 CLASS_LOADED_P (type) = 1;
5907 /* Otherwise, if we have a WFL for this type, use it (the type
5908 is already an array on an unresolved type, and we just keep
5909 on adding dimensions) */
5913 /* Add all the dimensions */
5915 type = build_unresolved_array_type (type);
5917 /* The type may have been incomplete in the first place */
5919 type = obtain_incomplete_type (type);
5927 /* Build something that the type identifier resolver will identify as
5928 being an array to an unresolved type. TYPE_WFL is a WFL on a
5932 build_unresolved_array_type (type_or_wfl)
5937 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5938 just create a array type */
5939 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5941 tree type = build_java_array_type (type_or_wfl, -1);
5942 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5946 obstack_1grow (&temporary_obstack, '[');
5947 obstack_grow0 (&temporary_obstack,
5948 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5949 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5950 ptr = obstack_finish (&temporary_obstack);
5951 return build_expr_wfl (get_identifier (ptr),
5952 EXPR_WFL_FILENAME (type_or_wfl),
5953 EXPR_WFL_LINENO (type_or_wfl),
5954 EXPR_WFL_COLNO (type_or_wfl));
5958 parser_add_interface (class_decl, interface_decl, wfl)
5959 tree class_decl, interface_decl, wfl;
5961 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5962 parse_error_context (wfl, "Interface `%s' repeated",
5963 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5966 /* Bulk of common class/interface checks. Return 1 if an error was
5967 encountered. TAG is 0 for a class, 1 for an interface. */
5970 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5971 int is_interface, flags;
5972 tree raw_name, qualified_name, decl, cl;
5975 int sca = 0; /* Static class allowed */
5976 int icaf = 0; /* Inner class allowed flags */
5977 int uaaf = CLASS_MODIFIERS; /* Usually allowed access flags */
5980 fprintf (stderr, " %s%s %s",
5981 (CPC_INNER_P () ? "inner" : ""),
5982 (is_interface ? "interface" : "class"),
5983 IDENTIFIER_POINTER (qualified_name));
5985 /* Scope of an interface/class type name:
5986 - Can't be imported by a single type import
5987 - Can't already exists in the package */
5988 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5989 && (node = find_name_in_single_imports (raw_name)))
5992 (cl, "%s name `%s' clashes with imported type `%s'",
5993 (is_interface ? "Interface" : "Class"),
5994 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5997 if (decl && CLASS_COMPLETE_P (decl))
5999 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
6000 qualified_name, decl, cl);
6004 if (check_inner_class_redefinition (raw_name, cl))
6007 /* If public, file name should match class/interface name, except
6008 when dealing with an inner class */
6009 if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6013 /* Contains OS dependent assumption on path separator. FIXME */
6014 for (f = &input_filename [strlen (input_filename)];
6015 f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6018 if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6020 if (strncmp (IDENTIFIER_POINTER (raw_name),
6021 f , IDENTIFIER_LENGTH (raw_name)) ||
6022 f [IDENTIFIER_LENGTH (raw_name)] != '.')
6024 (cl, "Public %s `%s' must be defined in a file called `%s.java'",
6025 (is_interface ? "interface" : "class"),
6026 IDENTIFIER_POINTER (qualified_name),
6027 IDENTIFIER_POINTER (raw_name));
6030 /* Static classes can be declared only in top level classes. Note:
6031 once static, a inner class is a top level class. */
6032 if (flags & ACC_STATIC)
6034 /* Catch the specific error of declaring an class inner class
6035 with no toplevel enclosing class. Prevent check_modifiers from
6036 complaining a second time */
6037 if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6039 parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
6040 IDENTIFIER_POINTER (qualified_name));
6043 /* Else, in the context of a top-level class declaration, let
6044 `check_modifiers' do its job, otherwise, give it a go */
6046 sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6049 /* Inner classes can be declared private or protected
6050 within their enclosing classes. */
6053 /* A class which is local to a block can't be public, private,
6054 protected or static. But it is created final, so allow this
6056 if (current_function_decl)
6057 icaf = sca = uaaf = ACC_FINAL;
6060 check_modifiers_consistency (flags);
6061 icaf = ACC_PRIVATE|ACC_PROTECTED;
6068 uaaf = INTERFACE_INNER_MODIFIERS;
6070 uaaf = INTERFACE_MODIFIERS;
6072 check_modifiers ("Illegal modifier `%s' for interface declaration",
6076 check_modifiers ((current_function_decl ?
6077 "Illegal modifier `%s' for local class declaration" :
6078 "Illegal modifier `%s' for class declaration"),
6079 flags, uaaf|sca|icaf);
6084 make_nested_class_name (cpc_list)
6092 make_nested_class_name (TREE_CHAIN (cpc_list));
6094 /* Pick the qualified name when dealing with the first upmost
6096 name = (TREE_CHAIN (cpc_list) ?
6097 TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6098 obstack_grow (&temporary_obstack,
6099 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6100 /* Why is NO_DOLLAR_IN_LABEL defined? */
6102 #ifdef NO_DOLLAR_IN_LABEL
6103 fatal ("make_nested_class_name: Can't use '$' as a separator "
6104 "for inner classes");
6107 obstack_1grow (&temporary_obstack, '$');
6110 /* Can't redefine a class already defined in an earlier scope. */
6113 check_inner_class_redefinition (raw_name, cl)
6118 for (scope_list = GET_CPC_LIST (); scope_list;
6119 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6120 if (raw_name == GET_CPC_UN_NODE (scope_list))
6123 (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",
6124 IDENTIFIER_POINTER (raw_name));
6131 find_as_inner_class (enclosing, name, cl)
6132 tree enclosing, name, cl;
6134 tree qual, to_return;
6138 name = TYPE_NAME (name);
6140 /* First search: within the scope of `enclosing', search for name */
6141 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6142 qual = EXPR_WFL_QUALIFICATION (cl);
6144 qual = build_tree_list (cl, NULL_TREE);
6146 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6148 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6151 /* We're dealing with a qualified name. Try to resolve thing until
6152 we get something that is an enclosing class. */
6153 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6155 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6157 for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6158 qual = TREE_CHAIN (qual))
6160 acc = merge_qualified_name (acc,
6161 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6162 BUILD_PTR_FROM_NAME (ptr, acc);
6163 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6166 /* A NULL qual and a decl means that the search ended
6167 successfully?!? We have to do something then. FIXME */
6172 qual = EXPR_WFL_QUALIFICATION (cl);
6174 /* Otherwise, create a qual for the other part of the resolution. */
6176 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6178 return find_as_inner_class_do (qual, enclosing);
6181 /* We go inside the list of sub classes and try to find a way
6185 find_as_inner_class_do (qual, enclosing)
6186 tree qual, enclosing;
6191 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6193 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6194 tree next_enclosing = NULL_TREE;
6197 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6198 inner_list; inner_list = TREE_CHAIN (inner_list))
6200 if (TREE_VALUE (inner_list) == name_to_match)
6202 next_enclosing = TREE_PURPOSE (inner_list);
6206 enclosing = next_enclosing;
6209 return (!qual && enclosing ? enclosing : NULL_TREE);
6212 /* Reach all inner classes and tie their unqualified name to a
6216 set_nested_class_simple_name_value (outer, set)
6222 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6223 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6224 TREE_PURPOSE (l) : NULL_TREE);
6228 link_nested_class_to_enclosing ()
6230 if (GET_ENCLOSING_CPC ())
6232 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6233 DECL_INNER_CLASS_LIST (enclosing) =
6234 tree_cons (GET_CPC (), GET_CPC_UN (),
6235 DECL_INNER_CLASS_LIST (enclosing));
6236 enclosing = enclosing;
6241 maybe_make_nested_class_name (name)
6244 tree id = NULL_TREE;
6248 make_nested_class_name (GET_CPC_LIST ());
6249 obstack_grow0 (&temporary_obstack,
6250 IDENTIFIER_POINTER (name),
6251 IDENTIFIER_LENGTH (name));
6252 id = get_identifier (obstack_finish (&temporary_obstack));
6254 QUALIFIED_P (id) = 1;
6259 /* If DECL is NULL, create and push a new DECL, record the current
6260 line CL and do other maintenance things. */
6263 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6264 tree decl, raw_name, qualified_name, cl;
6267 decl = push_class (make_class (), qualified_name);
6269 /* Take care of the file and line business */
6270 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6271 /* If we're emiting xrefs, store the line/col number information */
6273 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6275 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6276 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6277 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6278 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6280 PUSH_CPC (decl, raw_name);
6281 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6283 /* Link the declaration to the already seen ones */
6284 TREE_CHAIN (decl) = ctxp->class_list;
6285 ctxp->class_list = decl;
6287 /* Create a new nodes in the global lists */
6288 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6289 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6291 /* Install a new dependency list element */
6292 create_jdep_list (ctxp);
6294 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6295 IDENTIFIER_POINTER (qualified_name)));
6300 add_superinterfaces (decl, interface_list)
6301 tree decl, interface_list;
6304 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6305 takes care of ensuring that:
6306 - This is an accessible interface type,
6307 - Circularity detection.
6308 parser_add_interface is then called. If present but not defined,
6309 the check operation is delayed until the super interface gets
6311 for (node = interface_list; node; node = TREE_CHAIN (node))
6313 tree current = TREE_PURPOSE (node);
6314 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6315 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6317 if (!parser_check_super_interface (idecl, decl, current))
6318 parser_add_interface (decl, idecl, current);
6321 register_incomplete_type (JDEP_INTERFACE,
6322 current, decl, NULL_TREE);
6326 /* Create an interface in pass1 and return its decl. Return the
6327 interface's decl in pass 2. */
6330 create_interface (flags, id, super)
6334 tree raw_name = EXPR_WFL_NODE (id);
6335 tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6336 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6338 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6340 /* Basic checks: scope, redefinition, modifiers */
6341 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6347 /* Suspend the current parsing context if we're parsing an inner
6350 java_parser_context_suspend ();
6352 /* Push a new context for (static) initialized upon declaration fields */
6353 java_parser_context_push_initialized_field ();
6355 /* Interface modifiers check
6356 - public/abstract allowed (already done at that point)
6357 - abstract is obsolete (comes first, it's a warning, or should be)
6358 - Can't use twice the same (checked in the modifier rule) */
6359 if ((flags & ACC_ABSTRACT) && flag_redundant)
6360 parse_warning_context
6361 (MODIFIER_WFL (ABSTRACT_TK),
6362 "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6364 /* Create a new decl if DECL is NULL, otherwise fix it */
6365 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6367 /* Set super info and mark the class a complete */
6368 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6369 object_type_node, ctxp->interface_number);
6370 ctxp->interface_number = 0;
6371 CLASS_COMPLETE_P (decl) = 1;
6372 add_superinterfaces (decl, super);
6377 /* Anonymous class counter. Will be reset to 1 every time a non
6378 anonymous class gets created. */
6379 static int anonymous_class_counter = 1;
6381 /* Patch anonymous class CLASS, by either extending or implementing
6385 patch_anonymous_class (type_decl, class_decl, wfl)
6386 tree type_decl, class_decl, wfl;
6388 tree class = TREE_TYPE (class_decl);
6389 tree type = TREE_TYPE (type_decl);
6390 tree binfo = TYPE_BINFO (class);
6392 /* If it's an interface, implement it */
6393 if (CLASS_INTERFACE (type_decl))
6398 if (parser_check_super_interface (type_decl, class_decl, wfl))
6401 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6402 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6403 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6404 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6405 /* And add the interface */
6406 parser_add_interface (class_decl, type_decl, wfl);
6408 /* Otherwise, it's a type we want to extend */
6411 if (parser_check_super (type_decl, class_decl, wfl))
6413 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6418 create_anonymous_class (location, type_name)
6423 tree super = NULL_TREE, itf = NULL_TREE;
6424 tree id, type_decl, class;
6426 /* The unqualified name of the anonymous class. It's just a number. */
6427 sprintf (buffer, "%d", anonymous_class_counter++);
6428 id = build_wfl_node (get_identifier (buffer));
6429 EXPR_WFL_LINECOL (id) = location;
6431 /* We know about the type to extend/implement. We go ahead */
6432 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6434 /* Create a class which either implements on extends the designated
6435 class. The class bears an innacessible name. */
6436 if (CLASS_INTERFACE (type_decl))
6438 /* It's OK to modify it here. It's been already used and
6439 shouldn't be reused */
6440 ctxp->interface_number = 1;
6441 /* Interfaces should presented as a list of WFLs */
6442 itf = build_tree_list (type_name, NULL_TREE);
6448 class = create_class (ACC_FINAL, id, super, itf);
6450 /* We didn't know anything about the stuff. We register a dependence. */
6452 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6454 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6458 /* Create a class in pass1 and return its decl. Return class
6459 interface's decl in pass 2. */
6462 create_class (flags, id, super, interfaces)
6464 tree id, super, interfaces;
6466 tree raw_name = EXPR_WFL_NODE (id);
6467 tree class_id, decl;
6468 tree super_decl_type;
6470 class_id = parser_qualified_classname (0, raw_name);
6471 decl = IDENTIFIER_CLASS_VALUE (class_id);
6472 EXPR_WFL_NODE (id) = class_id;
6474 /* Basic check: scope, redefinition, modifiers */
6475 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6481 /* Suspend the current parsing context if we're parsing an inner
6482 class or an anonymous class. */
6484 java_parser_context_suspend ();
6485 /* Push a new context for (static) initialized upon declaration fields */
6486 java_parser_context_push_initialized_field ();
6488 /* Class modifier check:
6489 - Allowed modifier (already done at that point)
6490 - abstract AND final forbidden
6491 - Public classes defined in the correct file */
6492 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6494 (id, "Class `%s' can't be declared both abstract and final",
6495 IDENTIFIER_POINTER (raw_name));
6497 /* Create a new decl if DECL is NULL, otherwise fix it */
6498 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6500 /* If SUPER exists, use it, otherwise use Object */
6503 /* Can't extend java.lang.Object */
6504 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6506 parse_error_context (id, "Can't extend `java.lang.Object'");
6511 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6513 else if (TREE_TYPE (decl) != object_type_node)
6514 super_decl_type = object_type_node;
6515 /* We're defining java.lang.Object */
6517 super_decl_type = NULL_TREE;
6519 /* Set super info and mark the class a complete */
6520 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6521 ctxp->interface_number);
6522 ctxp->interface_number = 0;
6523 CLASS_COMPLETE_P (decl) = 1;
6524 add_superinterfaces (decl, interfaces);
6526 /* If the class is a top level inner class, install an alias. */
6527 if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6529 tree alias = parser_qualified_classname (1, raw_name);
6530 IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6533 /* Add the private this$<n> field, Replicate final locals still in
6534 scope as private final fields mangled like val$<local_name>.
6535 This doesn't not occur for top level (static) inner classes. */
6536 if (PURE_INNER_CLASS_DECL_P (decl))
6537 add_inner_class_fields (decl, current_function_decl);
6539 /* If doing xref, store the location at which the inherited class
6540 (if any) was seen. */
6541 if (flag_emit_xref && super)
6542 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6544 /* Eventually sets the @deprecated tag flag */
6545 CHECK_DEPRECATED (decl);
6547 /* Reset the anonymous class counter when declaring non inner classes */
6548 if (!INNER_CLASS_DECL_P (decl))
6549 anonymous_class_counter = 1;
6554 /* End a class declaration: register the statements used to create
6555 $finit$ and <clinit>, pop the current class and resume the prior
6556 parser context if necessary. */
6559 end_class_declaration (resume)
6562 /* If an error occured, context weren't pushed and won't need to be
6563 popped by a resume. */
6564 int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6566 java_parser_context_pop_initialized_field ();
6568 if (resume && no_error_occured)
6569 java_parser_context_resume ();
6573 add_inner_class_fields (class_decl, fct_decl)
6577 tree block, marker, f;
6579 f = add_field (TREE_TYPE (class_decl),
6580 build_current_thisn (TREE_TYPE (class_decl)),
6581 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
6583 FIELD_THISN (f) = 1;
6588 for (block = GET_CURRENT_BLOCK (fct_decl);
6589 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6592 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6595 tree wfl, init, list;
6597 /* Avoid non final arguments. */
6598 if (!LOCAL_FINAL (decl))
6601 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6602 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6603 wfl = build_wfl_node (get_identifier (name));
6604 init = build_wfl_node (get_identifier (pname));
6605 /* Build an initialization for the field: it will be
6606 initialized by a parameter added to $finit$, bearing a
6607 mangled name of the field itself (param$<n>.) The
6608 parameter is provided to $finit$ by the constructor
6609 invoking it (hence the constructor will also feature a
6610 hidden parameter, set to the value of the outer context
6611 local at the time the inner class is created.)
6613 Note: we take into account all possible locals that can
6614 be accessed by the inner class. It's actually not trivial
6615 to minimize these aliases down to the ones really
6616 used. One way to do that would be to expand all regular
6617 methods first, then $finit$ to get a picture of what's
6618 used. It works with the exception that we would have to
6619 go back on all constructor invoked in regular methods to
6620 have their invokation reworked (to include the right amount
6621 of alias initializer parameters.)
6623 The only real way around, I think, is a first pass to
6624 identify locals really used in the inner class. We leave
6625 the flag FIELD_LOCAL_ALIAS_USED around for that future
6628 On the other hand, it only affect local inner classes,
6629 whose constructors (and $finit$ call) will be featuring
6630 unecessary arguments. It's easy for a developper to keep
6631 this number of parameter down by using the `final'
6632 keyword only when necessary. For the time being, we can
6633 issue a warning on unecessary finals. FIXME */
6634 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
6637 /* Register the field. The TREE_LIST holding the part
6638 initialized/initializer will be marked ARG_FINAL_P so
6639 that the created field can be marked
6640 FIELD_LOCAL_ALIAS. */
6641 list = build_tree_list (wfl, init);
6642 ARG_FINAL_P (list) = 1;
6643 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6647 if (!CPC_INITIALIZER_STMT (ctxp))
6650 /* If we ever registered an alias field, insert and marker to
6651 remeber where the list ends. The second part of the list (the one
6652 featuring initialized fields) so it can be later reversed to
6653 enforce 8.5. The marker will be removed during that operation. */
6654 marker = build_tree_list (NULL_TREE, NULL_TREE);
6655 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6656 SET_CPC_INITIALIZER_STMT (ctxp, marker);
6659 /* Can't use lookup_field () since we don't want to load the class and
6660 can't set the CLASS_LOADED_P flag */
6663 find_field (class, name)
6668 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6670 if (DECL_NAME (decl) == name)
6676 /* Wrap around lookup_field that doesn't potentially upset the value
6680 lookup_field_wrapper (class, name)
6685 java_parser_context_save_global ();
6686 decl = lookup_field (&type, name);
6688 /* Last chance: if we're within the context of an inner class, we
6689 might be trying to access a local variable defined in an outer
6690 context. We try to look for it now. */
6691 if (INNER_CLASS_TYPE_P (class) && (!decl || decl == error_mark_node))
6694 MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
6695 name = get_identifier (alias_buffer);
6697 decl = lookup_field (&type, name);
6698 if (decl && decl != error_mark_node)
6699 FIELD_LOCAL_ALIAS_USED (decl) = 1;
6702 java_parser_context_restore_global ();
6703 return decl == error_mark_node ? NULL : decl;
6706 /* Find duplicate field within the same class declarations and report
6707 the error. Returns 1 if a duplicated field was found, 0
6711 duplicate_declaration_error_p (new_field_name, new_type, cl)
6712 tree new_field_name, new_type, cl;
6714 /* This might be modified to work with method decl as well */
6715 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6718 char *t1 = xstrdup (purify_type_name
6719 ((TREE_CODE (new_type) == POINTER_TYPE
6720 && TREE_TYPE (new_type) == NULL_TREE) ?
6721 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6722 lang_printable_name (new_type, 1)));
6723 /* The type may not have been completed by the time we report
6725 char *t2 = xstrdup (purify_type_name
6726 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
6727 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6728 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6729 lang_printable_name (TREE_TYPE (decl), 1)));
6731 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
6732 t1, IDENTIFIER_POINTER (new_field_name),
6733 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6734 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6742 /* Field registration routine. If TYPE doesn't exist, field
6743 declarations are linked to the undefined TYPE dependency list, to
6744 be later resolved in java_complete_class () */
6747 register_fields (flags, type, variable_list)
6749 tree type, variable_list;
6751 tree current, saved_type;
6752 tree class_type = NULL_TREE;
6753 int saved_lineno = lineno;
6755 tree wfl = NULL_TREE;
6758 class_type = TREE_TYPE (GET_CPC ());
6760 if (!class_type || class_type == error_mark_node)
6763 /* If we're adding fields to interfaces, those fields are public,
6765 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6767 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6768 flags, ACC_PUBLIC, "interface field(s)");
6769 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6770 flags, ACC_STATIC, "interface field(s)");
6771 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6772 flags, ACC_FINAL, "interface field(s)");
6773 check_modifiers ("Illegal interface member modifier `%s'", flags,
6774 INTERFACE_FIELD_MODIFIERS);
6775 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6778 /* Obtain a suitable type for resolution, if necessary */
6779 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6781 /* If TYPE is fully resolved and we don't have a reference, make one */
6782 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6784 for (current = variable_list, saved_type = type; current;
6785 current = TREE_CHAIN (current), type = saved_type)
6789 tree cl = TREE_PURPOSE (current);
6790 tree init = TREE_VALUE (current);
6791 tree current_name = EXPR_WFL_NODE (cl);
6793 /* Can't declare static fields in inner classes */
6794 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6795 && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6797 (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6798 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6799 lang_printable_name (class_type, 0));
6801 /* Process NAME, as it may specify extra dimension(s) for it */
6802 type = build_array_from_name (type, wfl, current_name, ¤t_name);
6804 /* Type adjustment. We may have just readjusted TYPE because
6805 the variable specified more dimensions. Make sure we have
6806 a reference if we can and don't have one already. Also
6807 change the name if we have an init. */
6808 if (type != saved_type)
6810 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6812 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6815 real_type = GET_REAL_TYPE (type);
6816 /* Check for redeclarations */
6817 if (duplicate_declaration_error_p (current_name, real_type, cl))
6820 /* Set lineno to the line the field was found and create a
6821 declaration for it. Eventually sets the @deprecated tag flag. */
6823 lineno = EXPR_WFL_LINECOL (cl);
6825 lineno = EXPR_WFL_LINENO (cl);
6826 field_decl = add_field (class_type, current_name, real_type, flags);
6827 CHECK_DEPRECATED (field_decl);
6829 /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6830 mark the created field FIELD_LOCAL_ALIAS, so that we can
6831 hide parameters to this inner class $finit$ and constructors. */
6832 if (ARG_FINAL_P (current))
6833 FIELD_LOCAL_ALIAS (field_decl) = 1;
6835 /* Check if we must chain. */
6837 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6839 /* If we have an initialization value tied to the field */
6842 /* The field is declared static */
6843 if (flags & ACC_STATIC)
6845 /* We include the field and its initialization part into
6846 a list used to generate <clinit>. After <clinit> is
6847 walked, field initializations will be processed and
6848 fields initialized with known constants will be taken
6849 out of <clinit> and have their DECL_INITIAL set
6851 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6852 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6853 if (TREE_OPERAND (init, 1)
6854 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6855 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6857 /* A non-static field declared with an immediate initialization is
6858 to be initialized in <init>, if any. This field is remembered
6859 to be processed at the time of the generation of <init>. */
6862 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6863 SET_CPC_INITIALIZER_STMT (ctxp, init);
6865 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6866 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6869 lineno = saved_lineno;
6872 /* Generate $finit$, using the list of initialized fields to populate
6873 its body. $finit$'s parameter(s) list is adjusted to include the
6874 one(s) used to initialized the field(s) caching outer context
6878 generate_finit (class_type)
6882 tree list = TYPE_FINIT_STMT_LIST (class_type);
6883 tree mdecl, current, parms;
6885 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
6886 class_type, NULL_TREE,
6888 CRAFTED_PARAM_LIST_FIXUP (parms);
6889 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6890 finit_identifier_node, parms);
6891 fix_method_argument_names (parms, mdecl);
6892 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6894 DECL_FUNCTION_NAP (mdecl) = count;
6895 start_artificial_method_body (mdecl);
6897 for (current = list; current; current = TREE_CHAIN (current))
6898 java_method_add_stmt (mdecl,
6899 build_debugable_stmt (EXPR_WFL_LINECOL (current),
6901 end_artificial_method_body (mdecl);
6906 add_instance_initializer (mdecl)
6910 tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6911 tree compound = NULL_TREE;
6915 for (current = stmt_list; current; current = TREE_CHAIN (current))
6916 compound = add_stmt_to_compound (compound, NULL_TREE, current);
6918 java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6919 NULL_TREE, compound));
6923 /* Shared accros method_declarator and method_header to remember the
6924 patch stage that was reached during the declaration of the method.
6925 A method DECL is built differently is there is no patch
6926 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6927 pending on the currently defined method. */
6929 static int patch_stage;
6931 /* Check the method declaration and add the method to its current
6932 class. If the argument list is known to contain incomplete types,
6933 the method is partially added and the registration will be resume
6934 once the method arguments resolved. If TYPE is NULL, we're dealing
6935 with a constructor. */
6938 method_header (flags, type, mdecl, throws)
6940 tree type, mdecl, throws;
6942 tree meth = TREE_VALUE (mdecl);
6943 tree id = TREE_PURPOSE (mdecl);
6944 tree type_wfl = NULL_TREE;
6945 tree meth_name = NULL_TREE;
6946 tree current, orig_arg, this_class = NULL;
6948 int constructor_ok = 0, must_chain;
6951 check_modifiers_consistency (flags);
6954 this_class = TREE_TYPE (GET_CPC ());
6956 if (!this_class || this_class == error_mark_node)
6959 /* There are some forbidden modifiers for an abstract method and its
6960 class must be abstract as well. */
6961 if (type && (flags & ACC_ABSTRACT))
6963 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6964 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6965 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6966 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6967 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6968 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6969 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6971 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
6972 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6973 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6976 /* Things to be checked when declaring a constructor */
6979 int ec = java_error_count;
6980 /* 8.6: Constructor declarations: we might be trying to define a
6981 method without specifying a return type. */
6982 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6984 (id, "Invalid method declaration, return type required");
6985 /* 8.6.3: Constructor modifiers */
6988 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6989 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
6990 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
6991 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
6992 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
6994 /* If we found error here, we don't consider it's OK to tread
6995 the method definition as a constructor, for the rest of this
6997 if (ec == java_error_count)
7001 /* Method declared within the scope of an interface are implicitly
7002 abstract and public. Conflicts with other erroneously provided
7003 modifiers are checked right after. */
7005 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7007 /* If FLAGS isn't set because of a modifier, turn the
7008 corresponding modifier WFL to NULL so we issue a warning on
7009 the obsolete use of the modifier */
7010 if (!(flags & ACC_PUBLIC))
7011 MODIFIER_WFL (PUBLIC_TK) = NULL;
7012 if (!(flags & ACC_ABSTRACT))
7013 MODIFIER_WFL (ABSTRACT_TK) = NULL;
7014 flags |= ACC_PUBLIC;
7015 flags |= ACC_ABSTRACT;
7018 /* Inner class can't declare static methods */
7019 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7022 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7023 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7024 lang_printable_name (this_class, 0));
7027 /* Modifiers context reset moved up, so abstract method declaration
7028 modifiers can be later checked. */
7030 /* Set constructor returned type to void and method name to <init>,
7031 unless we found an error identifier the constructor (in which
7032 case we retain the original name) */
7035 type = void_type_node;
7037 meth_name = init_identifier_node;
7040 meth_name = EXPR_WFL_NODE (id);
7042 /* Do the returned type resolution and registration if necessary */
7043 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7046 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7047 EXPR_WFL_NODE (id) = meth_name;
7048 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7052 patch_stage = JDEP_METHOD_RETURN;
7053 register_incomplete_type (patch_stage, type_wfl, id, type);
7054 TREE_TYPE (meth) = GET_REAL_TYPE (type);
7057 TREE_TYPE (meth) = type;
7059 saved_lineno = lineno;
7060 /* When defining an abstract or interface method, the curly
7061 bracket at level 1 doesn't exist because there is no function
7063 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
7064 EXPR_WFL_LINENO (id));
7066 /* Remember the original argument list */
7067 orig_arg = TYPE_ARG_TYPES (meth);
7069 if (patch_stage) /* includes ret type and/or all args */
7072 meth = add_method_1 (this_class, flags, meth_name, meth);
7073 /* Patch for the return type */
7074 if (patch_stage == JDEP_METHOD_RETURN)
7076 jdep = CLASSD_LAST (ctxp->classd_list);
7077 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7079 /* This is the stop JDEP. METH allows the function's signature
7081 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7084 meth = add_method (this_class, flags, meth_name,
7085 build_java_signature (meth));
7087 /* Remember final parameters */
7088 MARK_FINAL_PARMS (meth, orig_arg);
7090 /* Fix the method argument list so we have the argument name
7092 fix_method_argument_names (orig_arg, meth);
7094 /* Register the parameter number and re-install the current line
7096 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7097 lineno = saved_lineno;
7099 /* Register exception specified by the `throws' keyword for
7100 resolution and set the method decl appropriate field to the list.
7101 Note: the grammar ensures that what we get here are class
7105 throws = nreverse (throws);
7106 for (current = throws; current; current = TREE_CHAIN (current))
7108 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7109 NULL_TREE, NULL_TREE);
7110 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7111 &TREE_VALUE (current);
7113 DECL_FUNCTION_THROWS (meth) = throws;
7116 /* We set the DECL_NAME to ID so we can track the location where
7117 the function was declared. This allow us to report
7118 redefinition error accurately. When method are verified,
7119 DECL_NAME is reinstalled properly (using the content of the
7120 WFL node ID) (see check_method_redefinition). We don't do that
7121 when Object is being defined. Constructor <init> names will be
7122 reinstalled the same way. */
7123 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7124 DECL_NAME (meth) = id;
7126 /* Set the flag if we correctly processed a constructor */
7129 DECL_CONSTRUCTOR_P (meth) = 1;
7130 /* Compute and store the number of artificial parameters declared
7131 for this constructor */
7132 for (count = 0, current = TYPE_FIELDS (this_class); current;
7133 current = TREE_CHAIN (current))
7134 if (FIELD_LOCAL_ALIAS (current))
7136 DECL_FUNCTION_NAP (meth) = count;
7139 /* Eventually set the @deprecated tag flag */
7140 CHECK_DEPRECATED (meth);
7142 /* If doing xref, store column and line number information instead
7143 of the line number only. */
7145 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7151 fix_method_argument_names (orig_arg, meth)
7152 tree orig_arg, meth;
7154 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7155 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7157 TREE_PURPOSE (arg) = this_identifier_node;
7158 arg = TREE_CHAIN (arg);
7160 while (orig_arg != end_params_node)
7162 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7163 orig_arg = TREE_CHAIN (orig_arg);
7164 arg = TREE_CHAIN (arg);
7168 /* Complete the method declaration with METHOD_BODY. */
7171 finish_method_declaration (method_body)
7176 if (!current_function_decl)
7179 flags = get_access_flags_from_decl (current_function_decl);
7181 /* 8.4.5 Method Body */
7182 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7184 tree wfl = DECL_NAME (current_function_decl);
7185 parse_error_context (wfl,
7186 "%s method `%s' can't have a body defined",
7187 (METHOD_NATIVE (current_function_decl) ?
7188 "Native" : "Abstract"),
7189 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7190 method_body = NULL_TREE;
7192 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7194 tree wfl = DECL_NAME (current_function_decl);
7197 "Non native and non abstract method `%s' must have a body defined",
7198 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7199 method_body = NULL_TREE;
7202 if (flag_emit_class_files && method_body
7203 && TREE_CODE (method_body) == NOP_EXPR
7204 && TREE_TYPE (current_function_decl)
7205 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7206 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7208 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7209 maybe_absorb_scoping_blocks ();
7210 /* Exit function's body */
7212 /* Merge last line of the function with first line, directly in the
7213 function decl. It will be used to emit correct debug info. */
7214 if (!flag_emit_xref)
7215 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7217 /* Since function's argument's list are shared, reset the
7218 ARG_FINAL_P parameter that might have been set on some of this
7219 function parameters. */
7220 UNMARK_FINAL_PARMS (current_function_decl);
7222 /* So we don't have an irrelevant function declaration context for
7223 the next static block we'll see. */
7224 current_function_decl = NULL_TREE;
7227 /* Build a an error message for constructor circularity errors. */
7230 constructor_circularity_msg (from, to)
7233 static char string [4096];
7234 char *t = xstrdup (lang_printable_name (from, 0));
7235 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7240 /* Verify a circular call to METH. Return 1 if an error is found, 0
7244 verify_constructor_circularity (meth, current)
7247 static tree list = NULL_TREE;
7249 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7251 if (TREE_VALUE (c) == meth)
7257 list = nreverse (list);
7258 for (liste = list; liste; liste = TREE_CHAIN (liste))
7261 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7262 constructor_circularity_msg
7263 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7267 t = xstrdup (lang_printable_name (meth, 0));
7268 parse_error_context (TREE_PURPOSE (c),
7269 "%s: recursive invocation of constructor `%s'",
7270 constructor_circularity_msg (current, meth), t);
7276 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7278 list = tree_cons (c, current, list);
7279 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7281 list = TREE_CHAIN (list);
7286 /* Check modifiers that can be declared but exclusively */
7289 check_modifiers_consistency (flags)
7293 tree cl = NULL_TREE;
7295 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7296 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7297 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7300 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7304 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7306 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7309 parse_error_context (cl,
7310 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7313 /* Check the methode header METH for abstract specifics features */
7316 check_abstract_method_header (meth)
7319 int flags = get_access_flags_from_decl (meth);
7320 /* DECL_NAME might still be a WFL node */
7321 tree name = GET_METHOD_NAME (meth);
7323 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7324 ACC_ABSTRACT, "abstract method",
7325 IDENTIFIER_POINTER (name));
7326 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7327 ACC_PUBLIC, "abstract method",
7328 IDENTIFIER_POINTER (name));
7330 check_modifiers ("Illegal modifier `%s' for interface method",
7331 flags, INTERFACE_METHOD_MODIFIERS);
7334 /* Create a FUNCTION_TYPE node and start augmenting it with the
7335 declared function arguments. Arguments type that can't be resolved
7336 are left as they are, but the returned node is marked as containing
7337 incomplete types. */
7340 method_declarator (id, list)
7343 tree arg_types = NULL_TREE, current, node;
7344 tree meth = make_node (FUNCTION_TYPE);
7347 patch_stage = JDEP_NO_PATCH;
7349 /* If we're dealing with an inner class constructor, we hide the
7350 this$<n> decl in the name field of its parameter declaration. We
7351 also might have to hide the outer context local alias
7352 initializers. Not done when the class is a toplevel class. */
7353 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7354 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7356 tree aliases_list, type, thisn;
7357 /* First the aliases, linked to the regular parameters */
7359 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7360 TREE_TYPE (GET_CPC ()),
7362 list = chainon (nreverse (aliases_list), list);
7365 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7366 thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7367 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7371 for (current = list; current; current = TREE_CHAIN (current))
7374 tree wfl_name = TREE_PURPOSE (current);
7375 tree type = TREE_VALUE (current);
7376 tree name = EXPR_WFL_NODE (wfl_name);
7377 tree already, arg_node;
7378 tree type_wfl = NULL_TREE;
7381 /* Obtain a suitable type for resolution, if necessary */
7382 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7384 /* Process NAME, as it may specify extra dimension(s) for it */
7385 type = build_array_from_name (type, type_wfl, name, &name);
7386 EXPR_WFL_NODE (wfl_name) = name;
7388 real_type = GET_REAL_TYPE (type);
7389 if (TREE_CODE (real_type) == RECORD_TYPE)
7391 real_type = promote_type (real_type);
7392 if (TREE_CODE (type) == TREE_LIST)
7393 TREE_PURPOSE (type) = real_type;
7396 /* Check redefinition */
7397 for (already = arg_types; already; already = TREE_CHAIN (already))
7398 if (TREE_PURPOSE (already) == name)
7401 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7402 IDENTIFIER_POINTER (name),
7403 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7407 /* If we've an incomplete argument type, we know there is a location
7408 to patch when the type get resolved, later. */
7412 patch_stage = JDEP_METHOD;
7413 type = register_incomplete_type (patch_stage,
7414 type_wfl, wfl_name, type);
7415 jdep = CLASSD_LAST (ctxp->classd_list);
7416 JDEP_MISC (jdep) = id;
7419 /* The argument node: a name and a (possibly) incomplete type. */
7420 arg_node = build_tree_list (name, real_type);
7421 /* Remeber arguments declared final. */
7422 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7425 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7426 TREE_CHAIN (arg_node) = arg_types;
7427 arg_types = arg_node;
7429 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7430 node = build_tree_list (id, meth);
7435 unresolved_type_p (wfl, returned)
7440 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7444 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7445 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7446 *returned = TREE_TYPE (decl);
7447 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7448 *returned = TREE_TYPE (GET_CPC ());
7450 *returned = NULL_TREE;
7459 /* From NAME, build a qualified identifier node using the
7460 qualification from the current package definition. */
7463 parser_qualified_classname (is_static, name)
7467 tree nested_class_name;
7470 && (nested_class_name = maybe_make_nested_class_name (name)))
7471 return nested_class_name;
7474 return merge_qualified_name (ctxp->package, name);
7479 /* Called once the type a interface extends is resolved. Returns 0 if
7480 everything is OK. */
7483 parser_check_super_interface (super_decl, this_decl, this_wfl)
7484 tree super_decl, this_decl, this_wfl;
7486 tree super_type = TREE_TYPE (super_decl);
7488 /* Has to be an interface */
7489 if (!CLASS_INTERFACE (super_decl))
7492 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7493 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7494 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7495 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7496 "interface" : "class"),
7497 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7501 /* Check scope: same package OK, other package: OK if public */
7502 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7505 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7506 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7507 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7511 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7512 0 if everthing is OK. */
7515 parser_check_super (super_decl, this_decl, wfl)
7516 tree super_decl, this_decl, wfl;
7518 tree super_type = TREE_TYPE (super_decl);
7520 /* SUPER should be a CLASS (neither an array nor an interface) */
7521 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7524 (wfl, "Class `%s' can't subclass %s `%s'",
7525 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7526 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7527 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7531 if (CLASS_FINAL (TYPE_NAME (super_type)))
7533 parse_error_context (wfl, "Can't subclass final classes: %s",
7534 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7538 /* Check scope: same package OK, other package: OK if public */
7539 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7542 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7543 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7544 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7548 /* Create a new dependency list and link it (in a LIFO manner) to the
7549 CTXP list of type dependency list. */
7552 create_jdep_list (ctxp)
7553 struct parser_ctxt *ctxp;
7555 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
7556 new->first = new->last = NULL;
7557 new->next = ctxp->classd_list;
7558 ctxp->classd_list = new;
7562 reverse_jdep_list (ctxp)
7563 struct parser_ctxt *ctxp;
7565 register jdeplist *prev = NULL, *current, *next;
7566 for (current = ctxp->classd_list; current; current = next)
7568 next = current->next;
7569 current->next = prev;
7575 /* Create a fake pointer based on the ID stored in
7576 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7577 registered again. */
7580 obtain_incomplete_type (type_name)
7585 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7586 name = EXPR_WFL_NODE (type_name);
7587 else if (INCOMPLETE_TYPE_P (type_name))
7588 name = TYPE_NAME (type_name);
7590 fatal ("invalid type name - obtain_incomplete_type");
7592 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7593 if (TYPE_NAME (ptr) == name)
7598 push_obstacks (&permanent_obstack, &permanent_obstack);
7599 BUILD_PTR_FROM_NAME (ptr, name);
7602 TREE_CHAIN (ptr) = ctxp->incomplete_class;
7603 ctxp->incomplete_class = ptr;
7609 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7610 non NULL instead of computing a new fake type based on WFL. The new
7611 dependency is inserted in the current type dependency list, in FIFO
7615 register_incomplete_type (kind, wfl, decl, ptr)
7617 tree wfl, decl, ptr;
7619 jdep *new = (jdep *)xmalloc (sizeof (jdep));
7621 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7622 ptr = obtain_incomplete_type (wfl);
7624 JDEP_KIND (new) = kind;
7625 JDEP_DECL (new) = decl;
7626 JDEP_SOLV (new) = ptr;
7627 JDEP_WFL (new) = wfl;
7628 JDEP_CHAIN (new) = NULL;
7629 JDEP_MISC (new) = NULL_TREE;
7630 if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
7631 && GET_ENCLOSING_CPC ())
7632 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7634 JDEP_ENCLOSING (new) = GET_CPC ();
7635 JDEP_GET_PATCH (new) = (tree *)NULL;
7637 JDEP_INSERT (ctxp->classd_list, new);
7643 java_check_circular_reference ()
7646 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7648 tree type = TREE_TYPE (current);
7649 if (CLASS_INTERFACE (current))
7651 /* Check all interfaces this class extends */
7652 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7657 n = TREE_VEC_LENGTH (basetype_vec);
7658 for (i = 0; i < n; i++)
7660 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7661 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
7662 && interface_of_p (type, BINFO_TYPE (vec_elt)))
7663 parse_error_context (lookup_cl (current),
7664 "Cyclic interface inheritance");
7668 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7669 parse_error_context (lookup_cl (current),
7670 "Cyclic class inheritance%s",
7671 (cyclic_inheritance_report ?
7672 cyclic_inheritance_report : ""));
7676 /* Augment the parameter list PARM with parameters crafted to
7677 initialize outer context locals aliases. Through ARTIFICIAL, a
7678 count is kept of the number of crafted parameters. MODE governs
7679 what eventually gets created: something suitable for a function
7680 creation or a function invocation, either the constructor or
7684 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7686 tree class_type, parm;
7690 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7691 if (FIELD_LOCAL_ALIAS (field))
7693 char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7694 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7698 case AIPL_FUNCTION_DECLARATION:
7699 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7700 purpose = build_wfl_node (get_identifier (buffer));
7701 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7702 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7704 value = TREE_TYPE (field);
7707 case AIPL_FUNCTION_CREATION:
7708 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7709 purpose = get_identifier (buffer);
7710 value = TREE_TYPE (field);
7713 case AIPL_FUNCTION_FINIT_INVOCATION:
7714 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7715 /* Now, this is wrong. purpose should always be the NAME
7716 of something and value its matching value (decl, type,
7717 etc...) FIXME -- but there is a lot to fix. */
7719 /* When invoked for this kind of operation, we already
7720 know whether a field is used or not. */
7721 purpose = TREE_TYPE (field);
7722 value = build_wfl_node (get_identifier (buffer));
7725 case AIPL_FUNCTION_CTOR_INVOCATION:
7726 /* There are two case: the constructor invokation happends
7727 outside the local inner, in which case, locales from the outer
7728 context are directly used.
7730 Otherwise, we fold to using the alias directly. */
7731 if (class_type == current_class)
7735 name = get_identifier (&buffer[4]);
7736 value = IDENTIFIER_LOCAL_VALUE (name);
7740 parm = tree_cons (purpose, value, parm);
7747 /* Craft a constructor for CLASS_DECL -- what we should do when none
7748 where found. ARGS is non NULL when a special signature must be
7749 enforced. This is the case for anonymous classes. */
7752 craft_constructor (class_decl, args)
7753 tree class_decl, args;
7755 tree class_type = TREE_TYPE (class_decl);
7756 tree parm = NULL_TREE;
7757 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7759 int i = 0, artificial = 0;
7760 tree decl, ctor_name;
7763 push_obstacks (&permanent_obstack, &permanent_obstack);
7765 /* The constructor name is <init> unless we're dealing with an
7766 anonymous class, in which case the name will be fixed after having
7768 if (ANONYMOUS_CLASS_P (class_type))
7769 ctor_name = DECL_NAME (class_decl);
7771 ctor_name = init_identifier_node;
7773 /* If we're dealing with an inner class constructor, we hide the
7774 this$<n> decl in the name field of its parameter declaration. */
7775 if (PURE_INNER_CLASS_TYPE_P (class_type))
7777 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7778 parm = tree_cons (build_current_thisn (class_type),
7779 build_pointer_type (type), parm);
7781 /* Some more arguments to be hidden here. The values of the local
7782 variables of the outer context that the inner class needs to see. */
7783 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7788 /* Then if there are any args to be enforced, enforce them now */
7789 for (; args && args != end_params_node; args = TREE_CHAIN (args))
7791 sprintf (buffer, "parm%d", i++);
7792 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7795 CRAFTED_PARAM_LIST_FIXUP (parm);
7796 decl = create_artificial_method (class_type, flags, void_type_node,
7798 fix_method_argument_names (parm, decl);
7799 /* Now, mark the artificial parameters. */
7800 DECL_FUNCTION_NAP (decl) = artificial;
7803 DECL_CONSTRUCTOR_P (decl) = 1;
7807 /* Fix the constructors. This will be called right after circular
7808 references have been checked. It is necessary to fix constructors
7809 early even if no code generation will take place for that class:
7810 some generated constructor might be required by the class whose
7811 compilation triggered this one to be simply loaded. */
7814 java_fix_constructors ()
7818 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7820 tree class_type = TREE_TYPE (current);
7824 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7827 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7829 if (DECL_CONSTRUCTOR_P (decl))
7831 fix_constructors (decl);
7836 /* Anonymous class constructor can't be generated that early. */
7837 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7838 craft_constructor (current, NULL_TREE);
7842 /* safe_layout_class just makes sure that we can load a class without
7843 disrupting the current_class, input_file, lineno, etc, information
7844 about the class processed currently. */
7847 safe_layout_class (class)
7850 tree save_current_class = current_class;
7851 char *save_input_filename = input_filename;
7852 int save_lineno = lineno;
7854 push_obstacks (&permanent_obstack, &permanent_obstack);
7856 layout_class (class);
7859 current_class = save_current_class;
7860 input_filename = save_input_filename;
7861 lineno = save_lineno;
7862 CLASS_LOADED_P (class) = 1;
7866 jdep_resolve_class (dep)
7871 if (JDEP_RESOLVED_P (dep))
7872 decl = JDEP_RESOLVED_DECL (dep);
7875 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7876 JDEP_DECL (dep), JDEP_WFL (dep));
7877 JDEP_RESOLVED (dep, decl);
7881 complete_class_report_errors (dep);
7886 /* Complete unsatisfied class declaration and their dependencies */
7889 java_complete_class ()
7896 push_obstacks (&permanent_obstack, &permanent_obstack);
7898 /* Process imports and reverse the import on demand list */
7900 if (ctxp->import_demand_list)
7901 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7903 /* Rever things so we have the right order */
7904 ctxp->class_list = nreverse (ctxp->class_list);
7905 ctxp->classd_list = reverse_jdep_list (ctxp);
7907 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
7909 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7912 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7915 if (!(decl = jdep_resolve_class (dep)))
7918 /* Now it's time to patch */
7919 switch (JDEP_KIND (dep))
7922 /* Simply patch super */
7923 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7925 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
7926 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7931 /* We do part of the job done in add_field */
7932 tree field_decl = JDEP_DECL (dep);
7933 tree field_type = TREE_TYPE (decl);
7934 push_obstacks (&permanent_obstack, &permanent_obstack);
7935 if (TREE_CODE (field_type) == RECORD_TYPE)
7936 field_type = promote_type (field_type);
7938 TREE_TYPE (field_decl) = field_type;
7939 DECL_ALIGN (field_decl) = 0;
7940 layout_decl (field_decl, 0);
7941 SOURCE_FRONTEND_DEBUG
7942 (("Completed field/var decl `%s' with `%s'",
7943 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7944 IDENTIFIER_POINTER (DECL_NAME (decl))));
7947 case JDEP_METHOD: /* We start patching a method */
7948 case JDEP_METHOD_RETURN:
7954 type = TREE_TYPE(decl);
7955 if (TREE_CODE (type) == RECORD_TYPE)
7956 type = promote_type (type);
7957 JDEP_APPLY_PATCH (dep, type);
7958 SOURCE_FRONTEND_DEBUG
7959 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7960 "Completing fct `%s' with ret type `%s'":
7961 "Completing arg `%s' with type `%s'"),
7962 IDENTIFIER_POINTER (EXPR_WFL_NODE
7963 (JDEP_DECL_WFL (dep))),
7964 IDENTIFIER_POINTER (DECL_NAME (decl))));
7968 dep = JDEP_CHAIN (dep);
7969 if (JDEP_KIND (dep) == JDEP_METHOD_END)
7972 decl = jdep_resolve_class (dep);
7976 tree mdecl = JDEP_DECL (dep), signature;
7977 push_obstacks (&permanent_obstack, &permanent_obstack);
7978 /* Recompute and reset the signature, check first that
7979 all types are now defined. If they're not,
7980 dont build the signature. */
7981 if (check_method_types_complete (mdecl))
7983 signature = build_java_signature (TREE_TYPE (mdecl));
7984 set_java_signature (TREE_TYPE (mdecl), signature);
7992 case JDEP_INTERFACE:
7993 if (parser_check_super_interface (decl, JDEP_DECL (dep),
7996 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8001 type = TREE_TYPE(decl);
8002 if (TREE_CODE (type) == RECORD_TYPE)
8003 type = promote_type (type);
8004 JDEP_APPLY_PATCH (dep, type);
8008 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8009 SOURCE_FRONTEND_DEBUG
8010 (("Completing a random type dependency on a '%s' node",
8011 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8014 case JDEP_EXCEPTION:
8015 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8016 SOURCE_FRONTEND_DEBUG
8017 (("Completing `%s' `throws' argument node",
8018 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8021 case JDEP_ANONYMOUS:
8022 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8026 fatal ("Can't handle patch code %d - java_complete_class",
8035 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8039 resolve_class (enclosing, class_type, decl, cl)
8040 tree enclosing, class_type, decl, cl;
8042 const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8043 const char *base = name;
8044 tree resolved_type = TREE_TYPE (class_type);
8045 tree resolved_type_decl;
8047 if (resolved_type != NULL_TREE)
8049 tree resolved_type_decl = TYPE_NAME (resolved_type);
8050 if (resolved_type_decl == NULL_TREE
8051 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8053 resolved_type_decl = build_decl (TYPE_DECL,
8054 TYPE_NAME (class_type),
8057 return resolved_type_decl;
8060 /* 1- Check to see if we have an array. If true, find what we really
8062 while (name[0] == '[')
8065 TYPE_NAME (class_type) = get_identifier (name);
8067 /* 2- Resolve the bare type */
8068 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
8071 resolved_type = TREE_TYPE (resolved_type_decl);
8073 /* 3- If we have and array, reconstruct the array down to its nesting */
8076 while (base != name)
8078 if (TREE_CODE (resolved_type) == RECORD_TYPE)
8079 resolved_type = promote_type (resolved_type);
8080 resolved_type = build_java_array_type (resolved_type, -1);
8081 CLASS_LOADED_P (resolved_type) = 1;
8084 /* Build a fake decl for this, since this is what is expected to
8086 resolved_type_decl =
8087 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8088 /* Figure how those two things are important for error report. FIXME */
8089 DECL_SOURCE_LINE (resolved_type_decl) = 0;
8090 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8091 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8093 TREE_TYPE (class_type) = resolved_type;
8094 return resolved_type_decl;
8097 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8098 are used to report error messages. */
8101 do_resolve_class (enclosing, class_type, decl, cl)
8102 tree enclosing, class_type, decl, cl;
8104 tree new_class_decl;
8105 tree original_name = NULL_TREE;
8107 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8108 its is changed by find_in_imports{_on_demand} */
8110 /* 0- Search in the current class as an inner class */
8112 /* Maybe some code here should be added to load the class or
8113 something, at least if the class isn't an inner class and ended
8114 being loaded from class file. FIXME. */
8119 if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8120 return new_class_decl;
8122 /* Now go to the upper classes, bail out if necessary. */
8123 enclosing = CLASSTYPE_SUPER (TREE_TYPE (enclosing));
8124 if (!enclosing || enclosing == object_type_node)
8127 if (TREE_CODE (enclosing) == RECORD_TYPE)
8129 enclosing = TYPE_NAME (enclosing);
8133 if (TREE_CODE (enclosing) == IDENTIFIER_NODE)
8135 BUILD_PTR_FROM_NAME (name, enclosing);
8139 enclosing = do_resolve_class (NULL, name, NULL, NULL);
8142 /* 1- Check for the type in single imports */
8143 if (find_in_imports (class_type))
8146 /* 2- And check for the type in the current compilation unit. If it fails,
8147 try with a name qualified with the package name we've seen so far */
8148 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8150 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8151 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8152 load_class (TYPE_NAME (class_type), 0);
8153 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8156 original_name = TYPE_NAME (class_type);
8157 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8160 for (package = package_list; package; package = TREE_CHAIN (package))
8164 new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8166 TYPE_NAME (class_type) = new_qualified;
8167 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8168 if (!new_class_decl)
8169 load_class (TYPE_NAME (class_type), 0);
8170 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8173 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8174 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8175 load_class (TYPE_NAME (class_type), 0);
8176 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8181 TYPE_NAME (class_type) = original_name;
8183 /* 3- Check an other compilation unit that bears the name of type */
8184 load_class (TYPE_NAME (class_type), 0);
8185 if (check_pkg_class_access (TYPE_NAME (class_type),
8186 (cl ? cl : lookup_cl (decl))))
8189 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8190 return new_class_decl;
8192 /* 4- Check the import on demands. Don't allow bar.baz to be
8193 imported from foo.* */
8194 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8195 if (find_in_imports_on_demand (class_type))
8198 /* 5- Last call for a resolution */
8199 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8202 /* Resolve NAME and lay it out (if not done and if not the current
8203 parsed class). Return a decl node. This function is meant to be
8204 called when type resolution is necessary during the walk pass. */
8207 resolve_and_layout (something, cl)
8213 /* Don't do that on the current class */
8214 if (something == current_class)
8215 return TYPE_NAME (current_class);
8217 /* Don't do anything for void and other primitive types */
8218 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8221 /* Pointer types can be reall pointer types or fake pointers. When
8222 finding a real pointer, recheck for primitive types */
8223 if (TREE_CODE (something) == POINTER_TYPE)
8225 if (TREE_TYPE (something))
8227 something = TREE_TYPE (something);
8228 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8232 something = TYPE_NAME (something);
8235 /* Don't do anything for arrays of primitive types */
8236 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8237 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8240 /* Something might be a WFL */
8241 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8242 something = EXPR_WFL_NODE (something);
8244 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8245 TYPE_DECL or a real TYPE */
8246 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8247 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8248 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8250 if (!(decl = resolve_no_layout (something, cl)))
8253 /* Resolve and layout if necessary */
8254 layout_class_methods (TREE_TYPE (decl));
8255 /* Check methods, but only once */
8256 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
8257 && !CLASS_LOADED_P (TREE_TYPE (decl)))
8258 CHECK_METHODS (decl);
8259 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8260 safe_layout_class (TREE_TYPE (decl));
8265 /* Resolve a class, returns its decl but doesn't perform any
8266 layout. The current parsing context is saved and restored */
8269 resolve_no_layout (name, cl)
8273 BUILD_PTR_FROM_NAME (ptr, name);
8274 java_parser_context_save_global ();
8275 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8276 java_parser_context_restore_global ();
8281 /* Called when reporting errors. Skip leader '[' in a complex array
8282 type description that failed to be resolved. */
8285 purify_type_name (name)
8288 while (*name && *name == '[')
8293 /* The type CURRENT refers to can't be found. We print error messages. */
8296 complete_class_report_errors (dep)
8301 if (!JDEP_WFL (dep))
8304 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8305 switch (JDEP_KIND (dep))
8309 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8310 purify_type_name (name),
8311 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8315 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8316 purify_type_name (name),
8317 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8319 case JDEP_METHOD: /* Covers arguments */
8321 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8322 purify_type_name (name),
8323 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8324 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8326 case JDEP_METHOD_RETURN: /* Covers return type */
8328 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8329 purify_type_name (name),
8330 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8332 case JDEP_INTERFACE:
8334 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8335 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8336 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8337 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8341 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8342 purify_type_name (IDENTIFIER_POINTER
8343 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8344 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8346 case JDEP_EXCEPTION: /* As specified by `throws' */
8348 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8349 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8352 /* Fix for -Wall. Just break doing nothing. The error will be
8358 /* Return a static string containing the DECL prototype string. If
8359 DECL is a constructor, use the class name instead of the form
8363 get_printable_method_name (decl)
8366 const char *to_return;
8367 tree name = NULL_TREE;
8369 if (DECL_CONSTRUCTOR_P (decl))
8371 name = DECL_NAME (decl);
8372 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8375 to_return = lang_printable_name (decl, 0);
8376 if (DECL_CONSTRUCTOR_P (decl))
8377 DECL_NAME (decl) = name;
8382 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8383 nevertheless needs to be verfied, 1 otherwise. */
8386 reset_method_name (method)
8389 if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8391 /* NAME is just the plain name when Object is being defined */
8392 if (DECL_CONTEXT (method) != object_type_node)
8393 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
8394 init_identifier_node : GET_METHOD_NAME (method));
8401 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8404 java_get_real_method_name (method_decl)
8407 tree method_name = DECL_NAME (method_decl);
8408 if (DECL_CONSTRUCTOR_P (method_decl))
8409 return init_identifier_node;
8411 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8412 and still can be a constructor. FIXME */
8414 /* Don't confuse method only bearing the name of their class as
8416 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8418 && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8419 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8420 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8421 return init_identifier_node;
8423 return EXPR_WFL_NODE (method_name);
8426 /* Track method being redefined inside the same class. As a side
8427 effect, set DECL_NAME to an IDENTIFIER (prior entering this
8428 function it's a FWL, so we can track errors more accurately.) */
8431 check_method_redefinition (class, method)
8435 tree cl = DECL_NAME (method);
8436 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8437 /* decl name of artificial <clinit> and $finit$ doesn't need to be
8438 fixed and checked */
8440 /* Reset the method name before running the check. If it returns 1,
8441 the method doesn't need to be verified with respect to method
8442 redeclaration and we return 0 */
8443 if (reset_method_name (method))
8446 name = DECL_NAME (method);
8447 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8449 if (redef == method)
8451 if (DECL_NAME (redef) == name
8452 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8455 (cl, "Duplicate %s declaration `%s'",
8456 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8457 get_printable_method_name (redef));
8465 check_abstract_method_definitions (do_interface, class_decl, type)
8467 tree class_decl, type;
8469 tree class = TREE_TYPE (class_decl);
8470 tree method, end_type;
8472 end_type = (do_interface ? object_type_node : type);
8473 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8475 tree other_super, other_method, method_sig, method_name;
8477 int end_type_reached = 0;
8479 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8482 /* Now verify that somewhere in between TYPE and CLASS,
8483 abstract method METHOD gets a non abstract definition
8484 that is inherited by CLASS. */
8486 method_sig = build_java_signature (TREE_TYPE (method));
8487 method_name = DECL_NAME (method);
8488 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8489 method_name = EXPR_WFL_NODE (method_name);
8491 other_super = class;
8493 if (other_super == end_type)
8494 end_type_reached = 1;
8497 for (other_method = TYPE_METHODS (other_super); other_method;
8498 other_method = TREE_CHAIN (other_method))
8500 tree s = build_java_signature (TREE_TYPE (other_method));
8501 tree other_name = DECL_NAME (other_method);
8503 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8504 other_name = EXPR_WFL_NODE (other_name);
8505 if (!DECL_CLINIT_P (other_method)
8506 && !DECL_CONSTRUCTOR_P (other_method)
8507 && method_name == other_name && method_sig == s)
8513 other_super = CLASSTYPE_SUPER (other_super);
8514 } while (!end_type_reached);
8516 /* Report that abstract METHOD didn't find an implementation
8517 that CLASS can use. */
8520 char *t = xstrdup (lang_printable_name
8521 (TREE_TYPE (TREE_TYPE (method)), 0));
8522 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8523 tree saved_wfl = NULL_TREE;
8525 if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8527 saved_wfl = DECL_NAME (method);
8528 DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8532 (lookup_cl (class_decl),
8533 "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",
8534 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8535 t, lang_printable_name (method, 0),
8536 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
8537 "interface" : "class"),
8538 IDENTIFIER_POINTER (ccn),
8539 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8540 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8545 DECL_NAME (method) = saved_wfl;
8550 /* Check that CLASS_DECL somehow implements all inherited abstract
8554 java_check_abstract_method_definitions (class_decl)
8557 tree class = TREE_TYPE (class_decl);
8561 if (CLASS_ABSTRACT (class_decl))
8564 /* Check for inherited types */
8567 super = CLASSTYPE_SUPER (super);
8568 check_abstract_method_definitions (0, class_decl, super);
8569 } while (super != object_type_node);
8571 /* Check for implemented interfaces. */
8572 vector = TYPE_BINFO_BASETYPES (class);
8573 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8575 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8576 check_abstract_method_definitions (1, class_decl, super);
8580 /* Check all the types method DECL uses and return 1 if all of them
8581 are now complete, 0 otherwise. This is used to check whether its
8582 safe to build a method signature or not. */
8585 check_method_types_complete (decl)
8588 tree type = TREE_TYPE (decl);
8591 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8594 args = TYPE_ARG_TYPES (type);
8595 if (TREE_CODE (type) == METHOD_TYPE)
8596 args = TREE_CHAIN (args);
8597 for (; args != end_params_node; args = TREE_CHAIN (args))
8598 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8604 /* Check all the methods of CLASS_DECL. Methods are first completed
8605 then checked according to regular method existance rules. If no
8606 constructor for CLASS_DECL were encountered, then build its
8610 java_check_regular_methods (class_decl)
8613 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8615 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8616 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8619 /* It is not necessary to check methods defined in java.lang.Object */
8620 if (class == object_type_node)
8623 if (!TYPE_NVIRTUALS (class))
8624 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8626 /* Should take interfaces into account. FIXME */
8627 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8630 tree method_wfl = DECL_NAME (method);
8633 /* If we previously found something and its name was saved,
8635 if (found && saved_found_wfl)
8637 DECL_NAME (found) = saved_found_wfl;
8638 saved_found_wfl = NULL_TREE;
8641 /* Check for redefinitions */
8642 if (check_method_redefinition (class, method))
8645 /* If we see one constructor a mark so we don't generate the
8646 default one. Also skip other verifications: constructors
8647 can't be inherited hence hiden or overriden */
8648 if (DECL_CONSTRUCTOR_P (method))
8650 saw_constructor = 1;
8654 /* We verify things thrown by the method. They must inherits from
8655 java.lang.Throwable */
8656 for (mthrows = DECL_FUNCTION_THROWS (method);
8657 mthrows; mthrows = TREE_CHAIN (mthrows))
8659 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8661 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8663 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8666 sig = build_java_argument_signature (TREE_TYPE (method));
8667 found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8669 /* Inner class can't declare static methods */
8670 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8672 char *t = xstrdup (lang_printable_name (class, 0));
8674 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8675 lang_printable_name (method, 0), t);
8679 /* Nothing overrides or it's a private method. */
8682 if (METHOD_PRIVATE (found))
8688 /* If found wasn't verified, it's DECL_NAME won't be set properly.
8689 We set it temporarily for the sake of the error report. */
8690 saved_found_wfl = DECL_NAME (found);
8691 reset_method_name (found);
8693 /* If `found' is declared in an interface, make sure the
8694 modifier matches. */
8695 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8696 && clinit_identifier_node != DECL_NAME (found)
8697 && !METHOD_PUBLIC (method))
8699 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8700 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8701 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8702 lang_printable_name (method, 0),
8703 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8706 /* Can't override a method with the same name and different return
8708 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8711 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8714 "Method `%s' was defined with return type `%s' in class `%s'",
8715 lang_printable_name (found, 0), t,
8717 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8721 aflags = get_access_flags_from_decl (found);
8722 /* If the method has default, access in an other package, then
8723 issue a warning that the current method doesn't override the
8724 one that was found elsewhere. Do not issue this warning when
8725 the match was found in java.lang.Object. */
8726 if (DECL_CONTEXT (found) != object_type_node
8727 && ((aflags & ACC_VISIBILITY) == 0)
8728 && !class_in_current_package (DECL_CONTEXT (found))
8729 && !DECL_CLINIT_P (found)
8730 && flag_not_overriding)
8732 parse_warning_context
8733 (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8734 lang_printable_name (found, 0),
8735 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8736 IDENTIFIER_POINTER (DECL_NAME
8737 (TYPE_NAME (DECL_CONTEXT (found)))));
8741 /* Can't override final. Can't override static. */
8742 if (METHOD_FINAL (found) || METHOD_STATIC (found))
8744 /* Static *can* override static */
8745 if (METHOD_STATIC (found) && METHOD_STATIC (method))
8749 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8750 (METHOD_FINAL (found) ? "Final" : "Static"),
8751 lang_printable_name (found, 0),
8752 (METHOD_FINAL (found) ? "final" : "static"),
8754 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8758 /* Static method can't override instance method. */
8759 if (METHOD_STATIC (method))
8763 "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8764 lang_printable_name (found, 0),
8766 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8770 /* - Overriding/hiding public must be public
8771 - Overriding/hiding protected must be protected or public
8772 - If the overriden or hidden method has default (package)
8773 access, then the overriding or hiding method must not be
8774 private; otherwise, a compile-time error occurs. If
8775 `found' belongs to an interface, things have been already
8777 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8778 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8779 || (METHOD_PROTECTED (found)
8780 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8781 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8782 && METHOD_PRIVATE (method))))
8786 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8787 (METHOD_PUBLIC (method) ? "public" :
8788 (METHOD_PRIVATE (method) ? "private" : "protected")),
8789 IDENTIFIER_POINTER (DECL_NAME
8790 (TYPE_NAME (DECL_CONTEXT (found)))));
8794 /* Overriding methods must have compatible `throws' clauses on checked
8795 exceptions, if any */
8796 check_throws_clauses (method, method_wfl, found);
8798 /* Inheriting multiple methods with the same signature. FIXME */
8801 /* Don't forget eventual pending found and saved_found_wfl. Take
8802 into account that we might have exited because we saw an
8803 artificial method as the last entry. */
8805 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8806 DECL_NAME (found) = saved_found_wfl;
8808 if (!TYPE_NVIRTUALS (class))
8809 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8811 /* Search for inherited abstract method not yet implemented in this
8813 java_check_abstract_method_definitions (class_decl);
8815 if (!saw_constructor)
8816 fatal ("No constructor found");
8819 /* Return a non zero value if the `throws' clause of METHOD (if any)
8820 is incompatible with the `throws' clause of FOUND (if any). */
8823 check_throws_clauses (method, method_wfl, found)
8824 tree method, method_wfl, found;
8826 tree mthrows, fthrows;
8828 /* Can't check these things with class loaded from bytecode. FIXME */
8829 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8832 for (mthrows = DECL_FUNCTION_THROWS (method);
8833 mthrows; mthrows = TREE_CHAIN (mthrows))
8835 /* We don't verify unchecked expressions */
8836 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8838 /* Checked expression must be compatible */
8839 for (fthrows = DECL_FUNCTION_THROWS (found);
8840 fthrows; fthrows = TREE_CHAIN (fthrows))
8841 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8846 (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'",
8847 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8848 lang_printable_name (found, 0),
8850 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8855 /* Check abstract method of interface INTERFACE */
8858 java_check_abstract_methods (interface_decl)
8859 tree interface_decl;
8862 tree method, basetype_vec, found;
8863 tree interface = TREE_TYPE (interface_decl);
8865 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8867 tree method_wfl = DECL_NAME (method);
8869 /* 2- Check for double definition inside the defining interface */
8870 if (check_method_redefinition (interface, method))
8873 /* 3- Overriding is OK as far as we preserve the return type and
8874 the thrown exceptions (FIXME) */
8875 found = lookup_java_interface_method2 (interface, method);
8879 tree saved_found_wfl = DECL_NAME (found);
8880 reset_method_name (found);
8881 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8884 "Method `%s' was defined with return type `%s' in class `%s'",
8885 lang_printable_name (found, 0), t,
8887 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8889 DECL_NAME (found) = saved_found_wfl;
8894 /* 4- Inherited methods can't differ by their returned types */
8895 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8897 n = TREE_VEC_LENGTH (basetype_vec);
8898 for (i = 0; i < n; i++)
8900 tree sub_interface_method, sub_interface;
8901 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8904 sub_interface = BINFO_TYPE (vec_elt);
8905 for (sub_interface_method = TYPE_METHODS (sub_interface);
8906 sub_interface_method;
8907 sub_interface_method = TREE_CHAIN (sub_interface_method))
8909 found = lookup_java_interface_method2 (interface,
8910 sub_interface_method);
8911 if (found && (found != sub_interface_method))
8913 tree saved_found_wfl = DECL_NAME (found);
8914 reset_method_name (found);
8916 (lookup_cl (sub_interface_method),
8917 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8918 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8919 lang_printable_name (found, 0),
8921 (DECL_NAME (TYPE_NAME
8922 (DECL_CONTEXT (sub_interface_method)))),
8924 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8925 DECL_NAME (found) = saved_found_wfl;
8931 /* Lookup methods in interfaces using their name and partial
8932 signature. Return a matching method only if their types differ. */
8935 lookup_java_interface_method2 (class, method_decl)
8936 tree class, method_decl;
8939 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8944 n = TREE_VEC_LENGTH (basetype_vec);
8945 for (i = 0; i < n; i++)
8947 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8948 if ((BINFO_TYPE (vec_elt) != object_type_node)
8950 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8953 for (i = 0; i < n; i++)
8955 to_return = lookup_java_interface_method2
8956 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8964 /* Lookup method using their name and partial signature. Return a
8965 matching method only if their types differ. */
8968 lookup_java_method2 (clas, method_decl, do_interface)
8969 tree clas, method_decl;
8972 tree method, method_signature, method_name, method_type, name;
8974 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8975 name = DECL_NAME (method_decl);
8976 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8977 EXPR_WFL_NODE (name) : name);
8978 method_type = TREE_TYPE (TREE_TYPE (method_decl));
8980 while (clas != NULL_TREE)
8982 for (method = TYPE_METHODS (clas);
8983 method != NULL_TREE; method = TREE_CHAIN (method))
8985 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8986 tree name = DECL_NAME (method);
8987 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8988 EXPR_WFL_NODE (name) : name) == method_name
8989 && method_sig == method_signature
8990 && TREE_TYPE (TREE_TYPE (method)) != method_type)
8993 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
8998 /* Return the line that matches DECL line number, and try its best to
8999 position the column number. Used during error reports. */
9005 static tree cl = NULL_TREE;
9011 if (cl == NULL_TREE)
9012 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9014 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
9015 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
9017 line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
9018 EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
9020 found = strstr ((const char *)line,
9021 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9023 EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
9028 /* Look for a simple name in the single-type import list */
9031 find_name_in_single_imports (name)
9036 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9037 if (TREE_VALUE (node) == name)
9038 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9043 /* Process all single-type import. */
9051 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9053 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9055 /* Don't load twice something already defined. */
9056 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9058 QUALIFIED_P (to_be_found) = 1;
9059 load_class (to_be_found, 0);
9061 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9062 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9064 parse_error_context (TREE_PURPOSE (import),
9065 "Class or interface `%s' not found in import",
9066 IDENTIFIER_POINTER (to_be_found));
9075 /* Possibly find a class imported by a single-type import statement. Return
9076 1 if an error occured, 0 otherwise. */
9079 find_in_imports (class_type)
9084 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9085 if (TREE_VALUE (import) == TYPE_NAME (class_type))
9087 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9088 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9094 note_possible_classname (name, len)
9099 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9101 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9105 node = ident_subst (name, len, "", '/', '.', "");
9106 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9107 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9111 /* Read a import directory, gathering potential match for further type
9112 references. Indifferently reads a filesystem or a ZIP archive
9116 read_import_dir (wfl)
9119 tree package_id = EXPR_WFL_NODE (wfl);
9120 const char *package_name = IDENTIFIER_POINTER (package_id);
9121 int package_length = IDENTIFIER_LENGTH (package_id);
9123 JCF *saved_jcf = current_jcf;
9128 struct buffer filename[1];
9131 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9133 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9135 BUFFER_INIT (filename);
9136 buffer_grow (filename, package_length + 100);
9138 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9140 const char *entry_name = jcf_path_name (entry);
9141 int entry_length = strlen (entry_name);
9142 if (jcf_path_is_zipfile (entry))
9145 buffer_grow (filename, entry_length);
9146 memcpy (filename->data, entry_name, entry_length - 1);
9147 filename->data[entry_length-1] = '\0';
9148 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9150 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9153 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9154 BUFFER_RESET (filename);
9155 for (k = 0; k < package_length; k++)
9157 char ch = package_name[k];
9158 *filename->ptr++ = ch == '.' ? '/' : ch;
9160 *filename->ptr++ = '/';
9162 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9164 const char *current_entry = ZIPDIR_FILENAME (zipd);
9165 int current_entry_len = zipd->filename_length;
9167 if (current_entry_len >= BUFFER_LENGTH (filename)
9168 && strncmp (filename->data, current_entry,
9169 BUFFER_LENGTH (filename)) != 0)
9171 found |= note_possible_classname (current_entry,
9178 BUFFER_RESET (filename);
9179 buffer_grow (filename, entry_length + package_length + 4);
9180 strcpy (filename->data, entry_name);
9181 filename->ptr = filename->data + entry_length;
9182 for (k = 0; k < package_length; k++)
9184 char ch = package_name[k];
9185 *filename->ptr++ = ch == '.' ? '/' : ch;
9187 *filename->ptr = '\0';
9189 dirp = opendir (filename->data);
9192 *filename->ptr++ = '/';
9197 struct dirent *direntp = readdir (dirp);
9200 d_name = direntp->d_name;
9201 len = strlen (direntp->d_name);
9202 buffer_grow (filename, len+1);
9203 strcpy (filename->ptr, d_name);
9204 found |= note_possible_classname (filename->data + entry_length,
9205 package_length+len+1);
9212 free (filename->data);
9214 /* Here we should have a unified way of retrieving an entry, to be
9218 static int first = 1;
9221 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9226 parse_error_context (wfl, "Package `%s' not found in import",
9228 current_jcf = saved_jcf;
9231 current_jcf = saved_jcf;
9234 /* Possibly find a type in the import on demands specified
9235 types. Returns 1 if an error occured, 0 otherwise. Run throught the
9236 entire list, to detected potential double definitions. */
9239 find_in_imports_on_demand (class_type)
9242 tree node, import, node_to_use = NULL_TREE;
9244 tree cl = NULL_TREE;
9246 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9248 const char *id_name;
9249 obstack_grow (&temporary_obstack,
9250 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9251 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9252 obstack_1grow (&temporary_obstack, '.');
9253 obstack_grow0 (&temporary_obstack,
9254 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9255 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9256 id_name = obstack_finish (&temporary_obstack);
9258 node = maybe_get_identifier (id_name);
9259 if (node && IS_A_CLASSFILE_NAME (node))
9263 cl = TREE_PURPOSE (import);
9271 (import, "Type `%s' also potentially defined in package `%s'",
9272 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9273 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9280 /* Setup lineno so that it refers to the line of the import (in
9281 case we parse a class file and encounter errors */
9283 int saved_lineno = lineno;
9284 lineno = EXPR_WFL_LINENO (cl);
9285 TYPE_NAME (class_type) = node_to_use;
9286 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9287 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9288 /* If there is no DECL set for the class or if the class isn't
9289 loaded and not seen in source yet, the load */
9290 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9291 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9292 load_class (node_to_use, 0);
9293 lineno = saved_lineno;
9294 return check_pkg_class_access (TYPE_NAME (class_type), cl);
9297 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9301 resolve_package (pkg, next)
9305 tree type_name = NULL_TREE;
9306 const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9308 /* The trick is to determine when the package name stops and were
9309 the name of something contained in the package starts. Then we
9310 return a fully qualified name of what we want to get. */
9312 /* Do a quick search on well known package names */
9313 if (!strncmp (name, "java.lang.reflect", 17))
9316 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9317 type_name = lookup_package_type (name, 17);
9319 else if (!strncmp (name, "java.lang", 9))
9321 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9322 type_name = lookup_package_type (name, 9);
9325 /* If we found something here, return */
9329 *next = EXPR_WFL_QUALIFICATION (pkg);
9331 /* Try the current package. */
9332 if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),
9333 IDENTIFIER_LENGTH (ctxp->package)))
9336 lookup_package_type_and_set_next (name,
9337 IDENTIFIER_LENGTH (ctxp->package),
9343 /* Search in imported package */
9344 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9346 tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9347 int len = IDENTIFIER_LENGTH (current_pkg_name);
9348 if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9352 breakdown_qualified (&left, &dummy, current_pkg_name);
9353 len = IDENTIFIER_LENGTH (left);
9354 type_name = lookup_package_type_and_set_next (name, len, next);
9360 /* Try to progressively construct a type name */
9361 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9362 for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg);
9363 current; current = TREE_CHAIN (current))
9365 acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9366 if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9369 *next = TREE_CHAIN (current);
9377 lookup_package_type_and_set_next (name, len, next)
9383 tree type_name = lookup_package_type (name, len);
9388 ptr = IDENTIFIER_POINTER (type_name);
9389 while (ptr && (ptr = strchr (ptr, '.')))
9391 *next = TREE_CHAIN (*next);
9398 lookup_package_type (name, from)
9403 const char *sub = &name[from+1];
9404 while (*sub != '.' && *sub)
9406 strncpy (subname, name, sub-name);
9407 subname [sub-name] = '\0';
9408 return get_identifier (subname);
9411 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9412 access violations were found, 1 otherwise. */
9415 check_pkg_class_access (class_name, cl)
9421 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9424 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9427 if (!CLASS_PUBLIC (TYPE_NAME (type)))
9429 /* Access to a private class within the same package is
9432 breakdown_qualified (&l, &r, class_name);
9433 if (l == ctxp->package)
9437 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9438 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9439 IDENTIFIER_POINTER (class_name));
9445 /* Local variable declaration. */
9448 declare_local_variables (modifier, type, vlist)
9453 tree decl, current, saved_type;
9454 tree type_wfl = NULL_TREE;
9458 /* Push a new block if statements were seen between the last time we
9459 pushed a block and now. Keep a cound of block to close */
9460 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9462 tree body = GET_CURRENT_BLOCK (current_function_decl);
9463 tree b = enter_block ();
9464 BLOCK_EXPR_ORIGIN (b) = body;
9470 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9471 if (modifier == ACC_FINAL)
9476 (ctxp->modifier_ctx [i],
9477 "Only `final' is allowed as a local variables modifier");
9482 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9483 hold the TYPE value if a new incomplete has to be created (as
9484 opposed to being found already existing and reused). */
9485 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9487 /* If TYPE is fully resolved and we don't have a reference, make one */
9488 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9490 /* Go through all the declared variables */
9491 for (current = vlist, saved_type = type; current;
9492 current = TREE_CHAIN (current), type = saved_type)
9494 tree other, real_type;
9495 tree wfl = TREE_PURPOSE (current);
9496 tree name = EXPR_WFL_NODE (wfl);
9497 tree init = TREE_VALUE (current);
9499 /* Process NAME, as it may specify extra dimension(s) for it */
9500 type = build_array_from_name (type, type_wfl, name, &name);
9502 /* Variable redefinition check */
9503 if ((other = lookup_name_in_blocks (name)))
9505 variable_redefinition_error (wfl, name, TREE_TYPE (other),
9506 DECL_SOURCE_LINE (other));
9510 /* Type adjustment. We may have just readjusted TYPE because
9511 the variable specified more dimensions. Make sure we have
9512 a reference if we can and don't have one already. */
9513 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9515 real_type = GET_REAL_TYPE (type);
9516 /* Never layout this decl. This will be done when its scope
9518 decl = build_decl (VAR_DECL, name, real_type);
9519 LOCAL_FINAL (decl) = final_p;
9520 BLOCK_CHAIN_DECL (decl);
9522 /* If doing xreferencing, replace the line number with the WFL
9525 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9527 /* Don't try to use an INIT statement when an error was found */
9528 if (init && java_error_count)
9531 /* Add the initialization function to the current function's code */
9534 /* Name might have been readjusted */
9535 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9536 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9537 java_method_add_stmt (current_function_decl,
9538 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9542 /* Setup dependency the type of the decl */
9546 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9547 dep = CLASSD_LAST (ctxp->classd_list);
9548 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9551 SOURCE_FRONTEND_DEBUG (("Defined locals"));
9554 /* Called during parsing. Build decls from argument list. */
9557 source_start_java_method (fndecl)
9567 current_function_decl = fndecl;
9569 /* New scope for the function */
9571 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9572 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9574 tree type = TREE_VALUE (tem);
9575 tree name = TREE_PURPOSE (tem);
9577 /* If type is incomplete. Create an incomplete decl and ask for
9578 the decl to be patched later */
9579 if (INCOMPLETE_TYPE_P (type))
9582 tree real_type = GET_REAL_TYPE (type);
9583 parm_decl = build_decl (PARM_DECL, name, real_type);
9584 type = obtain_incomplete_type (type);
9585 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9586 jdep = CLASSD_LAST (ctxp->classd_list);
9587 JDEP_MISC (jdep) = name;
9588 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9591 parm_decl = build_decl (PARM_DECL, name, type);
9593 /* Remember if a local variable was declared final (via its
9594 TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9595 if (ARG_FINAL_P (tem))
9596 LOCAL_FINAL (parm_decl) = 1;
9598 BLOCK_CHAIN_DECL (parm_decl);
9600 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9601 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9603 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9604 DECL_MAX_LOCALS (current_function_decl) = i;
9607 /* Called during parsing. Creates an artificial method declaration. */
9610 create_artificial_method (class, flags, type, name, args)
9613 tree type, name, args;
9617 java_parser_context_save_global ();
9619 mdecl = make_node (FUNCTION_TYPE);
9620 TREE_TYPE (mdecl) = type;
9621 TYPE_ARG_TYPES (mdecl) = args;
9622 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
9623 java_parser_context_restore_global ();
9624 DECL_ARTIFICIAL (mdecl) = 1;
9628 /* Starts the body if an artifical method. */
9631 start_artificial_method_body (mdecl)
9634 DECL_SOURCE_LINE (mdecl) = 1;
9635 DECL_SOURCE_LINE_MERGE (mdecl, 1);
9636 source_start_java_method (mdecl);
9641 end_artificial_method_body (mdecl)
9644 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9648 /* Called during expansion. Push decls formerly built from argument
9649 list so they're usable during expansion. */
9652 expand_start_java_method (fndecl)
9657 current_function_decl = fndecl;
9660 fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9661 announce_function (fndecl);
9663 fprintf (stderr, "]");
9665 pushlevel (1); /* Prepare for a parameter push */
9666 ptr = &DECL_ARGUMENTS (fndecl);
9667 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9670 tree next = TREE_CHAIN (tem);
9671 tree type = TREE_TYPE (tem);
9672 if (PROMOTE_PROTOTYPES
9673 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9674 && INTEGRAL_TYPE_P (type))
9675 type = integer_type_node;
9676 DECL_ARG_TYPE (tem) = type;
9677 layout_decl (tem, 0);
9680 ptr = &TREE_CHAIN (tem);
9684 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9685 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9688 /* Terminate a function and expand its body. */
9691 source_end_java_method ()
9693 tree fndecl = current_function_decl;
9694 int flag_asynchronous_exceptions = asynchronous_exceptions;
9699 java_parser_context_save_global ();
9700 lineno = ctxp->last_ccb_indent1;
9702 /* Set EH language codes */
9703 java_set_exception_lang_code ();
9705 /* Turn function bodies with only a NOP expr null, so they don't get
9706 generated at all and we won't get warnings when using the -W
9708 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9709 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9711 /* Generate function's code */
9712 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9713 && ! flag_emit_class_files
9714 && ! flag_emit_xref)
9715 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9717 /* pop out of its parameters */
9718 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9720 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9722 /* Generate rtl for function exit. */
9723 if (! flag_emit_class_files && ! flag_emit_xref)
9725 lineno = DECL_SOURCE_LINE_LAST (fndecl);
9726 /* Emit catch-finally clauses */
9728 expand_function_end (input_filename, lineno, 0);
9730 /* FIXME: If the current method contains any exception handlers,
9731 force asynchronous_exceptions: this is necessary because signal
9732 handlers in libjava may throw exceptions. This is far from being
9733 a perfect solution, but it's better than doing nothing at all.*/
9735 asynchronous_exceptions = 1;
9737 /* Run the optimizers and output assembler code for this function. */
9738 rest_of_compilation (fndecl);
9741 current_function_decl = NULL_TREE;
9742 permanent_allocation (1);
9743 java_parser_context_restore_global ();
9744 asynchronous_exceptions = flag_asynchronous_exceptions;
9747 /* Record EXPR in the current function block. Complements compound
9748 expression second operand if necessary. */
9751 java_method_add_stmt (fndecl, expr)
9754 if (!GET_CURRENT_BLOCK (fndecl))
9756 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9760 add_stmt_to_block (b, type, stmt)
9763 tree body = BLOCK_EXPR_BODY (b), c;
9765 if (java_error_count)
9768 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9771 BLOCK_EXPR_BODY (b) = c;
9772 TREE_SIDE_EFFECTS (c) = 1;
9776 /* Add STMT to EXISTING if possible, otherwise create a new
9777 COMPOUND_EXPR and add STMT to it. */
9780 add_stmt_to_compound (existing, type, stmt)
9781 tree existing, type, stmt;
9784 return build (COMPOUND_EXPR, type, existing, stmt);
9789 /* Hold THIS for the scope of the current public method decl. */
9790 static tree current_this;
9792 void java_layout_seen_class_methods ()
9794 tree previous_list = all_class_list;
9795 tree end = NULL_TREE;
9800 for (current = previous_list;
9801 current != end; current = TREE_CHAIN (current))
9802 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9804 if (previous_list != all_class_list)
9806 end = previous_list;
9807 previous_list = all_class_list;
9815 java_reorder_fields ()
9817 static tree stop_reordering = NULL_TREE;
9820 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9822 current_class = TREE_TYPE (TREE_VALUE (current));
9824 if (current_class == stop_reordering)
9827 /* Reverse the fields, but leave the dummy field in front.
9828 Fields are already ordered for Object and Class */
9829 if (TYPE_FIELDS (current_class) && current_class != object_type_node
9830 && current_class != class_type_node)
9832 /* If the dummy field is there, reverse the right fields and
9833 just layout the type for proper fields offset */
9834 if (!DECL_NAME (TYPE_FIELDS (current_class)))
9836 tree fields = TYPE_FIELDS (current_class);
9837 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9838 TYPE_SIZE (current_class) = NULL_TREE;
9840 /* We don't have a dummy field, we need to layout the class,
9841 after having reversed the fields */
9844 TYPE_FIELDS (current_class) =
9845 nreverse (TYPE_FIELDS (current_class));
9846 TYPE_SIZE (current_class) = NULL_TREE;
9850 stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9853 /* Layout the methods of all classes loaded in one way on an
9854 other. Check methods of source parsed classes. Then reorder the
9855 fields and layout the classes or the type of all source parsed
9859 java_layout_classes ()
9862 int save_error_count = java_error_count;
9864 /* Layout the methods of all classes seen so far */
9865 java_layout_seen_class_methods ();
9866 java_parse_abort_on_error ();
9867 all_class_list = NULL_TREE;
9869 /* Then check the methods of all parsed classes */
9870 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9871 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9872 CHECK_METHODS (TREE_VALUE (current));
9873 java_parse_abort_on_error ();
9875 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9877 current_class = TREE_TYPE (TREE_VALUE (current));
9878 layout_class (current_class);
9880 /* From now on, the class is considered completely loaded */
9881 CLASS_LOADED_P (current_class) = 1;
9883 /* Error reported by the caller */
9884 if (java_error_count)
9888 /* We might have reloaded classes durign the process of laying out
9889 classes for code generation. We must layout the methods of those
9890 late additions, as constructor checks might use them */
9891 java_layout_seen_class_methods ();
9892 java_parse_abort_on_error ();
9895 /* Expand methods in the current set of classes rememebered for
9899 java_complete_expand_classes ()
9903 do_not_fold = flag_emit_xref;
9905 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9906 if (!INNER_CLASS_DECL_P (current))
9907 java_complete_expand_class (current);
9910 /* Expand the methods found in OUTER, starting first by OUTER's inner
9914 java_complete_expand_class (outer)
9919 set_nested_class_simple_name_value (outer, 1); /* Set */
9921 /* We need to go after all inner classes and start expanding them,
9922 starting with most nested ones. We have to do that because nested
9923 classes might add functions to outer classes */
9925 for (inner_list = DECL_INNER_CLASS_LIST (outer);
9926 inner_list; inner_list = TREE_CHAIN (inner_list))
9927 java_complete_expand_class (TREE_PURPOSE (inner_list));
9929 java_complete_expand_methods (outer);
9930 set_nested_class_simple_name_value (outer, 0); /* Reset */
9933 /* Expand methods registered in CLASS_DECL. The general idea is that
9934 we expand regular methods first. This allows us get an estimate on
9935 how outer context local alias fields are really used so we can add
9936 to the constructor just enough code to initialize them properly (it
9937 also lets us generate $finit$ correctly.) Then we expand the
9938 constructors and then <clinit>. */
9941 java_complete_expand_methods (class_decl)
9944 tree clinit, finit, decl, first_decl;
9946 current_class = TREE_TYPE (class_decl);
9948 /* Initialize a new constant pool */
9949 init_outgoing_cpool ();
9951 /* Pre-expand <clinit> to figure whether we really need it or
9952 not. If we do need it, we pre-expand the static fields so they're
9953 ready to be used somewhere else. <clinit> will be fully expanded
9954 after we processed the constructors. */
9955 first_decl = TYPE_METHODS (current_class);
9956 clinit = maybe_generate_pre_expand_clinit (current_class);
9958 /* Then generate $finit$ (if we need to) because constructor will
9960 if (TYPE_FINIT_STMT_LIST (current_class))
9962 finit = generate_finit (current_class);
9963 java_complete_expand_method (finit);
9966 /* Now do the constructors */
9967 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9971 if (!DECL_CONSTRUCTOR_P (decl))
9974 no_body = !DECL_FUNCTION_BODY (decl);
9975 /* Don't generate debug info on line zero when expanding a
9976 generated constructor. */
9978 restore_line_number_status (1);
9980 java_complete_expand_method (decl);
9983 restore_line_number_status (0);
9986 /* First, do the ordinary methods. */
9987 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
9989 /* Skip abstract or native methods */
9990 if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl)
9991 || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
9993 java_complete_expand_method (decl);
9996 /* If there is indeed a <clinit>, fully expand it now */
9999 /* Prevent the use of `this' inside <clinit> */
10000 ctxp->explicit_constructor_p = 1;
10001 java_complete_expand_method (clinit);
10002 ctxp->explicit_constructor_p = 0;
10005 /* We might have generated a class$ that we now want to expand */
10006 if (TYPE_DOT_CLASS (current_class))
10007 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10009 /* Now verify constructor circularity (stop after the first one we
10011 if (!CLASS_INTERFACE (class_decl))
10012 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10013 if (DECL_CONSTRUCTOR_P (decl)
10014 && verify_constructor_circularity (decl, decl))
10017 /* Save the constant pool. We'll need to restore it later. */
10018 TYPE_CPOOL (current_class) = outgoing_cpool;
10021 /* Hold a list of catch clauses list. The first element of this list is
10022 the list of the catch clauses of the currently analysed try block. */
10023 static tree currently_caught_type_list;
10025 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10026 safely used in some other methods/constructors. */
10029 maybe_generate_pre_expand_clinit (class_type)
10032 tree current, mdecl;
10034 if (!TYPE_CLINIT_STMT_LIST (class_type))
10037 /* Go through all static fields and pre expand them */
10038 for (current = TYPE_FIELDS (class_type); current;
10039 current = TREE_CHAIN (current))
10040 if (FIELD_STATIC (current))
10041 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10043 /* Then build the <clinit> method */
10044 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10045 clinit_identifier_node, end_params_node);
10046 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10048 start_artificial_method_body (mdecl);
10050 /* We process the list of assignment we produced as the result of
10051 the declaration of initialized static field and add them as
10052 statement to the <clinit> method. */
10053 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10054 current = TREE_CHAIN (current))
10056 /* We build the assignment expression that will initialize the
10057 field to its value. There are strict rules on static
10058 initializers (8.5). FIXME */
10059 tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10060 java_method_add_stmt (mdecl, stmt);
10063 end_artificial_method_body (mdecl);
10065 /* Now we want to place <clinit> as the last method for interface so
10066 that it doesn't interfere with the dispatch table based
10068 if (CLASS_INTERFACE (TYPE_NAME (class_type))
10069 && TREE_CHAIN (TYPE_METHODS (class_type)))
10072 TYPE_METHODS (class_type) = TREE_CHAIN (TYPE_METHODS (class_type));
10074 while (TREE_CHAIN (current))
10075 current = TREE_CHAIN (current);
10076 TREE_CHAIN (current) = mdecl;
10077 TREE_CHAIN (mdecl) = NULL_TREE;
10083 /* Complete and expand a method. */
10086 java_complete_expand_method (mdecl)
10089 current_function_decl = mdecl;
10090 /* Fix constructors before expanding them */
10091 if (DECL_CONSTRUCTOR_P (mdecl))
10092 fix_constructors (mdecl);
10094 /* Expand functions that have a body */
10095 if (DECL_FUNCTION_BODY (mdecl))
10097 tree fbody = DECL_FUNCTION_BODY (mdecl);
10098 tree block_body = BLOCK_EXPR_BODY (fbody);
10099 tree exception_copy = NULL_TREE;
10100 expand_start_java_method (mdecl);
10101 build_result_decl (mdecl);
10104 = (!METHOD_STATIC (mdecl) ?
10105 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10107 /* Purge the `throws' list of unchecked exceptions. If we're
10108 doing xref, save a copy of the list and re-install it
10110 if (flag_emit_xref)
10111 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10113 purge_unchecked_exceptions (mdecl);
10115 /* Install exceptions thrown with `throws' */
10116 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10118 if (block_body != NULL_TREE)
10120 block_body = java_complete_tree (block_body);
10122 if (!flag_emit_xref)
10123 check_for_initialization (block_body);
10124 ctxp->explicit_constructor_p = 0;
10126 BLOCK_EXPR_BODY (fbody) = block_body;
10128 /* If we saw a return but couldn't evaluate it properly, we'll
10129 have an error_mark_node here. */
10130 if (block_body != error_mark_node
10131 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10132 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10133 && !flag_emit_xref)
10134 missing_return_error (current_function_decl);
10136 complete_start_java_method (mdecl);
10138 /* Don't go any further if we've found error(s) during the
10140 if (!java_error_count)
10141 source_end_java_method ();
10144 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10145 poplevel (1, 0, 1);
10148 /* Pop the exceptions and sanity check */
10150 if (currently_caught_type_list)
10151 fatal ("Exception list non empty - java_complete_expand_method");
10153 if (flag_emit_xref)
10154 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10160 /* This section of the code deals with accessing enclosing context
10161 fields either directly by using the relevant access to this$<n> or
10162 by invoking an access method crafted for that purpose. */
10164 /* Build the necessary access from an inner class to an outer
10165 class. This routine could be optimized to cache previous result
10166 (decl, current_class and returned access). When an access method
10167 needs to be generated, it always takes the form of a read. It might
10168 be later turned into a write by calling outer_field_access_fix. */
10171 build_outer_field_access (id, decl)
10174 tree access = NULL_TREE;
10175 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10177 /* If decl's class is the direct outer class of the current_class,
10178 build the access as `this$<n>.<field>'. Not that we will break
10179 the `private' barrier if we're not emitting bytecodes. */
10180 if (ctx == DECL_CONTEXT (decl)
10181 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10183 tree thisn = build_current_thisn (current_class);
10184 access = make_qualified_primary (build_wfl_node (thisn),
10185 id, EXPR_WFL_LINECOL (id));
10187 /* Otherwise, generate access methods to outer this and access the
10188 field (either using an access method or by direct access.) */
10191 int lc = EXPR_WFL_LINECOL (id);
10193 /* Now we chain the required number of calls to the access$0 to
10194 get a hold to the enclosing instance we need, and the we
10195 build the field access. */
10196 access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10198 /* If the field is private and we're generating bytecode, then
10199 we generate an access method */
10200 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10202 tree name = build_outer_field_access_methods (decl);
10203 access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10204 name, access, NULL_TREE);
10206 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10207 Once again we break the `private' access rule from a foreign
10210 access = make_qualified_primary (access, id, lc);
10212 return resolve_expression_name (access, NULL);
10215 /* Return a non zero value if NODE describes an outer field inner
10219 outer_field_access_p (type, decl)
10222 if (!INNER_CLASS_TYPE_P (type)
10223 || TREE_CODE (decl) != FIELD_DECL
10224 || DECL_CONTEXT (decl) == type)
10227 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10228 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10230 if (type == DECL_CONTEXT (decl))
10232 if (!DECL_CONTEXT (TYPE_NAME (type)))
10239 /* Return a non zero value if NODE represents an outer field inner
10240 access that was been already expanded. As a side effect, it returns
10241 the name of the field being accessed and the argument passed to the
10242 access function, suitable for a regeneration of the access method
10243 call if necessary. */
10246 outer_field_expanded_access_p (node, name, arg_type, arg)
10247 tree node, *name, *arg_type, *arg;
10249 int identified = 0;
10251 if (TREE_CODE (node) != CALL_EXPR)
10254 /* Well, gcj generates slightly different tree nodes when compiling
10255 to native or bytecodes. It's the case for function calls. */
10257 if (flag_emit_class_files
10258 && TREE_CODE (node) == CALL_EXPR
10259 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10261 else if (!flag_emit_class_files)
10263 node = TREE_OPERAND (node, 0);
10265 if (node && TREE_OPERAND (node, 0)
10266 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10268 node = TREE_OPERAND (node, 0);
10269 if (TREE_OPERAND (node, 0)
10270 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10271 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
10272 (DECL_NAME (TREE_OPERAND (node, 0)))))
10277 if (identified && name && arg_type && arg)
10279 tree argument = TREE_OPERAND (node, 1);
10280 *name = DECL_NAME (TREE_OPERAND (node, 0));
10281 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10282 *arg = TREE_VALUE (argument);
10287 /* Detect in NODE an outer field read access from an inner class and
10288 transform it into a write with RHS as an argument. This function is
10289 called from the java_complete_lhs when an assignment to a LHS can
10293 outer_field_access_fix (wfl, node, rhs)
10294 tree wfl, node, rhs;
10296 tree name, arg_type, arg;
10298 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10300 /* At any rate, check whether we're trying to assign a value to
10302 tree accessed = (JDECL_P (node) ? node :
10303 (TREE_CODE (node) == COMPONENT_REF ?
10304 TREE_OPERAND (node, 1) : node));
10305 if (check_final_assignment (accessed, wfl))
10306 return error_mark_node;
10308 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
10309 arg_type, name, arg, rhs);
10310 return java_complete_tree (node);
10315 /* Construct the expression that calls an access method:
10316 <type>.access$<n>(<arg1> [, <arg2>]);
10318 ARG2 can be NULL and will be omitted in that case. It will denote a
10322 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10324 tree type, access_method_name, arg1, arg2;
10326 tree args, cn, access;
10328 args = arg1 ? arg1 :
10329 build_wfl_node (build_current_thisn (current_class));
10330 args = build_tree_list (NULL_TREE, args);
10333 args = tree_cons (NULL_TREE, arg2, args);
10335 access = build_method_invocation (build_wfl_node (access_method_name), args);
10336 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10337 return make_qualified_primary (cn, access, lc);
10341 build_new_access_id ()
10343 static int access_n_counter = 1;
10346 sprintf (buffer, "access$%d", access_n_counter++);
10347 return get_identifier (buffer);
10350 /* Create the static access functions for the outer field DECL. We define a
10352 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10353 return inst$.field;
10355 and a write access:
10356 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10357 TREE_TYPE (<field>) value$) {
10358 return inst$.field = value$;
10360 We should have a usage flags on the DECL so we can lazily turn the ones
10361 we're using for code generation. FIXME.
10365 build_outer_field_access_methods (decl)
10368 tree id, args, stmt, mdecl;
10370 /* Check point, to be removed. FIXME */
10371 if (FIELD_INNER_ACCESS (decl)
10372 && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10375 if (FIELD_INNER_ACCESS (decl))
10376 return FIELD_INNER_ACCESS (decl);
10378 push_obstacks (&permanent_obstack, &permanent_obstack);
10380 /* Create the identifier and a function named after it. */
10381 id = build_new_access_id ();
10383 /* The identifier is marked as bearing the name of a generated write
10384 access function for outer field accessed from inner classes. */
10385 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10387 /* Create the read access */
10388 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10389 TREE_CHAIN (args) = end_params_node;
10390 stmt = make_qualified_primary (build_wfl_node (inst_id),
10391 build_wfl_node (DECL_NAME (decl)), 0);
10392 stmt = build_return (0, stmt);
10393 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10394 TREE_TYPE (decl), id, args, stmt);
10395 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10397 /* Create the write access method */
10398 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10399 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10400 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10401 stmt = make_qualified_primary (build_wfl_node (inst_id),
10402 build_wfl_node (DECL_NAME (decl)), 0);
10403 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10404 build_wfl_node (wpv_id)));
10406 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10407 TREE_TYPE (decl), id, args, stmt);
10408 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10411 /* Return the access name */
10412 return FIELD_INNER_ACCESS (decl) = id;
10415 /* Build an field access method NAME. */
10418 build_outer_field_access_method (class, type, name, args, body)
10419 tree class, type, name, args, body;
10421 tree saved_current_function_decl, mdecl;
10423 /* Create the method */
10424 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10425 fix_method_argument_names (args, mdecl);
10426 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10428 /* Attach the method body. */
10429 saved_current_function_decl = current_function_decl;
10430 start_artificial_method_body (mdecl);
10431 java_method_add_stmt (mdecl, body);
10432 end_artificial_method_body (mdecl);
10433 current_function_decl = saved_current_function_decl;
10439 /* This section deals with building access function necessary for
10440 certain kinds of method invocation from inner classes. */
10443 build_outer_method_access_method (decl)
10446 tree saved_current_function_decl, mdecl;
10447 tree args = NULL_TREE, call_args = NULL_TREE;
10448 tree carg, id, body, class;
10450 int parm_id_count = 0;
10452 /* Test this abort with an access to a private field */
10453 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10456 /* Check the cache first */
10457 if (DECL_FUNCTION_INNER_ACCESS (decl))
10458 return DECL_FUNCTION_INNER_ACCESS (decl);
10460 class = DECL_CONTEXT (decl);
10462 /* Obtain an access identifier and mark it */
10463 id = build_new_access_id ();
10464 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10466 push_obstacks (&permanent_obstack, &permanent_obstack);
10468 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10469 /* Create the arguments, as much as the original */
10470 for (; carg && carg != end_params_node;
10471 carg = TREE_CHAIN (carg))
10473 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10474 args = chainon (args, build_tree_list (get_identifier (buffer),
10475 TREE_VALUE (carg)));
10477 args = chainon (args, end_params_node);
10479 /* Create the method */
10480 mdecl = create_artificial_method (class, ACC_STATIC,
10481 TREE_TYPE (TREE_TYPE (decl)), id, args);
10482 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10483 /* There is a potential bug here. We should be able to use
10484 fix_method_argument_names, but then arg names get mixed up and
10485 eventually a constructor will have its this$0 altered and the
10486 outer context won't be assignment properly. The test case is
10488 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10490 /* Attach the method body. */
10491 saved_current_function_decl = current_function_decl;
10492 start_artificial_method_body (mdecl);
10494 /* The actual method invocation uses the same args. When invoking a
10495 static methods that way, we don't want to skip the first
10498 if (!METHOD_STATIC (decl))
10499 carg = TREE_CHAIN (carg);
10500 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10501 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10504 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
10506 if (!METHOD_STATIC (decl))
10507 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
10509 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10510 body = build_return (0, body);
10511 java_method_add_stmt (mdecl,body);
10512 end_artificial_method_body (mdecl);
10513 current_function_decl = saved_current_function_decl;
10516 /* Back tag the access function so it know what it accesses */
10517 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10519 /* Tag the current method so it knows it has an access generated */
10520 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10524 /* This section of the code deals with building expressions to access
10525 the enclosing instance of an inner class. The enclosing instance is
10526 kept in a generated field called this$<n>, with <n> being the
10527 inner class nesting level (starting from 0.) */
10529 /* Build an access to a given this$<n>, possibly by chaining access
10530 call to others. Access methods to this$<n> are build on the fly if
10534 build_access_to_thisn (from, to, lc)
10538 tree access = NULL_TREE;
10542 tree access0_wfl, cn;
10544 maybe_build_thisn_access_method (from);
10545 access0_wfl = build_wfl_node (access0_identifier_node);
10546 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10547 EXPR_WFL_LINECOL (access0_wfl) = lc;
10551 access = build_current_thisn (current_class);
10552 access = build_wfl_node (access);
10554 access = build_tree_list (NULL_TREE, access);
10555 access = build_method_invocation (access0_wfl, access);
10556 access = make_qualified_primary (cn, access, lc);
10558 from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10563 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10564 is returned if nothing needs to be generated. Otherwise, the method
10565 generated, fully walked and a method decl is returned.
10567 NOTE: These generated methods should be declared in a class file
10568 attribute so that they can't be referred to directly. */
10571 maybe_build_thisn_access_method (type)
10574 tree mdecl, args, stmt, rtype;
10575 tree saved_current_function_decl;
10577 /* If TYPE is a top-level class, no access method is required.
10578 If there already is such an access method, bail out. */
10579 if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10582 /* We generate the method. The method looks like:
10583 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10585 push_obstacks (&permanent_obstack, &permanent_obstack);
10586 args = build_tree_list (inst_id, build_pointer_type (type));
10587 TREE_CHAIN (args) = end_params_node;
10588 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10589 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10590 access0_identifier_node, args);
10591 fix_method_argument_names (args, mdecl);
10592 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10593 stmt = build_current_thisn (type);
10594 stmt = make_qualified_primary (build_wfl_node (inst_id),
10595 build_wfl_node (stmt), 0);
10596 stmt = build_return (0, stmt);
10598 saved_current_function_decl = current_function_decl;
10599 start_artificial_method_body (mdecl);
10600 java_method_add_stmt (mdecl, stmt);
10601 end_artificial_method_body (mdecl);
10602 current_function_decl = saved_current_function_decl;
10605 CLASS_ACCESS0_GENERATED_P (type) = 1;
10610 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10611 the first level of innerclassing. this$1 for the next one, etc...
10612 This function can be invoked with TYPE to NULL, available and then
10613 has to count the parser context. */
10616 build_current_thisn (type)
10619 static int saved_i = -1;
10620 static tree saved_thisn = NULL_TREE;
10628 static tree saved_type = NULL_TREE;
10629 static int saved_type_i = 0;
10631 if (type == saved_type)
10635 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
10636 decl; decl = DECL_CONTEXT (decl), i++)
10644 i = list_length (GET_CPC_LIST ())-2;
10647 return saved_thisn;
10649 sprintf (buffer, "this$%d", i);
10651 saved_thisn = get_identifier (buffer);
10652 return saved_thisn;
10655 /* Return the assignement to the hidden enclosing context `this$<n>'
10656 by the second incoming parameter to the innerclass constructor. The
10657 form used is `this.this$<n> = this$<n>;'. */
10660 build_thisn_assign ()
10662 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10664 tree thisn = build_current_thisn (current_class);
10665 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10666 build_wfl_node (thisn), 0);
10667 tree rhs = build_wfl_node (thisn);
10668 EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10669 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10675 /* Building the synthetic `class$' used to implement the `.class' 1.1
10676 extension for non primitive types. This method looks like:
10678 static Class class$(String type) throws NoClassDefFoundError
10680 try {return (java.lang.Class.forName (String));}
10681 catch (ClassNotFoundException e) {
10682 throw new NoClassDefFoundError(e.getMessage());}
10686 build_dot_class_method (class)
10689 #define BWF(S) build_wfl_node (get_identifier ((S)))
10690 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10691 tree args, tmp, saved_current_function_decl, mdecl;
10692 tree stmt, throw_stmt, catch, catch_block, try_block;
10693 tree catch_clause_param;
10694 tree class_not_found_exception, no_class_def_found_error;
10696 static tree get_message_wfl, type_parm_wfl;
10698 if (!get_message_wfl)
10700 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10701 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10704 /* Build the arguments */
10705 args = build_tree_list (get_identifier ("type$"),
10706 build_pointer_type (string_type_node));
10707 TREE_CHAIN (args) = end_params_node;
10709 /* Build the qualified name java.lang.Class.forName */
10710 tmp = MQN (MQN (MQN (BWF ("java"),
10711 BWF ("lang")), BWF ("Class")), BWF ("forName"));
10713 /* For things we have to catch and throw */
10714 class_not_found_exception =
10715 lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10716 no_class_def_found_error =
10717 lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10718 load_class (class_not_found_exception, 1);
10719 load_class (no_class_def_found_error, 1);
10721 /* Create the "class$" function */
10722 mdecl = create_artificial_method (class, ACC_STATIC,
10723 build_pointer_type (class_type_node),
10724 get_identifier ("class$"), args);
10725 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10726 no_class_def_found_error);
10728 /* We start by building the try block. We need to build:
10729 return (java.lang.Class.forName (type)); */
10730 stmt = build_method_invocation (tmp,
10731 build_tree_list (NULL_TREE, type_parm_wfl));
10732 stmt = build_return (0, stmt);
10733 /* Put it in a block. That's the try block */
10734 try_block = build_expr_block (stmt, NULL_TREE);
10736 /* Now onto the catch block. We start by building the expression
10737 throwing a new exception:
10738 throw new NoClassDefFoundError (_.getMessage); */
10739 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
10740 get_message_wfl, 0);
10741 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10743 /* Build new NoClassDefFoundError (_.getMessage) */
10744 throw_stmt = build_new_invocation
10745 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10746 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10748 /* Build the throw, (it's too early to use BUILD_THROW) */
10749 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10751 /* Build the catch block to encapsulate all this. We begin by
10752 building an decl for the catch clause parameter and link it to
10753 newly created block, the catch block. */
10754 catch_clause_param =
10755 build_decl (VAR_DECL, wpv_id,
10756 build_pointer_type (class_not_found_exception));
10757 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10759 /* We initialize the variable with the exception handler. */
10760 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10761 soft_exceptioninfo_call_node);
10762 add_stmt_to_block (catch_block, NULL_TREE, catch);
10764 /* We add the statement throwing the new exception */
10765 add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10767 /* Build a catch expression for all this */
10768 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10770 /* Build the try/catch sequence */
10771 stmt = build_try_statement (0, try_block, catch_block);
10773 fix_method_argument_names (args, mdecl);
10774 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10775 saved_current_function_decl = current_function_decl;
10776 start_artificial_method_body (mdecl);
10777 java_method_add_stmt (mdecl, stmt);
10778 end_artificial_method_body (mdecl);
10779 current_function_decl = saved_current_function_decl;
10780 TYPE_DOT_CLASS (class) = mdecl;
10786 build_dot_class_method_invocation (name)
10789 tree s = make_node (STRING_CST);
10790 TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10791 TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10792 TREE_STRING_LENGTH (s)+1);
10793 strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10794 return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10795 build_tree_list (NULL_TREE, s));
10798 /* This section of the code deals with constructor. */
10800 /* Craft a body for default constructor. Patch existing constructor
10801 bodies with call to super() and field initialization statements if
10805 fix_constructors (mdecl)
10808 tree body = DECL_FUNCTION_BODY (mdecl);
10809 tree thisn_assign, compound = NULL_TREE;
10810 tree class_type = DECL_CONTEXT (mdecl);
10814 /* It is an error for the compiler to generate a default
10815 constructor if the superclass doesn't have a constructor that
10816 takes no argument, or the same args for an anonymous class */
10817 if (verify_constructor_super (mdecl))
10819 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10820 tree save = DECL_NAME (mdecl);
10821 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10822 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10823 parse_error_context
10824 (lookup_cl (TYPE_NAME (class_type)),
10825 "No constructor matching `%s' found in class `%s'",
10826 lang_printable_name (mdecl, 0), n);
10827 DECL_NAME (mdecl) = save;
10830 /* The constructor body must be crafted by hand. It's the
10831 constructor we defined when we realize we didn't have the
10832 CLASSNAME() constructor */
10833 start_artificial_method_body (mdecl);
10835 /* We don't generate a super constructor invocation if we're
10836 compiling java.lang.Object. build_super_invocation takes care
10838 compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10840 /* Insert the instance initializer block right here, after the
10841 super invocation. */
10842 add_instance_initializer (mdecl);
10844 /* Insert an assignment to the this$<n> hidden field, if
10846 if ((thisn_assign = build_thisn_assign ()))
10847 java_method_add_stmt (mdecl, thisn_assign);
10849 end_artificial_method_body (mdecl);
10851 /* Search for an explicit constructor invocation */
10855 tree main_block = BLOCK_EXPR_BODY (body);
10858 switch (TREE_CODE (body))
10861 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10864 case COMPOUND_EXPR:
10865 case EXPR_WITH_FILE_LOCATION:
10866 body = TREE_OPERAND (body, 0);
10869 body = BLOCK_EXPR_BODY (body);
10875 /* The constructor is missing an invocation of super() */
10877 compound = add_stmt_to_compound (compound, NULL_TREE,
10878 build_super_invocation (mdecl));
10880 /* Insert the instance initializer block right here, after the
10881 super invocation. */
10882 add_instance_initializer (mdecl);
10884 /* Generate the assignment to this$<n>, if necessary */
10885 if ((thisn_assign = build_thisn_assign ()))
10886 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10888 /* Fix the constructor main block if we're adding extra stmts */
10891 compound = add_stmt_to_compound (compound, NULL_TREE,
10892 BLOCK_EXPR_BODY (main_block));
10893 BLOCK_EXPR_BODY (main_block) = compound;
10898 /* Browse constructors in the super class, searching for a constructor
10899 that doesn't take any argument. Return 0 if one is found, 1
10900 otherwise. If the current class is an anonymous inner class, look
10901 for something that has the same signature. */
10904 verify_constructor_super (mdecl)
10907 tree class = CLASSTYPE_SUPER (current_class);
10913 if (ANONYMOUS_CLASS_P (current_class))
10915 tree mdecl_arg_type;
10916 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10917 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10918 if (DECL_CONSTRUCTOR_P (sdecl))
10921 for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
10922 arg_type != end_params_node &&
10923 mdecl_arg_type != end_params_node;
10924 arg_type = TREE_CHAIN (arg_type),
10925 mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
10926 if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
10929 if (arg_type == end_params_node &&
10930 mdecl_arg_type == end_params_node)
10936 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10938 if (DECL_CONSTRUCTOR_P (sdecl)
10939 && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)))
10940 == end_params_node)
10947 /* Generate code for all context remembered for code generation. */
10950 java_expand_classes ()
10952 int save_error_count = 0;
10953 static struct parser_ctxt *saved_ctxp = NULL;
10955 java_parse_abort_on_error ();
10956 if (!(ctxp = ctxp_for_generation))
10958 java_layout_classes ();
10959 java_parse_abort_on_error ();
10961 /* The list of packages declaration seen so far needs to be
10962 reversed, so that package declared in a file being compiled gets
10963 priority over packages declared as a side effect of parsing other
10965 package_list = nreverse (package_list);
10967 saved_ctxp = ctxp_for_generation;
10968 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10970 ctxp = ctxp_for_generation;
10971 lang_init_source (2); /* Error msgs have method prototypes */
10972 java_complete_expand_classes (); /* Complete and expand classes */
10973 java_parse_abort_on_error ();
10976 /* Find anonymous classes and expand their constructor, now they
10977 have been fixed. */
10978 for (ctxp_for_generation = saved_ctxp;
10979 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10982 ctxp = ctxp_for_generation;
10983 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10985 current_class = TREE_TYPE (current);
10986 if (ANONYMOUS_CLASS_P (current_class))
10989 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
10991 if (DECL_CONSTRUCTOR_P (d))
10993 restore_line_number_status (1);
10994 reset_method_name (d);
10995 java_complete_expand_method (d);
10996 restore_line_number_status (0);
10997 break; /* We now there are no other ones */
11004 /* If we've found error at that stage, don't try to generate
11005 anything, unless we're emitting xrefs or checking the syntax only
11006 (but not using -fsyntax-only for the purpose of generating
11008 if (java_error_count && !flag_emit_xref
11009 && (!flag_syntax_only && !flag_emit_class_files))
11012 /* Now things are stable, go for generation of the class data. */
11013 for (ctxp_for_generation = saved_ctxp;
11014 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
11017 ctxp = ctxp_for_generation;
11018 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11020 current_class = TREE_TYPE (current);
11021 outgoing_cpool = TYPE_CPOOL (current_class);
11022 if (flag_emit_class_files)
11023 write_classfile (current_class);
11024 if (flag_emit_xref)
11025 expand_xref (current_class);
11026 else if (! flag_syntax_only)
11032 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11033 a tree list node containing RIGHT. Fore coming RIGHTs will be
11034 chained to this hook. LOCATION contains the location of the
11035 separating `.' operator. */
11038 make_qualified_primary (primary, right, location)
11039 tree primary, right;
11044 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11045 wfl = build_wfl_wrap (primary);
11049 /* If wfl wasn't qualified, we build a first anchor */
11050 if (!EXPR_WFL_QUALIFICATION (wfl))
11051 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11054 /* And chain them */
11055 EXPR_WFL_LINECOL (right) = location;
11056 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11057 PRIMARY_P (wfl) = 1;
11061 /* Simple merge of two name separated by a `.' */
11064 merge_qualified_name (left, right)
11068 if (!left && !right)
11077 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11078 IDENTIFIER_LENGTH (left));
11079 obstack_1grow (&temporary_obstack, '.');
11080 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11081 IDENTIFIER_LENGTH (right));
11082 node = get_identifier (obstack_base (&temporary_obstack));
11083 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11084 QUALIFIED_P (node) = 1;
11088 /* Merge the two parts of a qualified name into LEFT. Set the
11089 location information of the resulting node to LOCATION, usually
11090 inherited from the location information of the `.' operator. */
11093 make_qualified_name (left, right, location)
11097 #ifdef USE_COMPONENT_REF
11098 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11099 EXPR_WFL_LINECOL (node) = location;
11102 tree left_id = EXPR_WFL_NODE (left);
11103 tree right_id = EXPR_WFL_NODE (right);
11106 merge = merge_qualified_name (left_id, right_id);
11108 /* Left wasn't qualified and is now qualified */
11109 if (!QUALIFIED_P (left_id))
11111 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11112 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11113 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11116 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11117 EXPR_WFL_LINECOL (wfl) = location;
11118 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11120 EXPR_WFL_NODE (left) = merge;
11125 /* Extract the last identifier component of the qualified in WFL. The
11126 last identifier is removed from the linked list */
11129 cut_identifier_in_qualified (wfl)
11133 tree previous = NULL_TREE;
11134 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11135 if (!TREE_CHAIN (q))
11138 fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11139 TREE_CHAIN (previous) = NULL_TREE;
11140 return TREE_PURPOSE (q);
11144 /* Resolve the expression name NAME. Return its decl. */
11147 resolve_expression_name (id, orig)
11151 tree name = EXPR_WFL_NODE (id);
11154 /* 6.5.5.1: Simple expression names */
11155 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11157 /* 15.13.1: NAME can appear within the scope of a local variable
11159 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11162 /* 15.13.1: NAME can appear within a class declaration */
11165 decl = lookup_field_wrapper (current_class, name);
11168 tree access = NULL_TREE;
11169 int fs = FIELD_STATIC (decl);
11171 /* If we're accessing an outer scope local alias, make
11172 sure we change the name of the field we're going to
11173 build access to. */
11174 if (FIELD_LOCAL_ALIAS_USED (decl))
11175 name = DECL_NAME (decl);
11177 /* Instance variable (8.3.1.1) can't appear within
11178 static method, static initializer or initializer for
11179 a static variable. */
11180 if (!fs && METHOD_STATIC (current_function_decl))
11182 static_ref_err (id, name, current_class);
11183 return error_mark_node;
11185 /* Instance variables can't appear as an argument of
11186 an explicit constructor invocation */
11187 if (!fs && ctxp->explicit_constructor_p)
11189 parse_error_context
11190 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11191 return error_mark_node;
11194 /* If we're processing an inner class and we're trying
11195 to access a field belonging to an outer class, build
11196 the access to the field */
11197 if (!fs && outer_field_access_p (current_class, decl))
11198 return build_outer_field_access (id, decl);
11200 /* Otherwise build what it takes to access the field */
11201 access = build_field_ref ((fs ? NULL_TREE : current_this),
11202 DECL_CONTEXT (decl), name);
11203 if (fs && !flag_emit_class_files && !flag_emit_xref)
11204 access = build_class_init (DECL_CONTEXT (access), access);
11205 /* We may be asked to save the real field access node */
11208 /* And we return what we got */
11211 /* Fall down to error report on undefined variable */
11214 /* 6.5.5.2 Qualified Expression Names */
11219 qualify_ambiguous_name (id);
11220 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11221 /* 15.10.2: Accessing Superclass Members using super */
11222 return resolve_field_access (id, orig, NULL);
11225 /* We've got an error here */
11226 parse_error_context (id, "Undefined variable `%s'",
11227 IDENTIFIER_POINTER (name));
11229 return error_mark_node;
11233 static_ref_err (wfl, field_id, class_type)
11234 tree wfl, field_id, class_type;
11236 parse_error_context
11238 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11239 IDENTIFIER_POINTER (field_id),
11240 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11243 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11244 We return something suitable to generate the field access. We also
11245 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
11246 recipient's address can be null. */
11249 resolve_field_access (qual_wfl, field_decl, field_type)
11251 tree *field_decl, *field_type;
11255 tree decl, where_found, type_found;
11257 if (resolve_qualified_expression_name (qual_wfl, &decl,
11258 &where_found, &type_found))
11259 return error_mark_node;
11261 /* Resolve the LENGTH field of an array here */
11262 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11263 && ! flag_emit_class_files && ! flag_emit_xref)
11265 tree length = build_java_array_length_access (where_found);
11267 build_java_arraynull_check (type_found, length, int_type_node);
11269 /* We might have been trying to resolve field.method(). In which
11270 case, the resolution is over and decl is the answer */
11271 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11273 else if (JDECL_P (decl))
11275 int static_final_found = 0;
11277 type_found = DECL_CONTEXT (decl);
11278 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11279 if (FIELD_FINAL (decl)
11280 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11281 && DECL_LANG_SPECIFIC (decl)
11282 && DECL_INITIAL (decl))
11284 field_ref = DECL_INITIAL (decl);
11285 static_final_found = 1;
11288 field_ref = build_field_ref ((is_static && !flag_emit_xref?
11289 NULL_TREE : where_found),
11290 type_found, DECL_NAME (decl));
11291 if (field_ref == error_mark_node)
11292 return error_mark_node;
11293 if (is_static && !static_final_found
11294 && !flag_emit_class_files && !flag_emit_xref)
11295 field_ref = build_class_init (type_found, field_ref);
11301 *field_decl = decl;
11303 *field_type = (QUAL_DECL_TYPE (decl) ?
11304 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11308 /* If NODE is an access to f static field, strip out the class
11309 initialization part and return the field decl, otherwise, return
11313 strip_out_static_field_access_decl (node)
11316 if (TREE_CODE (node) == COMPOUND_EXPR)
11318 tree op1 = TREE_OPERAND (node, 1);
11319 if (TREE_CODE (op1) == COMPOUND_EXPR)
11321 tree call = TREE_OPERAND (op1, 0);
11322 if (TREE_CODE (call) == CALL_EXPR
11323 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11324 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11325 == soft_initclass_node)
11326 return TREE_OPERAND (op1, 1);
11328 else if (JDECL_P (op1))
11334 /* 6.5.5.2: Qualified Expression Names */
11337 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11339 tree *found_decl, *type_found, *where_found;
11341 int from_type = 0; /* Field search initiated from a type */
11342 int from_super = 0, from_cast = 0, from_qualified_this = 0;
11343 int previous_call_static = 0;
11345 tree decl = NULL_TREE, type = NULL_TREE, q;
11346 /* For certain for of inner class instantiation */
11347 tree saved_current, saved_this;
11348 #define RESTORE_THIS_AND_CURRENT_CLASS \
11349 { current_class = saved_current; current_this = saved_this;}
11351 *type_found = *where_found = NULL_TREE;
11353 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11355 tree qual_wfl = QUAL_WFL (q);
11356 tree ret_decl; /* for EH checking */
11357 int location; /* for EH checking */
11359 /* 15.10.1 Field Access Using a Primary */
11360 switch (TREE_CODE (qual_wfl))
11363 case NEW_CLASS_EXPR:
11364 /* If the access to the function call is a non static field,
11365 build the code to access it. */
11366 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11368 decl = maybe_access_field (decl, *where_found,
11369 DECL_CONTEXT (decl));
11370 if (decl == error_mark_node)
11374 /* And code for the function call */
11375 if (complete_function_arguments (qual_wfl))
11378 /* We might have to setup a new current class and a new this
11379 for the search of an inner class, relative to the type of
11380 a expression resolved as `decl'. The current values are
11381 saved and restored shortly after */
11382 saved_current = current_class;
11383 saved_this = current_this;
11384 if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11386 current_class = type;
11387 current_this = decl;
11390 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11391 CALL_USING_SUPER (qual_wfl) = 1;
11392 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11393 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11394 *where_found = patch_method_invocation (qual_wfl, decl, type,
11395 &is_static, &ret_decl);
11396 if (*where_found == error_mark_node)
11398 RESTORE_THIS_AND_CURRENT_CLASS;
11401 *type_found = type = QUAL_DECL_TYPE (*where_found);
11403 /* If we're creating an inner class instance, check for that
11404 an enclosing instance is in scope */
11405 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11406 && INNER_ENCLOSING_SCOPE_CHECK (type))
11408 parse_error_context
11409 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11410 lang_printable_name (type, 0),
11411 (!current_this ? "" :
11412 "; an explicit one must be provided when creating this inner class"));
11413 RESTORE_THIS_AND_CURRENT_CLASS;
11417 /* In case we had to change then to resolve a inner class
11418 instantiation using a primary qualified by a `new' */
11419 RESTORE_THIS_AND_CURRENT_CLASS;
11423 check_thrown_exceptions (location, ret_decl);
11425 /* If the previous call was static and this one is too,
11426 build a compound expression to hold the two (because in
11427 that case, previous function calls aren't transported as
11428 forcoming function's argument. */
11429 if (previous_call_static && is_static)
11431 decl = build (COMPOUND_EXPR, type, decl, *where_found);
11432 TREE_SIDE_EFFECTS (decl) = 1;
11436 previous_call_static = is_static;
11437 decl = *where_found;
11442 case NEW_ARRAY_EXPR:
11443 case NEW_ANONYMOUS_ARRAY_EXPR:
11444 *where_found = decl = java_complete_tree (qual_wfl);
11445 if (decl == error_mark_node)
11447 *type_found = type = QUAL_DECL_TYPE (decl);
11448 CLASS_LOADED_P (type) = 1;
11452 *where_found = decl = java_complete_tree (qual_wfl);
11453 if (decl == error_mark_node)
11455 *type_found = type = QUAL_DECL_TYPE (decl);
11459 case CONDITIONAL_EXPR:
11462 *where_found = decl = java_complete_tree (qual_wfl);
11463 if (decl == error_mark_node)
11465 *type_found = type = QUAL_DECL_TYPE (decl);
11469 /* If the access to the function call is a non static field,
11470 build the code to access it. */
11471 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11473 decl = maybe_access_field (decl, *where_found, type);
11474 if (decl == error_mark_node)
11477 /* And code for the array reference expression */
11478 decl = java_complete_tree (qual_wfl);
11479 if (decl == error_mark_node)
11481 type = QUAL_DECL_TYPE (decl);
11485 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11487 if ((type = patch_string (decl)))
11489 *where_found = QUAL_RESOLUTION (q) = decl;
11490 *type_found = type = TREE_TYPE (decl);
11493 case CLASS_LITERAL:
11494 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11496 *where_found = QUAL_RESOLUTION (q) = decl;
11497 *type_found = type = TREE_TYPE (decl);
11501 /* Fix for -Wall Just go to the next statement. Don't
11506 /* If we fall here, we weren't processing a (static) function call. */
11507 previous_call_static = 0;
11509 /* It can be the keyword THIS */
11510 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11514 parse_error_context
11515 (wfl, "Keyword `this' used outside allowed context");
11518 if (ctxp->explicit_constructor_p)
11520 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11523 /* We have to generate code for intermediate acess */
11524 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11526 *where_found = decl = current_this;
11527 *type_found = type = QUAL_DECL_TYPE (decl);
11529 /* We're trying to access the this from somewhere else... */
11532 *where_found = decl = build_current_thisn (type);
11533 from_qualified_this = 1;
11540 /* 15.10.2 Accessing Superclass Members using SUPER */
11541 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11544 /* Check on the restricted use of SUPER */
11545 if (METHOD_STATIC (current_function_decl)
11546 || current_class == object_type_node)
11548 parse_error_context
11549 (wfl, "Keyword `super' used outside allowed context");
11552 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11553 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
11554 CLASSTYPE_SUPER (current_class),
11555 build_this (EXPR_WFL_LINECOL (qual_wfl)));
11556 *where_found = decl = java_complete_tree (node);
11557 if (decl == error_mark_node)
11559 *type_found = type = QUAL_DECL_TYPE (decl);
11560 from_super = from_type = 1;
11564 /* 15.13.1: Can't search for field name in packages, so we
11565 assume a variable/class name was meant. */
11566 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11568 tree name = resolve_package (wfl, &q);
11572 *where_found = decl = resolve_no_layout (name, qual_wfl);
11573 /* We wan't to be absolutely that the class is laid
11574 out. We're going to search something inside it. */
11575 *type_found = type = TREE_TYPE (decl);
11576 layout_class (type);
11579 /* Fix them all the way down, if any are left. */
11582 list = TREE_CHAIN (q);
11585 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11586 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11587 list = TREE_CHAIN (list);
11593 if (from_super || from_cast)
11594 parse_error_context
11595 ((from_cast ? qual_wfl : wfl),
11596 "No variable `%s' defined in class `%s'",
11597 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11598 lang_printable_name (type, 0));
11600 parse_error_context
11601 (qual_wfl, "Undefined variable or class name: `%s'",
11602 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11607 /* We have a type name. It's been already resolved when the
11608 expression was qualified. */
11609 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11611 if (!(decl = QUAL_RESOLUTION (q)))
11612 return 1; /* Error reported already */
11614 /* Sneak preview. If next we see a `new', we're facing a
11615 qualification with resulted in a type being selected
11616 instead of a field. Report the error */
11618 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11620 parse_error_context (qual_wfl, "Undefined variable `%s'",
11621 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11625 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11627 parse_error_context
11628 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11629 java_accstring_lookup (get_access_flags_from_decl (decl)),
11630 GET_TYPE_NAME (type),
11631 IDENTIFIER_POINTER (DECL_NAME (decl)),
11632 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11635 check_deprecation (qual_wfl, decl);
11637 type = TREE_TYPE (decl);
11640 /* We resolve and expression name */
11643 tree field_decl = NULL_TREE;
11645 /* If there exists an early resolution, use it. That occurs
11646 only once and we know that there are more things to
11647 come. Don't do that when processing something after SUPER
11648 (we need more thing to be put in place below */
11649 if (!from_super && QUAL_RESOLUTION (q))
11651 decl = QUAL_RESOLUTION (q);
11654 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11657 *where_found = current_this;
11660 static_ref_err (qual_wfl, DECL_NAME (decl),
11667 *where_found = TREE_TYPE (decl);
11668 if (TREE_CODE (*where_found) == POINTER_TYPE)
11669 *where_found = TREE_TYPE (*where_found);
11674 /* We have to search for a field, knowing the type of its
11675 container. The flag FROM_TYPE indicates that we resolved
11676 the last member of the expression as a type name, which
11677 means that for the resolution of this field, we'll look
11678 for other errors than if it was resolved as a member of
11683 tree field_decl_type; /* For layout */
11685 if (!from_type && !JREFERENCE_TYPE_P (type))
11687 parse_error_context
11688 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11689 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11690 lang_printable_name (type, 0),
11691 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11695 field_decl = lookup_field_wrapper (type,
11696 EXPR_WFL_NODE (qual_wfl));
11697 if (field_decl == NULL_TREE)
11699 parse_error_context
11700 (qual_wfl, "No variable `%s' defined in type `%s'",
11701 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11702 GET_TYPE_NAME (type));
11705 if (field_decl == error_mark_node)
11708 /* Layout the type of field_decl, since we may need
11709 it. Don't do primitive types or loaded classes. The
11710 situation of non primitive arrays may not handled
11711 properly here. FIXME */
11712 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11713 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11715 field_decl_type = TREE_TYPE (field_decl);
11716 if (!JPRIMITIVE_TYPE_P (field_decl_type)
11717 && !CLASS_LOADED_P (field_decl_type)
11718 && !TYPE_ARRAY_P (field_decl_type))
11719 resolve_and_layout (field_decl_type, NULL_TREE);
11720 if (TYPE_ARRAY_P (field_decl_type))
11721 CLASS_LOADED_P (field_decl_type) = 1;
11723 /* Check on accessibility here */
11724 if (not_accessible_p (type, field_decl, from_super))
11726 parse_error_context
11728 "Can't access %s field `%s.%s' from `%s'",
11729 java_accstring_lookup
11730 (get_access_flags_from_decl (field_decl)),
11731 GET_TYPE_NAME (type),
11732 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11734 (DECL_NAME (TYPE_NAME (current_class))));
11737 check_deprecation (qual_wfl, field_decl);
11739 /* There are things to check when fields are accessed
11740 from type. There are no restrictions on a static
11741 declaration of the field when it is accessed from an
11743 is_static = FIELD_STATIC (field_decl);
11744 if (!from_super && from_type
11745 && !TYPE_INTERFACE_P (type)
11747 && (current_function_decl
11748 && METHOD_STATIC (current_function_decl)))
11750 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11753 from_cast = from_super = 0;
11755 /* It's an access from a type but it isn't static, we
11756 make it relative to `this'. */
11757 if (!is_static && from_type)
11758 decl = current_this;
11760 /* If we need to generate something to get a proper
11761 handle on what this field is accessed from, do it
11765 decl = maybe_access_field (decl, *where_found, *type_found);
11766 if (decl == error_mark_node)
11770 /* We want to keep the location were found it, and the type
11772 *where_found = decl;
11773 *type_found = type;
11775 /* Generate the correct expression for field access from
11777 if (from_qualified_this)
11779 field_decl = build_outer_field_access (qual_wfl, field_decl);
11780 from_qualified_this = 0;
11783 /* This is the decl found and eventually the next one to
11788 type = QUAL_DECL_TYPE (decl);
11790 /* Sneak preview. If decl is qualified by a `new', report
11791 the error here to be accurate on the peculiar construct */
11793 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11794 && !JREFERENCE_TYPE_P (type))
11796 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
11797 lang_printable_name (type, 0));
11801 /* `q' might have changed due to a after package resolution
11802 re-qualification */
11806 *found_decl = decl;
11810 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11811 can't be accessed from REFERENCE (a record type). */
11814 not_accessible_p (reference, member, from_super)
11815 tree reference, member;
11818 int access_flag = get_access_flags_from_decl (member);
11820 /* Access always granted for members declared public */
11821 if (access_flag & ACC_PUBLIC)
11824 /* Check access on protected members */
11825 if (access_flag & ACC_PROTECTED)
11827 /* Access granted if it occurs from within the package
11828 containing the class in which the protected member is
11830 if (class_in_current_package (DECL_CONTEXT (member)))
11833 /* If accessed with the form `super.member', then access is granted */
11837 /* Otherwise, access is granted if occuring from the class where
11838 member is declared or a subclass of it */
11839 if (inherits_from_p (reference, DECL_CONTEXT (member)))
11844 /* Check access on private members. Access is granted only if it
11845 occurs from within the class in which it is declared. Exceptions
11846 are accesses from inner-classes. This section is probably not
11848 if (access_flag & ACC_PRIVATE)
11849 return (current_class == DECL_CONTEXT (member) ? 0 :
11850 (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11852 /* Default access are permitted only when occuring within the
11853 package in which the type (REFERENCE) is declared. In other words,
11854 REFERENCE is defined in the current package */
11856 return !class_in_current_package (reference);
11858 /* Otherwise, access is granted */
11862 /* Test deprecated decl access. */
11864 check_deprecation (wfl, decl)
11867 const char *file = DECL_SOURCE_FILE (decl);
11868 /* Complain if the field is deprecated and the file it was defined
11869 in isn't compiled at the same time the file which contains its
11871 if (DECL_DEPRECATED (decl)
11872 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11875 switch (TREE_CODE (decl))
11877 case FUNCTION_DECL:
11878 strcpy (the, "method");
11881 strcpy (the, "field");
11884 strcpy (the, "class");
11887 fatal ("unexpected DECL code - check_deprecation");
11889 parse_warning_context
11890 (wfl, "The %s `%s' in class `%s' has been deprecated",
11891 the, lang_printable_name (decl, 0),
11892 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11896 /* Returns 1 if class was declared in the current package, 0 otherwise */
11899 class_in_current_package (class)
11902 static tree cache = NULL_TREE;
11903 int qualified_flag;
11906 if (cache == class)
11909 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11911 /* If the current package is empty and the name of CLASS is
11912 qualified, class isn't in the current package. If there is a
11913 current package and the name of the CLASS is not qualified, class
11914 isn't in the current package */
11915 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11918 /* If there is not package and the name of CLASS isn't qualified,
11919 they belong to the same unnamed package */
11920 if (!ctxp->package && !qualified_flag)
11923 /* Compare the left part of the name of CLASS with the package name */
11924 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
11925 if (ctxp->package == left)
11933 /* This function may generate code to access DECL from WHERE. This is
11934 done only if certain conditions meet. */
11937 maybe_access_field (decl, where, type)
11938 tree decl, where, type;
11940 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
11941 && !FIELD_STATIC (decl))
11942 decl = build_field_ref (where ? where : current_this,
11943 (type ? type : DECL_CONTEXT (decl)),
11948 /* Build a method invocation, by patching PATCH. If non NULL
11949 and according to the situation, PRIMARY and WHERE may be
11950 used. IS_STATIC is set to 1 if the invoked function is static. */
11953 patch_method_invocation (patch, primary, where, is_static, ret_decl)
11954 tree patch, primary, where;
11958 tree wfl = TREE_OPERAND (patch, 0);
11959 tree args = TREE_OPERAND (patch, 1);
11960 tree name = EXPR_WFL_NODE (wfl);
11962 int is_static_flag = 0;
11963 int is_super_init = 0;
11964 tree this_arg = NULL_TREE;
11966 /* Should be overriden if everything goes well. Otherwise, if
11967 something fails, it should keep this value. It stop the
11968 evaluation of a bogus assignment. See java_complete_tree,
11969 MODIFY_EXPR: for the reasons why we sometimes want to keep on
11970 evaluating an assignment */
11971 TREE_TYPE (patch) = error_mark_node;
11973 /* Since lookup functions are messing with line numbers, save the
11975 java_parser_context_save_global ();
11977 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
11979 /* Resolution of qualified name, excluding constructors */
11980 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
11982 tree identifier, identifier_wfl, type, resolved;
11983 /* Extract the last IDENTIFIER of the qualified
11984 expression. This is a wfl and we will use it's location
11985 data during error report. */
11986 identifier_wfl = cut_identifier_in_qualified (wfl);
11987 identifier = EXPR_WFL_NODE (identifier_wfl);
11989 /* Given the context, IDENTIFIER is syntactically qualified
11990 as a MethodName. We need to qualify what's before */
11991 qualify_ambiguous_name (wfl);
11992 resolved = resolve_field_access (wfl, NULL, NULL);
11994 if (resolved == error_mark_node)
11995 PATCH_METHOD_RETURN_ERROR ();
11997 type = GET_SKIP_TYPE (resolved);
11998 resolve_and_layout (type, NULL_TREE);
11999 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
12000 args = nreverse (args);
12002 /* We're resolving a call from a type */
12003 if (TREE_CODE (resolved) == TYPE_DECL)
12005 if (CLASS_INTERFACE (resolved))
12007 parse_error_context
12009 "Can't make static reference to method `%s' in interface `%s'",
12010 IDENTIFIER_POINTER (identifier),
12011 IDENTIFIER_POINTER (name));
12012 PATCH_METHOD_RETURN_ERROR ();
12014 if (list && !METHOD_STATIC (list))
12016 char *fct_name = xstrdup (lang_printable_name (list, 0));
12017 parse_error_context
12019 "Can't make static reference to method `%s %s' in class `%s'",
12020 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12021 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12023 PATCH_METHOD_RETURN_ERROR ();
12027 this_arg = primary = resolved;
12029 /* IDENTIFIER_WFL will be used to report any problem further */
12030 wfl = identifier_wfl;
12032 /* Resolution of simple names, names generated after a primary: or
12036 tree class_to_search = NULL_TREE;
12037 int lc; /* Looking for Constructor */
12039 /* We search constructor in their target class */
12040 if (CALL_CONSTRUCTOR_P (patch))
12042 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12043 class_to_search = EXPR_WFL_NODE (wfl);
12044 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12045 this_identifier_node)
12046 class_to_search = NULL_TREE;
12047 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12048 super_identifier_node)
12051 if (CLASSTYPE_SUPER (current_class))
12053 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12056 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12057 PATCH_METHOD_RETURN_ERROR ();
12061 /* Class to search is NULL if we're searching the current one */
12062 if (class_to_search)
12064 class_to_search = resolve_and_layout (class_to_search, wfl);
12066 if (!class_to_search)
12068 parse_error_context
12069 (wfl, "Class `%s' not found in type declaration",
12070 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12071 PATCH_METHOD_RETURN_ERROR ();
12074 /* Can't instantiate an abstract class, but we can
12075 invoke it's constructor. It's use within the `new'
12076 context is denied here. */
12077 if (CLASS_ABSTRACT (class_to_search)
12078 && TREE_CODE (patch) == NEW_CLASS_EXPR)
12080 parse_error_context
12081 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12082 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12083 PATCH_METHOD_RETURN_ERROR ();
12086 class_to_search = TREE_TYPE (class_to_search);
12089 class_to_search = current_class;
12092 /* This is a regular search in the local class, unless an
12093 alternate class is specified. */
12096 class_to_search = (where ? where : current_class);
12100 /* NAME is a simple identifier or comes from a primary. Search
12101 in the class whose declaration contain the method being
12103 resolve_and_layout (class_to_search, NULL_TREE);
12105 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12106 /* Don't continue if no method were found, as the next statement
12107 can't be executed then. */
12109 PATCH_METHOD_RETURN_ERROR ();
12111 /* Check for static reference if non static methods */
12112 if (check_for_static_method_reference (wfl, patch, list,
12113 class_to_search, primary))
12114 PATCH_METHOD_RETURN_ERROR ();
12116 /* Check for inner classes creation from illegal contexts */
12117 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12118 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12119 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12121 parse_error_context
12122 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12123 lang_printable_name (class_to_search, 0),
12124 (!current_this ? "" :
12125 "; an explicit one must be provided when creating this inner class"));
12126 PATCH_METHOD_RETURN_ERROR ();
12129 /* Non static methods are called with the current object extra
12130 argument. If patch a `new TYPE()', the argument is the value
12131 returned by the object allocator. If method is resolved as a
12132 primary, use the primary otherwise use the current THIS. */
12133 args = nreverse (args);
12134 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12136 this_arg = primary ? primary : current_this;
12138 /* If we're using an access method, things are different.
12139 There are two familly of cases:
12141 1) We're not generating bytecodes:
12143 - LIST is non static. It's invocation is transformed from
12144 x(a1,...,an) into this$<n>.x(a1,....an).
12145 - LIST is static. It's invocation is transformed from
12146 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12148 2) We're generating bytecodes:
12150 - LIST is non static. It's invocation is transformed from
12151 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12152 - LIST is static. It's invocation is transformed from
12153 x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12155 Of course, this$<n> can be abitrary complex, ranging from
12156 this$0 (the immediate outer context) to
12157 access$0(access$0(...(this$0))).
12159 maybe_use_access_method returns a non zero value if the
12160 this_arg has to be moved into the (then generated) stub
12161 argument list. In the mean time, the selected function
12162 might have be replaced by a generated stub. */
12163 if (maybe_use_access_method (is_super_init, &list, &this_arg))
12164 args = tree_cons (NULL_TREE, this_arg, args);
12168 /* Merge point of all resolution schemes. If we have nothing, this
12169 is an error, already signaled */
12171 PATCH_METHOD_RETURN_ERROR ();
12173 /* Check accessibility, position the is_static flag, build and
12175 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12177 char *fct_name = xstrdup (lang_printable_name (list, 0));
12178 parse_error_context
12179 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12180 java_accstring_lookup (get_access_flags_from_decl (list)),
12181 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12182 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
12183 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12185 PATCH_METHOD_RETURN_ERROR ();
12187 check_deprecation (wfl, list);
12189 /* If invoking a innerclass constructor, there are hidden parameters
12191 if (TREE_CODE (patch) == NEW_CLASS_EXPR
12192 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12194 /* And make sure we add the accessed local variables to be saved
12195 in field aliases. */
12196 args = build_alias_initializer_parameter_list
12197 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12199 /* We have to reverse things. Find out why. FIXME */
12200 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12201 args = nreverse (args);
12203 /* Secretely pass the current_this/primary as a second argument */
12204 if (primary || current_this)
12205 args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12207 args = tree_cons (NULL_TREE, integer_zero_node, args);
12210 is_static_flag = METHOD_STATIC (list);
12211 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12212 args = tree_cons (NULL_TREE, this_arg, args);
12214 /* In the context of an explicit constructor invocation, we can't
12215 invoke any method relying on `this'. Exceptions are: we're
12216 invoking a static function, primary exists and is not the current
12217 this, we're creating a new object. */
12218 if (ctxp->explicit_constructor_p
12220 && (!primary || primary == current_this)
12221 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12223 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12224 PATCH_METHOD_RETURN_ERROR ();
12226 java_parser_context_restore_global ();
12228 *is_static = is_static_flag;
12229 /* Sometimes, we want the decl of the selected method. Such as for
12233 patch = patch_invoke (patch, list, args);
12234 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12236 tree finit_parms, finit_call;
12238 /* Prepare to pass hidden parameters to $finit$, if any. */
12239 finit_parms = build_alias_initializer_parameter_list
12240 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12243 build_method_invocation (build_wfl_node (finit_identifier_node),
12246 /* Generate the code used to initialize fields declared with an
12247 initialization statement and build a compound statement along
12248 with the super constructor invocation. */
12249 patch = build (COMPOUND_EXPR, void_type_node, patch,
12250 java_complete_tree (finit_call));
12251 CAN_COMPLETE_NORMALLY (patch) = 1;
12256 /* Check that we're not trying to do a static reference to a method in
12257 non static method. Return 1 if it's the case, 0 otherwise. */
12260 check_for_static_method_reference (wfl, node, method, where, primary)
12261 tree wfl, node, method, where, primary;
12263 if (METHOD_STATIC (current_function_decl)
12264 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12266 char *fct_name = xstrdup (lang_printable_name (method, 0));
12267 parse_error_context
12268 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
12269 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12270 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12277 /* Fix the invocation of *MDECL if necessary in the case of a
12278 invocation from an inner class. *THIS_ARG might be modified
12279 appropriately and an alternative access to *MDECL might be
12283 maybe_use_access_method (is_super_init, mdecl, this_arg)
12285 tree *mdecl, *this_arg;
12288 tree md = *mdecl, ta = *this_arg;
12290 int non_static_context = !METHOD_STATIC (md);
12293 || DECL_CONTEXT (md) == current_class
12294 || !PURE_INNER_CLASS_TYPE_P (current_class)
12295 || DECL_FINIT_P (md))
12298 /* If we're calling a method found in an enclosing class, generate
12299 what it takes to retrieve the right this. Don't do that if we're
12300 invoking a static method. */
12302 if (non_static_context)
12304 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12305 if (ctx == DECL_CONTEXT (md))
12307 ta = build_current_thisn (current_class);
12308 ta = build_wfl_node (ta);
12315 maybe_build_thisn_access_method (type);
12316 if (type == DECL_CONTEXT (md))
12318 ta = build_access_to_thisn (ctx, type, 0);
12321 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
12322 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12325 ta = java_complete_tree (ta);
12328 /* We might have to use an access method to get to MD. We can
12329 break the method access rule as far as we're not generating
12331 if (METHOD_PRIVATE (md) && flag_emit_class_files)
12333 md = build_outer_method_access_method (md);
12340 /* Returnin a non zero value indicates we were doing a non static
12341 method invokation that is now a static invocation. It will have
12342 callee displace `this' to insert it in the regular argument
12344 return (non_static_context && to_return);
12347 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12351 patch_invoke (patch, method, args)
12352 tree patch, method, args;
12355 tree original_call, t, ta;
12357 /* Last step for args: convert build-in types. If we're dealing with
12358 a new TYPE() type call, the first argument to the constructor
12359 isn't found in the incomming argument list, but delivered by
12361 t = TYPE_ARG_TYPES (TREE_TYPE (method));
12362 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12363 t = TREE_CHAIN (t);
12364 for (ta = args; t != end_params_node && ta;
12365 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12366 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12367 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12368 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12370 /* Resolve unresolved returned type isses */
12371 t = TREE_TYPE (TREE_TYPE (method));
12372 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12373 resolve_and_layout (TREE_TYPE (t), NULL);
12375 if (flag_emit_class_files || flag_emit_xref)
12379 tree signature = build_java_signature (TREE_TYPE (method));
12380 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12382 case INVOKE_VIRTUAL:
12383 dtable = invoke_build_dtable (0, args);
12384 func = build_invokevirtual (dtable, method);
12388 case INVOKE_STATIC:
12389 func = build_known_method_ref (method, TREE_TYPE (method),
12390 DECL_CONTEXT (method),
12394 case INVOKE_INTERFACE:
12395 dtable = invoke_build_dtable (1, args);
12396 func = build_invokeinterface (dtable, method);
12400 fatal ("internal error - unknown invocation_mode result");
12403 /* Ensure self_type is initialized, (invokestatic). FIXME */
12404 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12407 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12408 TREE_OPERAND (patch, 0) = func;
12409 TREE_OPERAND (patch, 1) = args;
12410 original_call = patch;
12412 /* We're processing a `new TYPE ()' form. New is called an its
12413 returned value is the first argument to the constructor. We build
12414 a COMPOUND_EXPR and use saved expression so that the overall NEW
12415 expression value is a pointer to a newly created and initialized
12417 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12419 tree class = DECL_CONTEXT (method);
12420 tree c1, saved_new, size, new;
12421 if (flag_emit_class_files || flag_emit_xref)
12423 TREE_TYPE (patch) = build_pointer_type (class);
12426 if (!TYPE_SIZE (class))
12427 safe_layout_class (class);
12428 size = size_in_bytes (class);
12429 new = build (CALL_EXPR, promote_type (class),
12430 build_address_of (alloc_object_node),
12431 tree_cons (NULL_TREE, build_class_ref (class),
12432 build_tree_list (NULL_TREE,
12433 size_in_bytes (class))),
12435 saved_new = save_expr (new);
12436 c1 = build_tree_list (NULL_TREE, saved_new);
12437 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12438 TREE_OPERAND (original_call, 1) = c1;
12439 TREE_SET_CODE (original_call, CALL_EXPR);
12440 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12446 invocation_mode (method, super)
12450 int access = get_access_flags_from_decl (method);
12453 return INVOKE_SUPER;
12455 if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
12456 return INVOKE_STATIC;
12458 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12459 return INVOKE_STATIC;
12461 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12462 return INVOKE_INTERFACE;
12464 if (DECL_CONSTRUCTOR_P (method))
12465 return INVOKE_STATIC;
12467 return INVOKE_VIRTUAL;
12470 /* Retrieve a refined list of matching methods. It covers the step
12471 15.11.2 (Compile-Time Step 2) */
12474 lookup_method_invoke (lc, cl, class, name, arg_list)
12477 tree class, name, arg_list;
12479 tree atl = end_params_node; /* Arg Type List */
12480 tree method, signature, list, node;
12481 const char *candidates; /* Used for error report */
12484 /* Fix the arguments */
12485 for (node = arg_list; node; node = TREE_CHAIN (node))
12487 tree current_arg = TREE_TYPE (TREE_VALUE (node));
12488 /* Non primitive type may have to be resolved */
12489 if (!JPRIMITIVE_TYPE_P (current_arg))
12490 resolve_and_layout (current_arg, NULL_TREE);
12492 if (TREE_CODE (current_arg) == RECORD_TYPE)
12493 current_arg = promote_type (current_arg);
12494 atl = tree_cons (NULL_TREE, current_arg, atl);
12497 /* Presto. If we're dealing with an anonymous class and a
12498 constructor call, generate the right constructor now, since we
12499 know the arguments' types. */
12501 if (lc && ANONYMOUS_CLASS_P (class))
12502 craft_constructor (TYPE_NAME (class), atl);
12504 /* Find all candidates and then refine the list, searching for the
12505 most specific method. */
12506 list = find_applicable_accessible_methods_list (lc, class, name, atl);
12507 list = find_most_specific_methods_list (list);
12508 if (list && !TREE_CHAIN (list))
12509 return TREE_VALUE (list);
12511 /* Issue an error. List candidates if any. Candidates are listed
12512 only if accessible (non accessible methods may end-up here for
12513 the sake of a better error report). */
12518 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12519 for (current = list; current; current = TREE_CHAIN (current))
12521 tree cm = TREE_VALUE (current);
12522 char string [4096];
12523 if (!cm || not_accessible_p (class, cm, 0))
12526 (string, " `%s' in `%s'%s",
12527 get_printable_method_name (cm),
12528 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12529 (TREE_CHAIN (current) ? "\n" : ""));
12530 obstack_grow (&temporary_obstack, string, strlen (string));
12532 obstack_1grow (&temporary_obstack, '\0');
12533 candidates = obstack_finish (&temporary_obstack);
12535 /* Issue the error message */
12536 method = make_node (FUNCTION_TYPE);
12537 TYPE_ARG_TYPES (method) = atl;
12538 signature = build_java_argument_signature (method);
12539 dup = xstrdup (lang_printable_name (class, 0));
12540 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12541 (lc ? "constructor" : "method"),
12542 (lc ? dup : IDENTIFIER_POINTER (name)),
12543 IDENTIFIER_POINTER (signature), dup,
12544 (candidates ? candidates : ""));
12549 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12550 when we're looking for a constructor. */
12553 find_applicable_accessible_methods_list (lc, class, name, arglist)
12555 tree class, name, arglist;
12557 static int object_done = 0;
12558 tree list = NULL_TREE, all_list = NULL_TREE;
12560 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12562 load_class (class, 1);
12563 safe_layout_class (class);
12566 /* Search interfaces */
12567 if (CLASS_INTERFACE (TYPE_NAME (class)))
12569 static struct hash_table t, *searched_interfaces = NULL;
12570 static int search_not_done = 0;
12572 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12574 /* Search in the hash table, otherwise create a new one if
12575 necessary and insert the new entry. */
12577 if (searched_interfaces)
12579 if (hash_lookup (searched_interfaces,
12580 (const hash_table_key) class, FALSE, NULL))
12585 hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12586 java_hash_compare_tree_node);
12587 searched_interfaces = &t;
12590 hash_lookup (searched_interfaces,
12591 (const hash_table_key) class, TRUE, NULL);
12593 search_applicable_methods_list (lc, TYPE_METHODS (class),
12594 name, arglist, &list, &all_list);
12595 n = TREE_VEC_LENGTH (basetype_vec);
12596 for (i = 1; i < n; i++)
12598 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12602 rlist = find_applicable_accessible_methods_list (lc, t, name,
12604 list = chainon (rlist, list);
12608 /* We're done. Reset the searched interfaces list and finally search
12609 java.lang.Object */
12610 if (!search_not_done)
12613 search_applicable_methods_list (lc,
12614 TYPE_METHODS (object_type_node),
12615 name, arglist, &list, &all_list);
12616 hash_table_free (searched_interfaces);
12617 searched_interfaces = NULL;
12620 /* Search classes */
12624 int seen_inner_class = 0;
12625 search_applicable_methods_list (lc, TYPE_METHODS (class),
12626 name, arglist, &list, &all_list);
12628 /* We must search all interfaces of this class */
12631 tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12632 int n = TREE_VEC_LENGTH (basetype_vec), i;
12634 for (i = 1; i < n; i++)
12636 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12638 if (t != object_type_node)
12639 rlist = find_applicable_accessible_methods_list (lc, t,
12641 list = chainon (rlist, list);
12646 /* Search enclosing context of inner classes before looking
12648 while (!lc && INNER_CLASS_TYPE_P (class))
12651 seen_inner_class = 1;
12652 class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12653 rlist = find_applicable_accessible_methods_list (lc, class,
12655 list = chainon (rlist, list);
12658 if (!lc && seen_inner_class
12659 && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12660 class = CLASSTYPE_SUPER (sc);
12664 for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
12665 class; class = CLASSTYPE_SUPER (class))
12666 search_applicable_methods_list (lc, TYPE_METHODS (class),
12667 name, arglist, &list, &all_list);
12670 /* Either return the list obtained or all selected (but
12671 inaccessible) methods for better error report. */
12672 return (!list ? all_list : list);
12675 /* Effectively search for the approriate method in method */
12678 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12680 tree method, name, arglist;
12681 tree *list, *all_list;
12683 for (; method; method = TREE_CHAIN (method))
12685 /* When dealing with constructor, stop here, otherwise search
12687 if (lc && !DECL_CONSTRUCTOR_P (method))
12689 else if (!lc && (DECL_CONSTRUCTOR_P (method)
12690 || (GET_METHOD_NAME (method) != name)))
12693 if (argument_types_convertible (method, arglist))
12695 /* Retain accessible methods only */
12696 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
12698 *list = tree_cons (NULL_TREE, method, *list);
12700 /* Also retain all selected method here */
12701 *all_list = tree_cons (NULL_TREE, method, *list);
12706 /* 15.11.2.2 Choose the Most Specific Method */
12709 find_most_specific_methods_list (list)
12713 tree current, new_list = NULL_TREE;
12714 for (current = list; current; current = TREE_CHAIN (current))
12717 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12719 for (method = list; method; method = TREE_CHAIN (method))
12721 /* Don't test a method against itself */
12722 if (method == current)
12725 /* Compare arguments and location where method where declared */
12726 if (argument_types_convertible (TREE_VALUE (method),
12727 TREE_VALUE (current))
12728 && valid_method_invocation_conversion_p
12729 (DECL_CONTEXT (TREE_VALUE (method)),
12730 DECL_CONTEXT (TREE_VALUE (current))))
12732 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12733 max = (v > max ? v : max);
12738 /* Review the list and select the maximally specific methods */
12739 for (current = list; current; current = TREE_CHAIN (current))
12740 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12741 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12743 /* If we have several and they're all abstract, just pick the
12746 if (new_list && TREE_CHAIN (new_list))
12749 for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c));
12750 c = TREE_CHAIN (c))
12754 new_list = nreverse (new_list);
12755 TREE_CHAIN (new_list) = NULL_TREE;
12759 /* If we can't find one, lower expectations and try to gather multiple
12760 maximally specific methods */
12761 while (!new_list && max)
12765 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12766 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12773 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12774 converted by method invocation conversion (5.3) to the type of the
12775 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12776 to change less often than M1. */
12779 argument_types_convertible (m1, m2_or_arglist)
12780 tree m1, m2_or_arglist;
12782 static tree m2_arg_value = NULL_TREE;
12783 static tree m2_arg_cache = NULL_TREE;
12785 register tree m1_arg, m2_arg;
12787 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12789 if (m2_arg_value == m2_or_arglist)
12790 m2_arg = m2_arg_cache;
12793 /* M2_OR_ARGLIST can be a function DECL or a raw list of
12795 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12797 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12798 if (!METHOD_STATIC (m2_or_arglist))
12799 m2_arg = TREE_CHAIN (m2_arg);
12802 m2_arg = m2_or_arglist;
12804 m2_arg_value = m2_or_arglist;
12805 m2_arg_cache = m2_arg;
12808 while (m1_arg != end_params_node && m2_arg != end_params_node)
12810 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12811 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12812 TREE_VALUE (m2_arg)))
12814 m1_arg = TREE_CHAIN (m1_arg);
12815 m2_arg = TREE_CHAIN (m2_arg);
12817 return m1_arg == end_params_node && m2_arg == end_params_node;
12820 /* Qualification routines */
12823 qualify_ambiguous_name (id)
12826 tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12827 saved_current_class;
12828 int again, super_found = 0, this_found = 0, new_array_found = 0;
12831 /* We first qualify the first element, then derive qualification of
12832 others based on the first one. If the first element is qualified
12833 by a resolution (field or type), this resolution is stored in the
12834 QUAL_RESOLUTION of the qual element being examined. We need to
12835 save the current_class since the use of SUPER might change the
12837 saved_current_class = current_class;
12838 qual = EXPR_WFL_QUALIFICATION (id);
12841 /* Simple qualified expression feature a qual_wfl that is a
12842 WFL. Expression derived from a primary feature more complicated
12843 things like a CALL_EXPR. Expression from primary need to be
12844 worked out to extract the part on which the qualification will
12846 qual_wfl = QUAL_WFL (qual);
12847 switch (TREE_CODE (qual_wfl))
12850 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12851 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
12853 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12854 qual_wfl = QUAL_WFL (qual);
12857 case NEW_ARRAY_EXPR:
12858 case NEW_ANONYMOUS_ARRAY_EXPR:
12859 qual = TREE_CHAIN (qual);
12860 again = new_array_found = 1;
12864 case NEW_CLASS_EXPR:
12865 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12868 while (TREE_CODE (qual_wfl) == ARRAY_REF)
12869 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12872 qual = TREE_CHAIN (qual);
12873 qual_wfl = QUAL_WFL (qual);
12875 case CLASS_LITERAL:
12876 qual = TREE_CHAIN (qual);
12877 qual_wfl = QUAL_WFL (qual);
12880 /* Fix for -Wall. Just break doing nothing */
12884 ptr_type = current_class;
12886 code = TREE_CODE (qual_wfl);
12888 /* Pos evaluation: non WFL leading expression nodes */
12889 if (code == CONVERT_EXPR
12890 && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
12891 name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
12893 else if (code == INTEGER_CST)
12896 else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
12897 TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
12898 name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
12900 else if (code == TREE_LIST)
12901 name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
12903 else if (code == STRING_CST || code == CONDITIONAL_EXPR
12904 || code == PLUS_EXPR)
12906 qual = TREE_CHAIN (qual);
12907 qual_wfl = QUAL_WFL (qual);
12912 name = EXPR_WFL_NODE (qual_wfl);
12915 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12920 /* If we have a THIS (from a primary), we set the context accordingly */
12921 if (name == this_identifier_node)
12923 qual = TREE_CHAIN (qual);
12924 qual_wfl = QUAL_WFL (qual);
12925 if (TREE_CODE (qual_wfl) == CALL_EXPR)
12928 name = EXPR_WFL_NODE (qual_wfl);
12931 /* If we have a SUPER, we set the context accordingly */
12932 if (name == super_identifier_node)
12934 current_class = CLASSTYPE_SUPER (ptr_type);
12935 /* Check that there is such a thing as a super class. If not,
12936 return. The error will be caught later on, during the
12938 if (!current_class)
12940 current_class = saved_current_class;
12943 qual = TREE_CHAIN (qual);
12944 /* Do one more interation to set things up */
12945 super_found = again = 1;
12949 /* If name appears within the scope of a local variable declaration
12950 or parameter declaration, then it is an expression name. We don't
12951 carry this test out if we're in the context of the use of SUPER
12953 if (!this_found && !super_found
12954 && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
12955 && (decl = IDENTIFIER_LOCAL_VALUE (name)))
12957 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12958 QUAL_RESOLUTION (qual) = decl;
12961 /* If within the class/interface NAME was found to be used there
12962 exists a (possibly inherited) field named NAME, then this is an
12963 expression name. If we saw a NEW_ARRAY_EXPR before and want to
12964 address length, it is OK. */
12965 else if ((decl = lookup_field_wrapper (ptr_type, name))
12966 || (new_array_found && name == length_identifier_node))
12968 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12969 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
12972 /* We reclassify NAME as yielding to a type name resolution if:
12973 - NAME is a class/interface declared within the compilation
12974 unit containing NAME,
12975 - NAME is imported via a single-type-import declaration,
12976 - NAME is declared in an another compilation unit of the package
12977 of the compilation unit containing NAME,
12978 - NAME is declared by exactly on type-import-on-demand declaration
12979 of the compilation unit containing NAME.
12980 - NAME is actually a STRING_CST. */
12981 else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
12982 || (decl = resolve_and_layout (name, NULL_TREE)))
12984 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
12985 QUAL_RESOLUTION (qual) = decl;
12988 /* Method call, array references and cast are expression name */
12989 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
12990 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
12991 || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
12992 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12994 /* Check here that NAME isn't declared by more than one
12995 type-import-on-demand declaration of the compilation unit
12996 containing NAME. FIXME */
12998 /* Otherwise, NAME is reclassified as a package name */
13000 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
13002 /* Propagate the qualification accross other components of the
13004 for (qual = TREE_CHAIN (qual); qual;
13005 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
13007 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13008 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
13010 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
13013 /* Store the global qualification for the ambiguous part of ID back
13015 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13016 RESOLVE_EXPRESSION_NAME_P (id) = 1;
13017 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13018 RESOLVE_TYPE_NAME_P (id) = 1;
13019 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13020 RESOLVE_PACKAGE_NAME_P (id) = 1;
13022 /* Restore the current class */
13023 current_class = saved_current_class;
13027 breakdown_qualified (left, right, source)
13028 tree *left, *right, source;
13030 char *p = IDENTIFIER_POINTER (source), *base;
13031 int l = IDENTIFIER_LENGTH (source);
13033 /* Breakdown NAME into REMAINDER . IDENTIFIER */
13036 while (*p != '.' && p != base)
13039 /* We didn't find a '.'. Return an error */
13045 *right = get_identifier (p+1);
13046 *left = get_identifier (IDENTIFIER_POINTER (source));
13052 /* Patch tree nodes in a function body. When a BLOCK is found, push
13053 local variable decls if present.
13054 Same as java_complete_lhs, but does resolve static finals to values. */
13057 java_complete_tree (node)
13060 node = java_complete_lhs (node);
13061 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13062 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13063 && !flag_emit_xref)
13065 tree value = DECL_INITIAL (node);
13066 DECL_INITIAL (node) = NULL_TREE;
13067 push_obstacks (&permanent_obstack, &permanent_obstack);
13068 value = fold_constant_for_init (value, node);
13070 DECL_INITIAL (node) = value;
13071 if (value != NULL_TREE)
13073 /* fold_constant_for_init sometimes widen the original type
13074 of the constant (i.e. byte to int.) It's not desirable,
13075 especially if NODE is a function argument. */
13076 if (TREE_CODE (value) == INTEGER_CST
13077 && TREE_TYPE (node) != TREE_TYPE (value))
13078 return convert (TREE_TYPE (node), value);
13087 java_stabilize_reference (node)
13090 if (TREE_CODE (node) == COMPOUND_EXPR)
13092 tree op0 = TREE_OPERAND (node, 0);
13093 tree op1 = TREE_OPERAND (node, 1);
13094 TREE_OPERAND (node, 0) = save_expr (op0);
13095 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13098 return stabilize_reference (node);
13101 /* Patch tree nodes in a function body. When a BLOCK is found, push
13102 local variable decls if present.
13103 Same as java_complete_tree, but does not resolve static finals to values. */
13106 java_complete_lhs (node)
13109 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13112 /* CONVERT_EXPR always has its type set, even though it needs to be
13114 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13117 /* The switch block implements cases processing container nodes
13118 first. Contained nodes are always written back. Leaves come
13119 next and return a value. */
13120 switch (TREE_CODE (node))
13124 /* 1- Block section.
13125 Set the local values on decl names so we can identify them
13126 faster when they're referenced. At that stage, identifiers
13127 are legal so we don't check for declaration errors. */
13128 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13130 DECL_CONTEXT (cn) = current_function_decl;
13131 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13133 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13134 CAN_COMPLETE_NORMALLY (node) = 1;
13137 tree stmt = BLOCK_EXPR_BODY (node);
13139 int error_seen = 0;
13140 if (TREE_CODE (stmt) == COMPOUND_EXPR)
13142 /* Re-order from (((A; B); C); ...; Z) to
13143 (A; (B; (C ; (...; Z)))).
13144 This makes it easier to scan the statements left-to-right
13145 without using recursion (which might overflow the stack
13146 if the block has many statements. */
13149 tree left = TREE_OPERAND (stmt, 0);
13150 if (TREE_CODE (left) != COMPOUND_EXPR)
13152 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13153 TREE_OPERAND (left, 1) = stmt;
13156 BLOCK_EXPR_BODY (node) = stmt;
13159 /* Now do the actual complete, without deep recursion for
13161 ptr = &BLOCK_EXPR_BODY (node);
13162 while (TREE_CODE (*ptr) == COMPOUND_EXPR
13163 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13165 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13166 tree *next = &TREE_OPERAND (*ptr, 1);
13167 TREE_OPERAND (*ptr, 0) = cur;
13168 if (cur == empty_stmt_node)
13170 /* Optimization; makes it easier to detect empty bodies.
13171 Most useful for <clinit> with all-constant initializer. */
13175 if (TREE_CODE (cur) == ERROR_MARK)
13177 else if (! CAN_COMPLETE_NORMALLY (cur))
13182 if (TREE_CODE (wfl_op2) == BLOCK)
13183 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13184 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13185 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13189 if (TREE_CODE (wfl_op2) != CASE_EXPR
13190 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13191 unreachable_stmt_error (*ptr);
13195 *ptr = java_complete_tree (*ptr);
13197 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13198 return error_mark_node;
13199 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13201 /* Turn local bindings to null */
13202 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13203 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13205 TREE_TYPE (node) = void_type_node;
13208 /* 2- They are expressions but ultimately deal with statements */
13211 wfl_op1 = TREE_OPERAND (node, 0);
13212 COMPLETE_CHECK_OP_0 (node);
13213 /* 14.19 A throw statement cannot complete normally. */
13214 CAN_COMPLETE_NORMALLY (node) = 0;
13215 return patch_throw_statement (node, wfl_op1);
13217 case SYNCHRONIZED_EXPR:
13218 wfl_op1 = TREE_OPERAND (node, 0);
13219 return patch_synchronized_statement (node, wfl_op1);
13222 return patch_try_statement (node);
13224 case TRY_FINALLY_EXPR:
13225 COMPLETE_CHECK_OP_0 (node);
13226 COMPLETE_CHECK_OP_1 (node);
13227 CAN_COMPLETE_NORMALLY (node)
13228 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13229 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13230 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13233 case CLEANUP_POINT_EXPR:
13234 COMPLETE_CHECK_OP_0 (node);
13235 TREE_TYPE (node) = void_type_node;
13236 CAN_COMPLETE_NORMALLY (node) =
13237 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13240 case WITH_CLEANUP_EXPR:
13241 COMPLETE_CHECK_OP_0 (node);
13242 COMPLETE_CHECK_OP_2 (node);
13243 CAN_COMPLETE_NORMALLY (node) =
13244 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13245 TREE_TYPE (node) = void_type_node;
13248 case LABELED_BLOCK_EXPR:
13249 PUSH_LABELED_BLOCK (node);
13250 if (LABELED_BLOCK_BODY (node))
13251 COMPLETE_CHECK_OP_1 (node);
13252 TREE_TYPE (node) = void_type_node;
13253 POP_LABELED_BLOCK ();
13255 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13257 LABELED_BLOCK_BODY (node) = NULL_TREE;
13258 CAN_COMPLETE_NORMALLY (node) = 1;
13260 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13261 CAN_COMPLETE_NORMALLY (node) = 1;
13264 case EXIT_BLOCK_EXPR:
13265 /* We don't complete operand 1, because it's the return value of
13266 the EXIT_BLOCK_EXPR which doesn't exist it Java */
13267 return patch_bc_statement (node);
13270 cn = java_complete_tree (TREE_OPERAND (node, 0));
13271 if (cn == error_mark_node)
13274 /* First, the case expression must be constant. Values of final
13275 fields are accepted. */
13277 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13278 && JDECL_P (TREE_OPERAND (cn, 1))
13279 && FIELD_FINAL (TREE_OPERAND (cn, 1))
13280 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13282 push_obstacks (&permanent_obstack, &permanent_obstack);
13283 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13284 TREE_OPERAND (cn, 1));
13288 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13290 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13291 parse_error_context (node, "Constant expression required");
13292 return error_mark_node;
13295 nn = ctxp->current_loop;
13297 /* It must be assignable to the type of the switch expression. */
13298 if (!try_builtin_assignconv (NULL_TREE,
13299 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13301 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13302 parse_error_context
13304 "Incompatible type for case. Can't convert `%s' to `int'",
13305 lang_printable_name (TREE_TYPE (cn), 0));
13306 return error_mark_node;
13309 cn = fold (convert (int_type_node, cn));
13311 /* Multiple instance of a case label bearing the same
13312 value is checked during code generation. The case
13313 expression is allright so far. */
13314 TREE_OPERAND (node, 0) = cn;
13315 TREE_TYPE (node) = void_type_node;
13316 CAN_COMPLETE_NORMALLY (node) = 1;
13317 TREE_SIDE_EFFECTS (node) = 1;
13321 nn = ctxp->current_loop;
13322 /* Only one default label is allowed per switch statement */
13323 if (SWITCH_HAS_DEFAULT (nn))
13325 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13326 parse_error_context (wfl_operator,
13327 "Duplicate case label: `default'");
13328 return error_mark_node;
13331 SWITCH_HAS_DEFAULT (nn) = 1;
13332 TREE_TYPE (node) = void_type_node;
13333 TREE_SIDE_EFFECTS (node) = 1;
13334 CAN_COMPLETE_NORMALLY (node) = 1;
13340 /* Check whether the loop was enclosed in a labeled
13341 statement. If not, create one, insert the loop in it and
13343 nn = patch_loop_statement (node);
13345 /* Anyways, walk the body of the loop */
13346 if (TREE_CODE (node) == LOOP_EXPR)
13347 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13348 /* Switch statement: walk the switch expression and the cases */
13350 node = patch_switch_statement (node);
13352 if (TREE_OPERAND (node, 0) == error_mark_node)
13353 nn = error_mark_node;
13356 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13357 /* If we returned something different, that's because we
13358 inserted a label. Pop the label too. */
13361 if (CAN_COMPLETE_NORMALLY (node))
13362 CAN_COMPLETE_NORMALLY (nn) = 1;
13363 POP_LABELED_BLOCK ();
13370 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13371 return patch_exit_expr (node);
13375 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13376 if (TREE_OPERAND (node, 0) == error_mark_node)
13377 return error_mark_node;
13378 /* then-else branches */
13379 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13380 if (TREE_OPERAND (node, 1) == error_mark_node)
13381 return error_mark_node;
13382 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13383 if (TREE_OPERAND (node, 2) == error_mark_node)
13384 return error_mark_node;
13385 return patch_if_else_statement (node);
13388 case CONDITIONAL_EXPR:
13390 wfl_op1 = TREE_OPERAND (node, 0);
13391 COMPLETE_CHECK_OP_0 (node);
13392 wfl_op2 = TREE_OPERAND (node, 1);
13393 COMPLETE_CHECK_OP_1 (node);
13394 wfl_op3 = TREE_OPERAND (node, 2);
13395 COMPLETE_CHECK_OP_2 (node);
13396 return patch_conditional_expr (node, wfl_op1, wfl_op2);
13398 /* 3- Expression section */
13399 case COMPOUND_EXPR:
13400 wfl_op2 = TREE_OPERAND (node, 1);
13401 TREE_OPERAND (node, 0) = nn =
13402 java_complete_tree (TREE_OPERAND (node, 0));
13403 if (wfl_op2 == empty_stmt_node)
13404 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13407 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13409 /* An unreachable condition in a do-while statement
13410 is *not* (technically) an unreachable statement. */
13412 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13413 nn = EXPR_WFL_NODE (nn);
13414 if (TREE_CODE (nn) != EXIT_EXPR)
13416 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13417 parse_error_context (wfl_operator, "Unreachable statement");
13420 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13421 if (TREE_OPERAND (node, 1) == error_mark_node)
13422 return error_mark_node;
13423 CAN_COMPLETE_NORMALLY (node)
13424 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13426 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13430 /* CAN_COMPLETE_NORMALLY (node) = 0; */
13431 return patch_return (node);
13433 case EXPR_WITH_FILE_LOCATION:
13434 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13435 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13438 node = resolve_expression_name (node, NULL);
13439 if (node == error_mark_node)
13441 /* Keep line number information somewhere were it doesn't
13442 disrupt the completion process. */
13443 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13445 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13446 TREE_OPERAND (node, 1) = wfl;
13448 CAN_COMPLETE_NORMALLY (node) = 1;
13453 int save_lineno = lineno;
13454 lineno = EXPR_WFL_LINENO (node);
13455 body = java_complete_tree (EXPR_WFL_NODE (node));
13456 lineno = save_lineno;
13457 EXPR_WFL_NODE (node) = body;
13458 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13459 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13460 if (body == empty_stmt_node)
13462 /* Optimization; makes it easier to detect empty bodies. */
13465 if (body == error_mark_node)
13467 /* Its important for the evaluation of assignment that
13468 this mark on the TREE_TYPE is propagated. */
13469 TREE_TYPE (node) = error_mark_node;
13470 return error_mark_node;
13473 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13478 case NEW_ARRAY_EXPR:
13479 /* Patch all the dimensions */
13481 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13483 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13484 tree dim = convert (int_type_node,
13485 java_complete_tree (TREE_VALUE (cn)));
13486 if (dim == error_mark_node)
13493 TREE_VALUE (cn) = dim;
13494 /* Setup the location of the current dimension, for
13495 later error report. */
13496 TREE_PURPOSE (cn) =
13497 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13498 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13501 /* They complete the array creation expression, if no errors
13503 CAN_COMPLETE_NORMALLY (node) = 1;
13504 return (flag ? error_mark_node
13505 : force_evaluation_order (patch_newarray (node)));
13507 case NEW_ANONYMOUS_ARRAY_EXPR:
13508 /* Create the array type if necessary. */
13509 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13511 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13512 if (!(type = resolve_type_during_patch (type)))
13513 return error_mark_node;
13514 type = build_array_from_name (type, NULL_TREE,
13515 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13516 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13518 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13519 ANONYMOUS_ARRAY_INITIALIZER (node));
13520 if (node == error_mark_node)
13521 return error_mark_node;
13522 CAN_COMPLETE_NORMALLY (node) = 1;
13525 case NEW_CLASS_EXPR:
13527 /* Complete function's argument(s) first */
13528 if (complete_function_arguments (node))
13529 return error_mark_node;
13532 tree decl, wfl = TREE_OPERAND (node, 0);
13533 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13535 node = patch_method_invocation (node, NULL_TREE,
13536 NULL_TREE, 0, &decl);
13537 if (node == error_mark_node)
13538 return error_mark_node;
13540 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13541 /* If we call this(...), register signature and positions */
13543 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
13544 tree_cons (wfl, decl,
13545 DECL_CONSTRUCTOR_CALLS (current_function_decl));
13546 CAN_COMPLETE_NORMALLY (node) = 1;
13547 return force_evaluation_order (node);
13551 /* Save potential wfls */
13552 wfl_op1 = TREE_OPERAND (node, 0);
13553 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13555 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13556 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13557 && DECL_INITIAL (nn) != NULL_TREE)
13561 push_obstacks (&permanent_obstack, &permanent_obstack);
13562 value = fold_constant_for_init (nn, nn);
13565 if (value != NULL_TREE)
13567 tree type = TREE_TYPE (value);
13568 if (JPRIMITIVE_TYPE_P (type) ||
13569 (type == string_ptr_type_node && ! flag_emit_class_files))
13570 return empty_stmt_node;
13572 DECL_INITIAL (nn) = NULL_TREE;
13574 wfl_op2 = TREE_OPERAND (node, 1);
13576 if (TREE_OPERAND (node, 0) == error_mark_node)
13577 return error_mark_node;
13579 flag = COMPOUND_ASSIGN_P (wfl_op2);
13582 /* This might break when accessing outer field from inner
13583 class. TESTME, FIXME */
13584 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
13586 /* Hand stablize the lhs on both places */
13587 TREE_OPERAND (node, 0) = lvalue;
13588 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
13589 (flag_emit_class_files ? lvalue : save_expr (lvalue));
13591 /* 15.25.2.a: Left hand is not an array access. FIXME */
13592 /* Now complete the RHS. We write it back later on. */
13593 nn = java_complete_tree (TREE_OPERAND (node, 1));
13595 if ((cn = patch_string (nn)))
13598 /* The last part of the rewrite for E1 op= E2 is to have
13599 E1 = (T)(E1 op E2), with T being the type of E1. */
13600 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
13601 TREE_TYPE (lvalue), nn));
13603 /* 15.25.2.b: Left hand is an array access. FIXME */
13606 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13607 function to complete this RHS. Note that a NEW_ARRAY_INIT
13608 might have been already fully expanded if created as a result
13609 of processing an anonymous array initializer. We avoid doing
13610 the operation twice by testing whether the node already bears
13612 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13613 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13614 TREE_OPERAND (node, 1));
13615 /* Otherwise we simply complete the RHS */
13617 nn = java_complete_tree (TREE_OPERAND (node, 1));
13619 if (nn == error_mark_node)
13620 return error_mark_node;
13622 /* Write back the RHS as we evaluated it. */
13623 TREE_OPERAND (node, 1) = nn;
13625 /* In case we're handling = with a String as a RHS, we need to
13626 produce a String out of the RHS (it might still be a
13627 STRING_CST or a StringBuffer at this stage */
13628 if ((nn = patch_string (TREE_OPERAND (node, 1))))
13629 TREE_OPERAND (node, 1) = nn;
13631 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13632 TREE_OPERAND (node, 1))))
13634 /* We return error_mark_node if outer_field_access_fix
13635 detects we write into a final. */
13636 if (nn == error_mark_node)
13637 return error_mark_node;
13642 node = patch_assignment (node, wfl_op1, wfl_op2);
13643 /* Reorganize the tree if necessary. */
13644 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
13645 || JSTRING_P (TREE_TYPE (node))))
13646 node = java_refold (node);
13649 CAN_COMPLETE_NORMALLY (node) = 1;
13661 case TRUNC_MOD_EXPR:
13662 case TRUNC_DIV_EXPR:
13664 case TRUTH_ANDIF_EXPR:
13665 case TRUTH_ORIF_EXPR:
13672 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13673 knows how to handle those cases. */
13674 wfl_op1 = TREE_OPERAND (node, 0);
13675 wfl_op2 = TREE_OPERAND (node, 1);
13677 CAN_COMPLETE_NORMALLY (node) = 1;
13678 /* Don't complete string nodes if dealing with the PLUS operand. */
13679 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13681 nn = java_complete_tree (wfl_op1);
13682 if (nn == error_mark_node)
13683 return error_mark_node;
13685 TREE_OPERAND (node, 0) = nn;
13687 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13689 nn = java_complete_tree (wfl_op2);
13690 if (nn == error_mark_node)
13691 return error_mark_node;
13693 TREE_OPERAND (node, 1) = nn;
13695 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13697 case INSTANCEOF_EXPR:
13698 wfl_op1 = TREE_OPERAND (node, 0);
13699 COMPLETE_CHECK_OP_0 (node);
13700 if (flag_emit_xref)
13702 TREE_TYPE (node) = boolean_type_node;
13705 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13707 case UNARY_PLUS_EXPR:
13709 case TRUTH_NOT_EXPR:
13711 case PREDECREMENT_EXPR:
13712 case PREINCREMENT_EXPR:
13713 case POSTDECREMENT_EXPR:
13714 case POSTINCREMENT_EXPR:
13716 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13717 how to handle those cases. */
13718 wfl_op1 = TREE_OPERAND (node, 0);
13719 CAN_COMPLETE_NORMALLY (node) = 1;
13720 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13721 if (TREE_OPERAND (node, 0) == error_mark_node)
13722 return error_mark_node;
13723 node = patch_unaryop (node, wfl_op1);
13724 CAN_COMPLETE_NORMALLY (node) = 1;
13728 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13729 how to handle those cases. */
13730 wfl_op1 = TREE_OPERAND (node, 0);
13731 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13732 if (TREE_OPERAND (node, 0) == error_mark_node)
13733 return error_mark_node;
13734 if (!flag_emit_class_files && !flag_emit_xref)
13735 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13736 /* The same applies to wfl_op2 */
13737 wfl_op2 = TREE_OPERAND (node, 1);
13738 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13739 if (TREE_OPERAND (node, 1) == error_mark_node)
13740 return error_mark_node;
13741 if (!flag_emit_class_files && !flag_emit_xref)
13742 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13743 return patch_array_ref (node);
13748 case COMPONENT_REF:
13749 /* The first step in the re-write of qualified name handling. FIXME.
13750 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13751 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13752 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13754 tree name = TREE_OPERAND (node, 1);
13755 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13756 if (field == NULL_TREE)
13758 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13759 return error_mark_node;
13761 if (! FIELD_STATIC (field))
13763 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13764 return error_mark_node;
13769 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13773 /* Can't use THIS in a static environment */
13776 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13777 parse_error_context (wfl_operator,
13778 "Keyword `this' used outside allowed context");
13779 TREE_TYPE (node) = error_mark_node;
13780 return error_mark_node;
13782 if (ctxp->explicit_constructor_p)
13784 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13785 parse_error_context
13786 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13787 TREE_TYPE (node) = error_mark_node;
13788 return error_mark_node;
13790 return current_this;
13792 case CLASS_LITERAL:
13793 CAN_COMPLETE_NORMALLY (node) = 1;
13794 node = patch_incomplete_class_ref (node);
13795 if (node == error_mark_node)
13796 return error_mark_node;
13799 case INSTANCE_INITIALIZERS_EXPR:
13800 in_instance_initializer++;
13801 node = java_complete_tree (TREE_OPERAND (node, 0));
13802 in_instance_initializer--;
13803 if (node != error_mark_node)
13804 TREE_TYPE (node) = void_type_node;
13806 return error_mark_node;
13810 CAN_COMPLETE_NORMALLY (node) = 1;
13811 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13812 and it's time to turn it into the appropriate String object */
13813 if ((nn = patch_string (node)))
13816 fatal ("No case for tree code `%s' - java_complete_tree\n",
13817 tree_code_name [TREE_CODE (node)]);
13822 /* Complete function call's argument. Return a non zero value is an
13823 error was found. */
13826 complete_function_arguments (node)
13832 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13833 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13835 tree wfl = TREE_VALUE (cn), parm, temp;
13836 parm = java_complete_tree (wfl);
13838 if (parm == error_mark_node)
13843 /* If have a string literal that we haven't transformed yet or a
13844 crafted string buffer, as a result of use of the the String
13845 `+' operator. Build `parm.toString()' and expand it. */
13846 if ((temp = patch_string (parm)))
13848 /* Inline PRIMTYPE.TYPE read access */
13849 parm = maybe_build_primttype_type_ref (parm, wfl);
13851 TREE_VALUE (cn) = parm;
13853 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13857 /* Sometimes (for loops and variable initialized during their
13858 declaration), we want to wrap a statement around a WFL and turn it
13862 build_debugable_stmt (location, stmt)
13866 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
13868 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
13869 EXPR_WFL_LINECOL (stmt) = location;
13871 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
13876 build_expr_block (body, decls)
13879 tree node = make_node (BLOCK);
13880 BLOCK_EXPR_DECLS (node) = decls;
13881 BLOCK_EXPR_BODY (node) = body;
13883 TREE_TYPE (node) = TREE_TYPE (body);
13884 TREE_SIDE_EFFECTS (node) = 1;
13888 /* Create a new function block and link it approriately to current
13889 function block chain */
13894 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
13897 /* Link block B supercontext to the previous block. The current
13898 function DECL is used as supercontext when enter_a_block is called
13899 for the first time for a given function. The current function body
13900 (DECL_FUNCTION_BODY) is set to be block B. */
13906 tree fndecl = current_function_decl;
13909 BLOCK_SUPERCONTEXT (b) = current_static_block;
13910 current_static_block = b;
13913 else if (!DECL_FUNCTION_BODY (fndecl))
13915 BLOCK_SUPERCONTEXT (b) = fndecl;
13916 DECL_FUNCTION_BODY (fndecl) = b;
13920 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
13921 DECL_FUNCTION_BODY (fndecl) = b;
13926 /* Exit a block by changing the current function body
13927 (DECL_FUNCTION_BODY) to the current block super context, only if
13928 the block being exited isn't the method's top level one. */
13934 if (current_function_decl)
13936 b = DECL_FUNCTION_BODY (current_function_decl);
13937 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
13938 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
13942 b = current_static_block;
13944 if (BLOCK_SUPERCONTEXT (b))
13945 current_static_block = BLOCK_SUPERCONTEXT (b);
13950 /* Lookup for NAME in the nested function's blocks, all the way up to
13951 the current toplevel one. It complies with Java's local variable
13955 lookup_name_in_blocks (name)
13958 tree b = GET_CURRENT_BLOCK (current_function_decl);
13960 while (b != current_function_decl)
13964 /* Paranoid sanity check. To be removed */
13965 if (TREE_CODE (b) != BLOCK)
13966 fatal ("non block expr function body - lookup_name_in_blocks");
13968 for (current = BLOCK_EXPR_DECLS (b); current;
13969 current = TREE_CHAIN (current))
13970 if (DECL_NAME (current) == name)
13972 b = BLOCK_SUPERCONTEXT (b);
13978 maybe_absorb_scoping_blocks ()
13980 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
13982 tree b = exit_block ();
13983 java_method_add_stmt (current_function_decl, b);
13984 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
13989 /* This section of the source is reserved to build_* functions that
13990 are building incomplete tree nodes and the patch_* functions that
13991 are completing them. */
13993 /* Wrap a non WFL node around a WFL. */
13995 build_wfl_wrap (node)
13998 tree wfl, node_to_insert = node;
14000 /* We want to process THIS . xxx symbolicaly, to keep it consistent
14001 with the way we're processing SUPER. A THIS from a primary as a
14002 different form than a SUPER. Turn THIS into something symbolic */
14003 if (TREE_CODE (node) == THIS_EXPR)
14004 node_to_insert = wfl = build_wfl_node (this_identifier_node);
14006 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
14008 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
14009 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14014 /* Build a super() constructor invocation. Returns empty_stmt_node if
14015 we're currently dealing with the class java.lang.Object. */
14018 build_super_invocation (mdecl)
14021 if (DECL_CONTEXT (mdecl) == object_type_node)
14022 return empty_stmt_node;
14025 tree super_wfl = build_wfl_node (super_identifier_node);
14026 tree a = NULL_TREE, t;
14027 /* If we're dealing with an anonymous class, pass the arguments
14028 of the crafted constructor along. */
14029 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14031 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14032 for (; t != end_params_node; t = TREE_CHAIN (t))
14033 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14035 return build_method_invocation (super_wfl, a);
14039 /* Build a SUPER/THIS qualified method invocation. */
14042 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14049 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14050 EXPR_WFL_LINECOL (wfl) = lloc;
14051 invok = build_method_invocation (name, args);
14052 return make_qualified_primary (wfl, invok, rloc);
14055 /* Build an incomplete CALL_EXPR node. */
14058 build_method_invocation (name, args)
14062 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14063 TREE_SIDE_EFFECTS (call) = 1;
14064 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14068 /* Build an incomplete new xxx(...) node. */
14071 build_new_invocation (name, args)
14074 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14075 TREE_SIDE_EFFECTS (call) = 1;
14076 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14080 /* Build an incomplete assignment expression. */
14083 build_assignment (op, op_location, lhs, rhs)
14084 int op, op_location;
14088 /* Build the corresponding binop if we deal with a Compound
14089 Assignment operator. Mark the binop sub-tree as part of a
14090 Compound Assignment expression */
14091 if (op != ASSIGN_TK)
14093 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14094 COMPOUND_ASSIGN_P (rhs) = 1;
14096 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14097 TREE_SIDE_EFFECTS (assignment) = 1;
14098 EXPR_WFL_LINECOL (assignment) = op_location;
14102 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14105 print_int_node (node)
14108 static char buffer [80];
14109 if (TREE_CONSTANT_OVERFLOW (node))
14110 sprintf (buffer, "<overflow>");
14112 if (TREE_INT_CST_HIGH (node) == 0)
14113 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14114 TREE_INT_CST_LOW (node));
14115 else if (TREE_INT_CST_HIGH (node) == -1
14116 && TREE_INT_CST_LOW (node) != 0)
14119 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14120 -TREE_INT_CST_LOW (node));
14123 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14124 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14129 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14133 check_final_assignment (lvalue, wfl)
14136 if (TREE_CODE (lvalue) == COMPOUND_EXPR
14137 && JDECL_P (TREE_OPERAND (lvalue, 1)))
14138 lvalue = TREE_OPERAND (lvalue, 1);
14140 /* When generating class files, references to the `length' field
14141 look a bit different. */
14142 if ((flag_emit_class_files
14143 && TREE_CODE (lvalue) == COMPONENT_REF
14144 && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14145 && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14146 || (TREE_CODE (lvalue) == FIELD_DECL
14147 && FIELD_FINAL (lvalue)
14148 && !DECL_CLINIT_P (current_function_decl)
14149 && !DECL_FINIT_P (current_function_decl)))
14151 parse_error_context
14152 (wfl, "Can't assign a value to the final variable `%s'",
14153 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14159 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14160 read. This is needed to avoid circularities in the implementation
14161 of these fields in libjava. */
14164 maybe_build_primttype_type_ref (rhs, wfl)
14167 tree to_return = NULL_TREE;
14168 tree rhs_type = TREE_TYPE (rhs);
14169 if (TREE_CODE (rhs) == COMPOUND_EXPR)
14171 tree n = TREE_OPERAND (rhs, 1);
14172 if (TREE_CODE (n) == VAR_DECL
14173 && DECL_NAME (n) == TYPE_identifier_node
14174 && rhs_type == class_ptr_type)
14176 const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14177 if (!strncmp (self_name, "java.lang.", 10))
14178 to_return = build_primtype_type_ref (self_name);
14181 return (to_return ? to_return : rhs );
14184 /* 15.25 Assignment operators. */
14187 patch_assignment (node, wfl_op1, wfl_op2)
14192 tree rhs = TREE_OPERAND (node, 1);
14193 tree lvalue = TREE_OPERAND (node, 0), llvalue;
14194 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14195 int error_found = 0;
14196 int lvalue_from_array = 0;
14198 /* Can't assign to a (blank) final. */
14199 if (check_final_assignment (lvalue, wfl_op1))
14202 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14204 /* Lhs can be a named variable */
14205 if (JDECL_P (lvalue))
14207 lhs_type = TREE_TYPE (lvalue);
14209 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14210 comment on reason why */
14211 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14213 lhs_type = TREE_TYPE (lvalue);
14214 lvalue_from_array = 1;
14216 /* Or a field access */
14217 else if (TREE_CODE (lvalue) == COMPONENT_REF)
14218 lhs_type = TREE_TYPE (lvalue);
14219 /* Or a function return slot */
14220 else if (TREE_CODE (lvalue) == RESULT_DECL)
14221 lhs_type = TREE_TYPE (lvalue);
14222 /* Otherwise, we might want to try to write into an optimized static
14223 final, this is an of a different nature, reported further on. */
14224 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14225 && resolve_expression_name (wfl_op1, &llvalue))
14227 if (!error_found && check_final_assignment (llvalue, wfl_op1))
14229 /* What we should do instead is resetting the all the flags
14230 previously set, exchange lvalue for llvalue and continue. */
14232 return error_mark_node;
14235 lhs_type = TREE_TYPE (lvalue);
14239 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14243 rhs_type = TREE_TYPE (rhs);
14244 /* 5.1 Try the assignment conversion for builtin type. */
14245 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14247 /* 5.2 If it failed, try a reference conversion */
14248 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14249 lhs_type = promote_type (rhs_type);
14251 /* 15.25.2 If we have a compound assignment, convert RHS into the
14253 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14254 new_rhs = convert (lhs_type, rhs);
14256 /* Explicit cast required. This is an error */
14259 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14260 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14262 char operation [32]; /* Max size known */
14264 /* If the assignment is part of a declaration, we use the WFL of
14265 the declared variable to point out the error and call it a
14266 declaration problem. If the assignment is a genuine =
14267 operator, we call is a operator `=' problem, otherwise we
14268 call it an assignment problem. In both of these last cases,
14269 we use the WFL of the operator to indicate the error. */
14271 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14274 strcpy (operation, "declaration");
14278 wfl = wfl_operator;
14279 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14280 strcpy (operation, "assignment");
14281 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14282 strcpy (operation, "`return'");
14284 strcpy (operation, "`='");
14287 if (!valid_cast_to_p (rhs_type, lhs_type))
14288 parse_error_context
14289 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14290 operation, t1, t2);
14292 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14293 operation, t1, t2);
14294 free (t1); free (t2);
14298 /* Inline read access to java.lang.PRIMTYPE.TYPE */
14300 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14303 return error_mark_node;
14305 /* 10.10: Array Store Exception runtime check */
14306 if (!flag_emit_class_files
14308 && lvalue_from_array
14309 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14312 tree base = lvalue;
14314 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14315 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14316 base = TREE_OPERAND (lvalue, 0);
14319 if (flag_bounds_check)
14320 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14322 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14325 /* Build the invocation of _Jv_CheckArrayStore */
14326 new_rhs = save_expr (new_rhs);
14327 check = build (CALL_EXPR, void_type_node,
14328 build_address_of (soft_checkarraystore_node),
14329 tree_cons (NULL_TREE, base,
14330 build_tree_list (NULL_TREE, new_rhs)),
14332 TREE_SIDE_EFFECTS (check) = 1;
14334 /* We have to decide on an insertion point */
14335 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14338 if (flag_bounds_check)
14340 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14341 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14342 build (COMPOUND_EXPR, void_type_node, t, check);
14345 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14346 check, TREE_OPERAND (lvalue, 1));
14350 /* Make sure the bound check will happen before the store check */
14351 if (flag_bounds_check)
14352 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14353 build (COMPOUND_EXPR, void_type_node,
14354 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14356 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14360 TREE_OPERAND (node, 0) = lvalue;
14361 TREE_OPERAND (node, 1) = new_rhs;
14362 TREE_TYPE (node) = lhs_type;
14366 /* Check that type SOURCE can be cast into type DEST. If the cast
14367 can't occur at all, return 0 otherwise 1. This function is used to
14368 produce accurate error messages on the reasons why an assignment
14372 try_reference_assignconv (lhs_type, rhs)
14373 tree lhs_type, rhs;
14375 tree new_rhs = NULL_TREE;
14376 tree rhs_type = TREE_TYPE (rhs);
14378 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14380 /* `null' may be assigned to any reference type */
14381 if (rhs == null_pointer_node)
14382 new_rhs = null_pointer_node;
14383 /* Try the reference assignment conversion */
14384 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14386 /* This is a magic assignment that we process differently */
14387 else if (rhs == soft_exceptioninfo_call_node)
14393 /* Check that RHS can be converted into LHS_TYPE by the assignment
14394 conversion (5.2), for the cases of RHS being a builtin type. Return
14395 NULL_TREE if the conversion fails or if because RHS isn't of a
14396 builtin type. Return a converted RHS if the conversion is possible. */
14399 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14400 tree wfl_op1, lhs_type, rhs;
14402 tree new_rhs = NULL_TREE;
14403 tree rhs_type = TREE_TYPE (rhs);
14405 /* Zero accepted everywhere */
14406 if (TREE_CODE (rhs) == INTEGER_CST
14407 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14408 && JPRIMITIVE_TYPE_P (rhs_type))
14409 new_rhs = convert (lhs_type, rhs);
14411 /* 5.1.1 Try Identity Conversion,
14412 5.1.2 Try Widening Primitive Conversion */
14413 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14414 new_rhs = convert (lhs_type, rhs);
14416 /* Try a narrowing primitive conversion (5.1.3):
14417 - expression is a constant expression of type int AND
14418 - variable is byte, short or char AND
14419 - The value of the expression is representable in the type of the
14421 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14422 && (lhs_type == byte_type_node || lhs_type == char_type_node
14423 || lhs_type == short_type_node))
14425 if (int_fits_type_p (rhs, lhs_type))
14426 new_rhs = convert (lhs_type, rhs);
14427 else if (wfl_op1) /* Might be called with a NULL */
14428 parse_warning_context
14429 (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'",
14430 print_int_node (rhs), lang_printable_name (lhs_type, 0));
14431 /* Reported a warning that will turn into an error further
14432 down, so we don't return */
14438 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14439 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
14440 0 is the conversion test fails. This implements parts the method
14441 invocation convertion (5.3). */
14444 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14445 tree lhs_type, rhs_type;
14447 /* 5.1.1: This is the identity conversion part. */
14448 if (lhs_type == rhs_type)
14451 /* Reject non primitive types */
14452 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14455 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14456 than a char can't be converted into a char. Short can't too, but
14457 the < test below takes care of that */
14458 if (lhs_type == char_type_node && rhs_type == byte_type_node)
14461 /* Accept all promoted type here. Note, we can't use <= in the test
14462 below, because we still need to bounce out assignments of short
14463 to char and the likes */
14464 if (lhs_type == int_type_node
14465 && (rhs_type == promoted_byte_type_node
14466 || rhs_type == promoted_short_type_node
14467 || rhs_type == promoted_char_type_node
14468 || rhs_type == promoted_boolean_type_node))
14471 /* From here, an integral is widened if its precision is smaller
14472 than the precision of the LHS or if the LHS is a floating point
14473 type, or the RHS is a float and the RHS a double. */
14474 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
14475 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14476 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14477 || (rhs_type == float_type_node && lhs_type == double_type_node))
14483 /* Check that something of SOURCE type can be assigned or cast to
14484 something of DEST type at runtime. Return 1 if the operation is
14485 valid, 0 otherwise. If CAST is set to 1, we're treating the case
14486 were SOURCE is cast into DEST, which borrows a lot of the
14487 assignment check. */
14490 valid_ref_assignconv_cast_p (source, dest, cast)
14495 /* SOURCE or DEST might be null if not from a declared entity. */
14496 if (!source || !dest)
14498 if (JNULLP_TYPE_P (source))
14500 if (TREE_CODE (source) == POINTER_TYPE)
14501 source = TREE_TYPE (source);
14502 if (TREE_CODE (dest) == POINTER_TYPE)
14503 dest = TREE_TYPE (dest);
14504 /* Case where SOURCE is a class type */
14505 if (TYPE_CLASS_P (source))
14507 if (TYPE_CLASS_P (dest))
14508 return (source == dest
14509 || inherits_from_p (source, dest)
14510 || enclosing_context_p (dest, source /*source, dest*/)
14511 || (cast && inherits_from_p (dest, source)));
14512 if (TYPE_INTERFACE_P (dest))
14514 /* If doing a cast and SOURCE is final, the operation is
14515 always correct a compile time (because even if SOURCE
14516 does not implement DEST, a subclass of SOURCE might). */
14517 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14519 /* Otherwise, SOURCE must implement DEST */
14520 return interface_of_p (dest, source);
14522 /* DEST is an array, cast permited if SOURCE is of Object type */
14523 return (cast && source == object_type_node ? 1 : 0);
14525 if (TYPE_INTERFACE_P (source))
14527 if (TYPE_CLASS_P (dest))
14529 /* If not casting, DEST must be the Object type */
14531 return dest == object_type_node;
14532 /* We're doing a cast. The cast is always valid is class
14533 DEST is not final, otherwise, DEST must implement SOURCE */
14534 else if (!CLASS_FINAL (TYPE_NAME (dest)))
14537 return interface_of_p (source, dest);
14539 if (TYPE_INTERFACE_P (dest))
14541 /* If doing a cast, then if SOURCE and DEST contain method
14542 with the same signature but different return type, then
14543 this is a (compile time) error */
14546 tree method_source, method_dest;
14550 for (method_source = TYPE_METHODS (source); method_source;
14551 method_source = TREE_CHAIN (method_source))
14554 build_java_argument_signature (TREE_TYPE (method_source));
14555 source_type = TREE_TYPE (TREE_TYPE (method_source));
14556 source_name = DECL_NAME (method_source);
14557 for (method_dest = TYPE_METHODS (dest);
14558 method_dest; method_dest = TREE_CHAIN (method_dest))
14560 build_java_argument_signature (TREE_TYPE (method_dest))
14561 && source_name == DECL_NAME (method_dest)
14562 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14568 return source == dest || interface_of_p (dest, source);
14572 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14574 if (TYPE_ARRAY_P (source))
14576 if (TYPE_CLASS_P (dest))
14577 return dest == object_type_node;
14578 /* Can't cast an array to an interface unless the interface is
14579 java.lang.Cloneable */
14580 if (TYPE_INTERFACE_P (dest))
14581 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14584 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14585 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14587 /* In case of severe errors, they turn out null */
14588 if (!dest_element_type || !source_element_type)
14590 if (source_element_type == dest_element_type)
14592 return valid_ref_assignconv_cast_p (source_element_type,
14593 dest_element_type, cast);
14601 valid_cast_to_p (source, dest)
14605 if (TREE_CODE (source) == POINTER_TYPE)
14606 source = TREE_TYPE (source);
14607 if (TREE_CODE (dest) == POINTER_TYPE)
14608 dest = TREE_TYPE (dest);
14610 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14611 return valid_ref_assignconv_cast_p (source, dest, 1);
14613 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14619 /* Method invocation conversion test. Return 1 if type SOURCE can be
14620 converted to type DEST through the methond invocation conversion
14624 do_unary_numeric_promotion (arg)
14627 tree type = TREE_TYPE (arg);
14628 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14629 : TREE_CODE (type) == CHAR_TYPE)
14630 arg = convert (int_type_node, arg);
14634 /* Return a non zero value if SOURCE can be converted into DEST using
14635 the method invocation conversion rule (5.3). */
14637 valid_method_invocation_conversion_p (dest, source)
14640 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14641 && valid_builtin_assignconv_identity_widening_p (dest, source))
14642 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14643 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14644 && valid_ref_assignconv_cast_p (source, dest, 0)));
14647 /* Build an incomplete binop expression. */
14650 build_binop (op, op_location, op1, op2)
14655 tree binop = build (op, NULL_TREE, op1, op2);
14656 TREE_SIDE_EFFECTS (binop) = 1;
14657 /* Store the location of the operator, for better error report. The
14658 string of the operator will be rebuild based on the OP value. */
14659 EXPR_WFL_LINECOL (binop) = op_location;
14663 /* Build the string of the operator retained by NODE. If NODE is part
14664 of a compound expression, add an '=' at the end of the string. This
14665 function is called when an error needs to be reported on an
14666 operator. The string is returned as a pointer to a static character
14670 operator_string (node)
14673 #define BUILD_OPERATOR_STRING(S) \
14675 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14679 static char buffer [10];
14680 switch (TREE_CODE (node))
14682 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14683 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14684 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14685 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14686 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14687 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14688 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14689 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14690 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14691 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14692 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14693 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14694 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14695 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14696 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14697 case GT_EXPR: BUILD_OPERATOR_STRING (">");
14698 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14699 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14700 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14701 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14702 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14703 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14704 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14705 case PREINCREMENT_EXPR: /* Fall through */
14706 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14707 case PREDECREMENT_EXPR: /* Fall through */
14708 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14710 fatal ("unregistered operator %s - operator_string",
14711 tree_code_name [TREE_CODE (node)]);
14714 #undef BUILD_OPERATOR_STRING
14717 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
14720 java_decl_equiv (var_acc1, var_acc2)
14721 tree var_acc1, var_acc2;
14723 if (JDECL_P (var_acc1))
14724 return (var_acc1 == var_acc2);
14726 return (TREE_CODE (var_acc1) == COMPONENT_REF
14727 && TREE_CODE (var_acc2) == COMPONENT_REF
14728 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14729 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14730 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14733 /* Return a non zero value if CODE is one of the operators that can be
14734 used in conjunction with the `=' operator in a compound assignment. */
14737 binop_compound_p (code)
14738 enum tree_code code;
14741 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14742 if (binop_lookup [i] == code)
14745 return i < BINOP_COMPOUND_CANDIDATES;
14748 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
14754 tree c, b, ns, decl;
14756 if (TREE_CODE (t) != MODIFY_EXPR)
14759 c = TREE_OPERAND (t, 1);
14760 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14761 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14762 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14765 /* Now the left branch of the binary operator. */
14766 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14767 if (! (b && TREE_CODE (b) == NOP_EXPR
14768 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14771 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14772 if (! (ns && TREE_CODE (ns) == NOP_EXPR
14773 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14776 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14777 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14778 /* It's got to be the an equivalent decl */
14779 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14781 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14782 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14783 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14784 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14785 /* Change the right part of the BINOP_EXPR */
14786 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14792 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14793 errors but we modify NODE so that it contains the type computed
14794 according to the expression, when it's fixed. Otherwise, we write
14795 error_mark_node as the type. It allows us to further the analysis
14796 of remaining nodes and detects more errors in certain cases. */
14799 patch_binop (node, wfl_op1, wfl_op2)
14804 tree op1 = TREE_OPERAND (node, 0);
14805 tree op2 = TREE_OPERAND (node, 1);
14806 tree op1_type = TREE_TYPE (op1);
14807 tree op2_type = TREE_TYPE (op2);
14808 tree prom_type = NULL_TREE, cn;
14809 int code = TREE_CODE (node);
14811 /* If 1, tell the routine that we have to return error_mark_node
14812 after checking for the initialization of the RHS */
14813 int error_found = 0;
14815 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14819 /* 15.16 Multiplicative operators */
14820 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
14821 case RDIV_EXPR: /* 15.16.2 Division Operator / */
14822 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
14823 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
14824 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14826 if (!JPRIMITIVE_TYPE_P (op1_type))
14827 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14828 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14829 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14830 TREE_TYPE (node) = error_mark_node;
14834 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14835 /* Change the division operator if necessary */
14836 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14837 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14839 if (TREE_CODE (prom_type) == INTEGER_TYPE
14840 && flag_use_divide_subroutine
14841 && ! flag_emit_class_files
14842 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14843 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14845 /* This one is more complicated. FLOATs are processed by a
14846 function call to soft_fmod. Duplicate the value of the
14847 COMPOUND_ASSIGN_P flag. */
14848 if (code == TRUNC_MOD_EXPR)
14850 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
14851 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
14852 TREE_SIDE_EFFECTS (mod)
14853 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14858 /* 15.17 Additive Operators */
14859 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
14861 /* Operation is valid if either one argument is a string
14862 constant, a String object or a StringBuffer crafted for the
14863 purpose of the a previous usage of the String concatenation
14866 if (TREE_CODE (op1) == STRING_CST
14867 || TREE_CODE (op2) == STRING_CST
14868 || JSTRING_TYPE_P (op1_type)
14869 || JSTRING_TYPE_P (op2_type)
14870 || IS_CRAFTED_STRING_BUFFER_P (op1)
14871 || IS_CRAFTED_STRING_BUFFER_P (op2))
14872 return build_string_concatenation (op1, op2);
14874 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
14876 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14878 if (!JPRIMITIVE_TYPE_P (op1_type))
14879 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14880 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14881 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14882 TREE_TYPE (node) = error_mark_node;
14886 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14889 /* 15.18 Shift Operators */
14893 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
14895 if (!JINTEGRAL_TYPE_P (op1_type))
14896 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14899 if (JPRIMITIVE_TYPE_P (op2_type))
14900 parse_error_context (wfl_operator,
14901 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
14902 operator_string (node),
14903 lang_printable_name (op2_type, 0));
14905 parse_error_context (wfl_operator,
14906 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
14907 operator_string (node),
14908 lang_printable_name (op2_type, 0));
14910 TREE_TYPE (node) = error_mark_node;
14915 /* Unary numeric promotion (5.6.1) is performed on each operand
14917 op1 = do_unary_numeric_promotion (op1);
14918 op2 = do_unary_numeric_promotion (op2);
14920 /* The type of the shift expression is the type of the promoted
14921 type of the left-hand operand */
14922 prom_type = TREE_TYPE (op1);
14924 /* Shift int only up to 0x1f and long up to 0x3f */
14925 if (prom_type == int_type_node)
14926 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14927 build_int_2 (0x1f, 0)));
14929 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14930 build_int_2 (0x3f, 0)));
14932 /* The >>> operator is a >> operating on unsigned quantities */
14933 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
14936 tree utype = unsigned_type (prom_type);
14937 op1 = convert (utype, op1);
14938 TREE_SET_CODE (node, RSHIFT_EXPR);
14939 TREE_OPERAND (node, 0) = op1;
14940 TREE_OPERAND (node, 1) = op2;
14941 TREE_TYPE (node) = utype;
14942 to_return = convert (prom_type, node);
14943 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
14944 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
14945 TREE_SIDE_EFFECTS (to_return)
14946 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14951 /* 15.19.1 Type Comparison Operator instaceof */
14952 case INSTANCEOF_EXPR:
14954 TREE_TYPE (node) = boolean_type_node;
14956 if (!(op2_type = resolve_type_during_patch (op2)))
14957 return error_mark_node;
14959 /* The first operand must be a reference type or the null type */
14960 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
14961 error_found = 1; /* Error reported further below */
14963 /* The second operand must be a reference type */
14964 if (!JREFERENCE_TYPE_P (op2_type))
14966 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14967 parse_error_context
14968 (wfl_operator, "Invalid argument `%s' for `instanceof'",
14969 lang_printable_name (op2_type, 0));
14973 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
14975 /* If the first operand is null, the result is always false */
14976 if (op1 == null_pointer_node)
14977 return boolean_false_node;
14978 else if (flag_emit_class_files)
14980 TREE_OPERAND (node, 1) = op2_type;
14981 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
14984 /* Otherwise we have to invoke instance of to figure it out */
14988 build (CALL_EXPR, boolean_type_node,
14989 build_address_of (soft_instanceof_node),
14992 build_tree_list (NULL_TREE,
14993 build_class_ref (op2_type))),
14995 TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
14999 /* There is no way the expression operand can be an instance of
15000 the type operand. This is a compile time error. */
15003 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
15004 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
15005 parse_error_context
15006 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
15007 t1, lang_printable_name (op2_type, 0));
15014 /* 15.21 Bitwise and Logical Operators */
15018 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15019 /* Binary numeric promotion is performed on both operand and the
15020 expression retain that type */
15021 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15023 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
15024 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15025 /* The type of the bitwise operator expression is BOOLEAN */
15026 prom_type = boolean_type_node;
15029 if (!JINTEGRAL_TYPE_P (op1_type))
15030 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15031 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15032 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15033 TREE_TYPE (node) = error_mark_node;
15035 /* Insert a break here if adding thing before the switch's
15036 break for this case */
15040 /* 15.22 Conditional-And Operator */
15041 case TRUTH_ANDIF_EXPR:
15042 /* 15.23 Conditional-Or Operator */
15043 case TRUTH_ORIF_EXPR:
15044 /* Operands must be of BOOLEAN type */
15045 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
15046 TREE_CODE (op2_type) != BOOLEAN_TYPE)
15048 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15049 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15050 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15051 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15052 TREE_TYPE (node) = boolean_type_node;
15056 /* The type of the conditional operators is BOOLEAN */
15057 prom_type = boolean_type_node;
15060 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15065 /* The type of each of the operands must be a primitive numeric
15067 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15069 if (!JNUMERIC_TYPE_P (op1_type))
15070 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15071 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15072 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15073 TREE_TYPE (node) = boolean_type_node;
15077 /* Binary numeric promotion is performed on the operands */
15078 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15079 /* The type of the relation expression is always BOOLEAN */
15080 prom_type = boolean_type_node;
15083 /* 15.20 Equality Operator */
15086 /* It's time for us to patch the strings. */
15087 if ((cn = patch_string (op1)))
15090 op1_type = TREE_TYPE (op1);
15092 if ((cn = patch_string (op2)))
15095 op2_type = TREE_TYPE (op2);
15098 /* 15.20.1 Numerical Equality Operators == and != */
15099 /* Binary numeric promotion is performed on the operands */
15100 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15101 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15103 /* 15.20.2 Boolean Equality Operators == and != */
15104 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15105 TREE_CODE (op2_type) == BOOLEAN_TYPE)
15106 ; /* Nothing to do here */
15108 /* 15.20.3 Reference Equality Operators == and != */
15109 /* Types have to be either references or the null type. If
15110 they're references, it must be possible to convert either
15111 type to the other by casting conversion. */
15112 else if (op1 == null_pointer_node || op2 == null_pointer_node
15113 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15114 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15115 || valid_ref_assignconv_cast_p (op2_type,
15117 ; /* Nothing to do here */
15119 /* Else we have an error figure what can't be converted into
15120 what and report the error */
15124 t1 = xstrdup (lang_printable_name (op1_type, 0));
15125 parse_error_context
15127 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15128 operator_string (node), t1,
15129 lang_printable_name (op2_type, 0));
15131 TREE_TYPE (node) = boolean_type_node;
15135 prom_type = boolean_type_node;
15140 return error_mark_node;
15142 TREE_OPERAND (node, 0) = op1;
15143 TREE_OPERAND (node, 1) = op2;
15144 TREE_TYPE (node) = prom_type;
15145 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15147 if (flag_emit_xref)
15150 /* fold does not respect side-effect order as required for Java but not C.
15151 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15154 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15155 : ! TREE_SIDE_EFFECTS (node))
15156 node = fold (node);
15160 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15161 zero value, the value of CSTE comes after the valude of STRING */
15164 do_merge_string_cste (cste, string, string_len, after)
15166 const char *string;
15167 int string_len, after;
15169 int len = TREE_STRING_LENGTH (cste) + string_len;
15170 const char *old = TREE_STRING_POINTER (cste);
15171 TREE_STRING_LENGTH (cste) = len;
15172 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15175 strcpy (TREE_STRING_POINTER (cste), string);
15176 strcat (TREE_STRING_POINTER (cste), old);
15180 strcpy (TREE_STRING_POINTER (cste), old);
15181 strcat (TREE_STRING_POINTER (cste), string);
15186 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15187 new STRING_CST on success, NULL_TREE on failure */
15190 merge_string_cste (op1, op2, after)
15194 /* Handle two string constants right away */
15195 if (TREE_CODE (op2) == STRING_CST)
15196 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
15197 TREE_STRING_LENGTH (op2), after);
15199 /* Reasonable integer constant can be treated right away */
15200 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15202 static const char *boolean_true = "true";
15203 static const char *boolean_false = "false";
15204 static const char *null_pointer = "null";
15206 const char *string;
15208 if (op2 == boolean_true_node)
15209 string = boolean_true;
15210 else if (op2 == boolean_false_node)
15211 string = boolean_false;
15212 else if (op2 == null_pointer_node)
15213 string = null_pointer;
15214 else if (TREE_TYPE (op2) == char_type_node)
15216 ch[0] = (char )TREE_INT_CST_LOW (op2);
15221 string = print_int_node (op2);
15223 return do_merge_string_cste (op1, string, strlen (string), after);
15228 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15229 has to be a STRING_CST and the other part must be a STRING_CST or a
15230 INTEGRAL constant. Return a new STRING_CST if the operation
15231 succeed, NULL_TREE otherwise.
15233 If the case we want to optimize for space, we might want to return
15234 NULL_TREE for each invocation of this routine. FIXME */
15237 string_constant_concatenation (op1, op2)
15240 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15245 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15246 rest = (string == op1 ? op2 : op1);
15247 invert = (string == op1 ? 0 : 1 );
15249 /* Walk REST, only if it looks reasonable */
15250 if (TREE_CODE (rest) != STRING_CST
15251 && !IS_CRAFTED_STRING_BUFFER_P (rest)
15252 && !JSTRING_TYPE_P (TREE_TYPE (rest))
15253 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15255 rest = java_complete_tree (rest);
15256 if (rest == error_mark_node)
15257 return error_mark_node;
15258 rest = fold (rest);
15260 return merge_string_cste (string, rest, invert);
15265 /* Implement the `+' operator. Does static optimization if possible,
15266 otherwise create (if necessary) and append elements to a
15267 StringBuffer. The StringBuffer will be carried around until it is
15268 used for a function call or an assignment. Then toString() will be
15269 called on it to turn it into a String object. */
15272 build_string_concatenation (op1, op2)
15276 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15278 if (flag_emit_xref)
15279 return build (PLUS_EXPR, string_type_node, op1, op2);
15281 /* Try to do some static optimization */
15282 if ((result = string_constant_concatenation (op1, op2)))
15285 /* Discard empty strings on either side of the expression */
15286 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15291 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15294 /* If operands are string constant, turn then into object references */
15295 if (TREE_CODE (op1) == STRING_CST)
15296 op1 = patch_string_cst (op1);
15297 if (op2 && TREE_CODE (op2) == STRING_CST)
15298 op2 = patch_string_cst (op2);
15300 /* If either one of the constant is null and the other non null
15301 operand is a String object, return it. */
15302 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15305 /* If OP1 isn't already a StringBuffer, create and
15306 initialize a new one */
15307 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15309 /* Two solutions here:
15310 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15311 2) OP1 is something else, we call new StringBuffer().append(OP1). */
15312 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15313 op1 = BUILD_STRING_BUFFER (op1);
15316 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15317 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15323 /* OP1 is no longer the last node holding a crafted StringBuffer */
15324 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15325 /* Create a node for `{new...,xxx}.append (op2)' */
15327 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15330 /* Mark the last node holding a crafted StringBuffer */
15331 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15333 TREE_SIDE_EFFECTS (op1) = side_effects;
15337 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15338 StringBuffer. If no string were found to be patched, return
15342 patch_string (node)
15345 if (node == error_mark_node)
15346 return error_mark_node;
15347 if (TREE_CODE (node) == STRING_CST)
15348 return patch_string_cst (node);
15349 else if (IS_CRAFTED_STRING_BUFFER_P (node))
15351 int saved = ctxp->explicit_constructor_p;
15352 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15354 /* Temporary disable forbid the use of `this'. */
15355 ctxp->explicit_constructor_p = 0;
15356 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15357 /* String concatenation arguments must be evaluated in order too. */
15358 ret = force_evaluation_order (ret);
15359 /* Restore it at its previous value */
15360 ctxp->explicit_constructor_p = saved;
15366 /* Build the internal representation of a string constant. */
15369 patch_string_cst (node)
15373 if (! flag_emit_class_files)
15375 push_obstacks (&permanent_obstack, &permanent_obstack);
15376 node = get_identifier (TREE_STRING_POINTER (node));
15377 location = alloc_name_constant (CONSTANT_String, node);
15378 node = build_ref_from_constant_pool (location);
15381 TREE_TYPE (node) = string_ptr_type_node;
15382 TREE_CONSTANT (node) = 1;
15386 /* Build an incomplete unary operator expression. */
15389 build_unaryop (op_token, op_location, op1)
15390 int op_token, op_location;
15397 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15398 case MINUS_TK: op = NEGATE_EXPR; break;
15399 case NEG_TK: op = TRUTH_NOT_EXPR; break;
15400 case NOT_TK: op = BIT_NOT_EXPR; break;
15401 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15405 unaryop = build1 (op, NULL_TREE, op1);
15406 TREE_SIDE_EFFECTS (unaryop) = 1;
15407 /* Store the location of the operator, for better error report. The
15408 string of the operator will be rebuild based on the OP value. */
15409 EXPR_WFL_LINECOL (unaryop) = op_location;
15413 /* Special case for the ++/-- operators, since they require an extra
15414 argument to build, which is set to NULL and patched
15415 later. IS_POST_P is 1 if the operator, 0 otherwise. */
15418 build_incdec (op_token, op_location, op1, is_post_p)
15419 int op_token, op_location;
15423 static enum tree_code lookup [2][2] =
15425 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15426 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15428 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
15429 NULL_TREE, op1, NULL_TREE);
15430 TREE_SIDE_EFFECTS (node) = 1;
15431 /* Store the location of the operator, for better error report. The
15432 string of the operator will be rebuild based on the OP value. */
15433 EXPR_WFL_LINECOL (node) = op_location;
15437 /* Build an incomplete cast operator, based on the use of the
15438 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15439 set. java_complete_tree is trained to walk a CONVERT_EXPR even
15440 though its type is already set. */
15443 build_cast (location, type, exp)
15447 tree node = build1 (CONVERT_EXPR, type, exp);
15448 EXPR_WFL_LINECOL (node) = location;
15452 /* Build an incomplete class reference operator. */
15454 build_incomplete_class_ref (location, class_name)
15458 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15459 EXPR_WFL_LINECOL (node) = location;
15463 /* Complete an incomplete class reference operator. */
15465 patch_incomplete_class_ref (node)
15468 tree type = TREE_OPERAND (node, 0);
15471 if (!(ref_type = resolve_type_during_patch (type)))
15472 return error_mark_node;
15474 if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15475 return build_class_ref (ref_type);
15477 /* If we're emitting class files and we have to deal with non
15478 primitive types, we invoke (and consider generating) the
15479 synthetic static method `class$'. */
15480 if (!TYPE_DOT_CLASS (current_class))
15481 build_dot_class_method (current_class);
15483 build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15484 return java_complete_tree (ref_type);
15487 /* 15.14 Unary operators. We return error_mark_node in case of error,
15488 but preserve the type of NODE if the type is fixed. */
15491 patch_unaryop (node, wfl_op)
15495 tree op = TREE_OPERAND (node, 0);
15496 tree op_type = TREE_TYPE (op);
15497 tree prom_type = NULL_TREE, value, decl;
15498 int outer_field_flag = 0;
15499 int code = TREE_CODE (node);
15500 int error_found = 0;
15502 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15506 /* 15.13.2 Postfix Increment Operator ++ */
15507 case POSTINCREMENT_EXPR:
15508 /* 15.13.3 Postfix Increment Operator -- */
15509 case POSTDECREMENT_EXPR:
15510 /* 15.14.1 Prefix Increment Operator ++ */
15511 case PREINCREMENT_EXPR:
15512 /* 15.14.2 Prefix Decrement Operator -- */
15513 case PREDECREMENT_EXPR:
15514 op = decl = strip_out_static_field_access_decl (op);
15515 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15516 /* We might be trying to change an outer field accessed using
15518 if (outer_field_flag)
15520 /* Retrieve the decl of the field we're trying to access. We
15521 do that by first retrieving the function we would call to
15522 access the field. It has been already verified that this
15523 field isn't final */
15524 if (flag_emit_class_files)
15525 decl = TREE_OPERAND (op, 0);
15527 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15528 decl = DECL_FUNCTION_ACCESS_DECL (decl);
15530 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15531 else if (!JDECL_P (decl)
15532 && TREE_CODE (decl) != COMPONENT_REF
15533 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15534 && TREE_CODE (decl) != INDIRECT_REF
15535 && !(TREE_CODE (decl) == COMPOUND_EXPR
15536 && TREE_OPERAND (decl, 1)
15537 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15540 /* Before screaming, check that we're not in fact trying to
15541 increment a optimized static final access, in which case
15542 we issue an different error message. */
15543 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15544 && resolve_expression_name (wfl_op, &lvalue)
15545 && check_final_assignment (lvalue, wfl_op)))
15546 parse_error_context (wfl_operator, "Invalid argument to `%s'",
15547 operator_string (node));
15548 TREE_TYPE (node) = error_mark_node;
15552 if (check_final_assignment (op, wfl_op))
15555 /* From now on, we know that op if a variable and that it has a
15556 valid wfl. We use wfl_op to locate errors related to the
15558 else if (!JNUMERIC_TYPE_P (op_type))
15560 parse_error_context
15561 (wfl_op, "Invalid argument type `%s' to `%s'",
15562 lang_printable_name (op_type, 0), operator_string (node));
15563 TREE_TYPE (node) = error_mark_node;
15568 /* Before the addition, binary numeric promotion is performed on
15569 both operands, if really necessary */
15570 if (JINTEGRAL_TYPE_P (op_type))
15572 value = build_int_2 (1, 0);
15573 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15577 value = build_int_2 (1, 0);
15579 binary_numeric_promotion (op_type,
15580 TREE_TYPE (value), &op, &value);
15583 /* We remember we might be accessing an outer field */
15584 if (outer_field_flag)
15586 /* We re-generate an access to the field */
15587 value = build (PLUS_EXPR, TREE_TYPE (op),
15588 build_outer_field_access (wfl_op, decl), value);
15590 /* And we patch the original access$() into a write
15591 with plus_op as a rhs */
15592 return outer_field_access_fix (node, op, value);
15595 /* And write back into the node. */
15596 TREE_OPERAND (node, 0) = op;
15597 TREE_OPERAND (node, 1) = value;
15598 /* Convert the overall back into its original type, if
15599 necessary, and return */
15600 if (JINTEGRAL_TYPE_P (op_type))
15601 return fold (node);
15603 return fold (convert (op_type, node));
15607 /* 15.14.3 Unary Plus Operator + */
15608 case UNARY_PLUS_EXPR:
15609 /* 15.14.4 Unary Minus Operator - */
15611 if (!JNUMERIC_TYPE_P (op_type))
15613 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15614 TREE_TYPE (node) = error_mark_node;
15617 /* Unary numeric promotion is performed on operand */
15620 op = do_unary_numeric_promotion (op);
15621 prom_type = TREE_TYPE (op);
15622 if (code == UNARY_PLUS_EXPR)
15627 /* 15.14.5 Bitwise Complement Operator ~ */
15629 if (!JINTEGRAL_TYPE_P (op_type))
15631 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15632 TREE_TYPE (node) = error_mark_node;
15637 op = do_unary_numeric_promotion (op);
15638 prom_type = TREE_TYPE (op);
15642 /* 15.14.6 Logical Complement Operator ! */
15643 case TRUTH_NOT_EXPR:
15644 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15646 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15647 /* But the type is known. We will report an error if further
15648 attempt of a assignment is made with this rhs */
15649 TREE_TYPE (node) = boolean_type_node;
15653 prom_type = boolean_type_node;
15656 /* 15.15 Cast Expression */
15658 value = patch_cast (node, wfl_operator);
15659 if (value == error_mark_node)
15661 /* If this cast is part of an assignment, we tell the code
15662 that deals with it not to complain about a mismatch,
15663 because things have been cast, anyways */
15664 TREE_TYPE (node) = error_mark_node;
15669 value = fold (value);
15670 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15677 return error_mark_node;
15679 /* There are cases where node has been replaced by something else
15680 and we don't end up returning here: UNARY_PLUS_EXPR,
15681 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15682 TREE_OPERAND (node, 0) = fold (op);
15683 TREE_TYPE (node) = prom_type;
15684 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15685 return fold (node);
15688 /* Generic type resolution that sometimes takes place during node
15689 patching. Returned the resolved type or generate an error
15690 message. Return the resolved type or NULL_TREE. */
15693 resolve_type_during_patch (type)
15696 if (unresolved_type_p (type, NULL))
15698 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15701 parse_error_context (type,
15702 "Class `%s' not found in type declaration",
15703 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15708 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15709 return TREE_TYPE (type_decl);
15714 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15715 found. Otherwise NODE or something meant to replace it is returned. */
15718 patch_cast (node, wfl_operator)
15722 tree op = TREE_OPERAND (node, 0);
15723 tree op_type = TREE_TYPE (op);
15724 tree cast_type = TREE_TYPE (node);
15727 /* First resolve OP_TYPE if unresolved */
15728 if (!(cast_type = resolve_type_during_patch (cast_type)))
15729 return error_mark_node;
15731 /* Check on cast that are proven correct at compile time */
15732 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15735 if (cast_type == op_type)
15738 /* float and double type are converted to the original type main
15739 variant and then to the target type. */
15740 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15741 op = convert (integer_type_node, op);
15743 /* Try widening/narowwing convertion. Potentially, things need
15744 to be worked out in gcc so we implement the extreme cases
15745 correctly. fold_convert() needs to be fixed. */
15746 return convert (cast_type, op);
15749 /* It's also valid to cast a boolean into a boolean */
15750 if (op_type == boolean_type_node && cast_type == boolean_type_node)
15753 /* null can be casted to references */
15754 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15755 return build_null_of_type (cast_type);
15757 /* The remaining legal casts involve conversion between reference
15758 types. Check for their compile time correctness. */
15759 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
15760 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15762 TREE_TYPE (node) = promote_type (cast_type);
15763 /* Now, the case can be determined correct at compile time if
15764 OP_TYPE can be converted into CAST_TYPE by assignment
15765 conversion (5.2) */
15767 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15769 TREE_SET_CODE (node, NOP_EXPR);
15773 if (flag_emit_class_files)
15775 TREE_SET_CODE (node, CONVERT_EXPR);
15779 /* The cast requires a run-time check */
15780 return build (CALL_EXPR, promote_type (cast_type),
15781 build_address_of (soft_checkcast_node),
15782 tree_cons (NULL_TREE, build_class_ref (cast_type),
15783 build_tree_list (NULL_TREE, op)),
15787 /* Any other casts are proven incorrect at compile time */
15788 t1 = xstrdup (lang_printable_name (op_type, 0));
15789 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15790 t1, lang_printable_name (cast_type, 0));
15792 return error_mark_node;
15795 /* Build a null constant and give it the type TYPE. */
15798 build_null_of_type (type)
15801 tree node = build_int_2 (0, 0);
15802 TREE_TYPE (node) = promote_type (type);
15806 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15807 a list of indices. */
15809 build_array_ref (location, array, index)
15813 tree node = build (ARRAY_REF, NULL_TREE, array, index);
15814 EXPR_WFL_LINECOL (node) = location;
15818 /* 15.12 Array Access Expression */
15821 patch_array_ref (node)
15824 tree array = TREE_OPERAND (node, 0);
15825 tree array_type = TREE_TYPE (array);
15826 tree index = TREE_OPERAND (node, 1);
15827 tree index_type = TREE_TYPE (index);
15828 int error_found = 0;
15830 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15832 if (TREE_CODE (array_type) == POINTER_TYPE)
15833 array_type = TREE_TYPE (array_type);
15835 /* The array reference must be an array */
15836 if (!TYPE_ARRAY_P (array_type))
15838 parse_error_context
15840 "`[]' can only be applied to arrays. It can't be applied to `%s'",
15841 lang_printable_name (array_type, 0));
15842 TREE_TYPE (node) = error_mark_node;
15846 /* The array index undergoes unary numeric promotion. The promoted
15847 type must be int */
15848 index = do_unary_numeric_promotion (index);
15849 if (TREE_TYPE (index) != int_type_node)
15851 if (valid_cast_to_p (index_type, int_type_node))
15852 parse_error_context (wfl_operator,
15853 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15854 lang_printable_name (index_type, 0));
15856 parse_error_context (wfl_operator,
15857 "Incompatible type for `[]'. Can't convert `%s' to `int'",
15858 lang_printable_name (index_type, 0));
15859 TREE_TYPE (node) = error_mark_node;
15864 return error_mark_node;
15866 array_type = TYPE_ARRAY_ELEMENT (array_type);
15868 if (flag_emit_class_files || flag_emit_xref)
15870 TREE_OPERAND (node, 0) = array;
15871 TREE_OPERAND (node, 1) = index;
15875 /* The save_expr is for correct evaluation order. It would be cleaner
15876 to use force_evaluation_order (see comment there), but that is
15877 difficult when we also have to deal with bounds checking. */
15878 if (TREE_SIDE_EFFECTS (index))
15879 array = save_expr (array);
15880 node = build_java_arrayaccess (array, array_type, index);
15881 if (TREE_SIDE_EFFECTS (index))
15882 node = build (COMPOUND_EXPR, array_type, array, node);
15884 TREE_TYPE (node) = array_type;
15888 /* 15.9 Array Creation Expressions */
15891 build_newarray_node (type, dims, extra_dims)
15897 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
15898 build_int_2 (extra_dims, 0));
15903 patch_newarray (node)
15906 tree type = TREE_OPERAND (node, 0);
15907 tree dims = TREE_OPERAND (node, 1);
15908 tree cdim, array_type;
15909 int error_found = 0;
15911 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
15913 /* Dimension types are verified. It's better for the types to be
15914 verified in order. */
15915 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
15918 tree dim = TREE_VALUE (cdim);
15920 /* Dim might have been saved during its evaluation */
15921 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
15923 /* The type of each specified dimension must be an integral type. */
15924 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
15927 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
15928 promoted type must be int. */
15931 dim = do_unary_numeric_promotion (dim);
15932 if (TREE_TYPE (dim) != int_type_node)
15936 /* Report errors on types here */
15939 parse_error_context
15940 (TREE_PURPOSE (cdim),
15941 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
15942 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
15943 "Explicit cast needed to" : "Can't"),
15944 lang_printable_name (TREE_TYPE (dim), 0));
15948 TREE_PURPOSE (cdim) = NULL_TREE;
15951 /* Resolve array base type if unresolved */
15952 if (!(type = resolve_type_during_patch (type)))
15957 /* We don't want further evaluation of this bogus array creation
15959 TREE_TYPE (node) = error_mark_node;
15960 return error_mark_node;
15963 /* Set array_type to the actual (promoted) array type of the result. */
15964 if (TREE_CODE (type) == RECORD_TYPE)
15965 type = build_pointer_type (type);
15966 while (--xdims >= 0)
15968 type = promote_type (build_java_array_type (type, -1));
15970 dims = nreverse (dims);
15972 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
15976 = build_java_array_type (type,
15977 TREE_CODE (cdim) == INTEGER_CST
15978 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
15980 array_type = promote_type (array_type);
15982 dims = nreverse (dims);
15984 /* The node is transformed into a function call. Things are done
15985 differently according to the number of dimensions. If the number
15986 of dimension is equal to 1, then the nature of the base type
15987 (primitive or not) matters. */
15989 return build_new_array (type, TREE_VALUE (dims));
15991 /* Can't reuse what's already written in expr.c because it uses the
15992 JVM stack representation. Provide a build_multianewarray. FIXME */
15993 return build (CALL_EXPR, array_type,
15994 build_address_of (soft_multianewarray_node),
15995 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
15996 tree_cons (NULL_TREE,
15997 build_int_2 (ndims, 0), dims )),
16001 /* 10.6 Array initializer. */
16003 /* Build a wfl for array element that don't have one, so we can
16004 pin-point errors. */
16007 maybe_build_array_element_wfl (node)
16010 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
16011 return build_expr_wfl (NULL_TREE, ctxp->filename,
16012 ctxp->elc.line, ctxp->elc.prev_col);
16017 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16018 identification of initialized arrays easier to detect during walk
16022 build_new_array_init (location, values)
16026 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16027 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16028 EXPR_WFL_LINECOL (to_return) = location;
16032 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16033 occurred. Otherwise return NODE after having set its type
16037 patch_new_array_init (type, node)
16040 int error_seen = 0;
16041 tree current, element_type;
16042 HOST_WIDE_INT length;
16043 int all_constant = 1;
16044 tree init = TREE_OPERAND (node, 0);
16046 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16048 parse_error_context (node,
16049 "Invalid array initializer for non-array type `%s'",
16050 lang_printable_name (type, 1));
16051 return error_mark_node;
16053 type = TREE_TYPE (type);
16054 element_type = TYPE_ARRAY_ELEMENT (type);
16056 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16058 for (length = 0, current = CONSTRUCTOR_ELTS (init);
16059 current; length++, current = TREE_CHAIN (current))
16061 tree elt = TREE_VALUE (current);
16062 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16064 error_seen |= array_constructor_check_entry (element_type, current);
16065 elt = TREE_VALUE (current);
16066 /* When compiling to native code, STRING_CST is converted to
16067 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16068 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16073 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16074 TREE_PURPOSE (current) = NULL_TREE;
16077 if (elt && TREE_VALUE (elt) == error_mark_node)
16082 return error_mark_node;
16084 /* Create a new type. We can't reuse the one we have here by
16085 patching its dimension because it originally is of dimension -1
16086 hence reused by gcc. This would prevent triangular arrays. */
16087 type = build_java_array_type (element_type, length);
16088 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16089 TREE_TYPE (node) = promote_type (type);
16090 TREE_CONSTANT (init) = all_constant;
16091 TREE_CONSTANT (node) = all_constant;
16095 /* Verify that one entry of the initializer element list can be
16096 assigned to the array base type. Report 1 if an error occurred, 0
16100 array_constructor_check_entry (type, entry)
16103 char *array_type_string = NULL; /* For error reports */
16104 tree value, type_value, new_value, wfl_value, patched;
16105 int error_seen = 0;
16107 new_value = NULL_TREE;
16108 wfl_value = TREE_VALUE (entry);
16110 push_obstacks (&permanent_obstack, &permanent_obstack);
16111 value = java_complete_tree (TREE_VALUE (entry));
16112 /* patch_string return error_mark_node if arg is error_mark_node */
16113 if ((patched = patch_string (value)))
16115 if (value == error_mark_node)
16118 type_value = TREE_TYPE (value);
16120 /* At anytime, try_builtin_assignconv can report a warning on
16121 constant overflow during narrowing. */
16122 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16123 new_value = try_builtin_assignconv (wfl_operator, type, value);
16124 if (!new_value && (new_value = try_reference_assignconv (type, value)))
16125 type_value = promote_type (type);
16128 /* Check and report errors */
16131 const char *msg = (!valid_cast_to_p (type_value, type) ?
16132 "Can't" : "Explicit cast needed to");
16133 if (!array_type_string)
16134 array_type_string = xstrdup (lang_printable_name (type, 1));
16135 parse_error_context
16136 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16137 msg, lang_printable_name (type_value, 1), array_type_string);
16143 new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
16144 TREE_VALUE (entry) = new_value;
16147 if (array_type_string)
16148 free (array_type_string);
16150 TREE_PURPOSE (entry) = NULL_TREE;
16155 build_this (location)
16158 tree node = build_wfl_node (this_identifier_node);
16159 TREE_SET_CODE (node, THIS_EXPR);
16160 EXPR_WFL_LINECOL (node) = location;
16164 /* 14.15 The return statement. It builds a modify expression that
16165 assigns the returned value to the RESULT_DECL that hold the value
16169 build_return (location, op)
16173 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16174 EXPR_WFL_LINECOL (node) = location;
16175 node = build_debugable_stmt (location, node);
16180 patch_return (node)
16183 tree return_exp = TREE_OPERAND (node, 0);
16184 tree meth = current_function_decl;
16185 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16186 int error_found = 0;
16188 TREE_TYPE (node) = error_mark_node;
16189 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16191 /* It's invalid to have a return value within a function that is
16192 declared with the keyword void or that is a constructor */
16193 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16196 /* It's invalid to use a return statement in a static block */
16197 if (DECL_CLINIT_P (current_function_decl))
16200 /* It's invalid to have a no return value within a function that
16201 isn't declared with the keyword `void' */
16202 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16205 if (in_instance_initializer)
16210 if (in_instance_initializer)
16211 parse_error_context (wfl_operator,
16212 "`return' inside instance initializer");
16214 else if (DECL_CLINIT_P (current_function_decl))
16215 parse_error_context (wfl_operator,
16216 "`return' inside static initializer");
16218 else if (!DECL_CONSTRUCTOR_P (meth))
16220 char *t = xstrdup (lang_printable_name (mtype, 0));
16221 parse_error_context (wfl_operator,
16222 "`return' with%s value from `%s %s'",
16223 (error_found == 1 ? "" : "out"),
16224 t, lang_printable_name (meth, 0));
16228 parse_error_context (wfl_operator,
16229 "`return' with value from constructor `%s'",
16230 lang_printable_name (meth, 0));
16231 return error_mark_node;
16234 /* If we have a return_exp, build a modify expression and expand
16235 it. Note: at that point, the assignment is declared valid, but we
16236 may want to carry some more hacks */
16239 tree exp = java_complete_tree (return_exp);
16240 tree modify, patched;
16242 /* If the function returned value and EXP are booleans, EXP has
16243 to be converted into the type of DECL_RESULT, which is integer
16244 (see complete_start_java_method) */
16245 if (TREE_TYPE (exp) == boolean_type_node &&
16246 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16247 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16249 /* `null' can be assigned to a function returning a reference */
16250 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16251 exp == null_pointer_node)
16252 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16254 if ((patched = patch_string (exp)))
16257 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16258 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16259 modify = java_complete_tree (modify);
16261 if (modify != error_mark_node)
16263 TREE_SIDE_EFFECTS (modify) = 1;
16264 TREE_OPERAND (node, 0) = modify;
16267 return error_mark_node;
16269 TREE_TYPE (node) = void_type_node;
16270 TREE_SIDE_EFFECTS (node) = 1;
16274 /* 14.8 The if Statement */
16277 build_if_else_statement (location, expression, if_body, else_body)
16279 tree expression, if_body, else_body;
16283 else_body = empty_stmt_node;
16284 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16285 EXPR_WFL_LINECOL (node) = location;
16286 node = build_debugable_stmt (location, node);
16291 patch_if_else_statement (node)
16294 tree expression = TREE_OPERAND (node, 0);
16296 TREE_TYPE (node) = error_mark_node;
16297 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16299 /* The type of expression must be boolean */
16300 if (TREE_TYPE (expression) != boolean_type_node
16301 && TREE_TYPE (expression) != promoted_boolean_type_node)
16303 parse_error_context
16305 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
16306 lang_printable_name (TREE_TYPE (expression), 0));
16307 return error_mark_node;
16310 TREE_TYPE (node) = void_type_node;
16311 TREE_SIDE_EFFECTS (node) = 1;
16312 CAN_COMPLETE_NORMALLY (node)
16313 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16314 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16318 /* 14.6 Labeled Statements */
16320 /* Action taken when a lableled statement is parsed. a new
16321 LABELED_BLOCK_EXPR is created. No statement is attached to the
16322 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
16325 build_labeled_block (location, label)
16330 tree label_decl, node;
16331 if (label == NULL_TREE || label == continue_identifier_node)
16332 label_name = label;
16335 label_name = merge_qualified_name (label_id, label);
16336 /* Issue an error if we try to reuse a label that was previously
16338 if (IDENTIFIER_LOCAL_VALUE (label_name))
16340 EXPR_WFL_LINECOL (wfl_operator) = location;
16341 parse_error_context (wfl_operator,
16342 "Declaration of `%s' shadows a previous label declaration",
16343 IDENTIFIER_POINTER (label));
16344 EXPR_WFL_LINECOL (wfl_operator) =
16345 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16346 parse_error_context (wfl_operator,
16347 "This is the location of the previous declaration of label `%s'",
16348 IDENTIFIER_POINTER (label));
16349 java_error_count--;
16353 label_decl = create_label_decl (label_name);
16354 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16355 EXPR_WFL_LINECOL (node) = location;
16356 TREE_SIDE_EFFECTS (node) = 1;
16360 /* A labeled statement LBE is attached a statement. */
16363 finish_labeled_statement (lbe, statement)
16364 tree lbe; /* Labeled block expr */
16367 /* In anyways, tie the loop to its statement */
16368 LABELED_BLOCK_BODY (lbe) = statement;
16369 pop_labeled_block ();
16370 POP_LABELED_BLOCK ();
16374 /* 14.10, 14.11, 14.12 Loop Statements */
16376 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16380 build_new_loop (loop_body)
16383 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
16384 TREE_SIDE_EFFECTS (loop) = 1;
16389 /* Create a loop body according to the following structure:
16391 COMPOUND_EXPR (loop main body)
16392 EXIT_EXPR (this order is for while/for loops.
16393 LABELED_BLOCK_EXPR the order is reversed for do loops)
16394 LABEL_DECL (a continue occuring here branches at the
16395 BODY end of this labeled block)
16398 REVERSED, if non zero, tells that the loop condition expr comes
16399 after the body, like in the do-while loop.
16401 To obtain a loop, the loop body structure described above is
16402 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16405 LABEL_DECL (use this label to exit the loop)
16407 <structure described above> */
16410 build_loop_body (location, condition, reversed)
16415 tree first, second, body;
16417 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16418 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16419 condition = build_debugable_stmt (location, condition);
16420 TREE_SIDE_EFFECTS (condition) = 1;
16422 body = build_labeled_block (0, continue_identifier_node);
16423 first = (reversed ? body : condition);
16424 second = (reversed ? condition : body);
16426 build (COMPOUND_EXPR, NULL_TREE,
16427 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16430 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16431 their order) on the current loop. Unlink the current loop from the
16435 finish_loop_body (location, condition, body, reversed)
16437 tree condition, body;
16440 tree to_return = ctxp->current_loop;
16441 tree loop_body = LOOP_EXPR_BODY (to_return);
16444 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16445 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16446 The real EXIT_EXPR is one operand further. */
16447 EXPR_WFL_LINECOL (cnode) = location;
16448 /* This one is for accurate error reports */
16449 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16450 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16452 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16457 /* Tailored version of finish_loop_body for FOR loops, when FOR
16458 loops feature the condition part */
16461 finish_for_loop (location, condition, update, body)
16463 tree condition, update, body;
16465 /* Put the condition and the loop body in place */
16466 tree loop = finish_loop_body (location, condition, body, 0);
16467 /* LOOP is the current loop which has been now popped of the loop
16468 stack. Install the update block */
16469 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16473 /* Try to find the loop a block might be related to. This comprises
16474 the case where the LOOP_EXPR is found as the second operand of a
16475 COMPOUND_EXPR, because the loop happens to have an initialization
16476 part, then expressed as the first operand of the COMPOUND_EXPR. If
16477 the search finds something, 1 is returned. Otherwise, 0 is
16478 returned. The search is assumed to start from a
16479 LABELED_BLOCK_EXPR's block. */
16482 search_loop (statement)
16485 if (TREE_CODE (statement) == LOOP_EXPR)
16488 if (TREE_CODE (statement) == BLOCK)
16489 statement = BLOCK_SUBBLOCKS (statement);
16493 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16494 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16495 statement = TREE_OPERAND (statement, 1);
16497 return (TREE_CODE (statement) == LOOP_EXPR
16498 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16501 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16502 returned otherwise. */
16505 labeled_block_contains_loop_p (block, loop)
16511 if (LABELED_BLOCK_BODY (block) == loop)
16514 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16520 /* If the loop isn't surrounded by a labeled statement, create one and
16521 insert LOOP as its body. */
16524 patch_loop_statement (loop)
16529 TREE_TYPE (loop) = void_type_node;
16530 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16533 loop_label = build_labeled_block (0, NULL_TREE);
16534 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16535 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16536 LABELED_BLOCK_BODY (loop_label) = loop;
16537 PUSH_LABELED_BLOCK (loop_label);
16541 /* 14.13, 14.14: break and continue Statements */
16543 /* Build a break or a continue statement. a null NAME indicates an
16544 unlabeled break/continue statement. */
16547 build_bc_statement (location, is_break, name)
16548 int location, is_break;
16551 tree break_continue, label_block_expr = NULL_TREE;
16555 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
16556 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16557 /* Null means that we don't have a target for this named
16558 break/continue. In this case, we make the target to be the
16559 label name, so that the error can be reported accuratly in
16560 patch_bc_statement. */
16561 label_block_expr = EXPR_WFL_NODE (name);
16563 /* Unlabeled break/continue will be handled during the
16564 break/continue patch operation */
16566 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16568 IS_BREAK_STMT_P (break_continue) = is_break;
16569 TREE_SIDE_EFFECTS (break_continue) = 1;
16570 EXPR_WFL_LINECOL (break_continue) = location;
16571 break_continue = build_debugable_stmt (location, break_continue);
16572 return break_continue;
16575 /* Verification of a break/continue statement. */
16578 patch_bc_statement (node)
16581 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16582 tree labeled_block = ctxp->current_labeled_block;
16583 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16585 /* Having an identifier here means that the target is unknown. */
16586 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16588 parse_error_context (wfl_operator, "No label definition found for `%s'",
16589 IDENTIFIER_POINTER (bc_label));
16590 return error_mark_node;
16592 if (! IS_BREAK_STMT_P (node))
16594 /* It's a continue statement. */
16595 for (;; labeled_block = TREE_CHAIN (labeled_block))
16597 if (labeled_block == NULL_TREE)
16599 if (bc_label == NULL_TREE)
16600 parse_error_context (wfl_operator,
16601 "`continue' must be in loop");
16603 parse_error_context
16604 (wfl_operator, "continue label `%s' does not name a loop",
16605 IDENTIFIER_POINTER (bc_label));
16606 return error_mark_node;
16608 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16609 == continue_identifier_node)
16610 && (bc_label == NULL_TREE
16611 || TREE_CHAIN (labeled_block) == bc_label))
16613 bc_label = labeled_block;
16618 else if (!bc_label)
16620 for (;; labeled_block = TREE_CHAIN (labeled_block))
16622 if (labeled_block == NULL_TREE)
16624 parse_error_context (wfl_operator,
16625 "`break' must be in loop or switch");
16626 return error_mark_node;
16628 target_stmt = LABELED_BLOCK_BODY (labeled_block);
16629 if (TREE_CODE (target_stmt) == SWITCH_EXPR
16630 || search_loop (target_stmt))
16632 bc_label = labeled_block;
16638 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16639 CAN_COMPLETE_NORMALLY (bc_label) = 1;
16641 /* Our break/continue don't return values. */
16642 TREE_TYPE (node) = void_type_node;
16643 /* Encapsulate the break within a compound statement so that it's
16644 expanded all the times by expand_expr (and not clobbered
16645 sometimes, like after a if statement) */
16646 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16647 TREE_SIDE_EFFECTS (node) = 1;
16651 /* Process the exit expression belonging to a loop. Its type must be
16655 patch_exit_expr (node)
16658 tree expression = TREE_OPERAND (node, 0);
16659 TREE_TYPE (node) = error_mark_node;
16660 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16662 /* The type of expression must be boolean */
16663 if (TREE_TYPE (expression) != boolean_type_node)
16665 parse_error_context
16667 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
16668 lang_printable_name (TREE_TYPE (expression), 0));
16669 return error_mark_node;
16671 /* Now we know things are allright, invert the condition, fold and
16673 TREE_OPERAND (node, 0) =
16674 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16676 if (! integer_zerop (TREE_OPERAND (node, 0))
16677 && ctxp->current_loop != NULL_TREE
16678 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16679 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16680 if (! integer_onep (TREE_OPERAND (node, 0)))
16681 CAN_COMPLETE_NORMALLY (node) = 1;
16684 TREE_TYPE (node) = void_type_node;
16688 /* 14.9 Switch statement */
16691 patch_switch_statement (node)
16694 tree se = TREE_OPERAND (node, 0), se_type;
16696 /* Complete the switch expression */
16697 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16698 se_type = TREE_TYPE (se);
16699 /* The type of the switch expression must be char, byte, short or
16701 if (!JINTEGRAL_TYPE_P (se_type))
16703 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16704 parse_error_context (wfl_operator,
16705 "Incompatible type for `switch'. Can't convert `%s' to `int'",
16706 lang_printable_name (se_type, 0));
16707 /* This is what java_complete_tree will check */
16708 TREE_OPERAND (node, 0) = error_mark_node;
16709 return error_mark_node;
16712 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16714 /* Ready to return */
16715 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16717 TREE_TYPE (node) = error_mark_node;
16718 return error_mark_node;
16720 TREE_TYPE (node) = void_type_node;
16721 TREE_SIDE_EFFECTS (node) = 1;
16722 CAN_COMPLETE_NORMALLY (node)
16723 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16724 || ! SWITCH_HAS_DEFAULT (node);
16728 /* 14.18 The try/catch statements */
16731 build_try_statement (location, try_block, catches)
16733 tree try_block, catches;
16735 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16736 EXPR_WFL_LINECOL (node) = location;
16741 build_try_finally_statement (location, try_block, finally)
16743 tree try_block, finally;
16745 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16746 EXPR_WFL_LINECOL (node) = location;
16751 patch_try_statement (node)
16754 int error_found = 0;
16755 tree try = TREE_OPERAND (node, 0);
16756 /* Exception handlers are considered in left to right order */
16757 tree catch = nreverse (TREE_OPERAND (node, 1));
16758 tree current, caught_type_list = NULL_TREE;
16760 /* Check catch clauses, if any. Every time we find an error, we try
16761 to process the next catch clause. We process the catch clause before
16762 the try block so that when processing the try block we can check thrown
16763 exceptions againts the caught type list. */
16764 for (current = catch; current; current = TREE_CHAIN (current))
16766 tree carg_decl, carg_type;
16767 tree sub_current, catch_block, catch_clause;
16770 /* At this point, the structure of the catch clause is
16771 CATCH_EXPR (catch node)
16772 BLOCK (with the decl of the parameter)
16774 MODIFY_EXPR (assignment of the catch parameter)
16775 BLOCK (catch clause block)
16777 catch_clause = TREE_OPERAND (current, 0);
16778 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16779 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16781 /* Catch clauses can't have more than one parameter declared,
16782 but it's already enforced by the grammar. Make sure that the
16783 only parameter of the clause statement in of class Throwable
16784 or a subclass of Throwable, but that was done earlier. The
16785 catch clause parameter type has also been resolved. */
16787 /* Just make sure that the catch clause parameter type inherits
16788 from java.lang.Throwable */
16789 if (!inherits_from_p (carg_type, throwable_type_node))
16791 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16792 parse_error_context (wfl_operator,
16793 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16794 lang_printable_name (carg_type, 0));
16799 /* Partial check for unreachable catch statement: The catch
16800 clause is reachable iff is no earlier catch block A in
16801 the try statement such that the type of the catch
16802 clause's parameter is the same as or a subclass of the
16803 type of A's parameter */
16805 for (sub_current = catch;
16806 sub_current != current; sub_current = TREE_CHAIN (sub_current))
16808 tree sub_catch_clause, decl;
16809 sub_catch_clause = TREE_OPERAND (sub_current, 0);
16810 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16812 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16814 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16815 parse_error_context
16817 "`catch' not reached because of the catch clause at line %d",
16818 EXPR_WFL_LINENO (sub_current));
16819 unreachable = error_found = 1;
16823 /* Complete the catch clause block */
16824 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16825 if (catch_block == error_mark_node)
16830 if (CAN_COMPLETE_NORMALLY (catch_block))
16831 CAN_COMPLETE_NORMALLY (node) = 1;
16832 TREE_OPERAND (current, 0) = catch_block;
16837 /* Things to do here: the exception must be thrown */
16839 /* Link this type to the caught type list */
16840 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16843 PUSH_EXCEPTIONS (caught_type_list);
16844 if ((try = java_complete_tree (try)) == error_mark_node)
16846 if (CAN_COMPLETE_NORMALLY (try))
16847 CAN_COMPLETE_NORMALLY (node) = 1;
16850 /* Verification ends here */
16852 return error_mark_node;
16854 TREE_OPERAND (node, 0) = try;
16855 TREE_OPERAND (node, 1) = catch;
16856 TREE_TYPE (node) = void_type_node;
16860 /* 14.17 The synchronized Statement */
16863 patch_synchronized_statement (node, wfl_op1)
16864 tree node, wfl_op1;
16866 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
16867 tree block = TREE_OPERAND (node, 1);
16869 tree enter, exit, expr_decl, assignment;
16871 if (expr == error_mark_node)
16873 block = java_complete_tree (block);
16877 /* The TYPE of expr must be a reference type */
16878 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
16880 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16881 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
16882 lang_printable_name (TREE_TYPE (expr), 0));
16883 return error_mark_node;
16886 if (flag_emit_xref)
16888 TREE_OPERAND (node, 0) = expr;
16889 TREE_OPERAND (node, 1) = java_complete_tree (block);
16890 CAN_COMPLETE_NORMALLY (node) = 1;
16894 /* Generate a try-finally for the synchronized statement, except
16895 that the handler that catches all throw exception calls
16896 _Jv_MonitorExit and then rethrow the exception.
16897 The synchronized statement is then implemented as:
16900 _Jv_MonitorEnter (expression)
16902 _Jv_MonitorExit (expression)
16906 e = _Jv_exception_info ();
16907 _Jv_MonitorExit (expression)
16911 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
16912 BUILD_MONITOR_ENTER (enter, expr_decl);
16913 BUILD_MONITOR_EXIT (exit, expr_decl);
16914 CAN_COMPLETE_NORMALLY (enter) = 1;
16915 CAN_COMPLETE_NORMALLY (exit) = 1;
16916 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
16917 TREE_SIDE_EFFECTS (assignment) = 1;
16918 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
16919 build (COMPOUND_EXPR, NULL_TREE,
16920 build (WITH_CLEANUP_EXPR, NULL_TREE,
16921 build (COMPOUND_EXPR, NULL_TREE,
16922 assignment, enter),
16925 node = build_expr_block (node, expr_decl);
16927 return java_complete_tree (node);
16930 /* 14.16 The throw Statement */
16933 patch_throw_statement (node, wfl_op1)
16934 tree node, wfl_op1;
16936 tree expr = TREE_OPERAND (node, 0);
16937 tree type = TREE_TYPE (expr);
16938 int unchecked_ok = 0, tryblock_throws_ok = 0;
16940 /* Thrown expression must be assignable to java.lang.Throwable */
16941 if (!try_reference_assignconv (throwable_type_node, expr))
16943 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16944 parse_error_context (wfl_operator,
16945 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
16946 lang_printable_name (type, 0));
16947 /* If the thrown expression was a reference, we further the
16948 compile-time check. */
16949 if (!JREFERENCE_TYPE_P (type))
16950 return error_mark_node;
16953 /* At least one of the following must be true */
16955 /* The type of the throw expression is a not checked exception,
16956 i.e. is a unchecked expression. */
16957 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
16959 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16960 /* An instance can't throw a checked excetion unless that exception
16961 is explicitely declared in the `throws' clause of each
16962 constructor. This doesn't apply to anonymous classes, since they
16963 don't have declared constructors. */
16965 && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
16968 for (current = TYPE_METHODS (current_class); current;
16969 current = TREE_CHAIN (current))
16970 if (DECL_CONSTRUCTOR_P (current)
16971 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
16973 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)",
16974 lang_printable_name (TREE_TYPE (expr), 0));
16975 return error_mark_node;
16979 /* Throw is contained in a try statement and at least one catch
16980 clause can receive the thrown expression or the current method is
16981 declared to throw such an exception. Or, the throw statement is
16982 contained in a method or constructor declaration and the type of
16983 the Expression is assignable to at least one type listed in the
16984 throws clause the declaration. */
16986 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
16987 if (!(unchecked_ok || tryblock_throws_ok))
16989 /* If there is a surrounding try block that has no matching
16990 clatch clause, report it first. A surrounding try block exits
16991 only if there is something after the list of checked
16992 exception thrown by the current function (if any). */
16993 if (IN_TRY_BLOCK_P ())
16994 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
16995 lang_printable_name (type, 0));
16996 /* If we have no surrounding try statement and the method doesn't have
16997 any throws, report it now. FIXME */
16999 /* We report that the exception can't be throw from a try block
17000 in all circumstances but when the `throw' is inside a static
17002 else if (!EXCEPTIONS_P (currently_caught_type_list)
17003 && !tryblock_throws_ok)
17005 if (DECL_CLINIT_P (current_function_decl))
17006 parse_error_context (wfl_operator,
17007 "Checked exception `%s' can't be thrown in initializer",
17008 lang_printable_name (type, 0));
17010 parse_error_context (wfl_operator,
17011 "Checked exception `%s' isn't thrown from a `try' block",
17012 lang_printable_name (type, 0));
17014 /* Otherwise, the current method doesn't have the appropriate
17015 throws declaration */
17017 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
17018 lang_printable_name (type, 0));
17019 return error_mark_node;
17022 if (! flag_emit_class_files && ! flag_emit_xref)
17023 BUILD_THROW (node, expr);
17025 /* If doing xrefs, keep the location where the `throw' was seen. */
17026 if (flag_emit_xref)
17027 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17031 /* Check that exception said to be thrown by method DECL can be
17032 effectively caught from where DECL is invoked. */
17035 check_thrown_exceptions (location, decl)
17040 /* For all the unchecked exceptions thrown by DECL */
17041 for (throws = DECL_FUNCTION_THROWS (decl); throws;
17042 throws = TREE_CHAIN (throws))
17043 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17046 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17047 if (DECL_NAME (decl) == get_identifier ("clone"))
17050 EXPR_WFL_LINECOL (wfl_operator) = location;
17051 if (DECL_FINIT_P (current_function_decl))
17052 parse_error_context
17053 (wfl_operator, "Exception `%s' can't be thrown in initializer",
17054 lang_printable_name (TREE_VALUE (throws), 0));
17057 parse_error_context
17058 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
17059 lang_printable_name (TREE_VALUE (throws), 0),
17060 (DECL_INIT_P (current_function_decl) ?
17061 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17062 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17067 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17068 try-catch blocks, OR is listed in the `throws' clause of the
17072 check_thrown_exceptions_do (exception)
17075 tree list = currently_caught_type_list;
17076 resolve_and_layout (exception, NULL_TREE);
17077 /* First, all the nested try-catch-finally at that stage. The
17078 last element contains `throws' clause exceptions, if any. */
17079 if (IS_UNCHECKED_EXCEPTION_P (exception))
17084 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17085 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17087 list = TREE_CHAIN (list);
17093 purge_unchecked_exceptions (mdecl)
17096 tree throws = DECL_FUNCTION_THROWS (mdecl);
17097 tree new = NULL_TREE;
17101 tree next = TREE_CHAIN (throws);
17102 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17104 TREE_CHAIN (throws) = new;
17109 /* List is inverted here, but it doesn't matter */
17110 DECL_FUNCTION_THROWS (mdecl) = new;
17113 /* 15.24 Conditional Operator ?: */
17116 patch_conditional_expr (node, wfl_cond, wfl_op1)
17117 tree node, wfl_cond, wfl_op1;
17119 tree cond = TREE_OPERAND (node, 0);
17120 tree op1 = TREE_OPERAND (node, 1);
17121 tree op2 = TREE_OPERAND (node, 2);
17122 tree resulting_type = NULL_TREE;
17123 tree t1, t2, patched;
17124 int error_found = 0;
17126 /* Operands of ?: might be StringBuffers crafted as a result of a
17127 string concatenation. Obtain a descent operand here. */
17128 if ((patched = patch_string (op1)))
17129 TREE_OPERAND (node, 1) = op1 = patched;
17130 if ((patched = patch_string (op2)))
17131 TREE_OPERAND (node, 2) = op2 = patched;
17133 t1 = TREE_TYPE (op1);
17134 t2 = TREE_TYPE (op2);
17136 /* The first expression must be a boolean */
17137 if (TREE_TYPE (cond) != boolean_type_node)
17139 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17140 parse_error_context (wfl_operator,
17141 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17142 lang_printable_name (TREE_TYPE (cond), 0));
17146 /* Second and third can be numeric, boolean (i.e. primitive),
17147 references or null. Anything else results in an error */
17148 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17149 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
17150 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17151 || (t1 == boolean_type_node && t2 == boolean_type_node)))
17154 /* Determine the type of the conditional expression. Same types are
17155 easy to deal with */
17157 resulting_type = t1;
17159 /* There are different rules for numeric types */
17160 else if (JNUMERIC_TYPE_P (t1))
17162 /* if byte/short found, the resulting type is short */
17163 if ((t1 == byte_type_node && t2 == short_type_node)
17164 || (t1 == short_type_node && t2 == byte_type_node))
17165 resulting_type = short_type_node;
17167 /* If t1 is a constant int and t2 is of type byte, short or char
17168 and t1's value fits in t2, then the resulting type is t2 */
17169 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17170 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17171 resulting_type = t2;
17173 /* If t2 is a constant int and t1 is of type byte, short or char
17174 and t2's value fits in t1, then the resulting type is t1 */
17175 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17176 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17177 resulting_type = t1;
17179 /* Otherwise, binary numeric promotion is applied and the
17180 resulting type is the promoted type of operand 1 and 2 */
17182 resulting_type = binary_numeric_promotion (t1, t2,
17183 &TREE_OPERAND (node, 1),
17184 &TREE_OPERAND (node, 2));
17187 /* Cases of a reference and a null type */
17188 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17189 resulting_type = t1;
17191 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17192 resulting_type = t2;
17194 /* Last case: different reference types. If a type can be converted
17195 into the other one by assignment conversion, the latter
17196 determines the type of the expression */
17197 else if ((resulting_type = try_reference_assignconv (t1, op2)))
17198 resulting_type = promote_type (t1);
17200 else if ((resulting_type = try_reference_assignconv (t2, op1)))
17201 resulting_type = promote_type (t2);
17203 /* If we don't have any resulting type, we're in trouble */
17204 if (!resulting_type)
17206 char *t = xstrdup (lang_printable_name (t1, 0));
17207 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17208 parse_error_context (wfl_operator,
17209 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17210 t, lang_printable_name (t2, 0));
17217 TREE_TYPE (node) = error_mark_node;
17218 return error_mark_node;
17221 TREE_TYPE (node) = resulting_type;
17222 TREE_SET_CODE (node, COND_EXPR);
17223 CAN_COMPLETE_NORMALLY (node) = 1;
17227 /* Try to constant fold NODE.
17228 If NODE is not a constant expression, return NULL_EXPR.
17229 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17232 fold_constant_for_init (node, context)
17236 tree op0, op1, val;
17237 enum tree_code code = TREE_CODE (node);
17239 if (code == STRING_CST)
17242 if (code == INTEGER_CST || code == REAL_CST)
17243 return convert (TREE_TYPE (context), node);
17244 if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
17252 case TRUNC_MOD_EXPR:
17260 case TRUTH_ANDIF_EXPR:
17261 case TRUTH_ORIF_EXPR:
17268 op0 = TREE_OPERAND (node, 0);
17269 op1 = TREE_OPERAND (node, 1);
17270 val = fold_constant_for_init (op0, context);
17271 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17273 TREE_OPERAND (node, 0) = val;
17274 val = fold_constant_for_init (op1, context);
17275 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17277 TREE_OPERAND (node, 1) = val;
17278 return patch_binop (node, op0, op1);
17280 case UNARY_PLUS_EXPR:
17282 case TRUTH_NOT_EXPR:
17285 op0 = TREE_OPERAND (node, 0);
17286 val = fold_constant_for_init (op0, context);
17287 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17289 TREE_OPERAND (node, 0) = val;
17290 return patch_unaryop (node, op0);
17294 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17295 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17297 TREE_OPERAND (node, 0) = val;
17298 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17299 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17301 TREE_OPERAND (node, 1) = val;
17302 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17303 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17305 TREE_OPERAND (node, 2) = val;
17306 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17307 : TREE_OPERAND (node, 2);
17311 if (! FIELD_FINAL (node)
17312 || DECL_INITIAL (node) == NULL_TREE)
17314 val = DECL_INITIAL (node);
17315 /* Guard against infinite recursion. */
17316 DECL_INITIAL (node) = NULL_TREE;
17317 val = fold_constant_for_init (val, node);
17318 DECL_INITIAL (node) = val;
17321 case EXPR_WITH_FILE_LOCATION:
17322 /* Compare java_complete_tree and resolve_expression_name. */
17323 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17324 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17326 tree name = EXPR_WFL_NODE (node);
17328 if (PRIMARY_P (node))
17330 else if (! QUALIFIED_P (name))
17332 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17333 if (decl == NULL_TREE
17334 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17336 return fold_constant_for_init (decl, decl);
17340 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
17341 qualify_ambiguous_name (node);
17342 if (resolve_field_access (node, &decl, NULL)
17343 && decl != NULL_TREE)
17344 return fold_constant_for_init (decl, decl);
17350 op0 = TREE_OPERAND (node, 0);
17351 val = fold_constant_for_init (op0, context);
17352 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17354 TREE_OPERAND (node, 0) = val;
17358 #ifdef USE_COMPONENT_REF
17360 case COMPONENT_REF:
17369 #ifdef USE_COMPONENT_REF
17370 /* Context is 'T' for TypeName, 'P' for PackageName,
17371 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17374 resolve_simple_name (name, context)
17381 resolve_qualified_name (name, context)