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 and interfaces 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;
6066 check_modifiers ("Illegal modifier `%s' for interface declaration",
6067 flags, INTERFACE_MODIFIERS);
6069 check_modifiers ("Illegal modifier `%s' for class declaration",
6070 flags, uaaf|sca|icaf);
6075 make_nested_class_name (cpc_list)
6083 make_nested_class_name (TREE_CHAIN (cpc_list));
6085 /* Pick the qualified name when dealing with the first upmost
6087 name = (TREE_CHAIN (cpc_list) ?
6088 TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6089 obstack_grow (&temporary_obstack,
6090 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6091 /* Why is NO_DOLLAR_IN_LABEL defined? */
6093 #ifdef NO_DOLLAR_IN_LABEL
6094 fatal ("make_nested_class_name: Can't use '$' as a separator "
6095 "for inner classes");
6098 obstack_1grow (&temporary_obstack, '$');
6101 /* Can't redefine a class already defined in an earlier scope. */
6104 check_inner_class_redefinition (raw_name, cl)
6109 for (scope_list = GET_CPC_LIST (); scope_list;
6110 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6111 if (raw_name == GET_CPC_UN_NODE (scope_list))
6114 (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",
6115 IDENTIFIER_POINTER (raw_name));
6122 find_as_inner_class (enclosing, name, cl)
6123 tree enclosing, name, cl;
6125 tree qual, to_return;
6129 name = TYPE_NAME (name);
6131 /* First search: within the scope of `enclosing', search for name */
6132 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6133 qual = EXPR_WFL_QUALIFICATION (cl);
6135 qual = build_tree_list (cl, NULL_TREE);
6137 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6139 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6142 /* We're dealing with a qualified name. Try to resolve thing until
6143 we get something that is an enclosing class. */
6144 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6146 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6148 for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6149 qual = TREE_CHAIN (qual))
6151 acc = merge_qualified_name (acc,
6152 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6153 BUILD_PTR_FROM_NAME (ptr, acc);
6154 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6157 /* A NULL qual and a decl means that the search ended
6158 successfully?!? We have to do something then. FIXME */
6163 qual = EXPR_WFL_QUALIFICATION (cl);
6165 /* Otherwise, create a qual for the other part of the resolution. */
6167 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6169 return find_as_inner_class_do (qual, enclosing);
6172 /* We go inside the list of sub classes and try to find a way
6176 find_as_inner_class_do (qual, enclosing)
6177 tree qual, enclosing;
6182 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6184 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6185 tree next_enclosing = NULL_TREE;
6188 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6189 inner_list; inner_list = TREE_CHAIN (inner_list))
6191 if (TREE_VALUE (inner_list) == name_to_match)
6193 next_enclosing = TREE_PURPOSE (inner_list);
6197 enclosing = next_enclosing;
6200 return (!qual && enclosing ? enclosing : NULL_TREE);
6203 /* Reach all inner classes and tie their unqualified name to a
6207 set_nested_class_simple_name_value (outer, set)
6213 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6214 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6215 TREE_PURPOSE (l) : NULL_TREE);
6219 link_nested_class_to_enclosing ()
6221 if (GET_ENCLOSING_CPC ())
6223 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6224 DECL_INNER_CLASS_LIST (enclosing) =
6225 tree_cons (GET_CPC (), GET_CPC_UN (),
6226 DECL_INNER_CLASS_LIST (enclosing));
6227 enclosing = enclosing;
6232 maybe_make_nested_class_name (name)
6235 tree id = NULL_TREE;
6239 make_nested_class_name (GET_CPC_LIST ());
6240 obstack_grow0 (&temporary_obstack,
6241 IDENTIFIER_POINTER (name),
6242 IDENTIFIER_LENGTH (name));
6243 id = get_identifier (obstack_finish (&temporary_obstack));
6245 QUALIFIED_P (id) = 1;
6250 /* If DECL is NULL, create and push a new DECL, record the current
6251 line CL and do other maintenance things. */
6254 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6255 tree decl, raw_name, qualified_name, cl;
6258 decl = push_class (make_class (), qualified_name);
6260 /* Take care of the file and line business */
6261 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6262 /* If we're emiting xrefs, store the line/col number information */
6264 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6266 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6267 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6268 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6269 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6271 PUSH_CPC (decl, raw_name);
6272 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6274 /* Link the declaration to the already seen ones */
6275 TREE_CHAIN (decl) = ctxp->class_list;
6276 ctxp->class_list = decl;
6278 /* Create a new nodes in the global lists */
6279 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6280 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6282 /* Install a new dependency list element */
6283 create_jdep_list (ctxp);
6285 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6286 IDENTIFIER_POINTER (qualified_name)));
6291 add_superinterfaces (decl, interface_list)
6292 tree decl, interface_list;
6295 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6296 takes care of ensuring that:
6297 - This is an accessible interface type,
6298 - Circularity detection.
6299 parser_add_interface is then called. If present but not defined,
6300 the check operation is delayed until the super interface gets
6302 for (node = interface_list; node; node = TREE_CHAIN (node))
6304 tree current = TREE_PURPOSE (node);
6305 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6306 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6308 if (!parser_check_super_interface (idecl, decl, current))
6309 parser_add_interface (decl, idecl, current);
6312 register_incomplete_type (JDEP_INTERFACE,
6313 current, decl, NULL_TREE);
6317 /* Create an interface in pass1 and return its decl. Return the
6318 interface's decl in pass 2. */
6321 create_interface (flags, id, super)
6325 tree raw_name = EXPR_WFL_NODE (id);
6326 tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6327 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6329 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6331 /* Basic checks: scope, redefinition, modifiers */
6332 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6338 /* Suspend the current parsing context if we're parsing an inner
6341 java_parser_context_suspend ();
6343 /* Push a new context for (static) initialized upon declaration fields */
6344 java_parser_context_push_initialized_field ();
6346 /* Interface modifiers check
6347 - public/abstract allowed (already done at that point)
6348 - abstract is obsolete (comes first, it's a warning, or should be)
6349 - Can't use twice the same (checked in the modifier rule) */
6350 if ((flags & ACC_ABSTRACT) && flag_redundant)
6351 parse_warning_context
6352 (MODIFIER_WFL (ABSTRACT_TK),
6353 "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6355 /* Create a new decl if DECL is NULL, otherwise fix it */
6356 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6358 /* Set super info and mark the class a complete */
6359 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6360 object_type_node, ctxp->interface_number);
6361 ctxp->interface_number = 0;
6362 CLASS_COMPLETE_P (decl) = 1;
6363 add_superinterfaces (decl, super);
6368 /* Anonymous class counter. Will be reset to 1 every time a non
6369 anonymous class gets created. */
6370 static int anonymous_class_counter = 1;
6372 /* Patch anonymous class CLASS, by either extending or implementing
6376 patch_anonymous_class (type_decl, class_decl, wfl)
6377 tree type_decl, class_decl, wfl;
6379 tree class = TREE_TYPE (class_decl);
6380 tree type = TREE_TYPE (type_decl);
6381 tree binfo = TYPE_BINFO (class);
6383 /* If it's an interface, implement it */
6384 if (CLASS_INTERFACE (type_decl))
6389 if (parser_check_super_interface (type_decl, class_decl, wfl))
6392 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6393 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6394 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6395 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6396 /* And add the interface */
6397 parser_add_interface (class_decl, type_decl, wfl);
6399 /* Otherwise, it's a type we want to extend */
6402 if (parser_check_super (type_decl, class_decl, wfl))
6404 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6409 create_anonymous_class (location, type_name)
6414 tree super = NULL_TREE, itf = NULL_TREE;
6415 tree id, type_decl, class;
6417 /* The unqualified name of the anonymous class. It's just a number. */
6418 sprintf (buffer, "%d", anonymous_class_counter++);
6419 id = build_wfl_node (get_identifier (buffer));
6420 EXPR_WFL_LINECOL (id) = location;
6422 /* We know about the type to extend/implement. We go ahead */
6423 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6425 /* Create a class which either implements on extends the designated
6426 class. The class bears an innacessible name. */
6427 if (CLASS_INTERFACE (type_decl))
6429 /* It's OK to modify it here. It's been already used and
6430 shouldn't be reused */
6431 ctxp->interface_number = 1;
6432 /* Interfaces should presented as a list of WFLs */
6433 itf = build_tree_list (type_name, NULL_TREE);
6439 class = create_class (ACC_FINAL, id, super, itf);
6441 /* We didn't know anything about the stuff. We register a dependence. */
6443 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6445 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6449 /* Create an class in pass1 and return its decl. Return class
6450 interface's decl in pass 2. */
6453 create_class (flags, id, super, interfaces)
6455 tree id, super, interfaces;
6457 tree raw_name = EXPR_WFL_NODE (id);
6458 tree class_id, decl;
6459 tree super_decl_type;
6461 class_id = parser_qualified_classname (0, raw_name);
6462 decl = IDENTIFIER_CLASS_VALUE (class_id);
6463 EXPR_WFL_NODE (id) = class_id;
6465 /* Basic check: scope, redefinition, modifiers */
6466 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6472 /* Suspend the current parsing context if we're parsing an inner
6473 class or an anonymous class. */
6475 java_parser_context_suspend ();
6476 /* Push a new context for (static) initialized upon declaration fields */
6477 java_parser_context_push_initialized_field ();
6479 /* Class modifier check:
6480 - Allowed modifier (already done at that point)
6481 - abstract AND final forbidden
6482 - Public classes defined in the correct file */
6483 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6485 (id, "Class `%s' can't be declared both abstract and final",
6486 IDENTIFIER_POINTER (raw_name));
6488 /* Create a new decl if DECL is NULL, otherwise fix it */
6489 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6491 /* If SUPER exists, use it, otherwise use Object */
6494 /* Can't extend java.lang.Object */
6495 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6497 parse_error_context (id, "Can't extend `java.lang.Object'");
6502 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6504 else if (TREE_TYPE (decl) != object_type_node)
6505 super_decl_type = object_type_node;
6506 /* We're defining java.lang.Object */
6508 super_decl_type = NULL_TREE;
6510 /* Set super info and mark the class a complete */
6511 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6512 ctxp->interface_number);
6513 ctxp->interface_number = 0;
6514 CLASS_COMPLETE_P (decl) = 1;
6515 add_superinterfaces (decl, interfaces);
6517 /* If the class is a top level inner class, install an alias. */
6518 if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6520 tree alias = parser_qualified_classname (1, raw_name);
6521 IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6524 /* Add the private this$<n> field, Replicate final locals still in
6525 scope as private final fields mangled like val$<local_name>.
6526 This doesn't not occur for top level (static) inner classes. */
6527 if (PURE_INNER_CLASS_DECL_P (decl))
6528 add_inner_class_fields (decl, current_function_decl);
6530 /* If doing xref, store the location at which the inherited class
6531 (if any) was seen. */
6532 if (flag_emit_xref && super)
6533 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6535 /* Eventually sets the @deprecated tag flag */
6536 CHECK_DEPRECATED (decl);
6538 /* Reset the anonymous class counter when declaring non inner classes */
6539 if (!INNER_CLASS_DECL_P (decl))
6540 anonymous_class_counter = 1;
6545 /* End a class declaration: register the statements used to create
6546 $finit$ and <clinit>, pop the current class and resume the prior
6547 parser context if necessary. */
6550 end_class_declaration (resume)
6553 /* If an error occured, context weren't pushed and won't need to be
6554 popped by a resume. */
6555 int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6557 java_parser_context_pop_initialized_field ();
6559 if (resume && no_error_occured)
6560 java_parser_context_resume ();
6564 add_inner_class_fields (class_decl, fct_decl)
6568 tree block, marker, f;
6570 f = add_field (TREE_TYPE (class_decl),
6571 build_current_thisn (TREE_TYPE (class_decl)),
6572 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
6574 FIELD_THISN (f) = 1;
6579 for (block = GET_CURRENT_BLOCK (fct_decl);
6580 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6583 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6586 tree wfl, init, list;
6588 /* Avoid non final arguments. */
6589 if (!LOCAL_FINAL (decl))
6592 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6593 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6594 wfl = build_wfl_node (get_identifier (name));
6595 init = build_wfl_node (get_identifier (pname));
6596 /* Build an initialization for the field: it will be
6597 initialized by a parameter added to $finit$, bearing a
6598 mangled name of the field itself (param$<n>.) The
6599 parameter is provided to $finit$ by the constructor
6600 invoking it (hence the constructor will also feature a
6601 hidden parameter, set to the value of the outer context
6602 local at the time the inner class is created.)
6604 Note: we take into account all possible locals that can
6605 be accessed by the inner class. It's actually not trivial
6606 to minimize these aliases down to the ones really
6607 used. One way to do that would be to expand all regular
6608 methods first, then $finit$ to get a picture of what's
6609 used. It works with the exception that we would have to
6610 go back on all constructor invoked in regular methods to
6611 have their invokation reworked (to include the right amount
6612 of alias initializer parameters.)
6614 The only real way around, I think, is a first pass to
6615 identify locals really used in the inner class. We leave
6616 the flag FIELD_LOCAL_ALIAS_USED around for that future
6619 On the other hand, it only affect local inner classes,
6620 whose constructors (and $finit$ call) will be featuring
6621 unecessary arguments. It's easy for a developper to keep
6622 this number of parameter down by using the `final'
6623 keyword only when necessary. For the time being, we can
6624 issue a warning on unecessary finals. FIXME */
6625 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
6628 /* Register the field. The TREE_LIST holding the part
6629 initialized/initializer will be marked ARG_FINAL_P so
6630 that the created field can be marked
6631 FIELD_LOCAL_ALIAS. */
6632 list = build_tree_list (wfl, init);
6633 ARG_FINAL_P (list) = 1;
6634 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6638 if (!CPC_INITIALIZER_STMT (ctxp))
6641 /* If we ever registered an alias field, insert and marker to
6642 remeber where the list ends. The second part of the list (the one
6643 featuring initialized fields) so it can be later reversed to
6644 enforce 8.5. The marker will be removed during that operation. */
6645 marker = build_tree_list (NULL_TREE, NULL_TREE);
6646 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6647 SET_CPC_INITIALIZER_STMT (ctxp, marker);
6650 /* Can't use lookup_field () since we don't want to load the class and
6651 can't set the CLASS_LOADED_P flag */
6654 find_field (class, name)
6659 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6661 if (DECL_NAME (decl) == name)
6667 /* Wrap around lookup_field that doesn't potentially upset the value
6671 lookup_field_wrapper (class, name)
6676 java_parser_context_save_global ();
6677 decl = lookup_field (&type, name);
6678 java_parser_context_restore_global ();
6679 return decl == error_mark_node ? NULL : decl;
6682 /* Find duplicate field within the same class declarations and report
6683 the error. Returns 1 if a duplicated field was found, 0
6687 duplicate_declaration_error_p (new_field_name, new_type, cl)
6688 tree new_field_name, new_type, cl;
6690 /* This might be modified to work with method decl as well */
6691 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6694 char *t1 = xstrdup (purify_type_name
6695 ((TREE_CODE (new_type) == POINTER_TYPE
6696 && TREE_TYPE (new_type) == NULL_TREE) ?
6697 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6698 lang_printable_name (new_type, 1)));
6699 /* The type may not have been completed by the time we report
6701 char *t2 = xstrdup (purify_type_name
6702 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
6703 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6704 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6705 lang_printable_name (TREE_TYPE (decl), 1)));
6707 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
6708 t1, IDENTIFIER_POINTER (new_field_name),
6709 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6710 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6718 /* Field registration routine. If TYPE doesn't exist, field
6719 declarations are linked to the undefined TYPE dependency list, to
6720 be later resolved in java_complete_class () */
6723 register_fields (flags, type, variable_list)
6725 tree type, variable_list;
6727 tree current, saved_type;
6728 tree class_type = NULL_TREE;
6729 int saved_lineno = lineno;
6731 tree wfl = NULL_TREE;
6734 class_type = TREE_TYPE (GET_CPC ());
6736 if (!class_type || class_type == error_mark_node)
6739 /* If we're adding fields to interfaces, those fields are public,
6741 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6743 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6744 flags, ACC_PUBLIC, "interface field(s)");
6745 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6746 flags, ACC_STATIC, "interface field(s)");
6747 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6748 flags, ACC_FINAL, "interface field(s)");
6749 check_modifiers ("Illegal interface member modifier `%s'", flags,
6750 INTERFACE_FIELD_MODIFIERS);
6751 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6754 /* Obtain a suitable type for resolution, if necessary */
6755 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6757 /* If TYPE is fully resolved and we don't have a reference, make one */
6758 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6760 for (current = variable_list, saved_type = type; current;
6761 current = TREE_CHAIN (current), type = saved_type)
6765 tree cl = TREE_PURPOSE (current);
6766 tree init = TREE_VALUE (current);
6767 tree current_name = EXPR_WFL_NODE (cl);
6769 /* Can't declare static fields in inner classes */
6770 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6771 && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6773 (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6774 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6775 lang_printable_name (class_type, 0));
6777 /* Process NAME, as it may specify extra dimension(s) for it */
6778 type = build_array_from_name (type, wfl, current_name, ¤t_name);
6780 /* Type adjustment. We may have just readjusted TYPE because
6781 the variable specified more dimensions. Make sure we have
6782 a reference if we can and don't have one already. Also
6783 change the name if we have an init. */
6784 if (type != saved_type)
6786 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6788 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6791 real_type = GET_REAL_TYPE (type);
6792 /* Check for redeclarations */
6793 if (duplicate_declaration_error_p (current_name, real_type, cl))
6796 /* Set lineno to the line the field was found and create a
6797 declaration for it. Eventually sets the @deprecated tag flag. */
6799 lineno = EXPR_WFL_LINECOL (cl);
6801 lineno = EXPR_WFL_LINENO (cl);
6802 field_decl = add_field (class_type, current_name, real_type, flags);
6803 CHECK_DEPRECATED (field_decl);
6805 /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6806 mark the created field FIELD_LOCAL_ALIAS, so that we can
6807 hide parameters to this inner class $finit$ and constructors. */
6808 if (ARG_FINAL_P (current))
6809 FIELD_LOCAL_ALIAS (field_decl) = 1;
6811 /* Check if we must chain. */
6813 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6815 /* If we have an initialization value tied to the field */
6818 /* The field is declared static */
6819 if (flags & ACC_STATIC)
6821 /* We include the field and its initialization part into
6822 a list used to generate <clinit>. After <clinit> is
6823 walked, field initializations will be processed and
6824 fields initialized with known constants will be taken
6825 out of <clinit> and have their DECL_INITIAL set
6827 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6828 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6829 if (TREE_OPERAND (init, 1)
6830 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6831 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6833 /* A non-static field declared with an immediate initialization is
6834 to be initialized in <init>, if any. This field is remembered
6835 to be processed at the time of the generation of <init>. */
6838 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6839 SET_CPC_INITIALIZER_STMT (ctxp, init);
6841 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6842 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6845 lineno = saved_lineno;
6848 /* Generate $finit$, using the list of initialized fields to populate
6849 its body. $finit$'s parameter(s) list is adjusted to include the
6850 one(s) used to initialized the field(s) caching outer context
6854 generate_finit (class_type)
6858 tree list = TYPE_FINIT_STMT_LIST (class_type);
6859 tree mdecl, current, parms;
6861 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
6862 class_type, NULL_TREE,
6864 CRAFTED_PARAM_LIST_FIXUP (parms);
6865 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6866 finit_identifier_node, parms);
6867 fix_method_argument_names (parms, mdecl);
6868 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6870 DECL_FUNCTION_NAP (mdecl) = count;
6871 start_artificial_method_body (mdecl);
6873 for (current = list; current; current = TREE_CHAIN (current))
6874 java_method_add_stmt (mdecl,
6875 build_debugable_stmt (EXPR_WFL_LINECOL (current),
6877 end_artificial_method_body (mdecl);
6882 add_instance_initializer (mdecl)
6886 tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6887 tree compound = NULL_TREE;
6891 for (current = stmt_list; current; current = TREE_CHAIN (current))
6892 compound = add_stmt_to_compound (compound, NULL_TREE, current);
6894 java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6895 NULL_TREE, compound));
6899 /* Shared accros method_declarator and method_header to remember the
6900 patch stage that was reached during the declaration of the method.
6901 A method DECL is built differently is there is no patch
6902 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6903 pending on the currently defined method. */
6905 static int patch_stage;
6907 /* Check the method declaration and add the method to its current
6908 class. If the argument list is known to contain incomplete types,
6909 the method is partially added and the registration will be resume
6910 once the method arguments resolved. If TYPE is NULL, we're dealing
6911 with a constructor. */
6914 method_header (flags, type, mdecl, throws)
6916 tree type, mdecl, throws;
6918 tree meth = TREE_VALUE (mdecl);
6919 tree id = TREE_PURPOSE (mdecl);
6920 tree type_wfl = NULL_TREE;
6921 tree meth_name = NULL_TREE;
6922 tree current, orig_arg, this_class = NULL;
6924 int constructor_ok = 0, must_chain;
6927 check_modifiers_consistency (flags);
6930 this_class = TREE_TYPE (GET_CPC ());
6932 if (!this_class || this_class == error_mark_node)
6935 /* There are some forbidden modifiers for an abstract method and its
6936 class must be abstract as well. */
6937 if (type && (flags & ACC_ABSTRACT))
6939 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6940 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6941 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6942 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6943 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6944 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6945 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6947 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
6948 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6949 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6952 /* Things to be checked when declaring a constructor */
6955 int ec = java_error_count;
6956 /* 8.6: Constructor declarations: we might be trying to define a
6957 method without specifying a return type. */
6958 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6960 (id, "Invalid method declaration, return type required");
6961 /* 8.6.3: Constructor modifiers */
6964 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6965 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
6966 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
6967 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
6968 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
6970 /* If we found error here, we don't consider it's OK to tread
6971 the method definition as a constructor, for the rest of this
6973 if (ec == java_error_count)
6977 /* Method declared within the scope of an interface are implicitly
6978 abstract and public. Conflicts with other erroneously provided
6979 modifiers are checked right after. */
6981 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
6983 /* If FLAGS isn't set because of a modifier, turn the
6984 corresponding modifier WFL to NULL so we issue a warning on
6985 the obsolete use of the modifier */
6986 if (!(flags & ACC_PUBLIC))
6987 MODIFIER_WFL (PUBLIC_TK) = NULL;
6988 if (!(flags & ACC_ABSTRACT))
6989 MODIFIER_WFL (ABSTRACT_TK) = NULL;
6990 flags |= ACC_PUBLIC;
6991 flags |= ACC_ABSTRACT;
6994 /* Inner class can't declare static methods */
6995 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
6998 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
6999 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7000 lang_printable_name (this_class, 0));
7003 /* Modifiers context reset moved up, so abstract method declaration
7004 modifiers can be later checked. */
7006 /* Set constructor returned type to void and method name to <init>,
7007 unless we found an error identifier the constructor (in which
7008 case we retain the original name) */
7011 type = void_type_node;
7013 meth_name = init_identifier_node;
7016 meth_name = EXPR_WFL_NODE (id);
7018 /* Do the returned type resolution and registration if necessary */
7019 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7022 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7023 EXPR_WFL_NODE (id) = meth_name;
7024 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7028 patch_stage = JDEP_METHOD_RETURN;
7029 register_incomplete_type (patch_stage, type_wfl, id, type);
7030 TREE_TYPE (meth) = GET_REAL_TYPE (type);
7033 TREE_TYPE (meth) = type;
7035 saved_lineno = lineno;
7036 /* When defining an abstract or interface method, the curly
7037 bracket at level 1 doesn't exist because there is no function
7039 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
7040 EXPR_WFL_LINENO (id));
7042 /* Remember the original argument list */
7043 orig_arg = TYPE_ARG_TYPES (meth);
7045 if (patch_stage) /* includes ret type and/or all args */
7048 meth = add_method_1 (this_class, flags, meth_name, meth);
7049 /* Patch for the return type */
7050 if (patch_stage == JDEP_METHOD_RETURN)
7052 jdep = CLASSD_LAST (ctxp->classd_list);
7053 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7055 /* This is the stop JDEP. METH allows the function's signature
7057 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7060 meth = add_method (this_class, flags, meth_name,
7061 build_java_signature (meth));
7063 /* Remember final parameters */
7064 MARK_FINAL_PARMS (meth, orig_arg);
7066 /* Fix the method argument list so we have the argument name
7068 fix_method_argument_names (orig_arg, meth);
7070 /* Register the parameter number and re-install the current line
7072 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7073 lineno = saved_lineno;
7075 /* Register exception specified by the `throws' keyword for
7076 resolution and set the method decl appropriate field to the list.
7077 Note: the grammar ensures that what we get here are class
7081 throws = nreverse (throws);
7082 for (current = throws; current; current = TREE_CHAIN (current))
7084 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7085 NULL_TREE, NULL_TREE);
7086 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7087 &TREE_VALUE (current);
7089 DECL_FUNCTION_THROWS (meth) = throws;
7092 /* We set the DECL_NAME to ID so we can track the location where
7093 the function was declared. This allow us to report
7094 redefinition error accurately. When method are verified,
7095 DECL_NAME is reinstalled properly (using the content of the
7096 WFL node ID) (see check_method_redefinition). We don't do that
7097 when Object is being defined. Constructor <init> names will be
7098 reinstalled the same way. */
7099 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7100 DECL_NAME (meth) = id;
7102 /* Set the flag if we correctly processed a constructor */
7105 DECL_CONSTRUCTOR_P (meth) = 1;
7106 /* Compute and store the number of artificial parameters declared
7107 for this constructor */
7108 for (count = 0, current = TYPE_FIELDS (this_class); current;
7109 current = TREE_CHAIN (current))
7110 if (FIELD_LOCAL_ALIAS (current))
7112 DECL_FUNCTION_NAP (meth) = count;
7115 /* Eventually set the @deprecated tag flag */
7116 CHECK_DEPRECATED (meth);
7118 /* If doing xref, store column and line number information instead
7119 of the line number only. */
7121 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7127 fix_method_argument_names (orig_arg, meth)
7128 tree orig_arg, meth;
7130 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7131 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7133 TREE_PURPOSE (arg) = this_identifier_node;
7134 arg = TREE_CHAIN (arg);
7136 while (orig_arg != end_params_node)
7138 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7139 orig_arg = TREE_CHAIN (orig_arg);
7140 arg = TREE_CHAIN (arg);
7144 /* Complete the method declaration with METHOD_BODY. */
7147 finish_method_declaration (method_body)
7152 if (!current_function_decl)
7155 flags = get_access_flags_from_decl (current_function_decl);
7157 /* 8.4.5 Method Body */
7158 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7160 tree wfl = DECL_NAME (current_function_decl);
7161 parse_error_context (wfl,
7162 "%s method `%s' can't have a body defined",
7163 (METHOD_NATIVE (current_function_decl) ?
7164 "Native" : "Abstract"),
7165 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7166 method_body = NULL_TREE;
7168 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7170 tree wfl = DECL_NAME (current_function_decl);
7173 "Non native and non abstract method `%s' must have a body defined",
7174 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7175 method_body = NULL_TREE;
7178 if (flag_emit_class_files && method_body
7179 && TREE_CODE (method_body) == NOP_EXPR
7180 && TREE_TYPE (current_function_decl)
7181 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7182 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7184 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7185 maybe_absorb_scoping_blocks ();
7186 /* Exit function's body */
7188 /* Merge last line of the function with first line, directly in the
7189 function decl. It will be used to emit correct debug info. */
7190 if (!flag_emit_xref)
7191 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7193 /* Since function's argument's list are shared, reset the
7194 ARG_FINAL_P parameter that might have been set on some of this
7195 function parameters. */
7196 UNMARK_FINAL_PARMS (current_function_decl);
7198 /* So we don't have an irrelevant function declaration context for
7199 the next static block we'll see. */
7200 current_function_decl = NULL_TREE;
7203 /* Build a an error message for constructor circularity errors. */
7206 constructor_circularity_msg (from, to)
7209 static char string [4096];
7210 char *t = xstrdup (lang_printable_name (from, 0));
7211 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7216 /* Verify a circular call to METH. Return 1 if an error is found, 0
7220 verify_constructor_circularity (meth, current)
7223 static tree list = NULL_TREE;
7225 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7227 if (TREE_VALUE (c) == meth)
7233 list = nreverse (list);
7234 for (liste = list; liste; liste = TREE_CHAIN (liste))
7237 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7238 constructor_circularity_msg
7239 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7243 t = xstrdup (lang_printable_name (meth, 0));
7244 parse_error_context (TREE_PURPOSE (c),
7245 "%s: recursive invocation of constructor `%s'",
7246 constructor_circularity_msg (current, meth), t);
7252 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7254 list = tree_cons (c, current, list);
7255 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7257 list = TREE_CHAIN (list);
7262 /* Check modifiers that can be declared but exclusively */
7265 check_modifiers_consistency (flags)
7269 tree cl = NULL_TREE;
7271 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7272 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7273 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7276 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7280 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7282 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7285 parse_error_context (cl,
7286 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7289 /* Check the methode header METH for abstract specifics features */
7292 check_abstract_method_header (meth)
7295 int flags = get_access_flags_from_decl (meth);
7296 /* DECL_NAME might still be a WFL node */
7297 tree name = GET_METHOD_NAME (meth);
7299 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7300 ACC_ABSTRACT, "abstract method",
7301 IDENTIFIER_POINTER (name));
7302 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7303 ACC_PUBLIC, "abstract method",
7304 IDENTIFIER_POINTER (name));
7306 check_modifiers ("Illegal modifier `%s' for interface method",
7307 flags, INTERFACE_METHOD_MODIFIERS);
7310 /* Create a FUNCTION_TYPE node and start augmenting it with the
7311 declared function arguments. Arguments type that can't be resolved
7312 are left as they are, but the returned node is marked as containing
7313 incomplete types. */
7316 method_declarator (id, list)
7319 tree arg_types = NULL_TREE, current, node;
7320 tree meth = make_node (FUNCTION_TYPE);
7323 patch_stage = JDEP_NO_PATCH;
7325 /* If we're dealing with an inner class constructor, we hide the
7326 this$<n> decl in the name field of its parameter declaration. We
7327 also might have to hide the outer context local alias
7328 initializers. Not done when the class is a toplevel class. */
7329 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7330 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7332 tree aliases_list, type, thisn;
7333 /* First the aliases, linked to the regular parameters */
7335 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7336 TREE_TYPE (GET_CPC ()),
7338 list = chainon (nreverse (aliases_list), list);
7341 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7342 thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7343 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7347 for (current = list; current; current = TREE_CHAIN (current))
7350 tree wfl_name = TREE_PURPOSE (current);
7351 tree type = TREE_VALUE (current);
7352 tree name = EXPR_WFL_NODE (wfl_name);
7353 tree already, arg_node;
7354 tree type_wfl = NULL_TREE;
7357 /* Obtain a suitable type for resolution, if necessary */
7358 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7360 /* Process NAME, as it may specify extra dimension(s) for it */
7361 type = build_array_from_name (type, type_wfl, name, &name);
7362 EXPR_WFL_NODE (wfl_name) = name;
7364 real_type = GET_REAL_TYPE (type);
7365 if (TREE_CODE (real_type) == RECORD_TYPE)
7367 real_type = promote_type (real_type);
7368 if (TREE_CODE (type) == TREE_LIST)
7369 TREE_PURPOSE (type) = real_type;
7372 /* Check redefinition */
7373 for (already = arg_types; already; already = TREE_CHAIN (already))
7374 if (TREE_PURPOSE (already) == name)
7377 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7378 IDENTIFIER_POINTER (name),
7379 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7383 /* If we've an incomplete argument type, we know there is a location
7384 to patch when the type get resolved, later. */
7388 patch_stage = JDEP_METHOD;
7389 type = register_incomplete_type (patch_stage,
7390 type_wfl, wfl_name, type);
7391 jdep = CLASSD_LAST (ctxp->classd_list);
7392 JDEP_MISC (jdep) = id;
7395 /* The argument node: a name and a (possibly) incomplete type. */
7396 arg_node = build_tree_list (name, real_type);
7397 /* Remeber arguments declared final. */
7398 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7401 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7402 TREE_CHAIN (arg_node) = arg_types;
7403 arg_types = arg_node;
7405 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7406 node = build_tree_list (id, meth);
7411 unresolved_type_p (wfl, returned)
7416 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7420 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7421 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7422 *returned = TREE_TYPE (decl);
7423 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7424 *returned = TREE_TYPE (GET_CPC ());
7426 *returned = NULL_TREE;
7435 /* From NAME, build a qualified identifier node using the
7436 qualification from the current package definition. */
7439 parser_qualified_classname (is_static, name)
7443 tree nested_class_name;
7446 && (nested_class_name = maybe_make_nested_class_name (name)))
7447 return nested_class_name;
7450 return merge_qualified_name (ctxp->package, name);
7455 /* Called once the type a interface extends is resolved. Returns 0 if
7456 everything is OK. */
7459 parser_check_super_interface (super_decl, this_decl, this_wfl)
7460 tree super_decl, this_decl, this_wfl;
7462 tree super_type = TREE_TYPE (super_decl);
7464 /* Has to be an interface */
7465 if (!CLASS_INTERFACE (super_decl))
7468 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7469 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7470 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7471 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7472 "interface" : "class"),
7473 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7477 /* Check scope: same package OK, other package: OK if public */
7478 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7481 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7482 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7483 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7487 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7488 0 if everthing is OK. */
7491 parser_check_super (super_decl, this_decl, wfl)
7492 tree super_decl, this_decl, wfl;
7494 tree super_type = TREE_TYPE (super_decl);
7496 /* SUPER should be a CLASS (neither an array nor an interface) */
7497 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7500 (wfl, "Class `%s' can't subclass %s `%s'",
7501 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7502 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7503 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7507 if (CLASS_FINAL (TYPE_NAME (super_type)))
7509 parse_error_context (wfl, "Can't subclass final classes: %s",
7510 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7514 /* Check scope: same package OK, other package: OK if public */
7515 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7518 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7519 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7520 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7524 /* Create a new dependency list and link it (in a LIFO manner) to the
7525 CTXP list of type dependency list. */
7528 create_jdep_list (ctxp)
7529 struct parser_ctxt *ctxp;
7531 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
7532 new->first = new->last = NULL;
7533 new->next = ctxp->classd_list;
7534 ctxp->classd_list = new;
7538 reverse_jdep_list (ctxp)
7539 struct parser_ctxt *ctxp;
7541 register jdeplist *prev = NULL, *current, *next;
7542 for (current = ctxp->classd_list; current; current = next)
7544 next = current->next;
7545 current->next = prev;
7551 /* Create a fake pointer based on the ID stored in
7552 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7553 registered again. */
7556 obtain_incomplete_type (type_name)
7561 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7562 name = EXPR_WFL_NODE (type_name);
7563 else if (INCOMPLETE_TYPE_P (type_name))
7564 name = TYPE_NAME (type_name);
7566 fatal ("invalid type name - obtain_incomplete_type");
7568 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7569 if (TYPE_NAME (ptr) == name)
7574 push_obstacks (&permanent_obstack, &permanent_obstack);
7575 BUILD_PTR_FROM_NAME (ptr, name);
7578 TREE_CHAIN (ptr) = ctxp->incomplete_class;
7579 ctxp->incomplete_class = ptr;
7585 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7586 non NULL instead of computing a new fake type based on WFL. The new
7587 dependency is inserted in the current type dependency list, in FIFO
7591 register_incomplete_type (kind, wfl, decl, ptr)
7593 tree wfl, decl, ptr;
7595 jdep *new = (jdep *)xmalloc (sizeof (jdep));
7597 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7598 ptr = obtain_incomplete_type (wfl);
7600 JDEP_KIND (new) = kind;
7601 JDEP_DECL (new) = decl;
7602 JDEP_SOLV (new) = ptr;
7603 JDEP_WFL (new) = wfl;
7604 JDEP_CHAIN (new) = NULL;
7605 JDEP_MISC (new) = NULL_TREE;
7606 if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
7607 && GET_ENCLOSING_CPC ())
7608 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7610 JDEP_ENCLOSING (new) = GET_CPC ();
7611 JDEP_GET_PATCH (new) = (tree *)NULL;
7613 JDEP_INSERT (ctxp->classd_list, new);
7619 java_check_circular_reference ()
7622 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7624 tree type = TREE_TYPE (current);
7625 if (CLASS_INTERFACE (current))
7627 /* Check all interfaces this class extends */
7628 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7633 n = TREE_VEC_LENGTH (basetype_vec);
7634 for (i = 0; i < n; i++)
7636 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7637 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
7638 && interface_of_p (type, BINFO_TYPE (vec_elt)))
7639 parse_error_context (lookup_cl (current),
7640 "Cyclic interface inheritance");
7644 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7645 parse_error_context (lookup_cl (current),
7646 "Cyclic class inheritance%s",
7647 (cyclic_inheritance_report ?
7648 cyclic_inheritance_report : ""));
7652 /* Augment the parameter list PARM with parameters crafted to
7653 initialize outer context locals aliases. Through ARTIFICIAL, a
7654 count is kept of the number of crafted parameters. MODE governs
7655 what eventually gets created: something suitable for a function
7656 creation or a function invocation, either the constructor or
7660 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7662 tree class_type, parm;
7666 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7667 if (FIELD_LOCAL_ALIAS (field))
7669 char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7670 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7674 case AIPL_FUNCTION_DECLARATION:
7675 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7676 purpose = build_wfl_node (get_identifier (buffer));
7677 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7678 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7680 value = TREE_TYPE (field);
7683 case AIPL_FUNCTION_CREATION:
7684 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7685 purpose = get_identifier (buffer);
7686 value = TREE_TYPE (field);
7689 case AIPL_FUNCTION_FINIT_INVOCATION:
7690 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7691 /* Now, this is wrong. purpose should always be the NAME
7692 of something and value its matching value (decl, type,
7693 etc...) FIXME -- but there is a lot to fix. */
7695 /* When invoked for this kind of operation, we already
7696 know whether a field is used or not. */
7697 purpose = TREE_TYPE (field);
7698 value = build_wfl_node (get_identifier (buffer));
7701 case AIPL_FUNCTION_CTOR_INVOCATION:
7702 /* There are two case: the constructor invokation happends
7703 outside the local inner, in which case, locales from the outer
7704 context are directly used.
7706 Otherwise, we fold to using the alias directly. */
7707 if (class_type == current_class)
7711 name = get_identifier (&buffer[4]);
7712 value = IDENTIFIER_LOCAL_VALUE (name);
7716 parm = tree_cons (purpose, value, parm);
7723 /* Craft a constructor for CLASS_DECL -- what we should do when none
7724 where found. ARGS is non NULL when a special signature must be
7725 enforced. This is the case for anonymous classes. */
7728 craft_constructor (class_decl, args)
7729 tree class_decl, args;
7731 tree class_type = TREE_TYPE (class_decl);
7732 tree parm = NULL_TREE;
7733 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7735 int i = 0, artificial = 0;
7736 tree decl, ctor_name;
7739 push_obstacks (&permanent_obstack, &permanent_obstack);
7741 /* The constructor name is <init> unless we're dealing with an
7742 anonymous class, in which case the name will be fixed after having
7744 if (ANONYMOUS_CLASS_P (class_type))
7745 ctor_name = DECL_NAME (class_decl);
7747 ctor_name = init_identifier_node;
7749 /* If we're dealing with an inner class constructor, we hide the
7750 this$<n> decl in the name field of its parameter declaration. */
7751 if (PURE_INNER_CLASS_TYPE_P (class_type))
7753 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7754 parm = tree_cons (build_current_thisn (class_type),
7755 build_pointer_type (type), parm);
7757 /* Some more arguments to be hidden here. The values of the local
7758 variables of the outer context that the inner class needs to see. */
7759 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7764 /* Then if there are any args to be enforced, enforce them now */
7765 for (; args && args != end_params_node; args = TREE_CHAIN (args))
7767 sprintf (buffer, "parm%d", i++);
7768 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7771 CRAFTED_PARAM_LIST_FIXUP (parm);
7772 decl = create_artificial_method (class_type, flags, void_type_node,
7774 fix_method_argument_names (parm, decl);
7775 /* Now, mark the artificial parameters. */
7776 DECL_FUNCTION_NAP (decl) = artificial;
7779 DECL_CONSTRUCTOR_P (decl) = 1;
7783 /* Fix the constructors. This will be called right after circular
7784 references have been checked. It is necessary to fix constructors
7785 early even if no code generation will take place for that class:
7786 some generated constructor might be required by the class whose
7787 compilation triggered this one to be simply loaded. */
7790 java_fix_constructors ()
7794 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7796 tree class_type = TREE_TYPE (current);
7800 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7803 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7805 if (DECL_CONSTRUCTOR_P (decl))
7807 fix_constructors (decl);
7812 /* Anonymous class constructor can't be generated that early. */
7813 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7814 craft_constructor (current, NULL_TREE);
7818 /* safe_layout_class just makes sure that we can load a class without
7819 disrupting the current_class, input_file, lineno, etc, information
7820 about the class processed currently. */
7823 safe_layout_class (class)
7826 tree save_current_class = current_class;
7827 char *save_input_filename = input_filename;
7828 int save_lineno = lineno;
7830 push_obstacks (&permanent_obstack, &permanent_obstack);
7832 layout_class (class);
7835 current_class = save_current_class;
7836 input_filename = save_input_filename;
7837 lineno = save_lineno;
7838 CLASS_LOADED_P (class) = 1;
7842 jdep_resolve_class (dep)
7847 if (JDEP_RESOLVED_P (dep))
7848 decl = JDEP_RESOLVED_DECL (dep);
7851 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7852 JDEP_DECL (dep), JDEP_WFL (dep));
7853 JDEP_RESOLVED (dep, decl);
7857 complete_class_report_errors (dep);
7862 /* Complete unsatisfied class declaration and their dependencies */
7865 java_complete_class ()
7872 push_obstacks (&permanent_obstack, &permanent_obstack);
7874 /* Process imports and reverse the import on demand list */
7876 if (ctxp->import_demand_list)
7877 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7879 /* Rever things so we have the right order */
7880 ctxp->class_list = nreverse (ctxp->class_list);
7881 ctxp->classd_list = reverse_jdep_list (ctxp);
7883 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
7885 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7888 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7891 if (!(decl = jdep_resolve_class (dep)))
7894 /* Now it's time to patch */
7895 switch (JDEP_KIND (dep))
7898 /* Simply patch super */
7899 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7901 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
7902 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7907 /* We do part of the job done in add_field */
7908 tree field_decl = JDEP_DECL (dep);
7909 tree field_type = TREE_TYPE (decl);
7910 push_obstacks (&permanent_obstack, &permanent_obstack);
7911 if (TREE_CODE (field_type) == RECORD_TYPE)
7912 field_type = promote_type (field_type);
7914 TREE_TYPE (field_decl) = field_type;
7915 DECL_ALIGN (field_decl) = 0;
7916 layout_decl (field_decl, 0);
7917 SOURCE_FRONTEND_DEBUG
7918 (("Completed field/var decl `%s' with `%s'",
7919 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7920 IDENTIFIER_POINTER (DECL_NAME (decl))));
7923 case JDEP_METHOD: /* We start patching a method */
7924 case JDEP_METHOD_RETURN:
7930 type = TREE_TYPE(decl);
7931 if (TREE_CODE (type) == RECORD_TYPE)
7932 type = promote_type (type);
7933 JDEP_APPLY_PATCH (dep, type);
7934 SOURCE_FRONTEND_DEBUG
7935 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7936 "Completing fct `%s' with ret type `%s'":
7937 "Completing arg `%s' with type `%s'"),
7938 IDENTIFIER_POINTER (EXPR_WFL_NODE
7939 (JDEP_DECL_WFL (dep))),
7940 IDENTIFIER_POINTER (DECL_NAME (decl))));
7944 dep = JDEP_CHAIN (dep);
7945 if (JDEP_KIND (dep) == JDEP_METHOD_END)
7948 decl = jdep_resolve_class (dep);
7952 tree mdecl = JDEP_DECL (dep), signature;
7953 push_obstacks (&permanent_obstack, &permanent_obstack);
7954 /* Recompute and reset the signature, check first that
7955 all types are now defined. If they're not,
7956 dont build the signature. */
7957 if (check_method_types_complete (mdecl))
7959 signature = build_java_signature (TREE_TYPE (mdecl));
7960 set_java_signature (TREE_TYPE (mdecl), signature);
7968 case JDEP_INTERFACE:
7969 if (parser_check_super_interface (decl, JDEP_DECL (dep),
7972 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
7977 type = TREE_TYPE(decl);
7978 if (TREE_CODE (type) == RECORD_TYPE)
7979 type = promote_type (type);
7980 JDEP_APPLY_PATCH (dep, type);
7984 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7985 SOURCE_FRONTEND_DEBUG
7986 (("Completing a random type dependency on a '%s' node",
7987 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
7990 case JDEP_EXCEPTION:
7991 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7992 SOURCE_FRONTEND_DEBUG
7993 (("Completing `%s' `throws' argument node",
7994 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
7997 case JDEP_ANONYMOUS:
7998 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8002 fatal ("Can't handle patch code %d - java_complete_class",
8011 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8015 resolve_class (enclosing, class_type, decl, cl)
8016 tree enclosing, class_type, decl, cl;
8018 const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8019 const char *base = name;
8020 tree resolved_type = TREE_TYPE (class_type);
8021 tree resolved_type_decl;
8023 if (resolved_type != NULL_TREE)
8025 tree resolved_type_decl = TYPE_NAME (resolved_type);
8026 if (resolved_type_decl == NULL_TREE
8027 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8029 resolved_type_decl = build_decl (TYPE_DECL,
8030 TYPE_NAME (class_type),
8033 return resolved_type_decl;
8036 /* 1- Check to see if we have an array. If true, find what we really
8038 while (name[0] == '[')
8041 TYPE_NAME (class_type) = get_identifier (name);
8043 /* 2- Resolve the bare type */
8044 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
8047 resolved_type = TREE_TYPE (resolved_type_decl);
8049 /* 3- If we have and array, reconstruct the array down to its nesting */
8052 while (base != name)
8054 if (TREE_CODE (resolved_type) == RECORD_TYPE)
8055 resolved_type = promote_type (resolved_type);
8056 resolved_type = build_java_array_type (resolved_type, -1);
8057 CLASS_LOADED_P (resolved_type) = 1;
8060 /* Build a fake decl for this, since this is what is expected to
8062 resolved_type_decl =
8063 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8064 /* Figure how those two things are important for error report. FIXME */
8065 DECL_SOURCE_LINE (resolved_type_decl) = 0;
8066 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8067 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8069 TREE_TYPE (class_type) = resolved_type;
8070 return resolved_type_decl;
8073 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8074 are used to report error messages. */
8077 do_resolve_class (enclosing, class_type, decl, cl)
8078 tree enclosing, class_type, decl, cl;
8080 tree new_class_decl;
8081 tree original_name = NULL_TREE;
8083 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8084 its is changed by find_in_imports{_on_demand} */
8086 /* 0- Search in the current class as an inner class */
8088 /* Maybe some code here should be added to load the class or
8089 something, at least if the class isn't an inner class and ended
8090 being loaded from class file. FIXME. */
8091 if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8092 return new_class_decl;
8094 /* 1- Check for the type in single imports */
8095 if (find_in_imports (class_type))
8098 /* 2- And check for the type in the current compilation unit. If it fails,
8099 try with a name qualified with the package name we've seen so far */
8100 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8102 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8103 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8104 load_class (TYPE_NAME (class_type), 0);
8105 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8108 original_name = TYPE_NAME (class_type);
8109 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8112 for (package = package_list; package; package = TREE_CHAIN (package))
8116 new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8118 TYPE_NAME (class_type) = new_qualified;
8119 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8120 if (!new_class_decl)
8121 load_class (TYPE_NAME (class_type), 0);
8122 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8125 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8126 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8127 load_class (TYPE_NAME (class_type), 0);
8128 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8133 TYPE_NAME (class_type) = original_name;
8135 /* 3- Check an other compilation unit that bears the name of type */
8136 load_class (TYPE_NAME (class_type), 0);
8137 if (check_pkg_class_access (TYPE_NAME (class_type),
8138 (cl ? cl : lookup_cl (decl))))
8141 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8142 return new_class_decl;
8144 /* 4- Check the import on demands. Don't allow bar.baz to be
8145 imported from foo.* */
8146 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8147 if (find_in_imports_on_demand (class_type))
8150 /* 5- Last call for a resolution */
8151 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8154 /* Resolve NAME and lay it out (if not done and if not the current
8155 parsed class). Return a decl node. This function is meant to be
8156 called when type resolution is necessary during the walk pass. */
8159 resolve_and_layout (something, cl)
8165 /* Don't do that on the current class */
8166 if (something == current_class)
8167 return TYPE_NAME (current_class);
8169 /* Don't do anything for void and other primitive types */
8170 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8173 /* Pointer types can be reall pointer types or fake pointers. When
8174 finding a real pointer, recheck for primitive types */
8175 if (TREE_CODE (something) == POINTER_TYPE)
8177 if (TREE_TYPE (something))
8179 something = TREE_TYPE (something);
8180 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8184 something = TYPE_NAME (something);
8187 /* Don't do anything for arrays of primitive types */
8188 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8189 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8192 /* Something might be a WFL */
8193 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8194 something = EXPR_WFL_NODE (something);
8196 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8197 TYPE_DECL or a real TYPE */
8198 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8199 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8200 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8202 if (!(decl = resolve_no_layout (something, cl)))
8205 /* Resolve and layout if necessary */
8206 layout_class_methods (TREE_TYPE (decl));
8207 /* Check methods, but only once */
8208 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
8209 && !CLASS_LOADED_P (TREE_TYPE (decl)))
8210 CHECK_METHODS (decl);
8211 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8212 safe_layout_class (TREE_TYPE (decl));
8217 /* Resolve a class, returns its decl but doesn't perform any
8218 layout. The current parsing context is saved and restored */
8221 resolve_no_layout (name, cl)
8225 BUILD_PTR_FROM_NAME (ptr, name);
8226 java_parser_context_save_global ();
8227 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8228 java_parser_context_restore_global ();
8233 /* Called when reporting errors. Skip leader '[' in a complex array
8234 type description that failed to be resolved. */
8237 purify_type_name (name)
8240 while (*name && *name == '[')
8245 /* The type CURRENT refers to can't be found. We print error messages. */
8248 complete_class_report_errors (dep)
8253 if (!JDEP_WFL (dep))
8256 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8257 switch (JDEP_KIND (dep))
8261 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8262 purify_type_name (name),
8263 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8267 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8268 purify_type_name (name),
8269 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8271 case JDEP_METHOD: /* Covers arguments */
8273 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8274 purify_type_name (name),
8275 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8276 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8278 case JDEP_METHOD_RETURN: /* Covers return type */
8280 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8281 purify_type_name (name),
8282 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8284 case JDEP_INTERFACE:
8286 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8287 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8288 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8289 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8293 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8294 purify_type_name (IDENTIFIER_POINTER
8295 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8296 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8298 case JDEP_EXCEPTION: /* As specified by `throws' */
8300 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8301 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8304 /* Fix for -Wall. Just break doing nothing. The error will be
8310 /* Return a static string containing the DECL prototype string. If
8311 DECL is a constructor, use the class name instead of the form
8315 get_printable_method_name (decl)
8318 const char *to_return;
8319 tree name = NULL_TREE;
8321 if (DECL_CONSTRUCTOR_P (decl))
8323 name = DECL_NAME (decl);
8324 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8327 to_return = lang_printable_name (decl, 0);
8328 if (DECL_CONSTRUCTOR_P (decl))
8329 DECL_NAME (decl) = name;
8334 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8335 nevertheless needs to be verfied, 1 otherwise. */
8338 reset_method_name (method)
8341 if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8343 /* NAME is just the plain name when Object is being defined */
8344 if (DECL_CONTEXT (method) != object_type_node)
8345 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
8346 init_identifier_node : GET_METHOD_NAME (method));
8353 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8356 java_get_real_method_name (method_decl)
8359 tree method_name = DECL_NAME (method_decl);
8360 if (DECL_CONSTRUCTOR_P (method_decl))
8361 return init_identifier_node;
8363 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8364 and still can be a constructor. FIXME */
8366 /* Don't confuse method only bearing the name of their class as
8368 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8370 && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8371 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8372 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8373 return init_identifier_node;
8375 return EXPR_WFL_NODE (method_name);
8378 /* Track method being redefined inside the same class. As a side
8379 effect, set DECL_NAME to an IDENTIFIER (prior entering this
8380 function it's a FWL, so we can track errors more accurately.) */
8383 check_method_redefinition (class, method)
8387 tree cl = DECL_NAME (method);
8388 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8389 /* decl name of artificial <clinit> and $finit$ doesn't need to be
8390 fixed and checked */
8392 /* Reset the method name before running the check. If it returns 1,
8393 the method doesn't need to be verified with respect to method
8394 redeclaration and we return 0 */
8395 if (reset_method_name (method))
8398 name = DECL_NAME (method);
8399 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8401 if (redef == method)
8403 if (DECL_NAME (redef) == name
8404 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8407 (cl, "Duplicate %s declaration `%s'",
8408 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8409 get_printable_method_name (redef));
8417 check_abstract_method_definitions (do_interface, class_decl, type)
8419 tree class_decl, type;
8421 tree class = TREE_TYPE (class_decl);
8422 tree method, end_type;
8424 end_type = (do_interface ? object_type_node : type);
8425 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8427 tree other_super, other_method, method_sig, method_name;
8429 int end_type_reached = 0;
8431 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8434 /* Now verify that somewhere in between TYPE and CLASS,
8435 abstract method METHOD gets a non abstract definition
8436 that is inherited by CLASS. */
8438 method_sig = build_java_signature (TREE_TYPE (method));
8439 method_name = DECL_NAME (method);
8440 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8441 method_name = EXPR_WFL_NODE (method_name);
8443 other_super = class;
8445 if (other_super == end_type)
8446 end_type_reached = 1;
8449 for (other_method = TYPE_METHODS (other_super); other_method;
8450 other_method = TREE_CHAIN (other_method))
8452 tree s = build_java_signature (TREE_TYPE (other_method));
8453 tree other_name = DECL_NAME (other_method);
8455 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8456 other_name = EXPR_WFL_NODE (other_name);
8457 if (!DECL_CLINIT_P (other_method)
8458 && !DECL_CONSTRUCTOR_P (other_method)
8459 && method_name == other_name && method_sig == s)
8465 other_super = CLASSTYPE_SUPER (other_super);
8466 } while (!end_type_reached);
8468 /* Report that abstract METHOD didn't find an implementation
8469 that CLASS can use. */
8472 char *t = xstrdup (lang_printable_name
8473 (TREE_TYPE (TREE_TYPE (method)), 0));
8474 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8475 tree saved_wfl = NULL_TREE;
8477 if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8479 saved_wfl = DECL_NAME (method);
8480 DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8484 (lookup_cl (class_decl),
8485 "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",
8486 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8487 t, lang_printable_name (method, 0),
8488 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
8489 "interface" : "class"),
8490 IDENTIFIER_POINTER (ccn),
8491 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8492 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8497 DECL_NAME (method) = saved_wfl;
8502 /* Check that CLASS_DECL somehow implements all inherited abstract
8506 java_check_abstract_method_definitions (class_decl)
8509 tree class = TREE_TYPE (class_decl);
8513 if (CLASS_ABSTRACT (class_decl))
8516 /* Check for inherited types */
8519 super = CLASSTYPE_SUPER (super);
8520 check_abstract_method_definitions (0, class_decl, super);
8521 } while (super != object_type_node);
8523 /* Check for implemented interfaces. */
8524 vector = TYPE_BINFO_BASETYPES (class);
8525 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8527 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8528 check_abstract_method_definitions (1, class_decl, super);
8532 /* Check all the types method DECL uses and return 1 if all of them
8533 are now complete, 0 otherwise. This is used to check whether its
8534 safe to build a method signature or not. */
8537 check_method_types_complete (decl)
8540 tree type = TREE_TYPE (decl);
8543 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8546 args = TYPE_ARG_TYPES (type);
8547 if (TREE_CODE (type) == METHOD_TYPE)
8548 args = TREE_CHAIN (args);
8549 for (; args != end_params_node; args = TREE_CHAIN (args))
8550 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8556 /* Check all the methods of CLASS_DECL. Methods are first completed
8557 then checked according to regular method existance rules. If no
8558 constructor for CLASS_DECL were encountered, then build its
8562 java_check_regular_methods (class_decl)
8565 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8567 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8568 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8571 /* It is not necessary to check methods defined in java.lang.Object */
8572 if (class == object_type_node)
8575 if (!TYPE_NVIRTUALS (class))
8576 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8578 /* Should take interfaces into account. FIXME */
8579 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8582 tree method_wfl = DECL_NAME (method);
8585 /* If we previously found something and its name was saved,
8587 if (found && saved_found_wfl)
8589 DECL_NAME (found) = saved_found_wfl;
8590 saved_found_wfl = NULL_TREE;
8593 /* Check for redefinitions */
8594 if (check_method_redefinition (class, method))
8597 /* If we see one constructor a mark so we don't generate the
8598 default one. Also skip other verifications: constructors
8599 can't be inherited hence hiden or overriden */
8600 if (DECL_CONSTRUCTOR_P (method))
8602 saw_constructor = 1;
8606 /* We verify things thrown by the method. They must inherits from
8607 java.lang.Throwable */
8608 for (mthrows = DECL_FUNCTION_THROWS (method);
8609 mthrows; mthrows = TREE_CHAIN (mthrows))
8611 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8613 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8615 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8618 sig = build_java_argument_signature (TREE_TYPE (method));
8619 found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8621 /* Inner class can't declare static methods */
8622 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8624 char *t = xstrdup (lang_printable_name (class, 0));
8626 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8627 lang_printable_name (method, 0), t);
8631 /* Nothing overrides or it's a private method. */
8634 if (METHOD_PRIVATE (found))
8640 /* If found wasn't verified, it's DECL_NAME won't be set properly.
8641 We set it temporarily for the sake of the error report. */
8642 saved_found_wfl = DECL_NAME (found);
8643 reset_method_name (found);
8645 /* If `found' is declared in an interface, make sure the
8646 modifier matches. */
8647 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8648 && clinit_identifier_node != DECL_NAME (found)
8649 && !METHOD_PUBLIC (method))
8651 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8652 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8653 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8654 lang_printable_name (method, 0),
8655 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8658 /* Can't override a method with the same name and different return
8660 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8663 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8666 "Method `%s' was defined with return type `%s' in class `%s'",
8667 lang_printable_name (found, 0), t,
8669 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8673 aflags = get_access_flags_from_decl (found);
8674 /* If the method has default, access in an other package, then
8675 issue a warning that the current method doesn't override the
8676 one that was found elsewhere. Do not issue this warning when
8677 the match was found in java.lang.Object. */
8678 if (DECL_CONTEXT (found) != object_type_node
8679 && ((aflags & ACC_VISIBILITY) == 0)
8680 && !class_in_current_package (DECL_CONTEXT (found))
8681 && !DECL_CLINIT_P (found)
8682 && flag_not_overriding)
8684 parse_warning_context
8685 (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8686 lang_printable_name (found, 0),
8687 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8688 IDENTIFIER_POINTER (DECL_NAME
8689 (TYPE_NAME (DECL_CONTEXT (found)))));
8693 /* Can't override final. Can't override static. */
8694 if (METHOD_FINAL (found) || METHOD_STATIC (found))
8696 /* Static *can* override static */
8697 if (METHOD_STATIC (found) && METHOD_STATIC (method))
8701 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8702 (METHOD_FINAL (found) ? "Final" : "Static"),
8703 lang_printable_name (found, 0),
8704 (METHOD_FINAL (found) ? "final" : "static"),
8706 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8710 /* Static method can't override instance method. */
8711 if (METHOD_STATIC (method))
8715 "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8716 lang_printable_name (found, 0),
8718 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8722 /* - Overriding/hiding public must be public
8723 - Overriding/hiding protected must be protected or public
8724 - If the overriden or hidden method has default (package)
8725 access, then the overriding or hiding method must not be
8726 private; otherwise, a compile-time error occurs. If
8727 `found' belongs to an interface, things have been already
8729 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8730 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8731 || (METHOD_PROTECTED (found)
8732 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8733 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8734 && METHOD_PRIVATE (method))))
8738 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8739 (METHOD_PUBLIC (method) ? "public" :
8740 (METHOD_PRIVATE (method) ? "private" : "protected")),
8741 IDENTIFIER_POINTER (DECL_NAME
8742 (TYPE_NAME (DECL_CONTEXT (found)))));
8746 /* Overriding methods must have compatible `throws' clauses on checked
8747 exceptions, if any */
8748 check_throws_clauses (method, method_wfl, found);
8750 /* Inheriting multiple methods with the same signature. FIXME */
8753 /* Don't forget eventual pending found and saved_found_wfl. Take
8754 into account that we might have exited because we saw an
8755 artificial method as the last entry. */
8757 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8758 DECL_NAME (found) = saved_found_wfl;
8760 if (!TYPE_NVIRTUALS (class))
8761 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8763 /* Search for inherited abstract method not yet implemented in this
8765 java_check_abstract_method_definitions (class_decl);
8767 if (!saw_constructor)
8768 fatal ("No constructor found");
8771 /* Return a non zero value if the `throws' clause of METHOD (if any)
8772 is incompatible with the `throws' clause of FOUND (if any). */
8775 check_throws_clauses (method, method_wfl, found)
8776 tree method, method_wfl, found;
8778 tree mthrows, fthrows;
8780 /* Can't check these things with class loaded from bytecode. FIXME */
8781 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8784 for (mthrows = DECL_FUNCTION_THROWS (method);
8785 mthrows; mthrows = TREE_CHAIN (mthrows))
8787 /* We don't verify unchecked expressions */
8788 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8790 /* Checked expression must be compatible */
8791 for (fthrows = DECL_FUNCTION_THROWS (found);
8792 fthrows; fthrows = TREE_CHAIN (fthrows))
8793 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8798 (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'",
8799 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8800 lang_printable_name (found, 0),
8802 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8807 /* Check abstract method of interface INTERFACE */
8810 java_check_abstract_methods (interface_decl)
8811 tree interface_decl;
8814 tree method, basetype_vec, found;
8815 tree interface = TREE_TYPE (interface_decl);
8817 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8819 tree method_wfl = DECL_NAME (method);
8821 /* 2- Check for double definition inside the defining interface */
8822 if (check_method_redefinition (interface, method))
8825 /* 3- Overriding is OK as far as we preserve the return type and
8826 the thrown exceptions (FIXME) */
8827 found = lookup_java_interface_method2 (interface, method);
8831 tree saved_found_wfl = DECL_NAME (found);
8832 reset_method_name (found);
8833 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8836 "Method `%s' was defined with return type `%s' in class `%s'",
8837 lang_printable_name (found, 0), t,
8839 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8841 DECL_NAME (found) = saved_found_wfl;
8846 /* 4- Inherited methods can't differ by their returned types */
8847 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8849 n = TREE_VEC_LENGTH (basetype_vec);
8850 for (i = 0; i < n; i++)
8852 tree sub_interface_method, sub_interface;
8853 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8856 sub_interface = BINFO_TYPE (vec_elt);
8857 for (sub_interface_method = TYPE_METHODS (sub_interface);
8858 sub_interface_method;
8859 sub_interface_method = TREE_CHAIN (sub_interface_method))
8861 found = lookup_java_interface_method2 (interface,
8862 sub_interface_method);
8863 if (found && (found != sub_interface_method))
8865 tree saved_found_wfl = DECL_NAME (found);
8866 reset_method_name (found);
8868 (lookup_cl (sub_interface_method),
8869 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8870 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8871 lang_printable_name (found, 0),
8873 (DECL_NAME (TYPE_NAME
8874 (DECL_CONTEXT (sub_interface_method)))),
8876 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8877 DECL_NAME (found) = saved_found_wfl;
8883 /* Lookup methods in interfaces using their name and partial
8884 signature. Return a matching method only if their types differ. */
8887 lookup_java_interface_method2 (class, method_decl)
8888 tree class, method_decl;
8891 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8896 n = TREE_VEC_LENGTH (basetype_vec);
8897 for (i = 0; i < n; i++)
8899 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8900 if ((BINFO_TYPE (vec_elt) != object_type_node)
8902 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8905 for (i = 0; i < n; i++)
8907 to_return = lookup_java_interface_method2
8908 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8916 /* Lookup method using their name and partial signature. Return a
8917 matching method only if their types differ. */
8920 lookup_java_method2 (clas, method_decl, do_interface)
8921 tree clas, method_decl;
8924 tree method, method_signature, method_name, method_type, name;
8926 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8927 name = DECL_NAME (method_decl);
8928 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8929 EXPR_WFL_NODE (name) : name);
8930 method_type = TREE_TYPE (TREE_TYPE (method_decl));
8932 while (clas != NULL_TREE)
8934 for (method = TYPE_METHODS (clas);
8935 method != NULL_TREE; method = TREE_CHAIN (method))
8937 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8938 tree name = DECL_NAME (method);
8939 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8940 EXPR_WFL_NODE (name) : name) == method_name
8941 && method_sig == method_signature
8942 && TREE_TYPE (TREE_TYPE (method)) != method_type)
8945 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
8950 /* Return the line that matches DECL line number, and try its best to
8951 position the column number. Used during error reports. */
8957 static tree cl = NULL_TREE;
8963 if (cl == NULL_TREE)
8964 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
8966 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
8967 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
8969 line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
8970 EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
8972 found = strstr ((const char *)line,
8973 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
8975 EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
8980 /* Look for a simple name in the single-type import list */
8983 find_name_in_single_imports (name)
8988 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
8989 if (TREE_VALUE (node) == name)
8990 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
8995 /* Process all single-type import. */
9003 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9005 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9007 /* Don't load twice something already defined. */
9008 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9010 QUALIFIED_P (to_be_found) = 1;
9011 load_class (to_be_found, 0);
9013 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9014 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9016 parse_error_context (TREE_PURPOSE (import),
9017 "Class or interface `%s' not found in import",
9018 IDENTIFIER_POINTER (to_be_found));
9027 /* Possibly find a class imported by a single-type import statement. Return
9028 1 if an error occured, 0 otherwise. */
9031 find_in_imports (class_type)
9036 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9037 if (TREE_VALUE (import) == TYPE_NAME (class_type))
9039 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9040 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9046 note_possible_classname (name, len)
9051 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9053 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9057 node = ident_subst (name, len, "", '/', '.', "");
9058 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9059 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9063 /* Read a import directory, gathering potential match for further type
9064 references. Indifferently reads a filesystem or a ZIP archive
9068 read_import_dir (wfl)
9071 tree package_id = EXPR_WFL_NODE (wfl);
9072 const char *package_name = IDENTIFIER_POINTER (package_id);
9073 int package_length = IDENTIFIER_LENGTH (package_id);
9075 JCF *saved_jcf = current_jcf;
9080 struct buffer filename[1];
9083 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9085 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9087 BUFFER_INIT (filename);
9088 buffer_grow (filename, package_length + 100);
9090 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9092 const char *entry_name = jcf_path_name (entry);
9093 int entry_length = strlen (entry_name);
9094 if (jcf_path_is_zipfile (entry))
9097 buffer_grow (filename, entry_length);
9098 memcpy (filename->data, entry_name, entry_length - 1);
9099 filename->data[entry_length-1] = '\0';
9100 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9102 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9105 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9106 BUFFER_RESET (filename);
9107 for (k = 0; k < package_length; k++)
9109 char ch = package_name[k];
9110 *filename->ptr++ = ch == '.' ? '/' : ch;
9112 *filename->ptr++ = '/';
9114 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9116 const char *current_entry = ZIPDIR_FILENAME (zipd);
9117 int current_entry_len = zipd->filename_length;
9119 if (current_entry_len >= BUFFER_LENGTH (filename)
9120 && strncmp (filename->data, current_entry,
9121 BUFFER_LENGTH (filename)) != 0)
9123 found |= note_possible_classname (current_entry,
9130 BUFFER_RESET (filename);
9131 buffer_grow (filename, entry_length + package_length + 4);
9132 strcpy (filename->data, entry_name);
9133 filename->ptr = filename->data + entry_length;
9134 for (k = 0; k < package_length; k++)
9136 char ch = package_name[k];
9137 *filename->ptr++ = ch == '.' ? '/' : ch;
9139 *filename->ptr = '\0';
9141 dirp = opendir (filename->data);
9144 *filename->ptr++ = '/';
9149 struct dirent *direntp = readdir (dirp);
9152 d_name = direntp->d_name;
9153 len = strlen (direntp->d_name);
9154 buffer_grow (filename, len+1);
9155 strcpy (filename->ptr, d_name);
9156 found |= note_possible_classname (filename->data + entry_length,
9157 package_length+len+1);
9164 free (filename->data);
9166 /* Here we should have a unified way of retrieving an entry, to be
9170 static int first = 1;
9173 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9178 parse_error_context (wfl, "Package `%s' not found in import",
9180 current_jcf = saved_jcf;
9183 current_jcf = saved_jcf;
9186 /* Possibly find a type in the import on demands specified
9187 types. Returns 1 if an error occured, 0 otherwise. Run throught the
9188 entire list, to detected potential double definitions. */
9191 find_in_imports_on_demand (class_type)
9194 tree node, import, node_to_use = NULL_TREE;
9196 tree cl = NULL_TREE;
9198 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9200 const char *id_name;
9201 obstack_grow (&temporary_obstack,
9202 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9203 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9204 obstack_1grow (&temporary_obstack, '.');
9205 obstack_grow0 (&temporary_obstack,
9206 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9207 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9208 id_name = obstack_finish (&temporary_obstack);
9210 node = maybe_get_identifier (id_name);
9211 if (node && IS_A_CLASSFILE_NAME (node))
9215 cl = TREE_PURPOSE (import);
9223 (import, "Type `%s' also potentially defined in package `%s'",
9224 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9225 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9232 /* Setup lineno so that it refers to the line of the import (in
9233 case we parse a class file and encounter errors */
9235 int saved_lineno = lineno;
9236 lineno = EXPR_WFL_LINENO (cl);
9237 TYPE_NAME (class_type) = node_to_use;
9238 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9239 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9240 /* If there is no DECL set for the class or if the class isn't
9241 loaded and not seen in source yet, the load */
9242 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9243 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9244 load_class (node_to_use, 0);
9245 lineno = saved_lineno;
9246 return check_pkg_class_access (TYPE_NAME (class_type), cl);
9249 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9253 resolve_package (pkg, next)
9257 tree type_name = NULL_TREE;
9258 const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9260 /* The trick is to determine when the package name stops and were
9261 the name of something contained in the package starts. Then we
9262 return a fully qualified name of what we want to get. */
9264 /* Do a quick search on well known package names */
9265 if (!strncmp (name, "java.lang.reflect", 17))
9268 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9269 type_name = lookup_package_type (name, 17);
9271 else if (!strncmp (name, "java.lang", 9))
9273 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9274 type_name = lookup_package_type (name, 9);
9277 /* If we found something here, return */
9281 *next = EXPR_WFL_QUALIFICATION (pkg);
9283 /* Try the current package. */
9284 if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),
9285 IDENTIFIER_LENGTH (ctxp->package)))
9288 lookup_package_type_and_set_next (name,
9289 IDENTIFIER_LENGTH (ctxp->package),
9295 /* Search in imported package */
9296 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9298 tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9299 int len = IDENTIFIER_LENGTH (current_pkg_name);
9300 if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9304 breakdown_qualified (&left, &dummy, current_pkg_name);
9305 len = IDENTIFIER_LENGTH (left);
9306 type_name = lookup_package_type_and_set_next (name, len, next);
9312 /* Try to progressively construct a type name */
9313 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9314 for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg);
9315 current; current = TREE_CHAIN (current))
9317 acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9318 if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9321 *next = TREE_CHAIN (current);
9329 lookup_package_type_and_set_next (name, len, next)
9335 tree type_name = lookup_package_type (name, len);
9340 ptr = IDENTIFIER_POINTER (type_name);
9341 while (ptr && (ptr = strchr (ptr, '.')))
9343 *next = TREE_CHAIN (*next);
9350 lookup_package_type (name, from)
9355 const char *sub = &name[from+1];
9356 while (*sub != '.' && *sub)
9358 strncpy (subname, name, sub-name);
9359 subname [sub-name] = '\0';
9360 return get_identifier (subname);
9363 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9364 access violations were found, 1 otherwise. */
9367 check_pkg_class_access (class_name, cl)
9373 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9376 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9379 if (!CLASS_PUBLIC (TYPE_NAME (type)))
9381 /* Access to a private class within the same package is
9384 breakdown_qualified (&l, &r, class_name);
9385 if (l == ctxp->package)
9389 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9390 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9391 IDENTIFIER_POINTER (class_name));
9397 /* Local variable declaration. */
9400 declare_local_variables (modifier, type, vlist)
9405 tree decl, current, saved_type;
9406 tree type_wfl = NULL_TREE;
9410 /* Push a new block if statements were seen between the last time we
9411 pushed a block and now. Keep a cound of block to close */
9412 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9414 tree body = GET_CURRENT_BLOCK (current_function_decl);
9415 tree b = enter_block ();
9416 BLOCK_EXPR_ORIGIN (b) = body;
9422 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9423 if (modifier == ACC_FINAL)
9428 (ctxp->modifier_ctx [i],
9429 "Only `final' is allowed as a local variables modifier");
9434 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9435 hold the TYPE value if a new incomplete has to be created (as
9436 opposed to being found already existing and reused). */
9437 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9439 /* If TYPE is fully resolved and we don't have a reference, make one */
9440 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9442 /* Go through all the declared variables */
9443 for (current = vlist, saved_type = type; current;
9444 current = TREE_CHAIN (current), type = saved_type)
9446 tree other, real_type;
9447 tree wfl = TREE_PURPOSE (current);
9448 tree name = EXPR_WFL_NODE (wfl);
9449 tree init = TREE_VALUE (current);
9451 /* Process NAME, as it may specify extra dimension(s) for it */
9452 type = build_array_from_name (type, type_wfl, name, &name);
9454 /* Variable redefinition check */
9455 if ((other = lookup_name_in_blocks (name)))
9457 variable_redefinition_error (wfl, name, TREE_TYPE (other),
9458 DECL_SOURCE_LINE (other));
9462 /* Type adjustment. We may have just readjusted TYPE because
9463 the variable specified more dimensions. Make sure we have
9464 a reference if we can and don't have one already. */
9465 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9467 real_type = GET_REAL_TYPE (type);
9468 /* Never layout this decl. This will be done when its scope
9470 decl = build_decl (VAR_DECL, name, real_type);
9471 LOCAL_FINAL (decl) = final_p;
9472 BLOCK_CHAIN_DECL (decl);
9474 /* If doing xreferencing, replace the line number with the WFL
9477 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9479 /* Don't try to use an INIT statement when an error was found */
9480 if (init && java_error_count)
9483 /* Add the initialization function to the current function's code */
9486 /* Name might have been readjusted */
9487 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9488 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9489 java_method_add_stmt (current_function_decl,
9490 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9494 /* Setup dependency the type of the decl */
9498 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9499 dep = CLASSD_LAST (ctxp->classd_list);
9500 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9503 SOURCE_FRONTEND_DEBUG (("Defined locals"));
9506 /* Called during parsing. Build decls from argument list. */
9509 source_start_java_method (fndecl)
9516 int flag_inner = DECL_CONSTRUCTOR_P (fndecl)
9517 && (INNER_CLASS_TYPE_P (DECL_CONTEXT (fndecl)) ? 1 : 0);
9523 current_function_decl = fndecl;
9525 /* New scope for the function */
9527 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9528 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9530 tree type = TREE_VALUE (tem);
9531 tree name = TREE_PURPOSE (tem);
9533 /* If type is incomplete. Create an incomplete decl and ask for
9534 the decl to be patched later */
9535 if (INCOMPLETE_TYPE_P (type))
9538 tree real_type = GET_REAL_TYPE (type);
9539 parm_decl = build_decl (PARM_DECL, name, real_type);
9540 type = obtain_incomplete_type (type);
9541 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9542 jdep = CLASSD_LAST (ctxp->classd_list);
9543 JDEP_MISC (jdep) = name;
9544 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9547 parm_decl = build_decl (PARM_DECL, name, type);
9549 /* Remember if a local variable was declared final (via its
9550 TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9551 if (ARG_FINAL_P (tem))
9552 LOCAL_FINAL (parm_decl) = 1;
9554 BLOCK_CHAIN_DECL (parm_decl);
9557 /* If this is a constructor of a inner class, hide the extra
9558 this$<n> parameter */
9559 if (i == 0 && flag_inner)
9561 tree link = TREE_CHAIN (tem);
9562 tree type = DECL_CONTEXT (TYPE_NAME (DECL_CONTEXT (fndecl)));
9564 type = build_pointer_type (TREE_TYPE (type));
9565 parm_decl = build_decl (PARM_DECL,
9566 build_current_thisn (current_class), type);
9567 BLOCK_CHAIN_DECL (parm_decl);
9568 /* We hide the this$<n> decl in the name field of its
9569 parameter declaration. */
9570 parm_decl = build_tree_list (DECL_NAME (parm_decl), type);
9571 TREE_CHAIN (tem) = parm_decl;
9572 TREE_CHAIN (parm_decl) = link;
9579 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9580 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9582 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9583 DECL_MAX_LOCALS (current_function_decl) = i;
9586 /* Called during parsing. Creates an artificial method declaration. */
9589 create_artificial_method (class, flags, type, name, args)
9592 tree type, name, args;
9596 java_parser_context_save_global ();
9598 mdecl = make_node (FUNCTION_TYPE);
9599 TREE_TYPE (mdecl) = type;
9600 TYPE_ARG_TYPES (mdecl) = args;
9601 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
9602 java_parser_context_restore_global ();
9603 DECL_ARTIFICIAL (mdecl) = 1;
9607 /* Starts the body if an artifical method. */
9610 start_artificial_method_body (mdecl)
9613 DECL_SOURCE_LINE (mdecl) = 1;
9614 DECL_SOURCE_LINE_MERGE (mdecl, 1);
9615 source_start_java_method (mdecl);
9620 end_artificial_method_body (mdecl)
9623 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9627 /* Called during expansion. Push decls formerly built from argument
9628 list so they're usable during expansion. */
9631 expand_start_java_method (fndecl)
9636 current_function_decl = fndecl;
9639 fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9640 announce_function (fndecl);
9642 fprintf (stderr, "]");
9644 pushlevel (1); /* Prepare for a parameter push */
9645 ptr = &DECL_ARGUMENTS (fndecl);
9646 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9649 tree next = TREE_CHAIN (tem);
9650 tree type = TREE_TYPE (tem);
9651 if (PROMOTE_PROTOTYPES
9652 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9653 && INTEGRAL_TYPE_P (type))
9654 type = integer_type_node;
9655 DECL_ARG_TYPE (tem) = type;
9656 layout_decl (tem, 0);
9659 ptr = &TREE_CHAIN (tem);
9663 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9664 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9667 /* Terminate a function and expand its body. */
9670 source_end_java_method ()
9672 tree fndecl = current_function_decl;
9673 int flag_asynchronous_exceptions = asynchronous_exceptions;
9678 java_parser_context_save_global ();
9679 lineno = ctxp->last_ccb_indent1;
9681 /* Set EH language codes */
9682 java_set_exception_lang_code ();
9684 /* Turn function bodies with only a NOP expr null, so they don't get
9685 generated at all and we won't get warnings when using the -W
9687 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9688 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9690 /* Generate function's code */
9691 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9692 && ! flag_emit_class_files
9693 && ! flag_emit_xref)
9694 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9696 /* pop out of its parameters */
9697 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9699 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9701 /* Generate rtl for function exit. */
9702 if (! flag_emit_class_files && ! flag_emit_xref)
9704 lineno = DECL_SOURCE_LINE_LAST (fndecl);
9705 /* Emit catch-finally clauses */
9707 expand_function_end (input_filename, lineno, 0);
9709 /* FIXME: If the current method contains any exception handlers,
9710 force asynchronous_exceptions: this is necessary because signal
9711 handlers in libjava may throw exceptions. This is far from being
9712 a perfect solution, but it's better than doing nothing at all.*/
9714 asynchronous_exceptions = 1;
9716 /* Run the optimizers and output assembler code for this function. */
9717 rest_of_compilation (fndecl);
9720 current_function_decl = NULL_TREE;
9721 permanent_allocation (1);
9722 java_parser_context_restore_global ();
9723 asynchronous_exceptions = flag_asynchronous_exceptions;
9726 /* Record EXPR in the current function block. Complements compound
9727 expression second operand if necessary. */
9730 java_method_add_stmt (fndecl, expr)
9733 if (!GET_CURRENT_BLOCK (fndecl))
9735 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9739 add_stmt_to_block (b, type, stmt)
9742 tree body = BLOCK_EXPR_BODY (b), c;
9744 if (java_error_count)
9747 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9750 BLOCK_EXPR_BODY (b) = c;
9751 TREE_SIDE_EFFECTS (c) = 1;
9755 /* Add STMT to EXISTING if possible, otherwise create a new
9756 COMPOUND_EXPR and add STMT to it. */
9759 add_stmt_to_compound (existing, type, stmt)
9760 tree existing, type, stmt;
9763 return build (COMPOUND_EXPR, type, existing, stmt);
9768 /* Hold THIS for the scope of the current public method decl. */
9769 static tree current_this;
9771 void java_layout_seen_class_methods ()
9773 tree previous_list = all_class_list;
9774 tree end = NULL_TREE;
9779 for (current = previous_list;
9780 current != end; current = TREE_CHAIN (current))
9781 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9783 if (previous_list != all_class_list)
9785 end = previous_list;
9786 previous_list = all_class_list;
9794 java_reorder_fields ()
9796 static tree stop_reordering = NULL_TREE;
9799 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9801 current_class = TREE_TYPE (TREE_VALUE (current));
9803 if (current_class == stop_reordering)
9806 /* Reverse the fields, but leave the dummy field in front.
9807 Fields are already ordered for Object and Class */
9808 if (TYPE_FIELDS (current_class) && current_class != object_type_node
9809 && current_class != class_type_node)
9811 /* If the dummy field is there, reverse the right fields and
9812 just layout the type for proper fields offset */
9813 if (!DECL_NAME (TYPE_FIELDS (current_class)))
9815 tree fields = TYPE_FIELDS (current_class);
9816 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9817 TYPE_SIZE (current_class) = NULL_TREE;
9819 /* We don't have a dummy field, we need to layout the class,
9820 after having reversed the fields */
9823 TYPE_FIELDS (current_class) =
9824 nreverse (TYPE_FIELDS (current_class));
9825 TYPE_SIZE (current_class) = NULL_TREE;
9829 stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9832 /* Layout the methods of all classes loaded in one way on an
9833 other. Check methods of source parsed classes. Then reorder the
9834 fields and layout the classes or the type of all source parsed
9838 java_layout_classes ()
9841 int save_error_count = java_error_count;
9843 /* Layout the methods of all classes seen so far */
9844 java_layout_seen_class_methods ();
9845 java_parse_abort_on_error ();
9846 all_class_list = NULL_TREE;
9848 /* Then check the methods of all parsed classes */
9849 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9850 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9851 CHECK_METHODS (TREE_VALUE (current));
9852 java_parse_abort_on_error ();
9854 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9856 current_class = TREE_TYPE (TREE_VALUE (current));
9857 layout_class (current_class);
9859 /* From now on, the class is considered completely loaded */
9860 CLASS_LOADED_P (current_class) = 1;
9862 /* Error reported by the caller */
9863 if (java_error_count)
9867 /* We might have reloaded classes durign the process of laying out
9868 classes for code generation. We must layout the methods of those
9869 late additions, as constructor checks might use them */
9870 java_layout_seen_class_methods ();
9871 java_parse_abort_on_error ();
9874 /* Expand methods in the current set of classes rememebered for
9878 java_complete_expand_classes ()
9882 do_not_fold = flag_emit_xref;
9884 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9885 if (!INNER_CLASS_DECL_P (current))
9886 java_complete_expand_class (current);
9889 /* Expand the methods found in OUTER, starting first by OUTER's inner
9893 java_complete_expand_class (outer)
9898 set_nested_class_simple_name_value (outer, 1); /* Set */
9900 /* We need to go after all inner classes and start expanding them,
9901 starting with most nested ones. We have to do that because nested
9902 classes might add functions to outer classes */
9904 for (inner_list = DECL_INNER_CLASS_LIST (outer);
9905 inner_list; inner_list = TREE_CHAIN (inner_list))
9906 java_complete_expand_class (TREE_PURPOSE (inner_list));
9908 java_complete_expand_methods (outer);
9909 set_nested_class_simple_name_value (outer, 0); /* Reset */
9912 /* Expand methods registered in CLASS_DECL. The general idea is that
9913 we expand regular methods first. This allows us get an estimate on
9914 how outer context local alias fields are really used so we can add
9915 to the constructor just enough code to initialize them properly (it
9916 also lets us generate $finit$ correctly.) Then we expand the
9917 constructors and then <clinit>. */
9920 java_complete_expand_methods (class_decl)
9923 tree clinit, finit, decl, first_decl;
9925 current_class = TREE_TYPE (class_decl);
9927 /* Initialize a new constant pool */
9928 init_outgoing_cpool ();
9930 /* Pre-expand <clinit> to figure whether we really need it or
9931 not. If we do need it, we pre-expand the static fields so they're
9932 ready to be used somewhere else. <clinit> will be fully expanded
9933 after we processed the constructors. */
9934 first_decl = TYPE_METHODS (current_class);
9935 clinit = maybe_generate_pre_expand_clinit (current_class);
9937 /* Then generate $finit$ (if we need to) because constructor will
9939 if (TYPE_FINIT_STMT_LIST (current_class))
9941 finit = generate_finit (current_class);
9942 java_complete_expand_method (finit);
9945 /* Now do the constructors */
9946 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9950 if (!DECL_CONSTRUCTOR_P (decl))
9953 no_body = !DECL_FUNCTION_BODY (decl);
9954 /* Don't generate debug info on line zero when expanding a
9955 generated constructor. */
9957 restore_line_number_status (1);
9959 java_complete_expand_method (decl);
9962 restore_line_number_status (0);
9965 /* First, do the ordinary methods. */
9966 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
9968 /* Skip abstract or native methods */
9969 if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl)
9970 || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
9972 java_complete_expand_method (decl);
9975 /* If there is indeed a <clinit>, fully expand it now */
9978 /* Prevent the use of `this' inside <clinit> */
9979 ctxp->explicit_constructor_p = 1;
9980 java_complete_expand_method (clinit);
9981 ctxp->explicit_constructor_p = 0;
9984 /* We might have generated a class$ that we now want to expand */
9985 if (TYPE_DOT_CLASS (current_class))
9986 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
9988 /* Now verify constructor circularity (stop after the first one we
9990 if (!CLASS_INTERFACE (class_decl))
9991 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
9992 if (DECL_CONSTRUCTOR_P (decl)
9993 && verify_constructor_circularity (decl, decl))
9996 /* Save the constant pool. We'll need to restore it later. */
9997 TYPE_CPOOL (current_class) = outgoing_cpool;
10000 /* Hold a list of catch clauses list. The first element of this list is
10001 the list of the catch clauses of the currently analysed try block. */
10002 static tree currently_caught_type_list;
10004 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10005 safely used in some other methods/constructors. */
10008 maybe_generate_pre_expand_clinit (class_type)
10011 tree current, mdecl;
10013 if (!TYPE_CLINIT_STMT_LIST (class_type))
10016 /* Go through all static fields and pre expand them */
10017 for (current = TYPE_FIELDS (class_type); current;
10018 current = TREE_CHAIN (current))
10019 if (FIELD_STATIC (current))
10020 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10022 /* Then build the <clinit> method */
10023 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10024 clinit_identifier_node, end_params_node);
10025 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10027 start_artificial_method_body (mdecl);
10029 /* We process the list of assignment we produced as the result of
10030 the declaration of initialized static field and add them as
10031 statement to the <clinit> method. */
10032 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10033 current = TREE_CHAIN (current))
10035 /* We build the assignment expression that will initialize the
10036 field to its value. There are strict rules on static
10037 initializers (8.5). FIXME */
10038 tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10039 java_method_add_stmt (mdecl, stmt);
10042 end_artificial_method_body (mdecl);
10044 /* Now we want to place <clinit> as the last method for interface so
10045 that it doesn't interfere with the dispatch table based
10047 if (CLASS_INTERFACE (TYPE_NAME (class_type))
10048 && TREE_CHAIN (TYPE_METHODS (class_type)))
10051 TYPE_METHODS (class_type) = TREE_CHAIN (TYPE_METHODS (class_type));
10053 while (TREE_CHAIN (current))
10054 current = TREE_CHAIN (current);
10055 TREE_CHAIN (current) = mdecl;
10056 TREE_CHAIN (mdecl) = NULL_TREE;
10062 /* Complete and expand a method. */
10065 java_complete_expand_method (mdecl)
10068 current_function_decl = mdecl;
10069 /* Fix constructors before expanding them */
10070 if (DECL_CONSTRUCTOR_P (mdecl))
10071 fix_constructors (mdecl);
10073 /* Expand functions that have a body */
10074 if (DECL_FUNCTION_BODY (mdecl))
10076 tree fbody = DECL_FUNCTION_BODY (mdecl);
10077 tree block_body = BLOCK_EXPR_BODY (fbody);
10078 tree exception_copy = NULL_TREE;
10079 expand_start_java_method (mdecl);
10080 build_result_decl (mdecl);
10083 = (!METHOD_STATIC (mdecl) ?
10084 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10086 /* Purge the `throws' list of unchecked exceptions. If we're
10087 doing xref, save a copy of the list and re-install it
10089 if (flag_emit_xref)
10090 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10092 purge_unchecked_exceptions (mdecl);
10094 /* Install exceptions thrown with `throws' */
10095 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10097 if (block_body != NULL_TREE)
10099 block_body = java_complete_tree (block_body);
10101 if (!flag_emit_xref)
10102 check_for_initialization (block_body);
10103 ctxp->explicit_constructor_p = 0;
10105 BLOCK_EXPR_BODY (fbody) = block_body;
10107 /* If we saw a return but couldn't evaluate it properly, we'll
10108 have an error_mark_node here. */
10109 if (block_body != error_mark_node
10110 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10111 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10112 && !flag_emit_xref)
10113 missing_return_error (current_function_decl);
10115 complete_start_java_method (mdecl);
10117 /* Don't go any further if we've found error(s) during the
10119 if (!java_error_count)
10120 source_end_java_method ();
10123 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10124 poplevel (1, 0, 1);
10127 /* Pop the exceptions and sanity check */
10129 if (currently_caught_type_list)
10130 fatal ("Exception list non empty - java_complete_expand_method");
10132 if (flag_emit_xref)
10133 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10139 /* This section of the code deals with accessing enclosing context
10140 fields either directly by using the relevant access to this$<n> or
10141 by invoking an access method crafted for that purpose. */
10143 /* Build the necessary access from an inner class to an outer
10144 class. This routine could be optimized to cache previous result
10145 (decl, current_class and returned access). When an access method
10146 needs to be generated, it always takes the form of a read. It might
10147 be later turned into a write by calling outer_field_access_fix. */
10150 build_outer_field_access (id, decl)
10153 tree access = NULL_TREE;
10154 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10156 /* If decl's class is the direct outer class of the current_class,
10157 build the access as `this$<n>.<field>'. Not that we will break
10158 the `private' barrier if we're not emitting bytecodes. */
10159 if (ctx == DECL_CONTEXT (decl)
10160 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10162 tree thisn = build_current_thisn (current_class);
10163 access = make_qualified_primary (build_wfl_node (thisn),
10164 id, EXPR_WFL_LINECOL (id));
10166 /* Otherwise, generate access methods to outer this and access the
10167 field (either using an access method or by direct access.) */
10170 int lc = EXPR_WFL_LINECOL (id);
10172 /* Now we chain the required number of calls to the access$0 to
10173 get a hold to the enclosing instance we need, and the we
10174 build the field access. */
10175 access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10177 /* If the field is private and we're generating bytecode, then
10178 we generate an access method */
10179 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10181 tree name = build_outer_field_access_methods (decl);
10182 access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10183 name, access, NULL_TREE);
10185 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10186 Once again we break the `private' access rule from a foreign
10189 access = make_qualified_primary (access, id, lc);
10191 return resolve_expression_name (access, NULL);
10194 /* Return a non zero value if NODE describes an outer field inner
10198 outer_field_access_p (type, decl)
10201 if (!INNER_CLASS_TYPE_P (type)
10202 || TREE_CODE (decl) != FIELD_DECL
10203 || DECL_CONTEXT (decl) == type)
10206 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10207 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10209 if (type == DECL_CONTEXT (decl))
10211 if (!DECL_CONTEXT (TYPE_NAME (type)))
10218 /* Return a non zero value if NODE represents an outer field inner
10219 access that was been already expanded. As a side effect, it returns
10220 the name of the field being accessed and the argument passed to the
10221 access function, suitable for a regeneration of the access method
10222 call if necessary. */
10225 outer_field_expanded_access_p (node, name, arg_type, arg)
10226 tree node, *name, *arg_type, *arg;
10228 int identified = 0;
10230 if (TREE_CODE (node) != CALL_EXPR)
10233 /* Well, gcj generates slightly different tree nodes when compiling
10234 to native or bytecodes. It's the case for function calls. */
10236 if (flag_emit_class_files
10237 && TREE_CODE (node) == CALL_EXPR
10238 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10240 else if (!flag_emit_class_files)
10242 node = TREE_OPERAND (node, 0);
10244 if (node && TREE_OPERAND (node, 0)
10245 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10247 node = TREE_OPERAND (node, 0);
10248 if (TREE_OPERAND (node, 0)
10249 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10250 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
10251 (DECL_NAME (TREE_OPERAND (node, 0)))))
10256 if (identified && name && arg_type && arg)
10258 tree argument = TREE_OPERAND (node, 1);
10259 *name = DECL_NAME (TREE_OPERAND (node, 0));
10260 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10261 *arg = TREE_VALUE (argument);
10266 /* Detect in NODE an outer field read access from an inner class and
10267 transform it into a write with RHS as an argument. This function is
10268 called from the java_complete_lhs when an assignment to a LHS can
10272 outer_field_access_fix (wfl, node, rhs)
10273 tree wfl, node, rhs;
10275 tree name, arg_type, arg;
10277 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10279 /* At any rate, check whether we're trying to assign a value to
10281 tree accessed = (JDECL_P (node) ? node :
10282 (TREE_CODE (node) == COMPONENT_REF ?
10283 TREE_OPERAND (node, 1) : node));
10284 if (check_final_assignment (accessed, wfl))
10285 return error_mark_node;
10287 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
10288 arg_type, name, arg, rhs);
10289 return java_complete_tree (node);
10294 /* Construct the expression that calls an access method:
10295 <type>.access$<n>(<arg1> [, <arg2>]);
10297 ARG2 can be NULL and will be omitted in that case. It will denote a
10301 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10303 tree type, access_method_name, arg1, arg2;
10305 tree args, cn, access;
10307 args = arg1 ? arg1 :
10308 build_wfl_node (build_current_thisn (current_class));
10309 args = build_tree_list (NULL_TREE, args);
10312 args = tree_cons (NULL_TREE, arg2, args);
10314 access = build_method_invocation (build_wfl_node (access_method_name), args);
10315 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10316 return make_qualified_primary (cn, access, lc);
10320 build_new_access_id ()
10322 static int access_n_counter = 1;
10325 sprintf (buffer, "access$%d", access_n_counter++);
10326 return get_identifier (buffer);
10329 /* Create the static access functions for the outer field DECL. We define a
10331 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10332 return inst$.field;
10334 and a write access:
10335 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10336 TREE_TYPE (<field>) value$) {
10337 return inst$.field = value$;
10339 We should have a usage flags on the DECL so we can lazily turn the ones
10340 we're using for code generation. FIXME.
10344 build_outer_field_access_methods (decl)
10347 tree id, args, stmt, mdecl;
10349 /* Check point, to be removed. FIXME */
10350 if (FIELD_INNER_ACCESS (decl)
10351 && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10354 if (FIELD_INNER_ACCESS (decl))
10355 return FIELD_INNER_ACCESS (decl);
10357 push_obstacks (&permanent_obstack, &permanent_obstack);
10359 /* Create the identifier and a function named after it. */
10360 id = build_new_access_id ();
10362 /* The identifier is marked as bearing the name of a generated write
10363 access function for outer field accessed from inner classes. */
10364 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10366 /* Create the read access */
10367 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10368 TREE_CHAIN (args) = end_params_node;
10369 stmt = make_qualified_primary (build_wfl_node (inst_id),
10370 build_wfl_node (DECL_NAME (decl)), 0);
10371 stmt = build_return (0, stmt);
10372 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10373 TREE_TYPE (decl), id, args, stmt);
10374 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10376 /* Create the write access method */
10377 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10378 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10379 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10380 stmt = make_qualified_primary (build_wfl_node (inst_id),
10381 build_wfl_node (DECL_NAME (decl)), 0);
10382 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10383 build_wfl_node (wpv_id)));
10385 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10386 TREE_TYPE (decl), id, args, stmt);
10387 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10390 /* Return the access name */
10391 return FIELD_INNER_ACCESS (decl) = id;
10394 /* Build an field access method NAME. */
10397 build_outer_field_access_method (class, type, name, args, body)
10398 tree class, type, name, args, body;
10400 tree saved_current_function_decl, mdecl;
10402 /* Create the method */
10403 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10404 fix_method_argument_names (args, mdecl);
10405 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10407 /* Attach the method body. */
10408 saved_current_function_decl = current_function_decl;
10409 start_artificial_method_body (mdecl);
10410 java_method_add_stmt (mdecl, body);
10411 end_artificial_method_body (mdecl);
10412 current_function_decl = saved_current_function_decl;
10418 /* This section deals with building access function necessary for
10419 certain kinds of method invocation from inner classes. */
10422 build_outer_method_access_method (decl)
10425 tree saved_current_function_decl, mdecl;
10426 tree args = NULL_TREE, call_args = NULL_TREE;
10427 tree carg, id, body, class;
10429 int parm_id_count = 0;
10431 /* Test this abort with an access to a private field */
10432 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10435 /* Check the cache first */
10436 if (DECL_FUNCTION_INNER_ACCESS (decl))
10437 return DECL_FUNCTION_INNER_ACCESS (decl);
10439 class = DECL_CONTEXT (decl);
10441 /* Obtain an access identifier and mark it */
10442 id = build_new_access_id ();
10443 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10445 push_obstacks (&permanent_obstack, &permanent_obstack);
10447 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10448 /* Create the arguments, as much as the original */
10449 for (; carg && carg != end_params_node;
10450 carg = TREE_CHAIN (carg))
10452 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10453 args = chainon (args, build_tree_list (get_identifier (buffer),
10454 TREE_VALUE (carg)));
10456 args = chainon (args, end_params_node);
10458 /* Create the method */
10459 mdecl = create_artificial_method (class, ACC_STATIC,
10460 TREE_TYPE (TREE_TYPE (decl)), id, args);
10461 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10462 /* There is a potential bug here. We should be able to use
10463 fix_method_argument_names, but then arg names get mixed up and
10464 eventually a constructor will have its this$0 altered and the
10465 outer context won't be assignment properly. The test case is
10467 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10469 /* Attach the method body. */
10470 saved_current_function_decl = current_function_decl;
10471 start_artificial_method_body (mdecl);
10473 /* The actual method invocation uses the same args. When invoking a
10474 static methods that way, we don't want to skip the first
10477 if (!METHOD_STATIC (decl))
10478 carg = TREE_CHAIN (carg);
10479 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10480 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10483 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
10485 if (!METHOD_STATIC (decl))
10486 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
10488 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10489 body = build_return (0, body);
10490 java_method_add_stmt (mdecl,body);
10491 end_artificial_method_body (mdecl);
10492 current_function_decl = saved_current_function_decl;
10495 /* Back tag the access function so it know what it accesses */
10496 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10498 /* Tag the current method so it knows it has an access generated */
10499 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10503 /* This section of the code deals with building expressions to access
10504 the enclosing instance of an inner class. The enclosing instance is
10505 kept in a generated field called this$<n>, with <n> being the
10506 inner class nesting level (starting from 0.) */
10508 /* Build an access to a given this$<n>, possibly by chaining access
10509 call to others. Access methods to this$<n> are build on the fly if
10513 build_access_to_thisn (from, to, lc)
10517 tree access = NULL_TREE;
10521 tree access0_wfl, cn;
10523 maybe_build_thisn_access_method (from);
10524 access0_wfl = build_wfl_node (access0_identifier_node);
10525 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10526 EXPR_WFL_LINECOL (access0_wfl) = lc;
10530 access = build_current_thisn (current_class);
10531 access = build_wfl_node (access);
10533 access = build_tree_list (NULL_TREE, access);
10534 access = build_method_invocation (access0_wfl, access);
10535 access = make_qualified_primary (cn, access, lc);
10537 from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10542 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10543 is returned if nothing needs to be generated. Otherwise, the method
10544 generated, fully walked and a method decl is returned.
10546 NOTE: These generated methods should be declared in a class file
10547 attribute so that they can't be referred to directly. */
10550 maybe_build_thisn_access_method (type)
10553 tree mdecl, args, stmt, rtype;
10554 tree saved_current_function_decl;
10556 /* If TYPE is a top-level class, no access method is required.
10557 If there already is such an access method, bail out. */
10558 if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10561 /* We generate the method. The method looks like:
10562 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10564 push_obstacks (&permanent_obstack, &permanent_obstack);
10565 args = build_tree_list (inst_id, build_pointer_type (type));
10566 TREE_CHAIN (args) = end_params_node;
10567 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10568 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10569 access0_identifier_node, args);
10570 fix_method_argument_names (args, mdecl);
10571 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10572 stmt = build_current_thisn (type);
10573 stmt = make_qualified_primary (build_wfl_node (inst_id),
10574 build_wfl_node (stmt), 0);
10575 stmt = build_return (0, stmt);
10577 saved_current_function_decl = current_function_decl;
10578 start_artificial_method_body (mdecl);
10579 java_method_add_stmt (mdecl, stmt);
10580 end_artificial_method_body (mdecl);
10581 current_function_decl = saved_current_function_decl;
10584 CLASS_ACCESS0_GENERATED_P (type) = 1;
10589 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10590 the first level of innerclassing. this$1 for the next one, etc...
10591 This function can be invoked with TYPE to NULL, available and then
10592 has to count the parser context. */
10595 build_current_thisn (type)
10598 static int saved_i = -1;
10599 static tree saved_thisn = NULL_TREE;
10607 static tree saved_type = NULL_TREE;
10608 static int saved_type_i = 0;
10610 if (type == saved_type)
10614 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
10615 decl; decl = DECL_CONTEXT (decl), i++)
10623 i = list_length (GET_CPC_LIST ())-2;
10626 return saved_thisn;
10628 sprintf (buffer, "this$%d", i);
10630 saved_thisn = get_identifier (buffer);
10631 return saved_thisn;
10634 /* Return the assignement to the hidden enclosing context `this$<n>'
10635 by the second incoming parameter to the innerclass constructor. The
10636 form used is `this.this$<n> = this$<n>;'. */
10639 build_thisn_assign ()
10641 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10643 tree thisn = build_current_thisn (current_class);
10644 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10645 build_wfl_node (thisn), 0);
10646 tree rhs = build_wfl_node (thisn);
10647 EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10648 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10654 /* Building the synthetic `class$' used to implement the `.class' 1.1
10655 extension for non primitive types. This method looks like:
10657 static Class class$(String type) throws NoClassDefFoundError
10659 try {return (java.lang.Class.forName (String));}
10660 catch (ClassNotFoundException e) {
10661 throw new NoClassDefFoundError(e.getMessage());}
10665 build_dot_class_method (class)
10668 #define BWF(S) build_wfl_node (get_identifier ((S)))
10669 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10670 tree args, tmp, saved_current_function_decl, mdecl;
10671 tree stmt, throw_stmt, catch, catch_block, try_block;
10672 tree catch_clause_param;
10673 tree class_not_found_exception, no_class_def_found_error;
10675 static tree get_message_wfl, type_parm_wfl;
10677 if (!get_message_wfl)
10679 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10680 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10683 /* Build the arguments */
10684 args = build_tree_list (get_identifier ("type$"),
10685 build_pointer_type (string_type_node));
10686 TREE_CHAIN (args) = end_params_node;
10688 /* Build the qualified name java.lang.Class.forName */
10689 tmp = MQN (MQN (MQN (BWF ("java"),
10690 BWF ("lang")), BWF ("Class")), BWF ("forName"));
10692 /* For things we have to catch and throw */
10693 class_not_found_exception =
10694 lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10695 no_class_def_found_error =
10696 lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10697 load_class (class_not_found_exception, 1);
10698 load_class (no_class_def_found_error, 1);
10700 /* Create the "class$" function */
10701 mdecl = create_artificial_method (class, ACC_STATIC,
10702 build_pointer_type (class_type_node),
10703 get_identifier ("class$"), args);
10704 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10705 no_class_def_found_error);
10707 /* We start by building the try block. We need to build:
10708 return (java.lang.Class.forName (type)); */
10709 stmt = build_method_invocation (tmp,
10710 build_tree_list (NULL_TREE, type_parm_wfl));
10711 stmt = build_return (0, stmt);
10712 /* Put it in a block. That's the try block */
10713 try_block = build_expr_block (stmt, NULL_TREE);
10715 /* Now onto the catch block. We start by building the expression
10716 throwing a new exception:
10717 throw new NoClassDefFoundError (_.getMessage); */
10718 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
10719 get_message_wfl, 0);
10720 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10722 /* Build new NoClassDefFoundError (_.getMessage) */
10723 throw_stmt = build_new_invocation
10724 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10725 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10727 /* Build the throw, (it's too early to use BUILD_THROW) */
10728 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10730 /* Build the catch block to encapsulate all this. We begin by
10731 building an decl for the catch clause parameter and link it to
10732 newly created block, the catch block. */
10733 catch_clause_param =
10734 build_decl (VAR_DECL, wpv_id,
10735 build_pointer_type (class_not_found_exception));
10736 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10738 /* We initialize the variable with the exception handler. */
10739 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10740 soft_exceptioninfo_call_node);
10741 add_stmt_to_block (catch_block, NULL_TREE, catch);
10743 /* We add the statement throwing the new exception */
10744 add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10746 /* Build a catch expression for all this */
10747 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10749 /* Build the try/catch sequence */
10750 stmt = build_try_statement (0, try_block, catch_block);
10752 fix_method_argument_names (args, mdecl);
10753 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10754 saved_current_function_decl = current_function_decl;
10755 start_artificial_method_body (mdecl);
10756 java_method_add_stmt (mdecl, stmt);
10757 end_artificial_method_body (mdecl);
10758 current_function_decl = saved_current_function_decl;
10759 TYPE_DOT_CLASS (class) = mdecl;
10765 build_dot_class_method_invocation (name)
10768 tree s = make_node (STRING_CST);
10769 TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10770 TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10771 TREE_STRING_LENGTH (s)+1);
10772 strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10773 return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10774 build_tree_list (NULL_TREE, s));
10777 /* This section of the code deals with constructor. */
10779 /* Craft a body for default constructor. Patch existing constructor
10780 bodies with call to super() and field initialization statements if
10784 fix_constructors (mdecl)
10787 tree body = DECL_FUNCTION_BODY (mdecl);
10788 tree thisn_assign, compound = NULL_TREE;
10789 tree class_type = DECL_CONTEXT (mdecl);
10793 /* It is an error for the compiler to generate a default
10794 constructor if the superclass doesn't have a constructor that
10795 takes no argument, or the same args for an anonymous class */
10796 if (verify_constructor_super (mdecl))
10798 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10799 tree save = DECL_NAME (mdecl);
10800 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10801 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10802 parse_error_context
10803 (lookup_cl (TYPE_NAME (class_type)),
10804 "No constructor matching `%s' found in class `%s'",
10805 lang_printable_name (mdecl, 0), n);
10806 DECL_NAME (mdecl) = save;
10809 /* The constructor body must be crafted by hand. It's the
10810 constructor we defined when we realize we didn't have the
10811 CLASSNAME() constructor */
10812 start_artificial_method_body (mdecl);
10814 /* We don't generate a super constructor invocation if we're
10815 compiling java.lang.Object. build_super_invocation takes care
10817 compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10819 /* Insert the instance initializer block right here, after the
10820 super invocation. */
10821 add_instance_initializer (mdecl);
10823 /* Insert an assignment to the this$<n> hidden field, if
10825 if ((thisn_assign = build_thisn_assign ()))
10826 java_method_add_stmt (mdecl, thisn_assign);
10828 end_artificial_method_body (mdecl);
10830 /* Search for an explicit constructor invocation */
10834 tree main_block = BLOCK_EXPR_BODY (body);
10837 switch (TREE_CODE (body))
10840 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10843 case COMPOUND_EXPR:
10844 case EXPR_WITH_FILE_LOCATION:
10845 body = TREE_OPERAND (body, 0);
10848 body = BLOCK_EXPR_BODY (body);
10854 /* The constructor is missing an invocation of super() */
10856 compound = add_stmt_to_compound (compound, NULL_TREE,
10857 build_super_invocation (mdecl));
10859 /* Insert the instance initializer block right here, after the
10860 super invocation. */
10861 add_instance_initializer (mdecl);
10863 /* Generate the assignment to this$<n>, if necessary */
10864 if ((thisn_assign = build_thisn_assign ()))
10865 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10867 /* Fix the constructor main block if we're adding extra stmts */
10870 compound = add_stmt_to_compound (compound, NULL_TREE,
10871 BLOCK_EXPR_BODY (main_block));
10872 BLOCK_EXPR_BODY (main_block) = compound;
10877 /* Browse constructors in the super class, searching for a constructor
10878 that doesn't take any argument. Return 0 if one is found, 1
10879 otherwise. If the current class is an anonymous inner class, look
10880 for something that has the same signature. */
10883 verify_constructor_super (mdecl)
10886 tree class = CLASSTYPE_SUPER (current_class);
10892 if (ANONYMOUS_CLASS_P (current_class))
10894 tree mdecl_arg_type;
10895 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10896 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10897 if (DECL_CONSTRUCTOR_P (sdecl))
10900 for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
10901 arg_type != end_params_node &&
10902 mdecl_arg_type != end_params_node;
10903 arg_type = TREE_CHAIN (arg_type),
10904 mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
10905 if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
10908 if (arg_type == end_params_node &&
10909 mdecl_arg_type == end_params_node)
10915 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10917 if (DECL_CONSTRUCTOR_P (sdecl)
10918 && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)))
10919 == end_params_node)
10926 /* Generate code for all context remembered for code generation. */
10929 java_expand_classes ()
10931 int save_error_count = 0;
10932 static struct parser_ctxt *saved_ctxp = NULL;
10934 java_parse_abort_on_error ();
10935 if (!(ctxp = ctxp_for_generation))
10937 java_layout_classes ();
10938 java_parse_abort_on_error ();
10940 /* The list of packages declaration seen so far needs to be
10941 reversed, so that package declared in a file being compiled gets
10942 priority over packages declared as a side effect of parsing other
10944 package_list = nreverse (package_list);
10946 saved_ctxp = ctxp_for_generation;
10947 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10949 ctxp = ctxp_for_generation;
10950 lang_init_source (2); /* Error msgs have method prototypes */
10951 java_complete_expand_classes (); /* Complete and expand classes */
10952 java_parse_abort_on_error ();
10955 /* Find anonymous classes and expand their constructor, now they
10956 have been fixed. */
10957 for (ctxp_for_generation = saved_ctxp;
10958 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10961 ctxp = ctxp_for_generation;
10962 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10964 current_class = TREE_TYPE (current);
10965 if (ANONYMOUS_CLASS_P (current_class))
10968 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
10970 if (DECL_CONSTRUCTOR_P (d))
10972 restore_line_number_status (1);
10973 reset_method_name (d);
10974 java_complete_expand_method (d);
10975 restore_line_number_status (0);
10976 break; /* We now there are no other ones */
10983 /* If we've found error at that stage, don't try to generate
10984 anything, unless we're emitting xrefs or checking the syntax only
10985 (but not using -fsyntax-only for the purpose of generating
10987 if (java_error_count && !flag_emit_xref
10988 && (!flag_syntax_only && !flag_emit_class_files))
10991 /* Now things are stable, go for generation of the class data. */
10992 for (ctxp_for_generation = saved_ctxp;
10993 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10996 ctxp = ctxp_for_generation;
10997 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10999 current_class = TREE_TYPE (current);
11000 outgoing_cpool = TYPE_CPOOL (current_class);
11001 if (flag_emit_class_files)
11002 write_classfile (current_class);
11003 if (flag_emit_xref)
11004 expand_xref (current_class);
11005 else if (! flag_syntax_only)
11011 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11012 a tree list node containing RIGHT. Fore coming RIGHTs will be
11013 chained to this hook. LOCATION contains the location of the
11014 separating `.' operator. */
11017 make_qualified_primary (primary, right, location)
11018 tree primary, right;
11023 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11024 wfl = build_wfl_wrap (primary);
11028 /* If wfl wasn't qualified, we build a first anchor */
11029 if (!EXPR_WFL_QUALIFICATION (wfl))
11030 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11033 /* And chain them */
11034 EXPR_WFL_LINECOL (right) = location;
11035 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11036 PRIMARY_P (wfl) = 1;
11040 /* Simple merge of two name separated by a `.' */
11043 merge_qualified_name (left, right)
11047 if (!left && !right)
11056 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11057 IDENTIFIER_LENGTH (left));
11058 obstack_1grow (&temporary_obstack, '.');
11059 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11060 IDENTIFIER_LENGTH (right));
11061 node = get_identifier (obstack_base (&temporary_obstack));
11062 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11063 QUALIFIED_P (node) = 1;
11067 /* Merge the two parts of a qualified name into LEFT. Set the
11068 location information of the resulting node to LOCATION, usually
11069 inherited from the location information of the `.' operator. */
11072 make_qualified_name (left, right, location)
11076 #ifdef USE_COMPONENT_REF
11077 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11078 EXPR_WFL_LINECOL (node) = location;
11081 tree left_id = EXPR_WFL_NODE (left);
11082 tree right_id = EXPR_WFL_NODE (right);
11085 merge = merge_qualified_name (left_id, right_id);
11087 /* Left wasn't qualified and is now qualified */
11088 if (!QUALIFIED_P (left_id))
11090 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11091 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11092 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11095 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11096 EXPR_WFL_LINECOL (wfl) = location;
11097 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11099 EXPR_WFL_NODE (left) = merge;
11104 /* Extract the last identifier component of the qualified in WFL. The
11105 last identifier is removed from the linked list */
11108 cut_identifier_in_qualified (wfl)
11112 tree previous = NULL_TREE;
11113 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11114 if (!TREE_CHAIN (q))
11117 fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11118 TREE_CHAIN (previous) = NULL_TREE;
11119 return TREE_PURPOSE (q);
11123 /* Resolve the expression name NAME. Return its decl. */
11126 resolve_expression_name (id, orig)
11130 tree name = EXPR_WFL_NODE (id);
11133 /* 6.5.5.1: Simple expression names */
11134 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11136 /* 15.13.1: NAME can appear within the scope of a local variable
11138 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11141 /* 15.13.1: NAME can appear within a class declaration */
11144 decl = lookup_field_wrapper (current_class, name);
11146 /* Last chance: if we're within the context of an inner
11147 class, we might be trying to access a local variable
11148 defined in an outer context. We try to look for it
11150 if (!decl && INNER_CLASS_TYPE_P (current_class))
11152 char *alias_buffer;
11153 MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
11154 name = get_identifier (alias_buffer);
11155 decl = lookup_field_wrapper (current_class, name);
11157 FIELD_LOCAL_ALIAS_USED (decl) = 1;
11162 tree access = NULL_TREE;
11163 int fs = FIELD_STATIC (decl);
11164 /* Instance variable (8.3.1.1) can't appear within
11165 static method, static initializer or initializer for
11166 a static variable. */
11167 if (!fs && METHOD_STATIC (current_function_decl))
11169 static_ref_err (id, name, current_class);
11170 return error_mark_node;
11172 /* Instance variables can't appear as an argument of
11173 an explicit constructor invocation */
11174 if (!fs && ctxp->explicit_constructor_p)
11176 parse_error_context
11177 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11178 return error_mark_node;
11181 /* If we're processing an inner class and we're trying
11182 to access a field belonging to an outer class, build
11183 the access to the field */
11184 if (!fs && outer_field_access_p (current_class, decl))
11185 return build_outer_field_access (id, decl);
11187 /* Otherwise build what it takes to access the field */
11188 access = build_field_ref ((fs ? NULL_TREE : current_this),
11189 DECL_CONTEXT (decl), name);
11190 if (fs && !flag_emit_class_files && !flag_emit_xref)
11191 access = build_class_init (DECL_CONTEXT (access), access);
11192 /* We may be asked to save the real field access node */
11195 /* And we return what we got */
11198 /* Fall down to error report on undefined variable */
11201 /* 6.5.5.2 Qualified Expression Names */
11206 qualify_ambiguous_name (id);
11207 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11208 /* 15.10.2: Accessing Superclass Members using super */
11209 return resolve_field_access (id, orig, NULL);
11212 /* We've got an error here */
11213 parse_error_context (id, "Undefined variable `%s'",
11214 IDENTIFIER_POINTER (name));
11216 return error_mark_node;
11220 static_ref_err (wfl, field_id, class_type)
11221 tree wfl, field_id, class_type;
11223 parse_error_context
11225 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11226 IDENTIFIER_POINTER (field_id),
11227 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11230 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11231 We return something suitable to generate the field access. We also
11232 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
11233 recipient's address can be null. */
11236 resolve_field_access (qual_wfl, field_decl, field_type)
11238 tree *field_decl, *field_type;
11242 tree decl, where_found, type_found;
11244 if (resolve_qualified_expression_name (qual_wfl, &decl,
11245 &where_found, &type_found))
11246 return error_mark_node;
11248 /* Resolve the LENGTH field of an array here */
11249 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11250 && ! flag_emit_class_files && ! flag_emit_xref)
11252 tree length = build_java_array_length_access (where_found);
11254 build_java_arraynull_check (type_found, length, int_type_node);
11256 /* We might have been trying to resolve field.method(). In which
11257 case, the resolution is over and decl is the answer */
11258 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11260 else if (JDECL_P (decl))
11262 int static_final_found = 0;
11264 type_found = DECL_CONTEXT (decl);
11265 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11266 if (FIELD_FINAL (decl)
11267 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11268 && DECL_LANG_SPECIFIC (decl)
11269 && DECL_INITIAL (decl))
11271 field_ref = DECL_INITIAL (decl);
11272 static_final_found = 1;
11275 field_ref = build_field_ref ((is_static && !flag_emit_xref?
11276 NULL_TREE : where_found),
11277 type_found, DECL_NAME (decl));
11278 if (field_ref == error_mark_node)
11279 return error_mark_node;
11280 if (is_static && !static_final_found
11281 && !flag_emit_class_files && !flag_emit_xref)
11282 field_ref = build_class_init (type_found, field_ref);
11288 *field_decl = decl;
11290 *field_type = (QUAL_DECL_TYPE (decl) ?
11291 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11295 /* If NODE is an access to f static field, strip out the class
11296 initialization part and return the field decl, otherwise, return
11300 strip_out_static_field_access_decl (node)
11303 if (TREE_CODE (node) == COMPOUND_EXPR)
11305 tree op1 = TREE_OPERAND (node, 1);
11306 if (TREE_CODE (op1) == COMPOUND_EXPR)
11308 tree call = TREE_OPERAND (op1, 0);
11309 if (TREE_CODE (call) == CALL_EXPR
11310 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11311 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11312 == soft_initclass_node)
11313 return TREE_OPERAND (op1, 1);
11315 else if (JDECL_P (op1))
11321 /* 6.5.5.2: Qualified Expression Names */
11324 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11326 tree *found_decl, *type_found, *where_found;
11328 int from_type = 0; /* Field search initiated from a type */
11329 int from_super = 0, from_cast = 0, from_qualified_this = 0;
11330 int previous_call_static = 0;
11332 tree decl = NULL_TREE, type = NULL_TREE, q;
11333 /* For certain for of inner class instantiation */
11334 tree saved_current, saved_this;
11335 #define RESTORE_THIS_AND_CURRENT_CLASS \
11336 { current_class = saved_current; current_this = saved_this;}
11338 *type_found = *where_found = NULL_TREE;
11340 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11342 tree qual_wfl = QUAL_WFL (q);
11343 tree ret_decl; /* for EH checking */
11344 int location; /* for EH checking */
11346 /* 15.10.1 Field Access Using a Primary */
11347 switch (TREE_CODE (qual_wfl))
11350 case NEW_CLASS_EXPR:
11351 /* If the access to the function call is a non static field,
11352 build the code to access it. */
11353 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11355 decl = maybe_access_field (decl, *where_found,
11356 DECL_CONTEXT (decl));
11357 if (decl == error_mark_node)
11361 /* And code for the function call */
11362 if (complete_function_arguments (qual_wfl))
11365 /* We might have to setup a new current class and a new this
11366 for the search of an inner class, relative to the type of
11367 a expression resolved as `decl'. The current values are
11368 saved and restored shortly after */
11369 saved_current = current_class;
11370 saved_this = current_this;
11371 if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11373 current_class = type;
11374 current_this = decl;
11377 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11378 CALL_USING_SUPER (qual_wfl) = 1;
11379 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11380 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11381 *where_found = patch_method_invocation (qual_wfl, decl, type,
11382 &is_static, &ret_decl);
11383 if (*where_found == error_mark_node)
11385 RESTORE_THIS_AND_CURRENT_CLASS;
11388 *type_found = type = QUAL_DECL_TYPE (*where_found);
11390 /* If we're creating an inner class instance, check for that
11391 an enclosing instance is in scope */
11392 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11393 && INNER_ENCLOSING_SCOPE_CHECK (type))
11395 parse_error_context
11396 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11397 lang_printable_name (type, 0),
11398 (!current_this ? "" :
11399 "; an explicit one must be provided when creating this inner class"));
11400 RESTORE_THIS_AND_CURRENT_CLASS;
11404 /* In case we had to change then to resolve a inner class
11405 instantiation using a primary qualified by a `new' */
11406 RESTORE_THIS_AND_CURRENT_CLASS;
11410 check_thrown_exceptions (location, ret_decl);
11412 /* If the previous call was static and this one is too,
11413 build a compound expression to hold the two (because in
11414 that case, previous function calls aren't transported as
11415 forcoming function's argument. */
11416 if (previous_call_static && is_static)
11418 decl = build (COMPOUND_EXPR, type, decl, *where_found);
11419 TREE_SIDE_EFFECTS (decl) = 1;
11423 previous_call_static = is_static;
11424 decl = *where_found;
11429 case NEW_ARRAY_EXPR:
11430 case NEW_ANONYMOUS_ARRAY_EXPR:
11431 *where_found = decl = java_complete_tree (qual_wfl);
11432 if (decl == error_mark_node)
11434 *type_found = type = QUAL_DECL_TYPE (decl);
11435 CLASS_LOADED_P (type) = 1;
11439 *where_found = decl = java_complete_tree (qual_wfl);
11440 if (decl == error_mark_node)
11442 *type_found = type = QUAL_DECL_TYPE (decl);
11446 case CONDITIONAL_EXPR:
11449 *where_found = decl = java_complete_tree (qual_wfl);
11450 if (decl == error_mark_node)
11452 *type_found = type = QUAL_DECL_TYPE (decl);
11456 /* If the access to the function call is a non static field,
11457 build the code to access it. */
11458 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11460 decl = maybe_access_field (decl, *where_found, type);
11461 if (decl == error_mark_node)
11464 /* And code for the array reference expression */
11465 decl = java_complete_tree (qual_wfl);
11466 if (decl == error_mark_node)
11468 type = QUAL_DECL_TYPE (decl);
11472 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11474 if ((type = patch_string (decl)))
11476 *where_found = QUAL_RESOLUTION (q) = decl;
11477 *type_found = type = TREE_TYPE (decl);
11480 case CLASS_LITERAL:
11481 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11483 *where_found = QUAL_RESOLUTION (q) = decl;
11484 *type_found = type = TREE_TYPE (decl);
11488 /* Fix for -Wall Just go to the next statement. Don't
11493 /* If we fall here, we weren't processing a (static) function call. */
11494 previous_call_static = 0;
11496 /* It can be the keyword THIS */
11497 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11501 parse_error_context
11502 (wfl, "Keyword `this' used outside allowed context");
11505 if (ctxp->explicit_constructor_p)
11507 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11510 /* We have to generate code for intermediate acess */
11511 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11513 *where_found = decl = current_this;
11514 *type_found = type = QUAL_DECL_TYPE (decl);
11516 /* We're trying to access the this from somewhere else... */
11519 *where_found = decl = build_current_thisn (type);
11520 from_qualified_this = 1;
11527 /* 15.10.2 Accessing Superclass Members using SUPER */
11528 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11531 /* Check on the restricted use of SUPER */
11532 if (METHOD_STATIC (current_function_decl)
11533 || current_class == object_type_node)
11535 parse_error_context
11536 (wfl, "Keyword `super' used outside allowed context");
11539 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11540 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
11541 CLASSTYPE_SUPER (current_class),
11542 build_this (EXPR_WFL_LINECOL (qual_wfl)));
11543 *where_found = decl = java_complete_tree (node);
11544 if (decl == error_mark_node)
11546 *type_found = type = QUAL_DECL_TYPE (decl);
11547 from_super = from_type = 1;
11551 /* 15.13.1: Can't search for field name in packages, so we
11552 assume a variable/class name was meant. */
11553 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11555 tree name = resolve_package (wfl, &q);
11559 *where_found = decl = resolve_no_layout (name, qual_wfl);
11560 /* We wan't to be absolutely that the class is laid
11561 out. We're going to search something inside it. */
11562 *type_found = type = TREE_TYPE (decl);
11563 layout_class (type);
11566 /* Fix them all the way down, if any are left. */
11569 list = TREE_CHAIN (q);
11572 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11573 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11574 list = TREE_CHAIN (list);
11580 if (from_super || from_cast)
11581 parse_error_context
11582 ((from_cast ? qual_wfl : wfl),
11583 "No variable `%s' defined in class `%s'",
11584 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11585 lang_printable_name (type, 0));
11587 parse_error_context
11588 (qual_wfl, "Undefined variable or class name: `%s'",
11589 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11594 /* We have a type name. It's been already resolved when the
11595 expression was qualified. */
11596 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11598 if (!(decl = QUAL_RESOLUTION (q)))
11599 return 1; /* Error reported already */
11601 /* Sneak preview. If next we see a `new', we're facing a
11602 qualification with resulted in a type being selected
11603 instead of a field. Report the error */
11605 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11607 parse_error_context (qual_wfl, "Undefined variable `%s'",
11608 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11612 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11614 parse_error_context
11615 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11616 java_accstring_lookup (get_access_flags_from_decl (decl)),
11617 GET_TYPE_NAME (type),
11618 IDENTIFIER_POINTER (DECL_NAME (decl)),
11619 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11622 check_deprecation (qual_wfl, decl);
11624 type = TREE_TYPE (decl);
11627 /* We resolve and expression name */
11630 tree field_decl = NULL_TREE;
11632 /* If there exists an early resolution, use it. That occurs
11633 only once and we know that there are more things to
11634 come. Don't do that when processing something after SUPER
11635 (we need more thing to be put in place below */
11636 if (!from_super && QUAL_RESOLUTION (q))
11638 decl = QUAL_RESOLUTION (q);
11641 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11644 *where_found = current_this;
11647 static_ref_err (qual_wfl, DECL_NAME (decl),
11654 *where_found = TREE_TYPE (decl);
11655 if (TREE_CODE (*where_found) == POINTER_TYPE)
11656 *where_found = TREE_TYPE (*where_found);
11661 /* We have to search for a field, knowing the type of its
11662 container. The flag FROM_TYPE indicates that we resolved
11663 the last member of the expression as a type name, which
11664 means that for the resolution of this field, we'll look
11665 for other errors than if it was resolved as a member of
11670 tree field_decl_type; /* For layout */
11672 if (!from_type && !JREFERENCE_TYPE_P (type))
11674 parse_error_context
11675 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11676 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11677 lang_printable_name (type, 0),
11678 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11682 field_decl = lookup_field_wrapper (type,
11683 EXPR_WFL_NODE (qual_wfl));
11684 if (field_decl == NULL_TREE)
11686 parse_error_context
11687 (qual_wfl, "No variable `%s' defined in type `%s'",
11688 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11689 GET_TYPE_NAME (type));
11692 if (field_decl == error_mark_node)
11695 /* Layout the type of field_decl, since we may need
11696 it. Don't do primitive types or loaded classes. The
11697 situation of non primitive arrays may not handled
11698 properly here. FIXME */
11699 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11700 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11702 field_decl_type = TREE_TYPE (field_decl);
11703 if (!JPRIMITIVE_TYPE_P (field_decl_type)
11704 && !CLASS_LOADED_P (field_decl_type)
11705 && !TYPE_ARRAY_P (field_decl_type))
11706 resolve_and_layout (field_decl_type, NULL_TREE);
11707 if (TYPE_ARRAY_P (field_decl_type))
11708 CLASS_LOADED_P (field_decl_type) = 1;
11710 /* Check on accessibility here */
11711 if (not_accessible_p (type, field_decl, from_super))
11713 parse_error_context
11715 "Can't access %s field `%s.%s' from `%s'",
11716 java_accstring_lookup
11717 (get_access_flags_from_decl (field_decl)),
11718 GET_TYPE_NAME (type),
11719 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11721 (DECL_NAME (TYPE_NAME (current_class))));
11724 check_deprecation (qual_wfl, field_decl);
11726 /* There are things to check when fields are accessed
11727 from type. There are no restrictions on a static
11728 declaration of the field when it is accessed from an
11730 is_static = FIELD_STATIC (field_decl);
11731 if (!from_super && from_type
11732 && !TYPE_INTERFACE_P (type)
11734 && (current_function_decl
11735 && METHOD_STATIC (current_function_decl)))
11737 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11740 from_cast = from_super = 0;
11742 /* It's an access from a type but it isn't static, we
11743 make it relative to `this'. */
11744 if (!is_static && from_type)
11745 decl = current_this;
11747 /* If we need to generate something to get a proper
11748 handle on what this field is accessed from, do it
11752 decl = maybe_access_field (decl, *where_found, *type_found);
11753 if (decl == error_mark_node)
11757 /* We want to keep the location were found it, and the type
11759 *where_found = decl;
11760 *type_found = type;
11762 /* Generate the correct expression for field access from
11764 if (from_qualified_this)
11766 field_decl = build_outer_field_access (qual_wfl, field_decl);
11767 from_qualified_this = 0;
11770 /* This is the decl found and eventually the next one to
11775 type = QUAL_DECL_TYPE (decl);
11777 /* Sneak preview. If decl is qualified by a `new', report
11778 the error here to be accurate on the peculiar construct */
11780 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11781 && !JREFERENCE_TYPE_P (type))
11783 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
11784 lang_printable_name (type, 0));
11788 /* `q' might have changed due to a after package resolution
11789 re-qualification */
11793 *found_decl = decl;
11797 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11798 can't be accessed from REFERENCE (a record type). */
11801 not_accessible_p (reference, member, from_super)
11802 tree reference, member;
11805 int access_flag = get_access_flags_from_decl (member);
11807 /* Access always granted for members declared public */
11808 if (access_flag & ACC_PUBLIC)
11811 /* Check access on protected members */
11812 if (access_flag & ACC_PROTECTED)
11814 /* Access granted if it occurs from within the package
11815 containing the class in which the protected member is
11817 if (class_in_current_package (DECL_CONTEXT (member)))
11820 /* If accessed with the form `super.member', then access is granted */
11824 /* Otherwise, access is granted if occuring from the class where
11825 member is declared or a subclass of it */
11826 if (inherits_from_p (reference, current_class))
11831 /* Check access on private members. Access is granted only if it
11832 occurs from within the class in witch it is declared. Exceptions
11833 are access from inner-classes. This section is probably not
11835 if (access_flag & ACC_PRIVATE)
11836 return (current_class == DECL_CONTEXT (member) ? 0 :
11837 (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11839 /* Default access are permitted only when occuring within the
11840 package in which the type (REFERENCE) is declared. In other words,
11841 REFERENCE is defined in the current package */
11843 return !class_in_current_package (reference);
11845 /* Otherwise, access is granted */
11849 /* Test deprecated decl access. */
11851 check_deprecation (wfl, decl)
11854 const char *file = DECL_SOURCE_FILE (decl);
11855 /* Complain if the field is deprecated and the file it was defined
11856 in isn't compiled at the same time the file which contains its
11858 if (DECL_DEPRECATED (decl)
11859 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11862 switch (TREE_CODE (decl))
11864 case FUNCTION_DECL:
11865 strcpy (the, "method");
11868 strcpy (the, "field");
11871 strcpy (the, "class");
11874 fatal ("unexpected DECL code - check_deprecation");
11876 parse_warning_context
11877 (wfl, "The %s `%s' in class `%s' has been deprecated",
11878 the, lang_printable_name (decl, 0),
11879 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11883 /* Returns 1 if class was declared in the current package, 0 otherwise */
11886 class_in_current_package (class)
11889 static tree cache = NULL_TREE;
11890 int qualified_flag;
11893 if (cache == class)
11896 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11898 /* If the current package is empty and the name of CLASS is
11899 qualified, class isn't in the current package. If there is a
11900 current package and the name of the CLASS is not qualified, class
11901 isn't in the current package */
11902 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11905 /* If there is not package and the name of CLASS isn't qualified,
11906 they belong to the same unnamed package */
11907 if (!ctxp->package && !qualified_flag)
11910 /* Compare the left part of the name of CLASS with the package name */
11911 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
11912 if (ctxp->package == left)
11920 /* This function may generate code to access DECL from WHERE. This is
11921 done only if certain conditions meet. */
11924 maybe_access_field (decl, where, type)
11925 tree decl, where, type;
11927 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
11928 && !FIELD_STATIC (decl))
11929 decl = build_field_ref (where ? where : current_this,
11930 (type ? type : DECL_CONTEXT (decl)),
11935 /* Build a method invocation, by patching PATCH. If non NULL
11936 and according to the situation, PRIMARY and WHERE may be
11937 used. IS_STATIC is set to 1 if the invoked function is static. */
11940 patch_method_invocation (patch, primary, where, is_static, ret_decl)
11941 tree patch, primary, where;
11945 tree wfl = TREE_OPERAND (patch, 0);
11946 tree args = TREE_OPERAND (patch, 1);
11947 tree name = EXPR_WFL_NODE (wfl);
11949 int is_static_flag = 0;
11950 int is_super_init = 0;
11951 tree this_arg = NULL_TREE;
11953 /* Should be overriden if everything goes well. Otherwise, if
11954 something fails, it should keep this value. It stop the
11955 evaluation of a bogus assignment. See java_complete_tree,
11956 MODIFY_EXPR: for the reasons why we sometimes want to keep on
11957 evaluating an assignment */
11958 TREE_TYPE (patch) = error_mark_node;
11960 /* Since lookup functions are messing with line numbers, save the
11962 java_parser_context_save_global ();
11964 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
11966 /* Resolution of qualified name, excluding constructors */
11967 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
11969 tree identifier, identifier_wfl, type, resolved;
11970 /* Extract the last IDENTIFIER of the qualified
11971 expression. This is a wfl and we will use it's location
11972 data during error report. */
11973 identifier_wfl = cut_identifier_in_qualified (wfl);
11974 identifier = EXPR_WFL_NODE (identifier_wfl);
11976 /* Given the context, IDENTIFIER is syntactically qualified
11977 as a MethodName. We need to qualify what's before */
11978 qualify_ambiguous_name (wfl);
11979 resolved = resolve_field_access (wfl, NULL, NULL);
11981 if (resolved == error_mark_node)
11982 PATCH_METHOD_RETURN_ERROR ();
11984 type = GET_SKIP_TYPE (resolved);
11985 resolve_and_layout (type, NULL_TREE);
11986 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
11987 args = nreverse (args);
11989 /* We're resolving a call from a type */
11990 if (TREE_CODE (resolved) == TYPE_DECL)
11992 if (CLASS_INTERFACE (resolved))
11994 parse_error_context
11996 "Can't make static reference to method `%s' in interface `%s'",
11997 IDENTIFIER_POINTER (identifier),
11998 IDENTIFIER_POINTER (name));
11999 PATCH_METHOD_RETURN_ERROR ();
12001 if (list && !METHOD_STATIC (list))
12003 char *fct_name = xstrdup (lang_printable_name (list, 0));
12004 parse_error_context
12006 "Can't make static reference to method `%s %s' in class `%s'",
12007 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12008 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12010 PATCH_METHOD_RETURN_ERROR ();
12014 this_arg = primary = resolved;
12016 /* IDENTIFIER_WFL will be used to report any problem further */
12017 wfl = identifier_wfl;
12019 /* Resolution of simple names, names generated after a primary: or
12023 tree class_to_search = NULL_TREE;
12024 int lc; /* Looking for Constructor */
12026 /* We search constructor in their target class */
12027 if (CALL_CONSTRUCTOR_P (patch))
12029 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12030 class_to_search = EXPR_WFL_NODE (wfl);
12031 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12032 this_identifier_node)
12033 class_to_search = NULL_TREE;
12034 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12035 super_identifier_node)
12038 if (CLASSTYPE_SUPER (current_class))
12040 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12043 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12044 PATCH_METHOD_RETURN_ERROR ();
12048 /* Class to search is NULL if we're searching the current one */
12049 if (class_to_search)
12051 class_to_search = resolve_and_layout (class_to_search, wfl);
12053 if (!class_to_search)
12055 parse_error_context
12056 (wfl, "Class `%s' not found in type declaration",
12057 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12058 PATCH_METHOD_RETURN_ERROR ();
12061 /* Can't instantiate an abstract class, but we can
12062 invoke it's constructor. It's use within the `new'
12063 context is denied here. */
12064 if (CLASS_ABSTRACT (class_to_search)
12065 && TREE_CODE (patch) == NEW_CLASS_EXPR)
12067 parse_error_context
12068 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12069 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12070 PATCH_METHOD_RETURN_ERROR ();
12073 class_to_search = TREE_TYPE (class_to_search);
12076 class_to_search = current_class;
12079 /* This is a regular search in the local class, unless an
12080 alternate class is specified. */
12083 class_to_search = (where ? where : current_class);
12087 /* NAME is a simple identifier or comes from a primary. Search
12088 in the class whose declaration contain the method being
12090 resolve_and_layout (class_to_search, NULL_TREE);
12092 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12093 /* Don't continue if no method were found, as the next statement
12094 can't be executed then. */
12096 PATCH_METHOD_RETURN_ERROR ();
12098 /* Check for static reference if non static methods */
12099 if (check_for_static_method_reference (wfl, patch, list,
12100 class_to_search, primary))
12101 PATCH_METHOD_RETURN_ERROR ();
12103 /* Check for inner classes creation from illegal contexts */
12104 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12105 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12106 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12108 parse_error_context
12109 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12110 lang_printable_name (class_to_search, 0),
12111 (!current_this ? "" :
12112 "; an explicit one must be provided when creating this inner class"));
12113 PATCH_METHOD_RETURN_ERROR ();
12116 /* Non static methods are called with the current object extra
12117 argument. If patch a `new TYPE()', the argument is the value
12118 returned by the object allocator. If method is resolved as a
12119 primary, use the primary otherwise use the current THIS. */
12120 args = nreverse (args);
12121 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12123 this_arg = primary ? primary : current_this;
12125 /* If we're using an access method, things are different.
12126 There are two familly of cases:
12128 1) We're not generating bytecodes:
12130 - LIST is non static. It's invocation is transformed from
12131 x(a1,...,an) into this$<n>.x(a1,....an).
12132 - LIST is static. It's invocation is transformed from
12133 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12135 2) We're generating bytecodes:
12137 - LIST is non static. It's invocation is transformed from
12138 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12139 - LIST is static. It's invocation is transformed from
12140 x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12142 Of course, this$<n> can be abitrary complex, ranging from
12143 this$0 (the immediate outer context) to
12144 access$0(access$0(...(this$0))).
12146 maybe_use_access_method returns a non zero value if the
12147 this_arg has to be deplaced into the (then generated)
12148 stub argument list. In the mean time, the selected
12149 function might have be replaced by a generated stub. */
12150 if (maybe_use_access_method (is_super_init, &list, &this_arg))
12151 args = tree_cons (NULL_TREE, this_arg, args);
12155 /* Merge point of all resolution schemes. If we have nothing, this
12156 is an error, already signaled */
12158 PATCH_METHOD_RETURN_ERROR ();
12160 /* Check accessibility, position the is_static flag, build and
12162 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12164 char *fct_name = xstrdup (lang_printable_name (list, 0));
12165 parse_error_context
12166 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12167 java_accstring_lookup (get_access_flags_from_decl (list)),
12168 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12169 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
12170 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12172 PATCH_METHOD_RETURN_ERROR ();
12174 check_deprecation (wfl, list);
12176 /* If invoking a innerclass constructor, there are hidden parameters
12178 if (TREE_CODE (patch) == NEW_CLASS_EXPR
12179 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12181 /* And make sure we add the accessed local variables to be saved
12182 in field aliases. */
12183 args = build_alias_initializer_parameter_list
12184 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12186 /* We have to reverse things. Find out why. FIXME */
12187 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12188 args = nreverse (args);
12190 /* Secretely pass the current_this/primary as a second argument */
12191 if (primary || current_this)
12192 args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12194 args = tree_cons (NULL_TREE, integer_zero_node, args);
12197 is_static_flag = METHOD_STATIC (list);
12198 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12199 args = tree_cons (NULL_TREE, this_arg, args);
12201 /* In the context of an explicit constructor invocation, we can't
12202 invoke any method relying on `this'. Exceptions are: we're
12203 invoking a static function, primary exists and is not the current
12204 this, we're creating a new object. */
12205 if (ctxp->explicit_constructor_p
12207 && (!primary || primary == current_this)
12208 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12210 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12211 PATCH_METHOD_RETURN_ERROR ();
12213 java_parser_context_restore_global ();
12215 *is_static = is_static_flag;
12216 /* Sometimes, we want the decl of the selected method. Such as for
12220 patch = patch_invoke (patch, list, args);
12221 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12223 tree finit_parms, finit_call;
12225 /* Prepare to pass hidden parameters to $finit$, if any. */
12226 finit_parms = build_alias_initializer_parameter_list
12227 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12230 build_method_invocation (build_wfl_node (finit_identifier_node),
12233 /* Generate the code used to initialize fields declared with an
12234 initialization statement and build a compound statement along
12235 with the super constructor invocation. */
12236 patch = build (COMPOUND_EXPR, void_type_node, patch,
12237 java_complete_tree (finit_call));
12238 CAN_COMPLETE_NORMALLY (patch) = 1;
12243 /* Check that we're not trying to do a static reference to a method in
12244 non static method. Return 1 if it's the case, 0 otherwise. */
12247 check_for_static_method_reference (wfl, node, method, where, primary)
12248 tree wfl, node, method, where, primary;
12250 if (METHOD_STATIC (current_function_decl)
12251 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12253 char *fct_name = xstrdup (lang_printable_name (method, 0));
12254 parse_error_context
12255 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
12256 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12257 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12264 /* Fix the invocation of *MDECL if necessary in the case of a
12265 invocation from an inner class. *THIS_ARG might be modified
12266 appropriately and an alternative access to *MDECL might be
12270 maybe_use_access_method (is_super_init, mdecl, this_arg)
12272 tree *mdecl, *this_arg;
12275 tree md = *mdecl, ta = *this_arg;
12277 int non_static_context = !METHOD_STATIC (md);
12280 || DECL_CONTEXT (md) == current_class
12281 || !PURE_INNER_CLASS_TYPE_P (current_class)
12282 || DECL_FINIT_P (md))
12285 /* If we're calling a method found in an enclosing class, generate
12286 what it takes to retrieve the right this. Don't do that if we're
12287 invoking a static method. */
12289 if (non_static_context)
12291 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12292 if (ctx == DECL_CONTEXT (md))
12294 ta = build_current_thisn (current_class);
12295 ta = build_wfl_node (ta);
12302 maybe_build_thisn_access_method (type);
12303 if (type == DECL_CONTEXT (md))
12305 ta = build_access_to_thisn (ctx, type, 0);
12308 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
12309 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12312 ta = java_complete_tree (ta);
12315 /* We might have to use an access method to get to MD. We can
12316 break the method access rule as far as we're not generating
12318 if (METHOD_PRIVATE (md) && flag_emit_class_files)
12320 md = build_outer_method_access_method (md);
12327 /* Returnin a non zero value indicates we were doing a non static
12328 method invokation that is now a static invocation. It will have
12329 callee displace `this' to insert it in the regular argument
12331 return (non_static_context && to_return);
12334 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12338 patch_invoke (patch, method, args)
12339 tree patch, method, args;
12342 tree original_call, t, ta;
12344 /* Last step for args: convert build-in types. If we're dealing with
12345 a new TYPE() type call, the first argument to the constructor
12346 isn't found in the incomming argument list, but delivered by
12348 t = TYPE_ARG_TYPES (TREE_TYPE (method));
12349 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12350 t = TREE_CHAIN (t);
12351 for (ta = args; t != end_params_node && ta;
12352 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12353 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12354 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12355 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12357 /* Resolve unresolved returned type isses */
12358 t = TREE_TYPE (TREE_TYPE (method));
12359 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12360 resolve_and_layout (TREE_TYPE (t), NULL);
12362 if (flag_emit_class_files || flag_emit_xref)
12366 tree signature = build_java_signature (TREE_TYPE (method));
12367 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12369 case INVOKE_VIRTUAL:
12370 dtable = invoke_build_dtable (0, args);
12371 func = build_invokevirtual (dtable, method);
12375 case INVOKE_STATIC:
12376 func = build_known_method_ref (method, TREE_TYPE (method),
12377 DECL_CONTEXT (method),
12381 case INVOKE_INTERFACE:
12382 dtable = invoke_build_dtable (1, args);
12383 func = build_invokeinterface (dtable, method);
12387 fatal ("internal error - unknown invocation_mode result");
12390 /* Ensure self_type is initialized, (invokestatic). FIXME */
12391 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12394 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12395 TREE_OPERAND (patch, 0) = func;
12396 TREE_OPERAND (patch, 1) = args;
12397 original_call = patch;
12399 /* We're processing a `new TYPE ()' form. New is called an its
12400 returned value is the first argument to the constructor. We build
12401 a COMPOUND_EXPR and use saved expression so that the overall NEW
12402 expression value is a pointer to a newly created and initialized
12404 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12406 tree class = DECL_CONTEXT (method);
12407 tree c1, saved_new, size, new;
12408 if (flag_emit_class_files || flag_emit_xref)
12410 TREE_TYPE (patch) = build_pointer_type (class);
12413 if (!TYPE_SIZE (class))
12414 safe_layout_class (class);
12415 size = size_in_bytes (class);
12416 new = build (CALL_EXPR, promote_type (class),
12417 build_address_of (alloc_object_node),
12418 tree_cons (NULL_TREE, build_class_ref (class),
12419 build_tree_list (NULL_TREE,
12420 size_in_bytes (class))),
12422 saved_new = save_expr (new);
12423 c1 = build_tree_list (NULL_TREE, saved_new);
12424 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12425 TREE_OPERAND (original_call, 1) = c1;
12426 TREE_SET_CODE (original_call, CALL_EXPR);
12427 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12433 invocation_mode (method, super)
12437 int access = get_access_flags_from_decl (method);
12440 return INVOKE_SUPER;
12442 if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
12443 return INVOKE_STATIC;
12445 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12446 return INVOKE_STATIC;
12448 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12449 return INVOKE_INTERFACE;
12451 if (DECL_CONSTRUCTOR_P (method))
12452 return INVOKE_STATIC;
12454 return INVOKE_VIRTUAL;
12457 /* Retrieve a refined list of matching methods. It covers the step
12458 15.11.2 (Compile-Time Step 2) */
12461 lookup_method_invoke (lc, cl, class, name, arg_list)
12464 tree class, name, arg_list;
12466 tree atl = end_params_node; /* Arg Type List */
12467 tree method, signature, list, node;
12468 const char *candidates; /* Used for error report */
12471 /* Fix the arguments */
12472 for (node = arg_list; node; node = TREE_CHAIN (node))
12474 tree current_arg = TREE_TYPE (TREE_VALUE (node));
12475 /* Non primitive type may have to be resolved */
12476 if (!JPRIMITIVE_TYPE_P (current_arg))
12477 resolve_and_layout (current_arg, NULL_TREE);
12479 if (TREE_CODE (current_arg) == RECORD_TYPE)
12480 current_arg = promote_type (current_arg);
12481 atl = tree_cons (NULL_TREE, current_arg, atl);
12484 /* Presto. If we're dealing with an anonymous class and a
12485 constructor call, generate the right constructor now, since we
12486 know the arguments' types. */
12488 if (lc && ANONYMOUS_CLASS_P (class))
12489 craft_constructor (TYPE_NAME (class), atl);
12491 /* Find all candidates and then refine the list, searching for the
12492 most specific method. */
12493 list = find_applicable_accessible_methods_list (lc, class, name, atl);
12494 list = find_most_specific_methods_list (list);
12495 if (list && !TREE_CHAIN (list))
12496 return TREE_VALUE (list);
12498 /* Issue an error. List candidates if any. Candidates are listed
12499 only if accessible (non accessible methods may end-up here for
12500 the sake of a better error report). */
12505 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12506 for (current = list; current; current = TREE_CHAIN (current))
12508 tree cm = TREE_VALUE (current);
12509 char string [4096];
12510 if (!cm || not_accessible_p (class, cm, 0))
12513 (string, " `%s' in `%s'%s",
12514 get_printable_method_name (cm),
12515 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12516 (TREE_CHAIN (current) ? "\n" : ""));
12517 obstack_grow (&temporary_obstack, string, strlen (string));
12519 obstack_1grow (&temporary_obstack, '\0');
12520 candidates = obstack_finish (&temporary_obstack);
12522 /* Issue the error message */
12523 method = make_node (FUNCTION_TYPE);
12524 TYPE_ARG_TYPES (method) = atl;
12525 signature = build_java_argument_signature (method);
12526 dup = xstrdup (lang_printable_name (class, 0));
12527 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12528 (lc ? "constructor" : "method"),
12529 (lc ? dup : IDENTIFIER_POINTER (name)),
12530 IDENTIFIER_POINTER (signature), dup,
12531 (candidates ? candidates : ""));
12536 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12537 when we're looking for a constructor. */
12540 find_applicable_accessible_methods_list (lc, class, name, arglist)
12542 tree class, name, arglist;
12544 static int object_done = 0;
12545 tree list = NULL_TREE, all_list = NULL_TREE;
12547 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12549 load_class (class, 1);
12550 safe_layout_class (class);
12553 /* Search interfaces */
12554 if (CLASS_INTERFACE (TYPE_NAME (class)))
12556 static struct hash_table t, *searched_interfaces = NULL;
12557 static int search_not_done = 0;
12559 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12561 /* Search in the hash table, otherwise create a new one if
12562 necessary and insert the new entry. */
12564 if (searched_interfaces)
12566 if (hash_lookup (searched_interfaces,
12567 (const hash_table_key) class, FALSE, NULL))
12572 hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12573 java_hash_compare_tree_node);
12574 searched_interfaces = &t;
12577 hash_lookup (searched_interfaces,
12578 (const hash_table_key) class, TRUE, NULL);
12580 search_applicable_methods_list (lc, TYPE_METHODS (class),
12581 name, arglist, &list, &all_list);
12582 n = TREE_VEC_LENGTH (basetype_vec);
12583 for (i = 1; i < n; i++)
12585 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12589 rlist = find_applicable_accessible_methods_list (lc, t, name,
12591 list = chainon (rlist, list);
12595 /* We're done. Reset the searched interfaces list and finally search
12596 java.lang.Object */
12597 if (!search_not_done)
12600 search_applicable_methods_list (lc,
12601 TYPE_METHODS (object_type_node),
12602 name, arglist, &list, &all_list);
12603 hash_table_free (searched_interfaces);
12604 searched_interfaces = NULL;
12607 /* Search classes */
12611 int seen_inner_class = 0;
12612 search_applicable_methods_list (lc, TYPE_METHODS (class),
12613 name, arglist, &list, &all_list);
12615 /* We must search all interfaces of this class */
12618 tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12619 int n = TREE_VEC_LENGTH (basetype_vec), i;
12621 for (i = 1; i < n; i++)
12623 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12625 if (t != object_type_node)
12626 rlist = find_applicable_accessible_methods_list (lc, t,
12628 list = chainon (rlist, list);
12633 /* Search enclosing context of inner classes before looking
12635 while (!lc && INNER_CLASS_TYPE_P (class))
12638 seen_inner_class = 1;
12639 class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12640 rlist = find_applicable_accessible_methods_list (lc, class,
12642 list = chainon (rlist, list);
12645 if (!lc && seen_inner_class
12646 && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12647 class = CLASSTYPE_SUPER (sc);
12651 for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
12652 class; class = CLASSTYPE_SUPER (class))
12653 search_applicable_methods_list (lc, TYPE_METHODS (class),
12654 name, arglist, &list, &all_list);
12657 /* Either return the list obtained or all selected (but
12658 inaccessible) methods for better error report. */
12659 return (!list ? all_list : list);
12662 /* Effectively search for the approriate method in method */
12665 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12667 tree method, name, arglist;
12668 tree *list, *all_list;
12670 for (; method; method = TREE_CHAIN (method))
12672 /* When dealing with constructor, stop here, otherwise search
12674 if (lc && !DECL_CONSTRUCTOR_P (method))
12676 else if (!lc && (DECL_CONSTRUCTOR_P (method)
12677 || (GET_METHOD_NAME (method) != name)))
12680 if (argument_types_convertible (method, arglist))
12682 /* Retain accessible methods only */
12683 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
12685 *list = tree_cons (NULL_TREE, method, *list);
12687 /* Also retain all selected method here */
12688 *all_list = tree_cons (NULL_TREE, method, *list);
12693 /* 15.11.2.2 Choose the Most Specific Method */
12696 find_most_specific_methods_list (list)
12700 tree current, new_list = NULL_TREE;
12701 for (current = list; current; current = TREE_CHAIN (current))
12704 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12706 for (method = list; method; method = TREE_CHAIN (method))
12708 /* Don't test a method against itself */
12709 if (method == current)
12712 /* Compare arguments and location where method where declared */
12713 if (argument_types_convertible (TREE_VALUE (method),
12714 TREE_VALUE (current))
12715 && valid_method_invocation_conversion_p
12716 (DECL_CONTEXT (TREE_VALUE (method)),
12717 DECL_CONTEXT (TREE_VALUE (current))))
12719 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12720 max = (v > max ? v : max);
12725 /* Review the list and select the maximally specific methods */
12726 for (current = list; current; current = TREE_CHAIN (current))
12727 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12728 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12730 /* If we have several and they're all abstract, just pick the
12733 if (new_list && TREE_CHAIN (new_list))
12736 for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c));
12737 c = TREE_CHAIN (c))
12741 new_list = nreverse (new_list);
12742 TREE_CHAIN (new_list) = NULL_TREE;
12746 /* If we can't find one, lower expectations and try to gather multiple
12747 maximally specific methods */
12748 while (!new_list && max)
12752 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12753 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12760 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12761 converted by method invocation conversion (5.3) to the type of the
12762 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12763 to change less often than M1. */
12766 argument_types_convertible (m1, m2_or_arglist)
12767 tree m1, m2_or_arglist;
12769 static tree m2_arg_value = NULL_TREE;
12770 static tree m2_arg_cache = NULL_TREE;
12772 register tree m1_arg, m2_arg;
12774 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12776 if (m2_arg_value == m2_or_arglist)
12777 m2_arg = m2_arg_cache;
12780 /* M2_OR_ARGLIST can be a function DECL or a raw list of
12782 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12784 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12785 if (!METHOD_STATIC (m2_or_arglist))
12786 m2_arg = TREE_CHAIN (m2_arg);
12789 m2_arg = m2_or_arglist;
12791 m2_arg_value = m2_or_arglist;
12792 m2_arg_cache = m2_arg;
12795 while (m1_arg != end_params_node && m2_arg != end_params_node)
12797 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12798 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12799 TREE_VALUE (m2_arg)))
12801 m1_arg = TREE_CHAIN (m1_arg);
12802 m2_arg = TREE_CHAIN (m2_arg);
12804 return m1_arg == end_params_node && m2_arg == end_params_node;
12807 /* Qualification routines */
12810 qualify_ambiguous_name (id)
12813 tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12814 saved_current_class;
12815 int again, super_found = 0, this_found = 0, new_array_found = 0;
12818 /* We first qualify the first element, then derive qualification of
12819 others based on the first one. If the first element is qualified
12820 by a resolution (field or type), this resolution is stored in the
12821 QUAL_RESOLUTION of the qual element being examined. We need to
12822 save the current_class since the use of SUPER might change the
12824 saved_current_class = current_class;
12825 qual = EXPR_WFL_QUALIFICATION (id);
12828 /* Simple qualified expression feature a qual_wfl that is a
12829 WFL. Expression derived from a primary feature more complicated
12830 things like a CALL_EXPR. Expression from primary need to be
12831 worked out to extract the part on which the qualification will
12833 qual_wfl = QUAL_WFL (qual);
12834 switch (TREE_CODE (qual_wfl))
12837 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12838 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
12840 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12841 qual_wfl = QUAL_WFL (qual);
12844 case NEW_ARRAY_EXPR:
12845 case NEW_ANONYMOUS_ARRAY_EXPR:
12846 qual = TREE_CHAIN (qual);
12847 again = new_array_found = 1;
12849 case NEW_CLASS_EXPR:
12851 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12854 while (TREE_CODE (qual_wfl) == ARRAY_REF)
12855 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12858 qual = TREE_CHAIN (qual);
12859 qual_wfl = QUAL_WFL (qual);
12861 case CLASS_LITERAL:
12862 qual = TREE_CHAIN (qual);
12863 qual_wfl = QUAL_WFL (qual);
12866 /* Fix for -Wall. Just break doing nothing */
12870 ptr_type = current_class;
12872 code = TREE_CODE (qual_wfl);
12874 /* Pos evaluation: non WFL leading expression nodes */
12875 if (code == CONVERT_EXPR
12876 && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
12877 name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
12879 else if (code == INTEGER_CST)
12882 else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
12883 TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
12884 name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
12886 else if (code == TREE_LIST)
12887 name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
12889 else if (code == STRING_CST || code == CONDITIONAL_EXPR
12890 || code == PLUS_EXPR)
12892 qual = TREE_CHAIN (qual);
12893 qual_wfl = QUAL_WFL (qual);
12898 name = EXPR_WFL_NODE (qual_wfl);
12901 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12906 /* If we have a THIS (from a primary), we set the context accordingly */
12907 if (name == this_identifier_node)
12909 qual = TREE_CHAIN (qual);
12910 qual_wfl = QUAL_WFL (qual);
12911 if (TREE_CODE (qual_wfl) == CALL_EXPR)
12914 name = EXPR_WFL_NODE (qual_wfl);
12917 /* If we have a SUPER, we set the context accordingly */
12918 if (name == super_identifier_node)
12920 current_class = CLASSTYPE_SUPER (ptr_type);
12921 /* Check that there is such a thing as a super class. If not,
12922 return. The error will be caught later on, during the
12924 if (!current_class)
12926 current_class = saved_current_class;
12929 qual = TREE_CHAIN (qual);
12930 /* Do one more interation to set things up */
12931 super_found = again = 1;
12935 /* If name appears within the scope of a location variable
12936 declaration or parameter declaration, then it is an expression
12937 name. We don't carry this test out if we're in the context of the
12938 use of SUPER or THIS */
12939 if (!this_found && !super_found
12940 && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
12941 && (decl = IDENTIFIER_LOCAL_VALUE (name)))
12943 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12944 QUAL_RESOLUTION (qual) = decl;
12947 /* If within the class/interface NAME was found to be used there
12948 exists a (possibly inherited) field named NAME, then this is an
12949 expression name. If we saw a NEW_ARRAY_EXPR before and want to
12950 address length, it is OK. */
12951 else if ((decl = lookup_field_wrapper (ptr_type, name))
12952 || (new_array_found && name == length_identifier_node))
12954 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12955 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
12958 /* We reclassify NAME as yielding to a type name resolution if:
12959 - NAME is a class/interface declared within the compilation
12960 unit containing NAME,
12961 - NAME is imported via a single-type-import declaration,
12962 - NAME is declared in an another compilation unit of the package
12963 of the compilation unit containing NAME,
12964 - NAME is declared by exactly on type-import-on-demand declaration
12965 of the compilation unit containing NAME.
12966 - NAME is actually a STRING_CST. */
12967 else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
12968 || (decl = resolve_and_layout (name, NULL_TREE)))
12970 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
12971 QUAL_RESOLUTION (qual) = decl;
12974 /* Method call are expression name */
12975 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
12976 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
12977 || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
12978 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12980 /* Check here that NAME isn't declared by more than one
12981 type-import-on-demand declaration of the compilation unit
12982 containing NAME. FIXME */
12984 /* Otherwise, NAME is reclassified as a package name */
12986 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
12988 /* Propagate the qualification accross other components of the
12990 for (qual = TREE_CHAIN (qual); qual;
12991 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
12993 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
12994 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
12996 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
12999 /* Store the global qualification for the ambiguous part of ID back
13001 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13002 RESOLVE_EXPRESSION_NAME_P (id) = 1;
13003 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13004 RESOLVE_TYPE_NAME_P (id) = 1;
13005 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13006 RESOLVE_PACKAGE_NAME_P (id) = 1;
13008 /* Restore the current class */
13009 current_class = saved_current_class;
13013 breakdown_qualified (left, right, source)
13014 tree *left, *right, source;
13016 char *p = IDENTIFIER_POINTER (source), *base;
13017 int l = IDENTIFIER_LENGTH (source);
13019 /* Breakdown NAME into REMAINDER . IDENTIFIER */
13022 while (*p != '.' && p != base)
13025 /* We didn't find a '.'. Return an error */
13031 *right = get_identifier (p+1);
13032 *left = get_identifier (IDENTIFIER_POINTER (source));
13038 /* Patch tree nodes in a function body. When a BLOCK is found, push
13039 local variable decls if present.
13040 Same as java_complete_lhs, but does resolve static finals to values. */
13043 java_complete_tree (node)
13046 node = java_complete_lhs (node);
13047 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13048 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13049 && !flag_emit_xref)
13051 tree value = DECL_INITIAL (node);
13052 DECL_INITIAL (node) = NULL_TREE;
13053 push_obstacks (&permanent_obstack, &permanent_obstack);
13054 value = fold_constant_for_init (value, node);
13056 DECL_INITIAL (node) = value;
13057 if (value != NULL_TREE)
13059 /* fold_constant_for_init sometimes widen the original type
13060 of the constant (i.e. byte to int.) It's not desirable,
13061 especially if NODE is a function argument. */
13062 if (TREE_CODE (value) == INTEGER_CST
13063 && TREE_TYPE (node) != TREE_TYPE (value))
13064 return convert (TREE_TYPE (node), value);
13073 java_stabilize_reference (node)
13076 if (TREE_CODE (node) == COMPOUND_EXPR)
13078 tree op0 = TREE_OPERAND (node, 0);
13079 tree op1 = TREE_OPERAND (node, 1);
13080 TREE_OPERAND (node, 0) = save_expr (op0);
13081 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13084 return stabilize_reference (node);
13087 /* Patch tree nodes in a function body. When a BLOCK is found, push
13088 local variable decls if present.
13089 Same as java_complete_tree, but does not resolve static finals to values. */
13092 java_complete_lhs (node)
13095 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13098 /* CONVERT_EXPR always has its type set, even though it needs to be
13100 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13103 /* The switch block implements cases processing container nodes
13104 first. Contained nodes are always written back. Leaves come
13105 next and return a value. */
13106 switch (TREE_CODE (node))
13110 /* 1- Block section.
13111 Set the local values on decl names so we can identify them
13112 faster when they're referenced. At that stage, identifiers
13113 are legal so we don't check for declaration errors. */
13114 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13116 DECL_CONTEXT (cn) = current_function_decl;
13117 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13119 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13120 CAN_COMPLETE_NORMALLY (node) = 1;
13123 tree stmt = BLOCK_EXPR_BODY (node);
13125 int error_seen = 0;
13126 if (TREE_CODE (stmt) == COMPOUND_EXPR)
13128 /* Re-order from (((A; B); C); ...; Z) to
13129 (A; (B; (C ; (...; Z)))).
13130 This makes it easier to scan the statements left-to-right
13131 without using recursion (which might overflow the stack
13132 if the block has many statements. */
13135 tree left = TREE_OPERAND (stmt, 0);
13136 if (TREE_CODE (left) != COMPOUND_EXPR)
13138 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13139 TREE_OPERAND (left, 1) = stmt;
13142 BLOCK_EXPR_BODY (node) = stmt;
13145 /* Now do the actual complete, without deep recursion for
13147 ptr = &BLOCK_EXPR_BODY (node);
13148 while (TREE_CODE (*ptr) == COMPOUND_EXPR
13149 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13151 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13152 tree *next = &TREE_OPERAND (*ptr, 1);
13153 TREE_OPERAND (*ptr, 0) = cur;
13154 if (cur == empty_stmt_node)
13156 /* Optimization; makes it easier to detect empty bodies.
13157 Most useful for <clinit> with all-constant initializer. */
13161 if (TREE_CODE (cur) == ERROR_MARK)
13163 else if (! CAN_COMPLETE_NORMALLY (cur))
13168 if (TREE_CODE (wfl_op2) == BLOCK)
13169 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13170 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13171 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13175 if (TREE_CODE (wfl_op2) != CASE_EXPR
13176 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13177 unreachable_stmt_error (*ptr);
13181 *ptr = java_complete_tree (*ptr);
13183 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13184 return error_mark_node;
13185 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13187 /* Turn local bindings to null */
13188 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13189 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13191 TREE_TYPE (node) = void_type_node;
13194 /* 2- They are expressions but ultimately deal with statements */
13197 wfl_op1 = TREE_OPERAND (node, 0);
13198 COMPLETE_CHECK_OP_0 (node);
13199 /* 14.19 A throw statement cannot complete normally. */
13200 CAN_COMPLETE_NORMALLY (node) = 0;
13201 return patch_throw_statement (node, wfl_op1);
13203 case SYNCHRONIZED_EXPR:
13204 wfl_op1 = TREE_OPERAND (node, 0);
13205 return patch_synchronized_statement (node, wfl_op1);
13208 return patch_try_statement (node);
13210 case TRY_FINALLY_EXPR:
13211 COMPLETE_CHECK_OP_0 (node);
13212 COMPLETE_CHECK_OP_1 (node);
13213 CAN_COMPLETE_NORMALLY (node)
13214 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13215 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13216 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13219 case CLEANUP_POINT_EXPR:
13220 COMPLETE_CHECK_OP_0 (node);
13221 TREE_TYPE (node) = void_type_node;
13222 CAN_COMPLETE_NORMALLY (node) =
13223 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13226 case WITH_CLEANUP_EXPR:
13227 COMPLETE_CHECK_OP_0 (node);
13228 COMPLETE_CHECK_OP_2 (node);
13229 CAN_COMPLETE_NORMALLY (node) =
13230 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13231 TREE_TYPE (node) = void_type_node;
13234 case LABELED_BLOCK_EXPR:
13235 PUSH_LABELED_BLOCK (node);
13236 if (LABELED_BLOCK_BODY (node))
13237 COMPLETE_CHECK_OP_1 (node);
13238 TREE_TYPE (node) = void_type_node;
13239 POP_LABELED_BLOCK ();
13241 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13243 LABELED_BLOCK_BODY (node) = NULL_TREE;
13244 CAN_COMPLETE_NORMALLY (node) = 1;
13246 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13247 CAN_COMPLETE_NORMALLY (node) = 1;
13250 case EXIT_BLOCK_EXPR:
13251 /* We don't complete operand 1, because it's the return value of
13252 the EXIT_BLOCK_EXPR which doesn't exist it Java */
13253 return patch_bc_statement (node);
13256 cn = java_complete_tree (TREE_OPERAND (node, 0));
13257 if (cn == error_mark_node)
13260 /* First, the case expression must be constant. Values of final
13261 fields are accepted. */
13263 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13264 && JDECL_P (TREE_OPERAND (cn, 1))
13265 && FIELD_FINAL (TREE_OPERAND (cn, 1))
13266 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13268 push_obstacks (&permanent_obstack, &permanent_obstack);
13269 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13270 TREE_OPERAND (cn, 1));
13274 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13276 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13277 parse_error_context (node, "Constant expression required");
13278 return error_mark_node;
13281 nn = ctxp->current_loop;
13283 /* It must be assignable to the type of the switch expression. */
13284 if (!try_builtin_assignconv (NULL_TREE,
13285 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13287 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13288 parse_error_context
13290 "Incompatible type for case. Can't convert `%s' to `int'",
13291 lang_printable_name (TREE_TYPE (cn), 0));
13292 return error_mark_node;
13295 cn = fold (convert (int_type_node, cn));
13297 /* Multiple instance of a case label bearing the same
13298 value is checked during code generation. The case
13299 expression is allright so far. */
13300 TREE_OPERAND (node, 0) = cn;
13301 TREE_TYPE (node) = void_type_node;
13302 CAN_COMPLETE_NORMALLY (node) = 1;
13303 TREE_SIDE_EFFECTS (node) = 1;
13307 nn = ctxp->current_loop;
13308 /* Only one default label is allowed per switch statement */
13309 if (SWITCH_HAS_DEFAULT (nn))
13311 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13312 parse_error_context (wfl_operator,
13313 "Duplicate case label: `default'");
13314 return error_mark_node;
13317 SWITCH_HAS_DEFAULT (nn) = 1;
13318 TREE_TYPE (node) = void_type_node;
13319 TREE_SIDE_EFFECTS (node) = 1;
13320 CAN_COMPLETE_NORMALLY (node) = 1;
13326 /* Check whether the loop was enclosed in a labeled
13327 statement. If not, create one, insert the loop in it and
13329 nn = patch_loop_statement (node);
13331 /* Anyways, walk the body of the loop */
13332 if (TREE_CODE (node) == LOOP_EXPR)
13333 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13334 /* Switch statement: walk the switch expression and the cases */
13336 node = patch_switch_statement (node);
13338 if (TREE_OPERAND (node, 0) == error_mark_node)
13339 nn = error_mark_node;
13342 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13343 /* If we returned something different, that's because we
13344 inserted a label. Pop the label too. */
13347 if (CAN_COMPLETE_NORMALLY (node))
13348 CAN_COMPLETE_NORMALLY (nn) = 1;
13349 POP_LABELED_BLOCK ();
13356 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13357 return patch_exit_expr (node);
13361 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13362 if (TREE_OPERAND (node, 0) == error_mark_node)
13363 return error_mark_node;
13364 /* then-else branches */
13365 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13366 if (TREE_OPERAND (node, 1) == error_mark_node)
13367 return error_mark_node;
13368 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13369 if (TREE_OPERAND (node, 2) == error_mark_node)
13370 return error_mark_node;
13371 return patch_if_else_statement (node);
13374 case CONDITIONAL_EXPR:
13376 wfl_op1 = TREE_OPERAND (node, 0);
13377 COMPLETE_CHECK_OP_0 (node);
13378 wfl_op2 = TREE_OPERAND (node, 1);
13379 COMPLETE_CHECK_OP_1 (node);
13380 wfl_op3 = TREE_OPERAND (node, 2);
13381 COMPLETE_CHECK_OP_2 (node);
13382 return patch_conditional_expr (node, wfl_op1, wfl_op2);
13384 /* 3- Expression section */
13385 case COMPOUND_EXPR:
13386 wfl_op2 = TREE_OPERAND (node, 1);
13387 TREE_OPERAND (node, 0) = nn =
13388 java_complete_tree (TREE_OPERAND (node, 0));
13389 if (wfl_op2 == empty_stmt_node)
13390 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13393 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13395 /* An unreachable condition in a do-while statement
13396 is *not* (technically) an unreachable statement. */
13398 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13399 nn = EXPR_WFL_NODE (nn);
13400 if (TREE_CODE (nn) != EXIT_EXPR)
13402 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13403 parse_error_context (wfl_operator, "Unreachable statement");
13406 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13407 if (TREE_OPERAND (node, 1) == error_mark_node)
13408 return error_mark_node;
13409 CAN_COMPLETE_NORMALLY (node)
13410 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13412 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13416 /* CAN_COMPLETE_NORMALLY (node) = 0; */
13417 return patch_return (node);
13419 case EXPR_WITH_FILE_LOCATION:
13420 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13421 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13424 node = resolve_expression_name (node, NULL);
13425 if (node == error_mark_node)
13427 /* Keep line number information somewhere were it doesn't
13428 disrupt the completion process. */
13429 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13431 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13432 TREE_OPERAND (node, 1) = wfl;
13434 CAN_COMPLETE_NORMALLY (node) = 1;
13439 int save_lineno = lineno;
13440 lineno = EXPR_WFL_LINENO (node);
13441 body = java_complete_tree (EXPR_WFL_NODE (node));
13442 lineno = save_lineno;
13443 EXPR_WFL_NODE (node) = body;
13444 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13445 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13446 if (body == empty_stmt_node)
13448 /* Optimization; makes it easier to detect empty bodies. */
13451 if (body == error_mark_node)
13453 /* Its important for the evaluation of assignment that
13454 this mark on the TREE_TYPE is propagated. */
13455 TREE_TYPE (node) = error_mark_node;
13456 return error_mark_node;
13459 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13464 case NEW_ARRAY_EXPR:
13465 /* Patch all the dimensions */
13467 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13469 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13470 tree dim = convert (int_type_node,
13471 java_complete_tree (TREE_VALUE (cn)));
13472 if (dim == error_mark_node)
13479 TREE_VALUE (cn) = dim;
13480 /* Setup the location of the current dimension, for
13481 later error report. */
13482 TREE_PURPOSE (cn) =
13483 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13484 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13487 /* They complete the array creation expression, if no errors
13489 CAN_COMPLETE_NORMALLY (node) = 1;
13490 return (flag ? error_mark_node
13491 : force_evaluation_order (patch_newarray (node)));
13493 case NEW_ANONYMOUS_ARRAY_EXPR:
13494 /* Create the array type if necessary. */
13495 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13497 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13498 if (!(type = resolve_type_during_patch (type)))
13499 return error_mark_node;
13500 type = build_array_from_name (type, NULL_TREE,
13501 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13502 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13504 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13505 ANONYMOUS_ARRAY_INITIALIZER (node));
13506 if (node == error_mark_node)
13507 return error_mark_node;
13508 CAN_COMPLETE_NORMALLY (node) = 1;
13511 case NEW_CLASS_EXPR:
13513 /* Complete function's argument(s) first */
13514 if (complete_function_arguments (node))
13515 return error_mark_node;
13518 tree decl, wfl = TREE_OPERAND (node, 0);
13519 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13521 node = patch_method_invocation (node, NULL_TREE,
13522 NULL_TREE, 0, &decl);
13523 if (node == error_mark_node)
13524 return error_mark_node;
13526 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13527 /* If we call this(...), register signature and positions */
13529 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
13530 tree_cons (wfl, decl,
13531 DECL_CONSTRUCTOR_CALLS (current_function_decl));
13532 CAN_COMPLETE_NORMALLY (node) = 1;
13533 return force_evaluation_order (node);
13537 /* Save potential wfls */
13538 wfl_op1 = TREE_OPERAND (node, 0);
13539 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13541 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13542 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13543 && DECL_INITIAL (nn) != NULL_TREE)
13547 push_obstacks (&permanent_obstack, &permanent_obstack);
13548 value = fold_constant_for_init (nn, nn);
13551 if (value != NULL_TREE)
13553 tree type = TREE_TYPE (value);
13554 if (JPRIMITIVE_TYPE_P (type) ||
13555 (type == string_ptr_type_node && ! flag_emit_class_files))
13556 return empty_stmt_node;
13558 DECL_INITIAL (nn) = NULL_TREE;
13560 wfl_op2 = TREE_OPERAND (node, 1);
13562 if (TREE_OPERAND (node, 0) == error_mark_node)
13563 return error_mark_node;
13565 flag = COMPOUND_ASSIGN_P (wfl_op2);
13568 /* This might break when accessing outer field from inner
13569 class. TESTME, FIXME */
13570 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
13572 /* Hand stablize the lhs on both places */
13573 TREE_OPERAND (node, 0) = lvalue;
13574 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
13575 (flag_emit_class_files ? lvalue : save_expr (lvalue));
13577 /* 15.25.2.a: Left hand is not an array access. FIXME */
13578 /* Now complete the RHS. We write it back later on. */
13579 nn = java_complete_tree (TREE_OPERAND (node, 1));
13581 if ((cn = patch_string (nn)))
13584 /* The last part of the rewrite for E1 op= E2 is to have
13585 E1 = (T)(E1 op E2), with T being the type of E1. */
13586 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
13587 TREE_TYPE (lvalue), nn));
13589 /* 15.25.2.b: Left hand is an array access. FIXME */
13592 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13593 function to complete this RHS. Note that a NEW_ARRAY_INIT
13594 might have been already fully expanded if created as a result
13595 of processing an anonymous array initializer. We avoid doing
13596 the operation twice by testing whether the node already bears
13598 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13599 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13600 TREE_OPERAND (node, 1));
13601 /* Otherwise we simply complete the RHS */
13603 nn = java_complete_tree (TREE_OPERAND (node, 1));
13605 if (nn == error_mark_node)
13606 return error_mark_node;
13608 /* Write back the RHS as we evaluated it. */
13609 TREE_OPERAND (node, 1) = nn;
13611 /* In case we're handling = with a String as a RHS, we need to
13612 produce a String out of the RHS (it might still be a
13613 STRING_CST or a StringBuffer at this stage */
13614 if ((nn = patch_string (TREE_OPERAND (node, 1))))
13615 TREE_OPERAND (node, 1) = nn;
13617 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13618 TREE_OPERAND (node, 1))))
13620 /* We return error_mark_node if outer_field_access_fix
13621 detects we write into a final. */
13622 if (nn == error_mark_node)
13623 return error_mark_node;
13628 node = patch_assignment (node, wfl_op1, wfl_op2);
13629 /* Reorganize the tree if necessary. */
13630 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
13631 || JSTRING_P (TREE_TYPE (node))))
13632 node = java_refold (node);
13635 CAN_COMPLETE_NORMALLY (node) = 1;
13647 case TRUNC_MOD_EXPR:
13648 case TRUNC_DIV_EXPR:
13650 case TRUTH_ANDIF_EXPR:
13651 case TRUTH_ORIF_EXPR:
13658 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13659 knows how to handle those cases. */
13660 wfl_op1 = TREE_OPERAND (node, 0);
13661 wfl_op2 = TREE_OPERAND (node, 1);
13663 CAN_COMPLETE_NORMALLY (node) = 1;
13664 /* Don't complete string nodes if dealing with the PLUS operand. */
13665 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13667 nn = java_complete_tree (wfl_op1);
13668 if (nn == error_mark_node)
13669 return error_mark_node;
13671 TREE_OPERAND (node, 0) = nn;
13673 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13675 nn = java_complete_tree (wfl_op2);
13676 if (nn == error_mark_node)
13677 return error_mark_node;
13679 TREE_OPERAND (node, 1) = nn;
13681 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13683 case INSTANCEOF_EXPR:
13684 wfl_op1 = TREE_OPERAND (node, 0);
13685 COMPLETE_CHECK_OP_0 (node);
13686 if (flag_emit_xref)
13688 TREE_TYPE (node) = boolean_type_node;
13691 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13693 case UNARY_PLUS_EXPR:
13695 case TRUTH_NOT_EXPR:
13697 case PREDECREMENT_EXPR:
13698 case PREINCREMENT_EXPR:
13699 case POSTDECREMENT_EXPR:
13700 case POSTINCREMENT_EXPR:
13702 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13703 how to handle those cases. */
13704 wfl_op1 = TREE_OPERAND (node, 0);
13705 CAN_COMPLETE_NORMALLY (node) = 1;
13706 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13707 if (TREE_OPERAND (node, 0) == error_mark_node)
13708 return error_mark_node;
13709 node = patch_unaryop (node, wfl_op1);
13710 CAN_COMPLETE_NORMALLY (node) = 1;
13714 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13715 how to handle those cases. */
13716 wfl_op1 = TREE_OPERAND (node, 0);
13717 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13718 if (TREE_OPERAND (node, 0) == error_mark_node)
13719 return error_mark_node;
13720 if (!flag_emit_class_files && !flag_emit_xref)
13721 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13722 /* The same applies to wfl_op2 */
13723 wfl_op2 = TREE_OPERAND (node, 1);
13724 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13725 if (TREE_OPERAND (node, 1) == error_mark_node)
13726 return error_mark_node;
13727 if (!flag_emit_class_files && !flag_emit_xref)
13728 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13729 return patch_array_ref (node);
13734 case COMPONENT_REF:
13735 /* The first step in the re-write of qualified name handling. FIXME.
13736 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13737 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13738 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13740 tree name = TREE_OPERAND (node, 1);
13741 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13742 if (field == NULL_TREE)
13744 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13745 return error_mark_node;
13747 if (! FIELD_STATIC (field))
13749 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13750 return error_mark_node;
13755 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13759 /* Can't use THIS in a static environment */
13762 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13763 parse_error_context (wfl_operator,
13764 "Keyword `this' used outside allowed context");
13765 TREE_TYPE (node) = error_mark_node;
13766 return error_mark_node;
13768 if (ctxp->explicit_constructor_p)
13770 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13771 parse_error_context
13772 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13773 TREE_TYPE (node) = error_mark_node;
13774 return error_mark_node;
13776 return current_this;
13778 case CLASS_LITERAL:
13779 CAN_COMPLETE_NORMALLY (node) = 1;
13780 node = patch_incomplete_class_ref (node);
13781 if (node == error_mark_node)
13782 return error_mark_node;
13785 case INSTANCE_INITIALIZERS_EXPR:
13786 in_instance_initializer++;
13787 node = java_complete_tree (TREE_OPERAND (node, 0));
13788 in_instance_initializer--;
13789 if (node != error_mark_node)
13790 TREE_TYPE (node) = void_type_node;
13792 return error_mark_node;
13796 CAN_COMPLETE_NORMALLY (node) = 1;
13797 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13798 and it's time to turn it into the appropriate String object */
13799 if ((nn = patch_string (node)))
13802 fatal ("No case for tree code `%s' - java_complete_tree\n",
13803 tree_code_name [TREE_CODE (node)]);
13808 /* Complete function call's argument. Return a non zero value is an
13809 error was found. */
13812 complete_function_arguments (node)
13818 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13819 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13821 tree wfl = TREE_VALUE (cn), parm, temp;
13822 parm = java_complete_tree (wfl);
13824 if (parm == error_mark_node)
13829 /* If have a string literal that we haven't transformed yet or a
13830 crafted string buffer, as a result of use of the the String
13831 `+' operator. Build `parm.toString()' and expand it. */
13832 if ((temp = patch_string (parm)))
13834 /* Inline PRIMTYPE.TYPE read access */
13835 parm = maybe_build_primttype_type_ref (parm, wfl);
13837 TREE_VALUE (cn) = parm;
13839 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13843 /* Sometimes (for loops and variable initialized during their
13844 declaration), we want to wrap a statement around a WFL and turn it
13848 build_debugable_stmt (location, stmt)
13852 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
13854 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
13855 EXPR_WFL_LINECOL (stmt) = location;
13857 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
13862 build_expr_block (body, decls)
13865 tree node = make_node (BLOCK);
13866 BLOCK_EXPR_DECLS (node) = decls;
13867 BLOCK_EXPR_BODY (node) = body;
13869 TREE_TYPE (node) = TREE_TYPE (body);
13870 TREE_SIDE_EFFECTS (node) = 1;
13874 /* Create a new function block and link it approriately to current
13875 function block chain */
13880 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
13883 /* Link block B supercontext to the previous block. The current
13884 function DECL is used as supercontext when enter_a_block is called
13885 for the first time for a given function. The current function body
13886 (DECL_FUNCTION_BODY) is set to be block B. */
13892 tree fndecl = current_function_decl;
13895 BLOCK_SUPERCONTEXT (b) = current_static_block;
13896 current_static_block = b;
13899 else if (!DECL_FUNCTION_BODY (fndecl))
13901 BLOCK_SUPERCONTEXT (b) = fndecl;
13902 DECL_FUNCTION_BODY (fndecl) = b;
13906 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
13907 DECL_FUNCTION_BODY (fndecl) = b;
13912 /* Exit a block by changing the current function body
13913 (DECL_FUNCTION_BODY) to the current block super context, only if
13914 the block being exited isn't the method's top level one. */
13920 if (current_function_decl)
13922 b = DECL_FUNCTION_BODY (current_function_decl);
13923 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
13924 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
13928 b = current_static_block;
13930 if (BLOCK_SUPERCONTEXT (b))
13931 current_static_block = BLOCK_SUPERCONTEXT (b);
13936 /* Lookup for NAME in the nested function's blocks, all the way up to
13937 the current toplevel one. It complies with Java's local variable
13941 lookup_name_in_blocks (name)
13944 tree b = GET_CURRENT_BLOCK (current_function_decl);
13946 while (b != current_function_decl)
13950 /* Paranoid sanity check. To be removed */
13951 if (TREE_CODE (b) != BLOCK)
13952 fatal ("non block expr function body - lookup_name_in_blocks");
13954 for (current = BLOCK_EXPR_DECLS (b); current;
13955 current = TREE_CHAIN (current))
13956 if (DECL_NAME (current) == name)
13958 b = BLOCK_SUPERCONTEXT (b);
13964 maybe_absorb_scoping_blocks ()
13966 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
13968 tree b = exit_block ();
13969 java_method_add_stmt (current_function_decl, b);
13970 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
13975 /* This section of the source is reserved to build_* functions that
13976 are building incomplete tree nodes and the patch_* functions that
13977 are completing them. */
13979 /* Wrap a non WFL node around a WFL. */
13981 build_wfl_wrap (node)
13984 tree wfl, node_to_insert = node;
13986 /* We want to process THIS . xxx symbolicaly, to keep it consistent
13987 with the way we're processing SUPER. A THIS from a primary as a
13988 different form than a SUPER. Turn THIS into something symbolic */
13989 if (TREE_CODE (node) == THIS_EXPR)
13990 node_to_insert = wfl = build_wfl_node (this_identifier_node);
13992 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
13994 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
13995 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
14000 /* Build a super() constructor invocation. Returns empty_stmt_node if
14001 we're currently dealing with the class java.lang.Object. */
14004 build_super_invocation (mdecl)
14007 if (DECL_CONTEXT (mdecl) == object_type_node)
14008 return empty_stmt_node;
14011 tree super_wfl = build_wfl_node (super_identifier_node);
14012 tree a = NULL_TREE, t;
14013 /* If we're dealing with an anonymous class, pass the arguments
14014 of the crafted constructor along. */
14015 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14017 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14018 for (; t != end_params_node; t = TREE_CHAIN (t))
14019 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14021 return build_method_invocation (super_wfl, a);
14025 /* Build a SUPER/THIS qualified method invocation. */
14028 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14035 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14036 EXPR_WFL_LINECOL (wfl) = lloc;
14037 invok = build_method_invocation (name, args);
14038 return make_qualified_primary (wfl, invok, rloc);
14041 /* Build an incomplete CALL_EXPR node. */
14044 build_method_invocation (name, args)
14048 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14049 TREE_SIDE_EFFECTS (call) = 1;
14050 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14054 /* Build an incomplete new xxx(...) node. */
14057 build_new_invocation (name, args)
14060 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14061 TREE_SIDE_EFFECTS (call) = 1;
14062 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14066 /* Build an incomplete assignment expression. */
14069 build_assignment (op, op_location, lhs, rhs)
14070 int op, op_location;
14074 /* Build the corresponding binop if we deal with a Compound
14075 Assignment operator. Mark the binop sub-tree as part of a
14076 Compound Assignment expression */
14077 if (op != ASSIGN_TK)
14079 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14080 COMPOUND_ASSIGN_P (rhs) = 1;
14082 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14083 TREE_SIDE_EFFECTS (assignment) = 1;
14084 EXPR_WFL_LINECOL (assignment) = op_location;
14088 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14091 print_int_node (node)
14094 static char buffer [80];
14095 if (TREE_CONSTANT_OVERFLOW (node))
14096 sprintf (buffer, "<overflow>");
14098 if (TREE_INT_CST_HIGH (node) == 0)
14099 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14100 TREE_INT_CST_LOW (node));
14101 else if (TREE_INT_CST_HIGH (node) == -1
14102 && TREE_INT_CST_LOW (node) != 0)
14105 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14106 -TREE_INT_CST_LOW (node));
14109 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14110 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14115 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14119 check_final_assignment (lvalue, wfl)
14122 if (TREE_CODE (lvalue) == COMPOUND_EXPR
14123 && JDECL_P (TREE_OPERAND (lvalue, 1)))
14124 lvalue = TREE_OPERAND (lvalue, 1);
14126 /* When generating class files, references to the `length' field
14127 look a bit different. */
14128 if ((flag_emit_class_files
14129 && TREE_CODE (lvalue) == COMPONENT_REF
14130 && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14131 && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14132 || (TREE_CODE (lvalue) == FIELD_DECL
14133 && FIELD_FINAL (lvalue)
14134 && !DECL_CLINIT_P (current_function_decl)
14135 && !DECL_FINIT_P (current_function_decl)))
14137 parse_error_context
14138 (wfl, "Can't assign a value to the final variable `%s'",
14139 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14145 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14146 read. This is needed to avoid circularities in the implementation
14147 of these fields in libjava. */
14150 maybe_build_primttype_type_ref (rhs, wfl)
14153 tree to_return = NULL_TREE;
14154 tree rhs_type = TREE_TYPE (rhs);
14155 if (TREE_CODE (rhs) == COMPOUND_EXPR)
14157 tree n = TREE_OPERAND (rhs, 1);
14158 if (TREE_CODE (n) == VAR_DECL
14159 && DECL_NAME (n) == TYPE_identifier_node
14160 && rhs_type == class_ptr_type)
14162 const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14163 if (!strncmp (self_name, "java.lang.", 10))
14164 to_return = build_primtype_type_ref (self_name);
14167 return (to_return ? to_return : rhs );
14170 /* 15.25 Assignment operators. */
14173 patch_assignment (node, wfl_op1, wfl_op2)
14178 tree rhs = TREE_OPERAND (node, 1);
14179 tree lvalue = TREE_OPERAND (node, 0), llvalue;
14180 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14181 int error_found = 0;
14182 int lvalue_from_array = 0;
14184 /* Can't assign to a (blank) final. */
14185 if (check_final_assignment (lvalue, wfl_op1))
14188 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14190 /* Lhs can be a named variable */
14191 if (JDECL_P (lvalue))
14193 lhs_type = TREE_TYPE (lvalue);
14195 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14196 comment on reason why */
14197 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14199 lhs_type = TREE_TYPE (lvalue);
14200 lvalue_from_array = 1;
14202 /* Or a field access */
14203 else if (TREE_CODE (lvalue) == COMPONENT_REF)
14204 lhs_type = TREE_TYPE (lvalue);
14205 /* Or a function return slot */
14206 else if (TREE_CODE (lvalue) == RESULT_DECL)
14207 lhs_type = TREE_TYPE (lvalue);
14208 /* Otherwise, we might want to try to write into an optimized static
14209 final, this is an of a different nature, reported further on. */
14210 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14211 && resolve_expression_name (wfl_op1, &llvalue))
14213 if (!error_found && check_final_assignment (llvalue, wfl_op1))
14215 /* What we should do instead is resetting the all the flags
14216 previously set, exchange lvalue for llvalue and continue. */
14218 return error_mark_node;
14221 lhs_type = TREE_TYPE (lvalue);
14225 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14229 rhs_type = TREE_TYPE (rhs);
14230 /* 5.1 Try the assignment conversion for builtin type. */
14231 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14233 /* 5.2 If it failed, try a reference conversion */
14234 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14235 lhs_type = promote_type (rhs_type);
14237 /* 15.25.2 If we have a compound assignment, convert RHS into the
14239 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14240 new_rhs = convert (lhs_type, rhs);
14242 /* Explicit cast required. This is an error */
14245 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14246 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14248 char operation [32]; /* Max size known */
14250 /* If the assignment is part of a declaration, we use the WFL of
14251 the declared variable to point out the error and call it a
14252 declaration problem. If the assignment is a genuine =
14253 operator, we call is a operator `=' problem, otherwise we
14254 call it an assignment problem. In both of these last cases,
14255 we use the WFL of the operator to indicate the error. */
14257 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14260 strcpy (operation, "declaration");
14264 wfl = wfl_operator;
14265 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14266 strcpy (operation, "assignment");
14267 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14268 strcpy (operation, "`return'");
14270 strcpy (operation, "`='");
14273 if (!valid_cast_to_p (rhs_type, lhs_type))
14274 parse_error_context
14275 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14276 operation, t1, t2);
14278 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14279 operation, t1, t2);
14280 free (t1); free (t2);
14284 /* Inline read access to java.lang.PRIMTYPE.TYPE */
14286 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14289 return error_mark_node;
14291 /* 10.10: Array Store Exception runtime check */
14292 if (!flag_emit_class_files
14294 && lvalue_from_array
14295 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14298 tree base = lvalue;
14300 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14301 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14302 base = TREE_OPERAND (lvalue, 0);
14305 if (flag_bounds_check)
14306 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14308 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14311 /* Build the invocation of _Jv_CheckArrayStore */
14312 new_rhs = save_expr (new_rhs);
14313 check = build (CALL_EXPR, void_type_node,
14314 build_address_of (soft_checkarraystore_node),
14315 tree_cons (NULL_TREE, base,
14316 build_tree_list (NULL_TREE, new_rhs)),
14318 TREE_SIDE_EFFECTS (check) = 1;
14320 /* We have to decide on an insertion point */
14321 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14324 if (flag_bounds_check)
14326 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14327 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14328 build (COMPOUND_EXPR, void_type_node, t, check);
14331 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14332 check, TREE_OPERAND (lvalue, 1));
14336 /* Make sure the bound check will happen before the store check */
14337 if (flag_bounds_check)
14338 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14339 build (COMPOUND_EXPR, void_type_node,
14340 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14342 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14346 TREE_OPERAND (node, 0) = lvalue;
14347 TREE_OPERAND (node, 1) = new_rhs;
14348 TREE_TYPE (node) = lhs_type;
14352 /* Check that type SOURCE can be cast into type DEST. If the cast
14353 can't occur at all, return 0 otherwise 1. This function is used to
14354 produce accurate error messages on the reasons why an assignment
14358 try_reference_assignconv (lhs_type, rhs)
14359 tree lhs_type, rhs;
14361 tree new_rhs = NULL_TREE;
14362 tree rhs_type = TREE_TYPE (rhs);
14364 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14366 /* `null' may be assigned to any reference type */
14367 if (rhs == null_pointer_node)
14368 new_rhs = null_pointer_node;
14369 /* Try the reference assignment conversion */
14370 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14372 /* This is a magic assignment that we process differently */
14373 else if (rhs == soft_exceptioninfo_call_node)
14379 /* Check that RHS can be converted into LHS_TYPE by the assignment
14380 conversion (5.2), for the cases of RHS being a builtin type. Return
14381 NULL_TREE if the conversion fails or if because RHS isn't of a
14382 builtin type. Return a converted RHS if the conversion is possible. */
14385 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14386 tree wfl_op1, lhs_type, rhs;
14388 tree new_rhs = NULL_TREE;
14389 tree rhs_type = TREE_TYPE (rhs);
14391 /* Zero accepted everywhere */
14392 if (TREE_CODE (rhs) == INTEGER_CST
14393 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14394 && JPRIMITIVE_TYPE_P (rhs_type))
14395 new_rhs = convert (lhs_type, rhs);
14397 /* 5.1.1 Try Identity Conversion,
14398 5.1.2 Try Widening Primitive Conversion */
14399 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14400 new_rhs = convert (lhs_type, rhs);
14402 /* Try a narrowing primitive conversion (5.1.3):
14403 - expression is a constant expression of type int AND
14404 - variable is byte, short or char AND
14405 - The value of the expression is representable in the type of the
14407 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14408 && (lhs_type == byte_type_node || lhs_type == char_type_node
14409 || lhs_type == short_type_node))
14411 if (int_fits_type_p (rhs, lhs_type))
14412 new_rhs = convert (lhs_type, rhs);
14413 else if (wfl_op1) /* Might be called with a NULL */
14414 parse_warning_context
14415 (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'",
14416 print_int_node (rhs), lang_printable_name (lhs_type, 0));
14417 /* Reported a warning that will turn into an error further
14418 down, so we don't return */
14424 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14425 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
14426 0 is the conversion test fails. This implements parts the method
14427 invocation convertion (5.3). */
14430 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14431 tree lhs_type, rhs_type;
14433 /* 5.1.1: This is the identity conversion part. */
14434 if (lhs_type == rhs_type)
14437 /* Reject non primitive types */
14438 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14441 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14442 than a char can't be converted into a char. Short can't too, but
14443 the < test below takes care of that */
14444 if (lhs_type == char_type_node && rhs_type == byte_type_node)
14447 /* Accept all promoted type here. Note, we can't use <= in the test
14448 below, because we still need to bounce out assignments of short
14449 to char and the likes */
14450 if (lhs_type == int_type_node
14451 && (rhs_type == promoted_byte_type_node
14452 || rhs_type == promoted_short_type_node
14453 || rhs_type == promoted_char_type_node
14454 || rhs_type == promoted_boolean_type_node))
14457 /* From here, an integral is widened if its precision is smaller
14458 than the precision of the LHS or if the LHS is a floating point
14459 type, or the RHS is a float and the RHS a double. */
14460 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
14461 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14462 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14463 || (rhs_type == float_type_node && lhs_type == double_type_node))
14469 /* Check that something of SOURCE type can be assigned or cast to
14470 something of DEST type at runtime. Return 1 if the operation is
14471 valid, 0 otherwise. If CAST is set to 1, we're treating the case
14472 were SOURCE is cast into DEST, which borrows a lot of the
14473 assignment check. */
14476 valid_ref_assignconv_cast_p (source, dest, cast)
14481 /* SOURCE or DEST might be null if not from a declared entity. */
14482 if (!source || !dest)
14484 if (JNULLP_TYPE_P (source))
14486 if (TREE_CODE (source) == POINTER_TYPE)
14487 source = TREE_TYPE (source);
14488 if (TREE_CODE (dest) == POINTER_TYPE)
14489 dest = TREE_TYPE (dest);
14490 /* Case where SOURCE is a class type */
14491 if (TYPE_CLASS_P (source))
14493 if (TYPE_CLASS_P (dest))
14494 return (source == dest
14495 || inherits_from_p (source, dest)
14496 || enclosing_context_p (dest, source /*source, dest*/)
14497 || (cast && inherits_from_p (dest, source)));
14498 if (TYPE_INTERFACE_P (dest))
14500 /* If doing a cast and SOURCE is final, the operation is
14501 always correct a compile time (because even if SOURCE
14502 does not implement DEST, a subclass of SOURCE might). */
14503 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14505 /* Otherwise, SOURCE must implement DEST */
14506 return interface_of_p (dest, source);
14508 /* DEST is an array, cast permited if SOURCE is of Object type */
14509 return (cast && source == object_type_node ? 1 : 0);
14511 if (TYPE_INTERFACE_P (source))
14513 if (TYPE_CLASS_P (dest))
14515 /* If not casting, DEST must be the Object type */
14517 return dest == object_type_node;
14518 /* We're doing a cast. The cast is always valid is class
14519 DEST is not final, otherwise, DEST must implement SOURCE */
14520 else if (!CLASS_FINAL (TYPE_NAME (dest)))
14523 return interface_of_p (source, dest);
14525 if (TYPE_INTERFACE_P (dest))
14527 /* If doing a cast, then if SOURCE and DEST contain method
14528 with the same signature but different return type, then
14529 this is a (compile time) error */
14532 tree method_source, method_dest;
14536 for (method_source = TYPE_METHODS (source); method_source;
14537 method_source = TREE_CHAIN (method_source))
14540 build_java_argument_signature (TREE_TYPE (method_source));
14541 source_type = TREE_TYPE (TREE_TYPE (method_source));
14542 source_name = DECL_NAME (method_source);
14543 for (method_dest = TYPE_METHODS (dest);
14544 method_dest; method_dest = TREE_CHAIN (method_dest))
14546 build_java_argument_signature (TREE_TYPE (method_dest))
14547 && source_name == DECL_NAME (method_dest)
14548 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14554 return source == dest || interface_of_p (dest, source);
14558 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14560 if (TYPE_ARRAY_P (source))
14562 if (TYPE_CLASS_P (dest))
14563 return dest == object_type_node;
14564 /* Can't cast an array to an interface unless the interface is
14565 java.lang.Cloneable */
14566 if (TYPE_INTERFACE_P (dest))
14567 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14570 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14571 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14573 /* In case of severe errors, they turn out null */
14574 if (!dest_element_type || !source_element_type)
14576 if (source_element_type == dest_element_type)
14578 return valid_ref_assignconv_cast_p (source_element_type,
14579 dest_element_type, cast);
14587 valid_cast_to_p (source, dest)
14591 if (TREE_CODE (source) == POINTER_TYPE)
14592 source = TREE_TYPE (source);
14593 if (TREE_CODE (dest) == POINTER_TYPE)
14594 dest = TREE_TYPE (dest);
14596 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14597 return valid_ref_assignconv_cast_p (source, dest, 1);
14599 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14605 /* Method invocation conversion test. Return 1 if type SOURCE can be
14606 converted to type DEST through the methond invocation conversion
14610 do_unary_numeric_promotion (arg)
14613 tree type = TREE_TYPE (arg);
14614 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14615 : TREE_CODE (type) == CHAR_TYPE)
14616 arg = convert (int_type_node, arg);
14620 /* Return a non zero value if SOURCE can be converted into DEST using
14621 the method invocation conversion rule (5.3). */
14623 valid_method_invocation_conversion_p (dest, source)
14626 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14627 && valid_builtin_assignconv_identity_widening_p (dest, source))
14628 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14629 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14630 && valid_ref_assignconv_cast_p (source, dest, 0)));
14633 /* Build an incomplete binop expression. */
14636 build_binop (op, op_location, op1, op2)
14641 tree binop = build (op, NULL_TREE, op1, op2);
14642 TREE_SIDE_EFFECTS (binop) = 1;
14643 /* Store the location of the operator, for better error report. The
14644 string of the operator will be rebuild based on the OP value. */
14645 EXPR_WFL_LINECOL (binop) = op_location;
14649 /* Build the string of the operator retained by NODE. If NODE is part
14650 of a compound expression, add an '=' at the end of the string. This
14651 function is called when an error needs to be reported on an
14652 operator. The string is returned as a pointer to a static character
14656 operator_string (node)
14659 #define BUILD_OPERATOR_STRING(S) \
14661 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14665 static char buffer [10];
14666 switch (TREE_CODE (node))
14668 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14669 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14670 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14671 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14672 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14673 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14674 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14675 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14676 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14677 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14678 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14679 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14680 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14681 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14682 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14683 case GT_EXPR: BUILD_OPERATOR_STRING (">");
14684 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14685 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14686 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14687 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14688 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14689 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14690 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14691 case PREINCREMENT_EXPR: /* Fall through */
14692 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14693 case PREDECREMENT_EXPR: /* Fall through */
14694 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14696 fatal ("unregistered operator %s - operator_string",
14697 tree_code_name [TREE_CODE (node)]);
14700 #undef BUILD_OPERATOR_STRING
14703 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
14706 java_decl_equiv (var_acc1, var_acc2)
14707 tree var_acc1, var_acc2;
14709 if (JDECL_P (var_acc1))
14710 return (var_acc1 == var_acc2);
14712 return (TREE_CODE (var_acc1) == COMPONENT_REF
14713 && TREE_CODE (var_acc2) == COMPONENT_REF
14714 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14715 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14716 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14719 /* Return a non zero value if CODE is one of the operators that can be
14720 used in conjunction with the `=' operator in a compound assignment. */
14723 binop_compound_p (code)
14724 enum tree_code code;
14727 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14728 if (binop_lookup [i] == code)
14731 return i < BINOP_COMPOUND_CANDIDATES;
14734 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
14740 tree c, b, ns, decl;
14742 if (TREE_CODE (t) != MODIFY_EXPR)
14745 c = TREE_OPERAND (t, 1);
14746 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14747 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14748 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14751 /* Now the left branch of the binary operator. */
14752 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14753 if (! (b && TREE_CODE (b) == NOP_EXPR
14754 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14757 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14758 if (! (ns && TREE_CODE (ns) == NOP_EXPR
14759 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14762 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14763 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14764 /* It's got to be the an equivalent decl */
14765 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14767 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14768 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14769 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14770 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14771 /* Change the right part of the BINOP_EXPR */
14772 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14778 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14779 errors but we modify NODE so that it contains the type computed
14780 according to the expression, when it's fixed. Otherwise, we write
14781 error_mark_node as the type. It allows us to further the analysis
14782 of remaining nodes and detects more errors in certain cases. */
14785 patch_binop (node, wfl_op1, wfl_op2)
14790 tree op1 = TREE_OPERAND (node, 0);
14791 tree op2 = TREE_OPERAND (node, 1);
14792 tree op1_type = TREE_TYPE (op1);
14793 tree op2_type = TREE_TYPE (op2);
14794 tree prom_type = NULL_TREE, cn;
14795 int code = TREE_CODE (node);
14797 /* If 1, tell the routine that we have to return error_mark_node
14798 after checking for the initialization of the RHS */
14799 int error_found = 0;
14801 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14805 /* 15.16 Multiplicative operators */
14806 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
14807 case RDIV_EXPR: /* 15.16.2 Division Operator / */
14808 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
14809 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
14810 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14812 if (!JPRIMITIVE_TYPE_P (op1_type))
14813 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14814 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14815 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14816 TREE_TYPE (node) = error_mark_node;
14820 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14821 /* Change the division operator if necessary */
14822 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14823 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14825 if (TREE_CODE (prom_type) == INTEGER_TYPE
14826 && flag_use_divide_subroutine
14827 && ! flag_emit_class_files
14828 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14829 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14831 /* This one is more complicated. FLOATs are processed by a
14832 function call to soft_fmod. Duplicate the value of the
14833 COMPOUND_ASSIGN_P flag. */
14834 if (code == TRUNC_MOD_EXPR)
14836 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
14837 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
14838 TREE_SIDE_EFFECTS (mod)
14839 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14844 /* 15.17 Additive Operators */
14845 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
14847 /* Operation is valid if either one argument is a string
14848 constant, a String object or a StringBuffer crafted for the
14849 purpose of the a previous usage of the String concatenation
14852 if (TREE_CODE (op1) == STRING_CST
14853 || TREE_CODE (op2) == STRING_CST
14854 || JSTRING_TYPE_P (op1_type)
14855 || JSTRING_TYPE_P (op2_type)
14856 || IS_CRAFTED_STRING_BUFFER_P (op1)
14857 || IS_CRAFTED_STRING_BUFFER_P (op2))
14858 return build_string_concatenation (op1, op2);
14860 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
14862 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14864 if (!JPRIMITIVE_TYPE_P (op1_type))
14865 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14866 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14867 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14868 TREE_TYPE (node) = error_mark_node;
14872 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14875 /* 15.18 Shift Operators */
14879 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
14881 if (!JINTEGRAL_TYPE_P (op1_type))
14882 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14885 if (JPRIMITIVE_TYPE_P (op2_type))
14886 parse_error_context (wfl_operator,
14887 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
14888 operator_string (node),
14889 lang_printable_name (op2_type, 0));
14891 parse_error_context (wfl_operator,
14892 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
14893 operator_string (node),
14894 lang_printable_name (op2_type, 0));
14896 TREE_TYPE (node) = error_mark_node;
14901 /* Unary numeric promotion (5.6.1) is performed on each operand
14903 op1 = do_unary_numeric_promotion (op1);
14904 op2 = do_unary_numeric_promotion (op2);
14906 /* The type of the shift expression is the type of the promoted
14907 type of the left-hand operand */
14908 prom_type = TREE_TYPE (op1);
14910 /* Shift int only up to 0x1f and long up to 0x3f */
14911 if (prom_type == int_type_node)
14912 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14913 build_int_2 (0x1f, 0)));
14915 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14916 build_int_2 (0x3f, 0)));
14918 /* The >>> operator is a >> operating on unsigned quantities */
14919 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
14922 tree utype = unsigned_type (prom_type);
14923 op1 = convert (utype, op1);
14924 TREE_SET_CODE (node, RSHIFT_EXPR);
14925 TREE_OPERAND (node, 0) = op1;
14926 TREE_OPERAND (node, 1) = op2;
14927 TREE_TYPE (node) = utype;
14928 to_return = convert (prom_type, node);
14929 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
14930 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
14931 TREE_SIDE_EFFECTS (to_return)
14932 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14937 /* 15.19.1 Type Comparison Operator instaceof */
14938 case INSTANCEOF_EXPR:
14940 TREE_TYPE (node) = boolean_type_node;
14942 if (!(op2_type = resolve_type_during_patch (op2)))
14943 return error_mark_node;
14945 /* The first operand must be a reference type or the null type */
14946 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
14947 error_found = 1; /* Error reported further below */
14949 /* The second operand must be a reference type */
14950 if (!JREFERENCE_TYPE_P (op2_type))
14952 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14953 parse_error_context
14954 (wfl_operator, "Invalid argument `%s' for `instanceof'",
14955 lang_printable_name (op2_type, 0));
14959 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
14961 /* If the first operand is null, the result is always false */
14962 if (op1 == null_pointer_node)
14963 return boolean_false_node;
14964 else if (flag_emit_class_files)
14966 TREE_OPERAND (node, 1) = op2_type;
14967 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
14970 /* Otherwise we have to invoke instance of to figure it out */
14974 build (CALL_EXPR, boolean_type_node,
14975 build_address_of (soft_instanceof_node),
14978 build_tree_list (NULL_TREE,
14979 build_class_ref (op2_type))),
14981 TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
14985 /* There is no way the expression operand can be an instance of
14986 the type operand. This is a compile time error. */
14989 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
14990 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14991 parse_error_context
14992 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
14993 t1, lang_printable_name (op2_type, 0));
15000 /* 15.21 Bitwise and Logical Operators */
15004 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15005 /* Binary numeric promotion is performed on both operand and the
15006 expression retain that type */
15007 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15009 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
15010 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15011 /* The type of the bitwise operator expression is BOOLEAN */
15012 prom_type = boolean_type_node;
15015 if (!JINTEGRAL_TYPE_P (op1_type))
15016 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15017 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15018 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15019 TREE_TYPE (node) = error_mark_node;
15021 /* Insert a break here if adding thing before the switch's
15022 break for this case */
15026 /* 15.22 Conditional-And Operator */
15027 case TRUTH_ANDIF_EXPR:
15028 /* 15.23 Conditional-Or Operator */
15029 case TRUTH_ORIF_EXPR:
15030 /* Operands must be of BOOLEAN type */
15031 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
15032 TREE_CODE (op2_type) != BOOLEAN_TYPE)
15034 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15035 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15036 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15037 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15038 TREE_TYPE (node) = boolean_type_node;
15042 /* The type of the conditional operators is BOOLEAN */
15043 prom_type = boolean_type_node;
15046 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15051 /* The type of each of the operands must be a primitive numeric
15053 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15055 if (!JNUMERIC_TYPE_P (op1_type))
15056 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15057 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15058 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15059 TREE_TYPE (node) = boolean_type_node;
15063 /* Binary numeric promotion is performed on the operands */
15064 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15065 /* The type of the relation expression is always BOOLEAN */
15066 prom_type = boolean_type_node;
15069 /* 15.20 Equality Operator */
15072 /* It's time for us to patch the strings. */
15073 if ((cn = patch_string (op1)))
15076 op1_type = TREE_TYPE (op1);
15078 if ((cn = patch_string (op2)))
15081 op2_type = TREE_TYPE (op2);
15084 /* 15.20.1 Numerical Equality Operators == and != */
15085 /* Binary numeric promotion is performed on the operands */
15086 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15087 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15089 /* 15.20.2 Boolean Equality Operators == and != */
15090 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15091 TREE_CODE (op2_type) == BOOLEAN_TYPE)
15092 ; /* Nothing to do here */
15094 /* 15.20.3 Reference Equality Operators == and != */
15095 /* Types have to be either references or the null type. If
15096 they're references, it must be possible to convert either
15097 type to the other by casting conversion. */
15098 else if (op1 == null_pointer_node || op2 == null_pointer_node
15099 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15100 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15101 || valid_ref_assignconv_cast_p (op2_type,
15103 ; /* Nothing to do here */
15105 /* Else we have an error figure what can't be converted into
15106 what and report the error */
15110 t1 = xstrdup (lang_printable_name (op1_type, 0));
15111 parse_error_context
15113 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15114 operator_string (node), t1,
15115 lang_printable_name (op2_type, 0));
15117 TREE_TYPE (node) = boolean_type_node;
15121 prom_type = boolean_type_node;
15126 return error_mark_node;
15128 TREE_OPERAND (node, 0) = op1;
15129 TREE_OPERAND (node, 1) = op2;
15130 TREE_TYPE (node) = prom_type;
15131 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15133 if (flag_emit_xref)
15136 /* fold does not respect side-effect order as required for Java but not C.
15137 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15140 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15141 : ! TREE_SIDE_EFFECTS (node))
15142 node = fold (node);
15146 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15147 zero value, the value of CSTE comes after the valude of STRING */
15150 do_merge_string_cste (cste, string, string_len, after)
15152 const char *string;
15153 int string_len, after;
15155 int len = TREE_STRING_LENGTH (cste) + string_len;
15156 const char *old = TREE_STRING_POINTER (cste);
15157 TREE_STRING_LENGTH (cste) = len;
15158 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15161 strcpy (TREE_STRING_POINTER (cste), string);
15162 strcat (TREE_STRING_POINTER (cste), old);
15166 strcpy (TREE_STRING_POINTER (cste), old);
15167 strcat (TREE_STRING_POINTER (cste), string);
15172 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15173 new STRING_CST on success, NULL_TREE on failure */
15176 merge_string_cste (op1, op2, after)
15180 /* Handle two string constants right away */
15181 if (TREE_CODE (op2) == STRING_CST)
15182 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
15183 TREE_STRING_LENGTH (op2), after);
15185 /* Reasonable integer constant can be treated right away */
15186 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15188 static const char *boolean_true = "true";
15189 static const char *boolean_false = "false";
15190 static const char *null_pointer = "null";
15192 const char *string;
15194 if (op2 == boolean_true_node)
15195 string = boolean_true;
15196 else if (op2 == boolean_false_node)
15197 string = boolean_false;
15198 else if (op2 == null_pointer_node)
15199 string = null_pointer;
15200 else if (TREE_TYPE (op2) == char_type_node)
15202 ch[0] = (char )TREE_INT_CST_LOW (op2);
15207 string = print_int_node (op2);
15209 return do_merge_string_cste (op1, string, strlen (string), after);
15214 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15215 has to be a STRING_CST and the other part must be a STRING_CST or a
15216 INTEGRAL constant. Return a new STRING_CST if the operation
15217 succeed, NULL_TREE otherwise.
15219 If the case we want to optimize for space, we might want to return
15220 NULL_TREE for each invocation of this routine. FIXME */
15223 string_constant_concatenation (op1, op2)
15226 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15231 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15232 rest = (string == op1 ? op2 : op1);
15233 invert = (string == op1 ? 0 : 1 );
15235 /* Walk REST, only if it looks reasonable */
15236 if (TREE_CODE (rest) != STRING_CST
15237 && !IS_CRAFTED_STRING_BUFFER_P (rest)
15238 && !JSTRING_TYPE_P (TREE_TYPE (rest))
15239 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15241 rest = java_complete_tree (rest);
15242 if (rest == error_mark_node)
15243 return error_mark_node;
15244 rest = fold (rest);
15246 return merge_string_cste (string, rest, invert);
15251 /* Implement the `+' operator. Does static optimization if possible,
15252 otherwise create (if necessary) and append elements to a
15253 StringBuffer. The StringBuffer will be carried around until it is
15254 used for a function call or an assignment. Then toString() will be
15255 called on it to turn it into a String object. */
15258 build_string_concatenation (op1, op2)
15262 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15264 if (flag_emit_xref)
15265 return build (PLUS_EXPR, string_type_node, op1, op2);
15267 /* Try to do some static optimization */
15268 if ((result = string_constant_concatenation (op1, op2)))
15271 /* Discard empty strings on either side of the expression */
15272 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15277 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15280 /* If operands are string constant, turn then into object references */
15281 if (TREE_CODE (op1) == STRING_CST)
15282 op1 = patch_string_cst (op1);
15283 if (op2 && TREE_CODE (op2) == STRING_CST)
15284 op2 = patch_string_cst (op2);
15286 /* If either one of the constant is null and the other non null
15287 operand is a String object, return it. */
15288 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15291 /* If OP1 isn't already a StringBuffer, create and
15292 initialize a new one */
15293 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15295 /* Two solutions here:
15296 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15297 2) OP1 is something else, we call new StringBuffer().append(OP1). */
15298 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15299 op1 = BUILD_STRING_BUFFER (op1);
15302 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15303 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15309 /* OP1 is no longer the last node holding a crafted StringBuffer */
15310 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15311 /* Create a node for `{new...,xxx}.append (op2)' */
15313 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15316 /* Mark the last node holding a crafted StringBuffer */
15317 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15319 TREE_SIDE_EFFECTS (op1) = side_effects;
15323 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15324 StringBuffer. If no string were found to be patched, return
15328 patch_string (node)
15331 if (node == error_mark_node)
15332 return error_mark_node;
15333 if (TREE_CODE (node) == STRING_CST)
15334 return patch_string_cst (node);
15335 else if (IS_CRAFTED_STRING_BUFFER_P (node))
15337 int saved = ctxp->explicit_constructor_p;
15338 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15340 /* Temporary disable forbid the use of `this'. */
15341 ctxp->explicit_constructor_p = 0;
15342 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15343 /* String concatenation arguments must be evaluated in order too. */
15344 ret = force_evaluation_order (ret);
15345 /* Restore it at its previous value */
15346 ctxp->explicit_constructor_p = saved;
15352 /* Build the internal representation of a string constant. */
15355 patch_string_cst (node)
15359 if (! flag_emit_class_files)
15361 push_obstacks (&permanent_obstack, &permanent_obstack);
15362 node = get_identifier (TREE_STRING_POINTER (node));
15363 location = alloc_name_constant (CONSTANT_String, node);
15364 node = build_ref_from_constant_pool (location);
15367 TREE_TYPE (node) = string_ptr_type_node;
15368 TREE_CONSTANT (node) = 1;
15372 /* Build an incomplete unary operator expression. */
15375 build_unaryop (op_token, op_location, op1)
15376 int op_token, op_location;
15383 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15384 case MINUS_TK: op = NEGATE_EXPR; break;
15385 case NEG_TK: op = TRUTH_NOT_EXPR; break;
15386 case NOT_TK: op = BIT_NOT_EXPR; break;
15387 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15391 unaryop = build1 (op, NULL_TREE, op1);
15392 TREE_SIDE_EFFECTS (unaryop) = 1;
15393 /* Store the location of the operator, for better error report. The
15394 string of the operator will be rebuild based on the OP value. */
15395 EXPR_WFL_LINECOL (unaryop) = op_location;
15399 /* Special case for the ++/-- operators, since they require an extra
15400 argument to build, which is set to NULL and patched
15401 later. IS_POST_P is 1 if the operator, 0 otherwise. */
15404 build_incdec (op_token, op_location, op1, is_post_p)
15405 int op_token, op_location;
15409 static enum tree_code lookup [2][2] =
15411 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15412 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15414 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
15415 NULL_TREE, op1, NULL_TREE);
15416 TREE_SIDE_EFFECTS (node) = 1;
15417 /* Store the location of the operator, for better error report. The
15418 string of the operator will be rebuild based on the OP value. */
15419 EXPR_WFL_LINECOL (node) = op_location;
15423 /* Build an incomplete cast operator, based on the use of the
15424 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15425 set. java_complete_tree is trained to walk a CONVERT_EXPR even
15426 though its type is already set. */
15429 build_cast (location, type, exp)
15433 tree node = build1 (CONVERT_EXPR, type, exp);
15434 EXPR_WFL_LINECOL (node) = location;
15438 /* Build an incomplete class reference operator. */
15440 build_incomplete_class_ref (location, class_name)
15444 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15445 EXPR_WFL_LINECOL (node) = location;
15449 /* Complete an incomplete class reference operator. */
15451 patch_incomplete_class_ref (node)
15454 tree type = TREE_OPERAND (node, 0);
15457 if (!(ref_type = resolve_type_during_patch (type)))
15458 return error_mark_node;
15460 if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15461 return build_class_ref (ref_type);
15463 /* If we're emitting class files and we have to deal with non
15464 primitive types, we invoke (and consider generating) the
15465 synthetic static method `class$'. */
15466 if (!TYPE_DOT_CLASS (current_class))
15467 build_dot_class_method (current_class);
15469 build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15470 return java_complete_tree (ref_type);
15473 /* 15.14 Unary operators. We return error_mark_node in case of error,
15474 but preserve the type of NODE if the type is fixed. */
15477 patch_unaryop (node, wfl_op)
15481 tree op = TREE_OPERAND (node, 0);
15482 tree op_type = TREE_TYPE (op);
15483 tree prom_type = NULL_TREE, value, decl;
15484 int outer_field_flag = 0;
15485 int code = TREE_CODE (node);
15486 int error_found = 0;
15488 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15492 /* 15.13.2 Postfix Increment Operator ++ */
15493 case POSTINCREMENT_EXPR:
15494 /* 15.13.3 Postfix Increment Operator -- */
15495 case POSTDECREMENT_EXPR:
15496 /* 15.14.1 Prefix Increment Operator ++ */
15497 case PREINCREMENT_EXPR:
15498 /* 15.14.2 Prefix Decrement Operator -- */
15499 case PREDECREMENT_EXPR:
15500 op = decl = strip_out_static_field_access_decl (op);
15501 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15502 /* We might be trying to change an outer field accessed using
15504 if (outer_field_flag)
15506 /* Retrieve the decl of the field we're trying to access. We
15507 do that by first retrieving the function we would call to
15508 access the field. It has been already verified that this
15509 field isn't final */
15510 if (flag_emit_class_files)
15511 decl = TREE_OPERAND (op, 0);
15513 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15514 decl = DECL_FUNCTION_ACCESS_DECL (decl);
15516 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15517 else if (!JDECL_P (decl)
15518 && TREE_CODE (decl) != COMPONENT_REF
15519 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15520 && TREE_CODE (decl) != INDIRECT_REF
15521 && !(TREE_CODE (decl) == COMPOUND_EXPR
15522 && TREE_OPERAND (decl, 1)
15523 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15526 /* Before screaming, check that we're not in fact trying to
15527 increment a optimized static final access, in which case
15528 we issue an different error message. */
15529 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15530 && resolve_expression_name (wfl_op, &lvalue)
15531 && check_final_assignment (lvalue, wfl_op)))
15532 parse_error_context (wfl_operator, "Invalid argument to `%s'",
15533 operator_string (node));
15534 TREE_TYPE (node) = error_mark_node;
15538 if (check_final_assignment (op, wfl_op))
15541 /* From now on, we know that op if a variable and that it has a
15542 valid wfl. We use wfl_op to locate errors related to the
15544 else if (!JNUMERIC_TYPE_P (op_type))
15546 parse_error_context
15547 (wfl_op, "Invalid argument type `%s' to `%s'",
15548 lang_printable_name (op_type, 0), operator_string (node));
15549 TREE_TYPE (node) = error_mark_node;
15554 /* Before the addition, binary numeric promotion is performed on
15555 both operands, if really necessary */
15556 if (JINTEGRAL_TYPE_P (op_type))
15558 value = build_int_2 (1, 0);
15559 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15563 value = build_int_2 (1, 0);
15565 binary_numeric_promotion (op_type,
15566 TREE_TYPE (value), &op, &value);
15569 /* We remember we might be accessing an outer field */
15570 if (outer_field_flag)
15572 /* We re-generate an access to the field */
15573 value = build (PLUS_EXPR, TREE_TYPE (op),
15574 build_outer_field_access (wfl_op, decl), value);
15576 /* And we patch the original access$() into a write
15577 with plus_op as a rhs */
15578 return outer_field_access_fix (node, op, value);
15581 /* And write back into the node. */
15582 TREE_OPERAND (node, 0) = op;
15583 TREE_OPERAND (node, 1) = value;
15584 /* Convert the overall back into its original type, if
15585 necessary, and return */
15586 if (JINTEGRAL_TYPE_P (op_type))
15587 return fold (node);
15589 return fold (convert (op_type, node));
15593 /* 15.14.3 Unary Plus Operator + */
15594 case UNARY_PLUS_EXPR:
15595 /* 15.14.4 Unary Minus Operator - */
15597 if (!JNUMERIC_TYPE_P (op_type))
15599 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15600 TREE_TYPE (node) = error_mark_node;
15603 /* Unary numeric promotion is performed on operand */
15606 op = do_unary_numeric_promotion (op);
15607 prom_type = TREE_TYPE (op);
15608 if (code == UNARY_PLUS_EXPR)
15613 /* 15.14.5 Bitwise Complement Operator ~ */
15615 if (!JINTEGRAL_TYPE_P (op_type))
15617 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15618 TREE_TYPE (node) = error_mark_node;
15623 op = do_unary_numeric_promotion (op);
15624 prom_type = TREE_TYPE (op);
15628 /* 15.14.6 Logical Complement Operator ! */
15629 case TRUTH_NOT_EXPR:
15630 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15632 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15633 /* But the type is known. We will report an error if further
15634 attempt of a assignment is made with this rhs */
15635 TREE_TYPE (node) = boolean_type_node;
15639 prom_type = boolean_type_node;
15642 /* 15.15 Cast Expression */
15644 value = patch_cast (node, wfl_operator);
15645 if (value == error_mark_node)
15647 /* If this cast is part of an assignment, we tell the code
15648 that deals with it not to complain about a mismatch,
15649 because things have been cast, anyways */
15650 TREE_TYPE (node) = error_mark_node;
15655 value = fold (value);
15656 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15663 return error_mark_node;
15665 /* There are cases where node has been replaced by something else
15666 and we don't end up returning here: UNARY_PLUS_EXPR,
15667 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15668 TREE_OPERAND (node, 0) = fold (op);
15669 TREE_TYPE (node) = prom_type;
15670 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15671 return fold (node);
15674 /* Generic type resolution that sometimes takes place during node
15675 patching. Returned the resolved type or generate an error
15676 message. Return the resolved type or NULL_TREE. */
15679 resolve_type_during_patch (type)
15682 if (unresolved_type_p (type, NULL))
15684 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15687 parse_error_context (type,
15688 "Class `%s' not found in type declaration",
15689 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15694 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15695 return TREE_TYPE (type_decl);
15700 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15701 found. Otherwise NODE or something meant to replace it is returned. */
15704 patch_cast (node, wfl_operator)
15708 tree op = TREE_OPERAND (node, 0);
15709 tree op_type = TREE_TYPE (op);
15710 tree cast_type = TREE_TYPE (node);
15713 /* First resolve OP_TYPE if unresolved */
15714 if (!(cast_type = resolve_type_during_patch (cast_type)))
15715 return error_mark_node;
15717 /* Check on cast that are proven correct at compile time */
15718 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15721 if (cast_type == op_type)
15724 /* float and double type are converted to the original type main
15725 variant and then to the target type. */
15726 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15727 op = convert (integer_type_node, op);
15729 /* Try widening/narowwing convertion. Potentially, things need
15730 to be worked out in gcc so we implement the extreme cases
15731 correctly. fold_convert() needs to be fixed. */
15732 return convert (cast_type, op);
15735 /* It's also valid to cast a boolean into a boolean */
15736 if (op_type == boolean_type_node && cast_type == boolean_type_node)
15739 /* null can be casted to references */
15740 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15741 return build_null_of_type (cast_type);
15743 /* The remaining legal casts involve conversion between reference
15744 types. Check for their compile time correctness. */
15745 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
15746 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15748 TREE_TYPE (node) = promote_type (cast_type);
15749 /* Now, the case can be determined correct at compile time if
15750 OP_TYPE can be converted into CAST_TYPE by assignment
15751 conversion (5.2) */
15753 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15755 TREE_SET_CODE (node, NOP_EXPR);
15759 if (flag_emit_class_files)
15761 TREE_SET_CODE (node, CONVERT_EXPR);
15765 /* The cast requires a run-time check */
15766 return build (CALL_EXPR, promote_type (cast_type),
15767 build_address_of (soft_checkcast_node),
15768 tree_cons (NULL_TREE, build_class_ref (cast_type),
15769 build_tree_list (NULL_TREE, op)),
15773 /* Any other casts are proven incorrect at compile time */
15774 t1 = xstrdup (lang_printable_name (op_type, 0));
15775 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15776 t1, lang_printable_name (cast_type, 0));
15778 return error_mark_node;
15781 /* Build a null constant and give it the type TYPE. */
15784 build_null_of_type (type)
15787 tree node = build_int_2 (0, 0);
15788 TREE_TYPE (node) = promote_type (type);
15792 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15793 a list of indices. */
15795 build_array_ref (location, array, index)
15799 tree node = build (ARRAY_REF, NULL_TREE, array, index);
15800 EXPR_WFL_LINECOL (node) = location;
15804 /* 15.12 Array Access Expression */
15807 patch_array_ref (node)
15810 tree array = TREE_OPERAND (node, 0);
15811 tree array_type = TREE_TYPE (array);
15812 tree index = TREE_OPERAND (node, 1);
15813 tree index_type = TREE_TYPE (index);
15814 int error_found = 0;
15816 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15818 if (TREE_CODE (array_type) == POINTER_TYPE)
15819 array_type = TREE_TYPE (array_type);
15821 /* The array reference must be an array */
15822 if (!TYPE_ARRAY_P (array_type))
15824 parse_error_context
15826 "`[]' can only be applied to arrays. It can't be applied to `%s'",
15827 lang_printable_name (array_type, 0));
15828 TREE_TYPE (node) = error_mark_node;
15832 /* The array index undergoes unary numeric promotion. The promoted
15833 type must be int */
15834 index = do_unary_numeric_promotion (index);
15835 if (TREE_TYPE (index) != int_type_node)
15837 if (valid_cast_to_p (index_type, int_type_node))
15838 parse_error_context (wfl_operator,
15839 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15840 lang_printable_name (index_type, 0));
15842 parse_error_context (wfl_operator,
15843 "Incompatible type for `[]'. Can't convert `%s' to `int'",
15844 lang_printable_name (index_type, 0));
15845 TREE_TYPE (node) = error_mark_node;
15850 return error_mark_node;
15852 array_type = TYPE_ARRAY_ELEMENT (array_type);
15854 if (flag_emit_class_files || flag_emit_xref)
15856 TREE_OPERAND (node, 0) = array;
15857 TREE_OPERAND (node, 1) = index;
15861 /* The save_expr is for correct evaluation order. It would be cleaner
15862 to use force_evaluation_order (see comment there), but that is
15863 difficult when we also have to deal with bounds checking. */
15864 if (TREE_SIDE_EFFECTS (index))
15865 array = save_expr (array);
15866 node = build_java_arrayaccess (array, array_type, index);
15867 if (TREE_SIDE_EFFECTS (index))
15868 node = build (COMPOUND_EXPR, array_type, array, node);
15870 TREE_TYPE (node) = array_type;
15874 /* 15.9 Array Creation Expressions */
15877 build_newarray_node (type, dims, extra_dims)
15883 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
15884 build_int_2 (extra_dims, 0));
15889 patch_newarray (node)
15892 tree type = TREE_OPERAND (node, 0);
15893 tree dims = TREE_OPERAND (node, 1);
15894 tree cdim, array_type;
15895 int error_found = 0;
15897 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
15899 /* Dimension types are verified. It's better for the types to be
15900 verified in order. */
15901 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
15904 tree dim = TREE_VALUE (cdim);
15906 /* Dim might have been saved during its evaluation */
15907 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
15909 /* The type of each specified dimension must be an integral type. */
15910 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
15913 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
15914 promoted type must be int. */
15917 dim = do_unary_numeric_promotion (dim);
15918 if (TREE_TYPE (dim) != int_type_node)
15922 /* Report errors on types here */
15925 parse_error_context
15926 (TREE_PURPOSE (cdim),
15927 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
15928 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
15929 "Explicit cast needed to" : "Can't"),
15930 lang_printable_name (TREE_TYPE (dim), 0));
15934 TREE_PURPOSE (cdim) = NULL_TREE;
15937 /* Resolve array base type if unresolved */
15938 if (!(type = resolve_type_during_patch (type)))
15943 /* We don't want further evaluation of this bogus array creation
15945 TREE_TYPE (node) = error_mark_node;
15946 return error_mark_node;
15949 /* Set array_type to the actual (promoted) array type of the result. */
15950 if (TREE_CODE (type) == RECORD_TYPE)
15951 type = build_pointer_type (type);
15952 while (--xdims >= 0)
15954 type = promote_type (build_java_array_type (type, -1));
15956 dims = nreverse (dims);
15958 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
15962 = build_java_array_type (type,
15963 TREE_CODE (cdim) == INTEGER_CST
15964 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
15966 array_type = promote_type (array_type);
15968 dims = nreverse (dims);
15970 /* The node is transformed into a function call. Things are done
15971 differently according to the number of dimensions. If the number
15972 of dimension is equal to 1, then the nature of the base type
15973 (primitive or not) matters. */
15975 return build_new_array (type, TREE_VALUE (dims));
15977 /* Can't reuse what's already written in expr.c because it uses the
15978 JVM stack representation. Provide a build_multianewarray. FIXME */
15979 return build (CALL_EXPR, array_type,
15980 build_address_of (soft_multianewarray_node),
15981 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
15982 tree_cons (NULL_TREE,
15983 build_int_2 (ndims, 0), dims )),
15987 /* 10.6 Array initializer. */
15989 /* Build a wfl for array element that don't have one, so we can
15990 pin-point errors. */
15993 maybe_build_array_element_wfl (node)
15996 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
15997 return build_expr_wfl (NULL_TREE, ctxp->filename,
15998 ctxp->elc.line, ctxp->elc.prev_col);
16003 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16004 identification of initialized arrays easier to detect during walk
16008 build_new_array_init (location, values)
16012 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16013 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16014 EXPR_WFL_LINECOL (to_return) = location;
16018 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16019 occurred. Otherwise return NODE after having set its type
16023 patch_new_array_init (type, node)
16026 int error_seen = 0;
16027 tree current, element_type;
16028 HOST_WIDE_INT length;
16029 int all_constant = 1;
16030 tree init = TREE_OPERAND (node, 0);
16032 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16034 parse_error_context (node,
16035 "Invalid array initializer for non-array type `%s'",
16036 lang_printable_name (type, 1));
16037 return error_mark_node;
16039 type = TREE_TYPE (type);
16040 element_type = TYPE_ARRAY_ELEMENT (type);
16042 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16044 for (length = 0, current = CONSTRUCTOR_ELTS (init);
16045 current; length++, current = TREE_CHAIN (current))
16047 tree elt = TREE_VALUE (current);
16048 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16050 error_seen |= array_constructor_check_entry (element_type, current);
16051 elt = TREE_VALUE (current);
16052 /* When compiling to native code, STRING_CST is converted to
16053 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16054 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16059 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16060 TREE_PURPOSE (current) = NULL_TREE;
16063 if (elt && TREE_VALUE (elt) == error_mark_node)
16068 return error_mark_node;
16070 /* Create a new type. We can't reuse the one we have here by
16071 patching its dimension because it originally is of dimension -1
16072 hence reused by gcc. This would prevent triangular arrays. */
16073 type = build_java_array_type (element_type, length);
16074 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16075 TREE_TYPE (node) = promote_type (type);
16076 TREE_CONSTANT (init) = all_constant;
16077 TREE_CONSTANT (node) = all_constant;
16081 /* Verify that one entry of the initializer element list can be
16082 assigned to the array base type. Report 1 if an error occurred, 0
16086 array_constructor_check_entry (type, entry)
16089 char *array_type_string = NULL; /* For error reports */
16090 tree value, type_value, new_value, wfl_value, patched;
16091 int error_seen = 0;
16093 new_value = NULL_TREE;
16094 wfl_value = TREE_VALUE (entry);
16096 push_obstacks (&permanent_obstack, &permanent_obstack);
16097 value = java_complete_tree (TREE_VALUE (entry));
16098 /* patch_string return error_mark_node if arg is error_mark_node */
16099 if ((patched = patch_string (value)))
16101 if (value == error_mark_node)
16104 type_value = TREE_TYPE (value);
16106 /* At anytime, try_builtin_assignconv can report a warning on
16107 constant overflow during narrowing. */
16108 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16109 new_value = try_builtin_assignconv (wfl_operator, type, value);
16110 if (!new_value && (new_value = try_reference_assignconv (type, value)))
16111 type_value = promote_type (type);
16114 /* Check and report errors */
16117 const char *msg = (!valid_cast_to_p (type_value, type) ?
16118 "Can't" : "Explicit cast needed to");
16119 if (!array_type_string)
16120 array_type_string = xstrdup (lang_printable_name (type, 1));
16121 parse_error_context
16122 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16123 msg, lang_printable_name (type_value, 1), array_type_string);
16129 new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
16130 TREE_VALUE (entry) = new_value;
16133 if (array_type_string)
16134 free (array_type_string);
16136 TREE_PURPOSE (entry) = NULL_TREE;
16141 build_this (location)
16144 tree node = build_wfl_node (this_identifier_node);
16145 TREE_SET_CODE (node, THIS_EXPR);
16146 EXPR_WFL_LINECOL (node) = location;
16150 /* 14.15 The return statement. It builds a modify expression that
16151 assigns the returned value to the RESULT_DECL that hold the value
16155 build_return (location, op)
16159 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16160 EXPR_WFL_LINECOL (node) = location;
16161 node = build_debugable_stmt (location, node);
16166 patch_return (node)
16169 tree return_exp = TREE_OPERAND (node, 0);
16170 tree meth = current_function_decl;
16171 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16172 int error_found = 0;
16174 TREE_TYPE (node) = error_mark_node;
16175 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16177 /* It's invalid to have a return value within a function that is
16178 declared with the keyword void or that is a constructor */
16179 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16182 /* It's invalid to use a return statement in a static block */
16183 if (DECL_CLINIT_P (current_function_decl))
16186 /* It's invalid to have a no return value within a function that
16187 isn't declared with the keyword `void' */
16188 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16191 if (in_instance_initializer)
16196 if (in_instance_initializer)
16197 parse_error_context (wfl_operator,
16198 "`return' inside instance initializer");
16200 else if (DECL_CLINIT_P (current_function_decl))
16201 parse_error_context (wfl_operator,
16202 "`return' inside static initializer");
16204 else if (!DECL_CONSTRUCTOR_P (meth))
16206 char *t = xstrdup (lang_printable_name (mtype, 0));
16207 parse_error_context (wfl_operator,
16208 "`return' with%s value from `%s %s'",
16209 (error_found == 1 ? "" : "out"),
16210 t, lang_printable_name (meth, 0));
16214 parse_error_context (wfl_operator,
16215 "`return' with value from constructor `%s'",
16216 lang_printable_name (meth, 0));
16217 return error_mark_node;
16220 /* If we have a return_exp, build a modify expression and expand
16221 it. Note: at that point, the assignment is declared valid, but we
16222 may want to carry some more hacks */
16225 tree exp = java_complete_tree (return_exp);
16226 tree modify, patched;
16228 /* If the function returned value and EXP are booleans, EXP has
16229 to be converted into the type of DECL_RESULT, which is integer
16230 (see complete_start_java_method) */
16231 if (TREE_TYPE (exp) == boolean_type_node &&
16232 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16233 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16235 /* `null' can be assigned to a function returning a reference */
16236 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16237 exp == null_pointer_node)
16238 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16240 if ((patched = patch_string (exp)))
16243 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16244 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16245 modify = java_complete_tree (modify);
16247 if (modify != error_mark_node)
16249 TREE_SIDE_EFFECTS (modify) = 1;
16250 TREE_OPERAND (node, 0) = modify;
16253 return error_mark_node;
16255 TREE_TYPE (node) = void_type_node;
16256 TREE_SIDE_EFFECTS (node) = 1;
16260 /* 14.8 The if Statement */
16263 build_if_else_statement (location, expression, if_body, else_body)
16265 tree expression, if_body, else_body;
16269 else_body = empty_stmt_node;
16270 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16271 EXPR_WFL_LINECOL (node) = location;
16272 node = build_debugable_stmt (location, node);
16277 patch_if_else_statement (node)
16280 tree expression = TREE_OPERAND (node, 0);
16282 TREE_TYPE (node) = error_mark_node;
16283 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16285 /* The type of expression must be boolean */
16286 if (TREE_TYPE (expression) != boolean_type_node
16287 && TREE_TYPE (expression) != promoted_boolean_type_node)
16289 parse_error_context
16291 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
16292 lang_printable_name (TREE_TYPE (expression), 0));
16293 return error_mark_node;
16296 TREE_TYPE (node) = void_type_node;
16297 TREE_SIDE_EFFECTS (node) = 1;
16298 CAN_COMPLETE_NORMALLY (node)
16299 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16300 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16304 /* 14.6 Labeled Statements */
16306 /* Action taken when a lableled statement is parsed. a new
16307 LABELED_BLOCK_EXPR is created. No statement is attached to the
16308 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
16311 build_labeled_block (location, label)
16316 tree label_decl, node;
16317 if (label == NULL_TREE || label == continue_identifier_node)
16318 label_name = label;
16321 label_name = merge_qualified_name (label_id, label);
16322 /* Issue an error if we try to reuse a label that was previously
16324 if (IDENTIFIER_LOCAL_VALUE (label_name))
16326 EXPR_WFL_LINECOL (wfl_operator) = location;
16327 parse_error_context (wfl_operator,
16328 "Declaration of `%s' shadows a previous label declaration",
16329 IDENTIFIER_POINTER (label));
16330 EXPR_WFL_LINECOL (wfl_operator) =
16331 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16332 parse_error_context (wfl_operator,
16333 "This is the location of the previous declaration of label `%s'",
16334 IDENTIFIER_POINTER (label));
16335 java_error_count--;
16339 label_decl = create_label_decl (label_name);
16340 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16341 EXPR_WFL_LINECOL (node) = location;
16342 TREE_SIDE_EFFECTS (node) = 1;
16346 /* A labeled statement LBE is attached a statement. */
16349 finish_labeled_statement (lbe, statement)
16350 tree lbe; /* Labeled block expr */
16353 /* In anyways, tie the loop to its statement */
16354 LABELED_BLOCK_BODY (lbe) = statement;
16355 pop_labeled_block ();
16356 POP_LABELED_BLOCK ();
16360 /* 14.10, 14.11, 14.12 Loop Statements */
16362 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16366 build_new_loop (loop_body)
16369 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
16370 TREE_SIDE_EFFECTS (loop) = 1;
16375 /* Create a loop body according to the following structure:
16377 COMPOUND_EXPR (loop main body)
16378 EXIT_EXPR (this order is for while/for loops.
16379 LABELED_BLOCK_EXPR the order is reversed for do loops)
16380 LABEL_DECL (a continue occuring here branches at the
16381 BODY end of this labeled block)
16384 REVERSED, if non zero, tells that the loop condition expr comes
16385 after the body, like in the do-while loop.
16387 To obtain a loop, the loop body structure described above is
16388 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16391 LABEL_DECL (use this label to exit the loop)
16393 <structure described above> */
16396 build_loop_body (location, condition, reversed)
16401 tree first, second, body;
16403 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16404 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16405 condition = build_debugable_stmt (location, condition);
16406 TREE_SIDE_EFFECTS (condition) = 1;
16408 body = build_labeled_block (0, continue_identifier_node);
16409 first = (reversed ? body : condition);
16410 second = (reversed ? condition : body);
16412 build (COMPOUND_EXPR, NULL_TREE,
16413 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16416 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16417 their order) on the current loop. Unlink the current loop from the
16421 finish_loop_body (location, condition, body, reversed)
16423 tree condition, body;
16426 tree to_return = ctxp->current_loop;
16427 tree loop_body = LOOP_EXPR_BODY (to_return);
16430 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16431 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16432 The real EXIT_EXPR is one operand further. */
16433 EXPR_WFL_LINECOL (cnode) = location;
16434 /* This one is for accurate error reports */
16435 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16436 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16438 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16443 /* Tailored version of finish_loop_body for FOR loops, when FOR
16444 loops feature the condition part */
16447 finish_for_loop (location, condition, update, body)
16449 tree condition, update, body;
16451 /* Put the condition and the loop body in place */
16452 tree loop = finish_loop_body (location, condition, body, 0);
16453 /* LOOP is the current loop which has been now popped of the loop
16454 stack. Install the update block */
16455 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16459 /* Try to find the loop a block might be related to. This comprises
16460 the case where the LOOP_EXPR is found as the second operand of a
16461 COMPOUND_EXPR, because the loop happens to have an initialization
16462 part, then expressed as the first operand of the COMPOUND_EXPR. If
16463 the search finds something, 1 is returned. Otherwise, 0 is
16464 returned. The search is assumed to start from a
16465 LABELED_BLOCK_EXPR's block. */
16468 search_loop (statement)
16471 if (TREE_CODE (statement) == LOOP_EXPR)
16474 if (TREE_CODE (statement) == BLOCK)
16475 statement = BLOCK_SUBBLOCKS (statement);
16479 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16480 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16481 statement = TREE_OPERAND (statement, 1);
16483 return (TREE_CODE (statement) == LOOP_EXPR
16484 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16487 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16488 returned otherwise. */
16491 labeled_block_contains_loop_p (block, loop)
16497 if (LABELED_BLOCK_BODY (block) == loop)
16500 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16506 /* If the loop isn't surrounded by a labeled statement, create one and
16507 insert LOOP as its body. */
16510 patch_loop_statement (loop)
16515 TREE_TYPE (loop) = void_type_node;
16516 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16519 loop_label = build_labeled_block (0, NULL_TREE);
16520 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16521 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16522 LABELED_BLOCK_BODY (loop_label) = loop;
16523 PUSH_LABELED_BLOCK (loop_label);
16527 /* 14.13, 14.14: break and continue Statements */
16529 /* Build a break or a continue statement. a null NAME indicates an
16530 unlabeled break/continue statement. */
16533 build_bc_statement (location, is_break, name)
16534 int location, is_break;
16537 tree break_continue, label_block_expr = NULL_TREE;
16541 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
16542 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16543 /* Null means that we don't have a target for this named
16544 break/continue. In this case, we make the target to be the
16545 label name, so that the error can be reported accuratly in
16546 patch_bc_statement. */
16547 label_block_expr = EXPR_WFL_NODE (name);
16549 /* Unlabeled break/continue will be handled during the
16550 break/continue patch operation */
16552 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16554 IS_BREAK_STMT_P (break_continue) = is_break;
16555 TREE_SIDE_EFFECTS (break_continue) = 1;
16556 EXPR_WFL_LINECOL (break_continue) = location;
16557 break_continue = build_debugable_stmt (location, break_continue);
16558 return break_continue;
16561 /* Verification of a break/continue statement. */
16564 patch_bc_statement (node)
16567 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16568 tree labeled_block = ctxp->current_labeled_block;
16569 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16571 /* Having an identifier here means that the target is unknown. */
16572 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16574 parse_error_context (wfl_operator, "No label definition found for `%s'",
16575 IDENTIFIER_POINTER (bc_label));
16576 return error_mark_node;
16578 if (! IS_BREAK_STMT_P (node))
16580 /* It's a continue statement. */
16581 for (;; labeled_block = TREE_CHAIN (labeled_block))
16583 if (labeled_block == NULL_TREE)
16585 if (bc_label == NULL_TREE)
16586 parse_error_context (wfl_operator,
16587 "`continue' must be in loop");
16589 parse_error_context
16590 (wfl_operator, "continue label `%s' does not name a loop",
16591 IDENTIFIER_POINTER (bc_label));
16592 return error_mark_node;
16594 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16595 == continue_identifier_node)
16596 && (bc_label == NULL_TREE
16597 || TREE_CHAIN (labeled_block) == bc_label))
16599 bc_label = labeled_block;
16604 else if (!bc_label)
16606 for (;; labeled_block = TREE_CHAIN (labeled_block))
16608 if (labeled_block == NULL_TREE)
16610 parse_error_context (wfl_operator,
16611 "`break' must be in loop or switch");
16612 return error_mark_node;
16614 target_stmt = LABELED_BLOCK_BODY (labeled_block);
16615 if (TREE_CODE (target_stmt) == SWITCH_EXPR
16616 || search_loop (target_stmt))
16618 bc_label = labeled_block;
16624 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16625 CAN_COMPLETE_NORMALLY (bc_label) = 1;
16627 /* Our break/continue don't return values. */
16628 TREE_TYPE (node) = void_type_node;
16629 /* Encapsulate the break within a compound statement so that it's
16630 expanded all the times by expand_expr (and not clobbered
16631 sometimes, like after a if statement) */
16632 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16633 TREE_SIDE_EFFECTS (node) = 1;
16637 /* Process the exit expression belonging to a loop. Its type must be
16641 patch_exit_expr (node)
16644 tree expression = TREE_OPERAND (node, 0);
16645 TREE_TYPE (node) = error_mark_node;
16646 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16648 /* The type of expression must be boolean */
16649 if (TREE_TYPE (expression) != boolean_type_node)
16651 parse_error_context
16653 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
16654 lang_printable_name (TREE_TYPE (expression), 0));
16655 return error_mark_node;
16657 /* Now we know things are allright, invert the condition, fold and
16659 TREE_OPERAND (node, 0) =
16660 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16662 if (! integer_zerop (TREE_OPERAND (node, 0))
16663 && ctxp->current_loop != NULL_TREE
16664 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16665 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16666 if (! integer_onep (TREE_OPERAND (node, 0)))
16667 CAN_COMPLETE_NORMALLY (node) = 1;
16670 TREE_TYPE (node) = void_type_node;
16674 /* 14.9 Switch statement */
16677 patch_switch_statement (node)
16680 tree se = TREE_OPERAND (node, 0), se_type;
16682 /* Complete the switch expression */
16683 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16684 se_type = TREE_TYPE (se);
16685 /* The type of the switch expression must be char, byte, short or
16687 if (!JINTEGRAL_TYPE_P (se_type))
16689 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16690 parse_error_context (wfl_operator,
16691 "Incompatible type for `switch'. Can't convert `%s' to `int'",
16692 lang_printable_name (se_type, 0));
16693 /* This is what java_complete_tree will check */
16694 TREE_OPERAND (node, 0) = error_mark_node;
16695 return error_mark_node;
16698 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16700 /* Ready to return */
16701 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16703 TREE_TYPE (node) = error_mark_node;
16704 return error_mark_node;
16706 TREE_TYPE (node) = void_type_node;
16707 TREE_SIDE_EFFECTS (node) = 1;
16708 CAN_COMPLETE_NORMALLY (node)
16709 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16710 || ! SWITCH_HAS_DEFAULT (node);
16714 /* 14.18 The try/catch statements */
16717 build_try_statement (location, try_block, catches)
16719 tree try_block, catches;
16721 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16722 EXPR_WFL_LINECOL (node) = location;
16727 build_try_finally_statement (location, try_block, finally)
16729 tree try_block, finally;
16731 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16732 EXPR_WFL_LINECOL (node) = location;
16737 patch_try_statement (node)
16740 int error_found = 0;
16741 tree try = TREE_OPERAND (node, 0);
16742 /* Exception handlers are considered in left to right order */
16743 tree catch = nreverse (TREE_OPERAND (node, 1));
16744 tree current, caught_type_list = NULL_TREE;
16746 /* Check catch clauses, if any. Every time we find an error, we try
16747 to process the next catch clause. We process the catch clause before
16748 the try block so that when processing the try block we can check thrown
16749 exceptions againts the caught type list. */
16750 for (current = catch; current; current = TREE_CHAIN (current))
16752 tree carg_decl, carg_type;
16753 tree sub_current, catch_block, catch_clause;
16756 /* At this point, the structure of the catch clause is
16757 CATCH_EXPR (catch node)
16758 BLOCK (with the decl of the parameter)
16760 MODIFY_EXPR (assignment of the catch parameter)
16761 BLOCK (catch clause block)
16763 catch_clause = TREE_OPERAND (current, 0);
16764 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16765 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16767 /* Catch clauses can't have more than one parameter declared,
16768 but it's already enforced by the grammar. Make sure that the
16769 only parameter of the clause statement in of class Throwable
16770 or a subclass of Throwable, but that was done earlier. The
16771 catch clause parameter type has also been resolved. */
16773 /* Just make sure that the catch clause parameter type inherits
16774 from java.lang.Throwable */
16775 if (!inherits_from_p (carg_type, throwable_type_node))
16777 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16778 parse_error_context (wfl_operator,
16779 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16780 lang_printable_name (carg_type, 0));
16785 /* Partial check for unreachable catch statement: The catch
16786 clause is reachable iff is no earlier catch block A in
16787 the try statement such that the type of the catch
16788 clause's parameter is the same as or a subclass of the
16789 type of A's parameter */
16791 for (sub_current = catch;
16792 sub_current != current; sub_current = TREE_CHAIN (sub_current))
16794 tree sub_catch_clause, decl;
16795 sub_catch_clause = TREE_OPERAND (sub_current, 0);
16796 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16798 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16800 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16801 parse_error_context
16803 "`catch' not reached because of the catch clause at line %d",
16804 EXPR_WFL_LINENO (sub_current));
16805 unreachable = error_found = 1;
16809 /* Complete the catch clause block */
16810 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16811 if (catch_block == error_mark_node)
16816 if (CAN_COMPLETE_NORMALLY (catch_block))
16817 CAN_COMPLETE_NORMALLY (node) = 1;
16818 TREE_OPERAND (current, 0) = catch_block;
16823 /* Things to do here: the exception must be thrown */
16825 /* Link this type to the caught type list */
16826 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16829 PUSH_EXCEPTIONS (caught_type_list);
16830 if ((try = java_complete_tree (try)) == error_mark_node)
16832 if (CAN_COMPLETE_NORMALLY (try))
16833 CAN_COMPLETE_NORMALLY (node) = 1;
16836 /* Verification ends here */
16838 return error_mark_node;
16840 TREE_OPERAND (node, 0) = try;
16841 TREE_OPERAND (node, 1) = catch;
16842 TREE_TYPE (node) = void_type_node;
16846 /* 14.17 The synchronized Statement */
16849 patch_synchronized_statement (node, wfl_op1)
16850 tree node, wfl_op1;
16852 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
16853 tree block = TREE_OPERAND (node, 1);
16855 tree enter, exit, expr_decl, assignment;
16857 if (expr == error_mark_node)
16859 block = java_complete_tree (block);
16863 /* The TYPE of expr must be a reference type */
16864 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
16866 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16867 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
16868 lang_printable_name (TREE_TYPE (expr), 0));
16869 return error_mark_node;
16872 if (flag_emit_xref)
16874 TREE_OPERAND (node, 0) = expr;
16875 TREE_OPERAND (node, 1) = java_complete_tree (block);
16876 CAN_COMPLETE_NORMALLY (node) = 1;
16880 /* Generate a try-finally for the synchronized statement, except
16881 that the handler that catches all throw exception calls
16882 _Jv_MonitorExit and then rethrow the exception.
16883 The synchronized statement is then implemented as:
16886 _Jv_MonitorEnter (expression)
16888 _Jv_MonitorExit (expression)
16892 e = _Jv_exception_info ();
16893 _Jv_MonitorExit (expression)
16897 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
16898 BUILD_MONITOR_ENTER (enter, expr_decl);
16899 BUILD_MONITOR_EXIT (exit, expr_decl);
16900 CAN_COMPLETE_NORMALLY (enter) = 1;
16901 CAN_COMPLETE_NORMALLY (exit) = 1;
16902 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
16903 TREE_SIDE_EFFECTS (assignment) = 1;
16904 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
16905 build (COMPOUND_EXPR, NULL_TREE,
16906 build (WITH_CLEANUP_EXPR, NULL_TREE,
16907 build (COMPOUND_EXPR, NULL_TREE,
16908 assignment, enter),
16911 node = build_expr_block (node, expr_decl);
16913 return java_complete_tree (node);
16916 /* 14.16 The throw Statement */
16919 patch_throw_statement (node, wfl_op1)
16920 tree node, wfl_op1;
16922 tree expr = TREE_OPERAND (node, 0);
16923 tree type = TREE_TYPE (expr);
16924 int unchecked_ok = 0, tryblock_throws_ok = 0;
16926 /* Thrown expression must be assignable to java.lang.Throwable */
16927 if (!try_reference_assignconv (throwable_type_node, expr))
16929 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16930 parse_error_context (wfl_operator,
16931 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
16932 lang_printable_name (type, 0));
16933 /* If the thrown expression was a reference, we further the
16934 compile-time check. */
16935 if (!JREFERENCE_TYPE_P (type))
16936 return error_mark_node;
16939 /* At least one of the following must be true */
16941 /* The type of the throw expression is a not checked exception,
16942 i.e. is a unchecked expression. */
16943 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
16945 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16946 /* An instance can't throw a checked excetion unless that exception
16947 is explicitely declared in the `throws' clause of each
16948 constructor. This doesn't apply to anonymous classes, since they
16949 don't have declared constructors. */
16951 && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
16954 for (current = TYPE_METHODS (current_class); current;
16955 current = TREE_CHAIN (current))
16956 if (DECL_CONSTRUCTOR_P (current)
16957 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
16959 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)",
16960 lang_printable_name (TREE_TYPE (expr), 0));
16961 return error_mark_node;
16965 /* Throw is contained in a try statement and at least one catch
16966 clause can receive the thrown expression or the current method is
16967 declared to throw such an exception. Or, the throw statement is
16968 contained in a method or constructor declaration and the type of
16969 the Expression is assignable to at least one type listed in the
16970 throws clause the declaration. */
16972 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
16973 if (!(unchecked_ok || tryblock_throws_ok))
16975 /* If there is a surrounding try block that has no matching
16976 clatch clause, report it first. A surrounding try block exits
16977 only if there is something after the list of checked
16978 exception thrown by the current function (if any). */
16979 if (IN_TRY_BLOCK_P ())
16980 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
16981 lang_printable_name (type, 0));
16982 /* If we have no surrounding try statement and the method doesn't have
16983 any throws, report it now. FIXME */
16985 /* We report that the exception can't be throw from a try block
16986 in all circumstances but when the `throw' is inside a static
16988 else if (!EXCEPTIONS_P (currently_caught_type_list)
16989 && !tryblock_throws_ok)
16991 if (DECL_CLINIT_P (current_function_decl))
16992 parse_error_context (wfl_operator,
16993 "Checked exception `%s' can't be thrown in initializer",
16994 lang_printable_name (type, 0));
16996 parse_error_context (wfl_operator,
16997 "Checked exception `%s' isn't thrown from a `try' block",
16998 lang_printable_name (type, 0));
17000 /* Otherwise, the current method doesn't have the appropriate
17001 throws declaration */
17003 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
17004 lang_printable_name (type, 0));
17005 return error_mark_node;
17008 if (! flag_emit_class_files && ! flag_emit_xref)
17009 BUILD_THROW (node, expr);
17011 /* If doing xrefs, keep the location where the `throw' was seen. */
17012 if (flag_emit_xref)
17013 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17017 /* Check that exception said to be thrown by method DECL can be
17018 effectively caught from where DECL is invoked. */
17021 check_thrown_exceptions (location, decl)
17026 /* For all the unchecked exceptions thrown by DECL */
17027 for (throws = DECL_FUNCTION_THROWS (decl); throws;
17028 throws = TREE_CHAIN (throws))
17029 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17032 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17033 if (DECL_NAME (decl) == get_identifier ("clone"))
17036 EXPR_WFL_LINECOL (wfl_operator) = location;
17037 if (DECL_FINIT_P (current_function_decl))
17038 parse_error_context
17039 (wfl_operator, "Exception `%s' can't be thrown in initializer",
17040 lang_printable_name (TREE_VALUE (throws), 0));
17043 parse_error_context
17044 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
17045 lang_printable_name (TREE_VALUE (throws), 0),
17046 (DECL_INIT_P (current_function_decl) ?
17047 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17048 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17053 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17054 try-catch blocks, OR is listed in the `throws' clause of the
17058 check_thrown_exceptions_do (exception)
17061 tree list = currently_caught_type_list;
17062 resolve_and_layout (exception, NULL_TREE);
17063 /* First, all the nested try-catch-finally at that stage. The
17064 last element contains `throws' clause exceptions, if any. */
17065 if (IS_UNCHECKED_EXCEPTION_P (exception))
17070 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17071 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17073 list = TREE_CHAIN (list);
17079 purge_unchecked_exceptions (mdecl)
17082 tree throws = DECL_FUNCTION_THROWS (mdecl);
17083 tree new = NULL_TREE;
17087 tree next = TREE_CHAIN (throws);
17088 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17090 TREE_CHAIN (throws) = new;
17095 /* List is inverted here, but it doesn't matter */
17096 DECL_FUNCTION_THROWS (mdecl) = new;
17099 /* 15.24 Conditional Operator ?: */
17102 patch_conditional_expr (node, wfl_cond, wfl_op1)
17103 tree node, wfl_cond, wfl_op1;
17105 tree cond = TREE_OPERAND (node, 0);
17106 tree op1 = TREE_OPERAND (node, 1);
17107 tree op2 = TREE_OPERAND (node, 2);
17108 tree resulting_type = NULL_TREE;
17109 tree t1, t2, patched;
17110 int error_found = 0;
17112 /* Operands of ?: might be StringBuffers crafted as a result of a
17113 string concatenation. Obtain a descent operand here. */
17114 if ((patched = patch_string (op1)))
17115 TREE_OPERAND (node, 1) = op1 = patched;
17116 if ((patched = patch_string (op2)))
17117 TREE_OPERAND (node, 2) = op2 = patched;
17119 t1 = TREE_TYPE (op1);
17120 t2 = TREE_TYPE (op2);
17122 /* The first expression must be a boolean */
17123 if (TREE_TYPE (cond) != boolean_type_node)
17125 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17126 parse_error_context (wfl_operator,
17127 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17128 lang_printable_name (TREE_TYPE (cond), 0));
17132 /* Second and third can be numeric, boolean (i.e. primitive),
17133 references or null. Anything else results in an error */
17134 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17135 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
17136 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17137 || (t1 == boolean_type_node && t2 == boolean_type_node)))
17140 /* Determine the type of the conditional expression. Same types are
17141 easy to deal with */
17143 resulting_type = t1;
17145 /* There are different rules for numeric types */
17146 else if (JNUMERIC_TYPE_P (t1))
17148 /* if byte/short found, the resulting type is short */
17149 if ((t1 == byte_type_node && t2 == short_type_node)
17150 || (t1 == short_type_node && t2 == byte_type_node))
17151 resulting_type = short_type_node;
17153 /* If t1 is a constant int and t2 is of type byte, short or char
17154 and t1's value fits in t2, then the resulting type is t2 */
17155 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17156 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17157 resulting_type = t2;
17159 /* If t2 is a constant int and t1 is of type byte, short or char
17160 and t2's value fits in t1, then the resulting type is t1 */
17161 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17162 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17163 resulting_type = t1;
17165 /* Otherwise, binary numeric promotion is applied and the
17166 resulting type is the promoted type of operand 1 and 2 */
17168 resulting_type = binary_numeric_promotion (t1, t2,
17169 &TREE_OPERAND (node, 1),
17170 &TREE_OPERAND (node, 2));
17173 /* Cases of a reference and a null type */
17174 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17175 resulting_type = t1;
17177 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17178 resulting_type = t2;
17180 /* Last case: different reference types. If a type can be converted
17181 into the other one by assignment conversion, the latter
17182 determines the type of the expression */
17183 else if ((resulting_type = try_reference_assignconv (t1, op2)))
17184 resulting_type = promote_type (t1);
17186 else if ((resulting_type = try_reference_assignconv (t2, op1)))
17187 resulting_type = promote_type (t2);
17189 /* If we don't have any resulting type, we're in trouble */
17190 if (!resulting_type)
17192 char *t = xstrdup (lang_printable_name (t1, 0));
17193 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17194 parse_error_context (wfl_operator,
17195 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17196 t, lang_printable_name (t2, 0));
17203 TREE_TYPE (node) = error_mark_node;
17204 return error_mark_node;
17207 TREE_TYPE (node) = resulting_type;
17208 TREE_SET_CODE (node, COND_EXPR);
17209 CAN_COMPLETE_NORMALLY (node) = 1;
17213 /* Try to constant fold NODE.
17214 If NODE is not a constant expression, return NULL_EXPR.
17215 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17218 fold_constant_for_init (node, context)
17222 tree op0, op1, val;
17223 enum tree_code code = TREE_CODE (node);
17225 if (code == STRING_CST)
17228 if (code == INTEGER_CST || code == REAL_CST)
17229 return convert (TREE_TYPE (context), node);
17230 if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
17238 case TRUNC_MOD_EXPR:
17246 case TRUTH_ANDIF_EXPR:
17247 case TRUTH_ORIF_EXPR:
17254 op0 = TREE_OPERAND (node, 0);
17255 op1 = TREE_OPERAND (node, 1);
17256 val = fold_constant_for_init (op0, context);
17257 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17259 TREE_OPERAND (node, 0) = val;
17260 val = fold_constant_for_init (op1, context);
17261 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17263 TREE_OPERAND (node, 1) = val;
17264 return patch_binop (node, op0, op1);
17266 case UNARY_PLUS_EXPR:
17268 case TRUTH_NOT_EXPR:
17271 op0 = TREE_OPERAND (node, 0);
17272 val = fold_constant_for_init (op0, context);
17273 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17275 TREE_OPERAND (node, 0) = val;
17276 return patch_unaryop (node, op0);
17280 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17281 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17283 TREE_OPERAND (node, 0) = val;
17284 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17285 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17287 TREE_OPERAND (node, 1) = val;
17288 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17289 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17291 TREE_OPERAND (node, 2) = val;
17292 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17293 : TREE_OPERAND (node, 2);
17297 if (! FIELD_FINAL (node)
17298 || DECL_INITIAL (node) == NULL_TREE)
17300 val = DECL_INITIAL (node);
17301 /* Guard against infinite recursion. */
17302 DECL_INITIAL (node) = NULL_TREE;
17303 val = fold_constant_for_init (val, node);
17304 DECL_INITIAL (node) = val;
17307 case EXPR_WITH_FILE_LOCATION:
17308 /* Compare java_complete_tree and resolve_expression_name. */
17309 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17310 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17312 tree name = EXPR_WFL_NODE (node);
17314 if (PRIMARY_P (node))
17316 else if (! QUALIFIED_P (name))
17318 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17319 if (decl == NULL_TREE
17320 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17322 return fold_constant_for_init (decl, decl);
17326 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
17327 qualify_ambiguous_name (node);
17328 if (resolve_field_access (node, &decl, NULL)
17329 && decl != NULL_TREE)
17330 return fold_constant_for_init (decl, decl);
17336 op0 = TREE_OPERAND (node, 0);
17337 val = fold_constant_for_init (op0, context);
17338 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17340 TREE_OPERAND (node, 0) = val;
17344 #ifdef USE_COMPONENT_REF
17346 case COMPONENT_REF:
17355 #ifdef USE_COMPONENT_REF
17356 /* Context is 'T' for TypeName, 'P' for PackageName,
17357 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17360 resolve_simple_name (name, context)
17367 resolve_qualified_name (name, context)