1 /* A Bison parser, made from /home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y
2 by GNU bison 1.35. */
3
4 #define YYBISON 1 /* Identify Bison output. */
5
6 #define yyparse java_parse
7 #define yylex java_lex
8 #define yyerror java_error
9 #define yylval java_lval
10 #define yychar java_char
11 #define yydebug java_debug
12 #define yynerrs java_nerrs
13 # define PLUS_TK 257
14 # define MINUS_TK 258
15 # define MULT_TK 259
16 # define DIV_TK 260
17 # define REM_TK 261
18 # define LS_TK 262
19 # define SRS_TK 263
20 # define ZRS_TK 264
21 # define AND_TK 265
22 # define XOR_TK 266
23 # define OR_TK 267
24 # define BOOL_AND_TK 268
25 # define BOOL_OR_TK 269
26 # define EQ_TK 270
27 # define NEQ_TK 271
28 # define GT_TK 272
29 # define GTE_TK 273
30 # define LT_TK 274
31 # define LTE_TK 275
32 # define PLUS_ASSIGN_TK 276
33 # define MINUS_ASSIGN_TK 277
34 # define MULT_ASSIGN_TK 278
35 # define DIV_ASSIGN_TK 279
36 # define REM_ASSIGN_TK 280
37 # define LS_ASSIGN_TK 281
38 # define SRS_ASSIGN_TK 282
39 # define ZRS_ASSIGN_TK 283
40 # define AND_ASSIGN_TK 284
41 # define XOR_ASSIGN_TK 285
42 # define OR_ASSIGN_TK 286
43 # define PUBLIC_TK 287
44 # define PRIVATE_TK 288
45 # define PROTECTED_TK 289
46 # define STATIC_TK 290
47 # define FINAL_TK 291
48 # define SYNCHRONIZED_TK 292
49 # define VOLATILE_TK 293
50 # define TRANSIENT_TK 294
51 # define NATIVE_TK 295
52 # define PAD_TK 296
53 # define ABSTRACT_TK 297
54 # define STRICT_TK 298
55 # define MODIFIER_TK 299
56 # define DECR_TK 300
57 # define INCR_TK 301
58 # define DEFAULT_TK 302
59 # define IF_TK 303
60 # define THROW_TK 304
61 # define BOOLEAN_TK 305
62 # define DO_TK 306
63 # define IMPLEMENTS_TK 307
64 # define THROWS_TK 308
65 # define BREAK_TK 309
66 # define IMPORT_TK 310
67 # define ELSE_TK 311
68 # define INSTANCEOF_TK 312
69 # define RETURN_TK 313
70 # define VOID_TK 314
71 # define CATCH_TK 315
72 # define INTERFACE_TK 316
73 # define CASE_TK 317
74 # define EXTENDS_TK 318
75 # define FINALLY_TK 319
76 # define SUPER_TK 320
77 # define WHILE_TK 321
78 # define CLASS_TK 322
79 # define SWITCH_TK 323
80 # define CONST_TK 324
81 # define TRY_TK 325
82 # define FOR_TK 326
83 # define NEW_TK 327
84 # define CONTINUE_TK 328
85 # define GOTO_TK 329
86 # define PACKAGE_TK 330
87 # define THIS_TK 331
88 # define ASSERT_TK 332
89 # define BYTE_TK 333
90 # define SHORT_TK 334
91 # define INT_TK 335
92 # define LONG_TK 336
93 # define CHAR_TK 337
94 # define INTEGRAL_TK 338
95 # define FLOAT_TK 339
96 # define DOUBLE_TK 340
97 # define FP_TK 341
98 # define ID_TK 342
99 # define REL_QM_TK 343
100 # define REL_CL_TK 344
101 # define NOT_TK 345
102 # define NEG_TK 346
103 # define ASSIGN_ANY_TK 347
104 # define ASSIGN_TK 348
105 # define OP_TK 349
106 # define CP_TK 350
107 # define OCB_TK 351
108 # define CCB_TK 352
109 # define OSB_TK 353
110 # define CSB_TK 354
111 # define SC_TK 355
112 # define C_TK 356
113 # define DOT_TK 357
114 # define STRING_LIT_TK 358
115 # define CHAR_LIT_TK 359
116 # define INT_LIT_TK 360
117 # define FP_LIT_TK 361
118 # define TRUE_TK 362
119 # define FALSE_TK 363
120 # define BOOL_LIT_TK 364
121 # define NULL_TK 365
122
123 #line 49 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
124
125 #include "config.h"
126 #include "system.h"
127 #include "coretypes.h"
128 #include "tm.h"
129 #include <dirent.h>
130 #include "tree.h"
131 #include "rtl.h"
132 #include "real.h"
133 #include "obstack.h"
134 #include "toplev.h"
135 #include "flags.h"
136 #include "java-tree.h"
137 #include "jcf.h"
138 #include "lex.h"
139 #include "parse.h"
140 #include "zipfile.h"
141 #include "convert.h"
142 #include "buffer.h"
143 #include "xref.h"
144 #include "function.h"
145 #include "except.h"
146 #include "ggc.h"
147 #include "debug.h"
148 #include "tree-inline.h"
149 #include "cgraph.h"
150
151 /* Local function prototypes */
152 static char *java_accstring_lookup (int);
153 static void classitf_redefinition_error (const char *,tree, tree, tree);
154 static void variable_redefinition_error (tree, tree, tree, int);
155 static tree create_class (int, tree, tree, tree);
156 static tree create_interface (int, tree, tree);
157 static void end_class_declaration (int);
158 static tree find_field (tree, tree);
159 static tree lookup_field_wrapper (tree, tree);
160 static int duplicate_declaration_error_p (tree, tree, tree);
161 static void register_fields (int, tree, tree);
162 static tree parser_qualified_classname (tree);
163 static int parser_check_super (tree, tree, tree);
164 static int parser_check_super_interface (tree, tree, tree);
165 static void check_modifiers_consistency (int);
166 static tree lookup_cl (tree);
167 static tree lookup_java_method2 (tree, tree, int);
168 static tree method_header (int, tree, tree, tree);
169 static void fix_method_argument_names (tree ,tree);
170 static tree method_declarator (tree, tree);
171 static void parse_warning_context (tree cl, const char *msg, ...)
172 ATTRIBUTE_PRINTF_2;
173 static void issue_warning_error_from_context (tree, const char *msg, va_list)
174 ATTRIBUTE_PRINTF (2, 0);
175 static void parse_ctor_invocation_error (void);
176 static tree parse_jdk1_1_error (const char *);
177 static void complete_class_report_errors (jdep *);
178 static int process_imports (void);
179 static void read_import_dir (tree);
180 static int find_in_imports_on_demand (tree, tree);
181 static void find_in_imports (tree, tree);
182 static void check_inner_class_access (tree, tree, tree);
183 static int check_pkg_class_access (tree, tree, bool);
184 static void register_package (tree);
185 static tree resolve_package (tree, tree *, tree *);
186 static tree resolve_class (tree, tree, tree, tree);
187 static void declare_local_variables (int, tree, tree);
188 static void dump_java_tree (enum tree_dump_index, tree);
189 static void source_start_java_method (tree);
190 static void source_end_java_method (void);
191 static tree find_name_in_single_imports (tree);
192 static void check_abstract_method_header (tree);
193 static tree lookup_java_interface_method2 (tree, tree);
194 static tree resolve_expression_name (tree, tree *);
195 static tree maybe_create_class_interface_decl (tree, tree, tree, tree);
196 static int check_class_interface_creation (int, int, tree, tree, tree, tree);
197 static tree patch_method_invocation (tree, tree, tree, int, int *, tree *);
198 static int breakdown_qualified (tree *, tree *, tree);
199 static int in_same_package (tree, tree);
200 static tree resolve_and_layout (tree, tree);
201 static tree qualify_and_find (tree, tree, tree);
202 static tree resolve_no_layout (tree, tree);
203 static int invocation_mode (tree, int);
204 static tree find_applicable_accessible_methods_list (int, tree, tree, tree);
205 static void search_applicable_methods_list (int, tree, tree, tree, tree *, tree *);
206 static tree find_most_specific_methods_list (tree);
207 static int argument_types_convertible (tree, tree);
208 static tree patch_invoke (tree, tree, tree);
209 static int maybe_use_access_method (int, tree *, tree *);
210 static tree lookup_method_invoke (int, tree, tree, tree, tree);
211 static tree register_incomplete_type (int, tree, tree, tree);
212 static tree check_inner_circular_reference (tree, tree);
213 static tree check_circular_reference (tree);
214 static tree obtain_incomplete_type (tree);
215 static tree java_complete_lhs (tree);
216 static tree java_complete_tree (tree);
217 static tree maybe_generate_pre_expand_clinit (tree);
218 static int analyze_clinit_body (tree, tree);
219 static int maybe_yank_clinit (tree);
220 static void java_complete_expand_method (tree);
221 static void java_expand_method_bodies (tree);
222 static int unresolved_type_p (tree, tree *);
223 static void create_jdep_list (struct parser_ctxt *);
224 static tree build_expr_block (tree, tree);
225 static tree enter_block (void);
226 static tree exit_block (void);
227 static tree lookup_name_in_blocks (tree);
228 static void maybe_absorb_scoping_blocks (void);
229 static tree build_method_invocation (tree, tree);
230 static tree build_new_invocation (tree, tree);
231 static tree build_assignment (int, int, tree, tree);
232 static tree build_binop (enum tree_code, int, tree, tree);
233 static tree patch_assignment (tree, tree);
234 static tree patch_binop (tree, tree, tree);
235 static tree build_unaryop (int, int, tree);
236 static tree build_incdec (int, int, tree, int);
237 static tree patch_unaryop (tree, tree);
238 static tree build_cast (int, tree, tree);
239 static tree build_null_of_type (tree);
240 static tree patch_cast (tree, tree);
241 static int valid_ref_assignconv_cast_p (tree, tree, int);
242 static int valid_builtin_assignconv_identity_widening_p (tree, tree);
243 static int valid_cast_to_p (tree, tree);
244 static int valid_method_invocation_conversion_p (tree, tree);
245 static tree try_builtin_assignconv (tree, tree, tree);
246 static tree try_reference_assignconv (tree, tree);
247 static tree build_unresolved_array_type (tree);
248 static int build_type_name_from_array_name (tree, tree *);
249 static tree build_array_from_name (tree, tree, tree, tree *);
250 static tree build_array_ref (int, tree, tree);
251 static tree patch_array_ref (tree);
252 static tree make_qualified_name (tree, tree, int);
253 static tree merge_qualified_name (tree, tree);
254 static tree make_qualified_primary (tree, tree, int);
255 static int resolve_qualified_expression_name (tree, tree *, tree *, tree *);
256 static void qualify_ambiguous_name (tree);
257 static tree resolve_field_access (tree, tree *, tree *);
258 static tree build_newarray_node (tree, tree, int);
259 static tree patch_newarray (tree);
260 static tree resolve_type_during_patch (tree);
261 static tree build_this (int);
262 static tree build_wfl_wrap (tree, int);
263 static tree build_return (int, tree);
264 static tree patch_return (tree);
265 static tree maybe_access_field (tree, tree, tree);
266 static int complete_function_arguments (tree);
267 static int check_for_static_method_reference (tree, tree, tree, tree, tree);
268 static int not_accessible_p (tree, tree, tree, int);
269 static void check_deprecation (tree, tree);
270 static int class_in_current_package (tree);
271 static tree build_if_else_statement (int, tree, tree, tree);
272 static tree patch_if_else_statement (tree);
273 static tree add_stmt_to_compound (tree, tree, tree);
274 static tree add_stmt_to_block (tree, tree, tree);
275 static tree patch_exit_expr (tree);
276 static tree build_labeled_block (int, tree);
277 static tree finish_labeled_statement (tree, tree);
278 static tree build_bc_statement (int, int, tree);
279 static tree patch_bc_statement (tree);
280 static tree patch_loop_statement (tree);
281 static tree build_new_loop (tree);
282 static tree build_loop_body (int, tree, int);
283 static tree finish_loop_body (int, tree, tree, int);
284 static tree build_debugable_stmt (int, tree);
285 static tree finish_for_loop (int, tree, tree, tree);
286 static tree patch_switch_statement (tree);
287 static tree string_constant_concatenation (tree, tree);
288 static tree build_string_concatenation (tree, tree);
289 static tree patch_string_cst (tree);
290 static tree patch_string (tree);
291 static tree encapsulate_with_try_catch (int, tree, tree, tree);
292 static tree build_assertion (int, tree, tree);
293 static tree build_try_statement (int, tree, tree);
294 static tree build_try_finally_statement (int, tree, tree);
295 static tree patch_try_statement (tree);
296 static tree patch_synchronized_statement (tree, tree);
297 static tree patch_throw_statement (tree, tree);
298 static void check_thrown_exceptions (int, tree, tree);
299 static int check_thrown_exceptions_do (tree);
300 static void purge_unchecked_exceptions (tree);
301 static bool ctors_unchecked_throws_clause_p (tree);
302 static void check_concrete_throws_clauses (tree, tree, tree, tree);
303 static void check_throws_clauses (tree, tree, tree);
304 static void finish_method_declaration (tree);
305 static tree build_super_invocation (tree);
306 static int verify_constructor_circularity (tree, tree);
307 static char *constructor_circularity_msg (tree, tree);
308 static tree build_this_super_qualified_invocation (int, tree, tree, int, int);
309 static const char *get_printable_method_name (tree);
310 static tree patch_conditional_expr (tree, tree, tree);
311 static tree generate_finit (tree);
312 static tree generate_instinit (tree);
313 static tree build_instinit_invocation (tree);
314 static void fix_constructors (tree);
315 static tree build_alias_initializer_parameter_list (int, tree, tree, int *);
316 static tree craft_constructor (tree, tree);
317 static int verify_constructor_super (tree);
318 static tree create_artificial_method (tree, int, tree, tree, tree);
319 static void start_artificial_method_body (tree);
320 static void end_artificial_method_body (tree);
321 static int check_method_redefinition (tree, tree);
322 static int check_method_types_complete (tree);
323 static bool hack_is_accessible_p (tree, tree);
324 static void java_check_regular_methods (tree);
325 static void check_interface_throws_clauses (tree, tree);
326 static void java_check_abstract_methods (tree);
327 static void unreachable_stmt_error (tree);
328 static int not_accessible_field_error (tree, tree);
329 static tree find_expr_with_wfl (tree);
330 static void missing_return_error (tree);
331 static tree build_new_array_init (int, tree);
332 static tree patch_new_array_init (tree, tree);
333 static tree maybe_build_array_element_wfl (tree);
334 static int array_constructor_check_entry (tree, tree);
335 static const char *purify_type_name (const char *);
336 static tree fold_constant_for_init (tree, tree);
337 static tree strip_out_static_field_access_decl (tree);
338 static jdeplist *reverse_jdep_list (struct parser_ctxt *);
339 static void static_ref_err (tree, tree, tree);
340 static void parser_add_interface (tree, tree, tree);
341 static void add_superinterfaces (tree, tree);
342 static tree jdep_resolve_class (jdep *);
343 static int note_possible_classname (const char *, int);
344 static void java_complete_expand_classes (void);
345 static void java_complete_expand_class (tree);
346 static void java_complete_expand_methods (tree);
347 static tree cut_identifier_in_qualified (tree);
348 static tree java_stabilize_reference (tree);
349 static tree do_unary_numeric_promotion (tree);
350 static char * operator_string (tree);
351 static tree do_merge_string_cste (tree, const char *, int, int);
352 static tree merge_string_cste (tree, tree, int);
353 static tree java_refold (tree);
354 static int java_decl_equiv (tree, tree);
355 static int binop_compound_p (enum tree_code);
356 static tree search_loop (tree);
357 static int labeled_block_contains_loop_p (tree, tree);
358 static int check_abstract_method_definitions (int, tree, tree);
359 static void java_check_abstract_method_definitions (tree);
360 static void java_debug_context_do (int);
361 static void java_parser_context_push_initialized_field (void);
362 static void java_parser_context_pop_initialized_field (void);
363 static tree reorder_static_initialized (tree);
364 static void java_parser_context_suspend (void);
365 static void java_parser_context_resume (void);
366 static int pop_current_osb (struct parser_ctxt *);
367
368 /* JDK 1.1 work. FIXME */
369
370 static tree maybe_make_nested_class_name (tree);
371 static int make_nested_class_name (tree);
372 static void set_nested_class_simple_name_value (tree, int);
373 static void link_nested_class_to_enclosing (void);
374 static tree resolve_inner_class (htab_t, tree, tree *, tree *, tree);
375 static tree find_as_inner_class (tree, tree, tree);
376 static tree find_as_inner_class_do (tree, tree);
377 static int check_inner_class_redefinition (tree, tree);
378
379 static tree build_thisn_assign (void);
380 static tree build_current_thisn (tree);
381 static tree build_access_to_thisn (tree, tree, int);
382 static tree maybe_build_thisn_access_method (tree);
383
384 static tree build_outer_field_access (tree, tree);
385 static tree build_outer_field_access_methods (tree);
386 static tree build_outer_field_access_expr (int, tree, tree,
387 tree, tree);
388 static tree build_outer_method_access_method (tree);
389 static tree build_new_access_id (void);
390 static tree build_outer_field_access_method (tree, tree, tree,
391 tree, tree);
392
393 static int outer_field_access_p (tree, tree);
394 static int outer_field_expanded_access_p (tree, tree *,
395 tree *, tree *);
396 static tree outer_field_access_fix (tree, tree, tree);
397 static tree build_incomplete_class_ref (int, tree);
398 static tree patch_incomplete_class_ref (tree);
399 static tree create_anonymous_class (int, tree);
400 static void patch_anonymous_class (tree, tree, tree);
401 static void add_inner_class_fields (tree, tree);
402
403 static tree build_dot_class_method (tree);
404 static tree build_dot_class_method_invocation (tree, tree);
405 static void create_new_parser_context (int);
406 static tree maybe_build_class_init_for_field (tree, tree);
407
408 static int attach_init_test_initialization_flags (void **, void *);
409 static int emit_test_initialization (void **, void *);
410
411 static char *string_convert_int_cst (tree);
412
413 /* Number of error found so far. */
414 int java_error_count;
415 /* Number of warning found so far. */
416 int java_warning_count;
417 /* Tell when not to fold, when doing xrefs */
418 int do_not_fold;
419 /* Cyclic inheritance report, as it can be set by layout_class */
420 const char *cyclic_inheritance_report;
421
422 /* The current parser context */
423 struct parser_ctxt *ctxp;
424
425 /* List of things that were analyzed for which code will be generated */
426 struct parser_ctxt *ctxp_for_generation = NULL;
427
428 /* binop_lookup maps token to tree_code. It is used where binary
429 operations are involved and required by the parser. RDIV_EXPR
430 covers both integral/floating point division. The code is changed
431 once the type of both operator is worked out. */
432
433 static const enum tree_code binop_lookup[19] =
434 {
435 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
436 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
437 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
438 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
439 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
440 };
441 #define BINOP_LOOKUP(VALUE) \
442 binop_lookup [((VALUE) - PLUS_TK) % ARRAY_SIZE (binop_lookup)]
443
444 /* This is the end index for binary operators that can also be used
445 in compound assignments. */
446 #define BINOP_COMPOUND_CANDIDATES 11
447
448 /* The "$L" identifier we use to create labels. */
449 static GTY(()) tree label_id;
450
451 /* The "StringBuffer" identifier used for the String `+' operator. */
452 static GTY(()) tree wfl_string_buffer;
453
454 /* The "append" identifier used for String `+' operator. */
455 static GTY(()) tree wfl_append;
456
457 /* The "toString" identifier used for String `+' operator. */
458 static GTY(()) tree wfl_to_string;
459
460 /* The "java.lang" import qualified name. */
461 static GTY(()) tree java_lang_id;
462
463 /* The generated `inst$' identifier used for generated enclosing
464 instance/field access functions. */
465 static GTY(()) tree inst_id;
466
467 /* Context and flag for static blocks */
468 static GTY(()) tree current_static_block;
469
470 /* The generated `write_parm_value$' identifier. */
471 static GTY(()) tree wpv_id;
472
473 /* The list of all packages we've seen so far */
474 static GTY(()) tree package_list;
475
476 /* Hold THIS for the scope of the current method decl. */
477 static GTY(()) tree current_this;
478
479 /* Hold a list of catch clauses list. The first element of this list is
480 the list of the catch clauses of the currently analyzed try block. */
481 static GTY(()) tree currently_caught_type_list;
482
483 /* This holds a linked list of all the case labels for the current
484 switch statement. It is only used when checking to see if there
485 are duplicate labels. FIXME: probably this should just be attached
486 to the switch itself; then it could be referenced via
487 `ctxp->current_loop'. */
488 static GTY(()) tree case_label_list;
489
490 /* Anonymous class counter. Will be reset to 1 every time a non
491 anonymous class gets created. */
492 static int anonymous_class_counter = 1;
493
494 static GTY(()) tree src_parse_roots[1];
495
496 /* All classes seen from source code */
497 #define gclass_list src_parse_roots[0]
498
499 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
500 line and point it out. */
501 /* Should point out the one that don't fit. ASCII/unicode, going
502 backward. FIXME */
503
504 #define check_modifiers(__message, __value, __mask) do { \
505 if ((__value) & ~(__mask)) \
506 { \
507 size_t i, remainder = (__value) & ~(__mask); \
508 for (i = 0; i < ARRAY_SIZE (ctxp->modifier_ctx); i++) \
509 if ((1 << i) & remainder) \
510 parse_error_context (ctxp->modifier_ctx [i], (__message), \
511 java_accstring_lookup (1 << i)); \
512 } \
513 } while (0)
514
515
516 #line 442 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
517 #ifndef YYSTYPE
518 typedef union {
519 tree node;
520 int sub_token;
521 struct {
522 int token;
523 int location;
524 } operator;
525 int value;
526 } yystype;
527 # define YYSTYPE yystype
528 # define YYSTYPE_IS_TRIVIAL 1
529 #endif
530 #line 452 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
531
532 #include "lex.c"
533 #ifndef YYDEBUG
534 # define YYDEBUG 1
535 #endif
536
537
538
539 #define YYFINAL 785
540 #define YYFLAG -32768
541 #define YYNTBASE 112
542
543 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
544 #define YYTRANSLATE(x) ((unsigned)(x) <= 365 ? yytranslate[x] : 275)
545
546 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
547 static const char yytranslate[] =
548 {
549 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
550 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
563 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
564 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
565 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
566 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
567 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
568 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
569 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
570 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
571 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
572 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
573 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
574 2, 2, 2, 2, 2, 2, 1, 3, 4, 5,
575 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
576 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
577 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
578 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
579 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
580 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
581 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
582 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
583 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
584 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
585 106, 107, 108, 109, 110, 111
586 };
587
588 #if YYDEBUG
589 static const short yyprhs[] =
590 {
591 0, 0, 2, 4, 6, 8, 10, 12, 14, 16,
592 18, 20, 22, 24, 26, 28, 30, 32, 34, 37,
593 40, 42, 44, 46, 50, 52, 53, 55, 57, 59,
594 62, 65, 68, 72, 74, 77, 79, 82, 86, 89,
595 93, 95, 97, 101, 104, 108, 114, 119, 125, 127,
596 129, 131, 133, 135, 138, 139, 147, 148, 155, 159,
597 162, 166, 171, 172, 175, 179, 182, 183, 186, 189,
598 191, 195, 199, 202, 206, 208, 211, 213, 215, 217,
599 219, 221, 223, 225, 227, 229, 233, 238, 240, 244,
600 248, 250, 254, 258, 263, 265, 269, 272, 276, 280,
601 282, 284, 285, 289, 292, 296, 300, 305, 310, 313,
602 317, 320, 324, 327, 331, 336, 340, 344, 348, 350,
603 354, 358, 361, 365, 368, 372, 374, 375, 378, 381,
604 383, 387, 391, 393, 395, 398, 400, 401, 405, 408,
605 412, 416, 421, 424, 428, 432, 437, 439, 444, 450,
606 458, 465, 467, 469, 470, 475, 476, 482, 483, 489,
607 490, 497, 501, 506, 509, 513, 516, 520, 523, 527,
608 529, 532, 534, 536, 538, 540, 542, 545, 548, 551,
609 555, 559, 564, 566, 570, 574, 577, 581, 583, 585,
610 587, 590, 592, 594, 596, 599, 602, 606, 608, 610,
611 612, 614, 616, 618, 620, 622, 624, 626, 628, 630,
612 632, 634, 636, 638, 640, 642, 644, 646, 648, 650,
613 652, 654, 657, 660, 663, 666, 669, 672, 675, 678,
614 682, 687, 692, 698, 703, 709, 716, 724, 731, 733,
615 735, 737, 739, 741, 743, 745, 751, 754, 758, 763,
616 771, 779, 780, 784, 789, 792, 796, 802, 805, 809,
617 813, 818, 820, 823, 826, 828, 831, 835, 838, 841,
618 845, 848, 853, 856, 859, 863, 868, 871, 873, 881,
619 889, 896, 900, 906, 911, 919, 926, 929, 932, 936,
620 939, 940, 942, 944, 947, 948, 950, 952, 956, 960,
621 963, 967, 970, 974, 977, 981, 984, 988, 991, 995,
622 998, 1002, 1006, 1009, 1013, 1019, 1023, 1026, 1030, 1036,
623 1042, 1045, 1050, 1054, 1056, 1060, 1064, 1069, 1072, 1074,
624 1077, 1080, 1085, 1088, 1092, 1097, 1100, 1103, 1105, 1107,
625 1109, 1111, 1115, 1117, 1119, 1121, 1123, 1125, 1129, 1133,
626 1137, 1141, 1145, 1149, 1153, 1157, 1161, 1167, 1172, 1174,
627 1179, 1185, 1191, 1198, 1202, 1206, 1211, 1217, 1220, 1224,
628 1225, 1233, 1234, 1241, 1245, 1249, 1251, 1255, 1259, 1263,
629 1267, 1272, 1277, 1282, 1287, 1291, 1295, 1297, 1300, 1304,
630 1308, 1311, 1314, 1318, 1322, 1326, 1330, 1333, 1337, 1342,
631 1348, 1355, 1361, 1368, 1373, 1378, 1383, 1388, 1392, 1397,
632 1401, 1406, 1408, 1410, 1412, 1414, 1417, 1420, 1422, 1424,
633 1427, 1429, 1432, 1434, 1437, 1440, 1443, 1446, 1449, 1452,
634 1454, 1457, 1460, 1462, 1465, 1468, 1474, 1479, 1484, 1490,
635 1495, 1498, 1504, 1509, 1515, 1517, 1521, 1525, 1529, 1533,
636 1537, 1541, 1543, 1547, 1551, 1555, 1559, 1561, 1565, 1569,
637 1573, 1577, 1581, 1585, 1587, 1591, 1595, 1599, 1603, 1607,
638 1611, 1615, 1619, 1623, 1627, 1629, 1633, 1637, 1641, 1645,
639 1647, 1651, 1655, 1657, 1661, 1665, 1667, 1671, 1675, 1677,
640 1681, 1685, 1687, 1691, 1695, 1697, 1703, 1708, 1712, 1718,
641 1720, 1722, 1726, 1730, 1732, 1734, 1736, 1738, 1740, 1742
642 };
643 static const short yyrhs[] =
644 {
645 125, 0, 106, 0, 107, 0, 110, 0, 105, 0,
646 104, 0, 111, 0, 115, 0, 116, 0, 84, 0,
647 87, 0, 51, 0, 117, 0, 120, 0, 121, 0,
648 117, 0, 117, 0, 115, 245, 0, 121, 245, 0,
649 122, 0, 123, 0, 124, 0, 121, 103, 124, 0,
650 88, 0, 0, 128, 0, 126, 0, 127, 0, 128,
651 126, 0, 128, 127, 0, 126, 127, 0, 128, 126,
652 127, 0, 129, 0, 126, 129, 0, 132, 0, 127,
653 132, 0, 76, 121, 101, 0, 76, 1, 0, 76,
654 121, 1, 0, 130, 0, 131, 0, 56, 121, 101,
655 0, 56, 1, 0, 56, 121, 1, 0, 56, 121,
656 103, 5, 101, 0, 56, 121, 103, 1, 0, 56,
657 121, 103, 5, 1, 0, 134, 0, 169, 0, 192,
658 0, 1, 0, 45, 0, 133, 45, 0, 0, 133,
659 68, 124, 137, 138, 135, 140, 0, 0, 68, 124,
660 137, 138, 136, 140, 0, 133, 68, 1, 0, 68,
661 1, 0, 68, 124, 1, 0, 133, 68, 124, 1,
662 0, 0, 64, 118, 0, 64, 118, 1, 0, 64,
663 1, 0, 0, 53, 139, 0, 53, 1, 0, 119,
664 0, 139, 102, 119, 0, 139, 102, 1, 0, 97,
665 98, 0, 97, 141, 98, 0, 142, 0, 141, 142,
666 0, 143, 0, 159, 0, 161, 0, 182, 0, 144,
667 0, 149, 0, 134, 0, 169, 0, 192, 0, 114,
668 145, 101, 0, 133, 114, 145, 101, 0, 146, 0,
669 145, 102, 146, 0, 145, 102, 1, 0, 147, 0,
670 147, 94, 148, 0, 147, 94, 1, 0, 147, 94,
671 148, 1, 0, 124, 0, 147, 99, 100, 0, 124,
672 1, 0, 147, 99, 1, 0, 147, 100, 1, 0,
673 273, 0, 180, 0, 0, 151, 150, 158, 0, 151,
674 1, 0, 114, 152, 156, 0, 60, 152, 156, 0,
675 133, 114, 152, 156, 0, 133, 60, 152, 156, 0,
676 114, 1, 0, 133, 114, 1, 0, 60, 1, 0,
677 133, 60, 1, 0, 133, 1, 0, 124, 95, 96,
678 0, 124, 95, 153, 96, 0, 152, 99, 100, 0,
679 124, 95, 1, 0, 152, 99, 1, 0, 154, 0,
680 153, 102, 154, 0, 153, 102, 1, 0, 114, 147,
681 0, 155, 114, 147, 0, 114, 1, 0, 155, 114,
682 1, 0, 133, 0, 0, 54, 157, 0, 54, 1,
683 0, 118, 0, 157, 102, 118, 0, 157, 102, 1,
684 0, 182, 0, 101, 0, 160, 182, 0, 133, 0,
685 0, 163, 162, 165, 0, 164, 156, 0, 133, 164,
686 156, 0, 122, 95, 96, 0, 122, 95, 153, 96,
687 0, 183, 166, 0, 183, 167, 166, 0, 183, 185,
688 166, 0, 183, 167, 185, 166, 0, 184, 0, 168,
689 95, 96, 101, 0, 168, 95, 241, 96, 101, 0,
690 121, 103, 66, 95, 241, 96, 101, 0, 121, 103,
691 66, 95, 96, 101, 0, 77, 0, 66, 0, 0,
692 62, 124, 170, 175, 0, 0, 133, 62, 124, 171,
693 175, 0, 0, 62, 124, 174, 172, 175, 0, 0,
694 133, 62, 124, 174, 173, 175, 0, 62, 124, 1,
695 0, 133, 62, 124, 1, 0, 64, 119, 0, 174,
696 102, 119, 0, 64, 1, 0, 174, 102, 1, 0,
697 97, 98, 0, 97, 176, 98, 0, 177, 0, 176,
698 177, 0, 178, 0, 179, 0, 134, 0, 169, 0,
699 144, 0, 151, 101, 0, 151, 1, 0, 97, 98,
700 0, 97, 102, 98, 0, 97, 181, 98, 0, 97,
701 181, 102, 98, 0, 148, 0, 181, 102, 148, 0,
702 181, 102, 1, 0, 183, 184, 0, 183, 185, 184,
703 0, 97, 0, 98, 0, 186, 0, 185, 186, 0,
704 187, 0, 189, 0, 134, 0, 188, 101, 0, 114,
705 145, 0, 155, 114, 145, 0, 191, 0, 194, 0,
706 198, 0, 199, 0, 210, 0, 214, 0, 191, 0,
707 195, 0, 200, 0, 211, 0, 215, 0, 182, 0,
708 192, 0, 196, 0, 201, 0, 213, 0, 221, 0,
709 222, 0, 223, 0, 226, 0, 224, 0, 228, 0,
710 225, 0, 101, 0, 124, 90, 0, 193, 189, 0,
711 124, 1, 0, 193, 190, 0, 197, 101, 0, 1,
712 101, 0, 1, 97, 0, 1, 98, 0, 168, 95,
713 1, 0, 168, 95, 96, 1, 0, 168, 95, 241,
714 1, 0, 168, 95, 241, 96, 1, 0, 121, 103,
715 66, 1, 0, 121, 103, 66, 95, 1, 0, 121,
716 103, 66, 95, 241, 1, 0, 121, 103, 66, 95,
717 241, 96, 1, 0, 121, 103, 66, 95, 96, 1,
718 0, 270, 0, 254, 0, 255, 0, 250, 0, 251,
719 0, 247, 0, 236, 0, 49, 95, 273, 96, 189,
720 0, 49, 1, 0, 49, 95, 1, 0, 49, 95,
721 273, 1, 0, 49, 95, 273, 96, 190, 57, 189,
722 0, 49, 95, 273, 96, 190, 57, 190, 0, 0,
723 203, 202, 204, 0, 69, 95, 273, 96, 0, 69,
724 1, 0, 69, 95, 1, 0, 69, 95, 273, 96,
725 1, 0, 97, 98, 0, 97, 207, 98, 0, 97,
726 205, 98, 0, 97, 205, 207, 98, 0, 206, 0,
727 205, 206, 0, 207, 185, 0, 208, 0, 207, 208,
728 0, 63, 274, 90, 0, 48, 90, 0, 63, 1,
729 0, 63, 274, 1, 0, 48, 1, 0, 67, 95,
730 273, 96, 0, 209, 189, 0, 67, 1, 0, 67,
731 95, 1, 0, 67, 95, 273, 1, 0, 209, 190,
732 0, 52, 0, 212, 189, 67, 95, 273, 96, 101,
733 0, 217, 101, 273, 101, 219, 96, 189, 0, 217,
734 101, 101, 219, 96, 189, 0, 217, 101, 1, 0,
735 217, 101, 273, 101, 1, 0, 217, 101, 101, 1,
736 0, 217, 101, 273, 101, 219, 96, 190, 0, 217,
737 101, 101, 219, 96, 190, 0, 72, 95, 0, 72,
738 1, 0, 72, 95, 1, 0, 216, 218, 0, 0,
739 220, 0, 188, 0, 220, 1, 0, 0, 220, 0,
740 197, 0, 220, 102, 197, 0, 220, 102, 1, 0,
741 55, 101, 0, 55, 124, 101, 0, 55, 1, 0,
742 55, 124, 1, 0, 74, 101, 0, 74, 124, 101,
743 0, 74, 1, 0, 74, 124, 1, 0, 59, 101,
744 0, 59, 273, 101, 0, 59, 1, 0, 59, 273,
745 1, 0, 50, 273, 101, 0, 50, 1, 0, 50,
746 273, 1, 0, 78, 273, 90, 273, 101, 0, 78,
747 273, 101, 0, 78, 1, 0, 78, 273, 1, 0,
748 227, 95, 273, 96, 182, 0, 227, 95, 273, 96,
749 1, 0, 227, 1, 0, 227, 95, 1, 96, 0,
750 227, 95, 1, 0, 133, 0, 71, 182, 229, 0,
751 71, 182, 232, 0, 71, 182, 229, 232, 0, 71,
752 1, 0, 230, 0, 229, 230, 0, 231, 182, 0,
753 61, 95, 154, 96, 0, 61, 1, 0, 61, 95,
754 1, 0, 61, 95, 1, 96, 0, 65, 182, 0,
755 65, 1, 0, 234, 0, 242, 0, 113, 0, 77,
756 0, 95, 273, 96, 0, 236, 0, 246, 0, 247,
757 0, 248, 0, 235, 0, 121, 103, 77, 0, 95,
758 273, 1, 0, 121, 103, 1, 0, 115, 103, 1,
759 0, 60, 103, 1, 0, 121, 103, 68, 0, 120,
760 103, 68, 0, 115, 103, 68, 0, 60, 103, 68,
761 0, 73, 118, 95, 241, 96, 0, 73, 118, 95,
762 96, 0, 237, 0, 240, 124, 95, 96, 0, 240,
763 124, 95, 96, 140, 0, 240, 124, 95, 241, 96,
764 0, 240, 124, 95, 241, 96, 140, 0, 73, 1,
765 101, 0, 73, 118, 1, 0, 73, 118, 95, 1,
766 0, 73, 118, 95, 241, 1, 0, 240, 1, 0,
767 240, 124, 1, 0, 0, 73, 118, 95, 241, 96,
768 238, 140, 0, 0, 73, 118, 95, 96, 239, 140,
769 0, 121, 103, 73, 0, 233, 103, 73, 0, 273,
770 0, 241, 102, 273, 0, 241, 102, 1, 0, 73,
771 115, 243, 0, 73, 117, 243, 0, 73, 115, 243,
772 245, 0, 73, 117, 243, 245, 0, 73, 117, 245,
773 180, 0, 73, 115, 245, 180, 0, 73, 1, 100,
774 0, 73, 1, 99, 0, 244, 0, 243, 244, 0,
775 99, 273, 100, 0, 99, 273, 1, 0, 99, 1,
776 0, 99, 100, 0, 245, 99, 100, 0, 245, 99,
777 1, 0, 233, 103, 124, 0, 66, 103, 124, 0,
778 66, 1, 0, 121, 95, 96, 0, 121, 95, 241,
779 96, 0, 233, 103, 124, 95, 96, 0, 233, 103,
780 124, 95, 241, 96, 0, 66, 103, 124, 95, 96,
781 0, 66, 103, 124, 95, 241, 96, 0, 66, 103,
782 1, 96, 0, 66, 103, 1, 103, 0, 121, 99,
783 273, 100, 0, 234, 99, 273, 100, 0, 121, 99,
784 1, 0, 121, 99, 273, 1, 0, 234, 99, 1,
785 0, 234, 99, 273, 1, 0, 233, 0, 121, 0,
786 250, 0, 251, 0, 249, 47, 0, 249, 46, 0,
787 254, 0, 255, 0, 3, 253, 0, 256, 0, 3,
788 1, 0, 252, 0, 4, 252, 0, 4, 1, 0,
789 47, 253, 0, 47, 1, 0, 46, 253, 0, 46,
790 1, 0, 249, 0, 91, 253, 0, 92, 253, 0,
791 257, 0, 91, 1, 0, 92, 1, 0, 95, 115,
792 245, 96, 253, 0, 95, 115, 96, 253, 0, 95,
793 273, 96, 256, 0, 95, 121, 245, 96, 256, 0,
794 95, 115, 99, 1, 0, 95, 1, 0, 95, 115,
795 245, 96, 1, 0, 95, 115, 96, 1, 0, 95,
796 121, 245, 96, 1, 0, 253, 0, 258, 5, 253,
797 0, 258, 6, 253, 0, 258, 7, 253, 0, 258,
798 5, 1, 0, 258, 6, 1, 0, 258, 7, 1,
799 0, 258, 0, 259, 3, 258, 0, 259, 4, 258,
800 0, 259, 3, 1, 0, 259, 4, 1, 0, 259,
801 0, 260, 8, 259, 0, 260, 9, 259, 0, 260,
802 10, 259, 0, 260, 8, 1, 0, 260, 9, 1,
803 0, 260, 10, 1, 0, 260, 0, 261, 20, 260,
804 0, 261, 18, 260, 0, 261, 21, 260, 0, 261,
805 19, 260, 0, 261, 58, 116, 0, 261, 20, 1,
806 0, 261, 18, 1, 0, 261, 21, 1, 0, 261,
807 19, 1, 0, 261, 58, 1, 0, 261, 0, 262,
808 16, 261, 0, 262, 17, 261, 0, 262, 16, 1,
809 0, 262, 17, 1, 0, 262, 0, 263, 11, 262,
810 0, 263, 11, 1, 0, 263, 0, 264, 12, 263,
811 0, 264, 12, 1, 0, 264, 0, 265, 13, 264,
812 0, 265, 13, 1, 0, 265, 0, 266, 14, 265,
813 0, 266, 14, 1, 0, 266, 0, 267, 15, 266,
814 0, 267, 15, 1, 0, 267, 0, 267, 89, 273,
815 90, 268, 0, 267, 89, 90, 1, 0, 267, 89,
816 1, 0, 267, 89, 273, 90, 1, 0, 268, 0,
817 270, 0, 271, 272, 269, 0, 271, 272, 1, 0,
818 121, 0, 246, 0, 248, 0, 93, 0, 94, 0,
819 269, 0, 273, 0
820 };
821
822 #endif
823
824 #if YYDEBUG
825 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
826 static const short yyrline[] =
827 {
828 0, 603, 608, 610, 611, 612, 613, 614, 618, 620,
829 623, 625, 626, 629, 631, 634, 638, 642, 646, 655,
830 666, 668, 671, 675, 680, 685, 687, 688, 689, 690,
831 691, 692, 693, 696, 701, 707, 709, 712, 718, 720,
832 724, 726, 729, 756, 758, 762, 781, 783, 787, 790,
833 792, 793, 803, 808, 823, 823, 828, 828, 832, 834,
834 836, 841, 845, 847, 849, 851, 855, 857, 859, 866,
835 872, 877, 881, 890, 900, 902, 905, 907, 908, 909,
836 919, 921, 922, 924, 926, 930, 933, 943, 946, 948,
837 952, 955, 962, 968, 976, 978, 980, 982, 987, 991,
838 993, 997, 997, 1009, 1013, 1016, 1018, 1020, 1022, 1027,
839 1032, 1037, 1042, 1049, 1055, 1057, 1066, 1068, 1072, 1077,
840 1082, 1086, 1091, 1096, 1101, 1108, 1118, 1120, 1122, 1126,
841 1129, 1131, 1135, 1137, 1141, 1150, 1166, 1166, 1176, 1179,
842 1183, 1189, 1193, 1202, 1204, 1206, 1210, 1215, 1222, 1230,
843 1232, 1236, 1243, 1253, 1253, 1258, 1258, 1262, 1262, 1266,
844 1266, 1270, 1272, 1276, 1282, 1287, 1289, 1293, 1296, 1300,
845 1302, 1305, 1307, 1308, 1310, 1314, 1318, 1324, 1329, 1332,
846 1334, 1336, 1340, 1346, 1350, 1355, 1358, 1362, 1367, 1381,
847 1383, 1386, 1388, 1390, 1397, 1401, 1404, 1408, 1410, 1411,
848 1412, 1413, 1414, 1418, 1420, 1421, 1422, 1423, 1427, 1429,
849 1430, 1431, 1432, 1433, 1434, 1435, 1436, 1437, 1438, 1439,
850 1442, 1460, 1471, 1474, 1478, 1485, 1495, 1500, 1505, 1510,
851 1512, 1517, 1519, 1524, 1526, 1528, 1530, 1532, 1536, 1538,
852 1539, 1540, 1541, 1542, 1543, 1546, 1552, 1554, 1556, 1560,
853 1565, 1570, 1570, 1586, 1592, 1594, 1596, 1603, 1606, 1608,
854 1610, 1614, 1616, 1619, 1623, 1625, 1628, 1635, 1641, 1643,
855 1645, 1649, 1657, 1660, 1662, 1664, 1668, 1673, 1682, 1687,
856 1694, 1701, 1703, 1705, 1709, 1712, 1721, 1728, 1730, 1734,
857 1747, 1749, 1755, 1761, 1765, 1767, 1771, 1774, 1776, 1780,
858 1783, 1785, 1787, 1791, 1794, 1796, 1798, 1802, 1805, 1807,
859 1809, 1813, 1819, 1821, 1825, 1830, 1834, 1836, 1840, 1847,
860 1849, 1851, 1853, 1857, 1869, 1872, 1874, 1879, 1883, 1885,
861 1892, 1901, 1927, 1929, 1934, 1938, 1941, 1946, 1948, 1951,
862 1953, 1955, 1957, 1958, 1959, 1960, 1961, 1965, 1970, 1972,
863 1974, 1976, 1980, 1983, 1985, 1987, 1994, 1997, 1999, 2003,
864 2009, 2010, 2016, 2017, 2019, 2021, 2023, 2025, 2027, 2036,
865 2036, 2070, 2070, 2087, 2090, 2094, 2100, 2105, 2109, 2112,
866 2114, 2116, 2120, 2131, 2140, 2142, 2146, 2149, 2153, 2164,
867 2166, 2174, 2201, 2203, 2207, 2212, 2218, 2222, 2225, 2227,
868 2238, 2249, 2254, 2263, 2265, 2269, 2272, 2274, 2279, 2284,
869 2289, 2296, 2298, 2299, 2300, 2303, 2308, 2313, 2315, 2316,
870 2318, 2319, 2323, 2329, 2331, 2335, 2338, 2342, 2345, 2349,
871 2351, 2353, 2355, 2356, 2358, 2362, 2371, 2373, 2375, 2389,
872 2391, 2396, 2398, 2400, 2404, 2406, 2411, 2416, 2421, 2423,
873 2425, 2429, 2431, 2436, 2441, 2443, 2447, 2449, 2454, 2459,
874 2464, 2466, 2468, 2472, 2474, 2479, 2484, 2489, 2494, 2496,
875 2498, 2500, 2502, 2504, 2508, 2510, 2515, 2520, 2522, 2526,
876 2528, 2533, 2537, 2539, 2544, 2548, 2550, 2555, 2559, 2561,
877 2566, 2570, 2572, 2577, 2581, 2583, 2588, 2594, 2596, 2600,
878 2602, 2605, 2608, 2615, 2617, 2618, 2621, 2623, 2626, 2630
879 };
880 #endif
881
882
883 #if (YYDEBUG) || defined YYERROR_VERBOSE
884
885 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
886 static const char *const yytname[] =
887 {
888 "$", "error", "$undefined.", "PLUS_TK", "MINUS_TK", "MULT_TK", "DIV_TK",
889 "REM_TK", "LS_TK", "SRS_TK", "ZRS_TK", "AND_TK", "XOR_TK", "OR_TK",
890 "BOOL_AND_TK", "BOOL_OR_TK", "EQ_TK", "NEQ_TK", "GT_TK", "GTE_TK",
891 "LT_TK", "LTE_TK", "PLUS_ASSIGN_TK", "MINUS_ASSIGN_TK",
892 "MULT_ASSIGN_TK", "DIV_ASSIGN_TK", "REM_ASSIGN_TK", "LS_ASSIGN_TK",
893 "SRS_ASSIGN_TK", "ZRS_ASSIGN_TK", "AND_ASSIGN_TK", "XOR_ASSIGN_TK",
894 "OR_ASSIGN_TK", "PUBLIC_TK", "PRIVATE_TK", "PROTECTED_TK", "STATIC_TK",
895 "FINAL_TK", "SYNCHRONIZED_TK", "VOLATILE_TK", "TRANSIENT_TK",
896 "NATIVE_TK", "PAD_TK", "ABSTRACT_TK", "STRICT_TK", "MODIFIER_TK",
897 "DECR_TK", "INCR_TK", "DEFAULT_TK", "IF_TK", "THROW_TK", "BOOLEAN_TK",
898 "DO_TK", "IMPLEMENTS_TK", "THROWS_TK", "BREAK_TK", "IMPORT_TK",
899 "ELSE_TK", "INSTANCEOF_TK", "RETURN_TK", "VOID_TK", "CATCH_TK",
900 "INTERFACE_TK", "CASE_TK", "EXTENDS_TK", "FINALLY_TK", "SUPER_TK",
901 "WHILE_TK", "CLASS_TK", "SWITCH_TK", "CONST_TK", "TRY_TK", "FOR_TK",
902 "NEW_TK", "CONTINUE_TK", "GOTO_TK", "PACKAGE_TK", "THIS_TK",
903 "ASSERT_TK", "BYTE_TK", "SHORT_TK", "INT_TK", "LONG_TK", "CHAR_TK",
904 "INTEGRAL_TK", "FLOAT_TK", "DOUBLE_TK", "FP_TK", "ID_TK", "REL_QM_TK",
905 "REL_CL_TK", "NOT_TK", "NEG_TK", "ASSIGN_ANY_TK", "ASSIGN_TK", "OP_TK",
906 "CP_TK", "OCB_TK", "CCB_TK", "OSB_TK", "CSB_TK", "SC_TK", "C_TK",
907 "DOT_TK", "STRING_LIT_TK", "CHAR_LIT_TK", "INT_LIT_TK", "FP_LIT_TK",
908 "TRUE_TK", "FALSE_TK", "BOOL_LIT_TK", "NULL_TK", "goal", "literal",
909 "type", "primitive_type", "reference_type", "class_or_interface_type",
910 "class_type", "interface_type", "array_type", "name", "simple_name",
911 "qualified_name", "identifier", "compilation_unit",
912 "import_declarations", "type_declarations", "package_declaration",
913 "import_declaration", "single_type_import_declaration",
914 "type_import_on_demand_declaration", "type_declaration", "modifiers",
915 "class_declaration", "@1", "@2", "super", "interfaces",
916 "interface_type_list", "class_body", "class_body_declarations",
917 "class_body_declaration", "class_member_declaration",
918 "field_declaration", "variable_declarators", "variable_declarator",
919 "variable_declarator_id", "variable_initializer", "method_declaration",
920 "@3", "method_header", "method_declarator", "formal_parameter_list",
921 "formal_parameter", "final", "throws", "class_type_list", "method_body",
922 "static_initializer", "static", "constructor_declaration", "@4",
923 "constructor_header", "constructor_declarator", "constructor_body",
924 "constructor_block_end", "explicit_constructor_invocation",
925 "this_or_super", "interface_declaration", "@5", "@6", "@7", "@8",
926 "extends_interfaces", "interface_body", "interface_member_declarations",
927 "interface_member_declaration", "constant_declaration",
928 "abstract_method_declaration", "array_initializer",
929 "variable_initializers", "block", "block_begin", "block_end",
930 "block_statements", "block_statement",
931 "local_variable_declaration_statement", "local_variable_declaration",
932 "statement", "statement_nsi", "statement_without_trailing_substatement",
933 "empty_statement", "label_decl", "labeled_statement",
934 "labeled_statement_nsi", "expression_statement", "statement_expression",
935 "if_then_statement", "if_then_else_statement",
936 "if_then_else_statement_nsi", "switch_statement", "@9",
937 "switch_expression", "switch_block", "switch_block_statement_groups",
938 "switch_block_statement_group", "switch_labels", "switch_label",
939 "while_expression", "while_statement", "while_statement_nsi",
940 "do_statement_begin", "do_statement", "for_statement",
941 "for_statement_nsi", "for_header", "for_begin", "for_init",
942 "for_update", "statement_expression_list", "break_statement",
943 "continue_statement", "return_statement", "throw_statement",
944 "assert_statement", "synchronized_statement", "synchronized",
945 "try_statement", "catches", "catch_clause", "catch_clause_parameter",
946 "finally", "primary", "primary_no_new_array", "type_literals",
947 "class_instance_creation_expression", "anonymous_class_creation", "@10",
948 "@11", "something_dot_new", "argument_list",
949 "array_creation_expression", "dim_exprs", "dim_expr", "dims",
950 "field_access", "method_invocation", "array_access",
951 "postfix_expression", "post_increment_expression",
952 "post_decrement_expression", "trap_overflow_corner_case",
953 "unary_expression", "pre_increment_expression",
954 "pre_decrement_expression", "unary_expression_not_plus_minus",
955 "cast_expression", "multiplicative_expression", "additive_expression",
956 "shift_expression", "relational_expression", "equality_expression",
957 "and_expression", "exclusive_or_expression", "inclusive_or_expression",
958 "conditional_and_expression", "conditional_or_expression",
959 "conditional_expression", "assignment_expression", "assignment",
960 "left_hand_side", "assignment_operator", "expression",
961 "constant_expression", 0
962 };
963 #endif
964
965 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
966 static const short yyr1[] =
967 {
968 0, 112, 113, 113, 113, 113, 113, 113, 114, 114,
969 115, 115, 115, 116, 116, 117, 118, 119, 120, 120,
970 121, 121, 122, 123, 124, 125, 125, 125, 125, 125,
971 125, 125, 125, 126, 126, 127, 127, 128, 128, 128,
972 129, 129, 130, 130, 130, 131, 131, 131, 132, 132,
973 132, 132, 133, 133, 135, 134, 136, 134, 134, 134,
974 134, 134, 137, 137, 137, 137, 138, 138, 138, 139,
975 139, 139, 140, 140, 141, 141, 142, 142, 142, 142,
976 143, 143, 143, 143, 143, 144, 144, 145, 145, 145,
977 146, 146, 146, 146, 147, 147, 147, 147, 147, 148,
978 148, 150, 149, 149, 151, 151, 151, 151, 151, 151,
979 151, 151, 151, 152, 152, 152, 152, 152, 153, 153,
980 153, 154, 154, 154, 154, 155, 156, 156, 156, 157,
981 157, 157, 158, 158, 159, 160, 162, 161, 163, 163,
982 164, 164, 165, 165, 165, 165, 166, 167, 167, 167,
983 167, 168, 168, 170, 169, 171, 169, 172, 169, 173,
984 169, 169, 169, 174, 174, 174, 174, 175, 175, 176,
985 176, 177, 177, 177, 177, 178, 179, 179, 180, 180,
986 180, 180, 181, 181, 181, 182, 182, 183, 184, 185,
987 185, 186, 186, 186, 187, 188, 188, 189, 189, 189,
988 189, 189, 189, 190, 190, 190, 190, 190, 191, 191,
989 191, 191, 191, 191, 191, 191, 191, 191, 191, 191,
990 192, 193, 194, 194, 195, 196, 196, 196, 196, 196,
991 196, 196, 196, 196, 196, 196, 196, 196, 197, 197,
992 197, 197, 197, 197, 197, 198, 198, 198, 198, 199,
993 200, 202, 201, 203, 203, 203, 203, 204, 204, 204,
994 204, 205, 205, 206, 207, 207, 208, 208, 208, 208,
995 208, 209, 210, 210, 210, 210, 211, 212, 213, 214,
996 214, 214, 214, 214, 215, 215, 216, 216, 216, 217,
997 218, 218, 218, 218, 219, 219, 220, 220, 220, 221,
998 221, 221, 221, 222, 222, 222, 222, 223, 223, 223,
999 223, 224, 224, 224, 225, 225, 225, 225, 226, 226,
1000 226, 226, 226, 227, 228, 228, 228, 228, 229, 229,
1001 230, 231, 231, 231, 231, 232, 232, 233, 233, 234,
1002 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
1003 234, 234, 235, 235, 235, 235, 236, 236, 236, 236,
1004 236, 236, 236, 236, 236, 236, 236, 236, 236, 238,
1005 237, 239, 237, 240, 240, 241, 241, 241, 242, 242,
1006 242, 242, 242, 242, 242, 242, 243, 243, 244, 244,
1007 244, 245, 245, 245, 246, 246, 246, 247, 247, 247,
1008 247, 247, 247, 247, 247, 248, 248, 248, 248, 248,
1009 248, 249, 249, 249, 249, 250, 251, 252, 252, 252,
1010 252, 252, 253, 253, 253, 254, 254, 255, 255, 256,
1011 256, 256, 256, 256, 256, 257, 257, 257, 257, 257,
1012 257, 257, 257, 257, 258, 258, 258, 258, 258, 258,
1013 258, 259, 259, 259, 259, 259, 260, 260, 260, 260,
1014 260, 260, 260, 261, 261, 261, 261, 261, 261, 261,
1015 261, 261, 261, 261, 262, 262, 262, 262, 262, 263,
1016 263, 263, 264, 264, 264, 265, 265, 265, 266, 266,
1017 266, 267, 267, 267, 268, 268, 268, 268, 268, 269,
1018 269, 270, 270, 271, 271, 271, 272, 272, 273, 274
1019 };
1020
1021 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
1022 static const short yyr2[] =
1023 {
1024 0, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1025 1, 1, 1, 1, 1, 1, 1, 1, 2, 2,
1026 1, 1, 1, 3, 1, 0, 1, 1, 1, 2,
1027 2, 2, 3, 1, 2, 1, 2, 3, 2, 3,
1028 1, 1, 3, 2, 3, 5, 4, 5, 1, 1,
1029 1, 1, 1, 2, 0, 7, 0, 6, 3, 2,
1030 3, 4, 0, 2, 3, 2, 0, 2, 2, 1,
1031 3, 3, 2, 3, 1, 2, 1, 1, 1, 1,
1032 1, 1, 1, 1, 1, 3, 4, 1, 3, 3,
1033 1, 3, 3, 4, 1, 3, 2, 3, 3, 1,
1034 1, 0, 3, 2, 3, 3, 4, 4, 2, 3,
1035 2, 3, 2, 3, 4, 3, 3, 3, 1, 3,
1036 3, 2, 3, 2, 3, 1, 0, 2, 2, 1,
1037 3, 3, 1, 1, 2, 1, 0, 3, 2, 3,
1038 3, 4, 2, 3, 3, 4, 1, 4, 5, 7,
1039 6, 1, 1, 0, 4, 0, 5, 0, 5, 0,
1040 6, 3, 4, 2, 3, 2, 3, 2, 3, 1,
1041 2, 1, 1, 1, 1, 1, 2, 2, 2, 3,
1042 3, 4, 1, 3, 3, 2, 3, 1, 1, 1,
1043 2, 1, 1, 1, 2, 2, 3, 1, 1, 1,
1044 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1045 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1046 1, 2, 2, 2, 2, 2, 2, 2, 2, 3,
1047 4, 4, 5, 4, 5, 6, 7, 6, 1, 1,
1048 1, 1, 1, 1, 1, 5, 2, 3, 4, 7,
1049 7, 0, 3, 4, 2, 3, 5, 2, 3, 3,
1050 4, 1, 2, 2, 1, 2, 3, 2, 2, 3,
1051 2, 4, 2, 2, 3, 4, 2, 1, 7, 7,
1052 6, 3, 5, 4, 7, 6, 2, 2, 3, 2,
1053 0, 1, 1, 2, 0, 1, 1, 3, 3, 2,
1054 3, 2, 3, 2, 3, 2, 3, 2, 3, 2,
1055 3, 3, 2, 3, 5, 3, 2, 3, 5, 5,
1056 2, 4, 3, 1, 3, 3, 4, 2, 1, 2,
1057 2, 4, 2, 3, 4, 2, 2, 1, 1, 1,
1058 1, 3, 1, 1, 1, 1, 1, 3, 3, 3,
1059 3, 3, 3, 3, 3, 3, 5, 4, 1, 4,
1060 5, 5, 6, 3, 3, 4, 5, 2, 3, 0,
1061 7, 0, 6, 3, 3, 1, 3, 3, 3, 3,
1062 4, 4, 4, 4, 3, 3, 1, 2, 3, 3,
1063 2, 2, 3, 3, 3, 3, 2, 3, 4, 5,
1064 6, 5, 6, 4, 4, 4, 4, 3, 4, 3,
1065 4, 1, 1, 1, 1, 2, 2, 1, 1, 2,
1066 1, 2, 1, 2, 2, 2, 2, 2, 2, 1,
1067 2, 2, 1, 2, 2, 5, 4, 4, 5, 4,
1068 2, 5, 4, 5, 1, 3, 3, 3, 3, 3,
1069 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
1070 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1071 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
1072 3, 3, 1, 3, 3, 1, 3, 3, 1, 3,
1073 3, 1, 3, 3, 1, 5, 4, 3, 5, 1,
1074 1, 3, 3, 1, 1, 1, 1, 1, 1, 1
1075 };
1076
1077 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
1078 doesn't specify something else to do. Zero means the default is an
1079 error. */
1080 static const short yydefact[] =
1081 {
1082 0, 51, 52, 0, 0, 0, 0, 220, 1, 0,
1083 0, 0, 33, 40, 41, 35, 0, 48, 49, 50,
1084 43, 24, 0, 20, 21, 22, 0, 59, 0, 38,
1085 0, 0, 34, 36, 0, 0, 53, 0, 0, 44,
1086 42, 0, 161, 0, 0, 157, 60, 0, 66, 39,
1087 37, 0, 0, 0, 58, 0, 46, 0, 23, 165,
1088 17, 163, 15, 0, 154, 0, 0, 65, 16, 0,
1089 0, 56, 162, 0, 159, 61, 66, 47, 45, 12,
1090 0, 10, 11, 167, 0, 8, 9, 13, 14, 15,
1091 0, 173, 175, 0, 174, 0, 169, 171, 172, 166,
1092 164, 158, 64, 68, 69, 67, 0, 156, 0, 54,
1093 110, 0, 126, 108, 0, 0, 87, 90, 126, 0,
1094 18, 19, 112, 0, 0, 177, 176, 168, 170, 0,
1095 0, 57, 160, 0, 0, 0, 0, 105, 96, 85,
1096 0, 0, 0, 0, 104, 391, 0, 111, 126, 109,
1097 0, 126, 71, 70, 187, 72, 20, 0, 82, 0,
1098 74, 76, 80, 81, 0, 77, 0, 78, 136, 126,
1099 83, 79, 0, 84, 55, 116, 113, 0, 125, 0,
1100 118, 0, 128, 129, 127, 117, 115, 89, 0, 88,
1101 92, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1102 0, 0, 0, 6, 5, 2, 3, 4, 7, 339,
1103 0, 0, 412, 0, 100, 411, 337, 346, 342, 358,
1104 0, 338, 343, 344, 345, 429, 413, 414, 422, 444,
1105 417, 418, 420, 432, 451, 456, 463, 474, 479, 482,
1106 485, 488, 491, 494, 499, 508, 500, 0, 99, 97,
1107 95, 98, 393, 392, 107, 86, 106, 0, 126, 73,
1108 75, 103, 0, 134, 0, 138, 0, 0, 0, 277,
1109 0, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1110 0, 188, 0, 8, 14, 412, 0, 125, 193, 0,
1111 0, 208, 185, 0, 189, 191, 0, 192, 197, 209,
1112 0, 198, 210, 0, 199, 200, 211, 251, 0, 201,
1113 0, 212, 202, 290, 0, 213, 214, 215, 217, 219,
1114 216, 0, 218, 244, 243, 0, 241, 242, 239, 240,
1115 238, 123, 121, 114, 0, 0, 0, 421, 412, 343,
1116 345, 419, 424, 423, 428, 427, 426, 425, 0, 396,
1117 0, 0, 0, 16, 0, 433, 430, 434, 431, 440,
1118 0, 412, 0, 178, 0, 182, 0, 0, 0, 0,
1119 0, 0, 93, 0, 0, 367, 0, 416, 415, 0,
1120 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1121 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1122 506, 507, 0, 140, 0, 139, 133, 102, 132, 137,
1123 0, 227, 228, 226, 246, 0, 312, 0, 301, 299,
1124 0, 309, 307, 0, 273, 0, 254, 0, 327, 0,
1125 287, 0, 305, 303, 0, 316, 0, 0, 195, 0,
1126 223, 221, 0, 0, 186, 190, 194, 412, 323, 222,
1127 225, 0, 272, 0, 412, 292, 296, 289, 0, 0,
1128 320, 0, 120, 119, 124, 122, 131, 130, 351, 355,
1129 0, 395, 385, 384, 363, 0, 378, 386, 0, 379,
1130 0, 364, 0, 0, 0, 18, 19, 348, 341, 179,
1131 180, 0, 350, 354, 353, 397, 0, 375, 407, 0,
1132 349, 352, 373, 347, 374, 394, 409, 0, 368, 0,
1133 448, 445, 449, 446, 450, 447, 454, 452, 455, 453,
1134 460, 457, 461, 458, 462, 459, 470, 465, 472, 467,
1135 469, 464, 471, 466, 473, 0, 468, 477, 475, 478,
1136 476, 481, 480, 484, 483, 487, 486, 490, 489, 493,
1137 492, 497, 0, 0, 502, 501, 141, 412, 142, 0,
1138 0, 146, 0, 247, 0, 313, 311, 302, 300, 310,
1139 308, 274, 0, 255, 0, 0, 0, 324, 328, 0,
1140 325, 288, 306, 304, 317, 0, 315, 341, 0, 196,
1141 229, 0, 0, 0, 252, 0, 293, 0, 281, 0,
1142 0, 322, 0, 403, 404, 0, 390, 0, 387, 380,
1143 383, 381, 382, 365, 357, 0, 442, 436, 439, 0,
1144 0, 437, 184, 181, 183, 398, 0, 408, 405, 0,
1145 410, 406, 359, 0, 496, 0, 0, 143, 0, 0,
1146 144, 248, 0, 275, 271, 0, 332, 0, 336, 335,
1147 329, 326, 330, 0, 233, 0, 230, 231, 0, 0,
1148 0, 257, 0, 261, 0, 264, 0, 298, 297, 283,
1149 0, 295, 0, 321, 0, 401, 0, 389, 388, 0,
1150 366, 356, 441, 435, 443, 438, 377, 376, 399, 0,
1151 360, 361, 498, 495, 0, 145, 0, 0, 0, 245,
1152 0, 197, 0, 204, 205, 0, 206, 207, 0, 256,
1153 333, 0, 314, 234, 0, 0, 232, 270, 267, 268,
1154 509, 0, 259, 262, 0, 258, 0, 265, 0, 0,
1155 282, 0, 319, 318, 402, 372, 0, 400, 362, 0,
1156 147, 0, 0, 0, 224, 276, 0, 334, 331, 237,
1157 235, 0, 269, 266, 260, 0, 280, 0, 370, 0,
1158 0, 148, 0, 249, 0, 0, 236, 278, 279, 150,
1159 0, 0, 0, 0, 149, 0, 0, 0, 0, 285,
1160 0, 250, 284, 0, 0, 0
1161 };
1162
1163 static const short yydefgoto[] =
1164 {
1165 783, 209, 282, 210, 86, 87, 69, 61, 211, 212,
1166 23, 24, 25, 8, 9, 10, 11, 12, 13, 14,
1167 15, 448, 288, 133, 106, 48, 71, 105, 131, 159,
1168 160, 161, 92, 115, 116, 117, 213, 163, 262, 93,
1169 112, 179, 180, 289, 137, 184, 407, 165, 166, 167,
1170 264, 168, 169, 409, 558, 559, 290, 18, 44, 73,
1171 66, 108, 45, 64, 95, 96, 97, 98, 214, 366,
1172 291, 172, 561, 726, 294, 295, 296, 297, 700, 298,
1173 299, 300, 301, 703, 302, 303, 304, 305, 704, 306,
1174 451, 307, 594, 662, 663, 664, 665, 308, 309, 706,
1175 310, 311, 312, 707, 313, 314, 457, 670, 671, 315,
1176 316, 317, 318, 319, 320, 321, 322, 577, 578, 579,
1177 580, 215, 216, 217, 218, 219, 736, 679, 220, 496,
1178 221, 476, 477, 121, 222, 223, 224, 225, 226, 227,
1179 228, 229, 230, 231, 232, 233, 234, 235, 236, 237,
1180 238, 239, 240, 241, 242, 243, 244, 245, 246, 247,
1181 402, 497, 721
1182 };
1183
1184 static const short yypact[] =
1185 {
1186 756,-32768,-32768, 269, -45, 482, 498,-32768,-32768, 874,
1187 408, 945,-32768,-32768,-32768,-32768, 556,-32768,-32768,-32768,
1188 -32768,-32768, 17,-32768,-32768,-32768, 191,-32768, 307,-32768,
1189 34, 426,-32768,-32768, 965, 433,-32768, -45, 511,-32768,
1190 -32768, 476,-32768, 516, -22, -13,-32768, 522, 43,-32768,
1191 -32768, -45, 592, 411,-32768, 350,-32768, 29,-32768,-32768,
1192 -32768,-32768, 118, 1118,-32768, 532, -22,-32768,-32768, 186,
1193 557,-32768,-32768, -22, -13,-32768, 43,-32768,-32768,-32768,
1194 562,-32768,-32768,-32768, 564, 144,-32768,-32768,-32768, 210,
1195 992,-32768,-32768, 41,-32768, 1255,-32768,-32768,-32768,-32768,
1196 -32768,-32768,-32768,-32768,-32768, 250, 276,-32768, -22,-32768,
1197 -32768, 245, 475,-32768, 224, 612,-32768, 691, 475, 266,
1198 373, 373,-32768, 575, 576,-32768,-32768,-32768,-32768, 595,
1199 1045,-32768,-32768, 276, 674, 597, 93,-32768,-32768,-32768,
1200 601, 2142, 103, 400,-32768,-32768, 227,-32768, 475,-32768,
1201 680, 475,-32768,-32768,-32768,-32768, 389, 794,-32768, 1186,
1202 -32768,-32768,-32768,-32768, 16,-32768, 347,-32768,-32768, 450,
1203 -32768,-32768, 1862,-32768,-32768,-32768,-32768, 606, 490, 202,
1204 -32768, 776,-32768,-32768, 428,-32768,-32768,-32768, 243,-32768,
1205 -32768, 2850, 5088, 2902, 2968, 531, 26, 496,-32768, 3020,
1206 3086, 3138, 5285,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1207 321, 570, 727, 82,-32768, 619, 441,-32768,-32768,-32768,
1208 618,-32768, 572,-32768, 723, 804,-32768,-32768,-32768,-32768,
1209 -32768,-32768,-32768,-32768, 797, 837, 1055, 659, 853, 670,
1210 716, 731, 733, 21,-32768,-32768,-32768, 810,-32768,-32768,
1211 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 890, 450,-32768,
1212 -32768,-32768, 460,-32768, 347,-32768, 751, 280, 3204,-32768,
1213 214, 2194, 11, 371, 401, 225, 416, 260, 665, 3256,
1214 5587,-32768, -45, 321, 570, 937, 548, 448,-32768, 776,
1215 668,-32768,-32768, 1862,-32768,-32768, 673,-32768,-32768,-32768,
1216 1931,-32768,-32768, 709,-32768,-32768,-32768,-32768, 1931,-32768,
1217 1931,-32768,-32768, 1406, 712,-32768,-32768,-32768,-32768,-32768,
1218 -32768, 418,-32768, 689, 706, 804, 865, 908,-32768,-32768,
1219 -32768,-32768, 858,-32768, 658, 624, 627,-32768, 135,-32768,
1220 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 430,-32768,
1221 632, 987, 730, 730, 420,-32768,-32768,-32768,-32768,-32768,
1222 271, 727, 171,-32768, 671,-32768, 555, 485, 765, 5351,
1223 2260, 710,-32768, -19, 3322,-32768, 429,-32768,-32768, 3374,
1224 3440, 3492, 3558, 3610, 3676, 3728, 3794, 3846, 3912, 3964,
1225 4030, 900, 4082, 4148, 4200, 4266, 4318, 4384, 4436, 2312,
1226 -32768,-32768, 4502,-32768, 479,-32768,-32768,-32768,-32768,-32768,
1227 1862,-32768,-32768,-32768,-32768, 4554,-32768, 56,-32768,-32768,
1228 72,-32768,-32768, 76,-32768, 4620,-32768, 4672,-32768, 635,
1229 -32768, 5140,-32768,-32768, 107,-32768, 78, 340, 717, 661,
1230 -32768,-32768, -45, 2378,-32768,-32768,-32768, 795, 490,-32768,
1231 -32768, 746,-32768, 779, 1042,-32768,-32768,-32768, 84, 2430,
1232 -32768, 4738,-32768,-32768,-32768, 858,-32768,-32768,-32768,-32768,
1233 -32, 764,-32768,-32768,-32768, 2496, 730,-32768, 197, 730,
1234 197,-32768, 2548, 4790, 228, 3, 507,-32768, 5629,-32768,
1235 -32768, 2076,-32768,-32768,-32768,-32768, 519,-32768,-32768, 230,
1236 -32768,-32768,-32768,-32768,-32768, 770,-32768, 247,-32768, 5403,
1237 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 797,-32768, 797,
1238 -32768, 837,-32768, 837,-32768, 837,-32768, 1055,-32768, 1055,
1239 -32768, 1055,-32768, 1055,-32768, 144,-32768,-32768, 659,-32768,
1240 659,-32768, 853,-32768, 670,-32768, 716,-32768, 731,-32768,
1241 733,-32768, 866, 783,-32768,-32768,-32768, 1101,-32768, 1862,
1242 782,-32768, 1862,-32768, 345,-32768,-32768,-32768,-32768,-32768,
1243 -32768,-32768, 349,-32768, 788, 437, 235, 635,-32768, 347,
1244 -32768,-32768,-32768,-32768,-32768, 5587,-32768,-32768, 447, 717,
1245 -32768, 878, 48, 0,-32768, 792,-32768, 5233,-32768, 5165,
1246 796, 812, 818,-32768,-32768, 5469,-32768, 264,-32768, 373,
1247 -32768, 373,-32768,-32768, 819, 108,-32768,-32768,-32768, 4856,
1248 1241,-32768,-32768,-32768,-32768,-32768, 4908,-32768,-32768, 5521,
1249 -32768,-32768, 276, 527,-32768, 4974, 860,-32768, 1862, 2614,
1250 -32768,-32768, 1998,-32768,-32768, 261,-32768, 1005,-32768,-32768,
1251 -32768,-32768,-32768, 820,-32768, 2666,-32768,-32768, 892, 25,
1252 5026,-32768, 2,-32768, 1612,-32768, 5587,-32768,-32768,-32768,
1253 828, 825, 5208,-32768, 265,-32768, 553,-32768,-32768, 276,
1254 -32768, 832,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 590,
1255 -32768, 276,-32768,-32768, 455,-32768, 123, 139, 472,-32768,
1256 881, 887, 1998,-32768,-32768, 1998,-32768,-32768, 830,-32768,
1257 867, 876,-32768,-32768, 972, 154,-32768,-32768,-32768,-32768,
1258 -32768, 273,-32768,-32768, 1686,-32768, 1793,-32768, 880, 1931,
1259 -32768, 883,-32768,-32768,-32768,-32768, 276,-32768,-32768, 2732,
1260 -32768, 158, 4554, 1931,-32768,-32768, 2784,-32768,-32768,-32768,
1261 -32768, 981,-32768,-32768,-32768, 882,-32768, 1931,-32768, 175,
1262 162,-32768, 355,-32768, 5165, 884,-32768,-32768,-32768,-32768,
1263 211, 1998, 893, 5208,-32768, 934, 1998, 896, 1998,-32768,
1264 1998,-32768,-32768, 998, 1000,-32768
1265 };
1266
1267 static const short yypgoto[] =
1268 {
1269 -32768,-32768, -62, -56, 613, 23, -113, -24, 333, -3,
1270 -77,-32768, 129,-32768, 994, 755,-32768, 47,-32768,-32768,
1271 720, 112, 510,-32768,-32768, 953, 936,-32768, -125,-32768,
1272 856,-32768, 152, -122, 877, -154, -188,-32768,-32768, 396,
1273 -33, 766, -330, -129, -93,-32768,-32768,-32768,-32768,-32768,
1274 -32768,-32768, 863,-32768, 38,-32768, 628, 302,-32768,-32768,
1275 -32768,-32768, 969, 506,-32768, 939,-32768,-32768, 253,-32768,
1276 -114, 777, -157, -159, -283,-32768, 729, -289, 248, -531,
1277 578, -503,-32768,-32768,-32768, -304,-32768,-32768,-32768,-32768,
1278 -32768,-32768,-32768,-32768, 367, 382, -617, -491,-32768,-32768,
1279 -32768,-32768,-32768,-32768,-32768, -442,-32768, -611, 734,-32768,
1280 -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 474,-32768,
1281 481,-32768,-32768,-32768, 142,-32768,-32768,-32768,-32768, -423,
1282 -32768, 700, 219, -61, 1214, 238, 1238, 397, 486, 515,
1283 875, -162, 639, 762, -482,-32768, 586, 763, 728, 568,
1284 677, 678, 672, 681, 683,-32768, 449, 692, 798,-32768,
1285 -32768, 257,-32768
1286 };
1287
1288
1289 #define YYLAST 5740
1290
1291
1292 static const short yytable[] =
1293 {
1294 22, 84, 150, 30, 463, 181, 621, 85, 174, 456,
1295 445, 449, 349, 293, 365, 292, 171, 261, 39, 452,
1296 592, 453, 183, 332, 120, 144, 717, 349, 124, 341,
1297 77, 345, 347, 84, 85, 49, 398, 356, 358, 85,
1298 62, 100, 125, 21, 62, 171, 104, 727, 659, 657,
1299 659, 118, 263, 156, 504, 254, 32, 565, 256, 615,
1300 89, 731, 62, 660, 603, 660, 60, 62, 84, 21,
1301 68, 604, 177, 567, 85, 63, 265, 569, 85, 584,
1302 156, 32, 156, 372, 354, 596, 633, 89, 60, 65,
1303 148, 151, 89, 60, 185, 124, 70, 84, 661, 619,
1304 722, 85, 146, 85, 249, 153, -152, 727, 582, 680,
1305 399, 701, 16, -101, 350, 718, 283, -101, 40, 335,
1306 41, 16, 16, 16, 656, 85, 62, 89, 181, 350,
1307 78, 89, 62, 26, 28, 50, 444, 51, 685, 702,
1308 657, 352, 126, 16, 658, 360, 16, 16, 408, 120,
1309 626, 705, 60, 772, 89, 750, 89, 566, 68, 716,
1310 438, 429, 777, 750, 16, 405, 53, 55, 585, 285,
1311 58, 701, 487, 568, 701, 90, 749, 570, 89, 586,
1312 58, 465, 676, -91, -91, -291, 597, 102, 338, 338,
1313 338, 338, 42, 186, 62, 177, 338, 338, 361, 702,
1314 708, 85, 702, 250, 681, 181, 689, 90, 583, 111,
1315 626, 705, 766, 114, 705, 418, 697, 511, 513, 515,
1316 353, 51, 120, 467, 740, 138, 428, 442, 252, 618,
1317 369, 627, 715, 85, 370, 741, 648, 283, 371, -63,
1318 701, 626, 157, 119, 138, 701, 178, 701, 630, 701,
1319 751, 562, 111, 114, 89, 43, 626, 283, 770, 761,
1320 708, 432, 709, 708, 626, 677, 732, 488, 702, 188,
1321 20, 157, 177, 702, 752, 702, 769, 702, 85, 445,
1322 705, 414, 162, -63, 287, 705, 89, 705, -153, 705,
1323 285, 478, 480, 668, 202, 456, 146, 447, 333, 485,
1324 486, 286, 21, 624, 334, 447, 188, 447, 46, 119,
1325 454, 162, 774, 51, 323, 419, 760, 711, -94, 134,
1326 589, 617, 154, -94, -94, -94, -94, 253, 145, 708,
1327 628, 89, 154, 62, 708, 535, 708, -94, 708, -94,
1328 134, 487, -94, -94, -94, -94, 641, 631, 21, 376,
1329 643, 75, 129, 699, 283, 445, 641, 21, -253, 68,
1330 -62, 433, 154, 753, 678, 94, 145, 483, 456, 178,
1331 484, 47, 424, 130, 367, 415, 338, 338, 338, 338,
1332 338, 338, 338, 338, 338, 338, 338, 338, 89, 338,
1333 338, 338, 338, 338, 338, 338, 88, 94, 248, 420,
1334 638, 251, 426, -62, -62, 287, 434, 557, -28, 1,
1335 324, 188, 72, 449, 47, 609, 452, 430, 611, 460,
1336 119, 481, 286, 88, 367, 178, -31, 1, 88, 286,
1337 508, 468, 170, -30, 1, 323, 587, 286, 646, 286,
1338 756, 642, 323, 445, 154, 644, 178, -62, 654, -323,
1339 323, 771, 323, 2, 763, 323, 654, 683, 362, 248,
1340 456, 170, 649, 88, 188, 652, 425, 88, 768, 456,
1341 4, 2, 146, 414, 120, 43, 5, 56, 2, 471,
1342 338, 57, 699, 27, 257, 338, 492, 756, 4, 763,
1343 88, 768, 88, 36, 5, 4, 427, 351, 469, 29,
1344 58, 5, 505, 283, 135, 284, 283, 690, -155, 7,
1345 17, 431, 54, 461, 88, 482, 38, 59, 181, 17,
1346 17, 17, 287, 67, 509, 417, 164, 7, 423, 135,
1347 336, 324, 647, 99, 7, 36, 436, 437, 324, 286,
1348 374, 17, 655, -323, 17, 17, 324, 79, 324, 440,
1349 739, 324, 323, 493, 735, 164, 285, 154, 103, 285,
1350 733, 406, 17, 110, 21, 113, 738, 742, 58, 325,
1351 21, 188, 101, 91, 136, 556, 147, 149, 19, 107,
1352 81, 334, 283, 82, 21, 177, 21, 19, 19, 19,
1353 88, 85, -32, 1, -22, -22, 152, 637, 182, 21,
1354 640, 36, 187, 620, 21, 91, 146, 331, 283, 19,
1355 21, 758, 19, 19, 132, 625, 338, 338, 37, 375,
1356 21, 626, 88, 691, 38, 464, 284, 499, 466, 626,
1357 19, 507, 338, 470, 348, 285, -22, 2, 441, 447,
1358 158, -22, -22, -22, 89, 21, 284, -22, 324, 734,
1359 21, -22, 21, 490, 4, 626, 553, 491, 326, 462,
1360 5, 285, 500, 21, 21, -504, -504, 88, 283, 158,
1361 283, 287, 564, 368, 287, 175, 695, 387, 388, 389,
1362 390, 394, 572, 21, 574, 21, 737, 327, 286, 21,
1363 325, 286, 626, 7, 21, 608, 575, 325, 608, 447,
1364 576, 323, 447, 2, 323, 325, 21, 325, 173, 79,
1365 325, 500, 21, 139, 140, 21, 600, 391, 602, 2,
1366 21, 285, 373, 285, 88, 79, 447, 588, 395, 501,
1367 33, 610, 607, 612, 502, -342, -342, 173, 503, 323,
1368 447, 323, 81, 284, 396, 82, 21, 397, 248, 21,
1369 287, 33, -344, -344, 447, 33, -25, 1, 81, 178,
1370 -151, 82, 21, 443, 31, 58, 35, 286, 447, 489,
1371 176, 286, 33, 447, 446, 447, 287, 447, 501, 326,
1372 323, 255, 140, 502, 323, 141, 326, 503, -342, 52,
1373 142, 143, -342, 286, 326, 122, 326, 324, 21, 326,
1374 324, 2, 379, 380, 381, -344, 323, 325, 327, -344,
1375 450, 328, 3, 459, 323, 327, -505, -505, 4, 140,
1376 -503, -503, 369, 327, 5, 327, 370, 79, 327, 475,
1377 371, 286, 6, 494, 286, 324, 287, 324, 287, 36,
1378 382, 383, 653, 593, 323, 79, 595, 323, 411, 412,
1379 377, 378, 413, 286, 123, 286, 37, 7, 286, 605,
1380 81, 500, 38, 82, 21, 629, 323, 634, 323, 392,
1381 393, 323, 286, 635, -27, 1, 324, 639, 81, 656,
1382 324, 82, 21, 687, 645, 323, 286, 666, -503, -503,
1383 369, -135, 284, 716, 370, 284, 326, 672, 439, 323,
1384 286, 534, 324, 400, 401, 286, 323, 286, 673, 286,
1385 324, -413, -413, 323, 674, 323, -371, 720, 323, 2,
1386 323, 712, 323, 728, 729, 327, 694, 597, 501, -369,
1387 3, 746, 328, 502, 329, 2, 4, 503, 743, 328,
1388 324, 79, 5, 324, -203, -26, 1, 328, 21, 328,
1389 744, 79, 328, 745, -414, -414, 325, 142, 143, 325,
1390 538, 540, 324, 747, 324, -29, 1, 324, 517, 519,
1391 330, 284, 748, 749, 81, 7, 755, 82, 21, 757,
1392 88, 324, 766, 767, 81, 773, 403, 82, 21, 776,
1393 2, 778, 780, 122, 325, 324, 325, 284, 784, 762,
1394 785, 3, 324, 765, 536, 34, 710, 4, 76, 324,
1395 2, 324, 109, 5, 324, 260, 324, 189, 324, 775,
1396 258, 3, 74, 404, 779, -15, 781, 4, 782, 723,
1397 -503, -503, 369, 5, 128, 325, 370, 36, 560, 325,
1398 439, 410, 455, 79, 724, 326, 7, 458, 326, 328,
1399 2, 650, 123, 479, 37, 329, 79, 284, 651, 284,
1400 38, 325, 329, 384, 385, 386, 7, 343, 546, 325,
1401 329, 542, 329, 544, 327, 329, 81, 327, 548, 82,
1402 21, 550, 0, 326, 693, 326, 472, 473, 474, 81,
1403 2, 330, 82, 21, 555, 0, 79, 0, 330, 325,
1404 0, 0, 325, 0, 0, 80, 330, 4, 330, 0,
1405 0, 330, 327, 5, 327, 527, 529, 531, 533, 0,
1406 0, 325, 0, 325, 326, 0, 325, 0, 326, 81,
1407 -15, 0, 82, 21, 0, -503, -503, 369, 0, 0,
1408 325, 370, 154, 155, 0, 371, 7, 521, 523, 525,
1409 326, 0, 0, 327, 325, 0, 0, 327, 326, 0,
1410 0, 325, 0, 2, 0, 0, 0, 0, 325, 79,
1411 325, 0, 329, 325, 0, 325, 0, 325, 80, 327,
1412 4, 0, 0, 0, 0, 0, 5, 327, 326, -15,
1413 0, 326, 0, 0, -503, -503, 369, 0, 328, 0,
1414 370, 328, 81, 0, 636, 82, 21, 0, 330, 0,
1415 326, 0, 326, 0, 0, 326, 83, 327, 0, 0,
1416 327, 0, 0, 0, 0, 0, 0, 0, 0, 326,
1417 0, 2, 0, 0, 0, 0, 328, 79, 328, 327,
1418 0, 327, 684, 326, 327, 0, 80, 0, 4, 0,
1419 326, 0, 0, 0, 5, 0, 0, 326, 327, 326,
1420 0, 0, 326, 0, 326, 0, 326, 0, 0, 0,
1421 81, 0, 327, 82, 21, 0, 0, 328, 0, 327,
1422 0, 328, 0, 154, 259, 0, 327, 7, 327, 0,
1423 0, 327, 79, 327, 0, 327, 0, 0, 0, 0,
1424 2, 195, 0, 328, 0, 0, 79, 196, 0, 0,
1425 0, 328, 0, 0, 197, 80, 0, 4, 198, 0,
1426 0, 329, 0, 5, 329, 81, 0, 0, 82, 21,
1427 0, 0, 199, 200, 0, 0, 201, 0, 0, 81,
1428 0, 328, 82, 21, 328, 203, 204, 205, 206, 0,
1429 0, 207, 208, 127, 0, 0, 0, 330, 0, 329,
1430 330, 329, 0, 328, 0, 328, 0, 0, 328, 0,
1431 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1432 0, 0, 328, 0, 0, 0, 0, 0, 0, 0,
1433 0, 0, 0, 0, 0, 330, 328, 330, 0, 0,
1434 329, 0, 0, 328, 329, 339, 339, 339, 339, 0,
1435 328, 0, 328, 339, 339, 328, 0, 328, 0, 328,
1436 0, 0, 0, 0, 0, 0, 329, 0, 0, 340,
1437 340, 340, 340, 0, 329, 0, 330, 340, 340, 0,
1438 330, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1439 0, 2, 193, 194, 0, 0, 0, 79, 0, 0,
1440 0, 0, 330, 0, 329, 0, 195, 329, 0, 0,
1441 330, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1442 0, 0, 0, 198, 0, 0, 329, 0, 329, 0,
1443 81, 329, 0, 82, 21, 0, 0, 0, 0, 0,
1444 330, 280, 0, 330, 0, 329, 0, 0, 0, 0,
1445 203, 204, 205, 206, 0, 0, 207, 208, 0, 329,
1446 0, 0, 330, 0, 330, 0, 329, 330, 0, 0,
1447 0, 0, 0, 329, 0, 329, 0, 0, 329, 0,
1448 329, 330, 329, 0, 0, 0, 0, 0, 0, 0,
1449 0, 0, 0, 0, 0, 330, 0, 0, 0, 0,
1450 0, 0, 330, 0, 0, 0, 0, 0, 0, 330,
1451 0, 330, 0, 0, 330, 0, 330, 0, 330, 0,
1452 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1453 0, 0, 0, 339, 339, 339, 339, 339, 339, 339,
1454 339, 339, 339, 339, 339, 0, 339, 339, 339, 339,
1455 339, 339, 339, 266, 0, 0, 0, 340, 340, 340,
1456 340, 340, 340, 340, 340, 340, 340, 340, 340, 0,
1457 340, 340, 340, 340, 340, 340, 340, 0, 0, 0,
1458 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1459 0, 0, 0, 0, 0, 0, 0, 2, 193, 194,
1460 659, 267, 268, 79, 269, 0, 0, 270, 0, 0,
1461 0, 271, 195, 0, 0, 660, 0, 0, 272, 273,
1462 5, 274, 0, 275, 276, 197, 277, 266, 0, 278,
1463 279, 0, 0, 0, 0, 0, 81, 339, 0, 82,
1464 21, 0, 339, 0, 0, 0, 0, 280, 0, 154,
1465 725, 0, 0, 7, 0, 0, 203, 204, 205, 206,
1466 0, 340, 207, 208, 0, 0, 340, 0, 0, 0,
1467 0, 2, 193, 194, 659, 267, 268, 79, 269, 0,
1468 0, 270, 0, 0, 0, 271, 195, 0, 0, 660,
1469 0, 0, 272, 273, 5, 274, 0, 275, 276, 197,
1470 277, 0, 0, 278, 279, 0, 0, 0, 0, 0,
1471 81, 0, 0, 82, 21, 0, 0, 0, 0, 0,
1472 0, 280, 0, 154, 754, 0, 0, 7, 0, 0,
1473 203, 204, 205, 206, 266, 0, 207, 208, 0, 0,
1474 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1475 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1476 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1477 0, 0, 0, 339, 339, 0, 0, 0, 2, 193,
1478 194, -263, 267, 268, 79, 269, 0, 0, 270, 339,
1479 0, 0, 271, 195, 0, 0, -263, 340, 340, 272,
1480 273, 5, 274, 266, 275, 276, 197, 277, 0, 0,
1481 278, 279, 0, 340, 0, 0, 0, 81, 0, 0,
1482 82, 21, 0, 0, 0, 0, 0, 0, 280, 0,
1483 154, -263, 0, 0, 7, 0, 0, 203, 204, 205,
1484 206, 0, 0, 207, 208, 0, 0, 2, 193, 194,
1485 0, 267, 268, 79, 269, 0, 0, 270, 0, 0,
1486 0, 271, 195, 0, 0, 0, 0, 0, 272, 273,
1487 5, 274, 266, 275, 276, 197, 277, 0, 0, 278,
1488 279, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1489 21, 0, 0, 0, 0, 0, 0, 280, 0, 154,
1490 281, 0, 0, 7, 0, 0, 203, 204, 205, 206,
1491 0, 0, 207, 208, 0, 0, 2, 193, 194, 0,
1492 267, 268, 79, 269, 0, 0, 270, 0, 0, 0,
1493 271, 195, 0, 0, 0, 0, 0, 272, 273, 266,
1494 274, 0, 275, 276, 197, 277, 0, 0, 278, 279,
1495 0, 0, 0, 0, 0, 81, 0, 0, 82, 21,
1496 0, 0, 0, 0, 0, 0, 280, 0, 154, 0,
1497 0, 0, 7, 0, 0, 203, 204, 205, 206, 0,
1498 0, 207, 208, 2, 193, 194, 0, 698, 268, 79,
1499 269, 0, 0, 270, 0, 0, 0, 271, 195, 0,
1500 0, 0, 0, 0, 272, 273, 0, 274, 0, 275,
1501 276, 197, 277, 0, 0, 278, 279, 622, 0, 191,
1502 192, 0, 81, 0, 0, 82, 21, 0, 0, 0,
1503 0, 0, 0, 280, 0, 154, 0, 0, 0, 7,
1504 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1505 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1506 0, 0, 193, 194, 0, 0, 0, 79, 0, 0,
1507 0, 0, 0, 0, 0, 0, 195, 0, 0, 0,
1508 0, 0, 196, 190, 0, 191, 192, 0, 0, 197,
1509 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1510 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1511 0, 201, 0, 202, 623, 0, 0, 0, 0, 0,
1512 203, 204, 205, 206, 0, 0, 207, 208, 193, 194,
1513 0, 0, 0, 79, 0, 421, 0, 191, 192, 0,
1514 0, 0, 195, 0, 0, 0, 0, 0, 196, 0,
1515 0, 0, 0, 0, 0, 197, 0, 0, 0, 198,
1516 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1517 21, 0, 0, 199, 200, 0, 0, 201, 0, 202,
1518 193, 194, 0, 0, 0, 79, 203, 204, 205, 206,
1519 0, 0, 207, 208, 195, 0, 0, 0, 0, 0,
1520 196, 498, 0, 191, 192, 0, 0, 197, 0, 0,
1521 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1522 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1523 0, 0, 0, 0, 0, 422, 0, 0, 203, 204,
1524 205, 206, 0, 0, 207, 208, 193, 194, 0, 0,
1525 0, 79, 0, 551, 0, 191, 192, 0, 0, 0,
1526 195, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1527 0, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1528 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1529 0, 199, 200, 0, 0, 201, 0, 0, 193, 194,
1530 145, 0, 0, 79, 203, 204, 205, 206, 0, 0,
1531 207, 208, 195, 0, 0, 0, 0, 0, 196, 590,
1532 0, 191, 192, 0, 0, 197, 0, 0, 0, 198,
1533 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1534 21, 0, 552, 199, 200, 0, 0, 201, 0, 0,
1535 0, 0, 0, 0, 0, 0, 203, 204, 205, 206,
1536 0, 0, 207, 208, 193, 194, 0, 0, 0, 79,
1537 0, 598, 0, 191, 192, 0, 0, 0, 195, 0,
1538 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1539 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1540 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1541 200, 0, 0, 201, 591, 0, 193, 194, 0, 0,
1542 0, 79, 203, 204, 205, 206, 0, 0, 207, 208,
1543 195, 0, 0, 0, 0, 0, 196, 606, 0, 191,
1544 192, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1545 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1546 0, 199, 200, 0, 0, 201, 0, 0, 0, 0,
1547 0, 599, 0, 0, 203, 204, 205, 206, 0, 0,
1548 207, 208, 193, 194, 0, 0, 0, 79, 0, 613,
1549 0, 191, 192, 0, 0, 0, 195, 0, 0, 0,
1550 0, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1551 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1552 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1553 0, 201, 0, 0, 193, 194, 145, 0, 0, 79,
1554 203, 204, 205, 206, 0, 0, 207, 208, 195, 0,
1555 0, 0, 0, 0, 196, 590, 0, 191, 192, 0,
1556 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1557 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1558 200, 0, 0, 201, 614, 0, 0, 0, 0, 0,
1559 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1560 193, 194, 0, 0, 0, 79, 0, 713, 0, 191,
1561 192, 0, 0, 0, 195, 0, 0, 0, 0, 0,
1562 196, 0, 0, 0, 0, 0, 0, 197, 0, 0,
1563 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1564 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1565 696, 0, 193, 194, 0, 0, 0, 79, 203, 204,
1566 205, 206, 0, 0, 207, 208, 195, 0, 0, 0,
1567 0, 0, 196, 713, 0, 191, 192, 0, 0, 197,
1568 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1569 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1570 0, 201, 714, 0, 0, 0, 0, 0, 0, 0,
1571 203, 204, 205, 206, 0, 0, 207, 208, 193, 194,
1572 0, 0, 0, 79, 0, 598, 0, 191, 192, 0,
1573 0, 0, 195, 0, 0, 0, 0, 0, 196, 0,
1574 0, 0, 0, 0, 0, 197, 0, 0, 0, 198,
1575 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1576 21, 0, 0, 199, 200, 0, 0, 201, 759, 0,
1577 193, 194, 0, 0, 0, 79, 203, 204, 205, 206,
1578 0, 0, 207, 208, 195, 0, 0, 0, 0, 0,
1579 196, 337, 0, 191, 192, 0, 0, 197, 0, 0,
1580 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1581 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1582 0, 0, 0, 0, 0, 764, 0, 0, 203, 204,
1583 205, 206, 0, 0, 207, 208, 193, 194, 0, 0,
1584 0, 79, 0, 344, 0, 191, 192, 0, 0, 0,
1585 195, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1586 0, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1587 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1588 0, 199, 200, 0, 0, 201, 0, 0, 193, 194,
1589 0, 0, 0, 79, 203, 204, 205, 206, 0, 0,
1590 207, 208, 195, 0, 0, 0, 0, 0, 196, 346,
1591 0, 191, 192, 0, 0, 197, 0, 0, 0, 198,
1592 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1593 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1594 0, 0, 0, 0, 0, 0, 203, 204, 205, 206,
1595 0, 0, 207, 208, 193, 194, 0, 0, 0, 79,
1596 0, 355, 0, 191, 192, 0, 0, 0, 195, 0,
1597 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1598 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1599 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1600 200, 0, 0, 201, 0, 0, 193, 194, 0, 0,
1601 0, 79, 203, 204, 205, 206, 0, 0, 207, 208,
1602 195, 0, 0, 0, 0, 0, 196, 357, 0, 191,
1603 192, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1604 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1605 0, 199, 200, 0, 0, 201, 0, 0, 0, 0,
1606 0, 0, 0, 0, 203, 204, 205, 206, 0, 0,
1607 207, 208, 193, 194, 0, 0, 0, 79, 0, 359,
1608 0, 191, 192, 0, 0, 0, 195, 0, 0, 0,
1609 0, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1610 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1611 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1612 0, 201, 0, 0, 193, 194, 0, 0, 0, 79,
1613 203, 204, 205, 206, 0, 0, 207, 208, 195, 0,
1614 0, 0, 0, 0, 196, 416, 0, 191, 192, 0,
1615 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1616 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1617 200, 0, 0, 201, 0, 0, 0, 0, 0, 0,
1618 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1619 193, 194, 0, 0, 0, 79, 0, 435, 0, 191,
1620 192, 0, 0, 0, 195, 0, 0, 0, 0, 0,
1621 196, 0, 0, 0, 0, 0, 0, 197, 0, 0,
1622 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1623 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1624 0, 0, 193, 194, 0, 0, 0, 79, 203, 204,
1625 205, 206, 0, 0, 207, 208, 195, 0, 0, 0,
1626 0, 0, 196, 506, 0, 191, 192, 0, 0, 197,
1627 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1628 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1629 0, 201, 0, 0, 0, 0, 0, 0, 0, 0,
1630 203, 204, 205, 206, 0, 0, 207, 208, 193, 194,
1631 0, 0, 0, 79, 0, 510, 0, 191, 192, 0,
1632 0, 0, 195, 0, 0, 0, 0, 0, 196, 0,
1633 0, 0, 0, 0, 0, 197, 0, 0, 0, 198,
1634 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1635 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1636 193, 194, 0, 0, 0, 79, 203, 204, 205, 206,
1637 0, 0, 207, 208, 195, 0, 0, 0, 0, 0,
1638 196, 512, 0, 191, 192, 0, 0, 197, 0, 0,
1639 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1640 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1641 0, 0, 0, 0, 0, 0, 0, 0, 203, 204,
1642 205, 206, 0, 0, 207, 208, 193, 194, 0, 0,
1643 0, 79, 0, 514, 0, 191, 192, 0, 0, 0,
1644 195, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1645 0, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1646 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1647 0, 199, 200, 0, 0, 201, 0, 0, 193, 194,
1648 0, 0, 0, 79, 203, 204, 205, 206, 0, 0,
1649 207, 208, 195, 0, 0, 0, 0, 0, 196, 516,
1650 0, 191, 192, 0, 0, 197, 0, 0, 0, 198,
1651 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1652 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1653 0, 0, 0, 0, 0, 0, 203, 204, 205, 206,
1654 0, 0, 207, 208, 193, 194, 0, 0, 0, 79,
1655 0, 518, 0, 191, 192, 0, 0, 0, 195, 0,
1656 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1657 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1658 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1659 200, 0, 0, 201, 0, 0, 193, 194, 0, 0,
1660 0, 79, 203, 204, 205, 206, 0, 0, 207, 208,
1661 195, 0, 0, 0, 0, 0, 196, 520, 0, 191,
1662 192, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1663 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1664 0, 199, 200, 0, 0, 201, 0, 0, 0, 0,
1665 0, 0, 0, 0, 203, 204, 205, 206, 0, 0,
1666 207, 208, 193, 194, 0, 0, 0, 79, 0, 522,
1667 0, 191, 192, 0, 0, 0, 195, 0, 0, 0,
1668 0, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1669 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1670 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1671 0, 201, 0, 0, 193, 194, 0, 0, 0, 79,
1672 203, 204, 205, 206, 0, 0, 207, 208, 195, 0,
1673 0, 0, 0, 0, 196, 524, 0, 191, 192, 0,
1674 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1675 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1676 200, 0, 0, 201, 0, 0, 0, 0, 0, 0,
1677 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1678 193, 194, 0, 0, 0, 79, 0, 526, 0, 191,
1679 192, 0, 0, 0, 195, 0, 0, 0, 0, 0,
1680 196, 0, 0, 0, 0, 0, 0, 197, 0, 0,
1681 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1682 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1683 0, 0, 193, 194, 0, 0, 0, 79, 203, 204,
1684 205, 206, 0, 0, 207, 208, 195, 0, 0, 0,
1685 0, 0, 196, 528, 0, 191, 192, 0, 0, 197,
1686 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1687 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1688 0, 201, 0, 0, 0, 0, 0, 0, 0, 0,
1689 203, 204, 205, 206, 0, 0, 207, 208, 193, 194,
1690 0, 0, 0, 79, 0, 530, 0, 191, 192, 0,
1691 0, 0, 195, 0, 0, 0, 0, 0, 196, 0,
1692 0, 0, 0, 0, 0, 197, 0, 0, 0, 198,
1693 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1694 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1695 193, 194, 0, 0, 0, 79, 203, 204, 205, 206,
1696 0, 0, 207, 208, 195, 0, 0, 0, 0, 0,
1697 196, 532, 0, 191, 192, 0, 0, 197, 0, 0,
1698 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1699 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1700 0, 0, 0, 0, 0, 0, 0, 0, 203, 204,
1701 205, 206, 0, 0, 207, 208, 193, 194, 0, 0,
1702 0, 79, 0, 537, 0, 191, 192, 0, 0, 0,
1703 195, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1704 0, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1705 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1706 0, 199, 200, 0, 0, 201, 0, 0, 193, 194,
1707 0, 0, 0, 79, 203, 204, 205, 206, 0, 0,
1708 207, 208, 195, 0, 0, 0, 0, 0, 196, 539,
1709 0, 191, 192, 0, 0, 197, 0, 0, 0, 198,
1710 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1711 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1712 0, 0, 0, 0, 0, 0, 203, 204, 205, 206,
1713 0, 0, 207, 208, 193, 194, 0, 0, 0, 79,
1714 0, 541, 0, 191, 192, 0, 0, 0, 195, 0,
1715 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1716 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1717 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1718 200, 0, 0, 201, 0, 0, 193, 194, 0, 0,
1719 0, 79, 203, 204, 205, 206, 0, 0, 207, 208,
1720 195, 0, 0, 0, 0, 0, 196, 543, 0, 191,
1721 192, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1722 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1723 0, 199, 200, 0, 0, 201, 0, 0, 0, 0,
1724 0, 0, 0, 0, 203, 204, 205, 206, 0, 0,
1725 207, 208, 193, 194, 0, 0, 0, 79, 0, 545,
1726 0, 191, 192, 0, 0, 0, 195, 0, 0, 0,
1727 0, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1728 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1729 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1730 0, 201, 0, 0, 193, 194, 0, 0, 0, 79,
1731 203, 204, 205, 206, 0, 0, 207, 208, 195, 0,
1732 0, 0, 0, 0, 196, 547, 0, 191, 192, 0,
1733 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1734 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1735 200, 0, 0, 201, 0, 0, 0, 0, 0, 0,
1736 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1737 193, 194, 0, 0, 0, 79, 0, 549, 0, 191,
1738 192, 0, 0, 0, 195, 0, 0, 0, 0, 0,
1739 196, 0, 0, 0, 0, 0, 0, 197, 0, 0,
1740 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1741 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1742 0, 0, 193, 194, 0, 0, 0, 79, 203, 204,
1743 205, 206, 0, 0, 207, 208, 195, 0, 0, 0,
1744 0, 0, 196, 554, 0, 191, 192, 0, 0, 197,
1745 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1746 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1747 0, 201, 0, 0, 0, 0, 0, 0, 0, 0,
1748 203, 204, 205, 206, 0, 0, 207, 208, 193, 194,
1749 0, 0, 0, 79, 0, 563, 0, 191, 192, 0,
1750 0, 0, 195, 0, 0, 0, 0, 0, 196, 0,
1751 0, 0, 0, 0, 0, 197, 0, 0, 0, 198,
1752 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1753 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1754 193, 194, 0, 0, 0, 79, 203, 204, 205, 206,
1755 0, 0, 207, 208, 195, 0, 0, 0, 0, 0,
1756 196, 571, 0, 191, 192, 0, 0, 197, 0, 0,
1757 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1758 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1759 0, 0, 0, 0, 0, 0, 0, 0, 203, 204,
1760 205, 206, 0, 0, 207, 208, 193, 194, 0, 0,
1761 0, 79, 0, 573, 0, 191, 192, 0, 0, 0,
1762 195, 0, 0, 0, 0, 0, 196, 0, 0, 0,
1763 0, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1764 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1765 0, 199, 200, 0, 0, 201, 0, 0, 193, 194,
1766 0, 0, 0, 79, 203, 204, 205, 206, 0, 0,
1767 207, 208, 195, 0, 0, 0, 0, 0, 196, 601,
1768 0, 191, 192, 0, 0, 197, 0, 0, 0, 198,
1769 0, 0, 0, 0, 0, 0, 81, 0, 0, 82,
1770 21, 0, 0, 199, 200, 0, 0, 201, 0, 0,
1771 0, 0, 0, 0, 0, 0, 203, 204, 205, 206,
1772 0, 0, 207, 208, 193, 194, 0, 0, 0, 79,
1773 0, 616, 0, 191, 192, 0, 0, 0, 195, 0,
1774 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1775 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1776 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1777 200, 0, 0, 201, 0, 0, 193, 194, 0, 0,
1778 0, 79, 203, 204, 205, 206, 0, 0, 207, 208,
1779 195, 0, 0, 0, 0, 0, 196, 682, 0, 191,
1780 192, 0, 0, 197, 0, 0, 0, 198, 0, 0,
1781 0, 0, 0, 0, 81, 0, 0, 82, 21, 0,
1782 0, 199, 200, 0, 0, 201, 0, 0, 0, 0,
1783 0, 0, 0, 0, 203, 204, 205, 206, 0, 0,
1784 207, 208, 193, 194, 0, 0, 0, 79, 0, 686,
1785 0, 191, 192, 0, 0, 0, 195, 0, 0, 0,
1786 0, 0, 196, 0, 0, 0, 0, 0, 0, 197,
1787 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1788 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1789 0, 201, 0, 0, 193, 194, 0, 0, 0, 79,
1790 203, 204, 205, 206, 0, 0, 207, 208, 195, 0,
1791 0, 0, 0, 0, 196, 692, 0, 191, 192, 0,
1792 0, 197, 0, 0, 0, 198, 0, 0, 0, 0,
1793 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1794 200, 0, 0, 201, 0, 0, 0, 0, 0, 0,
1795 0, 0, 203, 204, 205, 206, 0, 0, 207, 208,
1796 193, 194, 0, 0, 0, 79, 0, 719, 0, 191,
1797 192, 0, 0, 0, 195, 0, 0, 0, 0, 0,
1798 196, 0, 0, 0, 0, 0, 0, 197, 0, 0,
1799 0, 198, 0, 0, 0, 0, 0, 0, 81, 0,
1800 0, 82, 21, 0, 0, 199, 200, 0, 0, 201,
1801 0, 0, 193, 194, 0, 0, 0, 79, 203, 204,
1802 205, 206, 0, 0, 207, 208, 195, 0, 0, 342,
1803 0, 191, 196, 0, 0, 0, 0, 0, 0, 197,
1804 0, 0, 0, 198, 0, 0, 0, 0, 0, 0,
1805 81, 0, 0, 82, 21, 0, 0, 199, 200, 0,
1806 0, 201, 0, 0, 0, 0, 0, 0, 0, 0,
1807 203, 204, 205, 206, 193, 194, 207, 208, 0, 79,
1808 0, 581, 0, 0, 0, 0, 0, 0, 195, 0,
1809 0, 0, 0, 0, 196, 0, 0, 0, 0, 0,
1810 0, 197, 0, 0, 0, 198, 669, 0, 0, 0,
1811 0, 0, 81, 0, 0, 82, 21, 0, 0, 199,
1812 200, 0, 0, 201, 0, -286, -286, -286, 0, 0,
1813 0, -286, 203, 204, 205, 206, 0, 0, 207, 208,
1814 -286, 0, 0, 0, 0, 0, -286, 0, 0, 730,
1815 0, 193, 194, -286, 0, 0, 79, -286, 0, 0,
1816 0, 0, 0, 0, -286, 195, 0, -286, -286, 0,
1817 0, 196, 0, 0, 667, -286, 0, 0, 197, 0,
1818 0, -286, 198, 0, -286, -286, -286, -286, 0, 81,
1819 -286, -286, 82, 21, 193, 194, 0, 0, 0, 79,
1820 280, -294, 0, 0, 0, 0, 0, 0, 195, 203,
1821 204, 205, 206, 0, 196, 207, 208, 0, 0, 193,
1822 194, 197, 0, 0, 79, 198, 0, 0, 191, 192,
1823 0, 0, 81, 195, 0, 82, 21, 0, 0, 196,
1824 0, 0, 0, 280, -294, 0, 197, 0, 0, 0,
1825 198, 0, 203, 204, 205, 206, 0, 81, 207, 208,
1826 82, 21, 0, 0, 0, 0, 0, 0, 280, 0,
1827 0, 193, 194, 0, 0, 0, 79, 203, 204, 205,
1828 206, 0, 0, 207, 208, 195, 0, 0, 0, 0,
1829 0, 196, 0, 0, 191, 192, 0, 0, 197, 0,
1830 0, 0, 198, 0, 0, 0, 0, 0, 0, 81,
1831 0, 0, 82, 21, 0, 0, 199, 200, 0, 0,
1832 201, 0, 202, 363, 0, 0, 0, 364, 0, 203,
1833 204, 205, 206, 0, 0, 207, 208, 193, 194, 0,
1834 0, 0, 79, 0, 0, 0, 191, 192, 0, 0,
1835 0, 195, 0, 0, 0, 0, 0, 196, 0, 0,
1836 0, 0, 0, 0, 197, 0, 0, 0, 198, 0,
1837 0, 0, 0, 0, 0, 81, 0, 0, 82, 21,
1838 0, 0, 199, 200, 0, 0, 201, 495, 0, 193,
1839 194, 0, 0, 0, 79, 203, 204, 205, 206, 0,
1840 0, 207, 208, 195, 0, 0, 0, 0, 0, 196,
1841 0, 0, 191, 192, 0, 0, 197, 0, 0, 0,
1842 198, 0, 0, 0, 0, 0, 0, 81, 0, 0,
1843 82, 21, 0, 0, 199, 200, 0, 0, 201, 632,
1844 0, 0, 0, 0, 0, 0, 0, 203, 204, 205,
1845 206, 0, 0, 207, 208, 193, 194, 0, 0, 0,
1846 79, 0, 0, 0, 191, 192, 0, 0, 0, 195,
1847 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1848 0, 0, 197, 0, 0, 0, 198, 0, 0, 0,
1849 0, 0, 0, 81, 0, 0, 82, 21, 0, 0,
1850 199, 200, 0, 0, 201, 675, 0, 193, 194, 0,
1851 0, 0, 79, 203, 204, 205, 206, 0, 0, 207,
1852 208, 195, 0, 0, 0, 0, 0, 196, 0, 0,
1853 191, 192, 0, 0, 197, 0, 0, 0, 198, 0,
1854 0, 0, 0, 0, 0, 81, 0, 0, 82, 21,
1855 0, 0, 199, 200, 0, 0, 201, 688, 0, 0,
1856 0, 0, 0, 0, 0, 203, 204, 205, 206, 0,
1857 0, 207, 208, 193, 194, 0, 0, 0, 79, 0,
1858 0, 0, 0, 0, 0, 0, 0, 195, 0, 0,
1859 0, 0, 0, 196, 0, 0, 0, 0, 0, 0,
1860 197, 0, 0, 0, 198, 0, 0, 0, 0, 0,
1861 0, 81, 0, 0, 82, 21, 0, 0, 199, 200,
1862 79, 0, 201, 0, 0, 0, 0, 0, 0, 195,
1863 0, 203, 204, 205, 206, 196, 0, 207, 208, 0,
1864 0, 0, 197, 0, 0, 0, 198, 0, 0, 0,
1865 0, 0, 0, 81, 0, 0, 82, 21, 0, 0,
1866 199, 200, 0, 0, 201, 0, 0, 0, 0, 0,
1867 0, 0, 0, 203, 204, 205, 206, 0, 0, 207,
1868 208
1869 };
1870
1871 static const short yycheck[] =
1872 {
1873 3, 63, 124, 6, 334, 134, 488, 63, 133, 313,
1874 293, 300, 1, 172, 202, 172, 130, 1, 1, 308,
1875 443, 310, 135, 177, 85, 118, 1, 1, 90, 191,
1876 1, 193, 194, 95, 90, 1, 15, 199, 200, 95,
1877 43, 65, 1, 88, 47, 159, 70, 664, 48, 1,
1878 48, 84, 166, 130, 73, 148, 9, 1, 151, 482,
1879 63, 672, 65, 63, 96, 63, 43, 70, 130, 88,
1880 47, 103, 134, 1, 130, 97, 169, 1, 134, 1,
1881 157, 34, 159, 1, 197, 1, 509, 90, 65, 102,
1882 123, 124, 95, 70, 1, 157, 53, 159, 98, 96,
1883 98, 157, 99, 159, 1, 129, 95, 724, 1, 1,
1884 89, 642, 0, 97, 103, 90, 172, 101, 101, 181,
1885 103, 9, 10, 11, 1, 181, 129, 130, 257, 103,
1886 101, 134, 135, 4, 5, 101, 293, 103, 620, 642,
1887 1, 197, 101, 31, 96, 201, 34, 35, 262, 210,
1888 102, 642, 129, 764, 157, 1, 159, 101, 135, 1,
1889 282, 275, 773, 1, 52, 258, 37, 38, 90, 172,
1890 41, 702, 1, 101, 705, 63, 1, 101, 181, 101,
1891 51, 335, 605, 101, 102, 101, 102, 1, 191, 192,
1892 193, 194, 1, 100, 197, 257, 199, 200, 201, 702,
1893 642, 257, 705, 100, 96, 334, 629, 95, 101, 80,
1894 102, 702, 1, 84, 705, 1, 639, 379, 380, 381,
1895 197, 103, 283, 336, 101, 1, 1, 289, 1, 1,
1896 95, 1, 655, 289, 99, 96, 1, 293, 103, 53,
1897 771, 102, 130, 99, 1, 776, 134, 778, 1, 780,
1898 96, 410, 123, 124, 257, 64, 102, 313, 96, 101,
1899 702, 1, 1, 705, 102, 1, 1, 96, 771, 140,
1900 1, 159, 334, 776, 1, 778, 101, 780, 334, 562,
1901 771, 1, 130, 97, 172, 776, 289, 778, 97, 780,
1902 293, 352, 353, 597, 97, 599, 99, 300, 96, 360,
1903 361, 172, 88, 491, 102, 308, 177, 310, 1, 99,
1904 313, 159, 101, 103, 172, 101, 739, 647, 94, 95,
1905 442, 483, 97, 99, 100, 101, 102, 100, 100, 771,
1906 100, 334, 97, 336, 776, 391, 778, 94, 780, 96,
1907 95, 1, 99, 100, 101, 102, 1, 100, 88, 220,
1908 1, 1, 102, 642, 410, 638, 1, 88, 97, 336,
1909 53, 101, 97, 90, 100, 63, 100, 96, 672, 257,
1910 99, 64, 1, 97, 103, 95, 379, 380, 381, 382,
1911 383, 384, 385, 386, 387, 388, 389, 390, 391, 392,
1912 393, 394, 395, 396, 397, 398, 63, 95, 141, 270,
1913 559, 1, 1, 53, 97, 293, 277, 410, 0, 1,
1914 172, 282, 1, 702, 64, 476, 705, 1, 479, 1,
1915 99, 1, 293, 90, 103, 313, 0, 1, 95, 300,
1916 1, 1, 130, 0, 1, 293, 96, 308, 1, 310,
1917 729, 96, 300, 726, 97, 96, 334, 97, 1, 1,
1918 308, 96, 310, 45, 743, 313, 1, 619, 201, 202,
1919 764, 159, 576, 130, 335, 579, 95, 134, 757, 773,
1920 62, 45, 99, 1, 535, 64, 68, 1, 45, 350,
1921 483, 5, 771, 1, 95, 488, 1, 776, 62, 778,
1922 157, 780, 159, 45, 68, 62, 95, 1, 68, 1,
1923 371, 68, 373, 559, 54, 172, 562, 632, 97, 101,
1924 0, 95, 1, 95, 181, 95, 68, 1, 647, 9,
1925 10, 11, 410, 1, 95, 268, 130, 101, 271, 54,
1926 102, 293, 95, 1, 101, 45, 279, 280, 300, 410,
1927 99, 31, 95, 95, 34, 35, 308, 51, 310, 1,
1928 95, 313, 410, 68, 679, 159, 559, 97, 1, 562,
1929 674, 101, 52, 1, 88, 1, 691, 95, 439, 172,
1930 88, 442, 66, 63, 99, 96, 1, 1, 0, 73,
1931 84, 102, 638, 87, 88, 647, 88, 9, 10, 11,
1932 257, 647, 0, 1, 46, 47, 1, 559, 1, 88,
1933 562, 45, 1, 96, 88, 95, 99, 1, 664, 31,
1934 88, 736, 34, 35, 108, 96, 619, 620, 62, 1,
1935 88, 102, 289, 96, 68, 1, 293, 370, 1, 102,
1936 52, 374, 635, 1, 103, 638, 88, 45, 90, 642,
1937 130, 93, 94, 95, 647, 88, 313, 99, 410, 96,
1938 88, 103, 88, 98, 62, 102, 399, 102, 172, 1,
1939 68, 664, 1, 88, 88, 93, 94, 334, 724, 159,
1940 726, 559, 415, 103, 562, 1, 638, 18, 19, 20,
1941 21, 11, 425, 88, 427, 88, 96, 172, 559, 88,
1942 293, 562, 102, 101, 88, 476, 61, 300, 479, 702,
1943 65, 559, 705, 45, 562, 308, 88, 310, 130, 51,
1944 313, 1, 88, 101, 102, 88, 459, 58, 461, 45,
1945 88, 724, 103, 726, 391, 51, 729, 66, 12, 68,
1946 10, 478, 475, 480, 73, 46, 47, 159, 77, 597,
1947 743, 599, 84, 410, 13, 87, 88, 14, 491, 88,
1948 638, 31, 46, 47, 757, 35, 0, 1, 84, 647,
1949 95, 87, 88, 95, 9, 636, 11, 638, 771, 98,
1950 96, 642, 52, 776, 101, 778, 664, 780, 68, 293,
1951 638, 101, 102, 73, 642, 94, 300, 77, 99, 34,
1952 99, 100, 103, 664, 308, 1, 310, 559, 88, 313,
1953 562, 45, 5, 6, 7, 99, 664, 410, 293, 103,
1954 101, 172, 56, 101, 672, 300, 93, 94, 62, 102,
1955 93, 94, 95, 308, 68, 310, 99, 51, 313, 99,
1956 103, 702, 76, 68, 705, 597, 724, 599, 726, 45,
1957 3, 4, 585, 97, 702, 51, 67, 705, 97, 98,
1958 46, 47, 101, 724, 60, 726, 62, 101, 729, 95,
1959 84, 1, 68, 87, 88, 95, 724, 1, 726, 16,
1960 17, 729, 743, 90, 0, 1, 638, 95, 84, 1,
1961 642, 87, 88, 626, 96, 743, 757, 95, 93, 94,
1962 95, 97, 559, 1, 99, 562, 410, 101, 103, 757,
1963 771, 1, 664, 93, 94, 776, 764, 778, 96, 780,
1964 672, 46, 47, 771, 96, 773, 97, 660, 776, 45,
1965 778, 101, 780, 666, 96, 410, 66, 102, 68, 97,
1966 56, 101, 293, 73, 172, 45, 62, 77, 57, 300,
1967 702, 51, 68, 705, 57, 0, 1, 308, 88, 310,
1968 702, 51, 313, 705, 46, 47, 559, 99, 100, 562,
1969 392, 393, 724, 96, 726, 0, 1, 729, 382, 383,
1970 172, 638, 96, 1, 84, 101, 96, 87, 88, 96,
1971 647, 743, 1, 101, 84, 101, 96, 87, 88, 96,
1972 45, 57, 96, 1, 597, 757, 599, 664, 0, 742,
1973 0, 56, 764, 746, 391, 11, 1, 62, 55, 771,
1974 45, 773, 76, 68, 776, 159, 778, 140, 780, 771,
1975 157, 56, 53, 257, 776, 88, 778, 62, 780, 662,
1976 93, 94, 95, 68, 95, 638, 99, 45, 410, 642,
1977 103, 264, 313, 51, 662, 559, 101, 313, 562, 410,
1978 45, 577, 60, 353, 62, 293, 51, 724, 577, 726,
1979 68, 664, 300, 8, 9, 10, 101, 192, 396, 672,
1980 308, 394, 310, 395, 559, 313, 84, 562, 397, 87,
1981 88, 398, -1, 597, 635, 599, 99, 100, 101, 84,
1982 45, 293, 87, 88, 402, -1, 51, -1, 300, 702,
1983 -1, -1, 705, -1, -1, 60, 308, 62, 310, -1,
1984 -1, 313, 597, 68, 599, 387, 388, 389, 390, -1,
1985 -1, 724, -1, 726, 638, -1, 729, -1, 642, 84,
1986 88, -1, 87, 88, -1, 93, 94, 95, -1, -1,
1987 743, 99, 97, 98, -1, 103, 101, 384, 385, 386,
1988 664, -1, -1, 638, 757, -1, -1, 642, 672, -1,
1989 -1, 764, -1, 45, -1, -1, -1, -1, 771, 51,
1990 773, -1, 410, 776, -1, 778, -1, 780, 60, 664,
1991 62, -1, -1, -1, -1, -1, 68, 672, 702, 88,
1992 -1, 705, -1, -1, 93, 94, 95, -1, 559, -1,
1993 99, 562, 84, -1, 103, 87, 88, -1, 410, -1,
1994 724, -1, 726, -1, -1, 729, 98, 702, -1, -1,
1995 705, -1, -1, -1, -1, -1, -1, -1, -1, 743,
1996 -1, 45, -1, -1, -1, -1, 597, 51, 599, 724,
1997 -1, 726, 1, 757, 729, -1, 60, -1, 62, -1,
1998 764, -1, -1, -1, 68, -1, -1, 771, 743, 773,
1999 -1, -1, 776, -1, 778, -1, 780, -1, -1, -1,
2000 84, -1, 757, 87, 88, -1, -1, 638, -1, 764,
2001 -1, 642, -1, 97, 98, -1, 771, 101, 773, -1,
2002 -1, 776, 51, 778, -1, 780, -1, -1, -1, -1,
2003 45, 60, -1, 664, -1, -1, 51, 66, -1, -1,
2004 -1, 672, -1, -1, 73, 60, -1, 62, 77, -1,
2005 -1, 559, -1, 68, 562, 84, -1, -1, 87, 88,
2006 -1, -1, 91, 92, -1, -1, 95, -1, -1, 84,
2007 -1, 702, 87, 88, 705, 104, 105, 106, 107, -1,
2008 -1, 110, 111, 98, -1, -1, -1, 559, -1, 597,
2009 562, 599, -1, 724, -1, 726, -1, -1, 729, -1,
2010 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2011 -1, -1, 743, -1, -1, -1, -1, -1, -1, -1,
2012 -1, -1, -1, -1, -1, 597, 757, 599, -1, -1,
2013 638, -1, -1, 764, 642, 191, 192, 193, 194, -1,
2014 771, -1, 773, 199, 200, 776, -1, 778, -1, 780,
2015 -1, -1, -1, -1, -1, -1, 664, -1, -1, 191,
2016 192, 193, 194, -1, 672, -1, 638, 199, 200, -1,
2017 642, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2018 -1, 45, 46, 47, -1, -1, -1, 51, -1, -1,
2019 -1, -1, 664, -1, 702, -1, 60, 705, -1, -1,
2020 672, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2021 -1, -1, -1, 77, -1, -1, 724, -1, 726, -1,
2022 84, 729, -1, 87, 88, -1, -1, -1, -1, -1,
2023 702, 95, -1, 705, -1, 743, -1, -1, -1, -1,
2024 104, 105, 106, 107, -1, -1, 110, 111, -1, 757,
2025 -1, -1, 724, -1, 726, -1, 764, 729, -1, -1,
2026 -1, -1, -1, 771, -1, 773, -1, -1, 776, -1,
2027 778, 743, 780, -1, -1, -1, -1, -1, -1, -1,
2028 -1, -1, -1, -1, -1, 757, -1, -1, -1, -1,
2029 -1, -1, 764, -1, -1, -1, -1, -1, -1, 771,
2030 -1, 773, -1, -1, 776, -1, 778, -1, 780, -1,
2031 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2032 -1, -1, -1, 379, 380, 381, 382, 383, 384, 385,
2033 386, 387, 388, 389, 390, -1, 392, 393, 394, 395,
2034 396, 397, 398, 1, -1, -1, -1, 379, 380, 381,
2035 382, 383, 384, 385, 386, 387, 388, 389, 390, -1,
2036 392, 393, 394, 395, 396, 397, 398, -1, -1, -1,
2037 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2038 -1, -1, -1, -1, -1, -1, -1, 45, 46, 47,
2039 48, 49, 50, 51, 52, -1, -1, 55, -1, -1,
2040 -1, 59, 60, -1, -1, 63, -1, -1, 66, 67,
2041 68, 69, -1, 71, 72, 73, 74, 1, -1, 77,
2042 78, -1, -1, -1, -1, -1, 84, 483, -1, 87,
2043 88, -1, 488, -1, -1, -1, -1, 95, -1, 97,
2044 98, -1, -1, 101, -1, -1, 104, 105, 106, 107,
2045 -1, 483, 110, 111, -1, -1, 488, -1, -1, -1,
2046 -1, 45, 46, 47, 48, 49, 50, 51, 52, -1,
2047 -1, 55, -1, -1, -1, 59, 60, -1, -1, 63,
2048 -1, -1, 66, 67, 68, 69, -1, 71, 72, 73,
2049 74, -1, -1, 77, 78, -1, -1, -1, -1, -1,
2050 84, -1, -1, 87, 88, -1, -1, -1, -1, -1,
2051 -1, 95, -1, 97, 98, -1, -1, 101, -1, -1,
2052 104, 105, 106, 107, 1, -1, 110, 111, -1, -1,
2053 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2054 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2055 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2056 -1, -1, -1, 619, 620, -1, -1, -1, 45, 46,
2057 47, 48, 49, 50, 51, 52, -1, -1, 55, 635,
2058 -1, -1, 59, 60, -1, -1, 63, 619, 620, 66,
2059 67, 68, 69, 1, 71, 72, 73, 74, -1, -1,
2060 77, 78, -1, 635, -1, -1, -1, 84, -1, -1,
2061 87, 88, -1, -1, -1, -1, -1, -1, 95, -1,
2062 97, 98, -1, -1, 101, -1, -1, 104, 105, 106,
2063 107, -1, -1, 110, 111, -1, -1, 45, 46, 47,
2064 -1, 49, 50, 51, 52, -1, -1, 55, -1, -1,
2065 -1, 59, 60, -1, -1, -1, -1, -1, 66, 67,
2066 68, 69, 1, 71, 72, 73, 74, -1, -1, 77,
2067 78, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2068 88, -1, -1, -1, -1, -1, -1, 95, -1, 97,
2069 98, -1, -1, 101, -1, -1, 104, 105, 106, 107,
2070 -1, -1, 110, 111, -1, -1, 45, 46, 47, -1,
2071 49, 50, 51, 52, -1, -1, 55, -1, -1, -1,
2072 59, 60, -1, -1, -1, -1, -1, 66, 67, 1,
2073 69, -1, 71, 72, 73, 74, -1, -1, 77, 78,
2074 -1, -1, -1, -1, -1, 84, -1, -1, 87, 88,
2075 -1, -1, -1, -1, -1, -1, 95, -1, 97, -1,
2076 -1, -1, 101, -1, -1, 104, 105, 106, 107, -1,
2077 -1, 110, 111, 45, 46, 47, -1, 49, 50, 51,
2078 52, -1, -1, 55, -1, -1, -1, 59, 60, -1,
2079 -1, -1, -1, -1, 66, 67, -1, 69, -1, 71,
2080 72, 73, 74, -1, -1, 77, 78, 1, -1, 3,
2081 4, -1, 84, -1, -1, 87, 88, -1, -1, -1,
2082 -1, -1, -1, 95, -1, 97, -1, -1, -1, 101,
2083 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2084 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
2085 -1, -1, 46, 47, -1, -1, -1, 51, -1, -1,
2086 -1, -1, -1, -1, -1, -1, 60, -1, -1, -1,
2087 -1, -1, 66, 1, -1, 3, 4, -1, -1, 73,
2088 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2089 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2090 -1, 95, -1, 97, 98, -1, -1, -1, -1, -1,
2091 104, 105, 106, 107, -1, -1, 110, 111, 46, 47,
2092 -1, -1, -1, 51, -1, 1, -1, 3, 4, -1,
2093 -1, -1, 60, -1, -1, -1, -1, -1, 66, -1,
2094 -1, -1, -1, -1, -1, 73, -1, -1, -1, 77,
2095 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2096 88, -1, -1, 91, 92, -1, -1, 95, -1, 97,
2097 46, 47, -1, -1, -1, 51, 104, 105, 106, 107,
2098 -1, -1, 110, 111, 60, -1, -1, -1, -1, -1,
2099 66, 1, -1, 3, 4, -1, -1, 73, -1, -1,
2100 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2101 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2102 -1, -1, -1, -1, -1, 101, -1, -1, 104, 105,
2103 106, 107, -1, -1, 110, 111, 46, 47, -1, -1,
2104 -1, 51, -1, 1, -1, 3, 4, -1, -1, -1,
2105 60, -1, -1, -1, -1, -1, 66, -1, -1, -1,
2106 -1, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2107 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2108 -1, 91, 92, -1, -1, 95, -1, -1, 46, 47,
2109 100, -1, -1, 51, 104, 105, 106, 107, -1, -1,
2110 110, 111, 60, -1, -1, -1, -1, -1, 66, 1,
2111 -1, 3, 4, -1, -1, 73, -1, -1, -1, 77,
2112 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2113 88, -1, 90, 91, 92, -1, -1, 95, -1, -1,
2114 -1, -1, -1, -1, -1, -1, 104, 105, 106, 107,
2115 -1, -1, 110, 111, 46, 47, -1, -1, -1, 51,
2116 -1, 1, -1, 3, 4, -1, -1, -1, 60, -1,
2117 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2118 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2119 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2120 92, -1, -1, 95, 96, -1, 46, 47, -1, -1,
2121 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2122 60, -1, -1, -1, -1, -1, 66, 1, -1, 3,
2123 4, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2124 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2125 -1, 91, 92, -1, -1, 95, -1, -1, -1, -1,
2126 -1, 101, -1, -1, 104, 105, 106, 107, -1, -1,
2127 110, 111, 46, 47, -1, -1, -1, 51, -1, 1,
2128 -1, 3, 4, -1, -1, -1, 60, -1, -1, -1,
2129 -1, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2130 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2131 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2132 -1, 95, -1, -1, 46, 47, 100, -1, -1, 51,
2133 104, 105, 106, 107, -1, -1, 110, 111, 60, -1,
2134 -1, -1, -1, -1, 66, 1, -1, 3, 4, -1,
2135 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2136 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2137 92, -1, -1, 95, 96, -1, -1, -1, -1, -1,
2138 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2139 46, 47, -1, -1, -1, 51, -1, 1, -1, 3,
2140 4, -1, -1, -1, 60, -1, -1, -1, -1, -1,
2141 66, -1, -1, -1, -1, -1, -1, 73, -1, -1,
2142 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2143 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2144 96, -1, 46, 47, -1, -1, -1, 51, 104, 105,
2145 106, 107, -1, -1, 110, 111, 60, -1, -1, -1,
2146 -1, -1, 66, 1, -1, 3, 4, -1, -1, 73,
2147 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2148 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2149 -1, 95, 96, -1, -1, -1, -1, -1, -1, -1,
2150 104, 105, 106, 107, -1, -1, 110, 111, 46, 47,
2151 -1, -1, -1, 51, -1, 1, -1, 3, 4, -1,
2152 -1, -1, 60, -1, -1, -1, -1, -1, 66, -1,
2153 -1, -1, -1, -1, -1, 73, -1, -1, -1, 77,
2154 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2155 88, -1, -1, 91, 92, -1, -1, 95, 96, -1,
2156 46, 47, -1, -1, -1, 51, 104, 105, 106, 107,
2157 -1, -1, 110, 111, 60, -1, -1, -1, -1, -1,
2158 66, 1, -1, 3, 4, -1, -1, 73, -1, -1,
2159 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2160 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2161 -1, -1, -1, -1, -1, 101, -1, -1, 104, 105,
2162 106, 107, -1, -1, 110, 111, 46, 47, -1, -1,
2163 -1, 51, -1, 1, -1, 3, 4, -1, -1, -1,
2164 60, -1, -1, -1, -1, -1, 66, -1, -1, -1,
2165 -1, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2166 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2167 -1, 91, 92, -1, -1, 95, -1, -1, 46, 47,
2168 -1, -1, -1, 51, 104, 105, 106, 107, -1, -1,
2169 110, 111, 60, -1, -1, -1, -1, -1, 66, 1,
2170 -1, 3, 4, -1, -1, 73, -1, -1, -1, 77,
2171 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2172 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2173 -1, -1, -1, -1, -1, -1, 104, 105, 106, 107,
2174 -1, -1, 110, 111, 46, 47, -1, -1, -1, 51,
2175 -1, 1, -1, 3, 4, -1, -1, -1, 60, -1,
2176 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2177 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2178 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2179 92, -1, -1, 95, -1, -1, 46, 47, -1, -1,
2180 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2181 60, -1, -1, -1, -1, -1, 66, 1, -1, 3,
2182 4, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2183 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2184 -1, 91, 92, -1, -1, 95, -1, -1, -1, -1,
2185 -1, -1, -1, -1, 104, 105, 106, 107, -1, -1,
2186 110, 111, 46, 47, -1, -1, -1, 51, -1, 1,
2187 -1, 3, 4, -1, -1, -1, 60, -1, -1, -1,
2188 -1, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2189 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2190 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2191 -1, 95, -1, -1, 46, 47, -1, -1, -1, 51,
2192 104, 105, 106, 107, -1, -1, 110, 111, 60, -1,
2193 -1, -1, -1, -1, 66, 1, -1, 3, 4, -1,
2194 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2195 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2196 92, -1, -1, 95, -1, -1, -1, -1, -1, -1,
2197 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2198 46, 47, -1, -1, -1, 51, -1, 1, -1, 3,
2199 4, -1, -1, -1, 60, -1, -1, -1, -1, -1,
2200 66, -1, -1, -1, -1, -1, -1, 73, -1, -1,
2201 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2202 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2203 -1, -1, 46, 47, -1, -1, -1, 51, 104, 105,
2204 106, 107, -1, -1, 110, 111, 60, -1, -1, -1,
2205 -1, -1, 66, 1, -1, 3, 4, -1, -1, 73,
2206 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2207 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2208 -1, 95, -1, -1, -1, -1, -1, -1, -1, -1,
2209 104, 105, 106, 107, -1, -1, 110, 111, 46, 47,
2210 -1, -1, -1, 51, -1, 1, -1, 3, 4, -1,
2211 -1, -1, 60, -1, -1, -1, -1, -1, 66, -1,
2212 -1, -1, -1, -1, -1, 73, -1, -1, -1, 77,
2213 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2214 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2215 46, 47, -1, -1, -1, 51, 104, 105, 106, 107,
2216 -1, -1, 110, 111, 60, -1, -1, -1, -1, -1,
2217 66, 1, -1, 3, 4, -1, -1, 73, -1, -1,
2218 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2219 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2220 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
2221 106, 107, -1, -1, 110, 111, 46, 47, -1, -1,
2222 -1, 51, -1, 1, -1, 3, 4, -1, -1, -1,
2223 60, -1, -1, -1, -1, -1, 66, -1, -1, -1,
2224 -1, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2225 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2226 -1, 91, 92, -1, -1, 95, -1, -1, 46, 47,
2227 -1, -1, -1, 51, 104, 105, 106, 107, -1, -1,
2228 110, 111, 60, -1, -1, -1, -1, -1, 66, 1,
2229 -1, 3, 4, -1, -1, 73, -1, -1, -1, 77,
2230 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2231 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2232 -1, -1, -1, -1, -1, -1, 104, 105, 106, 107,
2233 -1, -1, 110, 111, 46, 47, -1, -1, -1, 51,
2234 -1, 1, -1, 3, 4, -1, -1, -1, 60, -1,
2235 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2236 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2237 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2238 92, -1, -1, 95, -1, -1, 46, 47, -1, -1,
2239 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2240 60, -1, -1, -1, -1, -1, 66, 1, -1, 3,
2241 4, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2242 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2243 -1, 91, 92, -1, -1, 95, -1, -1, -1, -1,
2244 -1, -1, -1, -1, 104, 105, 106, 107, -1, -1,
2245 110, 111, 46, 47, -1, -1, -1, 51, -1, 1,
2246 -1, 3, 4, -1, -1, -1, 60, -1, -1, -1,
2247 -1, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2248 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2249 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2250 -1, 95, -1, -1, 46, 47, -1, -1, -1, 51,
2251 104, 105, 106, 107, -1, -1, 110, 111, 60, -1,
2252 -1, -1, -1, -1, 66, 1, -1, 3, 4, -1,
2253 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2254 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2255 92, -1, -1, 95, -1, -1, -1, -1, -1, -1,
2256 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2257 46, 47, -1, -1, -1, 51, -1, 1, -1, 3,
2258 4, -1, -1, -1, 60, -1, -1, -1, -1, -1,
2259 66, -1, -1, -1, -1, -1, -1, 73, -1, -1,
2260 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2261 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2262 -1, -1, 46, 47, -1, -1, -1, 51, 104, 105,
2263 106, 107, -1, -1, 110, 111, 60, -1, -1, -1,
2264 -1, -1, 66, 1, -1, 3, 4, -1, -1, 73,
2265 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2266 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2267 -1, 95, -1, -1, -1, -1, -1, -1, -1, -1,
2268 104, 105, 106, 107, -1, -1, 110, 111, 46, 47,
2269 -1, -1, -1, 51, -1, 1, -1, 3, 4, -1,
2270 -1, -1, 60, -1, -1, -1, -1, -1, 66, -1,
2271 -1, -1, -1, -1, -1, 73, -1, -1, -1, 77,
2272 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2273 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2274 46, 47, -1, -1, -1, 51, 104, 105, 106, 107,
2275 -1, -1, 110, 111, 60, -1, -1, -1, -1, -1,
2276 66, 1, -1, 3, 4, -1, -1, 73, -1, -1,
2277 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2278 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2279 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
2280 106, 107, -1, -1, 110, 111, 46, 47, -1, -1,
2281 -1, 51, -1, 1, -1, 3, 4, -1, -1, -1,
2282 60, -1, -1, -1, -1, -1, 66, -1, -1, -1,
2283 -1, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2284 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2285 -1, 91, 92, -1, -1, 95, -1, -1, 46, 47,
2286 -1, -1, -1, 51, 104, 105, 106, 107, -1, -1,
2287 110, 111, 60, -1, -1, -1, -1, -1, 66, 1,
2288 -1, 3, 4, -1, -1, 73, -1, -1, -1, 77,
2289 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2290 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2291 -1, -1, -1, -1, -1, -1, 104, 105, 106, 107,
2292 -1, -1, 110, 111, 46, 47, -1, -1, -1, 51,
2293 -1, 1, -1, 3, 4, -1, -1, -1, 60, -1,
2294 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2295 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2296 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2297 92, -1, -1, 95, -1, -1, 46, 47, -1, -1,
2298 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2299 60, -1, -1, -1, -1, -1, 66, 1, -1, 3,
2300 4, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2301 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2302 -1, 91, 92, -1, -1, 95, -1, -1, -1, -1,
2303 -1, -1, -1, -1, 104, 105, 106, 107, -1, -1,
2304 110, 111, 46, 47, -1, -1, -1, 51, -1, 1,
2305 -1, 3, 4, -1, -1, -1, 60, -1, -1, -1,
2306 -1, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2307 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2308 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2309 -1, 95, -1, -1, 46, 47, -1, -1, -1, 51,
2310 104, 105, 106, 107, -1, -1, 110, 111, 60, -1,
2311 -1, -1, -1, -1, 66, 1, -1, 3, 4, -1,
2312 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2313 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2314 92, -1, -1, 95, -1, -1, -1, -1, -1, -1,
2315 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2316 46, 47, -1, -1, -1, 51, -1, 1, -1, 3,
2317 4, -1, -1, -1, 60, -1, -1, -1, -1, -1,
2318 66, -1, -1, -1, -1, -1, -1, 73, -1, -1,
2319 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2320 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2321 -1, -1, 46, 47, -1, -1, -1, 51, 104, 105,
2322 106, 107, -1, -1, 110, 111, 60, -1, -1, -1,
2323 -1, -1, 66, 1, -1, 3, 4, -1, -1, 73,
2324 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2325 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2326 -1, 95, -1, -1, -1, -1, -1, -1, -1, -1,
2327 104, 105, 106, 107, -1, -1, 110, 111, 46, 47,
2328 -1, -1, -1, 51, -1, 1, -1, 3, 4, -1,
2329 -1, -1, 60, -1, -1, -1, -1, -1, 66, -1,
2330 -1, -1, -1, -1, -1, 73, -1, -1, -1, 77,
2331 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2332 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2333 46, 47, -1, -1, -1, 51, 104, 105, 106, 107,
2334 -1, -1, 110, 111, 60, -1, -1, -1, -1, -1,
2335 66, 1, -1, 3, 4, -1, -1, 73, -1, -1,
2336 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2337 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2338 -1, -1, -1, -1, -1, -1, -1, -1, 104, 105,
2339 106, 107, -1, -1, 110, 111, 46, 47, -1, -1,
2340 -1, 51, -1, 1, -1, 3, 4, -1, -1, -1,
2341 60, -1, -1, -1, -1, -1, 66, -1, -1, -1,
2342 -1, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2343 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2344 -1, 91, 92, -1, -1, 95, -1, -1, 46, 47,
2345 -1, -1, -1, 51, 104, 105, 106, 107, -1, -1,
2346 110, 111, 60, -1, -1, -1, -1, -1, 66, 1,
2347 -1, 3, 4, -1, -1, 73, -1, -1, -1, 77,
2348 -1, -1, -1, -1, -1, -1, 84, -1, -1, 87,
2349 88, -1, -1, 91, 92, -1, -1, 95, -1, -1,
2350 -1, -1, -1, -1, -1, -1, 104, 105, 106, 107,
2351 -1, -1, 110, 111, 46, 47, -1, -1, -1, 51,
2352 -1, 1, -1, 3, 4, -1, -1, -1, 60, -1,
2353 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2354 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2355 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2356 92, -1, -1, 95, -1, -1, 46, 47, -1, -1,
2357 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2358 60, -1, -1, -1, -1, -1, 66, 1, -1, 3,
2359 4, -1, -1, 73, -1, -1, -1, 77, -1, -1,
2360 -1, -1, -1, -1, 84, -1, -1, 87, 88, -1,
2361 -1, 91, 92, -1, -1, 95, -1, -1, -1, -1,
2362 -1, -1, -1, -1, 104, 105, 106, 107, -1, -1,
2363 110, 111, 46, 47, -1, -1, -1, 51, -1, 1,
2364 -1, 3, 4, -1, -1, -1, 60, -1, -1, -1,
2365 -1, -1, 66, -1, -1, -1, -1, -1, -1, 73,
2366 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2367 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2368 -1, 95, -1, -1, 46, 47, -1, -1, -1, 51,
2369 104, 105, 106, 107, -1, -1, 110, 111, 60, -1,
2370 -1, -1, -1, -1, 66, 1, -1, 3, 4, -1,
2371 -1, 73, -1, -1, -1, 77, -1, -1, -1, -1,
2372 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2373 92, -1, -1, 95, -1, -1, -1, -1, -1, -1,
2374 -1, -1, 104, 105, 106, 107, -1, -1, 110, 111,
2375 46, 47, -1, -1, -1, 51, -1, 1, -1, 3,
2376 4, -1, -1, -1, 60, -1, -1, -1, -1, -1,
2377 66, -1, -1, -1, -1, -1, -1, 73, -1, -1,
2378 -1, 77, -1, -1, -1, -1, -1, -1, 84, -1,
2379 -1, 87, 88, -1, -1, 91, 92, -1, -1, 95,
2380 -1, -1, 46, 47, -1, -1, -1, 51, 104, 105,
2381 106, 107, -1, -1, 110, 111, 60, -1, -1, 1,
2382 -1, 3, 66, -1, -1, -1, -1, -1, -1, 73,
2383 -1, -1, -1, 77, -1, -1, -1, -1, -1, -1,
2384 84, -1, -1, 87, 88, -1, -1, 91, 92, -1,
2385 -1, 95, -1, -1, -1, -1, -1, -1, -1, -1,
2386 104, 105, 106, 107, 46, 47, 110, 111, -1, 51,
2387 -1, 1, -1, -1, -1, -1, -1, -1, 60, -1,
2388 -1, -1, -1, -1, 66, -1, -1, -1, -1, -1,
2389 -1, 73, -1, -1, -1, 77, 1, -1, -1, -1,
2390 -1, -1, 84, -1, -1, 87, 88, -1, -1, 91,
2391 92, -1, -1, 95, -1, 45, 46, 47, -1, -1,
2392 -1, 51, 104, 105, 106, 107, -1, -1, 110, 111,
2393 60, -1, -1, -1, -1, -1, 66, -1, -1, 1,
2394 -1, 46, 47, 73, -1, -1, 51, 77, -1, -1,
2395 -1, -1, -1, -1, 84, 60, -1, 87, 88, -1,
2396 -1, 66, -1, -1, 1, 95, -1, -1, 73, -1,
2397 -1, 101, 77, -1, 104, 105, 106, 107, -1, 84,
2398 110, 111, 87, 88, 46, 47, -1, -1, -1, 51,
2399 95, 96, -1, -1, -1, -1, -1, -1, 60, 104,
2400 105, 106, 107, -1, 66, 110, 111, -1, -1, 46,
2401 47, 73, -1, -1, 51, 77, -1, -1, 3, 4,
2402 -1, -1, 84, 60, -1, 87, 88, -1, -1, 66,
2403 -1, -1, -1, 95, 96, -1, 73, -1, -1, -1,
2404 77, -1, 104, 105, 106, 107, -1, 84, 110, 111,
2405 87, 88, -1, -1, -1, -1, -1, -1, 95, -1,
2406 -1, 46, 47, -1, -1, -1, 51, 104, 105, 106,
2407 107, -1, -1, 110, 111, 60, -1, -1, -1, -1,
2408 -1, 66, -1, -1, 3, 4, -1, -1, 73, -1,
2409 -1, -1, 77, -1, -1, -1, -1, -1, -1, 84,
2410 -1, -1, 87, 88, -1, -1, 91, 92, -1, -1,
2411 95, -1, 97, 98, -1, -1, -1, 102, -1, 104,
2412 105, 106, 107, -1, -1, 110, 111, 46, 47, -1,
2413 -1, -1, 51, -1, -1, -1, 3, 4, -1, -1,
2414 -1, 60, -1, -1, -1, -1, -1, 66, -1, -1,
2415 -1, -1, -1, -1, 73, -1, -1, -1, 77, -1,
2416 -1, -1, -1, -1, -1, 84, -1, -1, 87, 88,
2417 -1, -1, 91, 92, -1, -1, 95, 96, -1, 46,
2418 47, -1, -1, -1, 51, 104, 105, 106, 107, -1,
2419 -1, 110, 111, 60, -1, -1, -1, -1, -1, 66,
2420 -1, -1, 3, 4, -1, -1, 73, -1, -1, -1,
2421 77, -1, -1, -1, -1, -1, -1, 84, -1, -1,
2422 87, 88, -1, -1, 91, 92, -1, -1, 95, 96,
2423 -1, -1, -1, -1, -1, -1, -1, 104, 105, 106,
2424 107, -1, -1, 110, 111, 46, 47, -1, -1, -1,
2425 51, -1, -1, -1, 3, 4, -1, -1, -1, 60,
2426 -1, -1, -1, -1, -1, 66, -1, -1, -1, -1,
2427 -1, -1, 73, -1, -1, -1, 77, -1, -1, -1,
2428 -1, -1, -1, 84, -1, -1, 87, 88, -1, -1,
2429 91, 92, -1, -1, 95, 96, -1, 46, 47, -1,
2430 -1, -1, 51, 104, 105, 106, 107, -1, -1, 110,
2431 111, 60, -1, -1, -1, -1, -1, 66, -1, -1,
2432 3, 4, -1, -1, 73, -1, -1, -1, 77, -1,
2433 -1, -1, -1, -1, -1, 84, -1, -1, 87, 88,
2434 -1, -1, 91, 92, -1, -1, 95, 96, -1, -1,
2435 -1, -1, -1, -1, -1, 104, 105, 106, 107, -1,
2436 -1, 110, 111, 46, 47, -1, -1, -1, 51, -1,
2437 -1, -1, -1, -1, -1, -1, -1, 60, -1, -1,
2438 -1, -1, -1, 66, -1, -1, -1, -1, -1, -1,
2439 73, -1, -1, -1, 77, -1, -1, -1, -1, -1,
2440 -1, 84, -1, -1, 87, 88, -1, -1, 91, 92,
2441 51, -1, 95, -1, -1, -1, -1, -1, -1, 60,
2442 -1, 104, 105, 106, 107, 66, -1, 110, 111, -1,
2443 -1, -1, 73, -1, -1, -1, 77, -1, -1, -1,
2444 -1, -1, -1, 84, -1, -1, 87, 88, -1, -1,
2445 91, 92, -1, -1, 95, -1, -1, -1, -1, -1,
2446 -1, -1, -1, 104, 105, 106, 107, -1, -1, 110,
2447 111
2448 };
2449 #define YYPURE 1
2450
2451 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2452 #line 3 "/usr/share/bison/bison.simple"
2453
2454 /* Skeleton output parser for bison,
2455
2456 Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software
2457 Foundation, Inc.
2458
2459 This program is free software; you can redistribute it and/or modify
2460 it under the terms of the GNU General Public License as published by
2461 the Free Software Foundation; either version 2, or (at your option)
2462 any later version.
2463
2464 This program is distributed in the hope that it will be useful,
2465 but WITHOUT ANY WARRANTY; without even the implied warranty of
2466 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2467 GNU General Public License for more details.
2468
2469 You should have received a copy of the GNU General Public License
2470 along with this program; if not, write to the Free Software
2471 Foundation, Inc., 59 Temple Place - Suite 330,
2472 Boston, MA 02111-1307, USA. */
2473
2474 /* As a special exception, when this file is copied by Bison into a
2475 Bison output file, you may use that output file without restriction.
2476 This special exception was added by the Free Software Foundation
2477 in version 1.24 of Bison. */
2478
2479 /* This is the parser code that is written into each bison parser when
2480 the %semantic_parser declaration is not specified in the grammar.
2481 It was written by Richard Stallman by simplifying the hairy parser
2482 used when %semantic_parser is specified. */
2483
2484 /* All symbols defined below should begin with yy or YY, to avoid
2485 infringing on user name space. This should be done even for local
2486 variables, as they might otherwise be expanded by user macros.
2487 There are some unavoidable exceptions within include files to
2488 define necessary library symbols; they are noted "INFRINGES ON
2489 USER NAME SPACE" below. */
2490
2491 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
2492
2493 /* The parser invokes alloca or malloc; define the necessary symbols. */
2494
2495 # if YYSTACK_USE_ALLOCA
2496 # define YYSTACK_ALLOC alloca
2497 # else
2498 # ifndef YYSTACK_USE_ALLOCA
2499 # if defined (alloca) || defined (_ALLOCA_H)
2500 # define YYSTACK_ALLOC alloca
2501 # else
2502 # ifdef __GNUC__
2503 # define YYSTACK_ALLOC __builtin_alloca
2504 # endif
2505 # endif
2506 # endif
2507 # endif
2508
2509 # ifdef YYSTACK_ALLOC
2510 /* Pacify GCC's `empty if-body' warning. */
2511 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
2512 # else
2513 # if defined (__STDC__) || defined (__cplusplus)
2514 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
2515 # define YYSIZE_T size_t
2516 # endif
2517 # define YYSTACK_ALLOC malloc
2518 # define YYSTACK_FREE free
2519 # endif
2520 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
2521
2522
2523 #if (! defined (yyoverflow) \
2524 && (! defined (__cplusplus) \
2525 || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
2526
2527 /* A type that is properly aligned for any stack member. */
2528 union yyalloc
2529 {
2530 short yyss;
2531 YYSTYPE yyvs;
2532 # if YYLSP_NEEDED
2533 YYLTYPE yyls;
2534 # endif
2535 };
2536
2537 /* The size of the maximum gap between one aligned stack and the next. */
2538 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
2539
2540 /* The size of an array large to enough to hold all stacks, each with
2541 N elements. */
2542 # if YYLSP_NEEDED
2543 # define YYSTACK_BYTES(N) \
2544 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
2545 + 2 * YYSTACK_GAP_MAX)
2546 # else
2547 # define YYSTACK_BYTES(N) \
2548 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
2549 + YYSTACK_GAP_MAX)
2550 # endif
2551
2552 /* Copy COUNT objects from FROM to TO. The source and destination do
2553 not overlap. */
2554 # ifndef YYCOPY
2555 # if 1 < __GNUC__
2556 # define YYCOPY(To, From, Count) \
2557 __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
2558 # else
2559 # define YYCOPY(To, From, Count) \
2560 do \
2561 { \
2562 register YYSIZE_T yyi; \
2563 for (yyi = 0; yyi < (Count); yyi++) \
2564 (To)[yyi] = (From)[yyi]; \
2565 } \
2566 while (0)
2567 # endif
2568 # endif
2569
2570 /* Relocate STACK from its old location to the new one. The
2571 local variables YYSIZE and YYSTACKSIZE give the old and new number of
2572 elements in the stack, and YYPTR gives the new location of the
2573 stack. Advance YYPTR to a properly aligned location for the next
2574 stack. */
2575 # define YYSTACK_RELOCATE(Stack) \
2576 do \
2577 { \
2578 YYSIZE_T yynewbytes; \
2579 YYCOPY (&yyptr->Stack, Stack, yysize); \
2580 Stack = &yyptr->Stack; \
2581 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAX; \
2582 yyptr += yynewbytes / sizeof (*yyptr); \
2583 } \
2584 while (0)
2585
2586 #endif
2587
2588
2589 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
2590 # define YYSIZE_T __SIZE_TYPE__
2591 #endif
2592 #if ! defined (YYSIZE_T) && defined (size_t)
2593 # define YYSIZE_T size_t
2594 #endif
2595 #if ! defined (YYSIZE_T)
2596 # if defined (__STDC__) || defined (__cplusplus)
2597 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
2598 # define YYSIZE_T size_t
2599 # endif
2600 #endif
2601 #if ! defined (YYSIZE_T)
2602 # define YYSIZE_T unsigned int
2603 #endif
2604
2605 #define yyerrok (yyerrstatus = 0)
2606 #define yyclearin (yychar = YYEMPTY)
2607 #define YYEMPTY -2
2608 #define YYEOF 0
2609 #define YYACCEPT goto yyacceptlab
2610 #define YYABORT goto yyabortlab
2611 #define YYERROR goto yyerrlab1
2612 /* Like YYERROR except do call yyerror. This remains here temporarily
2613 to ease the transition to the new meaning of YYERROR, for GCC.
2614 Once GCC version 2 has supplanted version 1, this can go. */
2615 #define YYFAIL goto yyerrlab
2616 #define YYRECOVERING() (!!yyerrstatus)
2617 #define YYBACKUP(Token, Value) \
2618 do \
2619 if (yychar == YYEMPTY && yylen == 1) \
2620 { \
2621 yychar = (Token); \
2622 yylval = (Value); \
2623 yychar1 = YYTRANSLATE (yychar); \
2624 YYPOPSTACK; \
2625 goto yybackup; \
2626 } \
2627 else \
2628 { \
2629 yyerror ("syntax error: cannot back up"); \
2630 YYERROR; \
2631 } \
2632 while (0)
2633
2634 #define YYTERROR 1
2635 #define YYERRCODE 256
2636
2637
2638 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
2639 are run).
2640
2641 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
2642 first token. By default, to implement support for ranges, extend
2643 its range to the last symbol. */
2644
2645 #ifndef YYLLOC_DEFAULT
2646 # define YYLLOC_DEFAULT(Current, Rhs, N) \
2647 Current.last_line = Rhs[N].last_line; \
2648 Current.last_column = Rhs[N].last_column;
2649 #endif
2650
2651
2652 /* YYLEX -- calling `yylex' with the right arguments. */
2653
2654 #if YYPURE
2655 # if YYLSP_NEEDED
2656 # ifdef YYLEX_PARAM
2657 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
2658 # else
2659 # define YYLEX yylex (&yylval, &yylloc)
2660 # endif
2661 # else /* !YYLSP_NEEDED */
2662 # ifdef YYLEX_PARAM
2663 # define YYLEX yylex (&yylval, YYLEX_PARAM)
2664 # else
2665 # define YYLEX yylex (&yylval)
2666 # endif
2667 # endif /* !YYLSP_NEEDED */
2668 #else /* !YYPURE */
2669 # define YYLEX yylex ()
2670 #endif /* !YYPURE */
2671
2672
2673 /* Enable debugging if requested. */
2674 #if YYDEBUG
2675
2676 # ifndef YYFPRINTF
2677 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
2678 # define YYFPRINTF fprintf
2679 # endif
2680
2681 # define YYDPRINTF(Args) \
2682 do { \
2683 if (yydebug) \
2684 YYFPRINTF Args; \
2685 } while (0)
2686 /* Nonzero means print parse trace. It is left uninitialized so that
2687 multiple parsers can coexist. */
2688 int yydebug;
2689 #else /* !YYDEBUG */
2690 # define YYDPRINTF(Args)
2691 #endif /* !YYDEBUG */
2692
2693 /* YYINITDEPTH -- initial size of the parser's stacks. */
2694 #ifndef YYINITDEPTH
2695 # define YYINITDEPTH 200
2696 #endif
2697
2698 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
2699 if the built-in stack extension method is used).
2700
2701 Do not make this value too large; the results are undefined if
2702 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
2703 evaluated with infinite-precision integer arithmetic. */
2704
2705 #if YYMAXDEPTH == 0
2706 # undef YYMAXDEPTH
2707 #endif
2708
2709 #ifndef YYMAXDEPTH
2710 # define YYMAXDEPTH 10000
2711 #endif
2712
2713 #ifdef YYERROR_VERBOSE
2714
2715 # ifndef yystrlen
2716 # if defined (__GLIBC__) && defined (_STRING_H)
2717 # define yystrlen strlen
2718 # else
2719 /* Return the length of YYSTR. */
2720 static YYSIZE_T
2721 # if defined (__STDC__) || defined (__cplusplus)
yystrlen(const char * yystr)2722 yystrlen (const char *yystr)
2723 # else
2724 yystrlen (yystr)
2725 const char *yystr;
2726 # endif
2727 {
2728 register const char *yys = yystr;
2729
2730 while (*yys++ != '\0')
2731 continue;
2732
2733 return yys - yystr - 1;
2734 }
2735 # endif
2736 # endif
2737
2738 # ifndef yystpcpy
2739 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
2740 # define yystpcpy stpcpy
2741 # else
2742 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
2743 YYDEST. */
2744 static char *
2745 # if defined (__STDC__) || defined (__cplusplus)
yystpcpy(char * yydest,const char * yysrc)2746 yystpcpy (char *yydest, const char *yysrc)
2747 # else
2748 yystpcpy (yydest, yysrc)
2749 char *yydest;
2750 const char *yysrc;
2751 # endif
2752 {
2753 register char *yyd = yydest;
2754 register const char *yys = yysrc;
2755
2756 while ((*yyd++ = *yys++) != '\0')
2757 continue;
2758
2759 return yyd - 1;
2760 }
2761 # endif
2762 # endif
2763 #endif
2764
2765 #line 315 "/usr/share/bison/bison.simple"
2766
2767
2768 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2769 into yyparse. The argument should have type void *.
2770 It should actually point to an object.
2771 Grammar actions can access the variable by casting it
2772 to the proper pointer type. */
2773
2774 #ifdef YYPARSE_PARAM
2775 # if defined (__STDC__) || defined (__cplusplus)
2776 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2777 # define YYPARSE_PARAM_DECL
2778 # else
2779 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
2780 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2781 # endif
2782 #else /* !YYPARSE_PARAM */
2783 # define YYPARSE_PARAM_ARG
2784 # define YYPARSE_PARAM_DECL
2785 #endif /* !YYPARSE_PARAM */
2786
2787 /* Prevent warning if -Wstrict-prototypes. */
2788 #ifdef __GNUC__
2789 # ifdef YYPARSE_PARAM
2790 int yyparse (void *);
2791 # else
2792 int yyparse (void);
2793 # endif
2794 #endif
2795
2796 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
2797 variables are global, or local to YYPARSE. */
2798
2799 #define YY_DECL_NON_LSP_VARIABLES \
2800 /* The lookahead symbol. */ \
2801 int yychar; \
2802 \
2803 /* The semantic value of the lookahead symbol. */ \
2804 YYSTYPE yylval; \
2805 \
2806 /* Number of parse errors so far. */ \
2807 int yynerrs;
2808
2809 #if YYLSP_NEEDED
2810 # define YY_DECL_VARIABLES \
2811 YY_DECL_NON_LSP_VARIABLES \
2812 \
2813 /* Location data for the lookahead symbol. */ \
2814 YYLTYPE yylloc;
2815 #else
2816 # define YY_DECL_VARIABLES \
2817 YY_DECL_NON_LSP_VARIABLES
2818 #endif
2819
2820
2821 /* If nonreentrant, generate the variables here. */
2822
2823 #if !YYPURE
2824 YY_DECL_VARIABLES
2825 #endif /* !YYPURE */
2826
2827 int
yyparse(YYPARSE_PARAM_ARG)2828 yyparse (YYPARSE_PARAM_ARG)
2829 YYPARSE_PARAM_DECL
2830 {
2831 /* If reentrant, generate the variables here. */
2832 #if YYPURE
2833 YY_DECL_VARIABLES
2834 #endif /* !YYPURE */
2835
2836 register int yystate;
2837 register int yyn;
2838 int yyresult;
2839 /* Number of tokens to shift before error messages enabled. */
2840 int yyerrstatus;
2841 /* Lookahead token as an internal (translated) token number. */
2842 int yychar1 = 0;
2843
2844 /* Three stacks and their tools:
2845 `yyss': related to states,
2846 `yyvs': related to semantic values,
2847 `yyls': related to locations.
2848
2849 Refer to the stacks thru separate pointers, to allow yyoverflow
2850 to reallocate them elsewhere. */
2851
2852 /* The state stack. */
2853 short yyssa[YYINITDEPTH];
2854 short *yyss = yyssa;
2855 register short *yyssp;
2856
2857 /* The semantic value stack. */
2858 YYSTYPE yyvsa[YYINITDEPTH];
2859 YYSTYPE *yyvs = yyvsa;
2860 register YYSTYPE *yyvsp;
2861
2862 #if YYLSP_NEEDED
2863 /* The location stack. */
2864 YYLTYPE yylsa[YYINITDEPTH];
2865 YYLTYPE *yyls = yylsa;
2866 YYLTYPE *yylsp;
2867 #endif
2868
2869 #if YYLSP_NEEDED
2870 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2871 #else
2872 # define YYPOPSTACK (yyvsp--, yyssp--)
2873 #endif
2874
2875 YYSIZE_T yystacksize = YYINITDEPTH;
2876
2877
2878 /* The variables used to return semantic value and location from the
2879 action routines. */
2880 YYSTYPE yyval;
2881 #if YYLSP_NEEDED
2882 YYLTYPE yyloc;
2883 #endif
2884
2885 /* When reducing, the number of symbols on the RHS of the reduced
2886 rule. */
2887 int yylen;
2888
2889 YYDPRINTF ((stderr, "Starting parse\n"));
2890
2891 yystate = 0;
2892 yyerrstatus = 0;
2893 yynerrs = 0;
2894 yychar = YYEMPTY; /* Cause a token to be read. */
2895
2896 /* Initialize stack pointers.
2897 Waste one element of value and location stack
2898 so that they stay on the same level as the state stack.
2899 The wasted elements are never initialized. */
2900
2901 yyssp = yyss;
2902 yyvsp = yyvs;
2903 #if YYLSP_NEEDED
2904 yylsp = yyls;
2905 #endif
2906 goto yysetstate;
2907
2908 /*------------------------------------------------------------.
2909 | yynewstate -- Push a new state, which is found in yystate. |
2910 `------------------------------------------------------------*/
2911 yynewstate:
2912 /* In all cases, when you get here, the value and location stacks
2913 have just been pushed. so pushing a state here evens the stacks.
2914 */
2915 yyssp++;
2916
2917 yysetstate:
2918 *yyssp = yystate;
2919
2920 if (yyssp >= yyss + yystacksize - 1)
2921 {
2922 /* Get the current used size of the three stacks, in elements. */
2923 YYSIZE_T yysize = yyssp - yyss + 1;
2924
2925 #ifdef yyoverflow
2926 {
2927 /* Give user a chance to reallocate the stack. Use copies of
2928 these so that the &'s don't force the real ones into
2929 memory. */
2930 YYSTYPE *yyvs1 = yyvs;
2931 short *yyss1 = yyss;
2932
2933 /* Each stack pointer address is followed by the size of the
2934 data in use in that stack, in bytes. */
2935 # if YYLSP_NEEDED
2936 YYLTYPE *yyls1 = yyls;
2937 /* This used to be a conditional around just the two extra args,
2938 but that might be undefined if yyoverflow is a macro. */
2939 yyoverflow ("parser stack overflow",
2940 &yyss1, yysize * sizeof (*yyssp),
2941 &yyvs1, yysize * sizeof (*yyvsp),
2942 &yyls1, yysize * sizeof (*yylsp),
2943 &yystacksize);
2944 yyls = yyls1;
2945 # else
2946 yyoverflow ("parser stack overflow",
2947 &yyss1, yysize * sizeof (*yyssp),
2948 &yyvs1, yysize * sizeof (*yyvsp),
2949 &yystacksize);
2950 # endif
2951 yyss = yyss1;
2952 yyvs = yyvs1;
2953 }
2954 #else /* no yyoverflow */
2955 # ifndef YYSTACK_RELOCATE
2956 goto yyoverflowlab;
2957 # else
2958 /* Extend the stack our own way. */
2959 if (yystacksize >= YYMAXDEPTH)
2960 goto yyoverflowlab;
2961 yystacksize *= 2;
2962 if (yystacksize > YYMAXDEPTH)
2963 yystacksize = YYMAXDEPTH;
2964
2965 {
2966 short *yyss1 = yyss;
2967 union yyalloc *yyptr =
2968 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
2969 if (! yyptr)
2970 goto yyoverflowlab;
2971 YYSTACK_RELOCATE (yyss);
2972 YYSTACK_RELOCATE (yyvs);
2973 # if YYLSP_NEEDED
2974 YYSTACK_RELOCATE (yyls);
2975 # endif
2976 # undef YYSTACK_RELOCATE
2977 if (yyss1 != yyssa)
2978 YYSTACK_FREE (yyss1);
2979 }
2980 # endif
2981 #endif /* no yyoverflow */
2982
2983 yyssp = yyss + yysize - 1;
2984 yyvsp = yyvs + yysize - 1;
2985 #if YYLSP_NEEDED
2986 yylsp = yyls + yysize - 1;
2987 #endif
2988
2989 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
2990 (unsigned long int) yystacksize));
2991
2992 if (yyssp >= yyss + yystacksize - 1)
2993 YYABORT;
2994 }
2995
2996 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
2997
2998 goto yybackup;
2999
3000
3001 /*-----------.
3002 | yybackup. |
3003 `-----------*/
3004 yybackup:
3005
3006 /* Do appropriate processing given the current state. */
3007 /* Read a lookahead token if we need one and don't already have one. */
3008 /* yyresume: */
3009
3010 /* First try to decide what to do without reference to lookahead token. */
3011
3012 yyn = yypact[yystate];
3013 if (yyn == YYFLAG)
3014 goto yydefault;
3015
3016 /* Not known => get a lookahead token if don't already have one. */
3017
3018 /* yychar is either YYEMPTY or YYEOF
3019 or a valid token in external form. */
3020
3021 if (yychar == YYEMPTY)
3022 {
3023 YYDPRINTF ((stderr, "Reading a token: "));
3024 yychar = YYLEX;
3025 }
3026
3027 /* Convert token to internal form (in yychar1) for indexing tables with */
3028
3029 if (yychar <= 0) /* This means end of input. */
3030 {
3031 yychar1 = 0;
3032 yychar = YYEOF; /* Don't call YYLEX any more */
3033
3034 YYDPRINTF ((stderr, "Now at end of input.\n"));
3035 }
3036 else
3037 {
3038 yychar1 = YYTRANSLATE (yychar);
3039
3040 #if YYDEBUG
3041 /* We have to keep this `#if YYDEBUG', since we use variables
3042 which are defined only if `YYDEBUG' is set. */
3043 if (yydebug)
3044 {
3045 YYFPRINTF (stderr, "Next token is %d (%s",
3046 yychar, yytname[yychar1]);
3047 /* Give the individual parser a way to print the precise
3048 meaning of a token, for further debugging info. */
3049 # ifdef YYPRINT
3050 YYPRINT (stderr, yychar, yylval);
3051 # endif
3052 YYFPRINTF (stderr, ")\n");
3053 }
3054 #endif
3055 }
3056
3057 yyn += yychar1;
3058 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
3059 goto yydefault;
3060
3061 yyn = yytable[yyn];
3062
3063 /* yyn is what to do for this token type in this state.
3064 Negative => reduce, -yyn is rule number.
3065 Positive => shift, yyn is new state.
3066 New state is final state => don't bother to shift,
3067 just return success.
3068 0, or most negative number => error. */
3069
3070 if (yyn < 0)
3071 {
3072 if (yyn == YYFLAG)
3073 goto yyerrlab;
3074 yyn = -yyn;
3075 goto yyreduce;
3076 }
3077 else if (yyn == 0)
3078 goto yyerrlab;
3079
3080 if (yyn == YYFINAL)
3081 YYACCEPT;
3082
3083 /* Shift the lookahead token. */
3084 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
3085 yychar, yytname[yychar1]));
3086
3087 /* Discard the token being shifted unless it is eof. */
3088 if (yychar != YYEOF)
3089 yychar = YYEMPTY;
3090
3091 *++yyvsp = yylval;
3092 #if YYLSP_NEEDED
3093 *++yylsp = yylloc;
3094 #endif
3095
3096 /* Count tokens shifted since error; after three, turn off error
3097 status. */
3098 if (yyerrstatus)
3099 yyerrstatus--;
3100
3101 yystate = yyn;
3102 goto yynewstate;
3103
3104
3105 /*-----------------------------------------------------------.
3106 | yydefault -- do the default action for the current state. |
3107 `-----------------------------------------------------------*/
3108 yydefault:
3109 yyn = yydefact[yystate];
3110 if (yyn == 0)
3111 goto yyerrlab;
3112 goto yyreduce;
3113
3114
3115 /*-----------------------------.
3116 | yyreduce -- Do a reduction. |
3117 `-----------------------------*/
3118 yyreduce:
3119 /* yyn is the number of a rule to reduce with. */
3120 yylen = yyr2[yyn];
3121
3122 /* If YYLEN is nonzero, implement the default value of the action:
3123 `$$ = $1'.
3124
3125 Otherwise, the following line sets YYVAL to the semantic value of
3126 the lookahead token. This behavior is undocumented and Bison
3127 users should not rely upon it. Assigning to YYVAL
3128 unconditionally makes the parser a bit smaller, and it avoids a
3129 GCC warning that YYVAL may be used uninitialized. */
3130 yyval = yyvsp[1-yylen];
3131
3132 #if YYLSP_NEEDED
3133 /* Similarly for the default location. Let the user run additional
3134 commands if for instance locations are ranges. */
3135 yyloc = yylsp[1-yylen];
3136 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
3137 #endif
3138
3139 #if YYDEBUG
3140 /* We have to keep this `#if YYDEBUG', since we use variables which
3141 are defined only if `YYDEBUG' is set. */
3142 if (yydebug)
3143 {
3144 int yyi;
3145
3146 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
3147 yyn, yyrline[yyn]);
3148
3149 /* Print the symbols being reduced, and their result. */
3150 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
3151 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
3152 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
3153 }
3154 #endif
3155
3156 switch (yyn) {
3157
3158 case 1:
3159 #line 604 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3160 {;
3161 break;}
3162 case 18:
3163 #line 648 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3164 {
3165 int osb = pop_current_osb (ctxp);
3166 tree t = build_java_array_type ((yyvsp[-1].node), -1);
3167 while (--osb)
3168 t = build_unresolved_array_type (t);
3169 yyval.node = t;
3170 ;
3171 break;}
3172 case 19:
3173 #line 656 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3174 {
3175 int osb = pop_current_osb (ctxp);
3176 tree t = yyvsp[-1].node;
3177 while (osb--)
3178 t = build_unresolved_array_type (t);
3179 yyval.node = t;
3180 ;
3181 break;}
3182 case 23:
3183 #line 677 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3184 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
3185 break;}
3186 case 25:
3187 #line 686 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3188 {yyval.node = NULL;;
3189 break;}
3190 case 33:
3191 #line 698 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3192 {
3193 yyval.node = NULL;
3194 ;
3195 break;}
3196 case 34:
3197 #line 702 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3198 {
3199 yyval.node = NULL;
3200 ;
3201 break;}
3202 case 37:
3203 #line 714 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3204 {
3205 ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
3206 register_package (ctxp->package);
3207 ;
3208 break;}
3209 case 38:
3210 #line 719 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3211 {yyerror ("Missing name"); RECOVER;;
3212 break;}
3213 case 39:
3214 #line 721 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3215 {yyerror ("';' expected"); RECOVER;;
3216 break;}
3217 case 42:
3218 #line 731 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3219 {
3220 tree name = EXPR_WFL_NODE (yyvsp[-1].node), last_name;
3221 int i = IDENTIFIER_LENGTH (name)-1;
3222 const char *last = &IDENTIFIER_POINTER (name)[i];
3223 while (last != IDENTIFIER_POINTER (name))
3224 {
3225 if (last [0] == '.')
3226 break;
3227 last--;
3228 }
3229 last_name = get_identifier (++last);
3230 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3231 {
3232 tree err = find_name_in_single_imports (last_name);
3233 if (err && err != name)
3234 parse_error_context
3235 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3236 IDENTIFIER_POINTER (name),
3237 IDENTIFIER_POINTER (err));
3238 else
3239 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3240 }
3241 else
3242 REGISTER_IMPORT (yyvsp[-1].node, last_name);
3243 ;
3244 break;}
3245 case 43:
3246 #line 757 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3247 {yyerror ("Missing name"); RECOVER;;
3248 break;}
3249 case 44:
3250 #line 759 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3251 {yyerror ("';' expected"); RECOVER;;
3252 break;}
3253 case 45:
3254 #line 764 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3255 {
3256 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3257 tree it;
3258 /* Search for duplicates. */
3259 for (it = ctxp->import_demand_list; it; it = TREE_CHAIN (it))
3260 if (EXPR_WFL_NODE (TREE_PURPOSE (it)) == name)
3261 break;
3262 /* Don't import the same thing more than once, just ignore
3263 duplicates (7.5.2) */
3264 if (! it)
3265 {
3266 read_import_dir (yyvsp[-3].node);
3267 ctxp->import_demand_list =
3268 chainon (ctxp->import_demand_list,
3269 build_tree_list (yyvsp[-3].node, NULL_TREE));
3270 }
3271 ;
3272 break;}
3273 case 46:
3274 #line 782 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3275 {yyerror ("'*' expected"); RECOVER;;
3276 break;}
3277 case 47:
3278 #line 784 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3279 {yyerror ("';' expected"); RECOVER;;
3280 break;}
3281 case 48:
3282 #line 789 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3283 { end_class_declaration (0); ;
3284 break;}
3285 case 49:
3286 #line 791 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3287 { end_class_declaration (0); ;
3288 break;}
3289 case 51:
3290 #line 794 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3291 {
3292 YYERROR_NOW;
3293 yyerror ("Class or interface declaration expected");
3294 ;
3295 break;}
3296 case 52:
3297 #line 805 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3298 {
3299 yyval.value = (1 << yyvsp[0].value);
3300 ;
3301 break;}
3302 case 53:
3303 #line 809 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3304 {
3305 int acc = (1 << yyvsp[0].value);
3306 if (yyval.value & acc)
3307 parse_error_context
3308 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3309 java_accstring_lookup (acc));
3310 else
3311 {
3312 yyval.value |= acc;
3313 }
3314 ;
3315 break;}
3316 case 54:
3317 #line 825 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3318 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3319 break;}
3320 case 55:
3321 #line 827 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3322 {;;
3323 break;}
3324 case 56:
3325 #line 829 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3326 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3327 break;}
3328 case 57:
3329 #line 831 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3330 {;;
3331 break;}
3332 case 58:
3333 #line 833 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3334 { yyerror ("Missing class name"); RECOVER; ;
3335 break;}
3336 case 59:
3337 #line 835 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3338 { yyerror ("Missing class name"); RECOVER; ;
3339 break;}
3340 case 60:
3341 #line 837 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3342 {
3343 if (!ctxp->class_err) yyerror ("'{' expected");
3344 DRECOVER(class1);
3345 ;
3346 break;}
3347 case 61:
3348 #line 842 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3349 { if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER; ;
3350 break;}
3351 case 62:
3352 #line 846 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3353 { yyval.node = NULL; ;
3354 break;}
3355 case 63:
3356 #line 848 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3357 { yyval.node = yyvsp[0].node; ;
3358 break;}
3359 case 64:
3360 #line 850 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3361 {yyerror ("'{' expected"); ctxp->class_err=1;;
3362 break;}
3363 case 65:
3364 #line 852 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3365 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3366 break;}
3367 case 66:
3368 #line 856 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3369 { yyval.node = NULL_TREE; ;
3370 break;}
3371 case 67:
3372 #line 858 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3373 { yyval.node = yyvsp[0].node; ;
3374 break;}
3375 case 68:
3376 #line 860 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3377 {
3378 ctxp->class_err=1;
3379 yyerror ("Missing interface name");
3380 ;
3381 break;}
3382 case 69:
3383 #line 868 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3384 {
3385 ctxp->interface_number = 1;
3386 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3387 ;
3388 break;}
3389 case 70:
3390 #line 873 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3391 {
3392 ctxp->interface_number++;
3393 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3394 ;
3395 break;}
3396 case 71:
3397 #line 878 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3398 {yyerror ("Missing interface name"); RECOVER;;
3399 break;}
3400 case 72:
3401 #line 883 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3402 {
3403 /* Store the location of the `}' when doing xrefs */
3404 if (flag_emit_xref)
3405 DECL_END_SOURCE_LINE (GET_CPC ()) =
3406 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3407 yyval.node = GET_CPC ();
3408 ;
3409 break;}
3410 case 73:
3411 #line 891 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3412 {
3413 /* Store the location of the `}' when doing xrefs */
3414 if (flag_emit_xref)
3415 DECL_END_SOURCE_LINE (GET_CPC ()) =
3416 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3417 yyval.node = GET_CPC ();
3418 ;
3419 break;}
3420 case 79:
3421 #line 910 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3422 {
3423 if (yyvsp[0].node != empty_stmt_node)
3424 {
3425 TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3426 SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3427 }
3428 ;
3429 break;}
3430 case 82:
3431 #line 923 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3432 { end_class_declaration (1); ;
3433 break;}
3434 case 83:
3435 #line 925 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3436 { end_class_declaration (1); ;
3437 break;}
3438 case 85:
3439 #line 932 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3440 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3441 break;}
3442 case 86:
3443 #line 934 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3444 {
3445 check_modifiers
3446 ("Illegal modifier `%s' for field declaration",
3447 yyvsp[-3].value, FIELD_MODIFIERS);
3448 check_modifiers_consistency (yyvsp[-3].value);
3449 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3450 ;
3451 break;}
3452 case 88:
3453 #line 947 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3454 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3455 break;}
3456 case 89:
3457 #line 949 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3458 {yyerror ("Missing term"); RECOVER;;
3459 break;}
3460 case 90:
3461 #line 954 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3462 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3463 break;}
3464 case 91:
3465 #line 956 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3466 {
3467 if (java_error_count)
3468 yyvsp[0].node = NULL_TREE;
3469 yyval.node = build_tree_list
3470 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3471 ;
3472 break;}
3473 case 92:
3474 #line 963 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3475 {
3476 yyerror ("Missing variable initializer");
3477 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3478 RECOVER;
3479 ;
3480 break;}
3481 case 93:
3482 #line 969 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3483 {
3484 yyerror ("';' expected");
3485 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3486 RECOVER;
3487 ;
3488 break;}
3489 case 95:
3490 #line 979 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3491 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3492 break;}
3493 case 96:
3494 #line 981 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3495 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3496 break;}
3497 case 97:
3498 #line 983 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3499 {
3500 yyerror ("']' expected");
3501 DRECOVER(vdi);
3502 ;
3503 break;}
3504 case 98:
3505 #line 988 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3506 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3507 break;}
3508 case 101:
3509 #line 999 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3510 {
3511 current_function_decl = yyvsp[0].node;
3512 if (current_function_decl
3513 && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3514 source_start_java_method (current_function_decl);
3515 else
3516 current_function_decl = NULL_TREE;
3517 ;
3518 break;}
3519 case 102:
3520 #line 1008 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3521 { finish_method_declaration (yyvsp[0].node); ;
3522 break;}
3523 case 103:
3524 #line 1010 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3525 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3526 break;}
3527 case 104:
3528 #line 1015 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3529 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3530 break;}
3531 case 105:
3532 #line 1017 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3533 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3534 break;}
3535 case 106:
3536 #line 1019 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3537 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3538 break;}
3539 case 107:
3540 #line 1021 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3541 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3542 break;}
3543 case 108:
3544 #line 1023 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3545 {
3546 yyerror ("Invalid method declaration, method name required");
3547 RECOVER;
3548 ;
3549 break;}
3550 case 109:
3551 #line 1028 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3552 {
3553 yyerror ("Identifier expected");
3554 RECOVER;
3555 ;
3556 break;}
3557 case 110:
3558 #line 1033 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3559 {
3560 yyerror ("Identifier expected");
3561 RECOVER;
3562 ;
3563 break;}
3564 case 111:
3565 #line 1038 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3566 {
3567 yyerror ("Identifier expected");
3568 RECOVER;
3569 ;
3570 break;}
3571 case 112:
3572 #line 1043 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3573 {
3574 yyerror ("Invalid method declaration, return type required");
3575 RECOVER;
3576 ;
3577 break;}
3578 case 113:
3579 #line 1051 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3580 {
3581 ctxp->formal_parameter_number = 0;
3582 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3583 ;
3584 break;}
3585 case 114:
3586 #line 1056 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3587 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3588 break;}
3589 case 115:
3590 #line 1058 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3591 {
3592 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3593 TREE_PURPOSE (yyvsp[-2].node) =
3594 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3595 parse_warning_context
3596 (wfl_operator,
3597 "Discouraged form of returned type specification");
3598 ;
3599 break;}
3600 case 116:
3601 #line 1067 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3602 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3603 break;}
3604 case 117:
3605 #line 1069 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3606 {yyerror ("']' expected"); RECOVER;;
3607 break;}
3608 case 118:
3609 #line 1074 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3610 {
3611 ctxp->formal_parameter_number = 1;
3612 ;
3613 break;}
3614 case 119:
3615 #line 1078 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3616 {
3617 ctxp->formal_parameter_number += 1;
3618 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3619 ;
3620 break;}
3621 case 120:
3622 #line 1083 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3623 { yyerror ("Missing formal parameter term"); RECOVER; ;
3624 break;}
3625 case 121:
3626 #line 1088 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3627 {
3628 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3629 ;
3630 break;}
3631 case 122:
3632 #line 1092 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3633 {
3634 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3635 ARG_FINAL_P (yyval.node) = 1;
3636 ;
3637 break;}
3638 case 123:
3639 #line 1097 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3640 {
3641 yyerror ("Missing identifier"); RECOVER;
3642 yyval.node = NULL_TREE;
3643 ;
3644 break;}
3645 case 124:
3646 #line 1102 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3647 {
3648 yyerror ("Missing identifier"); RECOVER;
3649 yyval.node = NULL_TREE;
3650 ;
3651 break;}
3652 case 125:
3653 #line 1110 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3654 {
3655 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3656 yyvsp[0].value, ACC_FINAL);
3657 if (yyvsp[0].value != ACC_FINAL)
3658 MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3659 ;
3660 break;}
3661 case 126:
3662 #line 1119 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3663 { yyval.node = NULL_TREE; ;
3664 break;}
3665 case 127:
3666 #line 1121 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3667 { yyval.node = yyvsp[0].node; ;
3668 break;}
3669 case 128:
3670 #line 1123 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3671 {yyerror ("Missing class type term"); RECOVER;;
3672 break;}
3673 case 129:
3674 #line 1128 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3675 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3676 break;}
3677 case 130:
3678 #line 1130 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3679 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3680 break;}
3681 case 131:
3682 #line 1132 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3683 {yyerror ("Missing class type term"); RECOVER;;
3684 break;}
3685 case 133:
3686 #line 1137 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3687 { yyval.node = NULL_TREE; ;
3688 break;}
3689 case 134:
3690 #line 1143 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3691 {
3692 TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3693 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3694 current_static_block = NULL_TREE;
3695 ;
3696 break;}
3697 case 135:
3698 #line 1152 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3699 {
3700 check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3701 /* Can't have a static initializer in an innerclass */
3702 if (yyvsp[0].value | ACC_STATIC &&
3703 GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3704 parse_error_context
3705 (MODIFIER_WFL (STATIC_TK),
3706 "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3707 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3708 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3709 ;
3710 break;}
3711 case 136:
3712 #line 1168 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3713 {
3714 current_function_decl = yyvsp[0].node;
3715 source_start_java_method (current_function_decl);
3716 ;
3717 break;}
3718 case 137:
3719 #line 1173 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3720 { finish_method_declaration (yyvsp[0].node); ;
3721 break;}
3722 case 138:
3723 #line 1178 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3724 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3725 break;}
3726 case 139:
3727 #line 1180 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3728 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3729 break;}
3730 case 140:
3731 #line 1185 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3732 {
3733 ctxp->formal_parameter_number = 0;
3734 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3735 ;
3736 break;}
3737 case 141:
3738 #line 1190 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3739 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3740 break;}
3741 case 142:
3742 #line 1198 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3743 {
3744 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3745 yyval.node = yyvsp[0].node;
3746 ;
3747 break;}
3748 case 143:
3749 #line 1203 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3750 { yyval.node = yyvsp[0].node; ;
3751 break;}
3752 case 144:
3753 #line 1205 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3754 { yyval.node = yyvsp[0].node; ;
3755 break;}
3756 case 145:
3757 #line 1207 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3758 { yyval.node = yyvsp[0].node; ;
3759 break;}
3760 case 147:
3761 #line 1217 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3762 {
3763 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3764 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3765 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3766 ;
3767 break;}
3768 case 148:
3769 #line 1223 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3770 {
3771 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3772 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3773 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3774 ;
3775 break;}
3776 case 149:
3777 #line 1231 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3778 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3779 break;}
3780 case 150:
3781 #line 1233 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3782 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3783 break;}
3784 case 151:
3785 #line 1238 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3786 {
3787 tree wfl = build_wfl_node (this_identifier_node);
3788 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3789 yyval.node = wfl;
3790 ;
3791 break;}
3792 case 152:
3793 #line 1244 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3794 {
3795 tree wfl = build_wfl_node (super_identifier_node);
3796 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3797 yyval.node = wfl;
3798 ;
3799 break;}
3800 case 153:
3801 #line 1255 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3802 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3803 break;}
3804 case 154:
3805 #line 1257 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3806 { ; ;
3807 break;}
3808 case 155:
3809 #line 1259 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3810 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3811 break;}
3812 case 156:
3813 #line 1261 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3814 { ; ;
3815 break;}
3816 case 157:
3817 #line 1263 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3818 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3819 break;}
3820 case 158:
3821 #line 1265 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3822 { ; ;
3823 break;}
3824 case 159:
3825 #line 1267 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3826 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3827 break;}
3828 case 160:
3829 #line 1269 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3830 { ; ;
3831 break;}
3832 case 161:
3833 #line 1271 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3834 { yyerror ("'{' expected"); RECOVER; ;
3835 break;}
3836 case 162:
3837 #line 1273 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3838 { yyerror ("'{' expected"); RECOVER; ;
3839 break;}
3840 case 163:
3841 #line 1278 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3842 {
3843 ctxp->interface_number = 1;
3844 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3845 ;
3846 break;}
3847 case 164:
3848 #line 1283 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3849 {
3850 ctxp->interface_number++;
3851 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3852 ;
3853 break;}
3854 case 165:
3855 #line 1288 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3856 {yyerror ("Invalid interface type"); RECOVER;;
3857 break;}
3858 case 166:
3859 #line 1290 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3860 {yyerror ("Missing term"); RECOVER;;
3861 break;}
3862 case 167:
3863 #line 1295 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3864 { yyval.node = NULL_TREE; ;
3865 break;}
3866 case 168:
3867 #line 1297 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3868 { yyval.node = NULL_TREE; ;
3869 break;}
3870 case 173:
3871 #line 1309 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3872 { end_class_declaration (1); ;
3873 break;}
3874 case 174:
3875 #line 1311 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3876 { end_class_declaration (1); ;
3877 break;}
3878 case 176:
3879 #line 1320 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3880 {
3881 check_abstract_method_header (yyvsp[-1].node);
3882 current_function_decl = NULL_TREE; /* FIXME ? */
3883 ;
3884 break;}
3885 case 177:
3886 #line 1325 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3887 {yyerror ("';' expected"); RECOVER;;
3888 break;}
3889 case 178:
3890 #line 1331 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3891 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3892 break;}
3893 case 179:
3894 #line 1333 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3895 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, NULL_TREE); ;
3896 break;}
3897 case 180:
3898 #line 1335 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3899 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3900 break;}
3901 case 181:
3902 #line 1337 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3903 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3904 break;}
3905 case 182:
3906 #line 1342 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3907 {
3908 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3909 yyvsp[0].node, NULL_TREE);
3910 ;
3911 break;}
3912 case 183:
3913 #line 1347 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3914 {
3915 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3916 ;
3917 break;}
3918 case 184:
3919 #line 1351 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3920 {yyerror ("Missing term"); RECOVER;;
3921 break;}
3922 case 185:
3923 #line 1357 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3924 { yyval.node = yyvsp[0].node; ;
3925 break;}
3926 case 186:
3927 #line 1359 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3928 { yyval.node = yyvsp[0].node; ;
3929 break;}
3930 case 187:
3931 #line 1364 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3932 { enter_block (); ;
3933 break;}
3934 case 188:
3935 #line 1369 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3936 {
3937 maybe_absorb_scoping_blocks ();
3938 /* Store the location of the `}' when doing xrefs */
3939 if (current_function_decl && flag_emit_xref)
3940 DECL_END_SOURCE_LINE (current_function_decl) =
3941 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3942 yyval.node = exit_block ();
3943 if (!BLOCK_SUBBLOCKS (yyval.node))
3944 BLOCK_SUBBLOCKS (yyval.node) = empty_stmt_node;
3945 ;
3946 break;}
3947 case 192:
3948 #line 1389 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3949 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3950 break;}
3951 case 193:
3952 #line 1391 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3953 {
3954 LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3955 end_class_declaration (1);
3956 ;
3957 break;}
3958 case 195:
3959 #line 1403 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3960 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3961 break;}
3962 case 196:
3963 #line 1405 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3964 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3965 break;}
3966 case 202:
3967 #line 1415 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3968 { yyval.node = exit_block (); ;
3969 break;}
3970 case 207:
3971 #line 1424 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3972 { yyval.node = exit_block (); ;
3973 break;}
3974 case 220:
3975 #line 1444 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3976 {
3977 if (flag_extraneous_semicolon
3978 && ! current_static_block
3979 && (! current_function_decl ||
3980 /* Verify we're not in a inner class declaration */
3981 (GET_CPC () != TYPE_NAME
3982 (DECL_CONTEXT (current_function_decl)))))
3983
3984 {
3985 EXPR_WFL_SET_LINECOL (wfl_operator, input_line, -1);
3986 parse_warning_context (wfl_operator, "An empty declaration is a deprecated feature that should not be used");
3987 }
3988 yyval.node = empty_stmt_node;
3989 ;
3990 break;}
3991 case 221:
3992 #line 1462 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
3993 {
3994 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3995 EXPR_WFL_NODE (yyvsp[-1].node));
3996 pushlevel (2);
3997 push_labeled_block (yyval.node);
3998 PUSH_LABELED_BLOCK (yyval.node);
3999 ;
4000 break;}
4001 case 222:
4002 #line 1473 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4003 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
4004 break;}
4005 case 223:
4006 #line 1475 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4007 {yyerror ("':' expected"); RECOVER;;
4008 break;}
4009 case 224:
4010 #line 1480 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4011 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
4012 break;}
4013 case 225:
4014 #line 1487 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4015 {
4016 /* We have a statement. Generate a WFL around it so
4017 we can debug it */
4018 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, input_line, 0);
4019 /* We know we have a statement, so set the debug
4020 info to be eventually generate here. */
4021 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
4022 ;
4023 break;}
4024 case 226:
4025 #line 1496 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4026 {
4027 YYNOT_TWICE yyerror ("Invalid expression statement");
4028 DRECOVER (expr_stmt);
4029 ;
4030 break;}
4031 case 227:
4032 #line 1501 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4033 {
4034 YYNOT_TWICE yyerror ("Invalid expression statement");
4035 DRECOVER (expr_stmt);
4036 ;
4037 break;}
4038 case 228:
4039 #line 1506 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4040 {
4041 YYNOT_TWICE yyerror ("Invalid expression statement");
4042 DRECOVER (expr_stmt);
4043 ;
4044 break;}
4045 case 229:
4046 #line 1511 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4047 {yyerror ("')' expected"); RECOVER;;
4048 break;}
4049 case 230:
4050 #line 1513 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4051 {
4052 parse_ctor_invocation_error ();
4053 RECOVER;
4054 ;
4055 break;}
4056 case 231:
4057 #line 1518 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4058 {yyerror ("')' expected"); RECOVER;;
4059 break;}
4060 case 232:
4061 #line 1520 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4062 {
4063 parse_ctor_invocation_error ();
4064 RECOVER;
4065 ;
4066 break;}
4067 case 233:
4068 #line 1525 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4069 {yyerror ("'(' expected"); RECOVER;;
4070 break;}
4071 case 234:
4072 #line 1527 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4073 {yyerror ("')' expected"); RECOVER;;
4074 break;}
4075 case 235:
4076 #line 1529 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4077 {yyerror ("')' expected"); RECOVER;;
4078 break;}
4079 case 236:
4080 #line 1531 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4081 {yyerror ("';' expected"); RECOVER;;
4082 break;}
4083 case 237:
4084 #line 1533 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4085 {yyerror ("';' expected"); RECOVER;;
4086 break;}
4087 case 245:
4088 #line 1548 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4089 {
4090 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
4091 yyvsp[0].node, NULL_TREE);
4092 ;
4093 break;}
4094 case 246:
4095 #line 1553 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4096 {yyerror ("'(' expected"); RECOVER;;
4097 break;}
4098 case 247:
4099 #line 1555 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4100 {yyerror ("Missing term"); RECOVER;;
4101 break;}
4102 case 248:
4103 #line 1557 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4104 {yyerror ("')' expected"); RECOVER;;
4105 break;}
4106 case 249:
4107 #line 1562 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4108 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
4109 break;}
4110 case 250:
4111 #line 1567 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4112 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
4113 break;}
4114 case 251:
4115 #line 1572 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4116 {
4117 enter_block ();
4118 ;
4119 break;}
4120 case 252:
4121 #line 1576 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4122 {
4123 /* Make into "proper list" of COMPOUND_EXPRs.
4124 I.e. make the last statement also have its own
4125 COMPOUND_EXPR. */
4126 maybe_absorb_scoping_blocks ();
4127 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
4128 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
4129 ;
4130 break;}
4131 case 253:
4132 #line 1588 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4133 {
4134 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
4135 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4136 ;
4137 break;}
4138 case 254:
4139 #line 1593 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4140 {yyerror ("'(' expected"); RECOVER;;
4141 break;}
4142 case 255:
4143 #line 1595 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4144 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
4145 break;}
4146 case 256:
4147 #line 1597 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4148 {yyerror ("'{' expected"); RECOVER;;
4149 break;}
4150 case 257:
4151 #line 1605 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4152 { yyval.node = NULL_TREE; ;
4153 break;}
4154 case 258:
4155 #line 1607 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4156 { yyval.node = NULL_TREE; ;
4157 break;}
4158 case 259:
4159 #line 1609 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4160 { yyval.node = NULL_TREE; ;
4161 break;}
4162 case 260:
4163 #line 1611 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4164 { yyval.node = NULL_TREE; ;
4165 break;}
4166 case 266:
4167 #line 1630 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4168 {
4169 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
4170 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
4171 java_method_add_stmt (current_function_decl, lab);
4172 ;
4173 break;}
4174 case 267:
4175 #line 1636 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4176 {
4177 tree lab = build (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
4178 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
4179 java_method_add_stmt (current_function_decl, lab);
4180 ;
4181 break;}
4182 case 268:
4183 #line 1642 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4184 {yyerror ("Missing or invalid constant expression"); RECOVER;;
4185 break;}
4186 case 269:
4187 #line 1644 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4188 {yyerror ("':' expected"); RECOVER;;
4189 break;}
4190 case 270:
4191 #line 1646 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4192 {yyerror ("':' expected"); RECOVER;;
4193 break;}
4194 case 271:
4195 #line 1651 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4196 {
4197 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
4198 yyval.node = build_new_loop (body);
4199 ;
4200 break;}
4201 case 272:
4202 #line 1659 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4203 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
4204 break;}
4205 case 273:
4206 #line 1661 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4207 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
4208 break;}
4209 case 274:
4210 #line 1663 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4211 {yyerror ("Missing term and ')' expected"); RECOVER;;
4212 break;}
4213 case 275:
4214 #line 1665 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4215 {yyerror ("')' expected"); RECOVER;;
4216 break;}
4217 case 276:
4218 #line 1670 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4219 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
4220 break;}
4221 case 277:
4222 #line 1675 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4223 {
4224 tree body = build_loop_body (0, NULL_TREE, 1);
4225 yyval.node = build_new_loop (body);
4226 ;
4227 break;}
4228 case 278:
4229 #line 1684 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4230 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
4231 break;}
4232 case 279:
4233 #line 1689 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4234 {
4235 if (TREE_CODE_CLASS (TREE_CODE (yyvsp[-4].node)) == 'c')
4236 yyvsp[-4].node = build_wfl_node (yyvsp[-4].node);
4237 yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4238 ;
4239 break;}
4240 case 280:
4241 #line 1695 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4242 {
4243 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4244 /* We have not condition, so we get rid of the EXIT_EXPR */
4245 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
4246 empty_stmt_node;
4247 ;
4248 break;}
4249 case 281:
4250 #line 1702 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4251 {yyerror ("Invalid control expression"); RECOVER;;
4252 break;}
4253 case 282:
4254 #line 1704 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4255 {yyerror ("Invalid update expression"); RECOVER;;
4256 break;}
4257 case 283:
4258 #line 1706 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4259 {yyerror ("Invalid update expression"); RECOVER;;
4260 break;}
4261 case 284:
4262 #line 1711 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4263 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
4264 break;}
4265 case 285:
4266 #line 1713 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4267 {
4268 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4269 /* We have not condition, so we get rid of the EXIT_EXPR */
4270 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
4271 empty_stmt_node;
4272 ;
4273 break;}
4274 case 286:
4275 #line 1723 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4276 {
4277 /* This scope defined for local variable that may be
4278 defined within the scope of the for loop */
4279 enter_block ();
4280 ;
4281 break;}
4282 case 287:
4283 #line 1729 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4284 {yyerror ("'(' expected"); DRECOVER(for_1);;
4285 break;}
4286 case 288:
4287 #line 1731 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4288 {yyerror ("Invalid init statement"); RECOVER;;
4289 break;}
4290 case 289:
4291 #line 1736 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4292 {
4293 /* We now declare the loop body. The loop is
4294 declared as a for loop. */
4295 tree body = build_loop_body (0, NULL_TREE, 0);
4296 yyval.node = build_new_loop (body);
4297 FOR_LOOP_P (yyval.node) = 1;
4298 /* The loop is added to the current block the for
4299 statement is defined within */
4300 java_method_add_stmt (current_function_decl, yyval.node);
4301 ;
4302 break;}
4303 case 290:
4304 #line 1748 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4305 { yyval.node = empty_stmt_node; ;
4306 break;}
4307 case 291:
4308 #line 1750 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4309 {
4310 /* Init statement recorded within the previously
4311 defined block scope */
4312 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4313 ;
4314 break;}
4315 case 292:
4316 #line 1756 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4317 {
4318 /* Local variable are recorded within the previously
4319 defined block scope */
4320 yyval.node = NULL_TREE;
4321 ;
4322 break;}
4323 case 293:
4324 #line 1762 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4325 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4326 break;}
4327 case 294:
4328 #line 1766 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4329 {yyval.node = empty_stmt_node;;
4330 break;}
4331 case 295:
4332 #line 1768 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4333 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4334 break;}
4335 case 296:
4336 #line 1773 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4337 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4338 break;}
4339 case 297:
4340 #line 1775 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4341 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4342 break;}
4343 case 298:
4344 #line 1777 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4345 {yyerror ("Missing term"); RECOVER;;
4346 break;}
4347 case 299:
4348 #line 1782 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4349 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4350 break;}
4351 case 300:
4352 #line 1784 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4353 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4354 break;}
4355 case 301:
4356 #line 1786 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4357 {yyerror ("Missing term"); RECOVER;;
4358 break;}
4359 case 302:
4360 #line 1788 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4361 {yyerror ("';' expected"); RECOVER;;
4362 break;}
4363 case 303:
4364 #line 1793 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4365 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4366 break;}
4367 case 304:
4368 #line 1795 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4369 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4370 break;}
4371 case 305:
4372 #line 1797 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4373 {yyerror ("Missing term"); RECOVER;;
4374 break;}
4375 case 306:
4376 #line 1799 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4377 {yyerror ("';' expected"); RECOVER;;
4378 break;}
4379 case 307:
4380 #line 1804 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4381 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4382 break;}
4383 case 308:
4384 #line 1806 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4385 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4386 break;}
4387 case 309:
4388 #line 1808 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4389 {yyerror ("Missing term"); RECOVER;;
4390 break;}
4391 case 310:
4392 #line 1810 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4393 {yyerror ("';' expected"); RECOVER;;
4394 break;}
4395 case 311:
4396 #line 1815 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4397 {
4398 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4399 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4400 ;
4401 break;}
4402 case 312:
4403 #line 1820 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4404 {yyerror ("Missing term"); RECOVER;;
4405 break;}
4406 case 313:
4407 #line 1822 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4408 {yyerror ("';' expected"); RECOVER;;
4409 break;}
4410 case 314:
4411 #line 1827 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4412 {
4413 yyval.node = build_assertion (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[-1].node);
4414 ;
4415 break;}
4416 case 315:
4417 #line 1831 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4418 {
4419 yyval.node = build_assertion (yyvsp[-2].operator.location, yyvsp[-1].node, NULL_TREE);
4420 ;
4421 break;}
4422 case 316:
4423 #line 1835 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4424 {yyerror ("Missing term"); RECOVER;;
4425 break;}
4426 case 317:
4427 #line 1837 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4428 {yyerror ("';' expected"); RECOVER;;
4429 break;}
4430 case 318:
4431 #line 1842 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4432 {
4433 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4434 EXPR_WFL_LINECOL (yyval.node) =
4435 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4436 ;
4437 break;}
4438 case 319:
4439 #line 1848 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4440 {yyerror ("'{' expected"); RECOVER;;
4441 break;}
4442 case 320:
4443 #line 1850 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4444 {yyerror ("'(' expected"); RECOVER;;
4445 break;}
4446 case 321:
4447 #line 1852 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4448 {yyerror ("Missing term"); RECOVER;;
4449 break;}
4450 case 322:
4451 #line 1854 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4452 {yyerror ("Missing term"); RECOVER;;
4453 break;}
4454 case 323:
4455 #line 1859 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4456 {
4457 check_modifiers (
4458 "Illegal modifier `%s'. Only `synchronized' was expected here",
4459 yyvsp[0].value, ACC_SYNCHRONIZED);
4460 if (yyvsp[0].value != ACC_SYNCHRONIZED)
4461 MODIFIER_WFL (SYNCHRONIZED_TK) =
4462 build_wfl_node (NULL_TREE);
4463 ;
4464 break;}
4465 case 324:
4466 #line 1871 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4467 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4468 break;}
4469 case 325:
4470 #line 1873 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4471 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4472 break;}
4473 case 326:
4474 #line 1875 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4475 { yyval.node = build_try_finally_statement
4476 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4477 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4478 ;
4479 break;}
4480 case 327:
4481 #line 1880 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4482 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4483 break;}
4484 case 329:
4485 #line 1886 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4486 {
4487 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4488 yyval.node = yyvsp[0].node;
4489 ;
4490 break;}
4491 case 330:
4492 #line 1894 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4493 {
4494 java_method_add_stmt (current_function_decl, yyvsp[0].node);
4495 exit_block ();
4496 yyval.node = yyvsp[-1].node;
4497 ;
4498 break;}
4499 case 331:
4500 #line 1903 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4501 {
4502 /* We add a block to define a scope for
4503 formal_parameter (CCBP). The formal parameter is
4504 declared initialized by the appropriate function
4505 call */
4506 tree ccpb;
4507 tree init;
4508 if (yyvsp[-1].node)
4509 {
4510 ccpb = enter_block ();
4511 init = build_assignment
4512 (ASSIGN_TK, yyvsp[-2].operator.location, TREE_PURPOSE (yyvsp[-1].node),
4513 build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
4514 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4515 build_tree_list
4516 (TREE_PURPOSE (yyvsp[-1].node), init));
4517 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4518 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4519 }
4520 else
4521 {
4522 yyval.node = error_mark_node;
4523 }
4524 ;
4525 break;}
4526 case 332:
4527 #line 1928 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4528 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4529 break;}
4530 case 333:
4531 #line 1930 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4532 {
4533 yyerror ("Missing term or ')' expected");
4534 RECOVER; yyval.node = NULL_TREE;
4535 ;
4536 break;}
4537 case 334:
4538 #line 1935 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4539 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4540 break;}
4541 case 335:
4542 #line 1940 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4543 { yyval.node = yyvsp[0].node; ;
4544 break;}
4545 case 336:
4546 #line 1942 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4547 {yyerror ("'{' expected"); RECOVER; ;
4548 break;}
4549 case 340:
4550 #line 1954 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4551 { yyval.node = build_this (yyvsp[0].operator.location); ;
4552 break;}
4553 case 341:
4554 #line 1956 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4555 {yyval.node = yyvsp[-1].node;;
4556 break;}
4557 case 347:
4558 #line 1966 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4559 {
4560 tree wfl = build_wfl_node (this_identifier_node);
4561 yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4562 ;
4563 break;}
4564 case 348:
4565 #line 1971 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4566 {yyerror ("')' expected"); RECOVER;;
4567 break;}
4568 case 349:
4569 #line 1973 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4570 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4571 break;}
4572 case 350:
4573 #line 1975 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4574 {yyerror ("'class' expected" ); RECOVER;;
4575 break;}
4576 case 351:
4577 #line 1977 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4578 {yyerror ("'class' expected" ); RECOVER;;
4579 break;}
4580 case 352:
4581 #line 1982 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4582 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4583 break;}
4584 case 353:
4585 #line 1984 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4586 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4587 break;}
4588 case 354:
4589 #line 1986 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4590 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4591 break;}
4592 case 355:
4593 #line 1988 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4594 {
4595 yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location,
4596 void_type_node);
4597 ;
4598 break;}
4599 case 356:
4600 #line 1996 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4601 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4602 break;}
4603 case 357:
4604 #line 1998 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4605 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4606 break;}
4607 case 359:
4608 #line 2004 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4609 {
4610 tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4611 yyval.node = make_qualified_primary (yyvsp[-3].node, ctor,
4612 EXPR_WFL_LINECOL (yyvsp[-3].node));
4613 ;
4614 break;}
4615 case 361:
4616 #line 2011 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4617 {
4618 tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4619 yyval.node = make_qualified_primary (yyvsp[-4].node, ctor,
4620 EXPR_WFL_LINECOL (yyvsp[-4].node));
4621 ;
4622 break;}
4623 case 363:
4624 #line 2018 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4625 {yyerror ("'(' expected"); DRECOVER(new_1);;
4626 break;}
4627 case 364:
4628 #line 2020 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4629 {yyerror ("'(' expected"); RECOVER;;
4630 break;}
4631 case 365:
4632 #line 2022 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4633 {yyerror ("')' or term expected"); RECOVER;;
4634 break;}
4635 case 366:
4636 #line 2024 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4637 {yyerror ("')' expected"); RECOVER;;
4638 break;}
4639 case 367:
4640 #line 2026 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4641 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4642 break;}
4643 case 368:
4644 #line 2028 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4645 {yyerror ("'(' expected"); RECOVER;;
4646 break;}
4647 case 369:
4648 #line 2038 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4649 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4650 break;}
4651 case 370:
4652 #line 2040 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4653 {
4654 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4655 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4656
4657 end_class_declaration (1);
4658
4659 /* Now we can craft the new expression */
4660 yyval.node = build_new_invocation (id, yyvsp[-3].node);
4661
4662 /* Note that we can't possibly be here if
4663 `class_type' is an interface (in which case the
4664 anonymous class extends Object and implements
4665 `class_type', hence its constructor can't have
4666 arguments.) */
4667
4668 /* Otherwise, the innerclass must feature a
4669 constructor matching `argument_list'. Anonymous
4670 classes are a bit special: it's impossible to
4671 define constructor for them, hence constructors
4672 must be generated following the hints provided by
4673 the `new' expression. Whether a super constructor
4674 of that nature exists or not is to be verified
4675 later on in verify_constructor_super.
4676
4677 It's during the expansion of a `new' statement
4678 refering to an anonymous class that a ctor will
4679 be generated for the anonymous class, with the
4680 right arguments. */
4681
4682 ;
4683 break;}
4684 case 371:
4685 #line 2071 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4686 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4687 break;}
4688 case 372:
4689 #line 2073 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4690 {
4691 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4692 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4693
4694 end_class_declaration (1);
4695
4696 /* Now we can craft the new expression. The
4697 statement doesn't need to be remember so that a
4698 constructor can be generated, since its signature
4699 is already known. */
4700 yyval.node = build_new_invocation (id, NULL_TREE);
4701 ;
4702 break;}
4703 case 373:
4704 #line 2089 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4705 { yyval.node = yyvsp[-2].node; ;
4706 break;}
4707 case 374:
4708 #line 2091 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4709 { yyval.node = yyvsp[-2].node; ;
4710 break;}
4711 case 375:
4712 #line 2096 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4713 {
4714 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4715 ctxp->formal_parameter_number = 1;
4716 ;
4717 break;}
4718 case 376:
4719 #line 2101 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4720 {
4721 ctxp->formal_parameter_number += 1;
4722 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4723 ;
4724 break;}
4725 case 377:
4726 #line 2106 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4727 {yyerror ("Missing term"); RECOVER;;
4728 break;}
4729 case 378:
4730 #line 2111 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4731 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4732 break;}
4733 case 379:
4734 #line 2113 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4735 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4736 break;}
4737 case 380:
4738 #line 2115 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4739 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, pop_current_osb (ctxp));;
4740 break;}
4741 case 381:
4742 #line 2117 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4743 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, pop_current_osb (ctxp));;
4744 break;}
4745 case 382:
4746 #line 2121 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4747 {
4748 char *sig;
4749 int osb = pop_current_osb (ctxp);
4750 while (osb--)
4751 obstack_grow (&temporary_obstack, "[]", 2);
4752 obstack_1grow (&temporary_obstack, '\0');
4753 sig = obstack_finish (&temporary_obstack);
4754 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4755 yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4756 ;
4757 break;}
4758 case 383:
4759 #line 2132 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4760 {
4761 int osb = pop_current_osb (ctxp);
4762 tree type = yyvsp[-2].node;
4763 while (osb--)
4764 type = build_java_array_type (type, -1);
4765 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4766 build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4767 ;
4768 break;}
4769 case 384:
4770 #line 2141 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4771 {yyerror ("'[' expected"); DRECOVER ("]");;
4772 break;}
4773 case 385:
4774 #line 2143 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4775 {yyerror ("']' expected"); RECOVER;;
4776 break;}
4777 case 386:
4778 #line 2148 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4779 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4780 break;}
4781 case 387:
4782 #line 2150 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4783 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4784 break;}
4785 case 388:
4786 #line 2155 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4787 {
4788 if (JNUMERIC_TYPE_P (TREE_TYPE (yyvsp[-1].node)))
4789 {
4790 yyvsp[-1].node = build_wfl_node (yyvsp[-1].node);
4791 TREE_TYPE (yyvsp[-1].node) = NULL_TREE;
4792 }
4793 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4794 yyval.node = yyvsp[-1].node;
4795 ;
4796 break;}
4797 case 389:
4798 #line 2165 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4799 {yyerror ("']' expected"); RECOVER;;
4800 break;}
4801 case 390:
4802 #line 2167 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4803 {
4804 yyerror ("Missing term");
4805 yyerror ("']' expected");
4806 RECOVER;
4807 ;
4808 break;}
4809 case 391:
4810 #line 2176 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4811 {
4812 int allocate = 0;
4813 /* If not initialized, allocate memory for the osb
4814 numbers stack */
4815 if (!ctxp->osb_limit)
4816 {
4817 allocate = ctxp->osb_limit = 32;
4818 ctxp->osb_depth = -1;
4819 }
4820 /* If capacity overflown, reallocate a bigger chunk */
4821 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4822 allocate = ctxp->osb_limit << 1;
4823
4824 if (allocate)
4825 {
4826 allocate *= sizeof (int);
4827 if (ctxp->osb_number)
4828 ctxp->osb_number = xrealloc (ctxp->osb_number,
4829 allocate);
4830 else
4831 ctxp->osb_number = xmalloc (allocate);
4832 }
4833 ctxp->osb_depth++;
4834 CURRENT_OSB (ctxp) = 1;
4835 ;
4836 break;}
4837 case 392:
4838 #line 2202 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4839 { CURRENT_OSB (ctxp)++; ;
4840 break;}
4841 case 393:
4842 #line 2204 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4843 { yyerror ("']' expected"); RECOVER;;
4844 break;}
4845 case 394:
4846 #line 2209 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4847 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4848 break;}
4849 case 395:
4850 #line 2213 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4851 {
4852 tree super_wfl = build_wfl_node (super_identifier_node);
4853 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4854 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4855 ;
4856 break;}
4857 case 396:
4858 #line 2219 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4859 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4860 break;}
4861 case 397:
4862 #line 2224 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4863 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4864 break;}
4865 case 398:
4866 #line 2226 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4867 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4868 break;}
4869 case 399:
4870 #line 2228 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4871 {
4872 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4873 yyval.node = build_this_super_qualified_invocation
4874 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4875 else
4876 {
4877 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4878 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4879 }
4880 ;
4881 break;}
4882 case 400:
4883 #line 2239 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4884 {
4885 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4886 yyval.node = build_this_super_qualified_invocation
4887 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4888 else
4889 {
4890 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4891 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4892 }
4893 ;
4894 break;}
4895 case 401:
4896 #line 2250 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4897 {
4898 yyval.node = build_this_super_qualified_invocation
4899 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4900 ;
4901 break;}
4902 case 402:
4903 #line 2255 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4904 {
4905 yyval.node = build_this_super_qualified_invocation
4906 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4907 ;
4908 break;}
4909 case 403:
4910 #line 2264 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4911 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4912 break;}
4913 case 404:
4914 #line 2266 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4915 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4916 break;}
4917 case 405:
4918 #line 2271 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4919 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4920 break;}
4921 case 406:
4922 #line 2273 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4923 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4924 break;}
4925 case 407:
4926 #line 2275 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4927 {
4928 yyerror ("Missing term and ']' expected");
4929 DRECOVER(array_access);
4930 ;
4931 break;}
4932 case 408:
4933 #line 2280 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4934 {
4935 yyerror ("']' expected");
4936 DRECOVER(array_access);
4937 ;
4938 break;}
4939 case 409:
4940 #line 2285 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4941 {
4942 yyerror ("Missing term and ']' expected");
4943 DRECOVER(array_access);
4944 ;
4945 break;}
4946 case 410:
4947 #line 2290 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4948 {
4949 yyerror ("']' expected");
4950 DRECOVER(array_access);
4951 ;
4952 break;}
4953 case 415:
4954 #line 2305 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4955 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4956 break;}
4957 case 416:
4958 #line 2310 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4959 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4960 break;}
4961 case 419:
4962 #line 2317 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4963 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4964 break;}
4965 case 421:
4966 #line 2320 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4967 {yyerror ("Missing term"); RECOVER;
4968 break;}
4969 case 422:
4970 #line 2325 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4971 {
4972 error_if_numeric_overflow (yyvsp[0].node);
4973 yyval.node = yyvsp[0].node;
4974 ;
4975 break;}
4976 case 423:
4977 #line 2330 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4978 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4979 break;}
4980 case 424:
4981 #line 2332 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4982 {yyerror ("Missing term"); RECOVER;
4983 break;}
4984 case 425:
4985 #line 2337 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4986 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4987 break;}
4988 case 426:
4989 #line 2339 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4990 {yyerror ("Missing term"); RECOVER;
4991 break;}
4992 case 427:
4993 #line 2344 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4994 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4995 break;}
4996 case 428:
4997 #line 2346 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
4998 {yyerror ("Missing term"); RECOVER;
4999 break;}
5000 case 430:
5001 #line 2352 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5002 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
5003 break;}
5004 case 431:
5005 #line 2354 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5006 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
5007 break;}
5008 case 433:
5009 #line 2357 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5010 {yyerror ("Missing term"); RECOVER;
5011 break;}
5012 case 434:
5013 #line 2359 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5014 {yyerror ("Missing term"); RECOVER;
5015 break;}
5016 case 435:
5017 #line 2364 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5018 {
5019 tree type = yyvsp[-3].node;
5020 int osb = pop_current_osb (ctxp);
5021 while (osb--)
5022 type = build_java_array_type (type, -1);
5023 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
5024 ;
5025 break;}
5026 case 436:
5027 #line 2372 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5028 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5029 break;}
5030 case 437:
5031 #line 2374 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5032 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5033 break;}
5034 case 438:
5035 #line 2376 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5036 {
5037 const char *ptr;
5038 int osb = pop_current_osb (ctxp);
5039 obstack_grow (&temporary_obstack,
5040 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
5041 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
5042 while (osb--)
5043 obstack_grow (&temporary_obstack, "[]", 2);
5044 obstack_1grow (&temporary_obstack, '\0');
5045 ptr = obstack_finish (&temporary_obstack);
5046 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
5047 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
5048 ;
5049 break;}
5050 case 439:
5051 #line 2390 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5052 {yyerror ("']' expected, invalid type expression");;
5053 break;}
5054 case 440:
5055 #line 2392 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5056 {
5057 YYNOT_TWICE yyerror ("Invalid type expression"); RECOVER;
5058 RECOVER;
5059 ;
5060 break;}
5061 case 441:
5062 #line 2397 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5063 {yyerror ("Missing term"); RECOVER;;
5064 break;}
5065 case 442:
5066 #line 2399 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5067 {yyerror ("Missing term"); RECOVER;;
5068 break;}
5069 case 443:
5070 #line 2401 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5071 {yyerror ("Missing term"); RECOVER;;
5072 break;}
5073 case 445:
5074 #line 2407 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5075 {
5076 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
5077 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
5078 ;
5079 break;}
5080 case 446:
5081 #line 2412 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5082 {
5083 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5084 yyvsp[-2].node, yyvsp[0].node);
5085 ;
5086 break;}
5087 case 447:
5088 #line 2417 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5089 {
5090 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5091 yyvsp[-2].node, yyvsp[0].node);
5092 ;
5093 break;}
5094 case 448:
5095 #line 2422 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5096 {yyerror ("Missing term"); RECOVER;;
5097 break;}
5098 case 449:
5099 #line 2424 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5100 {yyerror ("Missing term"); RECOVER;;
5101 break;}
5102 case 450:
5103 #line 2426 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5104 {yyerror ("Missing term"); RECOVER;;
5105 break;}
5106 case 452:
5107 #line 2432 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5108 {
5109 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5110 yyvsp[-2].node, yyvsp[0].node);
5111 ;
5112 break;}
5113 case 453:
5114 #line 2437 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5115 {
5116 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5117 yyvsp[-2].node, yyvsp[0].node);
5118 ;
5119 break;}
5120 case 454:
5121 #line 2442 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5122 {yyerror ("Missing term"); RECOVER;;
5123 break;}
5124 case 455:
5125 #line 2444 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5126 {yyerror ("Missing term"); RECOVER;;
5127 break;}
5128 case 457:
5129 #line 2450 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5130 {
5131 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5132 yyvsp[-2].node, yyvsp[0].node);
5133 ;
5134 break;}
5135 case 458:
5136 #line 2455 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5137 {
5138 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5139 yyvsp[-2].node, yyvsp[0].node);
5140 ;
5141 break;}
5142 case 459:
5143 #line 2460 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5144 {
5145 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5146 yyvsp[-2].node, yyvsp[0].node);
5147 ;
5148 break;}
5149 case 460:
5150 #line 2465 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5151 {yyerror ("Missing term"); RECOVER;;
5152 break;}
5153 case 461:
5154 #line 2467 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5155 {yyerror ("Missing term"); RECOVER;;
5156 break;}
5157 case 462:
5158 #line 2469 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5159 {yyerror ("Missing term"); RECOVER;;
5160 break;}
5161 case 464:
5162 #line 2475 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5163 {
5164 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5165 yyvsp[-2].node, yyvsp[0].node);
5166 ;
5167 break;}
5168 case 465:
5169 #line 2480 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5170 {
5171 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5172 yyvsp[-2].node, yyvsp[0].node);
5173 ;
5174 break;}
5175 case 466:
5176 #line 2485 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5177 {
5178 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5179 yyvsp[-2].node, yyvsp[0].node);
5180 ;
5181 break;}
5182 case 467:
5183 #line 2490 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5184 {
5185 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5186 yyvsp[-2].node, yyvsp[0].node);
5187 ;
5188 break;}
5189 case 468:
5190 #line 2495 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5191 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5192 break;}
5193 case 469:
5194 #line 2497 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5195 {yyerror ("Missing term"); RECOVER;;
5196 break;}
5197 case 470:
5198 #line 2499 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5199 {yyerror ("Missing term"); RECOVER;;
5200 break;}
5201 case 471:
5202 #line 2501 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5203 {yyerror ("Missing term"); RECOVER;;
5204 break;}
5205 case 472:
5206 #line 2503 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5207 {yyerror ("Missing term"); RECOVER;;
5208 break;}
5209 case 473:
5210 #line 2505 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5211 {yyerror ("Invalid reference type"); RECOVER;;
5212 break;}
5213 case 475:
5214 #line 2511 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5215 {
5216 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5217 yyvsp[-2].node, yyvsp[0].node);
5218 ;
5219 break;}
5220 case 476:
5221 #line 2516 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5222 {
5223 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5224 yyvsp[-2].node, yyvsp[0].node);
5225 ;
5226 break;}
5227 case 477:
5228 #line 2521 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5229 {yyerror ("Missing term"); RECOVER;;
5230 break;}
5231 case 478:
5232 #line 2523 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5233 {yyerror ("Missing term"); RECOVER;;
5234 break;}
5235 case 480:
5236 #line 2529 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5237 {
5238 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5239 yyvsp[-2].node, yyvsp[0].node);
5240 ;
5241 break;}
5242 case 481:
5243 #line 2534 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5244 {yyerror ("Missing term"); RECOVER;;
5245 break;}
5246 case 483:
5247 #line 2540 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5248 {
5249 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5250 yyvsp[-2].node, yyvsp[0].node);
5251 ;
5252 break;}
5253 case 484:
5254 #line 2545 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5255 {yyerror ("Missing term"); RECOVER;;
5256 break;}
5257 case 486:
5258 #line 2551 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5259 {
5260 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5261 yyvsp[-2].node, yyvsp[0].node);
5262 ;
5263 break;}
5264 case 487:
5265 #line 2556 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5266 {yyerror ("Missing term"); RECOVER;;
5267 break;}
5268 case 489:
5269 #line 2562 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5270 {
5271 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5272 yyvsp[-2].node, yyvsp[0].node);
5273 ;
5274 break;}
5275 case 490:
5276 #line 2567 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5277 {yyerror ("Missing term"); RECOVER;;
5278 break;}
5279 case 492:
5280 #line 2573 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5281 {
5282 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
5283 yyvsp[-2].node, yyvsp[0].node);
5284 ;
5285 break;}
5286 case 493:
5287 #line 2578 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5288 {yyerror ("Missing term"); RECOVER;;
5289 break;}
5290 case 495:
5291 #line 2584 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5292 {
5293 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
5294 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
5295 ;
5296 break;}
5297 case 496:
5298 #line 2589 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5299 {
5300 YYERROR_NOW;
5301 yyerror ("Missing term");
5302 DRECOVER (1);
5303 ;
5304 break;}
5305 case 497:
5306 #line 2595 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5307 {yyerror ("Missing term"); DRECOVER (2);;
5308 break;}
5309 case 498:
5310 #line 2597 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5311 {yyerror ("Missing term"); DRECOVER (3);;
5312 break;}
5313 case 501:
5314 #line 2607 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5315 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5316 break;}
5317 case 502:
5318 #line 2609 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5319 {
5320 YYNOT_TWICE yyerror ("Missing term");
5321 DRECOVER (assign);
5322 ;
5323 break;}
5324 }
5325
5326 #line 705 "/usr/share/bison/bison.simple"
5327
5328
5329 yyvsp -= yylen;
5330 yyssp -= yylen;
5331 #if YYLSP_NEEDED
5332 yylsp -= yylen;
5333 #endif
5334
5335 #if YYDEBUG
5336 if (yydebug)
5337 {
5338 short *yyssp1 = yyss - 1;
5339 YYFPRINTF (stderr, "state stack now");
5340 while (yyssp1 != yyssp)
5341 YYFPRINTF (stderr, " %d", *++yyssp1);
5342 YYFPRINTF (stderr, "\n");
5343 }
5344 #endif
5345
5346 *++yyvsp = yyval;
5347 #if YYLSP_NEEDED
5348 *++yylsp = yyloc;
5349 #endif
5350
5351 /* Now `shift' the result of the reduction. Determine what state
5352 that goes to, based on the state we popped back to and the rule
5353 number reduced by. */
5354
5355 yyn = yyr1[yyn];
5356
5357 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5358 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5359 yystate = yytable[yystate];
5360 else
5361 yystate = yydefgoto[yyn - YYNTBASE];
5362
5363 goto yynewstate;
5364
5365
5366 /*------------------------------------.
5367 | yyerrlab -- here on detecting error |
5368 `------------------------------------*/
5369 yyerrlab:
5370 /* If not already recovering from an error, report this error. */
5371 if (!yyerrstatus)
5372 {
5373 ++yynerrs;
5374
5375 #ifdef YYERROR_VERBOSE
5376 yyn = yypact[yystate];
5377
5378 if (yyn > YYFLAG && yyn < YYLAST)
5379 {
5380 YYSIZE_T yysize = 0;
5381 char *yymsg;
5382 int yyx, yycount;
5383
5384 yycount = 0;
5385 /* Start YYX at -YYN if negative to avoid negative indexes in
5386 YYCHECK. */
5387 for (yyx = yyn < 0 ? -yyn : 0;
5388 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
5389 if (yycheck[yyx + yyn] == yyx)
5390 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
5391 yysize += yystrlen ("parse error, unexpected ") + 1;
5392 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
5393 yymsg = (char *) YYSTACK_ALLOC (yysize);
5394 if (yymsg != 0)
5395 {
5396 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
5397 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
5398
5399 if (yycount < 5)
5400 {
5401 yycount = 0;
5402 for (yyx = yyn < 0 ? -yyn : 0;
5403 yyx < (int) (sizeof (yytname) / sizeof (char *));
5404 yyx++)
5405 if (yycheck[yyx + yyn] == yyx)
5406 {
5407 const char *yyq = ! yycount ? ", expecting " : " or ";
5408 yyp = yystpcpy (yyp, yyq);
5409 yyp = yystpcpy (yyp, yytname[yyx]);
5410 yycount++;
5411 }
5412 }
5413 yyerror (yymsg);
5414 YYSTACK_FREE (yymsg);
5415 }
5416 else
5417 yyerror ("parse error; also virtual memory exhausted");
5418 }
5419 else
5420 #endif /* defined (YYERROR_VERBOSE) */
5421 yyerror ("parse error");
5422 }
5423 goto yyerrlab1;
5424
5425
5426 /*--------------------------------------------------.
5427 | yyerrlab1 -- error raised explicitly by an action |
5428 `--------------------------------------------------*/
5429 yyerrlab1:
5430 if (yyerrstatus == 3)
5431 {
5432 /* If just tried and failed to reuse lookahead token after an
5433 error, discard it. */
5434
5435 /* return failure if at end of input */
5436 if (yychar == YYEOF)
5437 YYABORT;
5438 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
5439 yychar, yytname[yychar1]));
5440 yychar = YYEMPTY;
5441 }
5442
5443 /* Else will try to reuse lookahead token after shifting the error
5444 token. */
5445
5446 yyerrstatus = 3; /* Each real token shifted decrements this */
5447
5448 goto yyerrhandle;
5449
5450
5451 /*-------------------------------------------------------------------.
5452 | yyerrdefault -- current state does not do anything special for the |
5453 | error token. |
5454 `-------------------------------------------------------------------*/
5455 yyerrdefault:
5456 #if 0
5457 /* This is wrong; only states that explicitly want error tokens
5458 should shift them. */
5459
5460 /* If its default is to accept any token, ok. Otherwise pop it. */
5461 yyn = yydefact[yystate];
5462 if (yyn)
5463 goto yydefault;
5464 #endif
5465
5466
5467 /*---------------------------------------------------------------.
5468 | yyerrpop -- pop the current state because it cannot handle the |
5469 | error token |
5470 `---------------------------------------------------------------*/
5471 yyerrpop:
5472 if (yyssp == yyss)
5473 YYABORT;
5474 yyvsp--;
5475 yystate = *--yyssp;
5476 #if YYLSP_NEEDED
5477 yylsp--;
5478 #endif
5479
5480 #if YYDEBUG
5481 if (yydebug)
5482 {
5483 short *yyssp1 = yyss - 1;
5484 YYFPRINTF (stderr, "Error: state stack now");
5485 while (yyssp1 != yyssp)
5486 YYFPRINTF (stderr, " %d", *++yyssp1);
5487 YYFPRINTF (stderr, "\n");
5488 }
5489 #endif
5490
5491 /*--------------.
5492 | yyerrhandle. |
5493 `--------------*/
5494 yyerrhandle:
5495 yyn = yypact[yystate];
5496 if (yyn == YYFLAG)
5497 goto yyerrdefault;
5498
5499 yyn += YYTERROR;
5500 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5501 goto yyerrdefault;
5502
5503 yyn = yytable[yyn];
5504 if (yyn < 0)
5505 {
5506 if (yyn == YYFLAG)
5507 goto yyerrpop;
5508 yyn = -yyn;
5509 goto yyreduce;
5510 }
5511 else if (yyn == 0)
5512 goto yyerrpop;
5513
5514 if (yyn == YYFINAL)
5515 YYACCEPT;
5516
5517 YYDPRINTF ((stderr, "Shifting error token, "));
5518
5519 *++yyvsp = yylval;
5520 #if YYLSP_NEEDED
5521 *++yylsp = yylloc;
5522 #endif
5523
5524 yystate = yyn;
5525 goto yynewstate;
5526
5527
5528 /*-------------------------------------.
5529 | yyacceptlab -- YYACCEPT comes here. |
5530 `-------------------------------------*/
5531 yyacceptlab:
5532 yyresult = 0;
5533 goto yyreturn;
5534
5535 /*-----------------------------------.
5536 | yyabortlab -- YYABORT comes here. |
5537 `-----------------------------------*/
5538 yyabortlab:
5539 yyresult = 1;
5540 goto yyreturn;
5541
5542 /*---------------------------------------------.
5543 | yyoverflowab -- parser overflow comes here. |
5544 `---------------------------------------------*/
5545 yyoverflowlab:
5546 yyerror ("parser stack overflow");
5547 yyresult = 2;
5548 /* Fall through. */
5549
5550 yyreturn:
5551 #ifndef yyoverflow
5552 if (yyss != yyssa)
5553 YYSTACK_FREE (yyss);
5554 #endif
5555 return yyresult;
5556 }
5557 #line 2634 "/home/mitchell/gcc-3.4.2/gcc-3.4.2/gcc/java/parse.y"
5558
5559
5560 /* Helper function to retrieve an OSB count. Should be used when the
5561 `dims:' rule is being used. */
5562
5563 static int
pop_current_osb(struct parser_ctxt * ctxp)5564 pop_current_osb (struct parser_ctxt *ctxp)
5565 {
5566 int to_return;
5567
5568 if (ctxp->osb_depth < 0)
5569 abort ();
5570
5571 to_return = CURRENT_OSB (ctxp);
5572 ctxp->osb_depth--;
5573
5574 return to_return;
5575 }
5576
5577
5578
5579 /* This section of the code deal with save/restoring parser contexts.
5580 Add mode documentation here. FIXME */
5581
5582 /* Helper function. Create a new parser context. With
5583 COPY_FROM_PREVIOUS set to a nonzero value, content of the previous
5584 context is copied, otherwise, the new context is zeroed. The newly
5585 created context becomes the current one. */
5586
5587 static void
create_new_parser_context(int copy_from_previous)5588 create_new_parser_context (int copy_from_previous)
5589 {
5590 struct parser_ctxt *new;
5591
5592 new = ggc_alloc (sizeof (struct parser_ctxt));
5593 if (copy_from_previous)
5594 {
5595 memcpy (new, ctxp, sizeof (struct parser_ctxt));
5596 /* This flag, indicating the context saves global values,
5597 should only be set by java_parser_context_save_global. */
5598 new->saved_data_ctx = 0;
5599 }
5600 else
5601 memset (new, 0, sizeof (struct parser_ctxt));
5602
5603 new->next = ctxp;
5604 ctxp = new;
5605 }
5606
5607 /* Create a new parser context and make it the current one. */
5608
5609 void
java_push_parser_context(void)5610 java_push_parser_context (void)
5611 {
5612 create_new_parser_context (0);
5613 }
5614
5615 void
java_pop_parser_context(int generate)5616 java_pop_parser_context (int generate)
5617 {
5618 tree current;
5619 struct parser_ctxt *toFree, *next;
5620
5621 if (!ctxp)
5622 return;
5623
5624 toFree = ctxp;
5625 next = ctxp->next;
5626 if (next)
5627 {
5628 input_line = ctxp->lineno;
5629 current_class = ctxp->class_type;
5630 }
5631
5632 /* If the old and new lexers differ, then free the old one. */
5633 if (ctxp->lexer && next && ctxp->lexer != next->lexer)
5634 java_destroy_lexer (ctxp->lexer);
5635
5636 /* Set the single import class file flag to 0 for the current list
5637 of imported things */
5638 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5639 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_VALUE (current)) = 0;
5640
5641 /* And restore those of the previous context */
5642 if ((ctxp = next)) /* Assignment is really meant here */
5643 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5644 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_VALUE (current)) = 1;
5645
5646 /* If we pushed a context to parse a class intended to be generated,
5647 we keep it so we can remember the class. What we could actually
5648 do is to just update a list of class names. */
5649 if (generate)
5650 {
5651 toFree->next = ctxp_for_generation;
5652 ctxp_for_generation = toFree;
5653 }
5654 }
5655
5656 /* Create a parser context for the use of saving some global
5657 variables. */
5658
5659 void
java_parser_context_save_global(void)5660 java_parser_context_save_global (void)
5661 {
5662 if (!ctxp)
5663 {
5664 java_push_parser_context ();
5665 ctxp->saved_data_ctx = 1;
5666 }
5667
5668 /* If this context already stores data, create a new one suitable
5669 for data storage. */
5670 else if (ctxp->saved_data)
5671 {
5672 create_new_parser_context (1);
5673 ctxp->saved_data_ctx = 1;
5674 }
5675
5676 ctxp->lineno = input_line;
5677 ctxp->class_type = current_class;
5678 ctxp->filename = input_filename;
5679 ctxp->function_decl = current_function_decl;
5680 ctxp->saved_data = 1;
5681 }
5682
5683 /* Restore some global variables from the previous context. Make the
5684 previous context the current one. */
5685
5686 void
java_parser_context_restore_global(void)5687 java_parser_context_restore_global (void)
5688 {
5689 input_line = ctxp->lineno;
5690 current_class = ctxp->class_type;
5691 input_filename = ctxp->filename;
5692 if (wfl_operator)
5693 {
5694 tree s;
5695 BUILD_FILENAME_IDENTIFIER_NODE (s, input_filename);
5696 EXPR_WFL_FILENAME_NODE (wfl_operator) = s;
5697 }
5698 current_function_decl = ctxp->function_decl;
5699 ctxp->saved_data = 0;
5700 if (ctxp->saved_data_ctx)
5701 java_pop_parser_context (0);
5702 }
5703
5704 /* Suspend vital data for the current class/function being parsed so
5705 that an other class can be parsed. Used to let local/anonymous
5706 classes be parsed. */
5707
5708 static void
java_parser_context_suspend(void)5709 java_parser_context_suspend (void)
5710 {
5711 /* This makes debugging through java_debug_context easier */
5712 static const char *const name = "<inner buffer context>";
5713
5714 /* Duplicate the previous context, use it to save the globals we're
5715 interested in */
5716 create_new_parser_context (1);
5717 ctxp->function_decl = current_function_decl;
5718 ctxp->class_type = current_class;
5719
5720 /* Then create a new context which inherits all data from the
5721 previous one. This will be the new current context */
5722 create_new_parser_context (1);
5723
5724 /* Help debugging */
5725 ctxp->next->filename = name;
5726 }
5727
5728 /* Resume vital data for the current class/function being parsed so
5729 that an other class can be parsed. Used to let local/anonymous
5730 classes be parsed. The trick is the data storing file position
5731 informations must be restored to their current value, so parsing
5732 can resume as if no context was ever saved. */
5733
5734 static void
java_parser_context_resume(void)5735 java_parser_context_resume (void)
5736 {
5737 struct parser_ctxt *old = ctxp; /* This one is to be discarded */
5738 struct parser_ctxt *saver = old->next; /* This one contain saved info */
5739 struct parser_ctxt *restored = saver->next; /* This one is the old current */
5740
5741 /* We need to inherit the list of classes to complete/generate */
5742 restored->classd_list = old->classd_list;
5743 restored->class_list = old->class_list;
5744
5745 /* Restore the current class and function from the saver */
5746 current_class = saver->class_type;
5747 current_function_decl = saver->function_decl;
5748
5749 /* Retrieve the restored context */
5750 ctxp = restored;
5751
5752 /* Re-installed the data for the parsing to carry on */
5753 memcpy (&ctxp->marker_begining, &old->marker_begining,
5754 (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5755 }
5756
5757 /* Add a new anchor node to which all statement(s) initializing static
5758 and non static initialized upon declaration field(s) will be
5759 linked. */
5760
5761 static void
java_parser_context_push_initialized_field(void)5762 java_parser_context_push_initialized_field (void)
5763 {
5764 tree node;
5765
5766 node = build_tree_list (NULL_TREE, NULL_TREE);
5767 TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5768 CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5769
5770 node = build_tree_list (NULL_TREE, NULL_TREE);
5771 TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5772 CPC_INITIALIZER_LIST (ctxp) = node;
5773
5774 node = build_tree_list (NULL_TREE, NULL_TREE);
5775 TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5776 CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5777 }
5778
5779 /* Pop the lists of initialized field. If this lists aren't empty,
5780 remember them so we can use it to create and populate the finit$
5781 or <clinit> functions. */
5782
5783 static void
java_parser_context_pop_initialized_field(void)5784 java_parser_context_pop_initialized_field (void)
5785 {
5786 tree stmts;
5787 tree class_type = TREE_TYPE (GET_CPC ());
5788
5789 if (CPC_INITIALIZER_LIST (ctxp))
5790 {
5791 stmts = CPC_INITIALIZER_STMT (ctxp);
5792 CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5793 if (stmts && !java_error_count)
5794 TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5795 }
5796
5797 if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5798 {
5799 stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5800 CPC_STATIC_INITIALIZER_LIST (ctxp) =
5801 TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5802 /* Keep initialization in order to enforce 8.5 */
5803 if (stmts && !java_error_count)
5804 TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5805 }
5806
5807 /* JDK 1.1 instance initializers */
5808 if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5809 {
5810 stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5811 CPC_INSTANCE_INITIALIZER_LIST (ctxp) =
5812 TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5813 if (stmts && !java_error_count)
5814 TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5815 }
5816 }
5817
5818 static tree
reorder_static_initialized(tree list)5819 reorder_static_initialized (tree list)
5820 {
5821 /* We have to keep things in order. The alias initializer have to
5822 come first, then the initialized regular field, in reverse to
5823 keep them in lexical order. */
5824 tree marker, previous = NULL_TREE;
5825 for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5826 if (TREE_CODE (marker) == TREE_LIST
5827 && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5828 break;
5829
5830 /* No static initialized, the list is fine as is */
5831 if (!previous)
5832 list = TREE_CHAIN (marker);
5833
5834 /* No marker? reverse the whole list */
5835 else if (!marker)
5836 list = nreverse (list);
5837
5838 /* Otherwise, reverse what's after the marker and the new reordered
5839 sublist will replace the marker. */
5840 else
5841 {
5842 TREE_CHAIN (previous) = NULL_TREE;
5843 list = nreverse (list);
5844 list = chainon (TREE_CHAIN (marker), list);
5845 }
5846 return list;
5847 }
5848
5849 /* Helper functions to dump the parser context stack. */
5850
5851 #define TAB_CONTEXT(C) \
5852 {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5853
5854 static void
java_debug_context_do(int tab)5855 java_debug_context_do (int tab)
5856 {
5857 struct parser_ctxt *copy = ctxp;
5858 while (copy)
5859 {
5860 TAB_CONTEXT (tab);
5861 fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5862 TAB_CONTEXT (tab);
5863 fprintf (stderr, "filename: %s\n", copy->filename);
5864 TAB_CONTEXT (tab);
5865 fprintf (stderr, "lineno: %d\n", copy->lineno);
5866 TAB_CONTEXT (tab);
5867 fprintf (stderr, "package: %s\n",
5868 (copy->package ?
5869 IDENTIFIER_POINTER (copy->package) : "<none>"));
5870 TAB_CONTEXT (tab);
5871 fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5872 TAB_CONTEXT (tab);
5873 fprintf (stderr, "saved data: %d\n", copy->saved_data);
5874 copy = copy->next;
5875 tab += 2;
5876 }
5877 }
5878
5879 /* Dump the stacked up parser contexts. Intended to be called from a
5880 debugger. */
5881
5882 void
java_debug_context(void)5883 java_debug_context (void)
5884 {
5885 java_debug_context_do (0);
5886 }
5887
5888
5889
5890 /* Flag for the error report routine to issue the error the first time
5891 it's called (overriding the default behavior which is to drop the
5892 first invocation and honor the second one, taking advantage of a
5893 richer context. */
5894 static int force_error = 0;
5895
5896 /* Reporting an constructor invocation error. */
5897 static void
parse_ctor_invocation_error(void)5898 parse_ctor_invocation_error (void)
5899 {
5900 if (DECL_CONSTRUCTOR_P (current_function_decl))
5901 yyerror ("Constructor invocation must be first thing in a constructor");
5902 else
5903 yyerror ("Only constructors can invoke constructors");
5904 }
5905
5906 /* Reporting JDK1.1 features not implemented. */
5907
5908 static tree
parse_jdk1_1_error(const char * msg)5909 parse_jdk1_1_error (const char *msg)
5910 {
5911 sorry (": `%s' JDK1.1(TM) feature", msg);
5912 java_error_count++;
5913 return empty_stmt_node;
5914 }
5915
5916 static int do_warning = 0;
5917
5918 void
yyerror(const char * msg)5919 yyerror (const char *msg)
5920 {
5921 static java_lc elc;
5922 static int prev_lineno;
5923 static const char *prev_msg;
5924
5925 int save_lineno;
5926 char *remainder, *code_from_source;
5927
5928 if (!force_error && prev_lineno == input_line)
5929 return;
5930
5931 /* Save current error location but report latter, when the context is
5932 richer. */
5933 if (ctxp->java_error_flag == 0)
5934 {
5935 ctxp->java_error_flag = 1;
5936 elc = ctxp->elc;
5937 /* Do something to use the previous line if we're reaching the
5938 end of the file... */
5939 #ifdef VERBOSE_SKELETON
5940 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5941 #endif
5942 return;
5943 }
5944
5945 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5946 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5947 return;
5948
5949 ctxp->java_error_flag = 0;
5950 if (do_warning)
5951 java_warning_count++;
5952 else
5953 java_error_count++;
5954
5955 if (elc.col == 0 && msg && msg[1] == ';')
5956 {
5957 elc.col = ctxp->p_line->char_col-1;
5958 elc.line = ctxp->p_line->lineno;
5959 }
5960
5961 save_lineno = input_line;
5962 prev_lineno = input_line = elc.line;
5963 prev_msg = msg;
5964
5965 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5966 obstack_grow0 (&temporary_obstack,
5967 code_from_source, strlen (code_from_source));
5968 remainder = obstack_finish (&temporary_obstack);
5969 if (do_warning)
5970 warning ("%s.\n%s", msg, remainder);
5971 else
5972 error ("%s.\n%s", msg, remainder);
5973
5974 /* This allow us to cheaply avoid an extra 'Invalid expression
5975 statement' error report when errors have been already reported on
5976 the same line. This occurs when we report an error but don't have
5977 a synchronization point other than ';', which
5978 expression_statement is the only one to take care of. */
5979 ctxp->prevent_ese = input_line = save_lineno;
5980 }
5981
5982 static void
issue_warning_error_from_context(tree cl,const char * msg,va_list ap)5983 issue_warning_error_from_context (tree cl, const char *msg, va_list ap)
5984 {
5985 const char *saved, *saved_input_filename;
5986 char buffer [4096];
5987 vsprintf (buffer, msg, ap);
5988 force_error = 1;
5989
5990 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5991 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5992 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5993
5994 /* We have a CL, that's a good reason for using it if it contains data */
5995 saved = ctxp->filename;
5996 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5997 ctxp->filename = EXPR_WFL_FILENAME (cl);
5998 saved_input_filename = input_filename;
5999 input_filename = ctxp->filename;
6000 java_error (NULL);
6001 java_error (buffer);
6002 ctxp->filename = saved;
6003 input_filename = saved_input_filename;
6004 force_error = 0;
6005 }
6006
6007 /* Issue an error message at a current source line CL */
6008
6009 void
parse_error_context(tree cl,const char * msg,...)6010 parse_error_context (tree cl, const char *msg, ...)
6011 {
6012 va_list ap;
6013 va_start (ap, msg);
6014 issue_warning_error_from_context (cl, msg, ap);
6015 va_end (ap);
6016 }
6017
6018 /* Issue a warning at a current source line CL */
6019
6020 static void
parse_warning_context(tree cl,const char * msg,...)6021 parse_warning_context (tree cl, const char *msg, ...)
6022 {
6023 va_list ap;
6024 va_start (ap, msg);
6025
6026 force_error = do_warning = 1;
6027 issue_warning_error_from_context (cl, msg, ap);
6028 do_warning = force_error = 0;
6029 va_end (ap);
6030 }
6031
6032 static tree
find_expr_with_wfl(tree node)6033 find_expr_with_wfl (tree node)
6034 {
6035 while (node)
6036 {
6037 char code;
6038 tree to_return;
6039
6040 switch (TREE_CODE (node))
6041 {
6042 case BLOCK:
6043 node = BLOCK_EXPR_BODY (node);
6044 continue;
6045
6046 case COMPOUND_EXPR:
6047 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
6048 if (to_return)
6049 return to_return;
6050 node = TREE_OPERAND (node, 1);
6051 continue;
6052
6053 case LOOP_EXPR:
6054 node = TREE_OPERAND (node, 0);
6055 continue;
6056
6057 case LABELED_BLOCK_EXPR:
6058 node = TREE_OPERAND (node, 1);
6059 continue;
6060
6061 default:
6062 code = TREE_CODE_CLASS (TREE_CODE (node));
6063 if (((code == '1') || (code == '2') || (code == 'e'))
6064 && EXPR_WFL_LINECOL (node))
6065 return node;
6066 return NULL_TREE;
6067 }
6068 }
6069 return NULL_TREE;
6070 }
6071
6072 /* Issue a missing return statement error. Uses METHOD to figure the
6073 last line of the method the error occurs in. */
6074
6075 static void
missing_return_error(tree method)6076 missing_return_error (tree method)
6077 {
6078 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_FUNCTION_LAST_LINE (method), -2);
6079 parse_error_context (wfl_operator, "Missing return statement");
6080 }
6081
6082 /* Issue an unreachable statement error. From NODE, find the next
6083 statement to report appropriately. */
6084 static void
unreachable_stmt_error(tree node)6085 unreachable_stmt_error (tree node)
6086 {
6087 /* Browse node to find the next expression node that has a WFL. Use
6088 the location to report the error */
6089 if (TREE_CODE (node) == COMPOUND_EXPR)
6090 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
6091 else
6092 node = find_expr_with_wfl (node);
6093
6094 if (node)
6095 {
6096 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
6097 parse_error_context (wfl_operator, "Unreachable statement");
6098 }
6099 else
6100 abort ();
6101 }
6102
6103 static int
not_accessible_field_error(tree wfl,tree decl)6104 not_accessible_field_error (tree wfl, tree decl)
6105 {
6106 parse_error_context
6107 (wfl, "Can't access %s field `%s.%s' from `%s'",
6108 java_accstring_lookup (get_access_flags_from_decl (decl)),
6109 GET_TYPE_NAME (DECL_CONTEXT (decl)),
6110 IDENTIFIER_POINTER (DECL_NAME (decl)),
6111 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
6112 return 1;
6113 }
6114
6115 int
java_report_errors(void)6116 java_report_errors (void)
6117 {
6118 if (java_error_count)
6119 fprintf (stderr, "%d error%s",
6120 java_error_count, (java_error_count == 1 ? "" : "s"));
6121 if (java_warning_count)
6122 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
6123 java_warning_count, (java_warning_count == 1 ? "" : "s"));
6124 if (java_error_count || java_warning_count)
6125 putc ('\n', stderr);
6126 return java_error_count;
6127 }
6128
6129 static char *
java_accstring_lookup(int flags)6130 java_accstring_lookup (int flags)
6131 {
6132 static char buffer [80];
6133 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
6134
6135 /* Access modifier looked-up first for easier report on forbidden
6136 access. */
6137 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
6138 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
6139 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
6140 if (flags & ACC_STATIC) COPY_RETURN ("static");
6141 if (flags & ACC_FINAL) COPY_RETURN ("final");
6142 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
6143 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
6144 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
6145 if (flags & ACC_NATIVE) COPY_RETURN ("native");
6146 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
6147 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
6148
6149 buffer [0] = '\0';
6150 return buffer;
6151 #undef COPY_RETURN
6152 }
6153
6154 /* Issuing error messages upon redefinition of classes, interfaces or
6155 variables. */
6156
6157 static void
classitf_redefinition_error(const char * context,tree id,tree decl,tree cl)6158 classitf_redefinition_error (const char *context, tree id, tree decl, tree cl)
6159 {
6160 parse_error_context (cl, "%s `%s' already defined in %s:%d",
6161 context, IDENTIFIER_POINTER (id),
6162 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6163 /* Here we should point out where its redefined. It's a unicode. FIXME */
6164 }
6165
6166 static void
variable_redefinition_error(tree context,tree name,tree type,int line)6167 variable_redefinition_error (tree context, tree name, tree type, int line)
6168 {
6169 const char *type_name;
6170
6171 /* Figure a proper name for type. We might haven't resolved it */
6172 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
6173 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
6174 else
6175 type_name = lang_printable_name (type, 0);
6176
6177 parse_error_context (context,
6178 "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
6179 IDENTIFIER_POINTER (name),
6180 type_name, IDENTIFIER_POINTER (name), line);
6181 }
6182
6183 /* If ANAME is terminated with `[]', it indicates an array. This
6184 function returns the number of `[]' found and if this number is
6185 greater than zero, it extracts the array type name and places it in
6186 the node pointed to by TRIMMED unless TRIMMED is null. */
6187
6188 static int
build_type_name_from_array_name(tree aname,tree * trimmed)6189 build_type_name_from_array_name (tree aname, tree *trimmed)
6190 {
6191 const char *name = IDENTIFIER_POINTER (aname);
6192 int len = IDENTIFIER_LENGTH (aname);
6193 int array_dims;
6194
6195 STRING_STRIP_BRACKETS (name, len, array_dims);
6196
6197 if (array_dims && trimmed)
6198 *trimmed = get_identifier_with_length (name, len);
6199
6200 return array_dims;
6201 }
6202
6203 static tree
build_array_from_name(tree type,tree type_wfl,tree name,tree * ret_name)6204 build_array_from_name (tree type, tree type_wfl, tree name, tree *ret_name)
6205 {
6206 int more_dims = 0;
6207
6208 /* Eventually get more dims */
6209 more_dims = build_type_name_from_array_name (name, &name);
6210
6211 /* If we have, then craft a new type for this variable */
6212 if (more_dims)
6213 {
6214 tree save = type;
6215
6216 /* If we have a pointer, use its type */
6217 if (TREE_CODE (type) == POINTER_TYPE)
6218 type = TREE_TYPE (type);
6219
6220 /* Building the first dimension of a primitive type uses this
6221 function */
6222 if (JPRIMITIVE_TYPE_P (type))
6223 {
6224 type = build_java_array_type (type, -1);
6225 more_dims--;
6226 }
6227 /* Otherwise, if we have a WFL for this type, use it (the type
6228 is already an array on an unresolved type, and we just keep
6229 on adding dimensions) */
6230 else if (type_wfl)
6231 {
6232 type = type_wfl;
6233 more_dims += build_type_name_from_array_name (TYPE_NAME (save),
6234 NULL);
6235 }
6236
6237 /* Add all the dimensions */
6238 while (more_dims--)
6239 type = build_unresolved_array_type (type);
6240
6241 /* The type may have been incomplete in the first place */
6242 if (type_wfl)
6243 type = obtain_incomplete_type (type);
6244 }
6245
6246 if (ret_name)
6247 *ret_name = name;
6248 return type;
6249 }
6250
6251 /* Build something that the type identifier resolver will identify as
6252 being an array to an unresolved type. TYPE_WFL is a WFL on a
6253 identifier. */
6254
6255 static tree
build_unresolved_array_type(tree type_or_wfl)6256 build_unresolved_array_type (tree type_or_wfl)
6257 {
6258 const char *ptr;
6259 tree wfl;
6260
6261 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
6262 just create a array type */
6263 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
6264 return build_java_array_type (type_or_wfl, -1);
6265
6266 obstack_grow (&temporary_obstack,
6267 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
6268 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
6269 obstack_grow0 (&temporary_obstack, "[]", 2);
6270 ptr = obstack_finish (&temporary_obstack);
6271 wfl = build_expr_wfl (get_identifier (ptr),
6272 EXPR_WFL_FILENAME (type_or_wfl),
6273 EXPR_WFL_LINENO (type_or_wfl),
6274 EXPR_WFL_COLNO (type_or_wfl));
6275 /* Re-install the existing qualifications so that the type can be
6276 resolved properly. */
6277 EXPR_WFL_QUALIFICATION (wfl) = EXPR_WFL_QUALIFICATION (type_or_wfl);
6278 return wfl;
6279 }
6280
6281 static void
parser_add_interface(tree class_decl,tree interface_decl,tree wfl)6282 parser_add_interface (tree class_decl, tree interface_decl, tree wfl)
6283 {
6284 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
6285 parse_error_context (wfl, "Interface `%s' repeated",
6286 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
6287 }
6288
6289 /* Bulk of common class/interface checks. Return 1 if an error was
6290 encountered. TAG is 0 for a class, 1 for an interface. */
6291
6292 static int
check_class_interface_creation(int is_interface,int flags,tree raw_name,tree qualified_name,tree decl,tree cl)6293 check_class_interface_creation (int is_interface, int flags, tree raw_name,
6294 tree qualified_name, tree decl, tree cl)
6295 {
6296 tree node;
6297 int sca = 0; /* Static class allowed */
6298 int icaf = 0; /* Inner class allowed flags */
6299 int uaaf = CLASS_MODIFIERS; /* Usually allowed access flags */
6300
6301 if (!quiet_flag)
6302 fprintf (stderr, " %s%s %s",
6303 (CPC_INNER_P () ? "inner" : ""),
6304 (is_interface ? "interface" : "class"),
6305 IDENTIFIER_POINTER (qualified_name));
6306
6307 /* Scope of an interface/class type name:
6308 - Can't be imported by a single type import
6309 - Can't already exists in the package */
6310 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
6311 && (node = find_name_in_single_imports (raw_name))
6312 && !CPC_INNER_P ())
6313 {
6314 parse_error_context
6315 (cl, "%s name `%s' clashes with imported type `%s'",
6316 (is_interface ? "Interface" : "Class"),
6317 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
6318 return 1;
6319 }
6320 if (decl && CLASS_COMPLETE_P (decl))
6321 {
6322 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
6323 qualified_name, decl, cl);
6324 return 1;
6325 }
6326
6327 if (check_inner_class_redefinition (raw_name, cl))
6328 return 1;
6329
6330 /* If public, file name should match class/interface name, except
6331 when dealing with an inner class */
6332 if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6333 {
6334 const char *f;
6335
6336 for (f = &input_filename [strlen (input_filename)];
6337 f != input_filename && ! IS_DIR_SEPARATOR (f[0]);
6338 f--)
6339 ;
6340 if (IS_DIR_SEPARATOR (f[0]))
6341 f++;
6342 if (strncmp (IDENTIFIER_POINTER (raw_name),
6343 f , IDENTIFIER_LENGTH (raw_name)) ||
6344 f [IDENTIFIER_LENGTH (raw_name)] != '.')
6345 parse_error_context
6346 (cl, "Public %s `%s' must be defined in a file called `%s.java'",
6347 (is_interface ? "interface" : "class"),
6348 IDENTIFIER_POINTER (qualified_name),
6349 IDENTIFIER_POINTER (raw_name));
6350 }
6351
6352 /* Static classes can be declared only in top level classes. Note:
6353 once static, a inner class is a top level class. */
6354 if (flags & ACC_STATIC)
6355 {
6356 /* Catch the specific error of declaring an class inner class
6357 with no toplevel enclosing class. Prevent check_modifiers from
6358 complaining a second time */
6359 if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6360 {
6361 parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
6362 IDENTIFIER_POINTER (qualified_name));
6363 sca = ACC_STATIC;
6364 }
6365 /* Else, in the context of a top-level class declaration, let
6366 `check_modifiers' do its job, otherwise, give it a go */
6367 else
6368 sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6369 }
6370
6371 /* Inner classes can be declared private or protected
6372 within their enclosing classes. */
6373 if (CPC_INNER_P ())
6374 {
6375 /* A class which is local to a block can't be public, private,
6376 protected or static. But it is created final, so allow this
6377 one. */
6378 if (current_function_decl)
6379 icaf = sca = uaaf = ACC_FINAL;
6380 else
6381 {
6382 check_modifiers_consistency (flags);
6383 icaf = ACC_PROTECTED;
6384 if (! CLASS_INTERFACE (GET_CPC ()))
6385 icaf |= ACC_PRIVATE;
6386 }
6387 }
6388
6389 if (is_interface)
6390 {
6391 if (CPC_INNER_P ())
6392 uaaf = INTERFACE_INNER_MODIFIERS;
6393 else
6394 uaaf = INTERFACE_MODIFIERS;
6395
6396 check_modifiers ("Illegal modifier `%s' for interface declaration",
6397 flags, uaaf);
6398 }
6399 else
6400 check_modifiers ((current_function_decl ?
6401 "Illegal modifier `%s' for local class declaration" :
6402 "Illegal modifier `%s' for class declaration"),
6403 flags, uaaf|sca|icaf);
6404 return 0;
6405 }
6406
6407 /* Construct a nested class name. If the final component starts with
6408 a digit, return true. Otherwise return false. */
6409 static int
make_nested_class_name(tree cpc_list)6410 make_nested_class_name (tree cpc_list)
6411 {
6412 tree name;
6413
6414 if (!cpc_list)
6415 return 0;
6416
6417 make_nested_class_name (TREE_CHAIN (cpc_list));
6418
6419 /* Pick the qualified name when dealing with the first upmost
6420 enclosing class */
6421 name = (TREE_CHAIN (cpc_list)
6422 ? TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6423 obstack_grow (&temporary_obstack,
6424 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6425 obstack_1grow (&temporary_obstack, '$');
6426
6427 return ISDIGIT (IDENTIFIER_POINTER (name)[0]);
6428 }
6429
6430 /* Can't redefine a class already defined in an earlier scope. */
6431
6432 static int
check_inner_class_redefinition(tree raw_name,tree cl)6433 check_inner_class_redefinition (tree raw_name, tree cl)
6434 {
6435 tree scope_list;
6436
6437 for (scope_list = GET_CPC_LIST (); scope_list;
6438 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6439 if (raw_name == GET_CPC_UN_NODE (scope_list))
6440 {
6441 parse_error_context
6442 (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",
6443 IDENTIFIER_POINTER (raw_name));
6444 return 1;
6445 }
6446 return 0;
6447 }
6448
6449 /* Tries to find a decl for CLASS_TYPE within ENCLOSING. If we fail,
6450 we remember ENCLOSING and SUPER. */
6451
6452 static tree
resolve_inner_class(htab_t circularity_hash,tree cl,tree * enclosing,tree * super,tree class_type)6453 resolve_inner_class (htab_t circularity_hash, tree cl, tree *enclosing,
6454 tree *super, tree class_type)
6455 {
6456 tree local_enclosing = *enclosing;
6457 tree local_super = NULL_TREE;
6458
6459 while (local_enclosing)
6460 {
6461 tree intermediate, decl;
6462
6463 *htab_find_slot (circularity_hash, local_enclosing, INSERT) =
6464 local_enclosing;
6465
6466 if ((decl = find_as_inner_class (local_enclosing, class_type, cl)))
6467 return decl;
6468
6469 intermediate = local_enclosing;
6470 /* Explore enclosing contexts. */
6471 while (INNER_CLASS_DECL_P (intermediate))
6472 {
6473 intermediate = DECL_CONTEXT (intermediate);
6474 if ((decl = find_as_inner_class (intermediate, class_type, cl)))
6475 return decl;
6476 }
6477
6478 /* Now go to the upper classes, bail out if necessary. We will
6479 analyze the returned SUPER and act accordingly (see
6480 do_resolve_class). */
6481 if (JPRIMITIVE_TYPE_P (TREE_TYPE (local_enclosing))
6482 || TREE_TYPE (local_enclosing) == void_type_node)
6483 {
6484 parse_error_context (cl, "Qualifier must be a reference");
6485 local_enclosing = NULL_TREE;
6486 break;
6487 }
6488 local_super = CLASSTYPE_SUPER (TREE_TYPE (local_enclosing));
6489 if (!local_super || local_super == object_type_node)
6490 break;
6491
6492 if (TREE_CODE (local_super) == POINTER_TYPE)
6493 local_super = do_resolve_class (NULL, local_super, NULL, NULL);
6494 else
6495 local_super = TYPE_NAME (local_super);
6496
6497 /* We may not have checked for circular inheritance yet, so do so
6498 here to prevent an infinite loop. */
6499 if (htab_find (circularity_hash, local_super) != NULL)
6500 {
6501 if (!cl)
6502 cl = lookup_cl (local_enclosing);
6503
6504 parse_error_context
6505 (cl, "Cyclic inheritance involving %s",
6506 IDENTIFIER_POINTER (DECL_NAME (local_enclosing)));
6507 local_enclosing = NULL_TREE;
6508 }
6509 else
6510 local_enclosing = local_super;
6511 }
6512
6513 /* We failed. Return LOCAL_SUPER and LOCAL_ENCLOSING. */
6514 *super = local_super;
6515 *enclosing = local_enclosing;
6516
6517 return NULL_TREE;
6518 }
6519
6520 /* Within ENCLOSING, find a decl for NAME and return it. NAME can be
6521 qualified. */
6522
6523 static tree
find_as_inner_class(tree enclosing,tree name,tree cl)6524 find_as_inner_class (tree enclosing, tree name, tree cl)
6525 {
6526 tree qual, to_return;
6527 if (!enclosing)
6528 return NULL_TREE;
6529
6530 name = TYPE_NAME (name);
6531
6532 /* First search: within the scope of `enclosing', search for name */
6533 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6534 qual = EXPR_WFL_QUALIFICATION (cl);
6535 else if (cl)
6536 qual = build_tree_list (cl, NULL_TREE);
6537 else
6538 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6539
6540 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6541 return to_return;
6542
6543 /* We're dealing with a qualified name. Try to resolve thing until
6544 we get something that is an enclosing class. */
6545 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6546 {
6547 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6548
6549 for (qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6550 qual = TREE_CHAIN (qual))
6551 {
6552 acc = merge_qualified_name (acc,
6553 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6554 BUILD_PTR_FROM_NAME (ptr, acc);
6555 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6556 }
6557
6558 /* A NULL qual and a decl means that the search ended
6559 successfully?!? We have to do something then. FIXME */
6560
6561 if (decl)
6562 enclosing = decl;
6563 else
6564 qual = EXPR_WFL_QUALIFICATION (cl);
6565 }
6566 /* Otherwise, create a qual for the other part of the resolution. */
6567 else
6568 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6569
6570 return find_as_inner_class_do (qual, enclosing);
6571 }
6572
6573 /* We go inside the list of sub classes and try to find a way
6574 through. */
6575
6576 static tree
find_as_inner_class_do(tree qual,tree enclosing)6577 find_as_inner_class_do (tree qual, tree enclosing)
6578 {
6579 if (!qual)
6580 return NULL_TREE;
6581
6582 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6583 {
6584 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6585 tree next_enclosing = NULL_TREE;
6586 tree inner_list;
6587
6588 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6589 inner_list; inner_list = TREE_CHAIN (inner_list))
6590 {
6591 if (TREE_VALUE (inner_list) == name_to_match)
6592 {
6593 next_enclosing = TREE_PURPOSE (inner_list);
6594 break;
6595 }
6596 }
6597 enclosing = next_enclosing;
6598 }
6599
6600 return (!qual && enclosing ? enclosing : NULL_TREE);
6601 }
6602
6603 /* Reach all inner classes and tie their unqualified name to a
6604 DECL. */
6605
6606 static void
set_nested_class_simple_name_value(tree outer,int set)6607 set_nested_class_simple_name_value (tree outer, int set)
6608 {
6609 tree l;
6610
6611 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6612 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6613 TREE_PURPOSE (l) : NULL_TREE);
6614 }
6615
6616 static void
link_nested_class_to_enclosing(void)6617 link_nested_class_to_enclosing (void)
6618 {
6619 if (GET_ENCLOSING_CPC ())
6620 {
6621 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6622 DECL_INNER_CLASS_LIST (enclosing) =
6623 tree_cons (GET_CPC (), GET_CPC_UN (),
6624 DECL_INNER_CLASS_LIST (enclosing));
6625 }
6626 }
6627
6628 static tree
maybe_make_nested_class_name(tree name)6629 maybe_make_nested_class_name (tree name)
6630 {
6631 tree id = NULL_TREE;
6632
6633 if (CPC_INNER_P ())
6634 {
6635 /* If we're in a function, we must append a number to create the
6636 nested class name. However, we don't do this if the class we
6637 are constructing is anonymous, because in that case we'll
6638 already have a number as the class name. */
6639 if (! make_nested_class_name (GET_CPC_LIST ())
6640 && current_function_decl != NULL_TREE
6641 && ! ISDIGIT (IDENTIFIER_POINTER (name)[0]))
6642 {
6643 char buf[10];
6644 sprintf (buf, "%d", anonymous_class_counter);
6645 ++anonymous_class_counter;
6646 obstack_grow (&temporary_obstack, buf, strlen (buf));
6647 obstack_1grow (&temporary_obstack, '$');
6648 }
6649 obstack_grow0 (&temporary_obstack,
6650 IDENTIFIER_POINTER (name),
6651 IDENTIFIER_LENGTH (name));
6652 id = get_identifier (obstack_finish (&temporary_obstack));
6653 if (ctxp->package)
6654 QUALIFIED_P (id) = 1;
6655 }
6656 return id;
6657 }
6658
6659 /* If DECL is NULL, create and push a new DECL, record the current
6660 line CL and do other maintenance things. */
6661
6662 static tree
maybe_create_class_interface_decl(tree decl,tree raw_name,tree qualified_name,tree cl)6663 maybe_create_class_interface_decl (tree decl, tree raw_name,
6664 tree qualified_name, tree cl)
6665 {
6666 if (!decl)
6667 decl = push_class (make_class (), qualified_name);
6668
6669 /* Take care of the file and line business */
6670 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6671 /* If we're emitting xrefs, store the line/col number information */
6672 if (flag_emit_xref)
6673 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6674 else
6675 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6676 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6677 CLASS_PARSED_P (TREE_TYPE (decl)) = 1;
6678 CLASS_FROM_CURRENTLY_COMPILED_P (TREE_TYPE (decl)) =
6679 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6680
6681 PUSH_CPC (decl, raw_name);
6682 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6683
6684 /* Link the declaration to the already seen ones */
6685 TREE_CHAIN (decl) = ctxp->class_list;
6686 ctxp->class_list = decl;
6687
6688 /* Create a new nodes in the global lists */
6689 gclass_list = tree_cons (NULL_TREE, decl, gclass_list);
6690 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6691
6692 /* Install a new dependency list element */
6693 create_jdep_list (ctxp);
6694
6695 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6696 IDENTIFIER_POINTER (qualified_name)));
6697 return decl;
6698 }
6699
6700 static void
add_superinterfaces(tree decl,tree interface_list)6701 add_superinterfaces (tree decl, tree interface_list)
6702 {
6703 tree node;
6704 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6705 takes care of ensuring that:
6706 - This is an accessible interface type,
6707 - Circularity detection.
6708 parser_add_interface is then called. If present but not defined,
6709 the check operation is delayed until the super interface gets
6710 defined. */
6711 for (node = interface_list; node; node = TREE_CHAIN (node))
6712 {
6713 tree current = TREE_PURPOSE (node);
6714 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6715 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6716 {
6717 if (!parser_check_super_interface (idecl, decl, current))
6718 parser_add_interface (decl, idecl, current);
6719 }
6720 else
6721 register_incomplete_type (JDEP_INTERFACE,
6722 current, decl, NULL_TREE);
6723 }
6724 }
6725
6726 /* Create an interface in pass1 and return its decl. Return the
6727 interface's decl in pass 2. */
6728
6729 static tree
create_interface(int flags,tree id,tree super)6730 create_interface (int flags, tree id, tree super)
6731 {
6732 tree raw_name = EXPR_WFL_NODE (id);
6733 tree q_name = parser_qualified_classname (raw_name);
6734 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6735
6736 /* Certain syntax errors are making SUPER be like ID. Avoid this
6737 case. */
6738 if (ctxp->class_err && id == super)
6739 super = NULL;
6740
6741 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6742
6743 /* Basic checks: scope, redefinition, modifiers */
6744 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6745 {
6746 PUSH_ERROR ();
6747 return NULL_TREE;
6748 }
6749
6750 /* Suspend the current parsing context if we're parsing an inner
6751 interface */
6752 if (CPC_INNER_P ())
6753 {
6754 java_parser_context_suspend ();
6755 /* Interface members are public. */
6756 if (CLASS_INTERFACE (GET_CPC ()))
6757 flags |= ACC_PUBLIC;
6758 }
6759
6760 /* Push a new context for (static) initialized upon declaration fields */
6761 java_parser_context_push_initialized_field ();
6762
6763 /* Interface modifiers check
6764 - public/abstract allowed (already done at that point)
6765 - abstract is obsolete (comes first, it's a warning, or should be)
6766 - Can't use twice the same (checked in the modifier rule) */
6767 if ((flags & ACC_ABSTRACT) && flag_redundant)
6768 parse_warning_context
6769 (MODIFIER_WFL (ABSTRACT_TK),
6770 "Redundant use of `abstract' modifier. Interface `%s' is implicitly abstract", IDENTIFIER_POINTER (raw_name));
6771
6772 /* Create a new decl if DECL is NULL, otherwise fix it */
6773 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6774
6775 /* Set super info and mark the class a complete */
6776 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6777 object_type_node, ctxp->interface_number);
6778 ctxp->interface_number = 0;
6779 CLASS_COMPLETE_P (decl) = 1;
6780 add_superinterfaces (decl, super);
6781
6782 /* Eventually sets the @deprecated tag flag */
6783 CHECK_DEPRECATED (decl);
6784
6785 return decl;
6786 }
6787
6788 /* Patch anonymous class CLASS, by either extending or implementing
6789 DEP. */
6790
6791 static void
patch_anonymous_class(tree type_decl,tree class_decl,tree wfl)6792 patch_anonymous_class (tree type_decl, tree class_decl, tree wfl)
6793 {
6794 tree class = TREE_TYPE (class_decl);
6795 tree type = TREE_TYPE (type_decl);
6796 tree binfo = TYPE_BINFO (class);
6797
6798 /* If it's an interface, implement it */
6799 if (CLASS_INTERFACE (type_decl))
6800 {
6801 tree s_binfo;
6802 int length;
6803
6804 if (parser_check_super_interface (type_decl, class_decl, wfl))
6805 return;
6806
6807 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6808 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6809 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6810 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6811 /* And add the interface */
6812 parser_add_interface (class_decl, type_decl, wfl);
6813 }
6814 /* Otherwise, it's a type we want to extend */
6815 else
6816 {
6817 if (parser_check_super (type_decl, class_decl, wfl))
6818 return;
6819 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6820 }
6821 }
6822
6823 static tree
create_anonymous_class(int location,tree type_name)6824 create_anonymous_class (int location, tree type_name)
6825 {
6826 char buffer [80];
6827 tree super = NULL_TREE, itf = NULL_TREE;
6828 tree id, type_decl, class;
6829
6830 /* The unqualified name of the anonymous class. It's just a number. */
6831 sprintf (buffer, "%d", anonymous_class_counter++);
6832 id = build_wfl_node (get_identifier (buffer));
6833 EXPR_WFL_LINECOL (id) = location;
6834
6835 /* We know about the type to extend/implement. We go ahead */
6836 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6837 {
6838 /* Create a class which either implements on extends the designated
6839 class. The class bears an inaccessible name. */
6840 if (CLASS_INTERFACE (type_decl))
6841 {
6842 /* It's OK to modify it here. It's been already used and
6843 shouldn't be reused */
6844 ctxp->interface_number = 1;
6845 /* Interfaces should presented as a list of WFLs */
6846 itf = build_tree_list (type_name, NULL_TREE);
6847 }
6848 else
6849 super = type_name;
6850 }
6851
6852 class = create_class (ACC_FINAL, id, super, itf);
6853
6854 /* We didn't know anything about the stuff. We register a dependence. */
6855 if (!type_decl)
6856 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6857
6858 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6859 return class;
6860 }
6861
6862 /* Create a class in pass1 and return its decl. Return class
6863 interface's decl in pass 2. */
6864
6865 static tree
create_class(int flags,tree id,tree super,tree interfaces)6866 create_class (int flags, tree id, tree super, tree interfaces)
6867 {
6868 tree raw_name = EXPR_WFL_NODE (id);
6869 tree class_id, decl;
6870 tree super_decl_type;
6871
6872 /* Certain syntax errors are making SUPER be like ID. Avoid this
6873 case. */
6874 if (ctxp->class_err && id == super)
6875 super = NULL;
6876
6877 class_id = parser_qualified_classname (raw_name);
6878 decl = IDENTIFIER_CLASS_VALUE (class_id);
6879 EXPR_WFL_NODE (id) = class_id;
6880
6881 /* Basic check: scope, redefinition, modifiers */
6882 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6883 {
6884 PUSH_ERROR ();
6885 return NULL_TREE;
6886 }
6887
6888 /* Suspend the current parsing context if we're parsing an inner
6889 class or an anonymous class. */
6890 if (CPC_INNER_P ())
6891 {
6892 java_parser_context_suspend ();
6893 /* Interface members are public. */
6894 if (CLASS_INTERFACE (GET_CPC ()))
6895 flags |= ACC_PUBLIC;
6896 }
6897
6898 /* Push a new context for (static) initialized upon declaration fields */
6899 java_parser_context_push_initialized_field ();
6900
6901 /* Class modifier check:
6902 - Allowed modifier (already done at that point)
6903 - abstract AND final forbidden
6904 - Public classes defined in the correct file */
6905 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6906 parse_error_context
6907 (id, "Class `%s' can't be declared both abstract and final",
6908 IDENTIFIER_POINTER (raw_name));
6909
6910 /* Create a new decl if DECL is NULL, otherwise fix it */
6911 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6912
6913 /* If SUPER exists, use it, otherwise use Object */
6914 if (super)
6915 {
6916 /* Can't extend java.lang.Object */
6917 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6918 {
6919 parse_error_context (id, "Can't extend `java.lang.Object'");
6920 return NULL_TREE;
6921 }
6922
6923 super_decl_type =
6924 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6925 }
6926 else if (TREE_TYPE (decl) != object_type_node)
6927 super_decl_type = object_type_node;
6928 /* We're defining java.lang.Object */
6929 else
6930 super_decl_type = NULL_TREE;
6931
6932 /* A class nested in an interface is implicitly static. */
6933 if (INNER_CLASS_DECL_P (decl)
6934 && CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (DECL_CONTEXT (decl)))))
6935 {
6936 flags |= ACC_STATIC;
6937 }
6938
6939 /* Set super info and mark the class as complete. */
6940 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6941 ctxp->interface_number);
6942 ctxp->interface_number = 0;
6943 CLASS_COMPLETE_P (decl) = 1;
6944 add_superinterfaces (decl, interfaces);
6945
6946 /* Add the private this$<n> field, Replicate final locals still in
6947 scope as private final fields mangled like val$<local_name>.
6948 This doesn't not occur for top level (static) inner classes. */
6949 if (PURE_INNER_CLASS_DECL_P (decl))
6950 add_inner_class_fields (decl, current_function_decl);
6951
6952 /* If doing xref, store the location at which the inherited class
6953 (if any) was seen. */
6954 if (flag_emit_xref && super)
6955 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6956
6957 /* Eventually sets the @deprecated tag flag */
6958 CHECK_DEPRECATED (decl);
6959
6960 /* Reset the anonymous class counter when declaring non inner classes */
6961 if (!INNER_CLASS_DECL_P (decl))
6962 anonymous_class_counter = 1;
6963
6964 return decl;
6965 }
6966
6967 /* End a class declaration: register the statements used to create
6968 finit$ and <clinit>, pop the current class and resume the prior
6969 parser context if necessary. */
6970
6971 static void
end_class_declaration(int resume)6972 end_class_declaration (int resume)
6973 {
6974 /* If an error occurred, context weren't pushed and won't need to be
6975 popped by a resume. */
6976 int no_error_occurred = ctxp->next && GET_CPC () != error_mark_node;
6977
6978 if (GET_CPC () != error_mark_node)
6979 dump_java_tree (TDI_class, GET_CPC ());
6980
6981 java_parser_context_pop_initialized_field ();
6982 POP_CPC ();
6983 if (resume && no_error_occurred)
6984 java_parser_context_resume ();
6985
6986 /* We're ending a class declaration, this is a good time to reset
6987 the interface cout. Note that might have been already done in
6988 create_interface, but if at that time an inner class was being
6989 dealt with, the interface count was reset in a context created
6990 for the sake of handling inner classes declaration. */
6991 ctxp->interface_number = 0;
6992 }
6993
6994 static void
add_inner_class_fields(tree class_decl,tree fct_decl)6995 add_inner_class_fields (tree class_decl, tree fct_decl)
6996 {
6997 tree block, marker, f;
6998
6999 f = add_field (TREE_TYPE (class_decl),
7000 build_current_thisn (TREE_TYPE (class_decl)),
7001 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
7002 ACC_PRIVATE);
7003 FIELD_THISN (f) = 1;
7004
7005 if (!fct_decl)
7006 return;
7007
7008 for (block = GET_CURRENT_BLOCK (fct_decl);
7009 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
7010 {
7011 tree decl;
7012 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
7013 {
7014 tree name, pname;
7015 tree wfl, init, list;
7016
7017 /* Avoid non final arguments. */
7018 if (!LOCAL_FINAL_P (decl))
7019 continue;
7020
7021 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
7022 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
7023 wfl = build_wfl_node (name);
7024 init = build_wfl_node (pname);
7025 /* Build an initialization for the field: it will be
7026 initialized by a parameter added to finit$, bearing a
7027 mangled name of the field itself (param$<n>.) The
7028 parameter is provided to finit$ by the constructor
7029 invoking it (hence the constructor will also feature a
7030 hidden parameter, set to the value of the outer context
7031 local at the time the inner class is created.)
7032
7033 Note: we take into account all possible locals that can
7034 be accessed by the inner class. It's actually not trivial
7035 to minimize these aliases down to the ones really
7036 used. One way to do that would be to expand all regular
7037 methods first, then finit$ to get a picture of what's
7038 used. It works with the exception that we would have to
7039 go back on all constructor invoked in regular methods to
7040 have their invocation reworked (to include the right amount
7041 of alias initializer parameters.)
7042
7043 The only real way around, I think, is a first pass to
7044 identify locals really used in the inner class. We leave
7045 the flag FIELD_LOCAL_ALIAS_USED around for that future
7046 use.
7047
7048 On the other hand, it only affect local inner classes,
7049 whose constructors (and finit$ call) will be featuring
7050 unnecessary arguments. It's easy for a developer to keep
7051 this number of parameter down by using the `final'
7052 keyword only when necessary. For the time being, we can
7053 issue a warning on unnecessary finals. FIXME */
7054 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
7055 wfl, init);
7056
7057 /* Register the field. The TREE_LIST holding the part
7058 initialized/initializer will be marked ARG_FINAL_P so
7059 that the created field can be marked
7060 FIELD_LOCAL_ALIAS. */
7061 list = build_tree_list (wfl, init);
7062 ARG_FINAL_P (list) = 1;
7063 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
7064 }
7065 }
7066
7067 if (!CPC_INITIALIZER_STMT (ctxp))
7068 return;
7069
7070 /* If we ever registered an alias field, insert and marker to
7071 remember where the list ends. The second part of the list (the one
7072 featuring initialized fields) so it can be later reversed to
7073 enforce 8.5. The marker will be removed during that operation. */
7074 marker = build_tree_list (NULL_TREE, NULL_TREE);
7075 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
7076 SET_CPC_INITIALIZER_STMT (ctxp, marker);
7077 }
7078
7079 /* Can't use lookup_field () since we don't want to load the class and
7080 can't set the CLASS_LOADED_P flag */
7081
7082 static tree
find_field(tree class,tree name)7083 find_field (tree class, tree name)
7084 {
7085 tree decl;
7086 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
7087 {
7088 if (DECL_NAME (decl) == name)
7089 return decl;
7090 }
7091 return NULL_TREE;
7092 }
7093
7094 /* Wrap around lookup_field that doesn't potentially upset the value
7095 of CLASS */
7096
7097 static tree
lookup_field_wrapper(tree class,tree name)7098 lookup_field_wrapper (tree class, tree name)
7099 {
7100 tree type = class;
7101 tree decl = NULL_TREE;
7102 java_parser_context_save_global ();
7103
7104 /* Last chance: if we're within the context of an inner class, we
7105 might be trying to access a local variable defined in an outer
7106 context. We try to look for it now. */
7107 if (INNER_CLASS_TYPE_P (class) && TREE_CODE (name) == IDENTIFIER_NODE)
7108 {
7109 tree new_name;
7110 MANGLE_OUTER_LOCAL_VARIABLE_NAME (new_name, name);
7111 decl = lookup_field (&type, new_name);
7112 if (decl && decl != error_mark_node)
7113 FIELD_LOCAL_ALIAS_USED (decl) = 1;
7114 }
7115 if (!decl || decl == error_mark_node)
7116 {
7117 type = class;
7118 decl = lookup_field (&type, name);
7119 }
7120
7121 /* If the field still hasn't been found, try the next enclosing context. */
7122 if (!decl && INNER_CLASS_TYPE_P (class))
7123 {
7124 tree outer_type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
7125 decl = lookup_field_wrapper (outer_type, name);
7126 }
7127
7128 java_parser_context_restore_global ();
7129 return decl == error_mark_node ? NULL : decl;
7130 }
7131
7132 /* Find duplicate field within the same class declarations and report
7133 the error. Returns 1 if a duplicated field was found, 0
7134 otherwise. */
7135
7136 static int
duplicate_declaration_error_p(tree new_field_name,tree new_type,tree cl)7137 duplicate_declaration_error_p (tree new_field_name, tree new_type, tree cl)
7138 {
7139 /* This might be modified to work with method decl as well */
7140 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
7141 if (decl)
7142 {
7143 char *t1 = xstrdup (purify_type_name
7144 ((TREE_CODE (new_type) == POINTER_TYPE
7145 && TREE_TYPE (new_type) == NULL_TREE) ?
7146 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
7147 lang_printable_name (new_type, 1)));
7148 /* The type may not have been completed by the time we report
7149 the error */
7150 char *t2 = xstrdup (purify_type_name
7151 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
7152 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
7153 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
7154 lang_printable_name (TREE_TYPE (decl), 1)));
7155 parse_error_context
7156 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
7157 t1, IDENTIFIER_POINTER (new_field_name),
7158 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
7159 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
7160 free (t1);
7161 free (t2);
7162 return 1;
7163 }
7164 return 0;
7165 }
7166
7167 /* Field registration routine. If TYPE doesn't exist, field
7168 declarations are linked to the undefined TYPE dependency list, to
7169 be later resolved in java_complete_class () */
7170
7171 static void
register_fields(int flags,tree type,tree variable_list)7172 register_fields (int flags, tree type, tree variable_list)
7173 {
7174 tree current, saved_type;
7175 tree class_type = NULL_TREE;
7176 int saved_lineno = input_line;
7177 int must_chain = 0;
7178 tree wfl = NULL_TREE;
7179
7180 if (GET_CPC ())
7181 class_type = TREE_TYPE (GET_CPC ());
7182
7183 if (!class_type || class_type == error_mark_node)
7184 return;
7185
7186 /* If we're adding fields to interfaces, those fields are public,
7187 static, final */
7188 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7189 {
7190 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
7191 flags, ACC_PUBLIC, "interface field(s)");
7192 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
7193 flags, ACC_STATIC, "interface field(s)");
7194 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
7195 flags, ACC_FINAL, "interface field(s)");
7196 check_modifiers ("Illegal interface member modifier `%s'", flags,
7197 INTERFACE_FIELD_MODIFIERS);
7198 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
7199 }
7200
7201 /* Obtain a suitable type for resolution, if necessary */
7202 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
7203
7204 /* If TYPE is fully resolved and we don't have a reference, make one */
7205 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7206
7207 for (current = variable_list, saved_type = type; current;
7208 current = TREE_CHAIN (current), type = saved_type)
7209 {
7210 tree real_type;
7211 tree field_decl;
7212 tree cl = TREE_PURPOSE (current);
7213 tree init = TREE_VALUE (current);
7214 tree current_name = EXPR_WFL_NODE (cl);
7215
7216 /* Can't declare non-final static fields in inner classes */
7217 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
7218 && !(flags & ACC_FINAL))
7219 parse_error_context
7220 (cl, "Field `%s' can't be static in inner class `%s' unless it is final",
7221 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
7222 lang_printable_name (class_type, 0));
7223
7224 /* Process NAME, as it may specify extra dimension(s) for it */
7225 type = build_array_from_name (type, wfl, current_name, ¤t_name);
7226
7227 /* Type adjustment. We may have just readjusted TYPE because
7228 the variable specified more dimensions. Make sure we have
7229 a reference if we can and don't have one already. Also
7230 change the name if we have an init. */
7231 if (type != saved_type)
7232 {
7233 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7234 if (init)
7235 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
7236 }
7237
7238 real_type = GET_REAL_TYPE (type);
7239 /* Check for redeclarations */
7240 if (duplicate_declaration_error_p (current_name, real_type, cl))
7241 continue;
7242
7243 /* Set lineno to the line the field was found and create a
7244 declaration for it. Eventually sets the @deprecated tag flag. */
7245 if (flag_emit_xref)
7246 input_line = EXPR_WFL_LINECOL (cl);
7247 else
7248 input_line = EXPR_WFL_LINENO (cl);
7249 field_decl = add_field (class_type, current_name, real_type, flags);
7250 CHECK_DEPRECATED_NO_RESET (field_decl);
7251
7252 /* If the field denotes a final instance variable, then we
7253 allocate a LANG_DECL_SPECIFIC part to keep track of its
7254 initialization. We also mark whether the field was
7255 initialized upon its declaration. We don't do that if the
7256 created field is an alias to a final local. */
7257 if (!ARG_FINAL_P (current) && (flags & ACC_FINAL))
7258 {
7259 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field_decl);
7260 DECL_FIELD_FINAL_WFL (field_decl) = cl;
7261 }
7262
7263 /* If the couple initializer/initialized is marked ARG_FINAL_P,
7264 we mark the created field FIELD_LOCAL_ALIAS, so that we can
7265 hide parameters to this inner class finit$ and
7266 constructors. It also means that the field isn't final per
7267 say. */
7268 if (ARG_FINAL_P (current))
7269 {
7270 FIELD_LOCAL_ALIAS (field_decl) = 1;
7271 FIELD_FINAL (field_decl) = 0;
7272 }
7273
7274 /* Check if we must chain. */
7275 if (must_chain)
7276 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
7277
7278 /* If we have an initialization value tied to the field */
7279 if (init)
7280 {
7281 /* The field is declared static */
7282 if (flags & ACC_STATIC)
7283 {
7284 /* We include the field and its initialization part into
7285 a list used to generate <clinit>. After <clinit> is
7286 walked, field initializations will be processed and
7287 fields initialized with known constants will be taken
7288 out of <clinit> and have their DECL_INITIAL set
7289 appropriately. */
7290 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
7291 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
7292 if (TREE_OPERAND (init, 1)
7293 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
7294 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
7295 }
7296 /* A non-static field declared with an immediate initialization is
7297 to be initialized in <init>, if any. This field is remembered
7298 to be processed at the time of the generation of <init>. */
7299 else
7300 {
7301 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
7302 SET_CPC_INITIALIZER_STMT (ctxp, init);
7303 }
7304 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
7305 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
7306 }
7307 }
7308
7309 CLEAR_DEPRECATED;
7310 input_line = saved_lineno;
7311 }
7312
7313 /* Generate finit$, using the list of initialized fields to populate
7314 its body. finit$'s parameter(s) list is adjusted to include the
7315 one(s) used to initialized the field(s) caching outer context
7316 local(s). */
7317
7318 static tree
generate_finit(tree class_type)7319 generate_finit (tree class_type)
7320 {
7321 int count = 0;
7322 tree list = TYPE_FINIT_STMT_LIST (class_type);
7323 tree mdecl, current, parms;
7324
7325 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7326 class_type, NULL_TREE,
7327 &count);
7328 CRAFTED_PARAM_LIST_FIXUP (parms);
7329 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
7330 finit_identifier_node, parms);
7331 fix_method_argument_names (parms, mdecl);
7332 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
7333 mdecl, NULL_TREE);
7334 DECL_FUNCTION_NAP (mdecl) = count;
7335 start_artificial_method_body (mdecl);
7336
7337 for (current = list; current; current = TREE_CHAIN (current))
7338 java_method_add_stmt (mdecl,
7339 build_debugable_stmt (EXPR_WFL_LINECOL (current),
7340 current));
7341 end_artificial_method_body (mdecl);
7342 return mdecl;
7343 }
7344
7345 /* Generate a function to run the instance initialization code. The
7346 private method is called `instinit$'. Unless we're dealing with an
7347 anonymous class, we determine whether all ctors of CLASS_TYPE
7348 declare a checked exception in their `throws' clause in order to
7349 see whether it's necessary to encapsulate the instance initializer
7350 statements in a try/catch/rethrow sequence. */
7351
7352 static tree
generate_instinit(tree class_type)7353 generate_instinit (tree class_type)
7354 {
7355 tree current;
7356 tree compound = NULL_TREE;
7357 tree parms = tree_cons (this_identifier_node,
7358 build_pointer_type (class_type), end_params_node);
7359 tree mdecl = create_artificial_method (class_type, ACC_PRIVATE,
7360 void_type_node,
7361 instinit_identifier_node, parms);
7362
7363 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
7364 mdecl, NULL_TREE);
7365
7366 /* Gather all the statements in a compound */
7367 for (current = TYPE_II_STMT_LIST (class_type);
7368 current; current = TREE_CHAIN (current))
7369 compound = add_stmt_to_compound (compound, NULL_TREE, current);
7370
7371 /* We need to encapsulate COMPOUND by a try/catch statement to
7372 rethrow exceptions that might occur in the instance initializer.
7373 We do that only if all ctors of CLASS_TYPE are set to catch a
7374 checked exception. This doesn't apply to anonymous classes (since
7375 they don't have declared ctors.) */
7376 if (!ANONYMOUS_CLASS_P (class_type) &&
7377 ctors_unchecked_throws_clause_p (class_type))
7378 {
7379 compound = encapsulate_with_try_catch (0, exception_type_node, compound,
7380 build1 (THROW_EXPR, NULL_TREE,
7381 build_wfl_node (wpv_id)));
7382 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
7383 exception_type_node);
7384 }
7385
7386 start_artificial_method_body (mdecl);
7387 java_method_add_stmt (mdecl, compound);
7388 end_artificial_method_body (mdecl);
7389
7390 return mdecl;
7391 }
7392
7393 /* FIXME */
7394 static tree
build_instinit_invocation(tree class_type)7395 build_instinit_invocation (tree class_type)
7396 {
7397 tree to_return = NULL_TREE;
7398
7399 if (TYPE_II_STMT_LIST (class_type))
7400 {
7401 tree parm = build_tree_list (NULL_TREE,
7402 build_wfl_node (this_identifier_node));
7403 to_return =
7404 build_method_invocation (build_wfl_node (instinit_identifier_node),
7405 parm);
7406 }
7407 return to_return;
7408 }
7409
7410 /* Shared across method_declarator and method_header to remember the
7411 patch stage that was reached during the declaration of the method.
7412 A method DECL is built differently is there is no patch
7413 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
7414 pending on the currently defined method. */
7415
7416 static int patch_stage;
7417
7418 /* Check the method declaration and add the method to its current
7419 class. If the argument list is known to contain incomplete types,
7420 the method is partially added and the registration will be resume
7421 once the method arguments resolved. If TYPE is NULL, we're dealing
7422 with a constructor. */
7423
7424 static tree
method_header(int flags,tree type,tree mdecl,tree throws)7425 method_header (int flags, tree type, tree mdecl, tree throws)
7426 {
7427 tree type_wfl = NULL_TREE;
7428 tree meth_name = NULL_TREE;
7429 tree current, orig_arg, this_class = NULL;
7430 tree id, meth;
7431 int saved_lineno;
7432 int constructor_ok = 0, must_chain;
7433 int count;
7434
7435 if (mdecl == error_mark_node)
7436 return error_mark_node;
7437 meth = TREE_VALUE (mdecl);
7438 id = TREE_PURPOSE (mdecl);
7439
7440 check_modifiers_consistency (flags);
7441
7442 if (GET_CPC ())
7443 this_class = TREE_TYPE (GET_CPC ());
7444
7445 if (!this_class || this_class == error_mark_node)
7446 return NULL_TREE;
7447
7448 /* There are some forbidden modifiers for an abstract method and its
7449 class must be abstract as well. */
7450 if (type && (flags & ACC_ABSTRACT))
7451 {
7452 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
7453 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
7454 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
7455 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
7456 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED, id, "Synchronized");
7457 ABSTRACT_CHECK (flags, ACC_STRICT, id, "Strictfp");
7458 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
7459 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
7460 parse_error_context
7461 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
7462 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())),
7463 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7464 }
7465
7466 /* A native method can't be strictfp. */
7467 if ((flags & ACC_NATIVE) && (flags & ACC_STRICT))
7468 parse_error_context (id, "native method `%s' can't be strictfp",
7469 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7470 /* No such thing as a transient or volatile method. */
7471 if ((flags & ACC_TRANSIENT))
7472 parse_error_context (id, "method `%s' can't be transient",
7473 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7474 if ((flags & ACC_VOLATILE))
7475 parse_error_context (id, "method `%s' can't be volatile",
7476 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7477
7478 /* Things to be checked when declaring a constructor */
7479 if (!type)
7480 {
7481 int ec = java_error_count;
7482 /* 8.6: Constructor declarations: we might be trying to define a
7483 method without specifying a return type. */
7484 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
7485 parse_error_context
7486 (id, "Invalid method declaration, return type required");
7487 /* 8.6.3: Constructor modifiers */
7488 else
7489 {
7490 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
7491 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
7492 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
7493 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
7494 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
7495 JCONSTRUCTOR_CHECK (flags, ACC_STRICT, id, "strictfp");
7496 }
7497 /* If we found error here, we don't consider it's OK to tread
7498 the method definition as a constructor, for the rest of this
7499 function */
7500 if (ec == java_error_count)
7501 constructor_ok = 1;
7502 }
7503
7504 /* Method declared within the scope of an interface are implicitly
7505 abstract and public. Conflicts with other erroneously provided
7506 modifiers are checked right after. */
7507
7508 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
7509 {
7510 /* If FLAGS isn't set because of a modifier, turn the
7511 corresponding modifier WFL to NULL so we issue a warning on
7512 the obsolete use of the modifier */
7513 if (!(flags & ACC_PUBLIC))
7514 MODIFIER_WFL (PUBLIC_TK) = NULL;
7515 if (!(flags & ACC_ABSTRACT))
7516 MODIFIER_WFL (ABSTRACT_TK) = NULL;
7517 flags |= ACC_PUBLIC;
7518 flags |= ACC_ABSTRACT;
7519 }
7520
7521 /* Inner class can't declare static methods */
7522 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
7523 {
7524 parse_error_context
7525 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
7526 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7527 lang_printable_name (this_class, 0));
7528 }
7529
7530 /* Modifiers context reset moved up, so abstract method declaration
7531 modifiers can be later checked. */
7532
7533 /* Set constructor returned type to void and method name to <init>,
7534 unless we found an error identifier the constructor (in which
7535 case we retain the original name) */
7536 if (!type)
7537 {
7538 type = void_type_node;
7539 if (constructor_ok)
7540 meth_name = init_identifier_node;
7541 }
7542 else
7543 meth_name = EXPR_WFL_NODE (id);
7544
7545 /* Do the returned type resolution and registration if necessary */
7546 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7547
7548 if (meth_name)
7549 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7550 EXPR_WFL_NODE (id) = meth_name;
7551 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7552
7553 if (must_chain)
7554 {
7555 patch_stage = JDEP_METHOD_RETURN;
7556 register_incomplete_type (patch_stage, type_wfl, id, type);
7557 TREE_TYPE (meth) = GET_REAL_TYPE (type);
7558 }
7559 else
7560 TREE_TYPE (meth) = type;
7561
7562 saved_lineno = input_line;
7563 /* When defining an abstract or interface method, the curly
7564 bracket at level 1 doesn't exist because there is no function
7565 body */
7566 input_line = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
7567 EXPR_WFL_LINENO (id));
7568
7569 /* Remember the original argument list */
7570 orig_arg = TYPE_ARG_TYPES (meth);
7571
7572 if (patch_stage) /* includes ret type and/or all args */
7573 {
7574 jdep *jdep;
7575 meth = add_method_1 (this_class, flags, meth_name, meth);
7576 /* Patch for the return type */
7577 if (patch_stage == JDEP_METHOD_RETURN)
7578 {
7579 jdep = CLASSD_LAST (ctxp->classd_list);
7580 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7581 }
7582 /* This is the stop JDEP. METH allows the function's signature
7583 to be computed. */
7584 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7585 }
7586 else
7587 meth = add_method (this_class, flags, meth_name,
7588 build_java_signature (meth));
7589
7590 /* Remember final parameters */
7591 MARK_FINAL_PARMS (meth, orig_arg);
7592
7593 /* Fix the method argument list so we have the argument name
7594 information */
7595 fix_method_argument_names (orig_arg, meth);
7596
7597 /* Register the parameter number and re-install the current line
7598 number */
7599 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7600 input_line = saved_lineno;
7601
7602 /* Register exception specified by the `throws' keyword for
7603 resolution and set the method decl appropriate field to the list.
7604 Note: the grammar ensures that what we get here are class
7605 types. */
7606 if (throws)
7607 {
7608 throws = nreverse (throws);
7609 for (current = throws; current; current = TREE_CHAIN (current))
7610 {
7611 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7612 NULL_TREE, NULL_TREE);
7613 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7614 &TREE_VALUE (current);
7615 }
7616 DECL_FUNCTION_THROWS (meth) = throws;
7617 }
7618
7619 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7620 DECL_FUNCTION_WFL (meth) = id;
7621
7622 /* Set the flag if we correctly processed a constructor */
7623 if (constructor_ok)
7624 {
7625 DECL_CONSTRUCTOR_P (meth) = 1;
7626 /* Compute and store the number of artificial parameters declared
7627 for this constructor */
7628 for (count = 0, current = TYPE_FIELDS (this_class); current;
7629 current = TREE_CHAIN (current))
7630 if (FIELD_LOCAL_ALIAS (current))
7631 count++;
7632 DECL_FUNCTION_NAP (meth) = count;
7633 }
7634
7635 /* Eventually set the @deprecated tag flag */
7636 CHECK_DEPRECATED (meth);
7637
7638 /* If doing xref, store column and line number information instead
7639 of the line number only. */
7640 if (flag_emit_xref)
7641 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7642
7643 return meth;
7644 }
7645
7646 static void
fix_method_argument_names(tree orig_arg,tree meth)7647 fix_method_argument_names (tree orig_arg, tree meth)
7648 {
7649 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7650 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7651 {
7652 TREE_PURPOSE (arg) = this_identifier_node;
7653 arg = TREE_CHAIN (arg);
7654 }
7655 while (orig_arg != end_params_node)
7656 {
7657 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7658 orig_arg = TREE_CHAIN (orig_arg);
7659 arg = TREE_CHAIN (arg);
7660 }
7661 }
7662
7663 /* Complete the method declaration with METHOD_BODY. */
7664
7665 static void
finish_method_declaration(tree method_body)7666 finish_method_declaration (tree method_body)
7667 {
7668 int flags;
7669
7670 if (!current_function_decl)
7671 return;
7672
7673 flags = get_access_flags_from_decl (current_function_decl);
7674
7675 /* 8.4.5 Method Body */
7676 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7677 {
7678 tree name = DECL_NAME (current_function_decl);
7679 parse_error_context (DECL_FUNCTION_WFL (current_function_decl),
7680 "%s method `%s' can't have a body defined",
7681 (METHOD_NATIVE (current_function_decl) ?
7682 "Native" : "Abstract"),
7683 IDENTIFIER_POINTER (name));
7684 method_body = NULL_TREE;
7685 }
7686 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7687 {
7688 tree name = DECL_NAME (current_function_decl);
7689 parse_error_context
7690 (DECL_FUNCTION_WFL (current_function_decl),
7691 "Non native and non abstract method `%s' must have a body defined",
7692 IDENTIFIER_POINTER (name));
7693 method_body = NULL_TREE;
7694 }
7695
7696 if (flag_emit_class_files && method_body
7697 && TREE_CODE (method_body) == NOP_EXPR
7698 && TREE_TYPE (current_function_decl)
7699 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7700 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7701
7702 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7703 maybe_absorb_scoping_blocks ();
7704 /* Exit function's body */
7705 exit_block ();
7706 /* Merge last line of the function with first line, directly in the
7707 function decl. It will be used to emit correct debug info. */
7708 if (!flag_emit_xref)
7709 DECL_FUNCTION_LAST_LINE (current_function_decl) = ctxp->last_ccb_indent1;
7710
7711 /* Since function's argument's list are shared, reset the
7712 ARG_FINAL_P parameter that might have been set on some of this
7713 function parameters. */
7714 UNMARK_FINAL_PARMS (current_function_decl);
7715
7716 /* So we don't have an irrelevant function declaration context for
7717 the next static block we'll see. */
7718 current_function_decl = NULL_TREE;
7719 }
7720
7721 /* Build a an error message for constructor circularity errors. */
7722
7723 static char *
constructor_circularity_msg(tree from,tree to)7724 constructor_circularity_msg (tree from, tree to)
7725 {
7726 static char string [4096];
7727 char *t = xstrdup (lang_printable_name (from, 0));
7728 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7729 free (t);
7730 return string;
7731 }
7732
7733 /* Verify a circular call to METH. Return 1 if an error is found, 0
7734 otherwise. */
7735
7736 static GTY(()) tree vcc_list;
7737 static int
verify_constructor_circularity(tree meth,tree current)7738 verify_constructor_circularity (tree meth, tree current)
7739 {
7740 tree c;
7741
7742 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7743 {
7744 if (TREE_VALUE (c) == meth)
7745 {
7746 char *t;
7747 if (vcc_list)
7748 {
7749 tree liste;
7750 vcc_list = nreverse (vcc_list);
7751 for (liste = vcc_list; liste; liste = TREE_CHAIN (liste))
7752 {
7753 parse_error_context
7754 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7755 constructor_circularity_msg
7756 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7757 java_error_count--;
7758 }
7759 }
7760 t = xstrdup (lang_printable_name (meth, 0));
7761 parse_error_context (TREE_PURPOSE (c),
7762 "%s: recursive invocation of constructor `%s'",
7763 constructor_circularity_msg (current, meth), t);
7764 free (t);
7765 vcc_list = NULL_TREE;
7766 return 1;
7767 }
7768 }
7769 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7770 {
7771 vcc_list = tree_cons (c, current, vcc_list);
7772 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7773 return 1;
7774 vcc_list = TREE_CHAIN (vcc_list);
7775 }
7776 return 0;
7777 }
7778
7779 /* Check modifiers that can be declared but exclusively */
7780
7781 static void
check_modifiers_consistency(int flags)7782 check_modifiers_consistency (int flags)
7783 {
7784 int acc_count = 0;
7785 tree cl = NULL_TREE;
7786
7787 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7788 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7789 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7790 if (acc_count > 1)
7791 parse_error_context
7792 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7793
7794 acc_count = 0;
7795 cl = NULL_TREE;
7796 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK, acc_count, cl);
7797 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK, acc_count, cl);
7798 if (acc_count > 1)
7799 parse_error_context (cl,
7800 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7801 }
7802
7803 /* Check the methode header METH for abstract specifics features */
7804
7805 static void
check_abstract_method_header(tree meth)7806 check_abstract_method_header (tree meth)
7807 {
7808 int flags = get_access_flags_from_decl (meth);
7809
7810 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7811 ACC_ABSTRACT, "abstract method",
7812 IDENTIFIER_POINTER (DECL_NAME (meth)));
7813 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7814 ACC_PUBLIC, "abstract method",
7815 IDENTIFIER_POINTER (DECL_NAME (meth)));
7816
7817 check_modifiers ("Illegal modifier `%s' for interface method",
7818 flags, INTERFACE_METHOD_MODIFIERS);
7819 }
7820
7821 /* Create a FUNCTION_TYPE node and start augmenting it with the
7822 declared function arguments. Arguments type that can't be resolved
7823 are left as they are, but the returned node is marked as containing
7824 incomplete types. */
7825
7826 static tree
method_declarator(tree id,tree list)7827 method_declarator (tree id, tree list)
7828 {
7829 tree arg_types = NULL_TREE, current, node;
7830 tree meth = make_node (FUNCTION_TYPE);
7831 jdep *jdep;
7832
7833 patch_stage = JDEP_NO_PATCH;
7834
7835 if (GET_CPC () == error_mark_node)
7836 return error_mark_node;
7837
7838 /* If we're dealing with an inner class constructor, we hide the
7839 this$<n> decl in the name field of its parameter declaration. We
7840 also might have to hide the outer context local alias
7841 initializers. Not done when the class is a toplevel class. */
7842 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7843 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7844 {
7845 tree aliases_list, type, thisn;
7846 /* First the aliases, linked to the regular parameters */
7847 aliases_list =
7848 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7849 TREE_TYPE (GET_CPC ()),
7850 NULL_TREE, NULL);
7851 list = chainon (nreverse (aliases_list), list);
7852
7853 /* Then this$<n> */
7854 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7855 thisn = build_current_thisn (TREE_TYPE (GET_CPC ()));
7856 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7857 list);
7858 }
7859
7860 for (current = list; current; current = TREE_CHAIN (current))
7861 {
7862 int must_chain = 0;
7863 tree wfl_name = TREE_PURPOSE (current);
7864 tree type = TREE_VALUE (current);
7865 tree name = EXPR_WFL_NODE (wfl_name);
7866 tree already, arg_node;
7867 tree type_wfl = NULL_TREE;
7868 tree real_type;
7869
7870 /* Obtain a suitable type for resolution, if necessary */
7871 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7872
7873 /* Process NAME, as it may specify extra dimension(s) for it */
7874 type = build_array_from_name (type, type_wfl, name, &name);
7875 EXPR_WFL_NODE (wfl_name) = name;
7876
7877 real_type = GET_REAL_TYPE (type);
7878 if (TREE_CODE (real_type) == RECORD_TYPE)
7879 {
7880 real_type = promote_type (real_type);
7881 if (TREE_CODE (type) == TREE_LIST)
7882 TREE_PURPOSE (type) = real_type;
7883 }
7884
7885 /* Check redefinition */
7886 for (already = arg_types; already; already = TREE_CHAIN (already))
7887 if (TREE_PURPOSE (already) == name)
7888 {
7889 parse_error_context
7890 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7891 IDENTIFIER_POINTER (name),
7892 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7893 break;
7894 }
7895
7896 /* If we've an incomplete argument type, we know there is a location
7897 to patch when the type get resolved, later. */
7898 jdep = NULL;
7899 if (must_chain)
7900 {
7901 patch_stage = JDEP_METHOD;
7902 type = register_incomplete_type (patch_stage,
7903 type_wfl, wfl_name, type);
7904 jdep = CLASSD_LAST (ctxp->classd_list);
7905 JDEP_MISC (jdep) = id;
7906 }
7907
7908 /* The argument node: a name and a (possibly) incomplete type. */
7909 arg_node = build_tree_list (name, real_type);
7910 /* Remember arguments declared final. */
7911 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7912
7913 if (jdep)
7914 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7915 TREE_CHAIN (arg_node) = arg_types;
7916 arg_types = arg_node;
7917 }
7918 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7919 node = build_tree_list (id, meth);
7920 return node;
7921 }
7922
7923 static int
unresolved_type_p(tree wfl,tree * returned)7924 unresolved_type_p (tree wfl, tree *returned)
7925
7926 {
7927 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7928 {
7929 if (returned)
7930 {
7931 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7932 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7933 *returned = TREE_TYPE (decl);
7934 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7935 *returned = TREE_TYPE (GET_CPC ());
7936 else
7937 *returned = NULL_TREE;
7938 }
7939 return 1;
7940 }
7941 if (returned)
7942 *returned = wfl;
7943 return 0;
7944 }
7945
7946 /* From NAME, build a qualified identifier node using the
7947 qualification from the current package definition. */
7948
7949 static tree
parser_qualified_classname(tree name)7950 parser_qualified_classname (tree name)
7951 {
7952 tree nested_class_name;
7953
7954 if ((nested_class_name = maybe_make_nested_class_name (name)))
7955 return nested_class_name;
7956
7957 if (ctxp->package)
7958 return merge_qualified_name (ctxp->package, name);
7959 else
7960 return name;
7961 }
7962
7963 /* Called once the type a interface extends is resolved. Returns 0 if
7964 everything is OK. */
7965
7966 static int
parser_check_super_interface(tree super_decl,tree this_decl,tree this_wfl)7967 parser_check_super_interface (tree super_decl, tree this_decl, tree this_wfl)
7968 {
7969 tree super_type = TREE_TYPE (super_decl);
7970
7971 /* Has to be an interface */
7972 if (!CLASS_INTERFACE (super_decl))
7973 {
7974 parse_error_context
7975 (this_wfl, "%s `%s' can't implement/extend %s `%s'",
7976 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7977 "Interface" : "Class"),
7978 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7979 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7980 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7981 return 1;
7982 }
7983
7984 /* Check top-level interface access. Inner classes are subject to member
7985 access rules (6.6.1). */
7986 if (! INNER_CLASS_P (super_type)
7987 && check_pkg_class_access (DECL_NAME (super_decl),
7988 lookup_cl (this_decl), true))
7989 return 1;
7990
7991 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7992 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7993 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7994 return 0;
7995 }
7996
7997 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7998 0 if everything is OK. */
7999
8000 static int
parser_check_super(tree super_decl,tree this_decl,tree wfl)8001 parser_check_super (tree super_decl, tree this_decl, tree wfl)
8002 {
8003 tree super_type = TREE_TYPE (super_decl);
8004
8005 /* SUPER should be a CLASS (neither an array nor an interface) */
8006 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
8007 {
8008 parse_error_context
8009 (wfl, "Class `%s' can't subclass %s `%s'",
8010 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
8011 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
8012 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
8013 return 1;
8014 }
8015
8016 if (CLASS_FINAL (TYPE_NAME (super_type)))
8017 {
8018 parse_error_context (wfl, "Can't subclass final classes: %s",
8019 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
8020 return 1;
8021 }
8022
8023 /* Check top-level class scope. Inner classes are subject to member access
8024 rules (6.6.1). */
8025 if (! INNER_CLASS_P (super_type)
8026 && (check_pkg_class_access (DECL_NAME (super_decl), wfl, true)))
8027 return 1;
8028
8029 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
8030 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
8031 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
8032 return 0;
8033 }
8034
8035 /* Create a new dependency list and link it (in a LIFO manner) to the
8036 CTXP list of type dependency list. */
8037
8038 static void
create_jdep_list(struct parser_ctxt * ctxp)8039 create_jdep_list (struct parser_ctxt *ctxp)
8040 {
8041 jdeplist *new = xmalloc (sizeof (jdeplist));
8042 new->first = new->last = NULL;
8043 new->next = ctxp->classd_list;
8044 ctxp->classd_list = new;
8045 }
8046
8047 static jdeplist *
reverse_jdep_list(struct parser_ctxt * ctxp)8048 reverse_jdep_list (struct parser_ctxt *ctxp)
8049 {
8050 jdeplist *prev = NULL, *current, *next;
8051 for (current = ctxp->classd_list; current; current = next)
8052 {
8053 next = current->next;
8054 current->next = prev;
8055 prev = current;
8056 }
8057 return prev;
8058 }
8059
8060 /* Create a fake pointer based on the ID stored in
8061 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
8062 registered again. */
8063
8064 static tree
obtain_incomplete_type(tree type_name)8065 obtain_incomplete_type (tree type_name)
8066 {
8067 tree ptr = NULL_TREE, name;
8068
8069 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
8070 name = EXPR_WFL_NODE (type_name);
8071 else if (INCOMPLETE_TYPE_P (type_name))
8072 name = TYPE_NAME (type_name);
8073 else
8074 abort ();
8075
8076 /* Workaround from build_pointer_type for incomplete types. */
8077 BUILD_PTR_FROM_NAME (ptr, name);
8078 TYPE_MODE (ptr) = ptr_mode;
8079 layout_type (ptr);
8080
8081 return ptr;
8082 }
8083
8084 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
8085 non NULL instead of computing a new fake type based on WFL. The new
8086 dependency is inserted in the current type dependency list, in FIFO
8087 manner. */
8088
8089 static tree
register_incomplete_type(int kind,tree wfl,tree decl,tree ptr)8090 register_incomplete_type (int kind, tree wfl, tree decl, tree ptr)
8091 {
8092 jdep *new = xmalloc (sizeof (jdep));
8093
8094 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
8095 ptr = obtain_incomplete_type (wfl);
8096
8097 JDEP_KIND (new) = kind;
8098 JDEP_DECL (new) = decl;
8099 JDEP_TO_RESOLVE (new) = ptr;
8100 JDEP_WFL (new) = wfl;
8101 JDEP_CHAIN (new) = NULL;
8102 JDEP_MISC (new) = NULL_TREE;
8103 /* For some dependencies, set the enclosing class of the current
8104 class to be the enclosing context */
8105 if ((kind == JDEP_INTERFACE || kind == JDEP_ANONYMOUS)
8106 && GET_ENCLOSING_CPC ())
8107 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
8108 else if (kind == JDEP_SUPER)
8109 JDEP_ENCLOSING (new) = (GET_ENCLOSING_CPC () ?
8110 TREE_VALUE (GET_ENCLOSING_CPC ()) : NULL_TREE);
8111 else
8112 JDEP_ENCLOSING (new) = GET_CPC ();
8113 JDEP_GET_PATCH (new) = (tree *)NULL;
8114
8115 JDEP_INSERT (ctxp->classd_list, new);
8116
8117 return ptr;
8118 }
8119
8120 /* This checks for circular references with innerclasses. We start
8121 from SOURCE and should never reach TARGET. Extended/implemented
8122 types in SOURCE have their enclosing context checked not to reach
8123 TARGET. When the last enclosing context of SOURCE is reached, its
8124 extended/implemented types are also checked not to reach TARGET.
8125 In case of error, WFL of the offending type is returned; NULL_TREE
8126 otherwise. */
8127
8128 static tree
check_inner_circular_reference(tree source,tree target)8129 check_inner_circular_reference (tree source, tree target)
8130 {
8131 tree basetype_vec = TYPE_BINFO_BASETYPES (source);
8132 tree ctx, cl;
8133 int i;
8134
8135 if (!basetype_vec)
8136 return NULL_TREE;
8137
8138 for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
8139 {
8140 tree su;
8141
8142 /* We can end up with a NULL_TREE or an incomplete type here if
8143 we encountered previous type resolution errors. It's safe to
8144 simply ignore these cases. */
8145 if (TREE_VEC_ELT (basetype_vec, i) == NULL_TREE)
8146 continue;
8147 su = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
8148 if (INCOMPLETE_TYPE_P (su))
8149 continue;
8150
8151 if (inherits_from_p (su, target))
8152 return lookup_cl (TYPE_NAME (su));
8153
8154 for (ctx = DECL_CONTEXT (TYPE_NAME (su)); ctx; ctx = DECL_CONTEXT (ctx))
8155 {
8156 /* An enclosing context shouldn't be TARGET */
8157 if (ctx == TYPE_NAME (target))
8158 return lookup_cl (TYPE_NAME (su));
8159
8160 /* When we reach the enclosing last context, start a check
8161 on it, with the same target */
8162 if (! DECL_CONTEXT (ctx) &&
8163 (cl = check_inner_circular_reference (TREE_TYPE (ctx), target)))
8164 return cl;
8165 }
8166 }
8167 return NULL_TREE;
8168 }
8169
8170 /* Explore TYPE's `extends' clause member(s) and return the WFL of the
8171 offending type if a circularity is detected. NULL_TREE is returned
8172 otherwise. TYPE can be an interface or a class. */
8173
8174 static tree
check_circular_reference(tree type)8175 check_circular_reference (tree type)
8176 {
8177 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
8178 int i;
8179
8180 if (!basetype_vec)
8181 return NULL_TREE;
8182
8183 if (! CLASS_INTERFACE (TYPE_NAME (type)))
8184 {
8185 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
8186 return lookup_cl (TYPE_NAME (type));
8187 return NULL_TREE;
8188 }
8189
8190 for (i = 0; i < TREE_VEC_LENGTH (basetype_vec); i++)
8191 {
8192 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8193 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
8194 && interface_of_p (type, BINFO_TYPE (vec_elt)))
8195 return lookup_cl (TYPE_NAME (BINFO_TYPE (vec_elt)));
8196 }
8197 return NULL_TREE;
8198 }
8199
8200 void
java_check_circular_reference(void)8201 java_check_circular_reference (void)
8202 {
8203 tree current;
8204 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
8205 {
8206 tree type = TREE_TYPE (current);
8207 tree cl;
8208
8209 cl = check_circular_reference (type);
8210 if (! cl)
8211 cl = check_inner_circular_reference (type, type);
8212 if (cl)
8213 parse_error_context (cl, "Cyclic class inheritance%s",
8214 (cyclic_inheritance_report ?
8215 cyclic_inheritance_report : ""));
8216 }
8217 }
8218
8219 /* Augment the parameter list PARM with parameters crafted to
8220 initialize outer context locals aliases. Through ARTIFICIAL, a
8221 count is kept of the number of crafted parameters. MODE governs
8222 what eventually gets created: something suitable for a function
8223 creation or a function invocation, either the constructor or
8224 finit$. */
8225
8226 static tree
build_alias_initializer_parameter_list(int mode,tree class_type,tree parm,int * artificial)8227 build_alias_initializer_parameter_list (int mode, tree class_type, tree parm,
8228 int *artificial)
8229 {
8230 tree field;
8231 tree additional_parms = NULL_TREE;
8232
8233 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
8234 if (FIELD_LOCAL_ALIAS (field))
8235 {
8236 const char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
8237 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
8238 tree mangled_id;
8239
8240 switch (mode)
8241 {
8242 case AIPL_FUNCTION_DECLARATION:
8243 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (mangled_id,
8244 &buffer [4]);
8245 purpose = build_wfl_node (mangled_id);
8246 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
8247 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
8248 else
8249 value = TREE_TYPE (field);
8250 break;
8251
8252 case AIPL_FUNCTION_CREATION:
8253 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (purpose,
8254 &buffer [4]);
8255 value = TREE_TYPE (field);
8256 break;
8257
8258 case AIPL_FUNCTION_FINIT_INVOCATION:
8259 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (mangled_id,
8260 &buffer [4]);
8261 /* Now, this is wrong. purpose should always be the NAME
8262 of something and value its matching value (decl, type,
8263 etc...) FIXME -- but there is a lot to fix. */
8264
8265 /* When invoked for this kind of operation, we already
8266 know whether a field is used or not. */
8267 purpose = TREE_TYPE (field);
8268 value = build_wfl_node (mangled_id);
8269 break;
8270
8271 case AIPL_FUNCTION_CTOR_INVOCATION:
8272 /* There are two case: the constructor invocation happens
8273 outside the local inner, in which case, locales from the outer
8274 context are directly used.
8275
8276 Otherwise, we fold to using the alias directly. */
8277 if (class_type == current_class)
8278 value = field;
8279 else
8280 {
8281 name = get_identifier (&buffer[4]);
8282 value = IDENTIFIER_LOCAL_VALUE (name);
8283 }
8284 break;
8285 }
8286 additional_parms = tree_cons (purpose, value, additional_parms);
8287 if (artificial)
8288 *artificial +=1;
8289 }
8290 if (additional_parms)
8291 {
8292 if (ANONYMOUS_CLASS_P (class_type)
8293 && mode == AIPL_FUNCTION_CTOR_INVOCATION)
8294 additional_parms = nreverse (additional_parms);
8295 parm = chainon (additional_parms, parm);
8296 }
8297
8298 return parm;
8299 }
8300
8301 /* Craft a constructor for CLASS_DECL -- what we should do when none
8302 where found. ARGS is non NULL when a special signature must be
8303 enforced. This is the case for anonymous classes. */
8304
8305 static tree
craft_constructor(tree class_decl,tree args)8306 craft_constructor (tree class_decl, tree args)
8307 {
8308 tree class_type = TREE_TYPE (class_decl);
8309 tree parm = NULL_TREE;
8310 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
8311 ACC_PUBLIC : 0);
8312 int i = 0, artificial = 0;
8313 tree decl, ctor_name;
8314 char buffer [80];
8315
8316 /* The constructor name is <init> unless we're dealing with an
8317 anonymous class, in which case the name will be fixed after having
8318 be expanded. */
8319 if (ANONYMOUS_CLASS_P (class_type))
8320 ctor_name = DECL_NAME (class_decl);
8321 else
8322 ctor_name = init_identifier_node;
8323
8324 /* If we're dealing with an inner class constructor, we hide the
8325 this$<n> decl in the name field of its parameter declaration. */
8326 if (PURE_INNER_CLASS_TYPE_P (class_type))
8327 {
8328 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
8329 parm = tree_cons (build_current_thisn (class_type),
8330 build_pointer_type (type), parm);
8331
8332 /* Some more arguments to be hidden here. The values of the local
8333 variables of the outer context that the inner class needs to see. */
8334 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
8335 class_type, parm,
8336 &artificial);
8337 }
8338
8339 /* Then if there are any args to be enforced, enforce them now */
8340 for (; args && args != end_params_node; args = TREE_CHAIN (args))
8341 {
8342 sprintf (buffer, "parm%d", i++);
8343 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
8344 }
8345
8346 CRAFTED_PARAM_LIST_FIXUP (parm);
8347 decl = create_artificial_method (class_type, flags, void_type_node,
8348 ctor_name, parm);
8349 fix_method_argument_names (parm, decl);
8350 /* Now, mark the artificial parameters. */
8351 DECL_FUNCTION_NAP (decl) = artificial;
8352 DECL_FUNCTION_SYNTHETIC_CTOR (decl) = DECL_CONSTRUCTOR_P (decl) = 1;
8353 DECL_INLINE (decl) = 1;
8354 return decl;
8355 }
8356
8357
8358 /* Fix the constructors. This will be called right after circular
8359 references have been checked. It is necessary to fix constructors
8360 early even if no code generation will take place for that class:
8361 some generated constructor might be required by the class whose
8362 compilation triggered this one to be simply loaded. */
8363
8364 void
java_fix_constructors(void)8365 java_fix_constructors (void)
8366 {
8367 tree current;
8368
8369 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
8370 {
8371 tree class_type = TREE_TYPE (current);
8372 int saw_ctor = 0;
8373 tree decl;
8374
8375 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
8376 continue;
8377
8378 output_class = current_class = class_type;
8379 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
8380 {
8381 if (DECL_CONSTRUCTOR_P (decl))
8382 {
8383 fix_constructors (decl);
8384 saw_ctor = 1;
8385 }
8386 }
8387
8388 /* Anonymous class constructor can't be generated that early. */
8389 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
8390 craft_constructor (current, NULL_TREE);
8391 }
8392 }
8393
8394 /* safe_layout_class just makes sure that we can load a class without
8395 disrupting the current_class, input_file, lineno, etc, information
8396 about the class processed currently. */
8397
8398 void
safe_layout_class(tree class)8399 safe_layout_class (tree class)
8400 {
8401 tree save_current_class = current_class;
8402 location_t save_location = input_location;
8403
8404 layout_class (class);
8405
8406 current_class = save_current_class;
8407 input_location = save_location;
8408 }
8409
8410 static tree
jdep_resolve_class(jdep * dep)8411 jdep_resolve_class (jdep *dep)
8412 {
8413 tree decl;
8414
8415 if (JDEP_RESOLVED_P (dep))
8416 decl = JDEP_RESOLVED_DECL (dep);
8417 else
8418 {
8419 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
8420 JDEP_DECL (dep), JDEP_WFL (dep));
8421 JDEP_RESOLVED (dep, decl);
8422 /* If there is no WFL, that's ok. We generate this warning
8423 elsewhere. */
8424 if (decl && JDEP_WFL (dep) != NULL_TREE)
8425 check_deprecation (JDEP_WFL (dep), decl);
8426 }
8427
8428 if (!decl)
8429 complete_class_report_errors (dep);
8430 else if (PURE_INNER_CLASS_DECL_P (decl))
8431 {
8432 tree inner = TREE_TYPE (decl);
8433 if (! CLASS_LOADED_P (inner))
8434 {
8435 safe_layout_class (inner);
8436 if (TYPE_SIZE (inner) == error_mark_node)
8437 TYPE_SIZE (inner) = NULL_TREE;
8438 }
8439 check_inner_class_access (decl, JDEP_ENCLOSING (dep), JDEP_WFL (dep));
8440 }
8441 return decl;
8442 }
8443
8444 /* Complete unsatisfied class declaration and their dependencies */
8445
8446 void
java_complete_class(void)8447 java_complete_class (void)
8448 {
8449 tree cclass;
8450 jdeplist *cclassd;
8451 int error_found;
8452 tree type;
8453
8454 /* Process imports */
8455 process_imports ();
8456
8457 /* Reverse things so we have the right order */
8458 ctxp->class_list = nreverse (ctxp->class_list);
8459 ctxp->classd_list = reverse_jdep_list (ctxp);
8460
8461 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
8462 cclass && cclassd;
8463 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
8464 {
8465 jdep *dep;
8466
8467 /* We keep the compilation unit imports in the class so that
8468 they can be used later to resolve type dependencies that
8469 aren't necessary to solve now. */
8470 TYPE_IMPORT_LIST (TREE_TYPE (cclass)) = ctxp->import_list;
8471 TYPE_IMPORT_DEMAND_LIST (TREE_TYPE (cclass)) = ctxp->import_demand_list;
8472
8473 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
8474 {
8475 tree decl;
8476 if (!(decl = jdep_resolve_class (dep)))
8477 continue;
8478
8479 /* Now it's time to patch */
8480 switch (JDEP_KIND (dep))
8481 {
8482 case JDEP_SUPER:
8483 /* Simply patch super */
8484 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
8485 continue;
8486 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
8487 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
8488 break;
8489
8490 case JDEP_FIELD:
8491 {
8492 /* We do part of the job done in add_field */
8493 tree field_decl = JDEP_DECL (dep);
8494 tree field_type = TREE_TYPE (decl);
8495 if (TREE_CODE (field_type) == RECORD_TYPE)
8496 field_type = promote_type (field_type);
8497 TREE_TYPE (field_decl) = field_type;
8498 DECL_ALIGN (field_decl) = 0;
8499 DECL_USER_ALIGN (field_decl) = 0;
8500 layout_decl (field_decl, 0);
8501 SOURCE_FRONTEND_DEBUG
8502 (("Completed field/var decl `%s' with `%s'",
8503 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
8504 IDENTIFIER_POINTER (DECL_NAME (decl))));
8505 break;
8506 }
8507 case JDEP_METHOD: /* We start patching a method */
8508 case JDEP_METHOD_RETURN:
8509 error_found = 0;
8510 while (1)
8511 {
8512 if (decl)
8513 {
8514 type = TREE_TYPE(decl);
8515 if (TREE_CODE (type) == RECORD_TYPE)
8516 type = promote_type (type);
8517 JDEP_APPLY_PATCH (dep, type);
8518 SOURCE_FRONTEND_DEBUG
8519 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
8520 "Completing fct `%s' with ret type `%s'":
8521 "Completing arg `%s' with type `%s'"),
8522 IDENTIFIER_POINTER (EXPR_WFL_NODE
8523 (JDEP_DECL_WFL (dep))),
8524 IDENTIFIER_POINTER (DECL_NAME (decl))));
8525 }
8526 else
8527 error_found = 1;
8528 dep = JDEP_CHAIN (dep);
8529 if (JDEP_KIND (dep) == JDEP_METHOD_END)
8530 break;
8531 else
8532 decl = jdep_resolve_class (dep);
8533 }
8534 if (!error_found)
8535 {
8536 tree mdecl = JDEP_DECL (dep), signature;
8537 /* Recompute and reset the signature, check first that
8538 all types are now defined. If they're not,
8539 don't build the signature. */
8540 if (check_method_types_complete (mdecl))
8541 {
8542 signature = build_java_signature (TREE_TYPE (mdecl));
8543 set_java_signature (TREE_TYPE (mdecl), signature);
8544 }
8545 }
8546 else
8547 continue;
8548 break;
8549
8550 case JDEP_INTERFACE:
8551 if (parser_check_super_interface (decl, JDEP_DECL (dep),
8552 JDEP_WFL (dep)))
8553 continue;
8554 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
8555 break;
8556
8557 case JDEP_PARM:
8558 case JDEP_VARIABLE:
8559 type = TREE_TYPE(decl);
8560 if (TREE_CODE (type) == RECORD_TYPE)
8561 type = promote_type (type);
8562 JDEP_APPLY_PATCH (dep, type);
8563 break;
8564
8565 case JDEP_TYPE:
8566 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8567 SOURCE_FRONTEND_DEBUG
8568 (("Completing a random type dependency on a '%s' node",
8569 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
8570 break;
8571
8572 case JDEP_EXCEPTION:
8573 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
8574 SOURCE_FRONTEND_DEBUG
8575 (("Completing `%s' `throws' argument node",
8576 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
8577 break;
8578
8579 case JDEP_ANONYMOUS:
8580 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
8581 break;
8582
8583 default:
8584 abort ();
8585 }
8586 }
8587 }
8588 return;
8589 }
8590
8591 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8592 array. */
8593
8594 static tree
resolve_class(tree enclosing,tree class_type,tree decl,tree cl)8595 resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
8596 {
8597 tree tname = TYPE_NAME (class_type);
8598 tree resolved_type = TREE_TYPE (class_type);
8599 int array_dims = 0;
8600 tree resolved_type_decl;
8601
8602 if (resolved_type != NULL_TREE)
8603 {
8604 tree resolved_type_decl = TYPE_NAME (resolved_type);
8605 if (resolved_type_decl == NULL_TREE
8606 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8607 {
8608 resolved_type_decl = build_decl (TYPE_DECL,
8609 TYPE_NAME (class_type),
8610 resolved_type);
8611 }
8612 return resolved_type_decl;
8613 }
8614
8615 /* 1- Check to see if we have an array. If true, find what we really
8616 want to resolve */
8617 if ((array_dims = build_type_name_from_array_name (tname,
8618 &TYPE_NAME (class_type))))
8619 WFL_STRIP_BRACKET (cl, cl);
8620
8621 /* 2- Resolve the bare type */
8622 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
8623 decl, cl)))
8624 return NULL_TREE;
8625 resolved_type = TREE_TYPE (resolved_type_decl);
8626
8627 /* 3- If we have an array, reconstruct the array down to its nesting */
8628 if (array_dims)
8629 {
8630 for (; array_dims; array_dims--)
8631 resolved_type = build_java_array_type (resolved_type, -1);
8632 resolved_type_decl = TYPE_NAME (resolved_type);
8633 }
8634 TREE_TYPE (class_type) = resolved_type;
8635 return resolved_type_decl;
8636 }
8637
8638 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8639 are used to report error messages; CL must either be NULL_TREE or a
8640 WFL wrapping a class. Do not try to replace TYPE_NAME (class_type)
8641 by a variable, since it is changed by find_in_imports{_on_demand}
8642 and (but it doesn't really matter) qualify_and_find. */
8643
8644 tree
do_resolve_class(tree enclosing,tree class_type,tree decl,tree cl)8645 do_resolve_class (tree enclosing, tree class_type, tree decl, tree cl)
8646 {
8647 tree new_class_decl = NULL_TREE, super = NULL_TREE;
8648 tree saved_enclosing_type = enclosing ? TREE_TYPE (enclosing) : NULL_TREE;
8649 tree decl_result;
8650 htab_t circularity_hash;
8651
8652 if (QUALIFIED_P (TYPE_NAME (class_type)))
8653 {
8654 /* If the type name is of the form `Q . Id', then Q is either a
8655 package name or a class name. First we try to find Q as a
8656 class and then treat Id as a member type. If we can't find Q
8657 as a class then we fall through. */
8658 tree q, left, left_type, right;
8659 if (breakdown_qualified (&left, &right, TYPE_NAME (class_type)) == 0)
8660 {
8661 BUILD_PTR_FROM_NAME (left_type, left);
8662 q = do_resolve_class (enclosing, left_type, decl, cl);
8663 if (q)
8664 {
8665 enclosing = q;
8666 saved_enclosing_type = TREE_TYPE (q);
8667 BUILD_PTR_FROM_NAME (class_type, right);
8668 }
8669 }
8670 }
8671
8672 if (enclosing)
8673 {
8674 /* This hash table is used to register the classes we're going
8675 through when searching the current class as an inner class, in
8676 order to detect circular references. Remember to free it before
8677 returning the section 0- of this function. */
8678 circularity_hash = htab_create (20, htab_hash_pointer, htab_eq_pointer,
8679 NULL);
8680
8681 /* 0- Search in the current class as an inner class.
8682 Maybe some code here should be added to load the class or
8683 something, at least if the class isn't an inner class and ended
8684 being loaded from class file. FIXME. */
8685 while (enclosing)
8686 {
8687 new_class_decl = resolve_inner_class (circularity_hash, cl, &enclosing,
8688 &super, class_type);
8689 if (new_class_decl)
8690 break;
8691
8692 /* If we haven't found anything because SUPER reached Object and
8693 ENCLOSING happens to be an innerclass, try the enclosing context. */
8694 if ((!super || super == object_type_node) &&
8695 enclosing && INNER_CLASS_DECL_P (enclosing))
8696 enclosing = DECL_CONTEXT (enclosing);
8697 else
8698 enclosing = NULL_TREE;
8699 }
8700
8701 htab_delete (circularity_hash);
8702
8703 if (new_class_decl)
8704 return new_class_decl;
8705 }
8706
8707 /* 1- Check for the type in single imports. This will change
8708 TYPE_NAME() if something relevant is found */
8709 find_in_imports (saved_enclosing_type, class_type);
8710
8711 /* 2- And check for the type in the current compilation unit */
8712 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8713 {
8714 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8715 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8716 load_class (TYPE_NAME (class_type), 0);
8717 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8718 }
8719
8720 /* 3- Search according to the current package definition */
8721 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8722 {
8723 if ((new_class_decl = qualify_and_find (class_type, ctxp->package,
8724 TYPE_NAME (class_type))))
8725 return new_class_decl;
8726 }
8727
8728 /* 4- Check the import on demands. Don't allow bar.baz to be
8729 imported from foo.* */
8730 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8731 if (find_in_imports_on_demand (saved_enclosing_type, class_type))
8732 return NULL_TREE;
8733
8734 /* If found in find_in_imports_on_demand, the type has already been
8735 loaded. */
8736 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8737 return new_class_decl;
8738
8739 /* 5- Try with a name qualified with the package name we've seen so far */
8740 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8741 {
8742 tree package;
8743
8744 /* If there is a current package (ctxp->package), it's the first
8745 element of package_list and we can skip it. */
8746 for (package = (ctxp->package ?
8747 TREE_CHAIN (package_list) : package_list);
8748 package; package = TREE_CHAIN (package))
8749 if ((new_class_decl = qualify_and_find (class_type,
8750 TREE_PURPOSE (package),
8751 TYPE_NAME (class_type))))
8752 return new_class_decl;
8753 }
8754
8755 /* 5- Check another compilation unit that bears the name of type */
8756 load_class (TYPE_NAME (class_type), 0);
8757
8758 if (!cl)
8759 cl = lookup_cl (decl);
8760
8761 /* If we don't have a value for CL, then we're being called recursively.
8762 We can't check package access just yet, but it will be taken care of
8763 by the caller. */
8764 if (cl)
8765 {
8766 if (check_pkg_class_access (TYPE_NAME (class_type), cl, true))
8767 return NULL_TREE;
8768 }
8769
8770 /* 6- Last call for a resolution */
8771 decl_result = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8772
8773 /* The final lookup might have registered a.b.c into a.b$c If we
8774 failed at the first lookup, progressively change the name if
8775 applicable and use the matching DECL instead. */
8776 if (!decl_result && QUALIFIED_P (TYPE_NAME (class_type)))
8777 {
8778 char *separator;
8779 tree name = TYPE_NAME (class_type);
8780 char *namebuffer = alloca (IDENTIFIER_LENGTH (name) + 1);
8781
8782 strcpy (namebuffer, IDENTIFIER_POINTER (name));
8783
8784 do {
8785
8786 /* Reach the last '.', and if applicable, replace it by a `$' and
8787 see if this exists as a type. */
8788 if ((separator = strrchr (namebuffer, '.')))
8789 {
8790 *separator = '$';
8791 name = get_identifier (namebuffer);
8792 decl_result = IDENTIFIER_CLASS_VALUE (name);
8793 }
8794 } while (!decl_result && separator);
8795 }
8796 return decl_result;
8797 }
8798
8799 static tree
qualify_and_find(tree class_type,tree package,tree name)8800 qualify_and_find (tree class_type, tree package, tree name)
8801 {
8802 tree new_qualified = merge_qualified_name (package, name);
8803 tree new_class_decl;
8804
8805 if (!IDENTIFIER_CLASS_VALUE (new_qualified))
8806 load_class (new_qualified, 0);
8807 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (new_qualified)))
8808 {
8809 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8810 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8811 load_class (new_qualified, 0);
8812 TYPE_NAME (class_type) = new_qualified;
8813 return IDENTIFIER_CLASS_VALUE (new_qualified);
8814 }
8815 return NULL_TREE;
8816 }
8817
8818 /* Resolve NAME and lay it out (if not done and if not the current
8819 parsed class). Return a decl node. This function is meant to be
8820 called when type resolution is necessary during the walk pass. */
8821
8822 static tree
resolve_and_layout(tree something,tree cl)8823 resolve_and_layout (tree something, tree cl)
8824 {
8825 tree decl, decl_type;
8826
8827 /* Don't do that on the current class */
8828 if (something == current_class)
8829 return TYPE_NAME (current_class);
8830
8831 /* Don't do anything for void and other primitive types */
8832 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8833 return NULL_TREE;
8834
8835 /* Pointer types can be reall pointer types or fake pointers. When
8836 finding a real pointer, recheck for primitive types */
8837 if (TREE_CODE (something) == POINTER_TYPE)
8838 {
8839 if (TREE_TYPE (something))
8840 {
8841 something = TREE_TYPE (something);
8842 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8843 return NULL_TREE;
8844 }
8845 else
8846 something = TYPE_NAME (something);
8847 }
8848
8849 /* Don't do anything for arrays of primitive types */
8850 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8851 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8852 return NULL_TREE;
8853
8854 /* Something might be a WFL */
8855 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8856 something = EXPR_WFL_NODE (something);
8857
8858 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8859 TYPE_DECL or a real TYPE */
8860 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8861 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8862 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8863
8864 if (!(decl = resolve_no_layout (something, cl)))
8865 return NULL_TREE;
8866
8867 /* Resolve and layout if necessary */
8868 decl_type = TREE_TYPE (decl);
8869 layout_class_methods (decl_type);
8870 /* Check methods */
8871 if (CLASS_FROM_SOURCE_P (decl_type))
8872 java_check_methods (decl);
8873 /* Layout the type if necessary */
8874 if (decl_type != current_class && !CLASS_LOADED_P (decl_type))
8875 safe_layout_class (decl_type);
8876
8877 return decl;
8878 }
8879
8880 /* Resolve a class, returns its decl but doesn't perform any
8881 layout. The current parsing context is saved and restored */
8882
8883 static tree
resolve_no_layout(tree name,tree cl)8884 resolve_no_layout (tree name, tree cl)
8885 {
8886 tree ptr, decl;
8887 BUILD_PTR_FROM_NAME (ptr, name);
8888 java_parser_context_save_global ();
8889 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8890 java_parser_context_restore_global ();
8891
8892 return decl;
8893 }
8894
8895 /* Called when reporting errors. Skip the '[]'s in a complex array
8896 type description that failed to be resolved. purify_type_name can't
8897 use an identifier tree. */
8898
8899 static const char *
purify_type_name(const char * name)8900 purify_type_name (const char *name)
8901 {
8902 int len = strlen (name);
8903 int bracket_found;
8904
8905 STRING_STRIP_BRACKETS (name, len, bracket_found);
8906 if (bracket_found)
8907 {
8908 char *stripped_name = xmemdup (name, len, len+1);
8909 stripped_name [len] = '\0';
8910 return stripped_name;
8911 }
8912 return name;
8913 }
8914
8915 /* The type CURRENT refers to can't be found. We print error messages. */
8916
8917 static void
complete_class_report_errors(jdep * dep)8918 complete_class_report_errors (jdep *dep)
8919 {
8920 const char *name;
8921
8922 if (!JDEP_WFL (dep))
8923 return;
8924
8925 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8926 switch (JDEP_KIND (dep))
8927 {
8928 case JDEP_SUPER:
8929 parse_error_context
8930 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8931 purify_type_name (name),
8932 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8933 break;
8934 case JDEP_FIELD:
8935 parse_error_context
8936 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8937 purify_type_name (name),
8938 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8939 break;
8940 case JDEP_METHOD: /* Covers arguments */
8941 parse_error_context
8942 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8943 purify_type_name (name),
8944 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8945 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8946 break;
8947 case JDEP_METHOD_RETURN: /* Covers return type */
8948 parse_error_context
8949 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8950 purify_type_name (name),
8951 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8952 break;
8953 case JDEP_INTERFACE:
8954 parse_error_context
8955 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8956 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8957 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8958 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8959 break;
8960 case JDEP_VARIABLE:
8961 parse_error_context
8962 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8963 purify_type_name (IDENTIFIER_POINTER
8964 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8965 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8966 break;
8967 case JDEP_EXCEPTION: /* As specified by `throws' */
8968 parse_error_context
8969 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8970 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8971 break;
8972 default:
8973 /* Fix for -Wall. Just break doing nothing. The error will be
8974 caught later */
8975 break;
8976 }
8977 }
8978
8979 /* Return a static string containing the DECL prototype string. If
8980 DECL is a constructor, use the class name instead of the form
8981 <init> */
8982
8983 static const char *
get_printable_method_name(tree decl)8984 get_printable_method_name (tree decl)
8985 {
8986 const char *to_return;
8987 tree name = NULL_TREE;
8988
8989 if (DECL_CONSTRUCTOR_P (decl))
8990 {
8991 name = DECL_NAME (decl);
8992 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8993 }
8994
8995 to_return = lang_printable_name (decl, 0);
8996 if (DECL_CONSTRUCTOR_P (decl))
8997 DECL_NAME (decl) = name;
8998
8999 return to_return;
9000 }
9001
9002 /* Track method being redefined inside the same class. As a side
9003 effect, set DECL_NAME to an IDENTIFIER (prior entering this
9004 function it's a FWL, so we can track errors more accurately.) */
9005
9006 static int
check_method_redefinition(tree class,tree method)9007 check_method_redefinition (tree class, tree method)
9008 {
9009 tree redef, sig;
9010
9011 /* There's no need to verify <clinit> and finit$ and instinit$ */
9012 if (DECL_CLINIT_P (method)
9013 || DECL_FINIT_P (method) || DECL_INSTINIT_P (method))
9014 return 0;
9015
9016 sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
9017 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
9018 {
9019 if (redef == method)
9020 break;
9021 if (DECL_NAME (redef) == DECL_NAME (method)
9022 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef))
9023 && !DECL_ARTIFICIAL (method))
9024 {
9025 parse_error_context
9026 (DECL_FUNCTION_WFL (method), "Duplicate %s declaration `%s'",
9027 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
9028 get_printable_method_name (redef));
9029 return 1;
9030 }
9031 }
9032 return 0;
9033 }
9034
9035 /* Return 1 if check went ok, 0 otherwise. */
9036 static int
check_abstract_method_definitions(int do_interface,tree class_decl,tree type)9037 check_abstract_method_definitions (int do_interface, tree class_decl,
9038 tree type)
9039 {
9040 tree class = TREE_TYPE (class_decl);
9041 tree method, end_type;
9042 int ok = 1;
9043
9044 end_type = (do_interface ? object_type_node : type);
9045 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
9046 {
9047 tree other_super, other_method, method_sig, method_name;
9048 int found = 0;
9049 int end_type_reached = 0;
9050
9051 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
9052 continue;
9053
9054 /* Now verify that somewhere in between TYPE and CLASS,
9055 abstract method METHOD gets a non abstract definition
9056 that is inherited by CLASS. */
9057
9058 method_sig = build_java_signature (TREE_TYPE (method));
9059 method_name = DECL_NAME (method);
9060 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
9061 method_name = EXPR_WFL_NODE (method_name);
9062
9063 other_super = class;
9064 do {
9065 if (other_super == end_type)
9066 end_type_reached = 1;
9067
9068 /* Method search */
9069 for (other_method = TYPE_METHODS (other_super); other_method;
9070 other_method = TREE_CHAIN (other_method))
9071 {
9072 tree s = build_java_signature (TREE_TYPE (other_method));
9073 tree other_name = DECL_NAME (other_method);
9074
9075 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
9076 other_name = EXPR_WFL_NODE (other_name);
9077 if (!DECL_CLINIT_P (other_method)
9078 && !DECL_CONSTRUCTOR_P (other_method)
9079 && method_name == other_name
9080 && method_sig == s
9081 && !METHOD_ABSTRACT (other_method))
9082 {
9083 found = 1;
9084 break;
9085 }
9086 }
9087 other_super = CLASSTYPE_SUPER (other_super);
9088 } while (!end_type_reached);
9089
9090 /* Report that abstract METHOD didn't find an implementation
9091 that CLASS can use. */
9092 if (!found)
9093 {
9094 char *t = xstrdup (lang_printable_name
9095 (TREE_TYPE (TREE_TYPE (method)), 0));
9096 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
9097
9098 parse_error_context
9099 (lookup_cl (class_decl),
9100 "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",
9101 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
9102 t, lang_printable_name (method, 0),
9103 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
9104 "interface" : "class"),
9105 IDENTIFIER_POINTER (ccn),
9106 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
9107 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
9108 ok = 0;
9109 free (t);
9110 }
9111 }
9112
9113 if (ok && do_interface)
9114 {
9115 /* Check for implemented interfaces. */
9116 int i;
9117 tree vector = TYPE_BINFO_BASETYPES (type);
9118 for (i = 1; ok && vector && i < TREE_VEC_LENGTH (vector); i++)
9119 {
9120 tree super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
9121 ok = check_abstract_method_definitions (1, class_decl, super);
9122 }
9123 }
9124
9125 return ok;
9126 }
9127
9128 /* Check that CLASS_DECL somehow implements all inherited abstract
9129 methods. */
9130
9131 static void
java_check_abstract_method_definitions(tree class_decl)9132 java_check_abstract_method_definitions (tree class_decl)
9133 {
9134 tree class = TREE_TYPE (class_decl);
9135 tree super, vector;
9136 int i;
9137
9138 if (CLASS_ABSTRACT (class_decl))
9139 return;
9140
9141 /* Check for inherited types */
9142 super = class;
9143 do {
9144 super = CLASSTYPE_SUPER (super);
9145 check_abstract_method_definitions (0, class_decl, super);
9146 } while (super != object_type_node);
9147
9148 /* Check for implemented interfaces. */
9149 vector = TYPE_BINFO_BASETYPES (class);
9150 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
9151 {
9152 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
9153 check_abstract_method_definitions (1, class_decl, super);
9154 }
9155 }
9156
9157 /* Check all the types method DECL uses and return 1 if all of them
9158 are now complete, 0 otherwise. This is used to check whether its
9159 safe to build a method signature or not. */
9160
9161 static int
check_method_types_complete(tree decl)9162 check_method_types_complete (tree decl)
9163 {
9164 tree type = TREE_TYPE (decl);
9165 tree args;
9166
9167 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
9168 return 0;
9169
9170 args = TYPE_ARG_TYPES (type);
9171 if (TREE_CODE (type) == METHOD_TYPE)
9172 args = TREE_CHAIN (args);
9173 for (; args != end_params_node; args = TREE_CHAIN (args))
9174 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
9175 return 0;
9176
9177 return 1;
9178 }
9179
9180 /* Visible interface to check methods contained in CLASS_DECL */
9181
9182 void
java_check_methods(tree class_decl)9183 java_check_methods (tree class_decl)
9184 {
9185 if (CLASS_METHOD_CHECKED_P (TREE_TYPE (class_decl)))
9186 return;
9187
9188 if (CLASS_INTERFACE (class_decl))
9189 java_check_abstract_methods (class_decl);
9190 else
9191 java_check_regular_methods (class_decl);
9192
9193 CLASS_METHOD_CHECKED_P (TREE_TYPE (class_decl)) = 1;
9194 }
9195
9196 /* Like not_accessible_p, but doesn't refer to the current class at
9197 all. */
9198 static bool
hack_is_accessible_p(tree member,tree from_where)9199 hack_is_accessible_p (tree member, tree from_where)
9200 {
9201 int flags = get_access_flags_from_decl (member);
9202
9203 if (from_where == DECL_CONTEXT (member)
9204 || (flags & ACC_PUBLIC))
9205 return true;
9206
9207 if ((flags & ACC_PROTECTED))
9208 {
9209 if (inherits_from_p (from_where, DECL_CONTEXT (member)))
9210 return true;
9211 }
9212
9213 if ((flags & ACC_PRIVATE))
9214 return false;
9215
9216 /* Package private, or protected. */
9217 return in_same_package (TYPE_NAME (from_where),
9218 TYPE_NAME (DECL_CONTEXT (member)));
9219 }
9220
9221 /* Check all the methods of CLASS_DECL. Methods are first completed
9222 then checked according to regular method existence rules. If no
9223 constructor for CLASS_DECL were encountered, then build its
9224 declaration. */
9225 static void
java_check_regular_methods(tree class_decl)9226 java_check_regular_methods (tree class_decl)
9227 {
9228 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
9229 tree method;
9230 tree class = TREE_TYPE (class_decl);
9231 tree found = NULL_TREE;
9232 tree mthrows;
9233
9234 /* It is not necessary to check methods defined in java.lang.Object */
9235 if (class == object_type_node)
9236 return;
9237
9238 if (!TYPE_NVIRTUALS (class))
9239 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
9240
9241 /* Should take interfaces into account. FIXME */
9242 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
9243 {
9244 tree sig;
9245 tree method_wfl = DECL_FUNCTION_WFL (method);
9246 int aflags;
9247
9248 /* Check for redefinitions */
9249 if (check_method_redefinition (class, method))
9250 continue;
9251
9252 /* We verify things thrown by the method. They must inherit from
9253 java.lang.Throwable. */
9254 for (mthrows = DECL_FUNCTION_THROWS (method);
9255 mthrows; mthrows = TREE_CHAIN (mthrows))
9256 {
9257 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
9258 parse_error_context
9259 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
9260 IDENTIFIER_POINTER
9261 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
9262 }
9263
9264 /* If we see one constructor a mark so we don't generate the
9265 default one. Also skip other verifications: constructors
9266 can't be inherited hence hidden or overridden. */
9267 if (DECL_CONSTRUCTOR_P (method))
9268 {
9269 saw_constructor = 1;
9270 continue;
9271 }
9272
9273 sig = build_java_argument_signature (TREE_TYPE (method));
9274 found = lookup_argument_method_generic (class, DECL_NAME (method), sig,
9275 SEARCH_SUPER | SEARCH_INTERFACE);
9276
9277 /* Inner class can't declare static methods */
9278 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
9279 {
9280 char *t = xstrdup (lang_printable_name (class, 0));
9281 parse_error_context
9282 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
9283 lang_printable_name (method, 0), t);
9284 free (t);
9285 }
9286
9287 /* Nothing overrides or it's a private method. */
9288 if (!found)
9289 continue;
9290 if (METHOD_PRIVATE (found))
9291 {
9292 found = NULL_TREE;
9293 continue;
9294 }
9295
9296 /* If `found' is declared in an interface, make sure the
9297 modifier matches. */
9298 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
9299 && clinit_identifier_node != DECL_NAME (found)
9300 && !METHOD_PUBLIC (method))
9301 {
9302 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
9303 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
9304 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
9305 lang_printable_name (method, 0),
9306 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
9307 }
9308
9309 /* Can't override a method with the same name and different return
9310 types. */
9311 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
9312 {
9313 char *t = xstrdup
9314 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
9315 parse_error_context
9316 (method_wfl,
9317 "Method `%s' was defined with return type `%s' in class `%s'",
9318 lang_printable_name (found, 0), t,
9319 IDENTIFIER_POINTER
9320 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9321 free (t);
9322 }
9323
9324 aflags = get_access_flags_from_decl (found);
9325
9326 /* Can't override final. Can't override static. */
9327 if (METHOD_FINAL (found) || METHOD_STATIC (found))
9328 {
9329 /* Static *can* override static */
9330 if (METHOD_STATIC (found) && METHOD_STATIC (method))
9331 continue;
9332 parse_error_context
9333 (method_wfl,
9334 "%s methods can't be overridden. Method `%s' is %s in class `%s'",
9335 (METHOD_FINAL (found) ? "Final" : "Static"),
9336 lang_printable_name (found, 0),
9337 (METHOD_FINAL (found) ? "final" : "static"),
9338 IDENTIFIER_POINTER
9339 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9340 continue;
9341 }
9342
9343 /* Static method can't override instance method. */
9344 if (METHOD_STATIC (method))
9345 {
9346 parse_error_context
9347 (method_wfl,
9348 "Instance methods can't be overridden by a static method. Method `%s' is an instance method in class `%s'",
9349 lang_printable_name (found, 0),
9350 IDENTIFIER_POINTER
9351 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9352 continue;
9353 }
9354
9355 /* - Overriding/hiding public must be public
9356 - Overriding/hiding protected must be protected or public
9357 - If the overridden or hidden method has default (package)
9358 access, then the overriding or hiding method must not be
9359 private; otherwise, a compile-time error occurs. If
9360 `found' belongs to an interface, things have been already
9361 taken care of. */
9362 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
9363 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
9364 || (METHOD_PROTECTED (found)
9365 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
9366 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
9367 && METHOD_PRIVATE (method))))
9368 {
9369 parse_error_context
9370 (method_wfl,
9371 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
9372 (METHOD_PUBLIC (method) ? "public" :
9373 (METHOD_PRIVATE (method) ? "private" : "protected")),
9374 IDENTIFIER_POINTER (DECL_NAME
9375 (TYPE_NAME (DECL_CONTEXT (found)))));
9376 continue;
9377 }
9378
9379 /* Check this method against all the other implementations it
9380 overrides. Here we only check the class hierarchy; the rest
9381 of the checking is done later. If this method is just a
9382 Miranda method, we can skip the check. */
9383 if (! METHOD_INVISIBLE (method))
9384 check_concrete_throws_clauses (class, method, DECL_NAME (method), sig);
9385 }
9386
9387 /* The above throws clause check only looked at superclasses. Now
9388 we must also make sure that all methods declared in interfaces
9389 have compatible throws clauses. FIXME: there are more efficient
9390 ways to organize this checking; we should implement one. */
9391 check_interface_throws_clauses (class, class);
9392
9393 if (!TYPE_NVIRTUALS (class))
9394 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
9395
9396 /* Search for inherited abstract method not yet implemented in this
9397 class. */
9398 java_check_abstract_method_definitions (class_decl);
9399
9400 if (!saw_constructor)
9401 abort ();
9402 }
9403
9404 /* Check to make sure that all the methods in all the interfaces
9405 implemented by CLASS_DECL are compatible with the concrete
9406 implementations available in CHECK_CLASS_DECL. */
9407 static void
check_interface_throws_clauses(tree check_class_decl,tree class_decl)9408 check_interface_throws_clauses (tree check_class_decl, tree class_decl)
9409 {
9410 for (; class_decl != NULL_TREE; class_decl = CLASSTYPE_SUPER (class_decl))
9411 {
9412 tree bases;
9413 int iface_len;
9414 int i;
9415
9416 if (! CLASS_LOADED_P (class_decl))
9417 {
9418 if (CLASS_FROM_SOURCE_P (class_decl))
9419 safe_layout_class (class_decl);
9420 else
9421 load_class (class_decl, 1);
9422 }
9423
9424 bases = TYPE_BINFO_BASETYPES (class_decl);
9425 iface_len = TREE_VEC_LENGTH (bases) - 1;
9426 for (i = iface_len; i > 0; --i)
9427 {
9428 tree interface = BINFO_TYPE (TREE_VEC_ELT (bases, i));
9429 tree iface_method;
9430
9431 for (iface_method = TYPE_METHODS (interface);
9432 iface_method != NULL_TREE;
9433 iface_method = TREE_CHAIN (iface_method))
9434 {
9435 tree sig, method;
9436
9437 /* First look for a concrete method implemented or
9438 inherited by this class. No need to search
9439 interfaces here, since we're already looking through
9440 all of them. */
9441 sig = build_java_argument_signature (TREE_TYPE (iface_method));
9442 method
9443 = lookup_argument_method_generic (check_class_decl,
9444 DECL_NAME (iface_method),
9445 sig, SEARCH_VISIBLE);
9446 /* If we don't find an implementation, that is ok. Any
9447 potential errors from that are diagnosed elsewhere.
9448 Also, multiple inheritance with conflicting throws
9449 clauses is fine in the absence of a concrete
9450 implementation. */
9451 if (method != NULL_TREE && !METHOD_ABSTRACT (method)
9452 && !METHOD_INVISIBLE (iface_method))
9453 {
9454 tree method_wfl = DECL_FUNCTION_WFL (method);
9455 check_throws_clauses (method, method_wfl, iface_method);
9456 }
9457 }
9458
9459 /* Now check superinterfaces. */
9460 check_interface_throws_clauses (check_class_decl, interface);
9461 }
9462 }
9463 }
9464
9465 /* Check throws clauses of a method against the clauses of all the
9466 methods it overrides. We do this by searching up the class
9467 hierarchy, examining all matching accessible methods. */
9468 static void
check_concrete_throws_clauses(tree class,tree self_method,tree name,tree signature)9469 check_concrete_throws_clauses (tree class, tree self_method,
9470 tree name, tree signature)
9471 {
9472 tree method = lookup_argument_method_generic (class, name, signature,
9473 SEARCH_SUPER | SEARCH_VISIBLE);
9474 while (method != NULL_TREE)
9475 {
9476 if (! METHOD_INVISIBLE (method) && hack_is_accessible_p (method, class))
9477 check_throws_clauses (self_method, DECL_FUNCTION_WFL (self_method),
9478 method);
9479
9480 method = lookup_argument_method_generic (DECL_CONTEXT (method),
9481 name, signature,
9482 SEARCH_SUPER | SEARCH_VISIBLE);
9483 }
9484 }
9485
9486 /* Generate an error if the `throws' clause of METHOD (if any) is
9487 incompatible with the `throws' clause of FOUND (if any). */
9488 static void
check_throws_clauses(tree method,tree method_wfl,tree found)9489 check_throws_clauses (tree method, tree method_wfl, tree found)
9490 {
9491 tree mthrows;
9492
9493 /* Can't check these things with class loaded from bytecode. FIXME */
9494 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
9495 return;
9496
9497 for (mthrows = DECL_FUNCTION_THROWS (method);
9498 mthrows; mthrows = TREE_CHAIN (mthrows))
9499 {
9500 tree fthrows;
9501
9502 /* We don't verify unchecked expressions */
9503 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
9504 continue;
9505 /* Checked expression must be compatible */
9506 for (fthrows = DECL_FUNCTION_THROWS (found);
9507 fthrows; fthrows = TREE_CHAIN (fthrows))
9508 {
9509 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
9510 break;
9511 }
9512 if (!fthrows)
9513 {
9514 parse_error_context
9515 (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'",
9516 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
9517 lang_printable_name (found, 0),
9518 IDENTIFIER_POINTER
9519 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9520 }
9521 }
9522 }
9523
9524 /* Check abstract method of interface INTERFACE */
9525 static void
java_check_abstract_methods(tree interface_decl)9526 java_check_abstract_methods (tree interface_decl)
9527 {
9528 int i, n;
9529 tree method, basetype_vec, found;
9530 tree interface = TREE_TYPE (interface_decl);
9531
9532 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
9533 {
9534 /* 2- Check for double definition inside the defining interface */
9535 if (check_method_redefinition (interface, method))
9536 continue;
9537
9538 /* 3- Overriding is OK as far as we preserve the return type. */
9539 found = lookup_java_interface_method2 (interface, method);
9540 if (found)
9541 {
9542 char *t;
9543 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
9544 parse_error_context
9545 (DECL_FUNCTION_WFL (found),
9546 "Method `%s' was defined with return type `%s' in class `%s'",
9547 lang_printable_name (found, 0), t,
9548 IDENTIFIER_POINTER
9549 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9550 free (t);
9551 continue;
9552 }
9553 }
9554
9555 /* 4- Inherited methods can't differ by their returned types */
9556 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
9557 return;
9558 n = TREE_VEC_LENGTH (basetype_vec);
9559 for (i = 0; i < n; i++)
9560 {
9561 tree sub_interface_method, sub_interface;
9562 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
9563 if (!vec_elt)
9564 continue;
9565 sub_interface = BINFO_TYPE (vec_elt);
9566 for (sub_interface_method = TYPE_METHODS (sub_interface);
9567 sub_interface_method;
9568 sub_interface_method = TREE_CHAIN (sub_interface_method))
9569 {
9570 found = lookup_java_interface_method2 (interface,
9571 sub_interface_method);
9572 if (found && (found != sub_interface_method))
9573 {
9574 parse_error_context
9575 (lookup_cl (sub_interface_method),
9576 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
9577 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
9578 lang_printable_name (found, 0),
9579 IDENTIFIER_POINTER
9580 (DECL_NAME (TYPE_NAME
9581 (DECL_CONTEXT (sub_interface_method)))),
9582 IDENTIFIER_POINTER
9583 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
9584 }
9585 }
9586 }
9587 }
9588
9589 /* Lookup methods in interfaces using their name and partial
9590 signature. Return a matching method only if their types differ. */
9591
9592 static tree
lookup_java_interface_method2(tree class,tree method_decl)9593 lookup_java_interface_method2 (tree class, tree method_decl)
9594 {
9595 int i, n;
9596 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
9597
9598 if (!basetype_vec)
9599 return NULL_TREE;
9600
9601 n = TREE_VEC_LENGTH (basetype_vec);
9602 for (i = 0; i < n; i++)
9603 {
9604 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
9605 if ((BINFO_TYPE (vec_elt) != object_type_node)
9606 && (to_return =
9607 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
9608 return to_return;
9609 }
9610 for (i = 0; i < n; i++)
9611 {
9612 to_return = lookup_java_interface_method2
9613 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
9614 if (to_return)
9615 return to_return;
9616 }
9617
9618 return NULL_TREE;
9619 }
9620
9621 /* Lookup method using their name and partial signature. Return a
9622 matching method only if their types differ. */
9623
9624 static tree
lookup_java_method2(tree clas,tree method_decl,int do_interface)9625 lookup_java_method2 (tree clas, tree method_decl, int do_interface)
9626 {
9627 tree method, method_signature, method_name, method_type, name;
9628
9629 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
9630 name = DECL_NAME (method_decl);
9631 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9632 EXPR_WFL_NODE (name) : name);
9633 method_type = TREE_TYPE (TREE_TYPE (method_decl));
9634
9635 while (clas != NULL_TREE)
9636 {
9637 for (method = TYPE_METHODS (clas);
9638 method != NULL_TREE; method = TREE_CHAIN (method))
9639 {
9640 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
9641 tree name = DECL_NAME (method);
9642 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
9643 EXPR_WFL_NODE (name) : name) == method_name
9644 && method_sig == method_signature
9645 && TREE_TYPE (TREE_TYPE (method)) != method_type)
9646 return method;
9647 }
9648 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
9649 }
9650 return NULL_TREE;
9651 }
9652
9653 /* Return the line that matches DECL line number, and try its best to
9654 position the column number. Used during error reports. */
9655
9656 static GTY(()) tree cl_v;
9657 static tree
lookup_cl(tree decl)9658 lookup_cl (tree decl)
9659 {
9660 char *line, *found;
9661
9662 if (!decl)
9663 return NULL_TREE;
9664
9665 if (cl_v == NULL_TREE)
9666 {
9667 cl_v = build_expr_wfl (NULL_TREE, NULL, 0, 0);
9668 }
9669
9670 EXPR_WFL_FILENAME_NODE (cl_v) = get_identifier (DECL_SOURCE_FILE (decl));
9671 EXPR_WFL_SET_LINECOL (cl_v, DECL_SOURCE_LINE (decl), -1);
9672
9673 line = java_get_line_col (EXPR_WFL_FILENAME (cl_v),
9674 EXPR_WFL_LINENO (cl_v), EXPR_WFL_COLNO (cl_v));
9675
9676 found = strstr ((const char *)line,
9677 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
9678 if (found)
9679 EXPR_WFL_SET_LINECOL (cl_v, EXPR_WFL_LINENO (cl_v), found - line);
9680
9681 return cl_v;
9682 }
9683
9684 /* Look for a simple name in the single-type import list */
9685
9686 static tree
find_name_in_single_imports(tree name)9687 find_name_in_single_imports (tree name)
9688 {
9689 tree node;
9690
9691 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
9692 if (TREE_VALUE (node) == name)
9693 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
9694
9695 return NULL_TREE;
9696 }
9697
9698 /* Process all single-type import. */
9699
9700 static int
process_imports(void)9701 process_imports (void)
9702 {
9703 tree import;
9704 int error_found;
9705
9706 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9707 {
9708 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9709 char *original_name;
9710
9711 original_name = xmemdup (IDENTIFIER_POINTER (to_be_found),
9712 IDENTIFIER_LENGTH (to_be_found),
9713 IDENTIFIER_LENGTH (to_be_found) + 1);
9714
9715 /* Don't load twice something already defined. */
9716 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9717 continue;
9718
9719 while (1)
9720 {
9721 tree left;
9722
9723 QUALIFIED_P (to_be_found) = 1;
9724 load_class (to_be_found, 0);
9725 error_found =
9726 check_pkg_class_access (to_be_found, TREE_PURPOSE (import), true);
9727
9728 /* We found it, we can bail out */
9729 if (IDENTIFIER_CLASS_VALUE (to_be_found))
9730 {
9731 check_deprecation (TREE_PURPOSE (import),
9732 IDENTIFIER_CLASS_VALUE (to_be_found));
9733 break;
9734 }
9735
9736 /* We haven't found it. Maybe we're trying to access an
9737 inner class. The only way for us to know is to try again
9738 after having dropped a qualifier. If we can't break it further,
9739 we have an error. */
9740 if (breakdown_qualified (&left, NULL, to_be_found))
9741 break;
9742
9743 to_be_found = left;
9744 }
9745 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9746 {
9747 parse_error_context (TREE_PURPOSE (import),
9748 "Class or interface `%s' not found in import",
9749 original_name);
9750 error_found = 1;
9751 }
9752
9753 free (original_name);
9754 if (error_found)
9755 return 1;
9756 }
9757 return 0;
9758 }
9759
9760 /* Possibly find and mark a class imported by a single-type import
9761 statement. */
9762
9763 static void
find_in_imports(tree enclosing_type,tree class_type)9764 find_in_imports (tree enclosing_type, tree class_type)
9765 {
9766 tree import = (enclosing_type ? TYPE_IMPORT_LIST (enclosing_type) :
9767 ctxp->import_list);
9768 while (import)
9769 {
9770 if (TREE_VALUE (import) == TYPE_NAME (class_type))
9771 {
9772 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9773 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9774 return;
9775 }
9776 import = TREE_CHAIN (import);
9777 }
9778 }
9779
9780 static int
note_possible_classname(const char * name,int len)9781 note_possible_classname (const char *name, int len)
9782 {
9783 tree node;
9784 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9785 len = len - 5;
9786 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9787 len = len - 6;
9788 else
9789 return 0;
9790 node = ident_subst (name, len, "", '/', '.', "");
9791 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9792 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9793 return 1;
9794 }
9795
9796 /* Read a import directory, gathering potential match for further type
9797 references. Indifferently reads a filesystem or a ZIP archive
9798 directory. */
9799
9800 static void
read_import_dir(tree wfl)9801 read_import_dir (tree wfl)
9802 {
9803 tree package_id = EXPR_WFL_NODE (wfl);
9804 const char *package_name = IDENTIFIER_POINTER (package_id);
9805 int package_length = IDENTIFIER_LENGTH (package_id);
9806 DIR *dirp = NULL;
9807 JCF *saved_jcf = current_jcf;
9808
9809 int found = 0;
9810 int k;
9811 void *entry;
9812 struct buffer filename[1];
9813
9814 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9815 return;
9816 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9817
9818 BUFFER_INIT (filename);
9819 buffer_grow (filename, package_length + 100);
9820
9821 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9822 {
9823 const char *entry_name = jcf_path_name (entry);
9824 int entry_length = strlen (entry_name);
9825 if (jcf_path_is_zipfile (entry))
9826 {
9827 ZipFile *zipf;
9828 buffer_grow (filename, entry_length);
9829 memcpy (filename->data, entry_name, entry_length - 1);
9830 filename->data[entry_length-1] = '\0';
9831 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9832 if (zipf == NULL)
9833 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9834 else
9835 {
9836 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9837 BUFFER_RESET (filename);
9838 for (k = 0; k < package_length; k++)
9839 {
9840 char ch = package_name[k];
9841 *filename->ptr++ = ch == '.' ? '/' : ch;
9842 }
9843 *filename->ptr++ = '/';
9844
9845 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9846 {
9847 const char *current_entry = ZIPDIR_FILENAME (zipd);
9848 int current_entry_len = zipd->filename_length;
9849
9850 if (current_entry_len >= BUFFER_LENGTH (filename)
9851 && strncmp (filename->data, current_entry,
9852 BUFFER_LENGTH (filename)) != 0)
9853 continue;
9854 found |= note_possible_classname (current_entry,
9855 current_entry_len);
9856 }
9857 }
9858 }
9859 else
9860 {
9861 BUFFER_RESET (filename);
9862 buffer_grow (filename, entry_length + package_length + 4);
9863 strcpy (filename->data, entry_name);
9864 filename->ptr = filename->data + entry_length;
9865 for (k = 0; k < package_length; k++)
9866 {
9867 char ch = package_name[k];
9868 *filename->ptr++ = ch == '.' ? '/' : ch;
9869 }
9870 *filename->ptr = '\0';
9871
9872 dirp = opendir (filename->data);
9873 if (dirp == NULL)
9874 continue;
9875 *filename->ptr++ = '/';
9876 for (;;)
9877 {
9878 int len;
9879 const char *d_name;
9880 struct dirent *direntp = readdir (dirp);
9881 if (!direntp)
9882 break;
9883 d_name = direntp->d_name;
9884 len = strlen (direntp->d_name);
9885 buffer_grow (filename, len+1);
9886 strcpy (filename->ptr, d_name);
9887 found |= note_possible_classname (filename->data + entry_length,
9888 package_length+len+1);
9889 }
9890 if (dirp)
9891 closedir (dirp);
9892 }
9893 }
9894
9895 free (filename->data);
9896
9897 /* Here we should have a unified way of retrieving an entry, to be
9898 indexed. */
9899 if (!found)
9900 {
9901 static int first = 1;
9902 if (first)
9903 {
9904 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives", package_name);
9905 java_error_count++;
9906 first = 0;
9907 }
9908 else
9909 parse_error_context (wfl, "Package `%s' not found in import",
9910 package_name);
9911 current_jcf = saved_jcf;
9912 return;
9913 }
9914 current_jcf = saved_jcf;
9915 }
9916
9917 /* Possibly find a type in the import on demands specified
9918 types. Returns 1 if an error occurred, 0 otherwise. Run through the
9919 entire list, to detected potential double definitions. */
9920
9921 static int
find_in_imports_on_demand(tree enclosing_type,tree class_type)9922 find_in_imports_on_demand (tree enclosing_type, tree class_type)
9923 {
9924 tree class_type_name = TYPE_NAME (class_type);
9925 tree import = (enclosing_type ? TYPE_IMPORT_DEMAND_LIST (enclosing_type) :
9926 ctxp->import_demand_list);
9927 tree cl = NULL_TREE;
9928 int seen_once = -1; /* -1 when not set, 1 if seen once, >1 otherwise. */
9929 int to_return = -1; /* -1 when not set, 0 or 1 otherwise */
9930 tree node;
9931
9932 for (; import; import = TREE_CHAIN (import))
9933 {
9934 int saved_lineno = input_line;
9935 int access_check;
9936 const char *id_name;
9937 tree decl, type_name_copy;
9938
9939 obstack_grow (&temporary_obstack,
9940 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9941 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9942 obstack_1grow (&temporary_obstack, '.');
9943 obstack_grow0 (&temporary_obstack,
9944 IDENTIFIER_POINTER (class_type_name),
9945 IDENTIFIER_LENGTH (class_type_name));
9946 id_name = obstack_finish (&temporary_obstack);
9947
9948 if (! (node = maybe_get_identifier (id_name)))
9949 continue;
9950
9951 /* Setup lineno so that it refers to the line of the import (in
9952 case we parse a class file and encounter errors */
9953 input_line = EXPR_WFL_LINENO (TREE_PURPOSE (import));
9954
9955 type_name_copy = TYPE_NAME (class_type);
9956 TYPE_NAME (class_type) = node;
9957 QUALIFIED_P (node) = 1;
9958 decl = IDENTIFIER_CLASS_VALUE (node);
9959 access_check = -1;
9960 /* If there is no DECL set for the class or if the class isn't
9961 loaded and not seen in source yet, then load */
9962 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9963 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9964 {
9965 load_class (node, 0);
9966 decl = IDENTIFIER_CLASS_VALUE (node);
9967 }
9968 if (decl && ! INNER_CLASS_P (TREE_TYPE (decl)))
9969 access_check = check_pkg_class_access (node, TREE_PURPOSE (import),
9970 false);
9971 else
9972 /* 6.6.1: Inner classes are subject to member access rules. */
9973 access_check = 0;
9974
9975 input_line = saved_lineno;
9976
9977 /* If the loaded class is not accessible or couldn't be loaded,
9978 we restore the original TYPE_NAME and process the next
9979 import. */
9980 if (access_check || !decl)
9981 {
9982 TYPE_NAME (class_type) = type_name_copy;
9983 continue;
9984 }
9985
9986 /* If the loaded class is accessible, we keep a tab on it to
9987 detect and report multiple inclusions. */
9988 if (IS_A_CLASSFILE_NAME (node))
9989 {
9990 if (seen_once < 0)
9991 {
9992 cl = TREE_PURPOSE (import);
9993 seen_once = 1;
9994 }
9995 else if (seen_once >= 0)
9996 {
9997 tree location = (cl ? cl : TREE_PURPOSE (import));
9998 tree package = (cl ? EXPR_WFL_NODE (cl) :
9999 EXPR_WFL_NODE (TREE_PURPOSE (import)));
10000 seen_once++;
10001 parse_error_context
10002 (location,
10003 "Type `%s' also potentially defined in package `%s'",
10004 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
10005 IDENTIFIER_POINTER (package));
10006 }
10007 }
10008 to_return = access_check;
10009 }
10010
10011 if (seen_once == 1)
10012 return to_return;
10013 else
10014 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
10015 }
10016
10017 /* Add package NAME to the list of packages encountered so far. To
10018 speed up class lookup in do_resolve_class, we make sure a
10019 particular package is added only once. */
10020
10021 static void
register_package(tree name)10022 register_package (tree name)
10023 {
10024 static htab_t pht;
10025 void **e;
10026
10027 if (pht == NULL)
10028 pht = htab_create (50, htab_hash_pointer, htab_eq_pointer, NULL);
10029
10030 e = htab_find_slot (pht, name, INSERT);
10031 if (*e == NULL)
10032 {
10033 package_list = chainon (package_list, build_tree_list (name, NULL));
10034 *e = name;
10035 }
10036 }
10037
10038 static tree
resolve_package(tree pkg,tree * next,tree * type_name)10039 resolve_package (tree pkg, tree *next, tree *type_name)
10040 {
10041 tree current;
10042 tree decl = NULL_TREE;
10043 *type_name = NULL_TREE;
10044
10045 /* The trick is to determine when the package name stops and were
10046 the name of something contained in the package starts. Then we
10047 return a fully qualified name of what we want to get. */
10048
10049 *next = EXPR_WFL_QUALIFICATION (pkg);
10050
10051 /* Try to progressively construct a type name */
10052 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
10053 for (current = EXPR_WFL_QUALIFICATION (pkg);
10054 current; current = TREE_CHAIN (current))
10055 {
10056 /* If we don't have what we're expecting, exit now. TYPE_NAME
10057 will be null and the error caught later. */
10058 if (TREE_CODE (QUAL_WFL (current)) != EXPR_WITH_FILE_LOCATION)
10059 break;
10060 *type_name =
10061 merge_qualified_name (*type_name, EXPR_WFL_NODE (QUAL_WFL (current)));
10062 if ((decl = resolve_no_layout (*type_name, NULL_TREE)))
10063 {
10064 /* resolve_package should be used in a loop, hence we
10065 point at this one to naturally process the next one at
10066 the next iteration. */
10067 *next = current;
10068 break;
10069 }
10070 }
10071 return decl;
10072 }
10073
10074
10075 /* Check accessibility of inner classes according to member access rules.
10076 DECL is the inner class, ENCLOSING_DECL is the class from which the
10077 access is being attempted. */
10078
10079 static void
check_inner_class_access(tree decl,tree enclosing_decl,tree cl)10080 check_inner_class_access (tree decl, tree enclosing_decl, tree cl)
10081 {
10082 const char *access;
10083 tree enclosing_decl_type;
10084
10085 /* We don't issue an error message when CL is null. CL can be null
10086 as a result of processing a JDEP crafted by source_start_java_method
10087 for the purpose of patching its parm decl. But the error would
10088 have been already trapped when fixing the method's signature.
10089 DECL can also be NULL in case of earlier errors. */
10090 if (!decl || !cl)
10091 return;
10092
10093 enclosing_decl_type = TREE_TYPE (enclosing_decl);
10094
10095 if (CLASS_PRIVATE (decl))
10096 {
10097 /* Access is permitted only within the body of the top-level
10098 class in which DECL is declared. */
10099 tree top_level = decl;
10100 while (DECL_CONTEXT (top_level))
10101 top_level = DECL_CONTEXT (top_level);
10102 while (DECL_CONTEXT (enclosing_decl))
10103 enclosing_decl = DECL_CONTEXT (enclosing_decl);
10104 if (top_level == enclosing_decl)
10105 return;
10106 access = "private";
10107 }
10108 else if (CLASS_PROTECTED (decl))
10109 {
10110 tree decl_context;
10111 /* Access is permitted from within the same package... */
10112 if (in_same_package (decl, enclosing_decl))
10113 return;
10114
10115 /* ... or from within the body of a subtype of the context in which
10116 DECL is declared. */
10117 decl_context = DECL_CONTEXT (decl);
10118 while (enclosing_decl)
10119 {
10120 if (CLASS_INTERFACE (decl))
10121 {
10122 if (interface_of_p (TREE_TYPE (decl_context),
10123 enclosing_decl_type))
10124 return;
10125 }
10126 else
10127 {
10128 /* Eww. The order of the arguments is different!! */
10129 if (inherits_from_p (enclosing_decl_type,
10130 TREE_TYPE (decl_context)))
10131 return;
10132 }
10133 enclosing_decl = DECL_CONTEXT (enclosing_decl);
10134 }
10135 access = "protected";
10136 }
10137 else if (! CLASS_PUBLIC (decl))
10138 {
10139 /* Access is permitted only from within the same package as DECL. */
10140 if (in_same_package (decl, enclosing_decl))
10141 return;
10142 access = "non-public";
10143 }
10144 else
10145 /* Class is public. */
10146 return;
10147
10148 parse_error_context (cl, "Nested %s %s is %s; cannot be accessed from here",
10149 (CLASS_INTERFACE (decl) ? "interface" : "class"),
10150 lang_printable_name (decl, 0), access);
10151 }
10152
10153 /* Accessibility check for top-level classes. If CLASS_NAME is in a
10154 foreign package, it must be PUBLIC. Return 0 if no access
10155 violations were found, 1 otherwise. If VERBOSE is true and an error
10156 was found, it is reported and accounted for. */
10157
10158 static int
check_pkg_class_access(tree class_name,tree cl,bool verbose)10159 check_pkg_class_access (tree class_name, tree cl, bool verbose)
10160 {
10161 tree type;
10162
10163 if (!IDENTIFIER_CLASS_VALUE (class_name))
10164 return 0;
10165
10166 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
10167 return 0;
10168
10169 if (!CLASS_PUBLIC (TYPE_NAME (type)))
10170 {
10171 /* Access to a private class within the same package is
10172 allowed. */
10173 tree l, r;
10174 breakdown_qualified (&l, &r, class_name);
10175 if (!QUALIFIED_P (class_name) && !ctxp->package)
10176 /* Both in the empty package. */
10177 return 0;
10178 if (l == ctxp->package)
10179 /* Both in the same package. */
10180 return 0;
10181
10182 if (verbose)
10183 parse_error_context
10184 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
10185 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
10186 IDENTIFIER_POINTER (class_name));
10187 return 1;
10188 }
10189 return 0;
10190 }
10191
10192 /* Local variable declaration. */
10193
10194 static void
declare_local_variables(int modifier,tree type,tree vlist)10195 declare_local_variables (int modifier, tree type, tree vlist)
10196 {
10197 tree decl, current, saved_type;
10198 tree type_wfl = NULL_TREE;
10199 int must_chain = 0;
10200 int final_p = 0;
10201
10202 /* Push a new block if statements were seen between the last time we
10203 pushed a block and now. Keep a count of blocks to close */
10204 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
10205 {
10206 tree b = enter_block ();
10207 BLOCK_IS_IMPLICIT (b) = 1;
10208 }
10209
10210 if (modifier)
10211 {
10212 size_t i;
10213 for (i = 0; i < ARRAY_SIZE (ctxp->modifier_ctx); i++)
10214 if (1 << i & modifier)
10215 break;
10216 if (modifier == ACC_FINAL)
10217 final_p = 1;
10218 else
10219 {
10220 parse_error_context
10221 (ctxp->modifier_ctx [i],
10222 "Only `final' is allowed as a local variables modifier");
10223 return;
10224 }
10225 }
10226
10227 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
10228 hold the TYPE value if a new incomplete has to be created (as
10229 opposed to being found already existing and reused). */
10230 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
10231
10232 /* If TYPE is fully resolved and we don't have a reference, make one */
10233 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
10234
10235 /* Go through all the declared variables */
10236 for (current = vlist, saved_type = type; current;
10237 current = TREE_CHAIN (current), type = saved_type)
10238 {
10239 tree other, real_type;
10240 tree wfl = TREE_PURPOSE (current);
10241 tree name = EXPR_WFL_NODE (wfl);
10242 tree init = TREE_VALUE (current);
10243
10244 /* Process NAME, as it may specify extra dimension(s) for it */
10245 type = build_array_from_name (type, type_wfl, name, &name);
10246
10247 /* Variable redefinition check */
10248 if ((other = lookup_name_in_blocks (name)))
10249 {
10250 variable_redefinition_error (wfl, name, TREE_TYPE (other),
10251 DECL_SOURCE_LINE (other));
10252 continue;
10253 }
10254
10255 /* Type adjustment. We may have just readjusted TYPE because
10256 the variable specified more dimensions. Make sure we have
10257 a reference if we can and don't have one already. */
10258 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
10259
10260 real_type = GET_REAL_TYPE (type);
10261 /* Never layout this decl. This will be done when its scope
10262 will be entered */
10263 decl = build_decl (VAR_DECL, name, real_type);
10264 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
10265 DECL_FINAL (decl) = final_p;
10266 BLOCK_CHAIN_DECL (decl);
10267
10268 /* If doing xreferencing, replace the line number with the WFL
10269 compound value */
10270 if (flag_emit_xref)
10271 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
10272
10273 /* Don't try to use an INIT statement when an error was found */
10274 if (init && java_error_count)
10275 init = NULL_TREE;
10276
10277 /* Add the initialization function to the current function's code */
10278 if (init)
10279 {
10280 /* Name might have been readjusted */
10281 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
10282 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
10283 java_method_add_stmt (current_function_decl,
10284 build_debugable_stmt (EXPR_WFL_LINECOL (init),
10285 init));
10286 }
10287
10288 /* Setup dependency the type of the decl */
10289 if (must_chain)
10290 {
10291 jdep *dep;
10292 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
10293 dep = CLASSD_LAST (ctxp->classd_list);
10294 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
10295 }
10296 }
10297 SOURCE_FRONTEND_DEBUG (("Defined locals"));
10298 }
10299
10300 /* Called during parsing. Build decls from argument list. */
10301
10302 static void
source_start_java_method(tree fndecl)10303 source_start_java_method (tree fndecl)
10304 {
10305 tree tem;
10306 tree parm_decl;
10307 int i;
10308
10309 if (!fndecl)
10310 return;
10311
10312 current_function_decl = fndecl;
10313
10314 /* New scope for the function */
10315 enter_block ();
10316 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
10317 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
10318 {
10319 tree type = TREE_VALUE (tem);
10320 tree name = TREE_PURPOSE (tem);
10321
10322 /* If type is incomplete. Create an incomplete decl and ask for
10323 the decl to be patched later */
10324 if (INCOMPLETE_TYPE_P (type))
10325 {
10326 jdep *jdep;
10327 tree real_type = GET_REAL_TYPE (type);
10328 parm_decl = build_decl (PARM_DECL, name, real_type);
10329 type = obtain_incomplete_type (type);
10330 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
10331 jdep = CLASSD_LAST (ctxp->classd_list);
10332 JDEP_MISC (jdep) = name;
10333 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
10334 }
10335 else
10336 parm_decl = build_decl (PARM_DECL, name, type);
10337
10338 /* Remember if a local variable was declared final (via its
10339 TREE_LIST of type/name.) Set DECL_FINAL accordingly. */
10340 if (ARG_FINAL_P (tem))
10341 {
10342 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (parm_decl);
10343 DECL_FINAL (parm_decl) = 1;
10344 }
10345
10346 BLOCK_CHAIN_DECL (parm_decl);
10347 }
10348 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
10349 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
10350 nreverse (tem);
10351 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
10352 DECL_MAX_LOCALS (current_function_decl) = i;
10353 }
10354
10355 /* Called during parsing. Creates an artificial method declaration. */
10356
10357 static tree
create_artificial_method(tree class,int flags,tree type,tree name,tree args)10358 create_artificial_method (tree class, int flags, tree type,
10359 tree name, tree args)
10360 {
10361 tree mdecl;
10362
10363 java_parser_context_save_global ();
10364 input_line = 0;
10365 mdecl = make_node (FUNCTION_TYPE);
10366 TREE_TYPE (mdecl) = type;
10367 TYPE_ARG_TYPES (mdecl) = args;
10368 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
10369 java_parser_context_restore_global ();
10370 DECL_ARTIFICIAL (mdecl) = 1;
10371 return mdecl;
10372 }
10373
10374 /* Starts the body if an artificial method. */
10375
10376 static void
start_artificial_method_body(tree mdecl)10377 start_artificial_method_body (tree mdecl)
10378 {
10379 DECL_SOURCE_LINE (mdecl) = 1;
10380 DECL_FUNCTION_LAST_LINE (mdecl) = 1;
10381 source_start_java_method (mdecl);
10382 enter_block ();
10383 }
10384
10385 static void
end_artificial_method_body(tree mdecl)10386 end_artificial_method_body (tree mdecl)
10387 {
10388 /* exit_block modifies DECL_FUNCTION_BODY (current_function_decl).
10389 It has to be evaluated first. (if mdecl is current_function_decl,
10390 we have an undefined behavior if no temporary variable is used.) */
10391 tree b = exit_block ();
10392 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = b;
10393 exit_block ();
10394 }
10395
10396 /* Dump a tree of some kind. This is a convenience wrapper for the
10397 dump_* functions in tree-dump.c. */
10398 static void
dump_java_tree(enum tree_dump_index phase,tree t)10399 dump_java_tree (enum tree_dump_index phase, tree t)
10400 {
10401 FILE *stream;
10402 int flags;
10403
10404 stream = dump_begin (phase, &flags);
10405 flags |= TDF_SLIM;
10406 if (stream)
10407 {
10408 dump_node (t, flags, stream);
10409 dump_end (phase, stream);
10410 }
10411 }
10412
10413 /* Terminate a function and expand its body. */
10414
10415 static void
source_end_java_method(void)10416 source_end_java_method (void)
10417 {
10418 tree fndecl = current_function_decl;
10419
10420 if (!fndecl)
10421 return;
10422
10423 java_parser_context_save_global ();
10424 input_line = ctxp->last_ccb_indent1;
10425
10426 /* Turn function bodies with only a NOP expr null, so they don't get
10427 generated at all and we won't get warnings when using the -W
10428 -Wall flags. */
10429 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
10430 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
10431
10432 /* We've generated all the trees for this function, and it has been
10433 patched. Dump it to a file if the user requested it. */
10434 dump_java_tree (TDI_original, fndecl);
10435
10436 /* Defer expanding the method until cgraph analysis is complete. */
10437 if (DECL_SAVED_TREE (fndecl))
10438 cgraph_finalize_function (fndecl, false);
10439
10440 current_function_decl = NULL_TREE;
10441 java_parser_context_restore_global ();
10442 }
10443
10444 /* Record EXPR in the current function block. Complements compound
10445 expression second operand if necessary. */
10446
10447 tree
java_method_add_stmt(tree fndecl,tree expr)10448 java_method_add_stmt (tree fndecl, tree expr)
10449 {
10450 if (!GET_CURRENT_BLOCK (fndecl))
10451 return NULL_TREE;
10452 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
10453 }
10454
10455 static tree
add_stmt_to_block(tree b,tree type,tree stmt)10456 add_stmt_to_block (tree b, tree type, tree stmt)
10457 {
10458 tree body = BLOCK_EXPR_BODY (b), c;
10459
10460 if (java_error_count)
10461 return body;
10462
10463 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
10464 return body;
10465
10466 BLOCK_EXPR_BODY (b) = c;
10467 TREE_SIDE_EFFECTS (c) = 1;
10468 return c;
10469 }
10470
10471 /* Add STMT to EXISTING if possible, otherwise create a new
10472 COMPOUND_EXPR and add STMT to it. */
10473
10474 static tree
add_stmt_to_compound(tree existing,tree type,tree stmt)10475 add_stmt_to_compound (tree existing, tree type, tree stmt)
10476 {
10477 if (existing)
10478 return build (COMPOUND_EXPR, type, existing, stmt);
10479 else
10480 return stmt;
10481 }
10482
java_layout_seen_class_methods(void)10483 void java_layout_seen_class_methods (void)
10484 {
10485 tree previous_list = all_class_list;
10486 tree end = NULL_TREE;
10487 tree current;
10488
10489 while (1)
10490 {
10491 for (current = previous_list;
10492 current != end; current = TREE_CHAIN (current))
10493 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
10494
10495 if (previous_list != all_class_list)
10496 {
10497 end = previous_list;
10498 previous_list = all_class_list;
10499 }
10500 else
10501 break;
10502 }
10503 }
10504
10505 static GTY(()) tree stop_reordering;
10506 void
java_reorder_fields(void)10507 java_reorder_fields (void)
10508 {
10509 tree current;
10510
10511 for (current = gclass_list; current; current = TREE_CHAIN (current))
10512 {
10513 output_class = current_class = TREE_TYPE (TREE_VALUE (current));
10514
10515 if (current_class == stop_reordering)
10516 break;
10517
10518 /* Reverse the fields, but leave the dummy field in front.
10519 Fields are already ordered for Object and Class */
10520 if (TYPE_FIELDS (current_class) && current_class != object_type_node
10521 && current_class != class_type_node)
10522 {
10523 /* If the dummy field is there, reverse the right fields and
10524 just layout the type for proper fields offset */
10525 if (!DECL_NAME (TYPE_FIELDS (current_class)))
10526 {
10527 tree fields = TYPE_FIELDS (current_class);
10528 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
10529 TYPE_SIZE (current_class) = NULL_TREE;
10530 }
10531 /* We don't have a dummy field, we need to layout the class,
10532 after having reversed the fields */
10533 else
10534 {
10535 TYPE_FIELDS (current_class) =
10536 nreverse (TYPE_FIELDS (current_class));
10537 TYPE_SIZE (current_class) = NULL_TREE;
10538 }
10539 }
10540 }
10541 /* There are cases were gclass_list will be empty. */
10542 if (gclass_list)
10543 stop_reordering = TREE_TYPE (TREE_VALUE (gclass_list));
10544 }
10545
10546 /* Layout the methods of all classes loaded in one way or another.
10547 Check methods of source parsed classes. Then reorder the
10548 fields and layout the classes or the type of all source parsed
10549 classes */
10550
10551 void
java_layout_classes(void)10552 java_layout_classes (void)
10553 {
10554 tree current;
10555 int save_error_count = java_error_count;
10556
10557 /* Layout the methods of all classes seen so far */
10558 java_layout_seen_class_methods ();
10559 java_parse_abort_on_error ();
10560 all_class_list = NULL_TREE;
10561
10562 /* Then check the methods of all parsed classes */
10563 for (current = gclass_list; current; current = TREE_CHAIN (current))
10564 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
10565 java_check_methods (TREE_VALUE (current));
10566 java_parse_abort_on_error ();
10567
10568 for (current = gclass_list; current; current = TREE_CHAIN (current))
10569 {
10570 output_class = current_class = TREE_TYPE (TREE_VALUE (current));
10571 layout_class (current_class);
10572
10573 /* Error reported by the caller */
10574 if (java_error_count)
10575 return;
10576 }
10577
10578 /* We might have reloaded classes durign the process of laying out
10579 classes for code generation. We must layout the methods of those
10580 late additions, as constructor checks might use them */
10581 java_layout_seen_class_methods ();
10582 java_parse_abort_on_error ();
10583 }
10584
10585 /* Expand methods in the current set of classes remembered for
10586 generation. */
10587
10588 static void
java_complete_expand_classes(void)10589 java_complete_expand_classes (void)
10590 {
10591 tree current;
10592
10593 do_not_fold = flag_emit_xref;
10594
10595 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10596 if (!INNER_CLASS_DECL_P (current))
10597 java_complete_expand_class (current);
10598 }
10599
10600 /* Expand the methods found in OUTER, starting first by OUTER's inner
10601 classes, if any. */
10602
10603 static void
java_complete_expand_class(tree outer)10604 java_complete_expand_class (tree outer)
10605 {
10606 tree inner_list;
10607
10608 set_nested_class_simple_name_value (outer, 1); /* Set */
10609
10610 /* We need to go after all inner classes and start expanding them,
10611 starting with most nested ones. We have to do that because nested
10612 classes might add functions to outer classes */
10613
10614 for (inner_list = DECL_INNER_CLASS_LIST (outer);
10615 inner_list; inner_list = TREE_CHAIN (inner_list))
10616 java_complete_expand_class (TREE_PURPOSE (inner_list));
10617
10618 java_complete_expand_methods (outer);
10619 set_nested_class_simple_name_value (outer, 0); /* Reset */
10620 }
10621
10622 /* Expand methods registered in CLASS_DECL. The general idea is that
10623 we expand regular methods first. This allows us get an estimate on
10624 how outer context local alias fields are really used so we can add
10625 to the constructor just enough code to initialize them properly (it
10626 also lets us generate finit$ correctly.) Then we expand the
10627 constructors and then <clinit>. */
10628
10629 static void
java_complete_expand_methods(tree class_decl)10630 java_complete_expand_methods (tree class_decl)
10631 {
10632 tree clinit, decl, first_decl;
10633
10634 output_class = current_class = TREE_TYPE (class_decl);
10635
10636 /* Pre-expand <clinit> to figure whether we really need it or
10637 not. If we do need it, we pre-expand the static fields so they're
10638 ready to be used somewhere else. <clinit> will be fully expanded
10639 after we processed the constructors. */
10640 first_decl = TYPE_METHODS (current_class);
10641 clinit = maybe_generate_pre_expand_clinit (current_class);
10642
10643 /* Then generate finit$ (if we need to) because constructors will
10644 try to use it.*/
10645 if (TYPE_FINIT_STMT_LIST (current_class))
10646 java_complete_expand_method (generate_finit (current_class));
10647
10648 /* Then generate instinit$ (if we need to) because constructors will
10649 try to use it. */
10650 if (TYPE_II_STMT_LIST (current_class))
10651 java_complete_expand_method (generate_instinit (current_class));
10652
10653 /* Now do the constructors */
10654 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
10655 {
10656 int no_body;
10657
10658 if (!DECL_CONSTRUCTOR_P (decl))
10659 continue;
10660
10661 no_body = !DECL_FUNCTION_BODY (decl);
10662 /* Don't generate debug info on line zero when expanding a
10663 generated constructor. */
10664 if (no_body)
10665 restore_line_number_status (1);
10666
10667 java_complete_expand_method (decl);
10668
10669 if (no_body)
10670 restore_line_number_status (0);
10671 }
10672
10673 /* First, do the ordinary methods. */
10674 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
10675 {
10676 /* Ctors aren't part of this batch. */
10677 if (DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
10678 continue;
10679
10680 /* Skip abstract or native methods -- but do handle native
10681 methods when generating JNI stubs. */
10682 if (METHOD_ABSTRACT (decl) || (! flag_jni && METHOD_NATIVE (decl)))
10683 {
10684 DECL_FUNCTION_BODY (decl) = NULL_TREE;
10685 continue;
10686 }
10687
10688 if (METHOD_NATIVE (decl))
10689 {
10690 tree body;
10691 current_function_decl = decl;
10692 body = build_jni_stub (decl);
10693 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl)) = body;
10694 }
10695
10696 java_complete_expand_method (decl);
10697 }
10698
10699 /* If there is indeed a <clinit>, fully expand it now */
10700 if (clinit)
10701 {
10702 /* Prevent the use of `this' inside <clinit> */
10703 ctxp->explicit_constructor_p = 1;
10704 java_complete_expand_method (clinit);
10705 ctxp->explicit_constructor_p = 0;
10706 }
10707
10708 /* We might have generated a class$ that we now want to expand */
10709 if (TYPE_DOT_CLASS (current_class))
10710 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
10711
10712 /* Now verify constructor circularity (stop after the first one we
10713 prove wrong.) */
10714 if (!CLASS_INTERFACE (class_decl))
10715 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
10716 if (DECL_CONSTRUCTOR_P (decl)
10717 && verify_constructor_circularity (decl, decl))
10718 break;
10719 }
10720
10721 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10722 safely used in some other methods/constructors. */
10723
10724 static tree
maybe_generate_pre_expand_clinit(tree class_type)10725 maybe_generate_pre_expand_clinit (tree class_type)
10726 {
10727 tree current, mdecl;
10728
10729 if (!TYPE_CLINIT_STMT_LIST (class_type))
10730 return NULL_TREE;
10731
10732 /* Go through all static fields and pre expand them */
10733 for (current = TYPE_FIELDS (class_type); current;
10734 current = TREE_CHAIN (current))
10735 if (FIELD_STATIC (current))
10736 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10737
10738 /* Then build the <clinit> method */
10739 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10740 clinit_identifier_node, end_params_node);
10741 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10742 mdecl, NULL_TREE);
10743 start_artificial_method_body (mdecl);
10744
10745 /* We process the list of assignment we produced as the result of
10746 the declaration of initialized static field and add them as
10747 statement to the <clinit> method. */
10748 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10749 current = TREE_CHAIN (current))
10750 {
10751 tree stmt = current;
10752 /* We build the assignment expression that will initialize the
10753 field to its value. There are strict rules on static
10754 initializers (8.5). FIXME */
10755 if (TREE_CODE (stmt) != BLOCK && stmt != empty_stmt_node)
10756 stmt = build_debugable_stmt (EXPR_WFL_LINECOL (stmt), stmt);
10757 java_method_add_stmt (mdecl, stmt);
10758 }
10759
10760 end_artificial_method_body (mdecl);
10761
10762 /* Now we want to place <clinit> as the last method (because we need
10763 it at least for interface so that it doesn't interfere with the
10764 dispatch table based lookup. */
10765 if (TREE_CHAIN (TYPE_METHODS (class_type)))
10766 {
10767 current = TREE_CHAIN (TYPE_METHODS (class_type));
10768 TYPE_METHODS (class_type) = current;
10769
10770 while (TREE_CHAIN (current))
10771 current = TREE_CHAIN (current);
10772
10773 TREE_CHAIN (current) = mdecl;
10774 TREE_CHAIN (mdecl) = NULL_TREE;
10775 }
10776
10777 return mdecl;
10778 }
10779
10780 /* Analyzes a method body and look for something that isn't a
10781 MODIFY_EXPR with a constant value. */
10782
10783 static int
analyze_clinit_body(tree this_class,tree bbody)10784 analyze_clinit_body (tree this_class, tree bbody)
10785 {
10786 while (bbody)
10787 switch (TREE_CODE (bbody))
10788 {
10789 case BLOCK:
10790 bbody = BLOCK_EXPR_BODY (bbody);
10791 break;
10792
10793 case EXPR_WITH_FILE_LOCATION:
10794 bbody = EXPR_WFL_NODE (bbody);
10795 break;
10796
10797 case COMPOUND_EXPR:
10798 if (analyze_clinit_body (this_class, TREE_OPERAND (bbody, 0)))
10799 return 1;
10800 bbody = TREE_OPERAND (bbody, 1);
10801 break;
10802
10803 case MODIFY_EXPR:
10804 /* If we're generating to class file and we're dealing with an
10805 array initialization, we return 1 to keep <clinit> */
10806 if (TREE_CODE (TREE_OPERAND (bbody, 1)) == NEW_ARRAY_INIT
10807 && flag_emit_class_files)
10808 return 1;
10809
10810 /* There are a few cases where we're required to keep
10811 <clinit>:
10812 - If this is an assignment whose operand is not constant,
10813 - If this is an assignment to a non-initialized field,
10814 - If this field is not a member of the current class.
10815 */
10816 return (! TREE_CONSTANT (TREE_OPERAND (bbody, 1))
10817 || ! DECL_INITIAL (TREE_OPERAND (bbody, 0))
10818 || DECL_CONTEXT (TREE_OPERAND (bbody, 0)) != this_class);
10819
10820 default:
10821 return 1;
10822 }
10823 return 0;
10824 }
10825
10826
10827 /* See whether we could get rid of <clinit>. Criteria are: all static
10828 final fields have constant initial values and the body of <clinit>
10829 is empty. Return 1 if <clinit> was discarded, 0 otherwise. */
10830
10831 static int
maybe_yank_clinit(tree mdecl)10832 maybe_yank_clinit (tree mdecl)
10833 {
10834 tree type, current;
10835 tree fbody, bbody;
10836
10837 if (!DECL_CLINIT_P (mdecl))
10838 return 0;
10839
10840 /* If the body isn't empty, then we keep <clinit>. Note that if
10841 we're emitting classfiles, this isn't enough not to rule it
10842 out. */
10843 fbody = DECL_FUNCTION_BODY (mdecl);
10844 bbody = BLOCK_EXPR_BODY (fbody);
10845 if (bbody && bbody != error_mark_node)
10846 bbody = BLOCK_EXPR_BODY (bbody);
10847 else
10848 return 0;
10849 if (bbody && ! flag_emit_class_files && bbody != empty_stmt_node)
10850 return 0;
10851
10852 type = DECL_CONTEXT (mdecl);
10853 current = TYPE_FIELDS (type);
10854
10855 for (current = (current ? TREE_CHAIN (current) : current);
10856 current; current = TREE_CHAIN (current))
10857 {
10858 tree f_init;
10859
10860 /* We're not interested in non-static fields. */
10861 if (!FIELD_STATIC (current))
10862 continue;
10863
10864 /* Nor in fields without initializers. */
10865 f_init = DECL_INITIAL (current);
10866 if (f_init == NULL_TREE)
10867 continue;
10868
10869 /* Anything that isn't String or a basic type is ruled out -- or
10870 if we know how to deal with it (when doing things natively) we
10871 should generated an empty <clinit> so that SUID are computed
10872 correctly. */
10873 if (! JSTRING_TYPE_P (TREE_TYPE (current))
10874 && ! JNUMERIC_TYPE_P (TREE_TYPE (current)))
10875 return 0;
10876
10877 if (! FIELD_FINAL (current) || ! TREE_CONSTANT (f_init))
10878 return 0;
10879 }
10880
10881 /* Now we analyze the method body and look for something that
10882 isn't a MODIFY_EXPR */
10883 if (bbody != empty_stmt_node && analyze_clinit_body (type, bbody))
10884 return 0;
10885
10886 /* Get rid of <clinit> in the class' list of methods */
10887 if (TYPE_METHODS (type) == mdecl)
10888 TYPE_METHODS (type) = TREE_CHAIN (mdecl);
10889 else
10890 for (current = TYPE_METHODS (type); current;
10891 current = TREE_CHAIN (current))
10892 if (TREE_CHAIN (current) == mdecl)
10893 {
10894 TREE_CHAIN (current) = TREE_CHAIN (mdecl);
10895 break;
10896 }
10897
10898 return 1;
10899 }
10900
10901 /* Install the argument from MDECL. Suitable to completion and
10902 expansion of mdecl's body. */
10903
10904 void
start_complete_expand_method(tree mdecl)10905 start_complete_expand_method (tree mdecl)
10906 {
10907 tree tem;
10908
10909 pushlevel (1); /* Prepare for a parameter push */
10910 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
10911 DECL_ARGUMENTS (mdecl) = tem;
10912
10913 for (; tem; tem = TREE_CHAIN (tem))
10914 {
10915 /* TREE_CHAIN (tem) will change after pushdecl. */
10916 tree next = TREE_CHAIN (tem);
10917 tree type = TREE_TYPE (tem);
10918 if (PROMOTE_PROTOTYPES
10919 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
10920 && INTEGRAL_TYPE_P (type))
10921 type = integer_type_node;
10922 DECL_ARG_TYPE (tem) = type;
10923 layout_decl (tem, 0);
10924 pushdecl (tem);
10925 /* Re-install the next so that the list is kept and the loop
10926 advances. */
10927 TREE_CHAIN (tem) = next;
10928 }
10929 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10930 input_line = DECL_SOURCE_LINE (mdecl);
10931 build_result_decl (mdecl);
10932 }
10933
10934
10935 /* Complete and expand a method. */
10936
10937 static void
java_complete_expand_method(tree mdecl)10938 java_complete_expand_method (tree mdecl)
10939 {
10940 tree fbody, block_body, exception_copy;
10941
10942 current_function_decl = mdecl;
10943 /* Fix constructors before expanding them */
10944 if (DECL_CONSTRUCTOR_P (mdecl))
10945 fix_constructors (mdecl);
10946
10947 /* Expand functions that have a body */
10948 if (!DECL_FUNCTION_BODY (mdecl))
10949 return;
10950
10951 fbody = DECL_FUNCTION_BODY (mdecl);
10952 block_body = BLOCK_EXPR_BODY (fbody);
10953 exception_copy = NULL_TREE;
10954
10955 current_function_decl = mdecl;
10956
10957 if (! quiet_flag)
10958 fprintf (stderr, " [%s.",
10959 lang_printable_name (DECL_CONTEXT (mdecl), 0));
10960 announce_function (mdecl);
10961 if (! quiet_flag)
10962 fprintf (stderr, "]");
10963
10964 /* Prepare the function for tree completion */
10965 start_complete_expand_method (mdecl);
10966
10967 /* Install the current this */
10968 current_this = (!METHOD_STATIC (mdecl) ?
10969 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10970
10971 /* Purge the `throws' list of unchecked exceptions (we save a copy
10972 of the list and re-install it later.) */
10973 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10974 purge_unchecked_exceptions (mdecl);
10975
10976 /* Install exceptions thrown with `throws' */
10977 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10978
10979 if (block_body != NULL_TREE)
10980 {
10981 block_body = java_complete_tree (block_body);
10982
10983 /* Before we check initialization, attached all class initialization
10984 variable to the block_body */
10985 htab_traverse (DECL_FUNCTION_INIT_TEST_TABLE (mdecl),
10986 attach_init_test_initialization_flags, block_body);
10987
10988 if (! flag_emit_xref && ! METHOD_NATIVE (mdecl))
10989 {
10990 check_for_initialization (block_body, mdecl);
10991
10992 /* Go through all the flags marking the initialization of
10993 static variables and see whether they're definitively
10994 assigned, in which case the type is remembered as
10995 definitively initialized in MDECL. */
10996 if (STATIC_CLASS_INIT_OPT_P ())
10997 {
10998 /* Always register the context as properly initialized in
10999 MDECL. This used with caution helps removing extra
11000 initialization of self. */
11001 if (METHOD_STATIC (mdecl))
11002 {
11003 *(htab_find_slot
11004 (DECL_FUNCTION_INITIALIZED_CLASS_TABLE (mdecl),
11005 DECL_CONTEXT (mdecl), INSERT)) = DECL_CONTEXT (mdecl);
11006 }
11007 }
11008 }
11009 ctxp->explicit_constructor_p = 0;
11010 }
11011
11012 BLOCK_EXPR_BODY (fbody) = block_body;
11013
11014 /* If we saw a return but couldn't evaluate it properly, we'll have
11015 an error_mark_node here. */
11016 if (block_body != error_mark_node
11017 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
11018 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
11019 && !flag_emit_xref)
11020 missing_return_error (current_function_decl);
11021
11022 /* See if we can get rid of <clinit> if MDECL happens to be <clinit> */
11023 maybe_yank_clinit (mdecl);
11024
11025 /* Pop the current level, with special measures if we found errors. */
11026 if (java_error_count)
11027 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
11028 poplevel (1, 0, 1);
11029
11030 /* Pop the exceptions and sanity check */
11031 POP_EXCEPTIONS();
11032 if (currently_caught_type_list)
11033 abort ();
11034
11035 /* Restore the copy of the list of exceptions if emitting xrefs. */
11036 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
11037 }
11038
11039 /* For with each class for which there's code to generate. */
11040
11041 static void
java_expand_method_bodies(tree class)11042 java_expand_method_bodies (tree class)
11043 {
11044 tree decl;
11045 for (decl = TYPE_METHODS (class); decl; decl = TREE_CHAIN (decl))
11046 {
11047 tree block;
11048 tree body;
11049
11050 if (! DECL_FUNCTION_BODY (decl))
11051 continue;
11052
11053 current_function_decl = decl;
11054
11055 block = BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (decl));
11056
11057 if (TREE_CODE (block) != BLOCK)
11058 abort ();
11059
11060 /* Save the function body for inlining. */
11061 DECL_SAVED_TREE (decl) = block;
11062
11063 body = BLOCK_EXPR_BODY (block);
11064
11065 if (TREE_TYPE (body) == NULL_TREE)
11066 abort ();
11067
11068 /* It's time to assign the variable flagging static class
11069 initialization based on which classes invoked static methods
11070 are definitely initializing. This should be flagged. */
11071 if (STATIC_CLASS_INIT_OPT_P ())
11072 {
11073 tree list = DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (decl);
11074 for (; list != NULL_TREE; list = TREE_CHAIN (list))
11075 {
11076 /* Executed for each statement calling a static function.
11077 LIST is a TREE_LIST whose PURPOSE is the called function
11078 and VALUE is a compound whose second operand can be patched
11079 with static class initialization flag assignments. */
11080
11081 tree called_method = TREE_PURPOSE (list);
11082 tree compound = TREE_VALUE (list);
11083 tree assignment_compound_list
11084 = build_tree_list (called_method, NULL);
11085
11086 /* For each class definitely initialized in
11087 CALLED_METHOD, fill ASSIGNMENT_COMPOUND with
11088 assignment to the class initialization flag. */
11089 htab_traverse (DECL_FUNCTION_INITIALIZED_CLASS_TABLE (called_method),
11090 emit_test_initialization,
11091 assignment_compound_list);
11092
11093 if (TREE_VALUE (assignment_compound_list))
11094 TREE_OPERAND (compound, 1)
11095 = TREE_VALUE (assignment_compound_list);
11096 }
11097 }
11098
11099 /* Prepend class initialization to static methods. */
11100 if (METHOD_STATIC (decl) && ! METHOD_PRIVATE (decl)
11101 && ! flag_emit_class_files
11102 && ! DECL_CLINIT_P (decl)
11103 && ! CLASS_INTERFACE (TYPE_NAME (class)))
11104 {
11105 tree init = build (CALL_EXPR, void_type_node,
11106 build_address_of (soft_initclass_node),
11107 build_tree_list (NULL_TREE,
11108 build_class_ref (class)),
11109 NULL_TREE);
11110 TREE_SIDE_EFFECTS (init) = 1;
11111 body = build (COMPOUND_EXPR, TREE_TYPE (body), init, body);
11112 BLOCK_EXPR_BODY (block) = body;
11113 }
11114
11115 /* Wrap synchronized method bodies in a monitorenter
11116 plus monitorexit cleanup. */
11117 if (METHOD_SYNCHRONIZED (decl) && ! flag_emit_class_files)
11118 {
11119 tree enter, exit, lock;
11120 if (METHOD_STATIC (decl))
11121 lock = build_class_ref (class);
11122 else
11123 lock = DECL_ARGUMENTS (decl);
11124 BUILD_MONITOR_ENTER (enter, lock);
11125 BUILD_MONITOR_EXIT (exit, lock);
11126
11127 body = build (COMPOUND_EXPR, void_type_node,
11128 enter,
11129 build (TRY_FINALLY_EXPR, void_type_node, body, exit));
11130 BLOCK_EXPR_BODY (block) = body;
11131 }
11132
11133 /* Expand the the function body. */
11134 source_end_java_method ();
11135 }
11136 }
11137
11138
11139
11140 /* This section of the code deals with accessing enclosing context
11141 fields either directly by using the relevant access to this$<n> or
11142 by invoking an access method crafted for that purpose. */
11143
11144 /* Build the necessary access from an inner class to an outer
11145 class. This routine could be optimized to cache previous result
11146 (decl, current_class and returned access). When an access method
11147 needs to be generated, it always takes the form of a read. It might
11148 be later turned into a write by calling outer_field_access_fix. */
11149
11150 static tree
build_outer_field_access(tree id,tree decl)11151 build_outer_field_access (tree id, tree decl)
11152 {
11153 tree access = NULL_TREE;
11154 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
11155 tree decl_ctx = DECL_CONTEXT (decl);
11156
11157 /* If the immediate enclosing context of the current class is the
11158 field decl's class or inherits from it; build the access as
11159 `this$<n>.<field>'. Note that we will break the `private' barrier
11160 if we're not emitting bytecodes. */
11161 if ((ctx == decl_ctx || inherits_from_p (ctx, decl_ctx))
11162 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
11163 {
11164 tree thisn = build_current_thisn (current_class);
11165 access = make_qualified_primary (build_wfl_node (thisn),
11166 id, EXPR_WFL_LINECOL (id));
11167 }
11168 /* Otherwise, generate access methods to outer this and access the
11169 field (either using an access method or by direct access.) */
11170 else
11171 {
11172 int lc = EXPR_WFL_LINECOL (id);
11173
11174 /* Now we chain the required number of calls to the access$0 to
11175 get a hold to the enclosing instance we need, and then we
11176 build the field access. */
11177 access = build_access_to_thisn (current_class, decl_ctx, lc);
11178
11179 /* If the field is private and we're generating bytecode, then
11180 we generate an access method */
11181 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
11182 {
11183 tree name = build_outer_field_access_methods (decl);
11184 access = build_outer_field_access_expr (lc, decl_ctx,
11185 name, access, NULL_TREE);
11186 }
11187 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
11188 Once again we break the `private' access rule from a foreign
11189 class. */
11190 else
11191 access = make_qualified_primary (access, id, lc);
11192 }
11193 return resolve_expression_name (access, NULL);
11194 }
11195
11196 /* Return a nonzero value if NODE describes an outer field inner
11197 access. */
11198
11199 static int
outer_field_access_p(tree type,tree decl)11200 outer_field_access_p (tree type, tree decl)
11201 {
11202 if (!INNER_CLASS_TYPE_P (type)
11203 || TREE_CODE (decl) != FIELD_DECL
11204 || DECL_CONTEXT (decl) == type)
11205 return 0;
11206
11207 /* If the inner class extends the declaration context of the field
11208 we're trying to access, then this isn't an outer field access */
11209 if (inherits_from_p (type, DECL_CONTEXT (decl)))
11210 return 0;
11211
11212 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
11213 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
11214 {
11215 if (type == DECL_CONTEXT (decl))
11216 return 1;
11217
11218 if (!DECL_CONTEXT (TYPE_NAME (type)))
11219 {
11220 /* Before we give up, see whether the field is inherited from
11221 the enclosing context we're considering. */
11222 if (inherits_from_p (type, DECL_CONTEXT (decl)))
11223 return 1;
11224 break;
11225 }
11226 }
11227
11228 return 0;
11229 }
11230
11231 /* Return a nonzero value if NODE represents an outer field inner
11232 access that was been already expanded. As a side effect, it returns
11233 the name of the field being accessed and the argument passed to the
11234 access function, suitable for a regeneration of the access method
11235 call if necessary. */
11236
11237 static int
outer_field_expanded_access_p(tree node,tree * name,tree * arg_type,tree * arg)11238 outer_field_expanded_access_p (tree node, tree *name, tree *arg_type,
11239 tree *arg)
11240 {
11241 int identified = 0;
11242
11243 if (TREE_CODE (node) != CALL_EXPR)
11244 return 0;
11245
11246 /* Well, gcj generates slightly different tree nodes when compiling
11247 to native or bytecodes. It's the case for function calls. */
11248
11249 if (flag_emit_class_files
11250 && TREE_CODE (node) == CALL_EXPR
11251 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
11252 identified = 1;
11253 else if (!flag_emit_class_files)
11254 {
11255 node = TREE_OPERAND (node, 0);
11256
11257 if (node && TREE_OPERAND (node, 0)
11258 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
11259 {
11260 node = TREE_OPERAND (node, 0);
11261 if (TREE_OPERAND (node, 0)
11262 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
11263 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
11264 (DECL_NAME (TREE_OPERAND (node, 0)))))
11265 identified = 1;
11266 }
11267 }
11268
11269 if (identified && name && arg_type && arg)
11270 {
11271 tree argument = TREE_OPERAND (node, 1);
11272 *name = DECL_NAME (TREE_OPERAND (node, 0));
11273 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
11274 *arg = TREE_VALUE (argument);
11275 }
11276 return identified;
11277 }
11278
11279 /* Detect in NODE an outer field read access from an inner class and
11280 transform it into a write with RHS as an argument. This function is
11281 called from the java_complete_lhs when an assignment to a LHS can
11282 be identified. */
11283
11284 static tree
outer_field_access_fix(tree wfl,tree node,tree rhs)11285 outer_field_access_fix (tree wfl, tree node, tree rhs)
11286 {
11287 tree name, arg_type, arg;
11288
11289 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
11290 {
11291 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
11292 arg_type, name, arg, rhs);
11293 return java_complete_tree (node);
11294 }
11295 return NULL_TREE;
11296 }
11297
11298 /* Construct the expression that calls an access method:
11299 <type>.access$<n>(<arg1> [, <arg2>]);
11300
11301 ARG2 can be NULL and will be omitted in that case. It will denote a
11302 read access. */
11303
11304 static tree
build_outer_field_access_expr(int lc,tree type,tree access_method_name,tree arg1,tree arg2)11305 build_outer_field_access_expr (int lc, tree type, tree access_method_name,
11306 tree arg1, tree arg2)
11307 {
11308 tree args, cn, access;
11309
11310 args = arg1 ? arg1 :
11311 build_wfl_node (build_current_thisn (current_class));
11312 args = build_tree_list (NULL_TREE, args);
11313
11314 if (arg2)
11315 args = tree_cons (NULL_TREE, arg2, args);
11316
11317 access = build_method_invocation (build_wfl_node (access_method_name), args);
11318 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
11319 return make_qualified_primary (cn, access, lc);
11320 }
11321
11322 static tree
build_new_access_id(void)11323 build_new_access_id (void)
11324 {
11325 static int access_n_counter = 1;
11326 char buffer [128];
11327
11328 sprintf (buffer, "access$%d", access_n_counter++);
11329 return get_identifier (buffer);
11330 }
11331
11332 /* Create the static access functions for the outer field DECL. We define a
11333 read:
11334 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
11335 return inst$.field;
11336 }
11337 and a write access:
11338 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
11339 TREE_TYPE (<field>) value$) {
11340 return inst$.field = value$;
11341 }
11342 We should have a usage flags on the DECL so we can lazily turn the ones
11343 we're using for code generation. FIXME.
11344 */
11345
11346 static tree
build_outer_field_access_methods(tree decl)11347 build_outer_field_access_methods (tree decl)
11348 {
11349 tree id, args, stmt, mdecl;
11350
11351 if (FIELD_INNER_ACCESS_P (decl))
11352 return FIELD_INNER_ACCESS (decl);
11353
11354 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
11355
11356 /* Create the identifier and a function named after it. */
11357 id = build_new_access_id ();
11358
11359 /* The identifier is marked as bearing the name of a generated write
11360 access function for outer field accessed from inner classes. */
11361 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
11362
11363 /* Create the read access */
11364 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
11365 TREE_CHAIN (args) = end_params_node;
11366 stmt = make_qualified_primary (build_wfl_node (inst_id),
11367 build_wfl_node (DECL_NAME (decl)), 0);
11368 stmt = build_return (0, stmt);
11369 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
11370 TREE_TYPE (decl), id, args, stmt);
11371 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
11372
11373 /* Create the write access method. No write access for final variable */
11374 if (!FIELD_FINAL (decl))
11375 {
11376 args = build_tree_list (inst_id,
11377 build_pointer_type (DECL_CONTEXT (decl)));
11378 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
11379 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
11380 stmt = make_qualified_primary (build_wfl_node (inst_id),
11381 build_wfl_node (DECL_NAME (decl)), 0);
11382 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
11383 build_wfl_node (wpv_id)));
11384 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
11385 TREE_TYPE (decl), id,
11386 args, stmt);
11387 }
11388 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
11389
11390 /* Return the access name */
11391 return FIELD_INNER_ACCESS (decl) = id;
11392 }
11393
11394 /* Build an field access method NAME. */
11395
11396 static tree
build_outer_field_access_method(tree class,tree type,tree name,tree args,tree body)11397 build_outer_field_access_method (tree class, tree type, tree name,
11398 tree args, tree body)
11399 {
11400 tree saved_current_function_decl, mdecl;
11401
11402 /* Create the method */
11403 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
11404 fix_method_argument_names (args, mdecl);
11405 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
11406
11407 /* Attach the method body. */
11408 saved_current_function_decl = current_function_decl;
11409 start_artificial_method_body (mdecl);
11410 java_method_add_stmt (mdecl, body);
11411 end_artificial_method_body (mdecl);
11412 current_function_decl = saved_current_function_decl;
11413
11414 return mdecl;
11415 }
11416
11417
11418 /* This section deals with building access function necessary for
11419 certain kinds of method invocation from inner classes. */
11420
11421 static tree
build_outer_method_access_method(tree decl)11422 build_outer_method_access_method (tree decl)
11423 {
11424 tree saved_current_function_decl, mdecl;
11425 tree args = NULL_TREE, call_args = NULL_TREE;
11426 tree carg, id, body, class;
11427 char buffer [80];
11428 int parm_id_count = 0;
11429
11430 /* Test this abort with an access to a private field */
11431 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
11432 abort ();
11433
11434 /* Check the cache first */
11435 if (DECL_FUNCTION_INNER_ACCESS (decl))
11436 return DECL_FUNCTION_INNER_ACCESS (decl);
11437
11438 class = DECL_CONTEXT (decl);
11439
11440 /* Obtain an access identifier and mark it */
11441 id = build_new_access_id ();
11442 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
11443
11444 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
11445 /* Create the arguments, as much as the original */
11446 for (; carg && carg != end_params_node;
11447 carg = TREE_CHAIN (carg))
11448 {
11449 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
11450 args = chainon (args, build_tree_list (get_identifier (buffer),
11451 TREE_VALUE (carg)));
11452 }
11453 args = chainon (args, end_params_node);
11454
11455 /* Create the method */
11456 mdecl = create_artificial_method (class, ACC_STATIC,
11457 TREE_TYPE (TREE_TYPE (decl)), id, args);
11458 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
11459 /* There is a potential bug here. We should be able to use
11460 fix_method_argument_names, but then arg names get mixed up and
11461 eventually a constructor will have its this$0 altered and the
11462 outer context won't be assignment properly. The testcase is
11463 stub.java FIXME */
11464 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
11465
11466 /* Attach the method body. */
11467 saved_current_function_decl = current_function_decl;
11468 start_artificial_method_body (mdecl);
11469
11470 /* The actual method invocation uses the same args. When invoking a
11471 static methods that way, we don't want to skip the first
11472 argument. */
11473 carg = args;
11474 if (!METHOD_STATIC (decl))
11475 carg = TREE_CHAIN (carg);
11476 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
11477 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
11478 call_args);
11479
11480 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
11481 call_args);
11482 if (!METHOD_STATIC (decl))
11483 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
11484 body, 0);
11485 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
11486 body = build_return (0, body);
11487 java_method_add_stmt (mdecl,body);
11488 end_artificial_method_body (mdecl);
11489 current_function_decl = saved_current_function_decl;
11490
11491 /* Back tag the access function so it know what it accesses */
11492 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
11493
11494 /* Tag the current method so it knows it has an access generated */
11495 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
11496 }
11497
11498
11499 /* This section of the code deals with building expressions to access
11500 the enclosing instance of an inner class. The enclosing instance is
11501 kept in a generated field called this$<n>, with <n> being the
11502 inner class nesting level (starting from 0.) */
11503
11504 /* Build an access to a given this$<n>, always chaining access call to
11505 others. Access methods to this$<n> are build on the fly if
11506 necessary. This CAN'T be used to solely access this$<n-1> from
11507 this$<n> (which alway yield to special cases and optimization, see
11508 for example build_outer_field_access). */
11509
11510 static tree
build_access_to_thisn(tree from,tree to,int lc)11511 build_access_to_thisn (tree from, tree to, int lc)
11512 {
11513 tree access = NULL_TREE;
11514
11515 while (from != to && PURE_INNER_CLASS_TYPE_P (from))
11516 {
11517 if (!access)
11518 {
11519 access = build_current_thisn (from);
11520 access = build_wfl_node (access);
11521 }
11522 else
11523 {
11524 tree access0_wfl, cn;
11525
11526 maybe_build_thisn_access_method (from);
11527 access0_wfl = build_wfl_node (access0_identifier_node);
11528 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
11529 EXPR_WFL_LINECOL (access0_wfl) = lc;
11530 access = build_tree_list (NULL_TREE, access);
11531 access = build_method_invocation (access0_wfl, access);
11532 access = make_qualified_primary (cn, access, lc);
11533 }
11534
11535 /* If FROM isn't an inner class, that's fine, we've done enough.
11536 What we're looking for can be accessed from there. */
11537 from = DECL_CONTEXT (TYPE_NAME (from));
11538 if (!from)
11539 break;
11540 from = TREE_TYPE (from);
11541 }
11542 return access;
11543 }
11544
11545 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
11546 is returned if nothing needs to be generated. Otherwise, the method
11547 generated and a method decl is returned.
11548
11549 NOTE: These generated methods should be declared in a class file
11550 attribute so that they can't be referred to directly. */
11551
11552 static tree
maybe_build_thisn_access_method(tree type)11553 maybe_build_thisn_access_method (tree type)
11554 {
11555 tree mdecl, args, stmt, rtype;
11556 tree saved_current_function_decl;
11557
11558 /* If TYPE is a top-level class, no access method is required.
11559 If there already is such an access method, bail out. */
11560 if (CLASS_ACCESS0_GENERATED_P (type) || !PURE_INNER_CLASS_TYPE_P (type))
11561 return NULL_TREE;
11562
11563 /* We generate the method. The method looks like:
11564 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
11565 */
11566 args = build_tree_list (inst_id, build_pointer_type (type));
11567 TREE_CHAIN (args) = end_params_node;
11568 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
11569 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
11570 access0_identifier_node, args);
11571 fix_method_argument_names (args, mdecl);
11572 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
11573 stmt = build_current_thisn (type);
11574 stmt = make_qualified_primary (build_wfl_node (inst_id),
11575 build_wfl_node (stmt), 0);
11576 stmt = build_return (0, stmt);
11577
11578 saved_current_function_decl = current_function_decl;
11579 start_artificial_method_body (mdecl);
11580 java_method_add_stmt (mdecl, stmt);
11581 end_artificial_method_body (mdecl);
11582 current_function_decl = saved_current_function_decl;
11583
11584 CLASS_ACCESS0_GENERATED_P (type) = 1;
11585
11586 return mdecl;
11587 }
11588
11589 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
11590 the first level of innerclassing. this$1 for the next one, etc...
11591 This function can be invoked with TYPE to NULL, available and then
11592 has to count the parser context. */
11593
11594 static GTY(()) tree saved_thisn;
11595 static GTY(()) tree saved_type;
11596
11597 static tree
build_current_thisn(tree type)11598 build_current_thisn (tree type)
11599 {
11600 static int saved_i = -1;
11601 static int saved_type_i = 0;
11602 tree decl;
11603 char buffer [24];
11604 int i = 0;
11605
11606 if (type)
11607 {
11608 if (type == saved_type)
11609 i = saved_type_i;
11610 else
11611 {
11612 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
11613 decl; decl = DECL_CONTEXT (decl), i++)
11614 ;
11615
11616 saved_type = type;
11617 saved_type_i = i;
11618 }
11619 }
11620 else
11621 i = list_length (GET_CPC_LIST ())-2;
11622
11623 if (i == saved_i)
11624 return saved_thisn;
11625
11626 sprintf (buffer, "this$%d", i);
11627 saved_i = i;
11628 saved_thisn = get_identifier (buffer);
11629 return saved_thisn;
11630 }
11631
11632 /* Return the assignment to the hidden enclosing context `this$<n>'
11633 by the second incoming parameter to the innerclass constructor. The
11634 form used is `this.this$<n> = this$<n>;'. */
11635
11636 static tree
build_thisn_assign(void)11637 build_thisn_assign (void)
11638 {
11639 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
11640 {
11641 tree thisn = build_current_thisn (current_class);
11642 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
11643 build_wfl_node (thisn), 0);
11644 tree rhs = build_wfl_node (thisn);
11645 EXPR_WFL_SET_LINECOL (lhs, input_line, 0);
11646 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
11647 }
11648 return NULL_TREE;
11649 }
11650
11651
11652 /* Building the synthetic `class$' used to implement the `.class' 1.1
11653 extension for non primitive types. This method looks like:
11654
11655 static Class class$(String type) throws NoClassDefFoundError
11656 {
11657 try {return (java.lang.Class.forName (String));}
11658 catch (ClassNotFoundException e) {
11659 throw new NoClassDefFoundError(e.getMessage());}
11660 } */
11661
11662 static GTY(()) tree get_message_wfl;
11663 static GTY(()) tree type_parm_wfl;
11664
11665 static tree
build_dot_class_method(tree class)11666 build_dot_class_method (tree class)
11667 {
11668 #define BWF(S) build_wfl_node (get_identifier ((S)))
11669 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
11670 tree args, tmp, saved_current_function_decl, mdecl, qual_name;
11671 tree stmt, throw_stmt;
11672
11673 if (!get_message_wfl)
11674 {
11675 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
11676 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
11677 }
11678
11679 /* Build the arguments */
11680 args = build_tree_list (get_identifier ("type$"),
11681 build_pointer_type (string_type_node));
11682 TREE_CHAIN (args) = end_params_node;
11683
11684 /* Build the qualified name java.lang.Class.forName */
11685 tmp = MQN (MQN (MQN (BWF ("java"),
11686 BWF ("lang")), BWF ("Class")), BWF ("forName"));
11687
11688 /* Create the "class$" function */
11689 mdecl = create_artificial_method (class, ACC_STATIC,
11690 build_pointer_type (class_type_node),
11691 classdollar_identifier_node, args);
11692 qual_name = MQN (MQN (BWF ("java"), BWF ("lang")),
11693 BWF ("NoClassDefFoundError"));
11694 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE, qual_name);
11695 register_incomplete_type (JDEP_EXCEPTION, qual_name, NULL_TREE, NULL_TREE);
11696 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
11697 &TREE_VALUE (DECL_FUNCTION_THROWS (mdecl));
11698
11699 /* We start by building the try block. We need to build:
11700 return (java.lang.Class.forName (type)); */
11701 stmt = build_method_invocation (tmp,
11702 build_tree_list (NULL_TREE, type_parm_wfl));
11703 stmt = build_return (0, stmt);
11704
11705 /* Now onto the catch block. We start by building the expression
11706 throwing a new exception: throw new NoClassDefFoundError (_.getMessage) */
11707 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
11708 get_message_wfl, 0);
11709 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
11710
11711 /* Build new NoClassDefFoundError (_.getMessage) */
11712 throw_stmt = build_new_invocation
11713 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
11714 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
11715
11716 /* Build the throw, (it's too early to use BUILD_THROW) */
11717 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
11718
11719 /* Encapsulate STMT in a try block. The catch clause executes THROW_STMT */
11720 qual_name = MQN (MQN (BWF ("java"), BWF ("lang")),
11721 BWF ("ClassNotFoundException"));
11722 stmt = encapsulate_with_try_catch (0, qual_name, stmt, throw_stmt);
11723
11724 fix_method_argument_names (args, mdecl);
11725 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
11726 saved_current_function_decl = current_function_decl;
11727 start_artificial_method_body (mdecl);
11728 java_method_add_stmt (mdecl, stmt);
11729 end_artificial_method_body (mdecl);
11730 current_function_decl = saved_current_function_decl;
11731 TYPE_DOT_CLASS (class) = mdecl;
11732
11733 return mdecl;
11734 }
11735
11736 static tree
build_dot_class_method_invocation(tree this_class,tree type)11737 build_dot_class_method_invocation (tree this_class, tree type)
11738 {
11739 tree dot_class_method = TYPE_DOT_CLASS (this_class);
11740 tree sig_id, s, t;
11741
11742 if (TYPE_ARRAY_P (type))
11743 sig_id = build_java_signature (type);
11744 else
11745 sig_id = DECL_NAME (TYPE_NAME (type));
11746
11747 /* Ensure that the proper name separator is used */
11748 sig_id = unmangle_classname (IDENTIFIER_POINTER (sig_id),
11749 IDENTIFIER_LENGTH (sig_id));
11750
11751 s = build_string (IDENTIFIER_LENGTH (sig_id),
11752 IDENTIFIER_POINTER (sig_id));
11753 t = build_method_invocation (build_wfl_node (DECL_NAME (dot_class_method)),
11754 build_tree_list (NULL_TREE, s));
11755 if (DECL_CONTEXT (dot_class_method) != this_class)
11756 {
11757 tree class_name = DECL_NAME (TYPE_NAME (DECL_CONTEXT (dot_class_method)));
11758 t = make_qualified_primary (build_wfl_node (class_name), t, 0);
11759 }
11760 return t;
11761 }
11762
11763 /* This section of the code deals with constructor. */
11764
11765 /* Craft a body for default constructor. Patch existing constructor
11766 bodies with call to super() and field initialization statements if
11767 necessary. */
11768
11769 static void
fix_constructors(tree mdecl)11770 fix_constructors (tree mdecl)
11771 {
11772 tree iii; /* Instance Initializer Invocation */
11773 tree body = DECL_FUNCTION_BODY (mdecl);
11774 tree thisn_assign, compound = NULL_TREE;
11775 tree class_type = DECL_CONTEXT (mdecl);
11776
11777 if (DECL_FIXED_CONSTRUCTOR_P (mdecl))
11778 return;
11779 DECL_FIXED_CONSTRUCTOR_P (mdecl) = 1;
11780
11781 if (!body)
11782 {
11783 /* It is an error for the compiler to generate a default
11784 constructor if the superclass doesn't have a constructor that
11785 takes no argument, or the same args for an anonymous class */
11786 if (verify_constructor_super (mdecl))
11787 {
11788 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
11789 tree save = DECL_NAME (mdecl);
11790 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
11791 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
11792 parse_error_context
11793 (lookup_cl (TYPE_NAME (class_type)),
11794 "No constructor matching `%s' found in class `%s'",
11795 lang_printable_name (mdecl, 0), n);
11796 DECL_NAME (mdecl) = save;
11797 }
11798
11799 /* The constructor body must be crafted by hand. It's the
11800 constructor we defined when we realize we didn't have the
11801 CLASSNAME() constructor */
11802 start_artificial_method_body (mdecl);
11803
11804 /* Insert an assignment to the this$<n> hidden field, if
11805 necessary */
11806 if ((thisn_assign = build_thisn_assign ()))
11807 java_method_add_stmt (mdecl, thisn_assign);
11808
11809 /* We don't generate a super constructor invocation if we're
11810 compiling java.lang.Object. build_super_invocation takes care
11811 of that. */
11812 java_method_add_stmt (mdecl, build_super_invocation (mdecl));
11813
11814 /* FIXME */
11815 if ((iii = build_instinit_invocation (class_type)))
11816 java_method_add_stmt (mdecl, iii);
11817
11818 end_artificial_method_body (mdecl);
11819 }
11820 /* Search for an explicit constructor invocation */
11821 else
11822 {
11823 int found = 0;
11824 int invokes_this = 0;
11825 tree found_call = NULL_TREE;
11826 tree main_block = BLOCK_EXPR_BODY (body);
11827
11828 while (body)
11829 switch (TREE_CODE (body))
11830 {
11831 case CALL_EXPR:
11832 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
11833 if (CALL_THIS_CONSTRUCTOR_P (body))
11834 invokes_this = 1;
11835 body = NULL_TREE;
11836 break;
11837 case COMPOUND_EXPR:
11838 case EXPR_WITH_FILE_LOCATION:
11839 found_call = body;
11840 body = TREE_OPERAND (body, 0);
11841 break;
11842 case BLOCK:
11843 found_call = body;
11844 body = BLOCK_EXPR_BODY (body);
11845 break;
11846 default:
11847 found = 0;
11848 body = NULL_TREE;
11849 }
11850
11851 /* Generate the assignment to this$<n>, if necessary */
11852 if ((thisn_assign = build_thisn_assign ()))
11853 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
11854
11855 /* The constructor is missing an invocation of super() */
11856 if (!found)
11857 compound = add_stmt_to_compound (compound, NULL_TREE,
11858 build_super_invocation (mdecl));
11859 /* Explicit super() invocation should take place before the
11860 instance initializer blocks. */
11861 else
11862 {
11863 compound = add_stmt_to_compound (compound, NULL_TREE,
11864 TREE_OPERAND (found_call, 0));
11865 TREE_OPERAND (found_call, 0) = empty_stmt_node;
11866 }
11867
11868 DECL_INIT_CALLS_THIS (mdecl) = invokes_this;
11869
11870 /* Insert the instance initializer block right after. */
11871 if (!invokes_this && (iii = build_instinit_invocation (class_type)))
11872 compound = add_stmt_to_compound (compound, NULL_TREE, iii);
11873
11874 /* Fix the constructor main block if we're adding extra stmts */
11875 if (compound)
11876 {
11877 compound = add_stmt_to_compound (compound, NULL_TREE,
11878 BLOCK_EXPR_BODY (main_block));
11879 BLOCK_EXPR_BODY (main_block) = compound;
11880 }
11881 }
11882 }
11883
11884 /* Browse constructors in the super class, searching for a constructor
11885 that doesn't take any argument. Return 0 if one is found, 1
11886 otherwise. If the current class is an anonymous inner class, look
11887 for something that has the same signature. */
11888
11889 static int
verify_constructor_super(tree mdecl)11890 verify_constructor_super (tree mdecl)
11891 {
11892 tree class = CLASSTYPE_SUPER (current_class);
11893 int super_inner = PURE_INNER_CLASS_TYPE_P (class);
11894 tree sdecl;
11895
11896 if (!class)
11897 return 0;
11898
11899 if (ANONYMOUS_CLASS_P (current_class))
11900 {
11901 tree mdecl_arg_type;
11902 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
11903 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11904 if (DECL_CONSTRUCTOR_P (sdecl))
11905 {
11906 tree m_arg_type;
11907 tree arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11908 if (super_inner)
11909 arg_type = TREE_CHAIN (arg_type);
11910 for (m_arg_type = mdecl_arg_type;
11911 (arg_type != end_params_node
11912 && m_arg_type != end_params_node);
11913 arg_type = TREE_CHAIN (arg_type),
11914 m_arg_type = TREE_CHAIN (m_arg_type))
11915 if (!valid_method_invocation_conversion_p
11916 (TREE_VALUE (arg_type),
11917 TREE_VALUE (m_arg_type)))
11918 break;
11919
11920 if (arg_type == end_params_node && m_arg_type == end_params_node)
11921 return 0;
11922 }
11923 }
11924 else
11925 {
11926 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
11927 {
11928 tree arg = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
11929 if (super_inner)
11930 arg = TREE_CHAIN (arg);
11931 if (DECL_CONSTRUCTOR_P (sdecl) && arg == end_params_node)
11932 return 0;
11933 }
11934 }
11935 return 1;
11936 }
11937
11938 /* Generate code for all context remembered for code generation. */
11939
11940 static GTY(()) tree reversed_class_list;
11941 void
java_expand_classes(void)11942 java_expand_classes (void)
11943 {
11944 int save_error_count = 0;
11945 static struct parser_ctxt *cur_ctxp = NULL;
11946
11947 java_parse_abort_on_error ();
11948 if (!(ctxp = ctxp_for_generation))
11949 return;
11950 java_layout_classes ();
11951 java_parse_abort_on_error ();
11952
11953 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
11954 {
11955 tree current;
11956 for (current = cur_ctxp->class_list;
11957 current;
11958 current = TREE_CHAIN (current))
11959 gen_indirect_dispatch_tables (TREE_TYPE (current));
11960 }
11961
11962 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
11963 {
11964 ctxp = cur_ctxp;
11965 input_filename = ctxp->filename;
11966 lang_init_source (2); /* Error msgs have method prototypes */
11967 java_complete_expand_classes (); /* Complete and expand classes */
11968 java_parse_abort_on_error ();
11969 }
11970 input_filename = main_input_filename;
11971
11972 /* Find anonymous classes and expand their constructor. This extra pass is
11973 necessary because the constructor itself is only generated when the
11974 method in which it is defined is expanded. */
11975 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
11976 {
11977 tree current;
11978 ctxp = cur_ctxp;
11979 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
11980 {
11981 output_class = current_class = TREE_TYPE (current);
11982 if (ANONYMOUS_CLASS_P (current_class))
11983 {
11984 tree d;
11985 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
11986 {
11987 if (DECL_CONSTRUCTOR_P (d))
11988 {
11989 restore_line_number_status (1);
11990 java_complete_expand_method (d);
11991 restore_line_number_status (0);
11992 break; /* There is only one constructor. */
11993 }
11994 }
11995 }
11996 }
11997 }
11998
11999 /* Expanding the constructors of anonymous classes generates access
12000 methods. Scan all the methods looking for null DECL_RESULTs --
12001 this will be the case if a method hasn't been expanded. */
12002 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
12003 {
12004 tree current;
12005 ctxp = cur_ctxp;
12006 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
12007 {
12008 tree d;
12009 output_class = current_class = TREE_TYPE (current);
12010 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
12011 {
12012 if (DECL_RESULT (d) == NULL_TREE)
12013 {
12014 restore_line_number_status (1);
12015 java_complete_expand_method (d);
12016 restore_line_number_status (0);
12017 }
12018 }
12019 }
12020 }
12021
12022 /* ??? Instead of all this we could iterate around the list of
12023 classes until there were no more un-expanded methods. It would
12024 take a little longer -- one pass over the whole list of methods
12025 -- but it would be simpler. Like this: */
12026 #if 0
12027 {
12028 int something_changed;
12029
12030 do
12031 {
12032 something_changed = 0;
12033 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
12034 {
12035 tree current;
12036 ctxp = cur_ctxp;
12037 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
12038 {
12039 tree d;
12040 output_class = current_class = TREE_TYPE (current);
12041 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
12042 {
12043 if (DECL_RESULT (d) == NULL_TREE)
12044 {
12045 something_changed = 1;
12046 restore_line_number_status (1);
12047 java_complete_expand_method (d);
12048 restore_line_number_status (0);
12049 }
12050 }
12051 }
12052 }
12053 }
12054 while (something_changed);
12055 }
12056 #endif
12057
12058 /* If we've found error at that stage, don't try to generate
12059 anything, unless we're emitting xrefs or checking the syntax only
12060 (but not using -fsyntax-only for the purpose of generating
12061 bytecode. */
12062 if (java_error_count && !flag_emit_xref
12063 && (!flag_syntax_only && !flag_emit_class_files))
12064 return;
12065
12066 /* Now things are stable, go for generation of the class data. */
12067
12068 /* We pessimistically marked all methods and fields external until
12069 we knew what set of classes we were planning to compile. Now mark
12070 those that will be generated locally as not external. */
12071 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
12072 {
12073 tree current;
12074 ctxp = cur_ctxp;
12075 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
12076 java_mark_class_local (TREE_TYPE (current));
12077 }
12078
12079 /* Compile the classes. */
12080 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
12081 {
12082 tree current;
12083 reversed_class_list = NULL;
12084
12085 ctxp = cur_ctxp;
12086
12087 /* We write out the classes in reverse order. This ensures that
12088 inner classes are written before their containing classes,
12089 which is important for parallel builds. Otherwise, the
12090 class file for the outer class may be found, but the class
12091 file for the inner class may not be present. In that
12092 situation, the compiler cannot fall back to the original
12093 source, having already read the outer class, so we must
12094 prevent that situation. */
12095 for (current = ctxp->class_list;
12096 current;
12097 current = TREE_CHAIN (current))
12098 reversed_class_list
12099 = tree_cons (NULL_TREE, current, reversed_class_list);
12100
12101 for (current = reversed_class_list;
12102 current;
12103 current = TREE_CHAIN (current))
12104 {
12105 output_class = current_class = TREE_TYPE (TREE_VALUE (current));
12106 if (flag_emit_class_files)
12107 write_classfile (current_class);
12108 if (flag_emit_xref)
12109 expand_xref (current_class);
12110 else if (! flag_syntax_only)
12111 java_expand_method_bodies (current_class);
12112 }
12113 }
12114 }
12115
12116 void
java_finish_classes(void)12117 java_finish_classes (void)
12118 {
12119 static struct parser_ctxt *cur_ctxp = NULL;
12120 for (cur_ctxp = ctxp_for_generation; cur_ctxp; cur_ctxp = cur_ctxp->next)
12121 {
12122 tree current;
12123 ctxp = cur_ctxp;
12124 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
12125 {
12126 output_class = current_class = TREE_TYPE (current);
12127 finish_class ();
12128 }
12129 }
12130 }
12131
12132 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
12133 a tree list node containing RIGHT. Fore coming RIGHTs will be
12134 chained to this hook. LOCATION contains the location of the
12135 separating `.' operator. */
12136
12137 static tree
make_qualified_primary(tree primary,tree right,int location)12138 make_qualified_primary (tree primary, tree right, int location)
12139 {
12140 tree wfl;
12141
12142 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
12143 wfl = build_wfl_wrap (primary, location);
12144 else
12145 {
12146 wfl = primary;
12147 /* If wfl wasn't qualified, we build a first anchor */
12148 if (!EXPR_WFL_QUALIFICATION (wfl))
12149 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
12150 }
12151
12152 /* And chain them */
12153 EXPR_WFL_LINECOL (right) = location;
12154 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
12155 PRIMARY_P (wfl) = 1;
12156 return wfl;
12157 }
12158
12159 /* Simple merge of two name separated by a `.' */
12160
12161 static tree
merge_qualified_name(tree left,tree right)12162 merge_qualified_name (tree left, tree right)
12163 {
12164 tree node;
12165 if (!left && !right)
12166 return NULL_TREE;
12167
12168 if (!left)
12169 return right;
12170
12171 if (!right)
12172 return left;
12173
12174 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
12175 IDENTIFIER_LENGTH (left));
12176 obstack_1grow (&temporary_obstack, '.');
12177 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
12178 IDENTIFIER_LENGTH (right));
12179 node = get_identifier (obstack_base (&temporary_obstack));
12180 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
12181 QUALIFIED_P (node) = 1;
12182 return node;
12183 }
12184
12185 /* Merge the two parts of a qualified name into LEFT. Set the
12186 location information of the resulting node to LOCATION, usually
12187 inherited from the location information of the `.' operator. */
12188
12189 static tree
make_qualified_name(tree left,tree right,int location)12190 make_qualified_name (tree left, tree right, int location)
12191 {
12192 #ifdef USE_COMPONENT_REF
12193 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
12194 EXPR_WFL_LINECOL (node) = location;
12195 return node;
12196 #else
12197 tree left_id = EXPR_WFL_NODE (left);
12198 tree right_id = EXPR_WFL_NODE (right);
12199 tree wfl, merge;
12200
12201 merge = merge_qualified_name (left_id, right_id);
12202
12203 /* Left wasn't qualified and is now qualified */
12204 if (!QUALIFIED_P (left_id))
12205 {
12206 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
12207 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
12208 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
12209 }
12210
12211 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
12212 EXPR_WFL_LINECOL (wfl) = location;
12213 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
12214
12215 EXPR_WFL_NODE (left) = merge;
12216 return left;
12217 #endif
12218 }
12219
12220 /* Extract the last identifier component of the qualified in WFL. The
12221 last identifier is removed from the linked list */
12222
12223 static tree
cut_identifier_in_qualified(tree wfl)12224 cut_identifier_in_qualified (tree wfl)
12225 {
12226 tree q;
12227 tree previous = NULL_TREE;
12228 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
12229 if (!TREE_CHAIN (q))
12230 {
12231 if (!previous)
12232 /* Operating on a non qualified qualified WFL. */
12233 abort ();
12234
12235 TREE_CHAIN (previous) = NULL_TREE;
12236 return TREE_PURPOSE (q);
12237 }
12238 }
12239
12240 /* Resolve the expression name NAME. Return its decl. */
12241
12242 static tree
resolve_expression_name(tree id,tree * orig)12243 resolve_expression_name (tree id, tree *orig)
12244 {
12245 tree name = EXPR_WFL_NODE (id);
12246 tree decl;
12247
12248 /* 6.5.5.1: Simple expression names */
12249 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
12250 {
12251 /* 15.13.1: NAME can appear within the scope of a local variable
12252 declaration */
12253 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
12254 return decl;
12255
12256 /* 15.13.1: NAME can appear within a class declaration */
12257 else
12258 {
12259 decl = lookup_field_wrapper (current_class, name);
12260 if (decl)
12261 {
12262 tree access = NULL_TREE;
12263 int fs = FIELD_STATIC (decl);
12264
12265 /* If we're accessing an outer scope local alias, make
12266 sure we change the name of the field we're going to
12267 build access to. */
12268 if (FIELD_LOCAL_ALIAS_USED (decl))
12269 name = DECL_NAME (decl);
12270
12271 check_deprecation (id, decl);
12272
12273 /* Instance variable (8.3.1.1) can't appear within
12274 static method, static initializer or initializer for
12275 a static variable. */
12276 if (!fs && METHOD_STATIC (current_function_decl))
12277 {
12278 static_ref_err (id, name, current_class);
12279 return error_mark_node;
12280 }
12281 /* Instance variables can't appear as an argument of
12282 an explicit constructor invocation */
12283 if (!fs && ctxp->explicit_constructor_p
12284 && !enclosing_context_p (DECL_CONTEXT (decl), current_class))
12285 {
12286 parse_error_context
12287 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
12288 return error_mark_node;
12289 }
12290
12291 /* If we're processing an inner class and we're trying
12292 to access a field belonging to an outer class, build
12293 the access to the field */
12294 if (!fs && outer_field_access_p (current_class, decl))
12295 {
12296 if (CLASS_STATIC (TYPE_NAME (current_class)))
12297 {
12298 static_ref_err (id, DECL_NAME (decl), current_class);
12299 return error_mark_node;
12300 }
12301 access = build_outer_field_access (id, decl);
12302 if (orig)
12303 *orig = access;
12304 return access;
12305 }
12306
12307 /* Otherwise build what it takes to access the field */
12308 access = build_field_ref ((fs ? NULL_TREE : current_this),
12309 DECL_CONTEXT (decl), name);
12310 if (fs)
12311 access = maybe_build_class_init_for_field (decl, access);
12312 /* We may be asked to save the real field access node */
12313 if (orig)
12314 *orig = access;
12315 /* Last check: can we access the field? */
12316 if (not_accessible_p (current_class, decl, NULL_TREE, 0))
12317 {
12318 not_accessible_field_error (id, decl);
12319 return error_mark_node;
12320 }
12321 /* And we return what we got */
12322 return access;
12323 }
12324 /* Fall down to error report on undefined variable */
12325 }
12326 }
12327 /* 6.5.5.2 Qualified Expression Names */
12328 else
12329 {
12330 if (orig)
12331 *orig = NULL_TREE;
12332 qualify_ambiguous_name (id);
12333 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
12334 /* 15.10.2: Accessing Superclass Members using super */
12335 return resolve_field_access (id, orig, NULL);
12336 }
12337
12338 /* We've got an error here */
12339 if (INNER_CLASS_TYPE_P (current_class))
12340 parse_error_context (id,
12341 "Local variable `%s' can't be accessed from within the inner class `%s' unless it is declared final",
12342 IDENTIFIER_POINTER (name),
12343 IDENTIFIER_POINTER (DECL_NAME
12344 (TYPE_NAME (current_class))));
12345 else
12346 parse_error_context (id, "Undefined variable `%s'",
12347 IDENTIFIER_POINTER (name));
12348
12349 return error_mark_node;
12350 }
12351
12352 static void
static_ref_err(tree wfl,tree field_id,tree class_type)12353 static_ref_err (tree wfl, tree field_id, tree class_type)
12354 {
12355 parse_error_context
12356 (wfl,
12357 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
12358 IDENTIFIER_POINTER (field_id),
12359 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
12360 }
12361
12362 /* 15.10.1 Field Access Using a Primary and/or Expression Name.
12363 We return something suitable to generate the field access. We also
12364 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
12365 recipient's address can be null. */
12366
12367 static tree
resolve_field_access(tree qual_wfl,tree * field_decl,tree * field_type)12368 resolve_field_access (tree qual_wfl, tree *field_decl, tree *field_type)
12369 {
12370 int is_static = 0;
12371 tree field_ref;
12372 tree decl, where_found, type_found;
12373
12374 if (resolve_qualified_expression_name (qual_wfl, &decl,
12375 &where_found, &type_found))
12376 return error_mark_node;
12377
12378 /* Resolve the LENGTH field of an array here */
12379 if (DECL_P (decl) && DECL_NAME (decl) == length_identifier_node
12380 && type_found && TYPE_ARRAY_P (type_found)
12381 && ! flag_emit_class_files && ! flag_emit_xref)
12382 {
12383 tree length = build_java_array_length_access (where_found);
12384 field_ref = length;
12385
12386 /* In case we're dealing with a static array, we need to
12387 initialize its class before the array length can be fetched.
12388 It's also a good time to create a DECL_RTL for the field if
12389 none already exists, otherwise if the field was declared in a
12390 class found in an external file and hasn't been (and won't
12391 be) accessed for its value, none will be created. */
12392 if (TREE_CODE (where_found) == VAR_DECL && FIELD_STATIC (where_found))
12393 {
12394 build_static_field_ref (where_found);
12395 field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
12396 }
12397 }
12398 /* We might have been trying to resolve field.method(). In which
12399 case, the resolution is over and decl is the answer */
12400 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
12401 field_ref = decl;
12402 else if (JDECL_P (decl))
12403 {
12404 if (!type_found)
12405 type_found = DECL_CONTEXT (decl);
12406 is_static = FIELD_STATIC (decl);
12407 field_ref = build_field_ref ((is_static && !flag_emit_xref?
12408 NULL_TREE : where_found),
12409 type_found, DECL_NAME (decl));
12410 if (field_ref == error_mark_node)
12411 return error_mark_node;
12412 if (is_static)
12413 field_ref = maybe_build_class_init_for_field (decl, field_ref);
12414
12415 /* If we're looking at a static field, we may need to generate a
12416 class initialization for it. This can happen when the access
12417 looks like `field.ref', where `field' is a static field in an
12418 interface we implement. */
12419 if (!flag_emit_class_files
12420 && !flag_emit_xref
12421 && TREE_CODE (where_found) == VAR_DECL
12422 && FIELD_STATIC (where_found))
12423 {
12424 build_static_field_ref (where_found);
12425 field_ref = build_class_init (DECL_CONTEXT (where_found), field_ref);
12426 }
12427 }
12428 else
12429 field_ref = decl;
12430
12431 if (field_decl)
12432 *field_decl = decl;
12433 if (field_type)
12434 *field_type = (QUAL_DECL_TYPE (decl) ?
12435 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
12436 return field_ref;
12437 }
12438
12439 /* If NODE is an access to f static field, strip out the class
12440 initialization part and return the field decl, otherwise, return
12441 NODE. */
12442
12443 static tree
strip_out_static_field_access_decl(tree node)12444 strip_out_static_field_access_decl (tree node)
12445 {
12446 if (TREE_CODE (node) == COMPOUND_EXPR)
12447 {
12448 tree op1 = TREE_OPERAND (node, 1);
12449 if (TREE_CODE (op1) == COMPOUND_EXPR)
12450 {
12451 tree call = TREE_OPERAND (op1, 0);
12452 if (TREE_CODE (call) == CALL_EXPR
12453 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
12454 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
12455 == soft_initclass_node)
12456 return TREE_OPERAND (op1, 1);
12457 }
12458 else if (JDECL_P (op1))
12459 return op1;
12460 }
12461 return node;
12462 }
12463
12464 /* 6.5.5.2: Qualified Expression Names */
12465
12466 static int
resolve_qualified_expression_name(tree wfl,tree * found_decl,tree * where_found,tree * type_found)12467 resolve_qualified_expression_name (tree wfl, tree *found_decl,
12468 tree *where_found, tree *type_found)
12469 {
12470 int from_type = 0; /* Field search initiated from a type */
12471 int from_super = 0, from_cast = 0, from_qualified_this = 0;
12472 int previous_call_static = 0;
12473 int is_static;
12474 tree decl = NULL_TREE, type = NULL_TREE, q;
12475 /* For certain for of inner class instantiation */
12476 tree saved_current, saved_this;
12477 #define RESTORE_THIS_AND_CURRENT_CLASS \
12478 { current_class = saved_current; current_this = saved_this;}
12479
12480 *type_found = *where_found = NULL_TREE;
12481
12482 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
12483 {
12484 tree qual_wfl = QUAL_WFL (q);
12485 tree ret_decl; /* for EH checking */
12486 int location; /* for EH checking */
12487
12488 /* 15.10.1 Field Access Using a Primary */
12489 switch (TREE_CODE (qual_wfl))
12490 {
12491 case CALL_EXPR:
12492 case NEW_CLASS_EXPR:
12493 /* If the access to the function call is a non static field,
12494 build the code to access it. */
12495 if (JDECL_P (decl) && !FIELD_STATIC (decl))
12496 {
12497 decl = maybe_access_field (decl, *where_found,
12498 DECL_CONTEXT (decl));
12499 if (decl == error_mark_node)
12500 return 1;
12501 }
12502
12503 /* And code for the function call */
12504 if (complete_function_arguments (qual_wfl))
12505 return 1;
12506
12507 /* We might have to setup a new current class and a new this
12508 for the search of an inner class, relative to the type of
12509 a expression resolved as `decl'. The current values are
12510 saved and restored shortly after */
12511 saved_current = current_class;
12512 saved_this = current_this;
12513 if (decl
12514 && (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
12515 || from_qualified_this))
12516 {
12517 /* If we still have `from_qualified_this', we have the form
12518 <T>.this.f() and we need to build <T>.this */
12519 if (from_qualified_this)
12520 {
12521 decl = build_access_to_thisn (current_class, type, 0);
12522 decl = java_complete_tree (decl);
12523 type = TREE_TYPE (TREE_TYPE (decl));
12524 }
12525 current_class = type;
12526 current_this = decl;
12527 from_qualified_this = 0;
12528 }
12529
12530 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
12531 CALL_USING_SUPER (qual_wfl) = 1;
12532 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
12533 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
12534 *where_found = patch_method_invocation (qual_wfl, decl, type,
12535 from_super,
12536 &is_static, &ret_decl);
12537 from_super = 0;
12538 if (*where_found == error_mark_node)
12539 {
12540 RESTORE_THIS_AND_CURRENT_CLASS;
12541 return 1;
12542 }
12543 *type_found = type = QUAL_DECL_TYPE (*where_found);
12544
12545 *where_found = force_evaluation_order (*where_found);
12546
12547 /* If we're creating an inner class instance, check for that
12548 an enclosing instance is in scope */
12549 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
12550 && INNER_ENCLOSING_SCOPE_CHECK (type))
12551 {
12552 parse_error_context
12553 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
12554 lang_printable_name (type, 0),
12555 (!current_this ? "" :
12556 "; an explicit one must be provided when creating this inner class"));
12557 RESTORE_THIS_AND_CURRENT_CLASS;
12558 return 1;
12559 }
12560
12561 /* In case we had to change then to resolve a inner class
12562 instantiation using a primary qualified by a `new' */
12563 RESTORE_THIS_AND_CURRENT_CLASS;
12564
12565 if (location)
12566 {
12567 tree arguments = NULL_TREE;
12568 if (TREE_CODE (qual_wfl) == CALL_EXPR
12569 && TREE_OPERAND (qual_wfl, 1) != NULL_TREE)
12570 arguments = TREE_VALUE (TREE_OPERAND (qual_wfl, 1));
12571 check_thrown_exceptions (location, ret_decl, arguments);
12572 }
12573
12574 /* If the previous call was static and this one is too,
12575 build a compound expression to hold the two (because in
12576 that case, previous function calls aren't transported as
12577 forcoming function's argument. */
12578 if (previous_call_static && is_static)
12579 {
12580 decl = build (COMPOUND_EXPR, TREE_TYPE (*where_found),
12581 decl, *where_found);
12582 TREE_SIDE_EFFECTS (decl) = 1;
12583 }
12584 else
12585 {
12586 previous_call_static = is_static;
12587 decl = *where_found;
12588 }
12589 from_type = 0;
12590 continue;
12591
12592 case NEW_ARRAY_EXPR:
12593 case NEW_ANONYMOUS_ARRAY_EXPR:
12594 *where_found = decl = java_complete_tree (qual_wfl);
12595 if (decl == error_mark_node)
12596 return 1;
12597 *type_found = type = QUAL_DECL_TYPE (decl);
12598 continue;
12599
12600 case CONVERT_EXPR:
12601 *where_found = decl = java_complete_tree (qual_wfl);
12602 if (decl == error_mark_node)
12603 return 1;
12604 *type_found = type = QUAL_DECL_TYPE (decl);
12605 from_cast = 1;
12606 continue;
12607
12608 case CONDITIONAL_EXPR:
12609 case STRING_CST:
12610 case MODIFY_EXPR:
12611 *where_found = decl = java_complete_tree (qual_wfl);
12612 if (decl == error_mark_node)
12613 return 1;
12614 *type_found = type = QUAL_DECL_TYPE (decl);
12615 continue;
12616
12617 case ARRAY_REF:
12618 /* If the access to the function call is a non static field,
12619 build the code to access it. */
12620 if (JDECL_P (decl) && !FIELD_STATIC (decl))
12621 {
12622 decl = maybe_access_field (decl, *where_found, type);
12623 if (decl == error_mark_node)
12624 return 1;
12625 }
12626 /* And code for the array reference expression */
12627 decl = java_complete_tree (qual_wfl);
12628 if (decl == error_mark_node)
12629 return 1;
12630 type = QUAL_DECL_TYPE (decl);
12631 continue;
12632
12633 case PLUS_EXPR:
12634 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
12635 return 1;
12636 if ((type = patch_string (decl)))
12637 decl = type;
12638 *where_found = QUAL_RESOLUTION (q) = decl;
12639 *type_found = type = TREE_TYPE (decl);
12640 break;
12641
12642 case CLASS_LITERAL:
12643 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
12644 return 1;
12645 *where_found = QUAL_RESOLUTION (q) = decl;
12646 *type_found = type = TREE_TYPE (decl);
12647 break;
12648
12649 default:
12650 /* Fix for -Wall Just go to the next statement. Don't
12651 continue */
12652 break;
12653 }
12654
12655 /* If we fall here, we weren't processing a (static) function call. */
12656 previous_call_static = 0;
12657
12658 /* It can be the keyword THIS */
12659 if (TREE_CODE (qual_wfl) == EXPR_WITH_FILE_LOCATION
12660 && EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
12661 {
12662 if (!current_this)
12663 {
12664 parse_error_context
12665 (wfl, "Keyword `this' used outside allowed context");
12666 return 1;
12667 }
12668 if (ctxp->explicit_constructor_p
12669 && type == current_class)
12670 {
12671 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12672 return 1;
12673 }
12674 /* We have to generate code for intermediate access */
12675 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
12676 {
12677 *where_found = decl = current_this;
12678 *type_found = type = QUAL_DECL_TYPE (decl);
12679 }
12680 /* We're trying to access the this from somewhere else. Make sure
12681 it's allowed before doing so. */
12682 else
12683 {
12684 if (!enclosing_context_p (type, current_class))
12685 {
12686 char *p = xstrdup (lang_printable_name (type, 0));
12687 parse_error_context (qual_wfl, "Can't use variable `%s.this': type `%s' isn't an outer type of type `%s'",
12688 p, p,
12689 lang_printable_name (current_class, 0));
12690 free (p);
12691 return 1;
12692 }
12693 from_qualified_this = 1;
12694 /* If there's nothing else after that, we need to
12695 produce something now, otherwise, the section of the
12696 code that needs to produce <T>.this will generate
12697 what is necessary. */
12698 if (!TREE_CHAIN (q))
12699 {
12700 decl = build_access_to_thisn (current_class, type, 0);
12701 *where_found = decl = java_complete_tree (decl);
12702 *type_found = type = TREE_TYPE (decl);
12703 }
12704 }
12705
12706 from_type = 0;
12707 continue;
12708 }
12709
12710 /* 15.10.2 Accessing Superclass Members using SUPER */
12711 if (TREE_CODE (qual_wfl) == EXPR_WITH_FILE_LOCATION
12712 && EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
12713 {
12714 tree node;
12715 /* Check on the restricted use of SUPER */
12716 if (METHOD_STATIC (current_function_decl)
12717 || current_class == object_type_node)
12718 {
12719 parse_error_context
12720 (wfl, "Keyword `super' used outside allowed context");
12721 return 1;
12722 }
12723 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
12724 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
12725 CLASSTYPE_SUPER (current_class),
12726 build_this (EXPR_WFL_LINECOL (qual_wfl)));
12727 *where_found = decl = java_complete_tree (node);
12728 if (decl == error_mark_node)
12729 return 1;
12730 *type_found = type = QUAL_DECL_TYPE (decl);
12731 from_super = from_type = 1;
12732 continue;
12733 }
12734
12735 /* 15.13.1: Can't search for field name in packages, so we
12736 assume a variable/class name was meant. */
12737 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
12738 {
12739 tree name;
12740 if ((decl = resolve_package (wfl, &q, &name)))
12741 {
12742 tree list;
12743 *where_found = decl;
12744
12745 /* We want to be absolutely sure that the class is laid
12746 out. We're going to search something inside it. */
12747 *type_found = type = TREE_TYPE (decl);
12748 layout_class (type);
12749 from_type = 1;
12750
12751 /* Fix them all the way down, if any are left. */
12752 if (q)
12753 {
12754 list = TREE_CHAIN (q);
12755 while (list)
12756 {
12757 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
12758 list = TREE_CHAIN (list);
12759 }
12760 }
12761 }
12762 else
12763 {
12764 if (from_super || from_cast)
12765 parse_error_context
12766 ((from_cast ? qual_wfl : wfl),
12767 "No variable `%s' defined in class `%s'",
12768 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
12769 lang_printable_name (type, 0));
12770 else
12771 parse_error_context
12772 (qual_wfl, "Undefined variable or class name: `%s'",
12773 IDENTIFIER_POINTER (name));
12774 return 1;
12775 }
12776 }
12777
12778 /* We have a type name. It's been already resolved when the
12779 expression was qualified. */
12780 else if (RESOLVE_TYPE_NAME_P (qual_wfl) && QUAL_RESOLUTION (q))
12781 {
12782 decl = QUAL_RESOLUTION (q);
12783
12784 /* Sneak preview. If next we see a `new', we're facing a
12785 qualification with resulted in a type being selected
12786 instead of a field. Report the error */
12787 if(TREE_CHAIN (q)
12788 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
12789 {
12790 parse_error_context (qual_wfl, "Undefined variable `%s'",
12791 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12792 return 1;
12793 }
12794
12795 if (not_accessible_p (TREE_TYPE (decl), decl, type, 0))
12796 return not_accessible_field_error (qual_wfl, decl);
12797 check_deprecation (qual_wfl, decl);
12798
12799 type = TREE_TYPE (decl);
12800 from_type = 1;
12801 }
12802 /* We resolve an expression name */
12803 else
12804 {
12805 tree field_decl = NULL_TREE;
12806
12807 /* If there exists an early resolution, use it. That occurs
12808 only once and we know that there are more things to
12809 come. Don't do that when processing something after SUPER
12810 (we need more thing to be put in place below */
12811 if (!from_super && QUAL_RESOLUTION (q))
12812 {
12813 decl = QUAL_RESOLUTION (q);
12814 if (!type)
12815 {
12816 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
12817 {
12818 if (current_this)
12819 *where_found = current_this;
12820 else
12821 {
12822 static_ref_err (qual_wfl, DECL_NAME (decl),
12823 current_class);
12824 return 1;
12825 }
12826 if (outer_field_access_p (current_class, decl))
12827 decl = build_outer_field_access (qual_wfl, decl);
12828 }
12829 else
12830 {
12831 *where_found = TREE_TYPE (decl);
12832 if (TREE_CODE (*where_found) == POINTER_TYPE)
12833 *where_found = TREE_TYPE (*where_found);
12834 }
12835 }
12836 }
12837
12838 /* Report and error if we're using a numerical literal as a
12839 qualifier. It can only be an INTEGER_CST. */
12840 else if (TREE_CODE (qual_wfl) == INTEGER_CST)
12841 {
12842 parse_error_context
12843 (wfl, "Can't use type `%s' as a qualifier",
12844 lang_printable_name (TREE_TYPE (qual_wfl), 0));
12845 return 1;
12846 }
12847
12848 /* We have to search for a field, knowing the type of its
12849 container. The flag FROM_TYPE indicates that we resolved
12850 the last member of the expression as a type name, which
12851 means that for the resolution of this field, we'll look
12852 for other errors than if it was resolved as a member of
12853 an other field. */
12854 else
12855 {
12856 int is_static;
12857 tree field_decl_type; /* For layout */
12858
12859 if (!from_type && !JREFERENCE_TYPE_P (type))
12860 {
12861 parse_error_context
12862 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
12863 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
12864 lang_printable_name (type, 0),
12865 IDENTIFIER_POINTER (DECL_NAME (decl)));
12866 return 1;
12867 }
12868
12869 field_decl = lookup_field_wrapper (type,
12870 EXPR_WFL_NODE (qual_wfl));
12871
12872 /* Maybe what we're trying to access to is an inner
12873 class, only if decl is a TYPE_DECL. */
12874 if (!field_decl && TREE_CODE (decl) == TYPE_DECL)
12875 {
12876 tree ptr, inner_decl;
12877
12878 BUILD_PTR_FROM_NAME (ptr, EXPR_WFL_NODE (qual_wfl));
12879 inner_decl = resolve_class (decl, ptr, NULL_TREE, qual_wfl);
12880 if (inner_decl)
12881 {
12882 check_inner_class_access (inner_decl, decl, qual_wfl);
12883 type = TREE_TYPE (inner_decl);
12884 decl = inner_decl;
12885 from_type = 1;
12886 continue;
12887 }
12888 }
12889
12890 if (field_decl == NULL_TREE)
12891 {
12892 parse_error_context
12893 (qual_wfl, "No variable `%s' defined in type `%s'",
12894 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
12895 GET_TYPE_NAME (type));
12896 return 1;
12897 }
12898 if (field_decl == error_mark_node)
12899 return 1;
12900
12901 /* Layout the type of field_decl, since we may need
12902 it. Don't do primitive types or loaded classes. The
12903 situation of non primitive arrays may not handled
12904 properly here. FIXME */
12905 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
12906 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
12907 else
12908 field_decl_type = TREE_TYPE (field_decl);
12909 if (!JPRIMITIVE_TYPE_P (field_decl_type)
12910 && !CLASS_LOADED_P (field_decl_type)
12911 && !TYPE_ARRAY_P (field_decl_type))
12912 resolve_and_layout (field_decl_type, NULL_TREE);
12913
12914 /* Check on accessibility here */
12915 if (not_accessible_p (current_class, field_decl,
12916 DECL_CONTEXT (field_decl), from_super))
12917 return not_accessible_field_error (qual_wfl,field_decl);
12918 check_deprecation (qual_wfl, field_decl);
12919
12920 /* There are things to check when fields are accessed
12921 from type. There are no restrictions on a static
12922 declaration of the field when it is accessed from an
12923 interface */
12924 is_static = FIELD_STATIC (field_decl);
12925 if (!from_super && from_type
12926 && !TYPE_INTERFACE_P (type)
12927 && !is_static
12928 && (current_function_decl
12929 && METHOD_STATIC (current_function_decl)))
12930 {
12931 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
12932 return 1;
12933 }
12934 from_cast = from_super = 0;
12935
12936 /* It's an access from a type but it isn't static, we
12937 make it relative to `this'. */
12938 if (!is_static && from_type)
12939 decl = current_this;
12940
12941 /* If we need to generate something to get a proper
12942 handle on what this field is accessed from, do it
12943 now. */
12944 if (!is_static)
12945 {
12946 decl = maybe_access_field (decl, *where_found, *type_found);
12947 if (decl == error_mark_node)
12948 return 1;
12949 }
12950
12951 /* We want to keep the location were found it, and the type
12952 we found. */
12953 *where_found = decl;
12954 *type_found = type;
12955
12956 /* Generate the correct expression for field access from
12957 qualified this */
12958 if (from_qualified_this)
12959 {
12960 field_decl = build_outer_field_access (qual_wfl, field_decl);
12961 from_qualified_this = 0;
12962 }
12963
12964 /* This is the decl found and eventually the next one to
12965 search from */
12966 decl = field_decl;
12967 }
12968 from_type = 0;
12969 type = QUAL_DECL_TYPE (decl);
12970
12971 /* Sneak preview. If decl is qualified by a `new', report
12972 the error here to be accurate on the peculiar construct */
12973 if (TREE_CHAIN (q)
12974 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
12975 && !JREFERENCE_TYPE_P (type))
12976 {
12977 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
12978 lang_printable_name (type, 0));
12979 return 1;
12980 }
12981 }
12982 /* `q' might have changed due to a after package resolution
12983 re-qualification */
12984 if (!q)
12985 break;
12986 }
12987 *found_decl = decl;
12988 return 0;
12989 }
12990
12991 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
12992 can't be accessed from REFERENCE (a record type). If MEMBER
12993 features a protected access, we then use WHERE which, if non null,
12994 holds the type of MEMBER's access that is checked against
12995 6.6.2.1. This function should be used when decl is a field or a
12996 method. */
12997
12998 static int
not_accessible_p(tree reference,tree member,tree where,int from_super)12999 not_accessible_p (tree reference, tree member, tree where, int from_super)
13000 {
13001 int access_flag = get_access_flags_from_decl (member);
13002
13003 /* Inner classes are processed by check_inner_class_access */
13004 if (INNER_CLASS_TYPE_P (reference))
13005 return 0;
13006
13007 /* Access always granted for members declared public */
13008 if (access_flag & ACC_PUBLIC)
13009 return 0;
13010
13011 /* Check access on protected members */
13012 if (access_flag & ACC_PROTECTED)
13013 {
13014 /* Access granted if it occurs from within the package
13015 containing the class in which the protected member is
13016 declared */
13017 if (class_in_current_package (DECL_CONTEXT (member)))
13018 return 0;
13019
13020 /* If accessed with the form `super.member', then access is granted */
13021 if (from_super)
13022 return 0;
13023
13024 /* If where is active, access was made through a
13025 qualifier. Access is granted if the type of the qualifier is
13026 or is a sublass of the type the access made from (6.6.2.1.) */
13027 if (where && !inherits_from_p (reference, where))
13028 return 1;
13029
13030 /* Otherwise, access is granted if occurring from the class where
13031 member is declared or a subclass of it. Find the right
13032 context to perform the check */
13033 if (PURE_INNER_CLASS_TYPE_P (reference))
13034 {
13035 while (INNER_CLASS_TYPE_P (reference))
13036 {
13037 if (inherits_from_p (reference, DECL_CONTEXT (member)))
13038 return 0;
13039 reference = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (reference)));
13040 }
13041 }
13042 if (inherits_from_p (reference, DECL_CONTEXT (member)))
13043 return 0;
13044 return 1;
13045 }
13046
13047 /* Check access on private members. Access is granted only if it
13048 occurs from within the class in which it is declared -- that does
13049 it for innerclasses too. */
13050 if (access_flag & ACC_PRIVATE)
13051 {
13052 if (reference == DECL_CONTEXT (member))
13053 return 0;
13054 if (enclosing_context_p (reference, DECL_CONTEXT (member)))
13055 return 0;
13056 return 1;
13057 }
13058
13059 /* Default access are permitted only when occurring within the
13060 package in which the type (REFERENCE) is declared. In other words,
13061 REFERENCE is defined in the current package */
13062 if (ctxp->package)
13063 return !class_in_current_package (reference);
13064
13065 /* Otherwise, access is granted */
13066 return 0;
13067 }
13068
13069 /* Test deprecated decl access. */
13070 static void
check_deprecation(tree wfl,tree decl)13071 check_deprecation (tree wfl, tree decl)
13072 {
13073 const char *file;
13074 tree elt;
13075
13076 if (! flag_deprecated)
13077 return;
13078
13079 /* We want to look at the element type of arrays here, so we strip
13080 all surrounding array types. */
13081 if (TYPE_ARRAY_P (TREE_TYPE (decl)))
13082 {
13083 elt = TREE_TYPE (decl);
13084 while (TYPE_ARRAY_P (elt))
13085 elt = TYPE_ARRAY_ELEMENT (elt);
13086 /* We'll end up with a pointer type, so we use TREE_TYPE to go
13087 to the record. */
13088 decl = TYPE_NAME (TREE_TYPE (elt));
13089 }
13090 file = DECL_SOURCE_FILE (decl);
13091
13092 /* Complain if the field is deprecated and the file it was defined
13093 in isn't compiled at the same time the file which contains its
13094 use is */
13095 if (DECL_DEPRECATED (decl)
13096 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
13097 {
13098 const char *the;
13099 switch (TREE_CODE (decl))
13100 {
13101 case FUNCTION_DECL:
13102 the = "method";
13103 break;
13104 case FIELD_DECL:
13105 case VAR_DECL:
13106 the = "field";
13107 break;
13108 case TYPE_DECL:
13109 parse_warning_context (wfl, "The class `%s' has been deprecated",
13110 IDENTIFIER_POINTER (DECL_NAME (decl)));
13111 return;
13112 default:
13113 abort ();
13114 }
13115 /* Don't issue a message if the context as been deprecated as a
13116 whole. */
13117 if (! CLASS_DEPRECATED (TYPE_NAME (DECL_CONTEXT (decl))))
13118 parse_warning_context
13119 (wfl, "The %s `%s' in class `%s' has been deprecated",
13120 the, lang_printable_name (decl, 0),
13121 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
13122 }
13123 }
13124
13125 /* Returns 1 if class was declared in the current package, 0 otherwise */
13126
13127 static GTY(()) tree cicp_cache;
13128 static int
class_in_current_package(tree class)13129 class_in_current_package (tree class)
13130 {
13131 int qualified_flag;
13132 tree left;
13133
13134 if (cicp_cache == class)
13135 return 1;
13136
13137 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
13138
13139 /* If the current package is empty and the name of CLASS is
13140 qualified, class isn't in the current package. If there is a
13141 current package and the name of the CLASS is not qualified, class
13142 isn't in the current package */
13143 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
13144 return 0;
13145
13146 /* If there is not package and the name of CLASS isn't qualified,
13147 they belong to the same unnamed package */
13148 if (!ctxp->package && !qualified_flag)
13149 return 1;
13150
13151 /* Compare the left part of the name of CLASS with the package name */
13152 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
13153 if (ctxp->package == left)
13154 {
13155 cicp_cache = class;
13156 return 1;
13157 }
13158 return 0;
13159 }
13160
13161 /* This function may generate code to access DECL from WHERE. This is
13162 done only if certain conditions meet. */
13163
13164 static tree
maybe_access_field(tree decl,tree where,tree type)13165 maybe_access_field (tree decl, tree where, tree type)
13166 {
13167 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
13168 && !FIELD_STATIC (decl))
13169 decl = build_field_ref (where ? where : current_this,
13170 (type ? type : DECL_CONTEXT (decl)),
13171 DECL_NAME (decl));
13172 return decl;
13173 }
13174
13175 /* Build a method invocation, by patching PATCH. If non NULL
13176 and according to the situation, PRIMARY and WHERE may be
13177 used. IS_STATIC is set to 1 if the invoked function is static. */
13178
13179 static tree
patch_method_invocation(tree patch,tree primary,tree where,int from_super,int * is_static,tree * ret_decl)13180 patch_method_invocation (tree patch, tree primary, tree where, int from_super,
13181 int *is_static, tree *ret_decl)
13182 {
13183 tree wfl = TREE_OPERAND (patch, 0);
13184 tree args = TREE_OPERAND (patch, 1);
13185 tree name = EXPR_WFL_NODE (wfl);
13186 tree list;
13187 int is_static_flag = 0;
13188 int is_super_init = 0;
13189 tree this_arg = NULL_TREE;
13190 int is_array_clone_call = 0;
13191
13192 /* Should be overridden if everything goes well. Otherwise, if
13193 something fails, it should keep this value. It stop the
13194 evaluation of a bogus assignment. See java_complete_tree,
13195 MODIFY_EXPR: for the reasons why we sometimes want to keep on
13196 evaluating an assignment */
13197 TREE_TYPE (patch) = error_mark_node;
13198
13199 /* Since lookup functions are messing with line numbers, save the
13200 context now. */
13201 java_parser_context_save_global ();
13202
13203 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
13204
13205 /* Resolution of qualified name, excluding constructors */
13206 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
13207 {
13208 tree identifier, identifier_wfl, type, resolved;
13209 /* Extract the last IDENTIFIER of the qualified
13210 expression. This is a wfl and we will use it's location
13211 data during error report. */
13212 identifier_wfl = cut_identifier_in_qualified (wfl);
13213 identifier = EXPR_WFL_NODE (identifier_wfl);
13214
13215 /* Given the context, IDENTIFIER is syntactically qualified
13216 as a MethodName. We need to qualify what's before */
13217 qualify_ambiguous_name (wfl);
13218 resolved = resolve_field_access (wfl, NULL, NULL);
13219
13220 if (TREE_CODE (resolved) == VAR_DECL && FIELD_STATIC (resolved)
13221 && FIELD_FINAL (resolved)
13222 && !inherits_from_p (DECL_CONTEXT (resolved), current_class)
13223 && !flag_emit_class_files && !flag_emit_xref)
13224 resolved = build_class_init (DECL_CONTEXT (resolved), resolved);
13225
13226 if (resolved == error_mark_node)
13227 PATCH_METHOD_RETURN_ERROR ();
13228
13229 type = GET_SKIP_TYPE (resolved);
13230 resolve_and_layout (type, NULL_TREE);
13231
13232 if (JPRIMITIVE_TYPE_P (type))
13233 {
13234 parse_error_context
13235 (identifier_wfl,
13236 "Can't invoke a method on primitive type `%s'",
13237 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
13238 PATCH_METHOD_RETURN_ERROR ();
13239 }
13240
13241 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
13242 args = nreverse (args);
13243
13244 /* We're resolving a call from a type */
13245 if (TREE_CODE (resolved) == TYPE_DECL)
13246 {
13247 if (CLASS_INTERFACE (resolved))
13248 {
13249 parse_error_context
13250 (identifier_wfl,
13251 "Can't make static reference to method `%s' in interface `%s'",
13252 IDENTIFIER_POINTER (identifier),
13253 IDENTIFIER_POINTER (name));
13254 PATCH_METHOD_RETURN_ERROR ();
13255 }
13256 if (list && !METHOD_STATIC (list))
13257 {
13258 char *fct_name = xstrdup (lang_printable_name (list, 0));
13259 parse_error_context
13260 (identifier_wfl,
13261 "Can't make static reference to method `%s %s' in class `%s'",
13262 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
13263 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
13264 free (fct_name);
13265 PATCH_METHOD_RETURN_ERROR ();
13266 }
13267 }
13268 else
13269 this_arg = primary = resolved;
13270
13271 if (TYPE_ARRAY_P (type) && identifier == get_identifier ("clone"))
13272 is_array_clone_call = 1;
13273
13274 /* IDENTIFIER_WFL will be used to report any problem further */
13275 wfl = identifier_wfl;
13276 }
13277 /* Resolution of simple names, names generated after a primary: or
13278 constructors */
13279 else
13280 {
13281 tree class_to_search = NULL_TREE;
13282 int lc; /* Looking for Constructor */
13283
13284 /* We search constructor in their target class */
13285 if (CALL_CONSTRUCTOR_P (patch))
13286 {
13287 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
13288 class_to_search = EXPR_WFL_NODE (wfl);
13289 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
13290 this_identifier_node)
13291 class_to_search = NULL_TREE;
13292 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
13293 super_identifier_node)
13294 {
13295 is_super_init = 1;
13296 if (CLASSTYPE_SUPER (current_class))
13297 class_to_search =
13298 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
13299 else
13300 {
13301 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
13302 PATCH_METHOD_RETURN_ERROR ();
13303 }
13304 }
13305
13306 /* Class to search is NULL if we're searching the current one */
13307 if (class_to_search)
13308 {
13309 class_to_search = resolve_and_layout (class_to_search, wfl);
13310
13311 if (!class_to_search)
13312 {
13313 parse_error_context
13314 (wfl, "Class `%s' not found in type declaration",
13315 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
13316 PATCH_METHOD_RETURN_ERROR ();
13317 }
13318
13319 /* Can't instantiate an abstract class, but we can
13320 invoke it's constructor. It's use within the `new'
13321 context is denied here. */
13322 if (CLASS_ABSTRACT (class_to_search)
13323 && TREE_CODE (patch) == NEW_CLASS_EXPR)
13324 {
13325 parse_error_context
13326 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
13327 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
13328 PATCH_METHOD_RETURN_ERROR ();
13329 }
13330
13331 class_to_search = TREE_TYPE (class_to_search);
13332 }
13333 else
13334 class_to_search = current_class;
13335 lc = 1;
13336 }
13337 /* This is a regular search in the local class, unless an
13338 alternate class is specified. */
13339 else
13340 {
13341 if (where != NULL_TREE)
13342 class_to_search = where;
13343 else if (QUALIFIED_P (name))
13344 class_to_search = current_class;
13345 else
13346 {
13347 class_to_search = current_class;
13348
13349 for (;;)
13350 {
13351 if (has_method (class_to_search, name))
13352 break;
13353 if (! INNER_CLASS_TYPE_P (class_to_search))
13354 {
13355 parse_error_context (wfl,
13356 "No method named `%s' in scope",
13357 IDENTIFIER_POINTER (name));
13358 PATCH_METHOD_RETURN_ERROR ();
13359 }
13360 class_to_search
13361 = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_to_search)));
13362 }
13363 }
13364 lc = 0;
13365 }
13366
13367 /* NAME is a simple identifier or comes from a primary. Search
13368 in the class whose declaration contain the method being
13369 invoked. */
13370 resolve_and_layout (class_to_search, NULL_TREE);
13371
13372 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
13373 /* Don't continue if no method were found, as the next statement
13374 can't be executed then. */
13375 if (!list)
13376 PATCH_METHOD_RETURN_ERROR ();
13377
13378 if (TYPE_ARRAY_P (class_to_search)
13379 && DECL_NAME (list) == get_identifier ("clone"))
13380 is_array_clone_call = 1;
13381
13382 /* Check for static reference if non static methods */
13383 if (check_for_static_method_reference (wfl, patch, list,
13384 class_to_search, primary))
13385 PATCH_METHOD_RETURN_ERROR ();
13386
13387 /* Check for inner classes creation from illegal contexts */
13388 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
13389 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
13390 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search)
13391 && !DECL_INIT_P (current_function_decl))
13392 {
13393 parse_error_context
13394 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
13395 lang_printable_name (class_to_search, 0),
13396 (!current_this ? "" :
13397 "; an explicit one must be provided when creating this inner class"));
13398 PATCH_METHOD_RETURN_ERROR ();
13399 }
13400
13401 /* Non static methods are called with the current object extra
13402 argument. If patch a `new TYPE()', the argument is the value
13403 returned by the object allocator. If method is resolved as a
13404 primary, use the primary otherwise use the current THIS. */
13405 args = nreverse (args);
13406 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
13407 {
13408 this_arg = primary ? primary : current_this;
13409
13410 /* If we're using an access method, things are different.
13411 There are two family of cases:
13412
13413 1) We're not generating bytecodes:
13414
13415 - LIST is non static. It's invocation is transformed from
13416 x(a1,...,an) into this$<n>.x(a1,....an).
13417 - LIST is static. It's invocation is transformed from
13418 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
13419
13420 2) We're generating bytecodes:
13421
13422 - LIST is non static. It's invocation is transformed from
13423 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
13424 - LIST is static. It's invocation is transformed from
13425 x(a1,....,an) into TYPE_OF(this$<n>).x(a1,....an).
13426
13427 Of course, this$<n> can be arbitrarily complex, ranging from
13428 this$0 (the immediate outer context) to
13429 access$0(access$0(...(this$0))).
13430
13431 maybe_use_access_method returns a nonzero value if the
13432 this_arg has to be moved into the (then generated) stub
13433 argument list. In the meantime, the selected function
13434 might have be replaced by a generated stub. */
13435 if (!primary &&
13436 maybe_use_access_method (is_super_init, &list, &this_arg))
13437 {
13438 args = tree_cons (NULL_TREE, this_arg, args);
13439 this_arg = NULL_TREE; /* So it doesn't get chained twice */
13440 }
13441 }
13442 }
13443
13444 /* Merge point of all resolution schemes. If we have nothing, this
13445 is an error, already signaled */
13446 if (!list)
13447 PATCH_METHOD_RETURN_ERROR ();
13448
13449 /* Check accessibility, position the is_static flag, build and
13450 return the call */
13451 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list,
13452 (primary ? TREE_TYPE (TREE_TYPE (primary)) :
13453 NULL_TREE), from_super)
13454 /* Calls to clone() on array types are permitted as a special-case. */
13455 && !is_array_clone_call)
13456 {
13457 const char *const fct_name = IDENTIFIER_POINTER (DECL_NAME (list));
13458 const char *const access =
13459 java_accstring_lookup (get_access_flags_from_decl (list));
13460 const char *const klass =
13461 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list))));
13462 const char *const refklass =
13463 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class)));
13464 const char *const what = (DECL_CONSTRUCTOR_P (list)
13465 ? "constructor" : "method");
13466 /* FIXME: WFL yields the wrong message here but I don't know
13467 what else to use. */
13468 parse_error_context (wfl,
13469 "Can't access %s %s `%s.%s' from `%s'",
13470 access, what, klass, fct_name, refklass);
13471 PATCH_METHOD_RETURN_ERROR ();
13472 }
13473
13474 /* Deprecation check: check whether the method being invoked or the
13475 instance-being-created's type are deprecated. */
13476 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
13477 check_deprecation (wfl, TYPE_NAME (DECL_CONTEXT (list)));
13478 check_deprecation (wfl, list);
13479
13480 /* If invoking a innerclass constructor, there are hidden parameters
13481 to pass */
13482 if (TREE_CODE (patch) == NEW_CLASS_EXPR
13483 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
13484 {
13485 /* And make sure we add the accessed local variables to be saved
13486 in field aliases. */
13487 args = build_alias_initializer_parameter_list
13488 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
13489
13490 /* Secretly pass the current_this/primary as a second argument */
13491 if (primary || current_this)
13492 {
13493 tree extra_arg;
13494 tree this_type = (current_this ?
13495 TREE_TYPE (TREE_TYPE (current_this)) : NULL_TREE);
13496 /* Method's (list) enclosing context */
13497 tree mec = DECL_CONTEXT (TYPE_NAME (DECL_CONTEXT (list)));
13498 /* If we have a primary, use it. */
13499 if (primary)
13500 extra_arg = primary;
13501 /* The current `this' is an inner class but isn't a direct
13502 enclosing context for the inner class we're trying to
13503 create. Build an access to the proper enclosing context
13504 and use it. */
13505 else if (current_this && PURE_INNER_CLASS_TYPE_P (this_type)
13506 && this_type != TREE_TYPE (mec))
13507 {
13508
13509 extra_arg = build_access_to_thisn (current_class,
13510 TREE_TYPE (mec), 0);
13511 extra_arg = java_complete_tree (extra_arg);
13512 }
13513 /* Otherwise, just use the current `this' as an enclosing
13514 context. */
13515 else
13516 extra_arg = current_this;
13517 args = tree_cons (NULL_TREE, extra_arg, args);
13518 }
13519 else
13520 args = tree_cons (NULL_TREE, integer_zero_node, args);
13521 }
13522
13523 /* This handles the situation where a constructor invocation needs
13524 to have an enclosing context passed as a second parameter (the
13525 constructor is one of an inner class). */
13526 if ((is_super_init ||
13527 (TREE_CODE (patch) == CALL_EXPR && name == this_identifier_node))
13528 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
13529 {
13530 tree dest = TYPE_NAME (DECL_CONTEXT (list));
13531 tree extra_arg =
13532 build_access_to_thisn (current_class, DECL_CONTEXT (dest), 0);
13533 extra_arg = java_complete_tree (extra_arg);
13534 args = tree_cons (NULL_TREE, extra_arg, args);
13535 }
13536
13537 is_static_flag = METHOD_STATIC (list);
13538 if (! is_static_flag && this_arg != NULL_TREE)
13539 args = tree_cons (NULL_TREE, this_arg, args);
13540
13541 /* In the context of an explicit constructor invocation, we can't
13542 invoke any method relying on `this'. Exceptions are: we're
13543 invoking a static function, primary exists and is not the current
13544 this, we're creating a new object. */
13545 if (ctxp->explicit_constructor_p
13546 && !is_static_flag
13547 && (!primary || primary == current_this)
13548 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
13549 {
13550 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
13551 PATCH_METHOD_RETURN_ERROR ();
13552 }
13553 java_parser_context_restore_global ();
13554 if (is_static)
13555 *is_static = is_static_flag;
13556 /* Sometimes, we want the decl of the selected method. Such as for
13557 EH checking */
13558 if (ret_decl)
13559 *ret_decl = list;
13560 patch = patch_invoke (patch, list, args);
13561
13562 /* Now is a good time to insert the call to finit$ */
13563 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
13564 {
13565 tree finit_parms, finit_call;
13566
13567 /* Prepare to pass hidden parameters to finit$, if any. */
13568 finit_parms = build_alias_initializer_parameter_list
13569 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
13570
13571 finit_call =
13572 build_method_invocation (build_wfl_node (finit_identifier_node),
13573 finit_parms);
13574
13575 /* Generate the code used to initialize fields declared with an
13576 initialization statement and build a compound statement along
13577 with the super constructor invocation. */
13578 CAN_COMPLETE_NORMALLY (patch) = 1;
13579 patch = build (COMPOUND_EXPR, void_type_node, patch,
13580 java_complete_tree (finit_call));
13581 }
13582 return patch;
13583 }
13584
13585 /* Check that we're not trying to do a static reference to a method in
13586 non static method. Return 1 if it's the case, 0 otherwise. */
13587
13588 static int
check_for_static_method_reference(tree wfl,tree node,tree method,tree where,tree primary)13589 check_for_static_method_reference (tree wfl, tree node, tree method,
13590 tree where, tree primary)
13591 {
13592 if (METHOD_STATIC (current_function_decl)
13593 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
13594 {
13595 char *fct_name = xstrdup (lang_printable_name (method, 0));
13596 parse_error_context
13597 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
13598 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
13599 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
13600 free (fct_name);
13601 return 1;
13602 }
13603 return 0;
13604 }
13605
13606 /* Fix the invocation of *MDECL if necessary in the case of a
13607 invocation from an inner class. *THIS_ARG might be modified
13608 appropriately and an alternative access to *MDECL might be
13609 returned. */
13610
13611 static int
maybe_use_access_method(int is_super_init,tree * mdecl,tree * this_arg)13612 maybe_use_access_method (int is_super_init, tree *mdecl, tree *this_arg)
13613 {
13614 tree ctx;
13615 tree md = *mdecl, ta = *this_arg;
13616 int to_return = 0;
13617 int non_static_context = !METHOD_STATIC (md);
13618
13619 if (is_super_init
13620 || DECL_CONTEXT (md) == current_class
13621 || !PURE_INNER_CLASS_TYPE_P (current_class)
13622 || DECL_FINIT_P (md)
13623 || DECL_INSTINIT_P (md))
13624 return 0;
13625
13626 /* If we're calling a method found in an enclosing class, generate
13627 what it takes to retrieve the right this. Don't do that if we're
13628 invoking a static method. Note that if MD's type is unrelated to
13629 CURRENT_CLASS, then the current this can be used. */
13630
13631 if (non_static_context && DECL_CONTEXT (md) != object_type_node)
13632 {
13633 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
13634 if (inherits_from_p (ctx, DECL_CONTEXT (md)))
13635 {
13636 ta = build_current_thisn (current_class);
13637 ta = build_wfl_node (ta);
13638 }
13639 else
13640 {
13641 tree type = ctx;
13642 while (type)
13643 {
13644 maybe_build_thisn_access_method (type);
13645 if (inherits_from_p (type, DECL_CONTEXT (md)))
13646 {
13647 ta = build_access_to_thisn (ctx, type, 0);
13648 break;
13649 }
13650 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
13651 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
13652 }
13653 }
13654 ta = java_complete_tree (ta);
13655 }
13656
13657 /* We might have to use an access method to get to MD. We can
13658 break the method access rule as far as we're not generating
13659 bytecode */
13660 if (METHOD_PRIVATE (md) && flag_emit_class_files)
13661 {
13662 md = build_outer_method_access_method (md);
13663 to_return = 1;
13664 }
13665
13666 *mdecl = md;
13667 *this_arg = ta;
13668
13669 /* Returning a nonzero value indicates we were doing a non static
13670 method invocation that is now a static invocation. It will have
13671 callee displace `this' to insert it in the regular argument
13672 list. */
13673 return (non_static_context && to_return);
13674 }
13675
13676 /* Patch an invoke expression METHOD and ARGS, based on its invocation
13677 mode. */
13678
13679 static tree
patch_invoke(tree patch,tree method,tree args)13680 patch_invoke (tree patch, tree method, tree args)
13681 {
13682 tree dtable, func;
13683 tree original_call, t, ta;
13684 tree check = NULL_TREE;
13685
13686 /* Last step for args: convert build-in types. If we're dealing with
13687 a new TYPE() type call, the first argument to the constructor
13688 isn't found in the incoming argument list, but delivered by
13689 `new' */
13690 t = TYPE_ARG_TYPES (TREE_TYPE (method));
13691 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
13692 t = TREE_CHAIN (t);
13693 for (ta = args; t != end_params_node && ta;
13694 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
13695 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
13696 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
13697 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
13698
13699 /* Resolve unresolved returned type issues */
13700 t = TREE_TYPE (TREE_TYPE (method));
13701 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
13702 resolve_and_layout (TREE_TYPE (t), NULL);
13703
13704 if (flag_emit_class_files || flag_emit_xref)
13705 func = method;
13706 else
13707 {
13708 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
13709 {
13710 case INVOKE_VIRTUAL:
13711 dtable = invoke_build_dtable (0, args);
13712 func = build_invokevirtual (dtable, method);
13713 break;
13714
13715 case INVOKE_NONVIRTUAL:
13716 /* If the object for the method call is null, we throw an
13717 exception. We don't do this if the object is the current
13718 method's `this'. In other cases we just rely on an
13719 optimization pass to eliminate redundant checks. */
13720 if (TREE_VALUE (args) != current_this)
13721 {
13722 /* We use a save_expr here to make sure we only evaluate
13723 the new `self' expression once. */
13724 tree save_arg = save_expr (TREE_VALUE (args));
13725 TREE_VALUE (args) = save_arg;
13726 check = java_check_reference (save_arg, 1);
13727 }
13728 /* Fall through. */
13729
13730 case INVOKE_SUPER:
13731 case INVOKE_STATIC:
13732 {
13733 tree signature = build_java_signature (TREE_TYPE (method));
13734 func = build_known_method_ref (method, TREE_TYPE (method),
13735 DECL_CONTEXT (method),
13736 signature, args);
13737 }
13738 break;
13739
13740 case INVOKE_INTERFACE:
13741 dtable = invoke_build_dtable (1, args);
13742 func = build_invokeinterface (dtable, method);
13743 break;
13744
13745 default:
13746 abort ();
13747 }
13748
13749 /* Ensure self_type is initialized, (invokestatic). FIXME */
13750 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
13751 }
13752
13753 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
13754 TREE_OPERAND (patch, 0) = func;
13755 TREE_OPERAND (patch, 1) = args;
13756 patch = check_for_builtin (method, patch);
13757 original_call = patch;
13758
13759 /* We're processing a `new TYPE ()' form. New is called and its
13760 returned value is the first argument to the constructor. We build
13761 a COMPOUND_EXPR and use saved expression so that the overall NEW
13762 expression value is a pointer to a newly created and initialized
13763 class. */
13764 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
13765 {
13766 tree class = DECL_CONTEXT (method);
13767 tree c1, saved_new, size, new;
13768 tree alloc_node;
13769
13770 if (flag_emit_class_files || flag_emit_xref)
13771 {
13772 TREE_TYPE (patch) = build_pointer_type (class);
13773 return patch;
13774 }
13775 if (!TYPE_SIZE (class))
13776 safe_layout_class (class);
13777 size = size_in_bytes (class);
13778 alloc_node =
13779 (class_has_finalize_method (class) ? alloc_object_node
13780 : alloc_no_finalizer_node);
13781 new = build (CALL_EXPR, promote_type (class),
13782 build_address_of (alloc_node),
13783 tree_cons (NULL_TREE, build_class_ref (class),
13784 build_tree_list (NULL_TREE,
13785 size_in_bytes (class))),
13786 NULL_TREE);
13787 saved_new = save_expr (new);
13788 c1 = build_tree_list (NULL_TREE, saved_new);
13789 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
13790 TREE_OPERAND (original_call, 1) = c1;
13791 TREE_SET_CODE (original_call, CALL_EXPR);
13792 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
13793 }
13794
13795 /* If CHECK is set, then we are building a check to see if the object
13796 is NULL. */
13797 if (check != NULL_TREE)
13798 {
13799 /* We have to call force_evaluation_order now because creating a
13800 COMPOUND_EXPR wraps the arg list in a way that makes it
13801 unrecognizable by force_evaluation_order later. Yuk. */
13802 patch = build (COMPOUND_EXPR, TREE_TYPE (patch), check,
13803 force_evaluation_order (patch));
13804 TREE_SIDE_EFFECTS (patch) = 1;
13805 }
13806
13807 /* In order to be able to modify PATCH later, we SAVE_EXPR it and
13808 put it as the first expression of a COMPOUND_EXPR. The second
13809 expression being an empty statement to be later patched if
13810 necessary. We remember a TREE_LIST (the PURPOSE is the method,
13811 the VALUE is the compound) in a hashtable and return a
13812 COMPOUND_EXPR built so that the result of the evaluation of the
13813 original PATCH node is returned. */
13814 if (STATIC_CLASS_INIT_OPT_P ()
13815 && current_function_decl && METHOD_STATIC (method))
13816 {
13817 tree list;
13818 tree fndecl = current_function_decl;
13819 /* We have to call force_evaluation_order now because creating a
13820 COMPOUND_EXPR wraps the arg list in a way that makes it
13821 unrecognizable by force_evaluation_order later. Yuk. */
13822 tree save = save_expr (force_evaluation_order (patch));
13823 tree type = TREE_TYPE (patch);
13824
13825 patch = build (COMPOUND_EXPR, type, save, empty_stmt_node);
13826 list = tree_cons (method, patch,
13827 DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl));
13828
13829 DECL_FUNCTION_STATIC_METHOD_INVOCATION_COMPOUND (fndecl) = list;
13830
13831 patch = build (COMPOUND_EXPR, type, patch, save);
13832 }
13833
13834 return patch;
13835 }
13836
13837 static int
invocation_mode(tree method,int super)13838 invocation_mode (tree method, int super)
13839 {
13840 int access = get_access_flags_from_decl (method);
13841
13842 if (super)
13843 return INVOKE_SUPER;
13844
13845 if (access & ACC_STATIC)
13846 return INVOKE_STATIC;
13847
13848 /* We have to look for a constructor before we handle nonvirtual
13849 calls; otherwise the constructor will look nonvirtual. */
13850 if (DECL_CONSTRUCTOR_P (method))
13851 return INVOKE_STATIC;
13852
13853 if (access & ACC_FINAL || access & ACC_PRIVATE)
13854 return INVOKE_NONVIRTUAL;
13855
13856 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
13857 return INVOKE_NONVIRTUAL;
13858
13859 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
13860 return INVOKE_INTERFACE;
13861
13862 return INVOKE_VIRTUAL;
13863 }
13864
13865 /* Retrieve a refined list of matching methods. It covers the step
13866 15.11.2 (Compile-Time Step 2) */
13867
13868 static tree
lookup_method_invoke(int lc,tree cl,tree class,tree name,tree arg_list)13869 lookup_method_invoke (int lc, tree cl, tree class, tree name, tree arg_list)
13870 {
13871 tree atl = end_params_node; /* Arg Type List */
13872 tree method, signature, list, node;
13873 const char *candidates; /* Used for error report */
13874 char *dup;
13875
13876 /* Fix the arguments */
13877 for (node = arg_list; node; node = TREE_CHAIN (node))
13878 {
13879 tree current_arg = TREE_TYPE (TREE_VALUE (node));
13880 /* Non primitive type may have to be resolved */
13881 if (!JPRIMITIVE_TYPE_P (current_arg))
13882 resolve_and_layout (current_arg, NULL_TREE);
13883 /* And promoted */
13884 if (TREE_CODE (current_arg) == RECORD_TYPE)
13885 current_arg = promote_type (current_arg);
13886 atl = tree_cons (NULL_TREE, current_arg, atl);
13887 }
13888
13889 /* Presto. If we're dealing with an anonymous class and a
13890 constructor call, generate the right constructor now, since we
13891 know the arguments' types. */
13892
13893 if (lc && ANONYMOUS_CLASS_P (class))
13894 {
13895 tree saved_current_class;
13896 tree mdecl = craft_constructor (TYPE_NAME (class), atl);
13897 saved_current_class = current_class;
13898 current_class = class;
13899 fix_constructors (mdecl);
13900 current_class = saved_current_class;
13901 }
13902
13903 /* Find all candidates and then refine the list, searching for the
13904 most specific method. */
13905 list = find_applicable_accessible_methods_list (lc, class, name, atl);
13906 list = find_most_specific_methods_list (list);
13907 if (list && !TREE_CHAIN (list))
13908 return TREE_VALUE (list);
13909
13910 /* Issue an error. List candidates if any. Candidates are listed
13911 only if accessible (non accessible methods may end-up here for
13912 the sake of a better error report). */
13913 candidates = NULL;
13914 if (list)
13915 {
13916 tree current;
13917 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
13918 for (current = list; current; current = TREE_CHAIN (current))
13919 {
13920 tree cm = TREE_VALUE (current);
13921 char string [4096];
13922 if (!cm || not_accessible_p (class, cm, NULL_TREE, 0))
13923 continue;
13924 sprintf
13925 (string, " `%s' in `%s'%s",
13926 get_printable_method_name (cm),
13927 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
13928 (TREE_CHAIN (current) ? "\n" : ""));
13929 obstack_grow (&temporary_obstack, string, strlen (string));
13930 }
13931 obstack_1grow (&temporary_obstack, '\0');
13932 candidates = obstack_finish (&temporary_obstack);
13933 }
13934 /* Issue the error message */
13935 method = make_node (FUNCTION_TYPE);
13936 TYPE_ARG_TYPES (method) = atl;
13937 signature = build_java_argument_signature (method);
13938 dup = xstrdup (lang_printable_name (class, 0));
13939 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
13940 (lc ? "constructor" : "method"),
13941 (lc ? dup : IDENTIFIER_POINTER (name)),
13942 IDENTIFIER_POINTER (signature), dup,
13943 (candidates ? candidates : ""));
13944 free (dup);
13945 return NULL_TREE;
13946 }
13947
13948 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
13949 when we're looking for a constructor. */
13950
13951 static tree
find_applicable_accessible_methods_list(int lc,tree class,tree name,tree arglist)13952 find_applicable_accessible_methods_list (int lc, tree class, tree name,
13953 tree arglist)
13954 {
13955 static htab_t searched_classes;
13956 static int search_not_done = 0;
13957 tree list = NULL_TREE, all_list = NULL_TREE;
13958
13959 /* Check the hash table to determine if this class has been searched
13960 already. */
13961 if (searched_classes)
13962 {
13963 if (htab_find (searched_classes, class) != NULL)
13964 return NULL;
13965 }
13966 else
13967 {
13968 searched_classes = htab_create (10, htab_hash_pointer,
13969 htab_eq_pointer, NULL);
13970 }
13971
13972 search_not_done++;
13973 *htab_find_slot (searched_classes, class, INSERT) = class;
13974
13975 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
13976 {
13977 load_class (class, 1);
13978 safe_layout_class (class);
13979 }
13980
13981 /* Search interfaces */
13982 if (TREE_CODE (TYPE_NAME (class)) == TYPE_DECL
13983 && CLASS_INTERFACE (TYPE_NAME (class)))
13984 {
13985 int i, n;
13986 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
13987 search_applicable_methods_list (lc, TYPE_METHODS (class),
13988 name, arglist, &list, &all_list);
13989 n = TREE_VEC_LENGTH (basetype_vec);
13990 for (i = 1; i < n; i++)
13991 {
13992 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
13993 tree rlist;
13994
13995 rlist = find_applicable_accessible_methods_list (lc, t, name,
13996 arglist);
13997 list = chainon (rlist, list);
13998 }
13999 }
14000 /* Search classes */
14001 else
14002 {
14003 search_applicable_methods_list (lc, TYPE_METHODS (class),
14004 name, arglist, &list, &all_list);
14005
14006 /* When looking finit$, class$ or instinit$, we turn LC to 1 so
14007 that we only search in class. Note that we should have found
14008 something at this point. */
14009 if (ID_FINIT_P (name) || ID_CLASSDOLLAR_P (name) || ID_INSTINIT_P (name))
14010 {
14011 lc = 1;
14012 if (!list)
14013 abort ();
14014 }
14015
14016 /* We must search all interfaces of this class */
14017 if (!lc)
14018 {
14019 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
14020 int n = TREE_VEC_LENGTH (basetype_vec), i;
14021 for (i = 1; i < n; i++)
14022 {
14023 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
14024 if (t != object_type_node)
14025 {
14026 tree rlist
14027 = find_applicable_accessible_methods_list (lc, t,
14028 name, arglist);
14029 list = chainon (rlist, list);
14030 }
14031 }
14032 }
14033
14034 /* Search superclass */
14035 if (!lc && CLASSTYPE_SUPER (class) != NULL_TREE)
14036 {
14037 tree rlist;
14038 class = CLASSTYPE_SUPER (class);
14039 rlist = find_applicable_accessible_methods_list (lc, class,
14040 name, arglist);
14041 list = chainon (rlist, list);
14042 }
14043 }
14044
14045 search_not_done--;
14046
14047 /* We're done. Reset the searched classes list and finally search
14048 java.lang.Object if it wasn't searched already. */
14049 if (!search_not_done)
14050 {
14051 if (!lc
14052 && TYPE_METHODS (object_type_node)
14053 && htab_find (searched_classes, object_type_node) == NULL)
14054 {
14055 search_applicable_methods_list (lc,
14056 TYPE_METHODS (object_type_node),
14057 name, arglist, &list, &all_list);
14058 }
14059 htab_delete (searched_classes);
14060 searched_classes = NULL;
14061 }
14062
14063 /* Either return the list obtained or all selected (but
14064 inaccessible) methods for better error report. */
14065 return (!list ? all_list : list);
14066 }
14067
14068 /* Effectively search for the appropriate method in method */
14069
14070 static void
search_applicable_methods_list(int lc,tree method,tree name,tree arglist,tree * list,tree * all_list)14071 search_applicable_methods_list (int lc, tree method, tree name, tree arglist,
14072 tree *list, tree *all_list)
14073 {
14074 for (; method; method = TREE_CHAIN (method))
14075 {
14076 /* When dealing with constructor, stop here, otherwise search
14077 other classes */
14078 if (lc && !DECL_CONSTRUCTOR_P (method))
14079 continue;
14080 else if (!lc && (DECL_CONSTRUCTOR_P (method)
14081 || (DECL_NAME (method) != name)))
14082 continue;
14083
14084 if (argument_types_convertible (method, arglist))
14085 {
14086 /* Retain accessible methods only */
14087 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
14088 method, NULL_TREE, 0))
14089 *list = tree_cons (NULL_TREE, method, *list);
14090 else
14091 /* Also retain all selected method here */
14092 *all_list = tree_cons (NULL_TREE, method, *list);
14093 }
14094 }
14095 }
14096
14097 /* 15.11.2.2 Choose the Most Specific Method */
14098
14099 static tree
find_most_specific_methods_list(tree list)14100 find_most_specific_methods_list (tree list)
14101 {
14102 int max = 0;
14103 int abstract, candidates;
14104 tree current, new_list = NULL_TREE;
14105 for (current = list; current; current = TREE_CHAIN (current))
14106 {
14107 tree method;
14108 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
14109
14110 for (method = list; method; method = TREE_CHAIN (method))
14111 {
14112 tree method_v, current_v;
14113 /* Don't test a method against itself */
14114 if (method == current)
14115 continue;
14116
14117 method_v = TREE_VALUE (method);
14118 current_v = TREE_VALUE (current);
14119
14120 /* Compare arguments and location where methods where declared */
14121 if (argument_types_convertible (method_v, current_v))
14122 {
14123 if (valid_method_invocation_conversion_p
14124 (DECL_CONTEXT (method_v), DECL_CONTEXT (current_v))
14125 || (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v))
14126 && enclosing_context_p (DECL_CONTEXT (method_v),
14127 DECL_CONTEXT (current_v))))
14128 {
14129 int v = (DECL_SPECIFIC_COUNT (current_v) +=
14130 (INNER_CLASS_TYPE_P (DECL_CONTEXT (current_v)) ? 2 : 1));
14131 max = (v > max ? v : max);
14132 }
14133 }
14134 }
14135 }
14136
14137 /* Review the list and select the maximally specific methods */
14138 for (current = list, abstract = -1, candidates = -1;
14139 current; current = TREE_CHAIN (current))
14140 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
14141 {
14142 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
14143 abstract += (METHOD_ABSTRACT (TREE_VALUE (current)) ? 1 : 0);
14144 candidates++;
14145 }
14146
14147 /* If we have several and they're all abstract, just pick the
14148 closest one. */
14149 if (candidates > 0 && candidates == abstract)
14150 {
14151 /* FIXME: merge the throws clauses. There is no convenient way
14152 to do this in gcj right now, since ideally we'd like to
14153 introduce a new METHOD_DECL here, but that is really not
14154 possible. */
14155 new_list = nreverse (new_list);
14156 TREE_CHAIN (new_list) = NULL_TREE;
14157 return new_list;
14158 }
14159
14160 /* We have several (we couldn't find a most specific), all but one
14161 are abstract, we pick the only non abstract one. */
14162 if (candidates > 0 && (candidates == abstract+1))
14163 {
14164 for (current = new_list; current; current = TREE_CHAIN (current))
14165 if (!METHOD_ABSTRACT (TREE_VALUE (current)))
14166 {
14167 TREE_CHAIN (current) = NULL_TREE;
14168 new_list = current;
14169 }
14170 }
14171
14172 /* If we can't find one, lower expectations and try to gather multiple
14173 maximally specific methods */
14174 while (!new_list && max)
14175 {
14176 while (--max > 0)
14177 {
14178 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
14179 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
14180 }
14181 }
14182
14183 return new_list;
14184 }
14185
14186 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
14187 converted by method invocation conversion (5.3) to the type of the
14188 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
14189 to change less often than M1. */
14190
14191 static GTY(()) tree m2_arg_value;
14192 static GTY(()) tree m2_arg_cache;
14193
14194 static int
argument_types_convertible(tree m1,tree m2_or_arglist)14195 argument_types_convertible (tree m1, tree m2_or_arglist)
14196 {
14197 tree m1_arg, m2_arg;
14198
14199 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
14200
14201 if (m2_arg_value == m2_or_arglist)
14202 m2_arg = m2_arg_cache;
14203 else
14204 {
14205 /* M2_OR_ARGLIST can be a function DECL or a raw list of
14206 argument types */
14207 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
14208 {
14209 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
14210 if (!METHOD_STATIC (m2_or_arglist))
14211 m2_arg = TREE_CHAIN (m2_arg);
14212 }
14213 else
14214 m2_arg = m2_or_arglist;
14215
14216 m2_arg_value = m2_or_arglist;
14217 m2_arg_cache = m2_arg;
14218 }
14219
14220 while (m1_arg != end_params_node && m2_arg != end_params_node)
14221 {
14222 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
14223 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
14224 TREE_VALUE (m2_arg)))
14225 break;
14226 m1_arg = TREE_CHAIN (m1_arg);
14227 m2_arg = TREE_CHAIN (m2_arg);
14228 }
14229 return m1_arg == end_params_node && m2_arg == end_params_node;
14230 }
14231
14232 /* Qualification routines */
14233
14234 /* Given a name x.y.z, look up x locally. If it's found, save the
14235 decl. If it's not found, mark the name as RESOLVE_PACKAGE_NAME_P,
14236 so that we later try and load the appropriate classes. */
14237 static void
qualify_ambiguous_name(tree id)14238 qualify_ambiguous_name (tree id)
14239 {
14240 tree name, decl;
14241
14242 /* We inspect the first item of the qualification list. As a sanity
14243 check, make sure that it is an identfier node. */
14244 tree qual = EXPR_WFL_QUALIFICATION (id);
14245 tree qual_wfl = QUAL_WFL (qual);
14246
14247 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
14248 return;
14249
14250 name = EXPR_WFL_NODE (qual_wfl);
14251
14252 /* If we don't have an identifier, or we have a 'this' or 'super',
14253 then field access processing is all we need : there is nothing
14254 for us to do. */
14255 if (!name || TREE_CODE (name) != IDENTIFIER_NODE ||
14256 name == this_identifier_node ||
14257 name == super_identifier_node)
14258 return;
14259
14260 /* If name appears within the scope of a local variable declaration
14261 or parameter declaration, or is a field within an enclosing
14262 class, then it is an expression name. Save the decl and let
14263 resolve_field_access do it's work. */
14264 if ((decl = IDENTIFIER_LOCAL_VALUE (name)) ||
14265 (decl = lookup_field_wrapper (current_class, name)))
14266 {
14267 QUAL_RESOLUTION (qual) = decl;
14268 return;
14269 }
14270
14271 /* If name is a known class name (either declared or imported), mark
14272 us as a type name. */
14273 if ((decl = resolve_and_layout (name, NULL_TREE)))
14274 {
14275 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
14276 QUAL_RESOLUTION (qual) = decl;
14277 }
14278
14279 /* Check here that NAME isn't declared by more than one
14280 type-import-on-demand declaration of the compilation unit
14281 containing NAME. FIXME */
14282
14283 /* We couldn't find a declaration for the name. Assume for now that
14284 we have a qualified class name that needs to be loaded from an
14285 external class file. */
14286 else
14287 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
14288
14289 /* Propagate the qualification across other components of the
14290 qualified name */
14291 for (qual = TREE_CHAIN (qual); qual;
14292 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
14293 {
14294 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
14295 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
14296 }
14297
14298 /* Store the global qualification for the ambiguous part of ID back
14299 into ID fields */
14300 if (RESOLVE_TYPE_NAME_P (qual_wfl))
14301 RESOLVE_TYPE_NAME_P (id) = 1;
14302 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
14303 RESOLVE_PACKAGE_NAME_P (id) = 1;
14304 }
14305
14306 static int
breakdown_qualified(tree * left,tree * right,tree source)14307 breakdown_qualified (tree *left, tree *right, tree source)
14308 {
14309 char *p, *base;
14310 int l = IDENTIFIER_LENGTH (source);
14311
14312 base = alloca (l + 1);
14313 memcpy (base, IDENTIFIER_POINTER (source), l + 1);
14314
14315 /* Breakdown NAME into REMAINDER . IDENTIFIER. */
14316 p = base + l - 1;
14317 while (*p != '.' && p != base)
14318 p--;
14319
14320 /* We didn't find a '.'. Return an error. */
14321 if (p == base)
14322 return 1;
14323
14324 *p = '\0';
14325 if (right)
14326 *right = get_identifier (p+1);
14327 *left = get_identifier (base);
14328
14329 return 0;
14330 }
14331
14332 /* Return TRUE if two classes are from the same package. */
14333
14334 static int
in_same_package(tree name1,tree name2)14335 in_same_package (tree name1, tree name2)
14336 {
14337 tree tmp;
14338 tree pkg1;
14339 tree pkg2;
14340
14341 if (TREE_CODE (name1) == TYPE_DECL)
14342 name1 = DECL_NAME (name1);
14343 if (TREE_CODE (name2) == TYPE_DECL)
14344 name2 = DECL_NAME (name2);
14345
14346 if (QUALIFIED_P (name1) != QUALIFIED_P (name2))
14347 /* One in empty package. */
14348 return 0;
14349
14350 if (QUALIFIED_P (name1) == 0 && QUALIFIED_P (name2) == 0)
14351 /* Both in empty package. */
14352 return 1;
14353
14354 breakdown_qualified (&pkg1, &tmp, name1);
14355 breakdown_qualified (&pkg2, &tmp, name2);
14356
14357 return (pkg1 == pkg2);
14358 }
14359
14360 /* Patch tree nodes in a function body. When a BLOCK is found, push
14361 local variable decls if present.
14362 Same as java_complete_lhs, but does resolve static finals to values. */
14363
14364 static tree
java_complete_tree(tree node)14365 java_complete_tree (tree node)
14366 {
14367 node = java_complete_lhs (node);
14368 if (JDECL_P (node) && CLASS_FINAL_VARIABLE_P (node)
14369 && DECL_INITIAL (node) != NULL_TREE
14370 && !flag_emit_xref)
14371 {
14372 tree value = fold_constant_for_init (node, node);
14373 if (value != NULL_TREE)
14374 return value;
14375 }
14376 return node;
14377 }
14378
14379 static tree
java_stabilize_reference(tree node)14380 java_stabilize_reference (tree node)
14381 {
14382 if (TREE_CODE (node) == COMPOUND_EXPR)
14383 {
14384 tree op0 = TREE_OPERAND (node, 0);
14385 tree op1 = TREE_OPERAND (node, 1);
14386 TREE_OPERAND (node, 0) = save_expr (op0);
14387 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
14388 return node;
14389 }
14390 return stabilize_reference (node);
14391 }
14392
14393 /* Patch tree nodes in a function body. When a BLOCK is found, push
14394 local variable decls if present.
14395 Same as java_complete_tree, but does not resolve static finals to values. */
14396
14397 static tree
java_complete_lhs(tree node)14398 java_complete_lhs (tree node)
14399 {
14400 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
14401 int flag;
14402
14403 /* CONVERT_EXPR always has its type set, even though it needs to be
14404 worked out. */
14405 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
14406 return node;
14407
14408 /* The switch block implements cases processing container nodes
14409 first. Contained nodes are always written back. Leaves come
14410 next and return a value. */
14411 switch (TREE_CODE (node))
14412 {
14413 case BLOCK:
14414
14415 /* 1- Block section.
14416 Set the local values on decl names so we can identify them
14417 faster when they're referenced. At that stage, identifiers
14418 are legal so we don't check for declaration errors. */
14419 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
14420 {
14421 DECL_CONTEXT (cn) = current_function_decl;
14422 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
14423 }
14424 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
14425 CAN_COMPLETE_NORMALLY (node) = 1;
14426 else
14427 {
14428 tree stmt = BLOCK_EXPR_BODY (node);
14429 tree *ptr;
14430 int error_seen = 0;
14431 if (TREE_CODE (stmt) == COMPOUND_EXPR)
14432 {
14433 /* Re-order from (((A; B); C); ...; Z) to
14434 (A; (B; (C ; (...; Z)))).
14435 This makes it easier to scan the statements left-to-right
14436 without using recursion (which might overflow the stack
14437 if the block has many statements. */
14438 for (;;)
14439 {
14440 tree left = TREE_OPERAND (stmt, 0);
14441 if (TREE_CODE (left) != COMPOUND_EXPR)
14442 break;
14443 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
14444 TREE_OPERAND (left, 1) = stmt;
14445 stmt = left;
14446 }
14447 BLOCK_EXPR_BODY (node) = stmt;
14448 }
14449
14450 /* Now do the actual complete, without deep recursion for
14451 long blocks. */
14452 ptr = &BLOCK_EXPR_BODY (node);
14453 while (TREE_CODE (*ptr) == COMPOUND_EXPR
14454 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
14455 {
14456 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
14457 tree *next = &TREE_OPERAND (*ptr, 1);
14458 TREE_OPERAND (*ptr, 0) = cur;
14459 if (cur == empty_stmt_node)
14460 {
14461 /* Optimization; makes it easier to detect empty bodies.
14462 Most useful for <clinit> with all-constant initializer. */
14463 *ptr = *next;
14464 continue;
14465 }
14466 if (TREE_CODE (cur) == ERROR_MARK)
14467 error_seen++;
14468 else if (! CAN_COMPLETE_NORMALLY (cur))
14469 {
14470 wfl_op2 = *next;
14471 for (;;)
14472 {
14473 if (TREE_CODE (wfl_op2) == BLOCK)
14474 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
14475 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
14476 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
14477 else
14478 break;
14479 }
14480 if (TREE_CODE (wfl_op2) != CASE_EXPR
14481 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
14482 unreachable_stmt_error (*ptr);
14483 }
14484 if (TREE_TYPE (*ptr) == NULL_TREE)
14485 TREE_TYPE (*ptr) = void_type_node;
14486 ptr = next;
14487 }
14488 *ptr = java_complete_tree (*ptr);
14489
14490 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
14491 return error_mark_node;
14492 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
14493 }
14494 /* Turn local bindings to null */
14495 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
14496 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
14497
14498 TREE_TYPE (node) = void_type_node;
14499 break;
14500
14501 /* 2- They are expressions but ultimately deal with statements */
14502
14503 case THROW_EXPR:
14504 wfl_op1 = TREE_OPERAND (node, 0);
14505 COMPLETE_CHECK_OP_0 (node);
14506 /* 14.19 A throw statement cannot complete normally. */
14507 CAN_COMPLETE_NORMALLY (node) = 0;
14508 return patch_throw_statement (node, wfl_op1);
14509
14510 case SYNCHRONIZED_EXPR:
14511 wfl_op1 = TREE_OPERAND (node, 0);
14512 return patch_synchronized_statement (node, wfl_op1);
14513
14514 case TRY_EXPR:
14515 return patch_try_statement (node);
14516
14517 case TRY_FINALLY_EXPR:
14518 COMPLETE_CHECK_OP_0 (node);
14519 COMPLETE_CHECK_OP_1 (node);
14520 /* Reduce try/finally nodes with an empty try block. */
14521 if (TREE_OPERAND (node, 0) == empty_stmt_node
14522 || BLOCK_EMPTY_P (TREE_OPERAND (node, 0)))
14523 return TREE_OPERAND (node, 1);
14524 /* Likewise for an empty finally block. */
14525 if (TREE_OPERAND (node, 1) == empty_stmt_node
14526 || BLOCK_EMPTY_P (TREE_OPERAND (node, 1)))
14527 return TREE_OPERAND (node, 0);
14528 CAN_COMPLETE_NORMALLY (node)
14529 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
14530 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
14531 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
14532 return node;
14533
14534 case LABELED_BLOCK_EXPR:
14535 PUSH_LABELED_BLOCK (node);
14536 if (LABELED_BLOCK_BODY (node))
14537 COMPLETE_CHECK_OP_1 (node);
14538 TREE_TYPE (node) = void_type_node;
14539 POP_LABELED_BLOCK ();
14540
14541 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
14542 {
14543 LABELED_BLOCK_BODY (node) = NULL_TREE;
14544 CAN_COMPLETE_NORMALLY (node) = 1;
14545 }
14546 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
14547 CAN_COMPLETE_NORMALLY (node) = 1;
14548 return node;
14549
14550 case EXIT_BLOCK_EXPR:
14551 /* We don't complete operand 1, because it's the return value of
14552 the EXIT_BLOCK_EXPR which doesn't exist it Java */
14553 return patch_bc_statement (node);
14554
14555 case CASE_EXPR:
14556 cn = java_complete_tree (TREE_OPERAND (node, 0));
14557 if (cn == error_mark_node)
14558 return cn;
14559
14560 /* First, the case expression must be constant. Values of final
14561 fields are accepted. */
14562 cn = fold (cn);
14563 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
14564 && JDECL_P (TREE_OPERAND (cn, 1))
14565 && FIELD_FINAL (TREE_OPERAND (cn, 1))
14566 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
14567 {
14568 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
14569 TREE_OPERAND (cn, 1));
14570 }
14571 /* Accept final locals too. */
14572 else if (TREE_CODE (cn) == VAR_DECL && DECL_FINAL (cn))
14573 cn = fold_constant_for_init (DECL_INITIAL (cn), cn);
14574
14575 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
14576 {
14577 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14578 parse_error_context (node, "Constant expression required");
14579 return error_mark_node;
14580 }
14581
14582 nn = ctxp->current_loop;
14583
14584 /* It must be assignable to the type of the switch expression. */
14585 if (!try_builtin_assignconv (NULL_TREE,
14586 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
14587 {
14588 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14589 parse_error_context
14590 (wfl_operator,
14591 "Incompatible type for case. Can't convert `%s' to `int'",
14592 lang_printable_name (TREE_TYPE (cn), 0));
14593 return error_mark_node;
14594 }
14595
14596 cn = fold (convert (int_type_node, cn));
14597 TREE_CONSTANT_OVERFLOW (cn) = 0;
14598 CAN_COMPLETE_NORMALLY (cn) = 1;
14599
14600 /* Save the label on a list so that we can later check for
14601 duplicates. */
14602 case_label_list = tree_cons (node, cn, case_label_list);
14603
14604 /* Multiple instance of a case label bearing the same value is
14605 checked later. The case expression is all right so far. */
14606 if (TREE_CODE (cn) == VAR_DECL)
14607 cn = DECL_INITIAL (cn);
14608 TREE_OPERAND (node, 0) = cn;
14609 TREE_TYPE (node) = void_type_node;
14610 CAN_COMPLETE_NORMALLY (node) = 1;
14611 TREE_SIDE_EFFECTS (node) = 1;
14612 break;
14613
14614 case DEFAULT_EXPR:
14615 nn = ctxp->current_loop;
14616 /* Only one default label is allowed per switch statement */
14617 if (SWITCH_HAS_DEFAULT (nn))
14618 {
14619 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14620 parse_error_context (wfl_operator,
14621 "Duplicate case label: `default'");
14622 return error_mark_node;
14623 }
14624 else
14625 SWITCH_HAS_DEFAULT (nn) = 1;
14626 TREE_TYPE (node) = void_type_node;
14627 TREE_SIDE_EFFECTS (node) = 1;
14628 CAN_COMPLETE_NORMALLY (node) = 1;
14629 break;
14630
14631 case SWITCH_EXPR:
14632 case LOOP_EXPR:
14633 PUSH_LOOP (node);
14634 /* Check whether the loop was enclosed in a labeled
14635 statement. If not, create one, insert the loop in it and
14636 return the node */
14637 nn = patch_loop_statement (node);
14638
14639 /* Anyways, walk the body of the loop */
14640 if (TREE_CODE (node) == LOOP_EXPR)
14641 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
14642 /* Switch statement: walk the switch expression and the cases */
14643 else
14644 node = patch_switch_statement (node);
14645
14646 if (node == error_mark_node || TREE_OPERAND (node, 0) == error_mark_node)
14647 nn = error_mark_node;
14648 else
14649 {
14650 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
14651 /* If we returned something different, that's because we
14652 inserted a label. Pop the label too. */
14653 if (nn != node)
14654 {
14655 if (CAN_COMPLETE_NORMALLY (node))
14656 CAN_COMPLETE_NORMALLY (nn) = 1;
14657 POP_LABELED_BLOCK ();
14658 }
14659 }
14660 POP_LOOP ();
14661 return nn;
14662
14663 case EXIT_EXPR:
14664 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
14665 return patch_exit_expr (node);
14666
14667 case COND_EXPR:
14668 /* Condition */
14669 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
14670 if (TREE_OPERAND (node, 0) == error_mark_node)
14671 return error_mark_node;
14672 /* then-else branches */
14673 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
14674 if (TREE_OPERAND (node, 1) == error_mark_node)
14675 return error_mark_node;
14676 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
14677 if (TREE_OPERAND (node, 2) == error_mark_node)
14678 return error_mark_node;
14679 return patch_if_else_statement (node);
14680 break;
14681
14682 case CONDITIONAL_EXPR:
14683 /* Condition */
14684 wfl_op1 = TREE_OPERAND (node, 0);
14685 COMPLETE_CHECK_OP_0 (node);
14686 wfl_op2 = TREE_OPERAND (node, 1);
14687 COMPLETE_CHECK_OP_1 (node);
14688 wfl_op3 = TREE_OPERAND (node, 2);
14689 COMPLETE_CHECK_OP_2 (node);
14690 return patch_conditional_expr (node, wfl_op1, wfl_op2);
14691
14692 /* 3- Expression section */
14693 case COMPOUND_EXPR:
14694 wfl_op2 = TREE_OPERAND (node, 1);
14695 TREE_OPERAND (node, 0) = nn =
14696 java_complete_tree (TREE_OPERAND (node, 0));
14697 if (wfl_op2 == empty_stmt_node)
14698 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
14699 else
14700 {
14701 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
14702 {
14703 /* An unreachable condition in a do-while statement
14704 is *not* (technically) an unreachable statement. */
14705 nn = wfl_op2;
14706 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
14707 nn = EXPR_WFL_NODE (nn);
14708 /* NN can be NULL_TREE exactly when UPDATE is, in
14709 finish_for_loop. */
14710 if (nn != NULL_TREE && TREE_CODE (nn) != EXIT_EXPR)
14711 {
14712 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14713 if (SUPPRESS_UNREACHABLE_ERROR (nn))
14714 {
14715 /* Perhaps this warning should have an
14716 associated flag. The code being compiled is
14717 pedantically correct, but useless. */
14718 parse_warning_context (wfl_operator,
14719 "Unreachable statement");
14720 }
14721 else
14722 parse_error_context (wfl_operator,
14723 "Unreachable statement");
14724 }
14725 }
14726 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
14727 if (TREE_OPERAND (node, 1) == error_mark_node)
14728 return error_mark_node;
14729 /* Even though we might allow the case where the first
14730 operand doesn't return normally, we still should compute
14731 CAN_COMPLETE_NORMALLY correctly. */
14732 CAN_COMPLETE_NORMALLY (node)
14733 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
14734 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
14735 }
14736 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
14737 break;
14738
14739 case RETURN_EXPR:
14740 /* CAN_COMPLETE_NORMALLY (node) = 0; */
14741 return patch_return (node);
14742
14743 case EXPR_WITH_FILE_LOCATION:
14744 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
14745 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
14746 {
14747 tree wfl = node;
14748 node = resolve_expression_name (node, NULL);
14749 if (node == error_mark_node)
14750 return node;
14751 /* Keep line number information somewhere were it doesn't
14752 disrupt the completion process. */
14753 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
14754 {
14755 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
14756 TREE_OPERAND (node, 1) = wfl;
14757 }
14758 CAN_COMPLETE_NORMALLY (node) = 1;
14759 }
14760 else
14761 {
14762 tree body;
14763 int save_lineno = input_line;
14764 input_line = EXPR_WFL_LINENO (node);
14765 body = java_complete_tree (EXPR_WFL_NODE (node));
14766 input_line = save_lineno;
14767 EXPR_WFL_NODE (node) = body;
14768 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
14769 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
14770 if (body == empty_stmt_node || TREE_CONSTANT (body))
14771 {
14772 /* Makes it easier to constant fold, detect empty bodies. */
14773 return body;
14774 }
14775 if (body == error_mark_node)
14776 {
14777 /* Its important for the evaluation of assignment that
14778 this mark on the TREE_TYPE is propagated. */
14779 TREE_TYPE (node) = error_mark_node;
14780 return error_mark_node;
14781 }
14782 else
14783 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
14784
14785 }
14786 break;
14787
14788 case NEW_ARRAY_EXPR:
14789 /* Patch all the dimensions */
14790 flag = 0;
14791 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
14792 {
14793 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
14794 tree dim = convert (int_type_node,
14795 java_complete_tree (TREE_VALUE (cn)));
14796 if (dim == error_mark_node)
14797 {
14798 flag = 1;
14799 continue;
14800 }
14801 else
14802 {
14803 TREE_VALUE (cn) = dim;
14804 /* Setup the location of the current dimension, for
14805 later error report. */
14806 TREE_PURPOSE (cn) =
14807 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
14808 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
14809 }
14810 }
14811 /* They complete the array creation expression, if no errors
14812 were found. */
14813 CAN_COMPLETE_NORMALLY (node) = 1;
14814 return (flag ? error_mark_node
14815 : force_evaluation_order (patch_newarray (node)));
14816
14817 case NEW_ANONYMOUS_ARRAY_EXPR:
14818 /* Create the array type if necessary. */
14819 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
14820 {
14821 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
14822 if (!(type = resolve_type_during_patch (type)))
14823 return error_mark_node;
14824 type = build_array_from_name (type, NULL_TREE,
14825 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
14826 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
14827 }
14828 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
14829 ANONYMOUS_ARRAY_INITIALIZER (node));
14830 if (node == error_mark_node)
14831 return error_mark_node;
14832 CAN_COMPLETE_NORMALLY (node) = 1;
14833 return node;
14834
14835 case NEW_CLASS_EXPR:
14836 case CALL_EXPR:
14837 /* Complete function's argument(s) first */
14838 if (complete_function_arguments (node))
14839 return error_mark_node;
14840 else
14841 {
14842 tree decl, wfl = TREE_OPERAND (node, 0);
14843 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
14844 int from_super = (EXPR_WFL_NODE (TREE_OPERAND (node, 0)) ==
14845 super_identifier_node);
14846 tree arguments;
14847 int location = EXPR_WFL_LINECOL (node);
14848
14849 node = patch_method_invocation (node, NULL_TREE, NULL_TREE,
14850 from_super, 0, &decl);
14851 if (node == error_mark_node)
14852 return error_mark_node;
14853
14854 if (TREE_CODE (node) == CALL_EXPR
14855 && TREE_OPERAND (node, 1) != NULL_TREE)
14856 arguments = TREE_VALUE (TREE_OPERAND (node, 1));
14857 else
14858 arguments = NULL_TREE;
14859 check_thrown_exceptions (location, decl, arguments);
14860 /* If we call this(...), register signature and positions */
14861 if (in_this)
14862 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
14863 tree_cons (wfl, decl,
14864 DECL_CONSTRUCTOR_CALLS (current_function_decl));
14865 CAN_COMPLETE_NORMALLY (node) = 1;
14866 return force_evaluation_order (node);
14867 }
14868
14869 case MODIFY_EXPR:
14870 /* Save potential wfls */
14871 wfl_op1 = TREE_OPERAND (node, 0);
14872 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
14873
14874 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
14875 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
14876 && DECL_INITIAL (nn) != NULL_TREE)
14877 {
14878 tree value;
14879
14880 value = fold_constant_for_init (nn, nn);
14881
14882 /* When we have a primitype type, or a string and we're not
14883 emitting a class file, we actually don't want to generate
14884 anything for the assignment. */
14885 if (value != NULL_TREE &&
14886 (JPRIMITIVE_TYPE_P (TREE_TYPE (value)) ||
14887 (TREE_TYPE (value) == string_ptr_type_node &&
14888 ! flag_emit_class_files)))
14889 {
14890 /* Prepare node for patch_assignment */
14891 TREE_OPERAND (node, 1) = value;
14892 /* Call patch assignment to verify the assignment */
14893 if (patch_assignment (node, wfl_op1) == error_mark_node)
14894 return error_mark_node;
14895 /* Set DECL_INITIAL properly (a conversion might have
14896 been decided by patch_assignment) and return the
14897 empty statement. */
14898 else
14899 {
14900 tree patched = patch_string (TREE_OPERAND (node, 1));
14901 if (patched)
14902 DECL_INITIAL (nn) = patched;
14903 else
14904 DECL_INITIAL (nn) = TREE_OPERAND (node, 1);
14905 DECL_FIELD_FINAL_IUD (nn) = 1;
14906 return empty_stmt_node;
14907 }
14908 }
14909 if (! flag_emit_class_files)
14910 DECL_INITIAL (nn) = NULL_TREE;
14911 }
14912 wfl_op2 = TREE_OPERAND (node, 1);
14913
14914 if (TREE_OPERAND (node, 0) == error_mark_node)
14915 return error_mark_node;
14916
14917 flag = COMPOUND_ASSIGN_P (wfl_op2);
14918 if (flag)
14919 {
14920 /* This might break when accessing outer field from inner
14921 class. TESTME, FIXME */
14922 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
14923
14924 /* Hand stabilize the lhs on both places */
14925 TREE_OPERAND (node, 0) = lvalue;
14926 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
14927 (flag_emit_class_files ? lvalue : save_expr (lvalue));
14928
14929 /* 15.25.2.a: Left hand is not an array access. FIXME */
14930 /* Now complete the RHS. We write it back later on. */
14931 nn = java_complete_tree (TREE_OPERAND (node, 1));
14932
14933 if ((cn = patch_string (nn)))
14934 nn = cn;
14935
14936 /* The last part of the rewrite for E1 op= E2 is to have
14937 E1 = (T)(E1 op E2), with T being the type of E1. */
14938 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
14939 TREE_TYPE (lvalue), nn));
14940
14941 /* If the assignment is compound and has reference type,
14942 then ensure the LHS has type String and nothing else. */
14943 if (JREFERENCE_TYPE_P (TREE_TYPE (lvalue))
14944 && ! JSTRING_TYPE_P (TREE_TYPE (lvalue)))
14945 parse_error_context (wfl_op2,
14946 "Incompatible type for `+='. Can't convert `%s' to `java.lang.String'",
14947 lang_printable_name (TREE_TYPE (lvalue), 0));
14948
14949 /* 15.25.2.b: Left hand is an array access. FIXME */
14950 }
14951
14952 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
14953 function to complete this RHS. Note that a NEW_ARRAY_INIT
14954 might have been already fully expanded if created as a result
14955 of processing an anonymous array initializer. We avoid doing
14956 the operation twice by testing whether the node already bears
14957 a type. */
14958 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
14959 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
14960 TREE_OPERAND (node, 1));
14961 /* Otherwise we simply complete the RHS */
14962 else
14963 nn = java_complete_tree (TREE_OPERAND (node, 1));
14964
14965 if (nn == error_mark_node)
14966 return error_mark_node;
14967
14968 /* Write back the RHS as we evaluated it. */
14969 TREE_OPERAND (node, 1) = nn;
14970
14971 /* In case we're handling = with a String as a RHS, we need to
14972 produce a String out of the RHS (it might still be a
14973 STRING_CST or a StringBuffer at this stage */
14974 if ((nn = patch_string (TREE_OPERAND (node, 1))))
14975 TREE_OPERAND (node, 1) = nn;
14976
14977 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
14978 TREE_OPERAND (node, 1))))
14979 {
14980 /* We return error_mark_node if outer_field_access_fix
14981 detects we write into a final. */
14982 if (nn == error_mark_node)
14983 return error_mark_node;
14984 node = nn;
14985 }
14986 else
14987 {
14988 node = patch_assignment (node, wfl_op1);
14989 if (node == error_mark_node)
14990 return error_mark_node;
14991 /* Reorganize the tree if necessary. */
14992 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
14993 || JSTRING_P (TREE_TYPE (node))))
14994 node = java_refold (node);
14995 }
14996
14997 /* Seek to set DECL_INITIAL to a proper value, since it might have
14998 undergone a conversion in patch_assignment. We do that only when
14999 it's necessary to have DECL_INITIAL properly set. */
15000 nn = TREE_OPERAND (node, 0);
15001 if (TREE_CODE (nn) == VAR_DECL
15002 && DECL_INITIAL (nn) && CONSTANT_VALUE_P (DECL_INITIAL (nn))
15003 && FIELD_STATIC (nn) && FIELD_FINAL (nn)
15004 && (JPRIMITIVE_TYPE_P (TREE_TYPE (nn))
15005 || TREE_TYPE (nn) == string_ptr_type_node))
15006 DECL_INITIAL (nn) = TREE_OPERAND (node, 1);
15007
15008 CAN_COMPLETE_NORMALLY (node) = 1;
15009 return node;
15010
15011 case MULT_EXPR:
15012 case PLUS_EXPR:
15013 case MINUS_EXPR:
15014 case LSHIFT_EXPR:
15015 case RSHIFT_EXPR:
15016 case URSHIFT_EXPR:
15017 case BIT_AND_EXPR:
15018 case BIT_XOR_EXPR:
15019 case BIT_IOR_EXPR:
15020 case TRUNC_MOD_EXPR:
15021 case TRUNC_DIV_EXPR:
15022 case RDIV_EXPR:
15023 case TRUTH_ANDIF_EXPR:
15024 case TRUTH_ORIF_EXPR:
15025 case EQ_EXPR:
15026 case NE_EXPR:
15027 case GT_EXPR:
15028 case GE_EXPR:
15029 case LT_EXPR:
15030 case LE_EXPR:
15031 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
15032 knows how to handle those cases. */
15033 wfl_op1 = TREE_OPERAND (node, 0);
15034 wfl_op2 = TREE_OPERAND (node, 1);
15035
15036 CAN_COMPLETE_NORMALLY (node) = 1;
15037 /* Don't complete string nodes if dealing with the PLUS operand. */
15038 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
15039 {
15040 nn = java_complete_tree (wfl_op1);
15041 if (nn == error_mark_node)
15042 return error_mark_node;
15043
15044 TREE_OPERAND (node, 0) = nn;
15045 }
15046 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
15047 {
15048 nn = java_complete_tree (wfl_op2);
15049 if (nn == error_mark_node)
15050 return error_mark_node;
15051
15052 TREE_OPERAND (node, 1) = nn;
15053 }
15054 return patch_binop (node, wfl_op1, wfl_op2);
15055
15056 case INSTANCEOF_EXPR:
15057 wfl_op1 = TREE_OPERAND (node, 0);
15058 COMPLETE_CHECK_OP_0 (node);
15059 if (flag_emit_xref)
15060 {
15061 TREE_TYPE (node) = boolean_type_node;
15062 return node;
15063 }
15064 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
15065
15066 case UNARY_PLUS_EXPR:
15067 case NEGATE_EXPR:
15068 case TRUTH_NOT_EXPR:
15069 case BIT_NOT_EXPR:
15070 case PREDECREMENT_EXPR:
15071 case PREINCREMENT_EXPR:
15072 case POSTDECREMENT_EXPR:
15073 case POSTINCREMENT_EXPR:
15074 case CONVERT_EXPR:
15075 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
15076 how to handle those cases. */
15077 wfl_op1 = TREE_OPERAND (node, 0);
15078 CAN_COMPLETE_NORMALLY (node) = 1;
15079 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
15080 if (TREE_OPERAND (node, 0) == error_mark_node)
15081 return error_mark_node;
15082 node = patch_unaryop (node, wfl_op1);
15083 CAN_COMPLETE_NORMALLY (node) = 1;
15084 break;
15085
15086 case ARRAY_REF:
15087 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
15088 how to handle those cases. */
15089 wfl_op1 = TREE_OPERAND (node, 0);
15090 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
15091 if (TREE_OPERAND (node, 0) == error_mark_node)
15092 return error_mark_node;
15093 if (!flag_emit_class_files && !flag_emit_xref)
15094 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
15095 /* The same applies to wfl_op2 */
15096 wfl_op2 = TREE_OPERAND (node, 1);
15097 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
15098 if (TREE_OPERAND (node, 1) == error_mark_node)
15099 return error_mark_node;
15100 if (!flag_emit_class_files && !flag_emit_xref)
15101 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
15102 return patch_array_ref (node);
15103
15104 case RECORD_TYPE:
15105 return node;;
15106
15107 case COMPONENT_REF:
15108 /* The first step in the re-write of qualified name handling. FIXME.
15109 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
15110 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
15111 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
15112 {
15113 tree name = TREE_OPERAND (node, 1);
15114 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
15115 if (field == NULL_TREE)
15116 {
15117 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
15118 return error_mark_node;
15119 }
15120 if (! FIELD_STATIC (field))
15121 {
15122 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
15123 return error_mark_node;
15124 }
15125 return field;
15126 }
15127 else
15128 abort ();
15129 break;
15130
15131 case THIS_EXPR:
15132 /* Can't use THIS in a static environment */
15133 if (!current_this)
15134 {
15135 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15136 parse_error_context (wfl_operator,
15137 "Keyword `this' used outside allowed context");
15138 TREE_TYPE (node) = error_mark_node;
15139 return error_mark_node;
15140 }
15141 if (ctxp->explicit_constructor_p)
15142 {
15143 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15144 parse_error_context
15145 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
15146 TREE_TYPE (node) = error_mark_node;
15147 return error_mark_node;
15148 }
15149 return current_this;
15150
15151 case CLASS_LITERAL:
15152 CAN_COMPLETE_NORMALLY (node) = 1;
15153 node = patch_incomplete_class_ref (node);
15154 if (node == error_mark_node)
15155 return error_mark_node;
15156 break;
15157
15158 default:
15159 CAN_COMPLETE_NORMALLY (node) = 1;
15160 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
15161 and it's time to turn it into the appropriate String object */
15162 if ((nn = patch_string (node)))
15163 node = nn;
15164 else
15165 internal_error ("No case for %s", tree_code_name [TREE_CODE (node)]);
15166 }
15167 return node;
15168 }
15169
15170 /* Complete function call's argument. Return a nonzero value is an
15171 error was found. */
15172
15173 static int
complete_function_arguments(tree node)15174 complete_function_arguments (tree node)
15175 {
15176 int flag = 0;
15177 tree cn;
15178
15179 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
15180 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
15181 {
15182 tree wfl = TREE_VALUE (cn), parm, temp;
15183 parm = java_complete_tree (wfl);
15184
15185 if (parm == error_mark_node)
15186 {
15187 flag = 1;
15188 continue;
15189 }
15190 /* If have a string literal that we haven't transformed yet or a
15191 crafted string buffer, as a result of use of the the String
15192 `+' operator. Build `parm.toString()' and expand it. */
15193 if ((temp = patch_string (parm)))
15194 parm = temp;
15195
15196 TREE_VALUE (cn) = parm;
15197 }
15198 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
15199 return flag;
15200 }
15201
15202 /* Sometimes (for loops and variable initialized during their
15203 declaration), we want to wrap a statement around a WFL and turn it
15204 debugable. */
15205
15206 static tree
build_debugable_stmt(int location,tree stmt)15207 build_debugable_stmt (int location, tree stmt)
15208 {
15209 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
15210 {
15211 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
15212 EXPR_WFL_LINECOL (stmt) = location;
15213 }
15214 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
15215 return stmt;
15216 }
15217
15218 static tree
build_expr_block(tree body,tree decls)15219 build_expr_block (tree body, tree decls)
15220
15221 {
15222 tree node = make_node (BLOCK);
15223 BLOCK_EXPR_DECLS (node) = decls;
15224 BLOCK_EXPR_BODY (node) = body;
15225 if (body)
15226 TREE_TYPE (node) = TREE_TYPE (body);
15227 TREE_SIDE_EFFECTS (node) = 1;
15228 return node;
15229 }
15230
15231 /* Create a new function block and link it appropriately to current
15232 function block chain */
15233
15234 static tree
enter_block(void)15235 enter_block (void)
15236 {
15237 tree b = build_expr_block (NULL_TREE, NULL_TREE);
15238
15239 /* Link block B supercontext to the previous block. The current
15240 function DECL is used as supercontext when enter_a_block is called
15241 for the first time for a given function. The current function body
15242 (DECL_FUNCTION_BODY) is set to be block B. */
15243
15244 tree fndecl = current_function_decl;
15245
15246 if (!fndecl) {
15247 BLOCK_SUPERCONTEXT (b) = current_static_block;
15248 current_static_block = b;
15249 }
15250
15251 else if (!DECL_FUNCTION_BODY (fndecl))
15252 {
15253 BLOCK_SUPERCONTEXT (b) = fndecl;
15254 DECL_FUNCTION_BODY (fndecl) = b;
15255 }
15256 else
15257 {
15258 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
15259 DECL_FUNCTION_BODY (fndecl) = b;
15260 }
15261 return b;
15262 }
15263
15264 /* Exit a block by changing the current function body
15265 (DECL_FUNCTION_BODY) to the current block super context, only if
15266 the block being exited isn't the method's top level one. */
15267
15268 static tree
exit_block(void)15269 exit_block (void)
15270 {
15271 tree b;
15272 if (current_function_decl)
15273 {
15274 b = DECL_FUNCTION_BODY (current_function_decl);
15275 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
15276 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
15277 }
15278 else
15279 {
15280 b = current_static_block;
15281
15282 if (BLOCK_SUPERCONTEXT (b))
15283 current_static_block = BLOCK_SUPERCONTEXT (b);
15284 }
15285 return b;
15286 }
15287
15288 /* Lookup for NAME in the nested function's blocks, all the way up to
15289 the current toplevel one. It complies with Java's local variable
15290 scoping rules. */
15291
15292 static tree
lookup_name_in_blocks(tree name)15293 lookup_name_in_blocks (tree name)
15294 {
15295 tree b = GET_CURRENT_BLOCK (current_function_decl);
15296
15297 while (b != current_function_decl)
15298 {
15299 tree current;
15300
15301 /* Paranoid sanity check. To be removed */
15302 if (TREE_CODE (b) != BLOCK)
15303 abort ();
15304
15305 for (current = BLOCK_EXPR_DECLS (b); current;
15306 current = TREE_CHAIN (current))
15307 if (DECL_NAME (current) == name)
15308 return current;
15309 b = BLOCK_SUPERCONTEXT (b);
15310 }
15311 return NULL_TREE;
15312 }
15313
15314 static void
maybe_absorb_scoping_blocks(void)15315 maybe_absorb_scoping_blocks (void)
15316 {
15317 while (BLOCK_IS_IMPLICIT (GET_CURRENT_BLOCK (current_function_decl)))
15318 {
15319 tree b = exit_block ();
15320 java_method_add_stmt (current_function_decl, b);
15321 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", input_line));
15322 }
15323 }
15324
15325
15326 /* This section of the source is reserved to build_* functions that
15327 are building incomplete tree nodes and the patch_* functions that
15328 are completing them. */
15329
15330 /* Wrap a non WFL node around a WFL. */
15331
15332 static tree
build_wfl_wrap(tree node,int location)15333 build_wfl_wrap (tree node, int location)
15334 {
15335 tree wfl, node_to_insert = node;
15336
15337 /* We want to process THIS . xxx symbolically, to keep it consistent
15338 with the way we're processing SUPER. A THIS from a primary as a
15339 different form than a SUPER. Turn THIS into something symbolic */
15340 if (TREE_CODE (node) == THIS_EXPR)
15341 node_to_insert = wfl = build_wfl_node (this_identifier_node);
15342 else
15343 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
15344
15345 EXPR_WFL_LINECOL (wfl) = location;
15346 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
15347 return wfl;
15348 }
15349
15350 /* Build a super() constructor invocation. Returns empty_stmt_node if
15351 we're currently dealing with the class java.lang.Object. */
15352
15353 static tree
build_super_invocation(tree mdecl)15354 build_super_invocation (tree mdecl)
15355 {
15356 if (DECL_CONTEXT (mdecl) == object_type_node)
15357 return empty_stmt_node;
15358 else
15359 {
15360 tree super_wfl = build_wfl_node (super_identifier_node);
15361 tree a = NULL_TREE, t;
15362 /* If we're dealing with an anonymous class, pass the arguments
15363 of the crafted constructor along. */
15364 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
15365 {
15366 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
15367 for (; t != end_params_node; t = TREE_CHAIN (t))
15368 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
15369 }
15370 return build_method_invocation (super_wfl, a);
15371 }
15372 }
15373
15374 /* Build a SUPER/THIS qualified method invocation. */
15375
15376 static tree
build_this_super_qualified_invocation(int use_this,tree name,tree args,int lloc,int rloc)15377 build_this_super_qualified_invocation (int use_this, tree name, tree args,
15378 int lloc, int rloc)
15379 {
15380 tree invok;
15381 tree wfl =
15382 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
15383 EXPR_WFL_LINECOL (wfl) = lloc;
15384 invok = build_method_invocation (name, args);
15385 return make_qualified_primary (wfl, invok, rloc);
15386 }
15387
15388 /* Build an incomplete CALL_EXPR node. */
15389
15390 static tree
build_method_invocation(tree name,tree args)15391 build_method_invocation (tree name, tree args)
15392 {
15393 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
15394 TREE_SIDE_EFFECTS (call) = 1;
15395 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
15396 return call;
15397 }
15398
15399 /* Build an incomplete new xxx(...) node. */
15400
15401 static tree
build_new_invocation(tree name,tree args)15402 build_new_invocation (tree name, tree args)
15403 {
15404 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
15405 TREE_SIDE_EFFECTS (call) = 1;
15406 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
15407 return call;
15408 }
15409
15410 /* Build an incomplete assignment expression. */
15411
15412 static tree
build_assignment(int op,int op_location,tree lhs,tree rhs)15413 build_assignment (int op, int op_location, tree lhs, tree rhs)
15414 {
15415 tree assignment;
15416 /* Build the corresponding binop if we deal with a Compound
15417 Assignment operator. Mark the binop sub-tree as part of a
15418 Compound Assignment expression */
15419 if (op != ASSIGN_TK)
15420 {
15421 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
15422 COMPOUND_ASSIGN_P (rhs) = 1;
15423 }
15424 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
15425 TREE_SIDE_EFFECTS (assignment) = 1;
15426 EXPR_WFL_LINECOL (assignment) = op_location;
15427 return assignment;
15428 }
15429
15430 /* Print an INTEGER_CST node as decimal in a static buffer, and return
15431 the buffer. This is used only for string conversion. */
15432 static char *
string_convert_int_cst(tree node)15433 string_convert_int_cst (tree node)
15434 {
15435 /* Long.MIN_VALUE is -9223372036854775808, 20 characters. */
15436 static char buffer[21];
15437
15438 unsigned HOST_WIDE_INT lo = TREE_INT_CST_LOW (node);
15439 unsigned HOST_WIDE_INT hi = TREE_INT_CST_HIGH (node);
15440 char *p = buffer + sizeof (buffer);
15441 int neg = 0;
15442
15443 unsigned HOST_WIDE_INT hibit = (((unsigned HOST_WIDE_INT) 1)
15444 << (HOST_BITS_PER_WIDE_INT - 1));
15445
15446 *--p = '\0';
15447
15448 /* If negative, note the fact and negate the value. */
15449 if ((hi & hibit))
15450 {
15451 lo = ~lo;
15452 hi = ~hi;
15453 if (++lo == 0)
15454 ++hi;
15455 neg = 1;
15456 }
15457
15458 /* Divide by 10 until there are no bits left. */
15459 do
15460 {
15461 unsigned HOST_WIDE_INT acc = 0;
15462 unsigned HOST_WIDE_INT outhi = 0, outlo = 0;
15463 unsigned int i;
15464
15465 /* Use long division to compute the result and the remainder. */
15466 for (i = 0; i < 2 * HOST_BITS_PER_WIDE_INT; ++i)
15467 {
15468 /* Shift a bit into accumulator. */
15469 acc <<= 1;
15470 if ((hi & hibit))
15471 acc |= 1;
15472
15473 /* Shift the value. */
15474 hi <<= 1;
15475 if ((lo & hibit))
15476 hi |= 1;
15477 lo <<= 1;
15478
15479 /* Shift the correct bit into the result. */
15480 outhi <<= 1;
15481 if ((outlo & hibit))
15482 outhi |= 1;
15483 outlo <<= 1;
15484 if (acc >= 10)
15485 {
15486 acc -= 10;
15487 outlo |= 1;
15488 }
15489 }
15490
15491 /* '0' == 060 in Java, but might not be here (think EBCDIC). */
15492 *--p = '\060' + acc;
15493
15494 hi = outhi;
15495 lo = outlo;
15496 }
15497 while (hi || lo);
15498
15499 if (neg)
15500 *--p = '\055'; /* '-' == 055 in Java, but might not be here. */
15501
15502 return p;
15503 }
15504
15505 /* Print an INTEGER_CST node in a static buffer, and return the
15506 buffer. This is used only for error handling. */
15507 char *
print_int_node(tree node)15508 print_int_node (tree node)
15509 {
15510 static char buffer [80];
15511 if (TREE_CONSTANT_OVERFLOW (node))
15512 sprintf (buffer, "<overflow>");
15513
15514 if (TREE_INT_CST_HIGH (node) == 0)
15515 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
15516 TREE_INT_CST_LOW (node));
15517 else if (TREE_INT_CST_HIGH (node) == -1
15518 && TREE_INT_CST_LOW (node) != 0)
15519 sprintf (buffer, "-" HOST_WIDE_INT_PRINT_UNSIGNED,
15520 -TREE_INT_CST_LOW (node));
15521 else
15522 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
15523 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
15524
15525 return buffer;
15526 }
15527
15528
15529 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
15530 context. */
15531
15532 /* 15.25 Assignment operators. */
15533
15534 static tree
patch_assignment(tree node,tree wfl_op1)15535 patch_assignment (tree node, tree wfl_op1)
15536 {
15537 tree rhs = TREE_OPERAND (node, 1);
15538 tree lvalue = TREE_OPERAND (node, 0), llvalue;
15539 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
15540 int error_found = 0;
15541 int lvalue_from_array = 0;
15542 int is_return = 0;
15543
15544 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15545
15546 /* Lhs can be a named variable */
15547 if (JDECL_P (lvalue))
15548 {
15549 lhs_type = TREE_TYPE (lvalue);
15550 }
15551 /* Or Lhs can be an array access. */
15552 else if (TREE_CODE (lvalue) == ARRAY_REF)
15553 {
15554 lhs_type = TREE_TYPE (lvalue);
15555 lvalue_from_array = 1;
15556 }
15557 /* Or a field access */
15558 else if (TREE_CODE (lvalue) == COMPONENT_REF)
15559 lhs_type = TREE_TYPE (lvalue);
15560 /* Or a function return slot */
15561 else if (TREE_CODE (lvalue) == RESULT_DECL)
15562 {
15563 /* If the return type is an integral type, then we create the
15564 RESULT_DECL with a promoted type, but we need to do these
15565 checks against the unpromoted type to ensure type safety. So
15566 here we look at the real type, not the type of the decl we
15567 are modifying. */
15568 lhs_type = TREE_TYPE (TREE_TYPE (current_function_decl));
15569 is_return = 1;
15570 }
15571 /* Otherwise, we might want to try to write into an optimized static
15572 final, this is an of a different nature, reported further on. */
15573 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
15574 && resolve_expression_name (wfl_op1, &llvalue))
15575 {
15576 lhs_type = TREE_TYPE (lvalue);
15577 }
15578 else
15579 {
15580 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
15581 error_found = 1;
15582 }
15583
15584 rhs_type = TREE_TYPE (rhs);
15585
15586 /* 5.1 Try the assignment conversion for builtin type. */
15587 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
15588
15589 /* 5.2 If it failed, try a reference conversion */
15590 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
15591 lhs_type = promote_type (rhs_type);
15592
15593 /* 15.25.2 If we have a compound assignment, convert RHS into the
15594 type of the LHS */
15595 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
15596 new_rhs = convert (lhs_type, rhs);
15597
15598 /* Explicit cast required. This is an error */
15599 if (!new_rhs)
15600 {
15601 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
15602 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
15603 tree wfl;
15604 char operation [32]; /* Max size known */
15605
15606 /* If the assignment is part of a declaration, we use the WFL of
15607 the declared variable to point out the error and call it a
15608 declaration problem. If the assignment is a genuine =
15609 operator, we call is a operator `=' problem, otherwise we
15610 call it an assignment problem. In both of these last cases,
15611 we use the WFL of the operator to indicate the error. */
15612
15613 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
15614 {
15615 wfl = wfl_op1;
15616 strcpy (operation, "declaration");
15617 }
15618 else
15619 {
15620 wfl = wfl_operator;
15621 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
15622 strcpy (operation, "assignment");
15623 else if (is_return)
15624 strcpy (operation, "`return'");
15625 else
15626 strcpy (operation, "`='");
15627 }
15628
15629 if (!valid_cast_to_p (rhs_type, lhs_type))
15630 parse_error_context
15631 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
15632 operation, t1, t2);
15633 else
15634 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
15635 operation, t1, t2);
15636 free (t1); free (t2);
15637 error_found = 1;
15638 }
15639
15640 if (error_found)
15641 return error_mark_node;
15642
15643 /* If we're processing a `return' statement, promote the actual type
15644 to the promoted type. */
15645 if (is_return)
15646 new_rhs = convert (TREE_TYPE (lvalue), new_rhs);
15647
15648 /* 10.10: Array Store Exception runtime check */
15649 if (!flag_emit_class_files
15650 && !flag_emit_xref
15651 && lvalue_from_array
15652 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
15653 {
15654 tree array, store_check, base, index_expr;
15655
15656 /* Save RHS so that it doesn't get re-evaluated by the store check. */
15657 new_rhs = save_expr (new_rhs);
15658
15659 /* Get the INDIRECT_REF. */
15660 array = TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0);
15661 /* Get the array pointer expr. */
15662 array = TREE_OPERAND (array, 0);
15663 store_check = build_java_arraystore_check (array, new_rhs);
15664
15665 index_expr = TREE_OPERAND (lvalue, 1);
15666
15667 if (TREE_CODE (index_expr) == COMPOUND_EXPR)
15668 {
15669 /* A COMPOUND_EXPR here is a bounds check. The bounds check must
15670 happen before the store check, so prepare to insert the store
15671 check within the second operand of the existing COMPOUND_EXPR. */
15672 base = index_expr;
15673 }
15674 else
15675 base = lvalue;
15676
15677 index_expr = TREE_OPERAND (base, 1);
15678 TREE_OPERAND (base, 1) = build (COMPOUND_EXPR, TREE_TYPE (index_expr),
15679 store_check, index_expr);
15680 }
15681
15682 /* Final locals can be used as case values in switch
15683 statement. Prepare them for this eventuality. */
15684 if (TREE_CODE (lvalue) == VAR_DECL
15685 && DECL_FINAL (lvalue)
15686 && TREE_CONSTANT (new_rhs)
15687 && IDENTIFIER_LOCAL_VALUE (DECL_NAME (lvalue))
15688 && JINTEGRAL_TYPE_P (TREE_TYPE (lvalue))
15689 )
15690 {
15691 TREE_CONSTANT (lvalue) = 1;
15692 DECL_INITIAL (lvalue) = new_rhs;
15693 }
15694
15695 /* Copy the rhs if it's a reference. */
15696 if (! flag_check_references && ! flag_emit_class_files && optimize > 0)
15697 {
15698 switch (TREE_CODE (new_rhs))
15699 {
15700 case ARRAY_REF:
15701 case INDIRECT_REF:
15702 case COMPONENT_REF:
15703 /* Transform a = foo.bar
15704 into a = { int tmp; tmp = foo.bar; tmp; ).
15705 We need to ensure that if a read from memory fails
15706 because of a NullPointerException, a destination variable
15707 will remain unchanged. An explicit temporary does what
15708 we need.
15709
15710 If flag_check_references is set, this is unnecessary
15711 because we'll check each reference before doing any
15712 reads. If optimize is not set the result will never be
15713 written to a stack slot that contains the LHS. */
15714 {
15715 tree tmp = build_decl (VAR_DECL, get_identifier ("<tmp>"),
15716 TREE_TYPE (new_rhs));
15717 tree block = make_node (BLOCK);
15718 tree assignment
15719 = build (MODIFY_EXPR, TREE_TYPE (new_rhs), tmp, fold (new_rhs));
15720 DECL_CONTEXT (tmp) = current_function_decl;
15721 TREE_TYPE (block) = TREE_TYPE (new_rhs);
15722 BLOCK_VARS (block) = tmp;
15723 BLOCK_EXPR_BODY (block)
15724 = build (COMPOUND_EXPR, TREE_TYPE (new_rhs), assignment, tmp);
15725 TREE_SIDE_EFFECTS (block) = 1;
15726 new_rhs = block;
15727 }
15728 break;
15729 default:
15730 break;
15731 }
15732 }
15733
15734 TREE_OPERAND (node, 0) = lvalue;
15735 TREE_OPERAND (node, 1) = new_rhs;
15736 TREE_TYPE (node) = lhs_type;
15737 return node;
15738 }
15739
15740 /* Check that type SOURCE can be cast into type DEST. If the cast
15741 can't occur at all, return NULL; otherwise, return a possibly
15742 modified rhs. */
15743
15744 static tree
try_reference_assignconv(tree lhs_type,tree rhs)15745 try_reference_assignconv (tree lhs_type, tree rhs)
15746 {
15747 tree new_rhs = NULL_TREE;
15748 tree rhs_type = TREE_TYPE (rhs);
15749
15750 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
15751 {
15752 /* `null' may be assigned to any reference type */
15753 if (rhs == null_pointer_node)
15754 new_rhs = null_pointer_node;
15755 /* Try the reference assignment conversion */
15756 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
15757 new_rhs = rhs;
15758 /* This is a magic assignment that we process differently */
15759 else if (TREE_CODE (rhs) == JAVA_EXC_OBJ_EXPR)
15760 new_rhs = rhs;
15761 }
15762 return new_rhs;
15763 }
15764
15765 /* Check that RHS can be converted into LHS_TYPE by the assignment
15766 conversion (5.2), for the cases of RHS being a builtin type. Return
15767 NULL_TREE if the conversion fails or if because RHS isn't of a
15768 builtin type. Return a converted RHS if the conversion is possible. */
15769
15770 static tree
try_builtin_assignconv(tree wfl_op1,tree lhs_type,tree rhs)15771 try_builtin_assignconv (tree wfl_op1, tree lhs_type, tree rhs)
15772 {
15773 tree new_rhs = NULL_TREE;
15774 tree rhs_type = TREE_TYPE (rhs);
15775
15776 /* Handle boolean specially. */
15777 if (TREE_CODE (rhs_type) == BOOLEAN_TYPE
15778 || TREE_CODE (lhs_type) == BOOLEAN_TYPE)
15779 {
15780 if (TREE_CODE (rhs_type) == BOOLEAN_TYPE
15781 && TREE_CODE (lhs_type) == BOOLEAN_TYPE)
15782 new_rhs = rhs;
15783 }
15784
15785 /* 5.1.1 Try Identity Conversion,
15786 5.1.2 Try Widening Primitive Conversion */
15787 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
15788 new_rhs = convert (lhs_type, rhs);
15789
15790 /* Try a narrowing primitive conversion (5.1.3):
15791 - expression is a constant expression of type byte, short, char,
15792 or int, AND
15793 - variable is byte, short or char AND
15794 - The value of the expression is representable in the type of the
15795 variable */
15796 else if ((rhs_type == byte_type_node || rhs_type == short_type_node
15797 || rhs_type == char_type_node || rhs_type == int_type_node)
15798 && TREE_CONSTANT (rhs)
15799 && (lhs_type == byte_type_node || lhs_type == char_type_node
15800 || lhs_type == short_type_node))
15801 {
15802 if (int_fits_type_p (rhs, lhs_type))
15803 new_rhs = convert (lhs_type, rhs);
15804 else if (wfl_op1) /* Might be called with a NULL */
15805 parse_warning_context
15806 (wfl_op1, "Constant expression `%s' too wide for narrowing primitive conversion to `%s'",
15807 print_int_node (rhs), lang_printable_name (lhs_type, 0));
15808 /* Reported a warning that will turn into an error further
15809 down, so we don't return */
15810 }
15811
15812 return new_rhs;
15813 }
15814
15815 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
15816 conversion (5.1.1) or widening primitive conversion (5.1.2). Return
15817 0 is the conversion test fails. This implements parts the method
15818 invocation conversion (5.3). */
15819
15820 static int
valid_builtin_assignconv_identity_widening_p(tree lhs_type,tree rhs_type)15821 valid_builtin_assignconv_identity_widening_p (tree lhs_type, tree rhs_type)
15822 {
15823 /* 5.1.1: This is the identity conversion part. */
15824 if (lhs_type == rhs_type)
15825 return 1;
15826
15827 /* Reject non primitive types and boolean conversions. */
15828 if (!JNUMERIC_TYPE_P (lhs_type) || !JNUMERIC_TYPE_P (rhs_type))
15829 return 0;
15830
15831 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
15832 than a char can't be converted into a char. Short can't too, but
15833 the < test below takes care of that */
15834 if (lhs_type == char_type_node && rhs_type == byte_type_node)
15835 return 0;
15836
15837 /* Accept all promoted type here. Note, we can't use <= in the test
15838 below, because we still need to bounce out assignments of short
15839 to char and the likes */
15840 if (lhs_type == int_type_node
15841 && (rhs_type == promoted_byte_type_node
15842 || rhs_type == promoted_short_type_node
15843 || rhs_type == promoted_char_type_node
15844 || rhs_type == promoted_boolean_type_node))
15845 return 1;
15846
15847 /* From here, an integral is widened if its precision is smaller
15848 than the precision of the LHS or if the LHS is a floating point
15849 type, or the RHS is a float and the RHS a double. */
15850 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
15851 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
15852 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
15853 || (rhs_type == float_type_node && lhs_type == double_type_node))
15854 return 1;
15855
15856 return 0;
15857 }
15858
15859 /* Check that something of SOURCE type can be assigned or cast to
15860 something of DEST type at runtime. Return 1 if the operation is
15861 valid, 0 otherwise. If CAST is set to 1, we're treating the case
15862 were SOURCE is cast into DEST, which borrows a lot of the
15863 assignment check. */
15864
15865 static int
valid_ref_assignconv_cast_p(tree source,tree dest,int cast)15866 valid_ref_assignconv_cast_p (tree source, tree dest, int cast)
15867 {
15868 /* SOURCE or DEST might be null if not from a declared entity. */
15869 if (!source || !dest)
15870 return 0;
15871 if (JNULLP_TYPE_P (source))
15872 return 1;
15873 if (TREE_CODE (source) == POINTER_TYPE)
15874 source = TREE_TYPE (source);
15875 if (TREE_CODE (dest) == POINTER_TYPE)
15876 dest = TREE_TYPE (dest);
15877
15878 /* If source and dest are being compiled from bytecode, they may need to
15879 be loaded. */
15880 if (CLASS_P (source) && !CLASS_LOADED_P (source))
15881 {
15882 load_class (source, 1);
15883 safe_layout_class (source);
15884 }
15885 if (CLASS_P (dest) && !CLASS_LOADED_P (dest))
15886 {
15887 load_class (dest, 1);
15888 safe_layout_class (dest);
15889 }
15890
15891 /* Case where SOURCE is a class type */
15892 if (TYPE_CLASS_P (source))
15893 {
15894 if (TYPE_CLASS_P (dest))
15895 return (source == dest
15896 || inherits_from_p (source, dest)
15897 || (cast && inherits_from_p (dest, source)));
15898 if (TYPE_INTERFACE_P (dest))
15899 {
15900 /* If doing a cast and SOURCE is final, the operation is
15901 always correct a compile time (because even if SOURCE
15902 does not implement DEST, a subclass of SOURCE might). */
15903 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
15904 return 1;
15905 /* Otherwise, SOURCE must implement DEST */
15906 return interface_of_p (dest, source);
15907 }
15908 /* DEST is an array, cast permitted if SOURCE is of Object type */
15909 return (cast && source == object_type_node ? 1 : 0);
15910 }
15911 if (TYPE_INTERFACE_P (source))
15912 {
15913 if (TYPE_CLASS_P (dest))
15914 {
15915 /* If not casting, DEST must be the Object type */
15916 if (!cast)
15917 return dest == object_type_node;
15918 /* We're doing a cast. The cast is always valid is class
15919 DEST is not final, otherwise, DEST must implement SOURCE */
15920 else if (!CLASS_FINAL (TYPE_NAME (dest)))
15921 return 1;
15922 else
15923 return interface_of_p (source, dest);
15924 }
15925 if (TYPE_INTERFACE_P (dest))
15926 {
15927 /* If doing a cast, then if SOURCE and DEST contain method
15928 with the same signature but different return type, then
15929 this is a (compile time) error */
15930 if (cast)
15931 {
15932 tree method_source, method_dest;
15933 tree source_type;
15934 tree source_sig;
15935 tree source_name;
15936 for (method_source = TYPE_METHODS (source); method_source;
15937 method_source = TREE_CHAIN (method_source))
15938 {
15939 source_sig =
15940 build_java_argument_signature (TREE_TYPE (method_source));
15941 source_type = TREE_TYPE (TREE_TYPE (method_source));
15942 source_name = DECL_NAME (method_source);
15943 for (method_dest = TYPE_METHODS (dest);
15944 method_dest; method_dest = TREE_CHAIN (method_dest))
15945 if (source_sig ==
15946 build_java_argument_signature (TREE_TYPE (method_dest))
15947 && source_name == DECL_NAME (method_dest)
15948 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
15949 return 0;
15950 }
15951 return 1;
15952 }
15953 else
15954 return source == dest || interface_of_p (dest, source);
15955 }
15956 else
15957 {
15958 /* Array */
15959 return (cast
15960 && (DECL_NAME (TYPE_NAME (source))
15961 == java_lang_cloneable_identifier_node
15962 || (DECL_NAME (TYPE_NAME (source))
15963 == java_io_serializable_identifier_node)));
15964 }
15965 }
15966 if (TYPE_ARRAY_P (source))
15967 {
15968 if (TYPE_CLASS_P (dest))
15969 return dest == object_type_node;
15970 /* Can't cast an array to an interface unless the interface is
15971 java.lang.Cloneable or java.io.Serializable. */
15972 if (TYPE_INTERFACE_P (dest))
15973 return (DECL_NAME (TYPE_NAME (dest))
15974 == java_lang_cloneable_identifier_node
15975 || (DECL_NAME (TYPE_NAME (dest))
15976 == java_io_serializable_identifier_node));
15977 else /* Arrays */
15978 {
15979 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
15980 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
15981
15982 /* In case of severe errors, they turn out null */
15983 if (!dest_element_type || !source_element_type)
15984 return 0;
15985 if (source_element_type == dest_element_type)
15986 return 1;
15987 return valid_ref_assignconv_cast_p (source_element_type,
15988 dest_element_type, cast);
15989 }
15990 return 0;
15991 }
15992 return 0;
15993 }
15994
15995 static int
valid_cast_to_p(tree source,tree dest)15996 valid_cast_to_p (tree source, tree dest)
15997 {
15998 if (TREE_CODE (source) == POINTER_TYPE)
15999 source = TREE_TYPE (source);
16000 if (TREE_CODE (dest) == POINTER_TYPE)
16001 dest = TREE_TYPE (dest);
16002
16003 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
16004 return valid_ref_assignconv_cast_p (source, dest, 1);
16005
16006 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
16007 return 1;
16008
16009 else if (TREE_CODE (source) == BOOLEAN_TYPE
16010 && TREE_CODE (dest) == BOOLEAN_TYPE)
16011 return 1;
16012
16013 return 0;
16014 }
16015
16016 static tree
do_unary_numeric_promotion(tree arg)16017 do_unary_numeric_promotion (tree arg)
16018 {
16019 tree type = TREE_TYPE (arg);
16020 if ((TREE_CODE (type) == INTEGER_TYPE && TYPE_PRECISION (type) < 32)
16021 || TREE_CODE (type) == CHAR_TYPE)
16022 arg = convert (int_type_node, arg);
16023 return arg;
16024 }
16025
16026 /* Return a nonzero value if SOURCE can be converted into DEST using
16027 the method invocation conversion rule (5.3). */
16028 static int
valid_method_invocation_conversion_p(tree dest,tree source)16029 valid_method_invocation_conversion_p (tree dest, tree source)
16030 {
16031 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
16032 && valid_builtin_assignconv_identity_widening_p (dest, source))
16033 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
16034 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
16035 && valid_ref_assignconv_cast_p (source, dest, 0)));
16036 }
16037
16038 /* Build an incomplete binop expression. */
16039
16040 static tree
build_binop(enum tree_code op,int op_location,tree op1,tree op2)16041 build_binop (enum tree_code op, int op_location, tree op1, tree op2)
16042 {
16043 tree binop = build (op, NULL_TREE, op1, op2);
16044 TREE_SIDE_EFFECTS (binop) = 1;
16045 /* Store the location of the operator, for better error report. The
16046 string of the operator will be rebuild based on the OP value. */
16047 EXPR_WFL_LINECOL (binop) = op_location;
16048 return binop;
16049 }
16050
16051 /* Build the string of the operator retained by NODE. If NODE is part
16052 of a compound expression, add an '=' at the end of the string. This
16053 function is called when an error needs to be reported on an
16054 operator. The string is returned as a pointer to a static character
16055 buffer. */
16056
16057 static char *
operator_string(tree node)16058 operator_string (tree node)
16059 {
16060 #define BUILD_OPERATOR_STRING(S) \
16061 { \
16062 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
16063 return buffer; \
16064 }
16065
16066 static char buffer [10];
16067 switch (TREE_CODE (node))
16068 {
16069 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
16070 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
16071 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
16072 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
16073 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
16074 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
16075 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
16076 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
16077 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
16078 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
16079 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
16080 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
16081 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
16082 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
16083 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
16084 case GT_EXPR: BUILD_OPERATOR_STRING (">");
16085 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
16086 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
16087 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
16088 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
16089 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
16090 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
16091 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
16092 case PREINCREMENT_EXPR: /* Fall through */
16093 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
16094 case PREDECREMENT_EXPR: /* Fall through */
16095 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
16096 default:
16097 internal_error ("unregistered operator %s",
16098 tree_code_name [TREE_CODE (node)]);
16099 }
16100 return NULL;
16101 #undef BUILD_OPERATOR_STRING
16102 }
16103
16104 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
16105
16106 static int
java_decl_equiv(tree var_acc1,tree var_acc2)16107 java_decl_equiv (tree var_acc1, tree var_acc2)
16108 {
16109 if (JDECL_P (var_acc1))
16110 return (var_acc1 == var_acc2);
16111
16112 return (TREE_CODE (var_acc1) == COMPONENT_REF
16113 && TREE_CODE (var_acc2) == COMPONENT_REF
16114 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
16115 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
16116 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
16117 }
16118
16119 /* Return a nonzero value if CODE is one of the operators that can be
16120 used in conjunction with the `=' operator in a compound assignment. */
16121
16122 static int
binop_compound_p(enum tree_code code)16123 binop_compound_p (enum tree_code code)
16124 {
16125 int i;
16126 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
16127 if (binop_lookup [i] == code)
16128 break;
16129
16130 return i < BINOP_COMPOUND_CANDIDATES;
16131 }
16132
16133 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
16134
16135 static tree
java_refold(tree t)16136 java_refold (tree t)
16137 {
16138 tree c, b, ns, decl;
16139
16140 if (TREE_CODE (t) != MODIFY_EXPR)
16141 return t;
16142
16143 c = TREE_OPERAND (t, 1);
16144 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
16145 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
16146 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
16147 return t;
16148
16149 /* Now the left branch of the binary operator. */
16150 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
16151 if (! (b && TREE_CODE (b) == NOP_EXPR
16152 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
16153 return t;
16154
16155 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
16156 if (! (ns && TREE_CODE (ns) == NOP_EXPR
16157 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
16158 return t;
16159
16160 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
16161 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
16162 /* It's got to be the an equivalent decl */
16163 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
16164 {
16165 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
16166 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
16167 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
16168 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
16169 /* Change the right part of the BINOP_EXPR */
16170 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
16171 }
16172
16173 return t;
16174 }
16175
16176 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
16177 errors but we modify NODE so that it contains the type computed
16178 according to the expression, when it's fixed. Otherwise, we write
16179 error_mark_node as the type. It allows us to further the analysis
16180 of remaining nodes and detects more errors in certain cases. */
16181
16182 static tree
patch_binop(tree node,tree wfl_op1,tree wfl_op2)16183 patch_binop (tree node, tree wfl_op1, tree wfl_op2)
16184 {
16185 tree op1 = TREE_OPERAND (node, 0);
16186 tree op2 = TREE_OPERAND (node, 1);
16187 tree op1_type = TREE_TYPE (op1);
16188 tree op2_type = TREE_TYPE (op2);
16189 tree prom_type = NULL_TREE, cn;
16190 enum tree_code code = TREE_CODE (node);
16191
16192 /* If 1, tell the routine that we have to return error_mark_node
16193 after checking for the initialization of the RHS */
16194 int error_found = 0;
16195
16196 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16197
16198 /* If either op<n>_type are NULL, this might be early signs of an
16199 error situation, unless it's too early to tell (in case we're
16200 handling a `+', `==', `!=' or `instanceof'.) We want to set op<n>_type
16201 correctly so the error can be later on reported accurately. */
16202 if (! (code == PLUS_EXPR || code == NE_EXPR
16203 || code == EQ_EXPR || code == INSTANCEOF_EXPR))
16204 {
16205 tree n;
16206 if (! op1_type)
16207 {
16208 n = java_complete_tree (op1);
16209 op1_type = TREE_TYPE (n);
16210 }
16211 if (! op2_type)
16212 {
16213 n = java_complete_tree (op2);
16214 op2_type = TREE_TYPE (n);
16215 }
16216 }
16217
16218 switch (code)
16219 {
16220 /* 15.16 Multiplicative operators */
16221 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
16222 case RDIV_EXPR: /* 15.16.2 Division Operator / */
16223 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
16224 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
16225 if (!JNUMERIC_TYPE_P (op1_type) || !JNUMERIC_TYPE_P (op2_type))
16226 {
16227 if (!JNUMERIC_TYPE_P (op1_type))
16228 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
16229 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
16230 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
16231 TREE_TYPE (node) = error_mark_node;
16232 error_found = 1;
16233 break;
16234 }
16235 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
16236
16237 /* Detect integral division by zero */
16238 if ((code == RDIV_EXPR || code == TRUNC_MOD_EXPR)
16239 && TREE_CODE (prom_type) == INTEGER_TYPE
16240 && (op2 == integer_zero_node || op2 == long_zero_node ||
16241 (TREE_CODE (op2) == INTEGER_CST &&
16242 ! TREE_INT_CST_LOW (op2) && ! TREE_INT_CST_HIGH (op2))))
16243 {
16244 parse_warning_context (wfl_operator, "Evaluating this expression will result in an arithmetic exception being thrown");
16245 TREE_CONSTANT (node) = 0;
16246 }
16247
16248 /* Change the division operator if necessary */
16249 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
16250 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
16251
16252 /* Before divisions as is disappear, try to simplify and bail if
16253 applicable, otherwise we won't perform even simple
16254 simplifications like (1-1)/3. We can't do that with floating
16255 point number, folds can't handle them at this stage. */
16256 if (code == RDIV_EXPR && TREE_CONSTANT (op1) && TREE_CONSTANT (op2)
16257 && JINTEGRAL_TYPE_P (op1) && JINTEGRAL_TYPE_P (op2))
16258 {
16259 TREE_TYPE (node) = prom_type;
16260 node = fold (node);
16261 if (TREE_CODE (node) != code)
16262 return node;
16263 }
16264
16265 if (TREE_CODE (prom_type) == INTEGER_TYPE
16266 && flag_use_divide_subroutine
16267 && ! flag_emit_class_files
16268 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
16269 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
16270
16271 /* This one is more complicated. FLOATs are processed by a
16272 function call to soft_fmod. Duplicate the value of the
16273 COMPOUND_ASSIGN_P flag. */
16274 if (code == TRUNC_MOD_EXPR)
16275 {
16276 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
16277 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
16278 TREE_SIDE_EFFECTS (mod)
16279 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
16280 return mod;
16281 }
16282 break;
16283
16284 /* 15.17 Additive Operators */
16285 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
16286
16287 /* Operation is valid if either one argument is a string
16288 constant, a String object or a StringBuffer crafted for the
16289 purpose of the a previous usage of the String concatenation
16290 operator */
16291
16292 if (TREE_CODE (op1) == STRING_CST
16293 || TREE_CODE (op2) == STRING_CST
16294 || JSTRING_TYPE_P (op1_type)
16295 || JSTRING_TYPE_P (op2_type)
16296 || IS_CRAFTED_STRING_BUFFER_P (op1)
16297 || IS_CRAFTED_STRING_BUFFER_P (op2))
16298 return build_string_concatenation (op1, op2);
16299
16300 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
16301 Numeric Types */
16302 if (!JNUMERIC_TYPE_P (op1_type) || !JNUMERIC_TYPE_P (op2_type))
16303 {
16304 if (!JNUMERIC_TYPE_P (op1_type))
16305 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
16306 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
16307 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
16308 TREE_TYPE (node) = error_mark_node;
16309 error_found = 1;
16310 break;
16311 }
16312 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
16313 break;
16314
16315 /* 15.18 Shift Operators */
16316 case LSHIFT_EXPR:
16317 case RSHIFT_EXPR:
16318 case URSHIFT_EXPR:
16319 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
16320 {
16321 if (!JINTEGRAL_TYPE_P (op1_type))
16322 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
16323 else
16324 {
16325 if (JNUMERIC_TYPE_P (op2_type))
16326 parse_error_context (wfl_operator,
16327 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
16328 operator_string (node),
16329 lang_printable_name (op2_type, 0));
16330 else
16331 parse_error_context (wfl_operator,
16332 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
16333 operator_string (node),
16334 lang_printable_name (op2_type, 0));
16335 }
16336 TREE_TYPE (node) = error_mark_node;
16337 error_found = 1;
16338 break;
16339 }
16340
16341 /* Unary numeric promotion (5.6.1) is performed on each operand
16342 separately */
16343 op1 = do_unary_numeric_promotion (op1);
16344 op2 = do_unary_numeric_promotion (op2);
16345
16346 /* If the right hand side is of type `long', first cast it to
16347 `int'. */
16348 if (TREE_TYPE (op2) == long_type_node)
16349 op2 = build1 (CONVERT_EXPR, int_type_node, op2);
16350
16351 /* The type of the shift expression is the type of the promoted
16352 type of the left-hand operand */
16353 prom_type = TREE_TYPE (op1);
16354
16355 /* Shift int only up to 0x1f and long up to 0x3f */
16356 if (prom_type == int_type_node)
16357 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
16358 build_int_2 (0x1f, 0)));
16359 else
16360 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
16361 build_int_2 (0x3f, 0)));
16362
16363 /* The >>> operator is a >> operating on unsigned quantities */
16364 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
16365 {
16366 tree to_return;
16367 tree utype = java_unsigned_type (prom_type);
16368 op1 = convert (utype, op1);
16369 TREE_SET_CODE (node, RSHIFT_EXPR);
16370 TREE_OPERAND (node, 0) = op1;
16371 TREE_OPERAND (node, 1) = op2;
16372 TREE_TYPE (node) = utype;
16373 to_return = convert (prom_type, node);
16374 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
16375 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
16376 TREE_SIDE_EFFECTS (to_return)
16377 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
16378 return to_return;
16379 }
16380 break;
16381
16382 /* 15.19.1 Type Comparison Operator instanceof */
16383 case INSTANCEOF_EXPR:
16384
16385 TREE_TYPE (node) = boolean_type_node;
16386
16387 /* OP1_TYPE might be NULL when OP1 is a string constant. */
16388 if ((cn = patch_string (op1)))
16389 {
16390 op1 = cn;
16391 op1_type = TREE_TYPE (op1);
16392 }
16393 if (op1_type == NULL_TREE)
16394 abort ();
16395
16396 if (!(op2_type = resolve_type_during_patch (op2)))
16397 return error_mark_node;
16398
16399 /* The first operand must be a reference type or the null type */
16400 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
16401 error_found = 1; /* Error reported further below */
16402
16403 /* The second operand must be a reference type */
16404 if (!JREFERENCE_TYPE_P (op2_type))
16405 {
16406 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
16407 parse_error_context
16408 (wfl_operator, "Invalid argument `%s' for `instanceof'",
16409 lang_printable_name (op2_type, 0));
16410 error_found = 1;
16411 }
16412
16413 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
16414 {
16415 /* If the first operand is null, the result is always false */
16416 if (op1 == null_pointer_node)
16417 return boolean_false_node;
16418 else if (flag_emit_class_files)
16419 {
16420 TREE_OPERAND (node, 1) = op2_type;
16421 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
16422 return node;
16423 }
16424 /* Otherwise we have to invoke instance of to figure it out */
16425 else
16426 return build_instanceof (op1, op2_type);
16427 }
16428 /* There is no way the expression operand can be an instance of
16429 the type operand. This is a compile time error. */
16430 else
16431 {
16432 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
16433 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16434 parse_error_context
16435 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
16436 t1, lang_printable_name (op2_type, 0));
16437 free (t1);
16438 error_found = 1;
16439 }
16440
16441 break;
16442
16443 /* 15.21 Bitwise and Logical Operators */
16444 case BIT_AND_EXPR:
16445 case BIT_XOR_EXPR:
16446 case BIT_IOR_EXPR:
16447 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
16448 /* Binary numeric promotion is performed on both operand and the
16449 expression retain that type */
16450 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
16451
16452 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
16453 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
16454 /* The type of the bitwise operator expression is BOOLEAN */
16455 prom_type = boolean_type_node;
16456 else
16457 {
16458 if (!JINTEGRAL_TYPE_P (op1_type))
16459 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
16460 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
16461 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
16462 TREE_TYPE (node) = error_mark_node;
16463 error_found = 1;
16464 /* Insert a break here if adding thing before the switch's
16465 break for this case */
16466 }
16467 break;
16468
16469 /* 15.22 Conditional-And Operator */
16470 case TRUTH_ANDIF_EXPR:
16471 /* 15.23 Conditional-Or Operator */
16472 case TRUTH_ORIF_EXPR:
16473 /* Operands must be of BOOLEAN type */
16474 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
16475 TREE_CODE (op2_type) != BOOLEAN_TYPE)
16476 {
16477 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
16478 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
16479 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
16480 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
16481 TREE_TYPE (node) = boolean_type_node;
16482 error_found = 1;
16483 break;
16484 }
16485 else if (integer_zerop (op1))
16486 {
16487 return code == TRUTH_ANDIF_EXPR ? op1 : op2;
16488 }
16489 else if (integer_onep (op1))
16490 {
16491 return code == TRUTH_ANDIF_EXPR ? op2 : op1;
16492 }
16493 /* The type of the conditional operators is BOOLEAN */
16494 prom_type = boolean_type_node;
16495 break;
16496
16497 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
16498 case LT_EXPR:
16499 case GT_EXPR:
16500 case LE_EXPR:
16501 case GE_EXPR:
16502 /* The type of each of the operands must be a primitive numeric
16503 type */
16504 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
16505 {
16506 if (!JNUMERIC_TYPE_P (op1_type))
16507 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
16508 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
16509 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
16510 TREE_TYPE (node) = boolean_type_node;
16511 error_found = 1;
16512 break;
16513 }
16514 /* Binary numeric promotion is performed on the operands */
16515 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
16516 /* The type of the relation expression is always BOOLEAN */
16517 prom_type = boolean_type_node;
16518 break;
16519
16520 /* 15.20 Equality Operator */
16521 case EQ_EXPR:
16522 case NE_EXPR:
16523 /* It's time for us to patch the strings. */
16524 if ((cn = patch_string (op1)))
16525 {
16526 op1 = cn;
16527 op1_type = TREE_TYPE (op1);
16528 }
16529 if ((cn = patch_string (op2)))
16530 {
16531 op2 = cn;
16532 op2_type = TREE_TYPE (op2);
16533 }
16534
16535 /* 15.20.1 Numerical Equality Operators == and != */
16536 /* Binary numeric promotion is performed on the operands */
16537 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
16538 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
16539
16540 /* 15.20.2 Boolean Equality Operators == and != */
16541 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
16542 TREE_CODE (op2_type) == BOOLEAN_TYPE)
16543 ; /* Nothing to do here */
16544
16545 /* 15.20.3 Reference Equality Operators == and != */
16546 /* Types have to be either references or the null type. If
16547 they're references, it must be possible to convert either
16548 type to the other by casting conversion. */
16549 else if (op1 == null_pointer_node || op2 == null_pointer_node
16550 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
16551 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
16552 || valid_ref_assignconv_cast_p (op2_type,
16553 op1_type, 1))))
16554 ; /* Nothing to do here */
16555
16556 /* Else we have an error figure what can't be converted into
16557 what and report the error */
16558 else
16559 {
16560 char *t1;
16561 t1 = xstrdup (lang_printable_name (op1_type, 0));
16562 parse_error_context
16563 (wfl_operator,
16564 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
16565 operator_string (node), t1,
16566 lang_printable_name (op2_type, 0));
16567 free (t1);
16568 TREE_TYPE (node) = boolean_type_node;
16569 error_found = 1;
16570 break;
16571 }
16572 prom_type = boolean_type_node;
16573 break;
16574 default:
16575 abort ();
16576 }
16577
16578 if (error_found)
16579 return error_mark_node;
16580
16581 TREE_OPERAND (node, 0) = op1;
16582 TREE_OPERAND (node, 1) = op2;
16583 TREE_TYPE (node) = prom_type;
16584 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
16585
16586 if (flag_emit_xref)
16587 return node;
16588
16589 /* fold does not respect side-effect order as required for Java but not C.
16590 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
16591 * bytecode.
16592 */
16593 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
16594 : ! TREE_SIDE_EFFECTS (node))
16595 node = fold (node);
16596 return node;
16597 }
16598
16599 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
16600 zero value, the value of CSTE comes after the valude of STRING */
16601
16602 static tree
do_merge_string_cste(tree cste,const char * string,int string_len,int after)16603 do_merge_string_cste (tree cste, const char *string, int string_len, int after)
16604 {
16605 const char *old = TREE_STRING_POINTER (cste);
16606 int old_len = TREE_STRING_LENGTH (cste);
16607 int len = old_len + string_len;
16608 char *new = alloca (len+1);
16609
16610 if (after)
16611 {
16612 memcpy (new, string, string_len);
16613 memcpy (&new [string_len], old, old_len);
16614 }
16615 else
16616 {
16617 memcpy (new, old, old_len);
16618 memcpy (&new [old_len], string, string_len);
16619 }
16620 new [len] = '\0';
16621 return build_string (len, new);
16622 }
16623
16624 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
16625 new STRING_CST on success, NULL_TREE on failure. */
16626
16627 static tree
merge_string_cste(tree op1,tree op2,int after)16628 merge_string_cste (tree op1, tree op2, int after)
16629 {
16630 /* Handle two string constants right away. */
16631 if (TREE_CODE (op2) == STRING_CST)
16632 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
16633 TREE_STRING_LENGTH (op2), after);
16634
16635 /* Reasonable integer constant can be treated right away. */
16636 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
16637 {
16638 static const char *const boolean_true = "true";
16639 static const char *const boolean_false = "false";
16640 static const char *const null_pointer = "null";
16641 char ch[4];
16642 const char *string;
16643
16644 if (op2 == boolean_true_node)
16645 string = boolean_true;
16646 else if (op2 == boolean_false_node)
16647 string = boolean_false;
16648 else if (op2 == null_pointer_node
16649 || (integer_zerop (op2)
16650 && TREE_CODE (TREE_TYPE (op2)) == POINTER_TYPE))
16651 /* FIXME: null is not a compile-time constant, so it is only safe to
16652 merge if the overall expression is non-constant. However, this
16653 code always merges without checking the overall expression. */
16654 string = null_pointer;
16655 else if (TREE_TYPE (op2) == char_type_node)
16656 {
16657 /* Convert the character into UTF-8. */
16658 unsigned int c = (unsigned int) TREE_INT_CST_LOW (op2);
16659 unsigned char *p = (unsigned char *) ch;
16660 if (0x01 <= c && c <= 0x7f)
16661 *p++ = (unsigned char) c;
16662 else if (c < 0x7ff)
16663 {
16664 *p++ = (unsigned char) (c >> 6 | 0xc0);
16665 *p++ = (unsigned char) ((c & 0x3f) | 0x80);
16666 }
16667 else
16668 {
16669 *p++ = (unsigned char) (c >> 12 | 0xe0);
16670 *p++ = (unsigned char) (((c >> 6) & 0x3f) | 0x80);
16671 *p++ = (unsigned char) ((c & 0x3f) | 0x80);
16672 }
16673 *p = '\0';
16674
16675 string = ch;
16676 }
16677 else
16678 string = string_convert_int_cst (op2);
16679
16680 return do_merge_string_cste (op1, string, strlen (string), after);
16681 }
16682 return NULL_TREE;
16683 }
16684
16685 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
16686 has to be a STRING_CST and the other part must be a STRING_CST or a
16687 INTEGRAL constant. Return a new STRING_CST if the operation
16688 succeed, NULL_TREE otherwise.
16689
16690 If the case we want to optimize for space, we might want to return
16691 NULL_TREE for each invocation of this routine. FIXME */
16692
16693 static tree
string_constant_concatenation(tree op1,tree op2)16694 string_constant_concatenation (tree op1, tree op2)
16695 {
16696 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
16697 {
16698 tree string, rest;
16699 int invert;
16700
16701 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
16702 rest = (string == op1 ? op2 : op1);
16703 invert = (string == op1 ? 0 : 1 );
16704
16705 /* Walk REST, only if it looks reasonable */
16706 if (TREE_CODE (rest) != STRING_CST
16707 && !IS_CRAFTED_STRING_BUFFER_P (rest)
16708 && !JSTRING_TYPE_P (TREE_TYPE (rest))
16709 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
16710 {
16711 rest = java_complete_tree (rest);
16712 if (rest == error_mark_node)
16713 return error_mark_node;
16714 rest = fold (rest);
16715 }
16716 return merge_string_cste (string, rest, invert);
16717 }
16718 return NULL_TREE;
16719 }
16720
16721 /* Implement the `+' operator. Does static optimization if possible,
16722 otherwise create (if necessary) and append elements to a
16723 StringBuffer. The StringBuffer will be carried around until it is
16724 used for a function call or an assignment. Then toString() will be
16725 called on it to turn it into a String object. */
16726
16727 static tree
build_string_concatenation(tree op1,tree op2)16728 build_string_concatenation (tree op1, tree op2)
16729 {
16730 tree result;
16731 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
16732
16733 if (flag_emit_xref)
16734 return build (PLUS_EXPR, string_type_node, op1, op2);
16735
16736 /* Try to do some static optimization */
16737 if ((result = string_constant_concatenation (op1, op2)))
16738 return result;
16739
16740 /* Discard empty strings on either side of the expression */
16741 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
16742 {
16743 op1 = op2;
16744 op2 = NULL_TREE;
16745 }
16746 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
16747 op2 = NULL_TREE;
16748
16749 /* If operands are string constant, turn then into object references */
16750 if (TREE_CODE (op1) == STRING_CST)
16751 op1 = patch_string_cst (op1);
16752 if (op2 && TREE_CODE (op2) == STRING_CST)
16753 op2 = patch_string_cst (op2);
16754
16755 /* If either one of the constant is null and the other non null
16756 operand is a String constant, return it. */
16757 if ((TREE_CODE (op1) == STRING_CST) && !op2)
16758 return op1;
16759
16760 /* If OP1 isn't already a StringBuffer, create and
16761 initialize a new one */
16762 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
16763 {
16764 /* Two solutions here:
16765 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
16766 2) OP1 is something else, we call new StringBuffer().append(OP1). */
16767 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
16768 op1 = BUILD_STRING_BUFFER (op1);
16769 else
16770 {
16771 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
16772 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
16773 }
16774 }
16775
16776 if (op2)
16777 {
16778 /* OP1 is no longer the last node holding a crafted StringBuffer */
16779 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
16780 /* Create a node for `{new...,xxx}.append (op2)' */
16781 if (op2)
16782 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
16783 }
16784
16785 /* Mark the last node holding a crafted StringBuffer */
16786 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
16787
16788 TREE_SIDE_EFFECTS (op1) = side_effects;
16789 return op1;
16790 }
16791
16792 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
16793 StringBuffer. If no string were found to be patched, return
16794 NULL. */
16795
16796 static tree
patch_string(tree node)16797 patch_string (tree node)
16798 {
16799 if (node == error_mark_node)
16800 return error_mark_node;
16801 if (TREE_CODE (node) == STRING_CST)
16802 return patch_string_cst (node);
16803 else if (IS_CRAFTED_STRING_BUFFER_P (node))
16804 {
16805 int saved = ctxp->explicit_constructor_p;
16806 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
16807 tree ret;
16808 /* Temporary disable forbid the use of `this'. */
16809 ctxp->explicit_constructor_p = 0;
16810 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
16811 /* String concatenation arguments must be evaluated in order too. */
16812 ret = force_evaluation_order (ret);
16813 /* Restore it at its previous value */
16814 ctxp->explicit_constructor_p = saved;
16815 return ret;
16816 }
16817 return NULL_TREE;
16818 }
16819
16820 /* Build the internal representation of a string constant. */
16821
16822 static tree
patch_string_cst(tree node)16823 patch_string_cst (tree node)
16824 {
16825 int location;
16826 if (! flag_emit_class_files)
16827 {
16828 node = get_identifier (TREE_STRING_POINTER (node));
16829 location = alloc_name_constant (CONSTANT_String, node);
16830 node = build_ref_from_constant_pool (location);
16831 }
16832 TREE_TYPE (node) = string_ptr_type_node;
16833 TREE_CONSTANT (node) = 1;
16834 return node;
16835 }
16836
16837 /* Build an incomplete unary operator expression. */
16838
16839 static tree
build_unaryop(int op_token,int op_location,tree op1)16840 build_unaryop (int op_token, int op_location, tree op1)
16841 {
16842 enum tree_code op;
16843 tree unaryop;
16844 switch (op_token)
16845 {
16846 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
16847 case MINUS_TK: op = NEGATE_EXPR; break;
16848 case NEG_TK: op = TRUTH_NOT_EXPR; break;
16849 case NOT_TK: op = BIT_NOT_EXPR; break;
16850 default: abort ();
16851 }
16852
16853 unaryop = build1 (op, NULL_TREE, op1);
16854 TREE_SIDE_EFFECTS (unaryop) = 1;
16855 /* Store the location of the operator, for better error report. The
16856 string of the operator will be rebuild based on the OP value. */
16857 EXPR_WFL_LINECOL (unaryop) = op_location;
16858 return unaryop;
16859 }
16860
16861 /* Special case for the ++/-- operators, since they require an extra
16862 argument to build, which is set to NULL and patched
16863 later. IS_POST_P is 1 if the operator, 0 otherwise. */
16864
16865 static tree
build_incdec(int op_token,int op_location,tree op1,int is_post_p)16866 build_incdec (int op_token, int op_location, tree op1, int is_post_p)
16867 {
16868 static const enum tree_code lookup [2][2] =
16869 {
16870 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
16871 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
16872 };
16873 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
16874 NULL_TREE, op1, NULL_TREE);
16875 TREE_SIDE_EFFECTS (node) = 1;
16876 /* Store the location of the operator, for better error report. The
16877 string of the operator will be rebuild based on the OP value. */
16878 EXPR_WFL_LINECOL (node) = op_location;
16879 return node;
16880 }
16881
16882 /* Build an incomplete cast operator, based on the use of the
16883 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
16884 set. java_complete_tree is trained to walk a CONVERT_EXPR even
16885 though its type is already set. */
16886
16887 static tree
build_cast(int location,tree type,tree exp)16888 build_cast (int location, tree type, tree exp)
16889 {
16890 tree node = build1 (CONVERT_EXPR, type, exp);
16891 EXPR_WFL_LINECOL (node) = location;
16892 return node;
16893 }
16894
16895 /* Build an incomplete class reference operator. */
16896 static tree
build_incomplete_class_ref(int location,tree class_name)16897 build_incomplete_class_ref (int location, tree class_name)
16898 {
16899 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
16900 tree class_decl = GET_CPC ();
16901 tree this_class = TREE_TYPE (class_decl);
16902
16903 /* Generate the synthetic static method `class$'. (Previously we
16904 deferred this, causing different method tables to be emitted
16905 for native code and bytecode.) */
16906 if (!TYPE_DOT_CLASS (this_class)
16907 && !JPRIMITIVE_TYPE_P (class_name)
16908 && !(TREE_CODE (class_name) == VOID_TYPE))
16909 {
16910 tree target_class;
16911
16912 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
16913 {
16914 /* For interfaces, adding a static 'class$' method directly
16915 is illegal. So create an inner class to contain the new
16916 method. Empirically this matches the behavior of javac. */
16917 tree t = build_wfl_node (DECL_NAME (TYPE_NAME (object_type_node)));
16918 tree inner = create_anonymous_class (0, t);
16919 target_class = TREE_TYPE (inner);
16920 end_class_declaration (1);
16921 }
16922 else
16923 {
16924 /* For inner classes, add a 'class$' method to their outermost
16925 context, creating it if necessary. */
16926 while (INNER_CLASS_DECL_P (class_decl))
16927 class_decl = DECL_CONTEXT (class_decl);
16928 target_class = TREE_TYPE (class_decl);
16929 }
16930
16931 if (TYPE_DOT_CLASS (target_class) == NULL_TREE)
16932 build_dot_class_method (target_class);
16933
16934 if (this_class != target_class)
16935 TYPE_DOT_CLASS (this_class) = TYPE_DOT_CLASS (target_class);
16936 }
16937
16938 EXPR_WFL_LINECOL (node) = location;
16939 return node;
16940 }
16941
16942 /* Complete an incomplete class reference operator. */
16943 static tree
patch_incomplete_class_ref(tree node)16944 patch_incomplete_class_ref (tree node)
16945 {
16946 tree type = TREE_OPERAND (node, 0);
16947 tree ref_type;
16948
16949 if (!(ref_type = resolve_type_during_patch (type)))
16950 return error_mark_node;
16951
16952 /* If we're not emitting class files and we know ref_type is a
16953 compiled class, build a direct reference. */
16954 if ((! flag_emit_class_files && is_compiled_class (ref_type))
16955 || JPRIMITIVE_TYPE_P (ref_type)
16956 || TREE_CODE (ref_type) == VOID_TYPE)
16957 {
16958 tree dot = build_class_ref (ref_type);
16959 /* A class referenced by `foo.class' is initialized. */
16960 if (!flag_emit_class_files)
16961 dot = build_class_init (ref_type, dot);
16962 return java_complete_tree (dot);
16963 }
16964
16965 /* If we're emitting class files and we have to deal with non
16966 primitive types, we invoke the synthetic static method `class$'. */
16967 ref_type = build_dot_class_method_invocation (current_class, ref_type);
16968 return java_complete_tree (ref_type);
16969 }
16970
16971 /* 15.14 Unary operators. We return error_mark_node in case of error,
16972 but preserve the type of NODE if the type is fixed. */
16973
16974 static tree
patch_unaryop(tree node,tree wfl_op)16975 patch_unaryop (tree node, tree wfl_op)
16976 {
16977 tree op = TREE_OPERAND (node, 0);
16978 tree op_type = TREE_TYPE (op);
16979 tree prom_type = NULL_TREE, value, decl;
16980 int outer_field_flag = 0;
16981 int code = TREE_CODE (node);
16982 int error_found = 0;
16983
16984 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16985
16986 switch (code)
16987 {
16988 /* 15.13.2 Postfix Increment Operator ++ */
16989 case POSTINCREMENT_EXPR:
16990 /* 15.13.3 Postfix Increment Operator -- */
16991 case POSTDECREMENT_EXPR:
16992 /* 15.14.1 Prefix Increment Operator ++ */
16993 case PREINCREMENT_EXPR:
16994 /* 15.14.2 Prefix Decrement Operator -- */
16995 case PREDECREMENT_EXPR:
16996 op = decl = strip_out_static_field_access_decl (op);
16997 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
16998 /* We might be trying to change an outer field accessed using
16999 access method. */
17000 if (outer_field_flag)
17001 {
17002 /* Retrieve the decl of the field we're trying to access. We
17003 do that by first retrieving the function we would call to
17004 access the field. It has been already verified that this
17005 field isn't final */
17006 if (flag_emit_class_files)
17007 decl = TREE_OPERAND (op, 0);
17008 else
17009 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
17010 decl = DECL_FUNCTION_ACCESS_DECL (decl);
17011 }
17012 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
17013 else if (!JDECL_P (decl)
17014 && TREE_CODE (decl) != COMPONENT_REF
17015 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
17016 && TREE_CODE (decl) != INDIRECT_REF
17017 && !(TREE_CODE (decl) == COMPOUND_EXPR
17018 && TREE_OPERAND (decl, 1)
17019 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
17020 {
17021 TREE_TYPE (node) = error_mark_node;
17022 error_found = 1;
17023 }
17024
17025 /* From now on, we know that op if a variable and that it has a
17026 valid wfl. We use wfl_op to locate errors related to the
17027 ++/-- operand. */
17028 if (!JNUMERIC_TYPE_P (op_type))
17029 {
17030 parse_error_context
17031 (wfl_op, "Invalid argument type `%s' to `%s'",
17032 lang_printable_name (op_type, 0), operator_string (node));
17033 TREE_TYPE (node) = error_mark_node;
17034 error_found = 1;
17035 }
17036 else
17037 {
17038 /* Before the addition, binary numeric promotion is performed on
17039 both operands, if really necessary */
17040 if (JINTEGRAL_TYPE_P (op_type))
17041 {
17042 value = build_int_2 (1, 0);
17043 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
17044 }
17045 else
17046 {
17047 value = build_int_2 (1, 0);
17048 TREE_TYPE (node) =
17049 binary_numeric_promotion (op_type,
17050 TREE_TYPE (value), &op, &value);
17051 }
17052
17053 /* We remember we might be accessing an outer field */
17054 if (outer_field_flag)
17055 {
17056 /* We re-generate an access to the field */
17057 value = build (PLUS_EXPR, TREE_TYPE (op),
17058 build_outer_field_access (wfl_op, decl), value);
17059
17060 /* And we patch the original access$() into a write
17061 with plus_op as a rhs */
17062 return outer_field_access_fix (node, op, value);
17063 }
17064
17065 /* And write back into the node. */
17066 TREE_OPERAND (node, 0) = op;
17067 TREE_OPERAND (node, 1) = value;
17068 /* Convert the overall back into its original type, if
17069 necessary, and return */
17070 if (JINTEGRAL_TYPE_P (op_type))
17071 return fold (node);
17072 else
17073 return fold (convert (op_type, node));
17074 }
17075 break;
17076
17077 /* 15.14.3 Unary Plus Operator + */
17078 case UNARY_PLUS_EXPR:
17079 /* 15.14.4 Unary Minus Operator - */
17080 case NEGATE_EXPR:
17081 if (!JNUMERIC_TYPE_P (op_type))
17082 {
17083 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
17084 TREE_TYPE (node) = error_mark_node;
17085 error_found = 1;
17086 }
17087 /* Unary numeric promotion is performed on operand */
17088 else
17089 {
17090 op = do_unary_numeric_promotion (op);
17091 prom_type = TREE_TYPE (op);
17092 if (code == UNARY_PLUS_EXPR)
17093 return fold (op);
17094 }
17095 break;
17096
17097 /* 15.14.5 Bitwise Complement Operator ~ */
17098 case BIT_NOT_EXPR:
17099 if (!JINTEGRAL_TYPE_P (op_type))
17100 {
17101 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
17102 TREE_TYPE (node) = error_mark_node;
17103 error_found = 1;
17104 }
17105 else
17106 {
17107 op = do_unary_numeric_promotion (op);
17108 prom_type = TREE_TYPE (op);
17109 }
17110 break;
17111
17112 /* 15.14.6 Logical Complement Operator ! */
17113 case TRUTH_NOT_EXPR:
17114 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
17115 {
17116 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
17117 /* But the type is known. We will report an error if further
17118 attempt of a assignment is made with this rhs */
17119 TREE_TYPE (node) = boolean_type_node;
17120 error_found = 1;
17121 }
17122 else
17123 prom_type = boolean_type_node;
17124 break;
17125
17126 /* 15.15 Cast Expression */
17127 case CONVERT_EXPR:
17128 value = patch_cast (node, wfl_operator);
17129 if (value == error_mark_node)
17130 {
17131 /* If this cast is part of an assignment, we tell the code
17132 that deals with it not to complain about a mismatch,
17133 because things have been cast, anyways */
17134 TREE_TYPE (node) = error_mark_node;
17135 error_found = 1;
17136 }
17137 else
17138 {
17139 value = fold (value);
17140 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
17141 return value;
17142 }
17143 break;
17144 }
17145
17146 if (error_found)
17147 return error_mark_node;
17148
17149 /* There are cases where node has been replaced by something else
17150 and we don't end up returning here: UNARY_PLUS_EXPR,
17151 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
17152 TREE_OPERAND (node, 0) = fold (op);
17153 TREE_TYPE (node) = prom_type;
17154 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
17155 return fold (node);
17156 }
17157
17158 /* Generic type resolution that sometimes takes place during node
17159 patching. Returned the resolved type or generate an error
17160 message. Return the resolved type or NULL_TREE. */
17161
17162 static tree
resolve_type_during_patch(tree type)17163 resolve_type_during_patch (tree type)
17164 {
17165 if (unresolved_type_p (type, NULL))
17166 {
17167 tree type_decl = resolve_and_layout (EXPR_WFL_NODE (type), type);
17168 if (!type_decl)
17169 {
17170 parse_error_context (type,
17171 "Class `%s' not found in type declaration",
17172 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
17173 return NULL_TREE;
17174 }
17175
17176 check_deprecation (type, type_decl);
17177
17178 return TREE_TYPE (type_decl);
17179 }
17180 return type;
17181 }
17182
17183 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
17184 found. Otherwise NODE or something meant to replace it is returned. */
17185
17186 static tree
patch_cast(tree node,tree wfl_op)17187 patch_cast (tree node, tree wfl_op)
17188 {
17189 tree op = TREE_OPERAND (node, 0);
17190 tree cast_type = TREE_TYPE (node);
17191 tree patched, op_type;
17192 char *t1;
17193
17194 /* Some string patching might be necessary at this stage */
17195 if ((patched = patch_string (op)))
17196 TREE_OPERAND (node, 0) = op = patched;
17197 op_type = TREE_TYPE (op);
17198
17199 /* First resolve OP_TYPE if unresolved */
17200 if (!(cast_type = resolve_type_during_patch (cast_type)))
17201 return error_mark_node;
17202
17203 /* Check on cast that are proven correct at compile time */
17204 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
17205 {
17206 /* Same type */
17207 if (cast_type == op_type)
17208 return node;
17209
17210 /* A narrowing conversion from a floating-point number to an
17211 integral type requires special handling (5.1.3). */
17212 if (JFLOAT_TYPE_P (op_type) && JINTEGRAL_TYPE_P (cast_type))
17213 if (cast_type != long_type_node)
17214 op = convert (integer_type_node, op);
17215
17216 /* Try widening/narrowing conversion. Potentially, things need
17217 to be worked out in gcc so we implement the extreme cases
17218 correctly. fold_convert() needs to be fixed. */
17219 return convert (cast_type, op);
17220 }
17221
17222 /* It's also valid to cast a boolean into a boolean */
17223 if (op_type == boolean_type_node && cast_type == boolean_type_node)
17224 return node;
17225
17226 /* null can be casted to references */
17227 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
17228 return build_null_of_type (cast_type);
17229
17230 /* The remaining legal casts involve conversion between reference
17231 types. Check for their compile time correctness. */
17232 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
17233 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
17234 {
17235 TREE_TYPE (node) = promote_type (cast_type);
17236 /* Now, the case can be determined correct at compile time if
17237 OP_TYPE can be converted into CAST_TYPE by assignment
17238 conversion (5.2) */
17239
17240 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
17241 {
17242 TREE_SET_CODE (node, NOP_EXPR);
17243 return node;
17244 }
17245
17246 if (flag_emit_class_files)
17247 {
17248 TREE_SET_CODE (node, CONVERT_EXPR);
17249 return node;
17250 }
17251
17252 /* The cast requires a run-time check */
17253 return build (CALL_EXPR, promote_type (cast_type),
17254 build_address_of (soft_checkcast_node),
17255 tree_cons (NULL_TREE, build_class_ref (cast_type),
17256 build_tree_list (NULL_TREE, op)),
17257 NULL_TREE);
17258 }
17259
17260 /* Any other casts are proven incorrect at compile time */
17261 t1 = xstrdup (lang_printable_name (op_type, 0));
17262 parse_error_context (wfl_op, "Invalid cast from `%s' to `%s'",
17263 t1, lang_printable_name (cast_type, 0));
17264 free (t1);
17265 return error_mark_node;
17266 }
17267
17268 /* Build a null constant and give it the type TYPE. */
17269
17270 static tree
build_null_of_type(tree type)17271 build_null_of_type (tree type)
17272 {
17273 tree node = build_int_2 (0, 0);
17274 TREE_TYPE (node) = promote_type (type);
17275 return node;
17276 }
17277
17278 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
17279 a list of indices. */
17280 static tree
build_array_ref(int location,tree array,tree index)17281 build_array_ref (int location, tree array, tree index)
17282 {
17283 tree node = build (ARRAY_REF, NULL_TREE, array, index);
17284 EXPR_WFL_LINECOL (node) = location;
17285 return node;
17286 }
17287
17288 /* 15.12 Array Access Expression */
17289
17290 static tree
patch_array_ref(tree node)17291 patch_array_ref (tree node)
17292 {
17293 tree array = TREE_OPERAND (node, 0);
17294 tree array_type = TREE_TYPE (array);
17295 tree index = TREE_OPERAND (node, 1);
17296 tree index_type = TREE_TYPE (index);
17297 int error_found = 0;
17298
17299 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
17300
17301 if (TREE_CODE (array_type) == POINTER_TYPE)
17302 array_type = TREE_TYPE (array_type);
17303
17304 /* The array reference must be an array */
17305 if (!TYPE_ARRAY_P (array_type))
17306 {
17307 parse_error_context
17308 (wfl_operator,
17309 "`[]' can only be applied to arrays. It can't be applied to `%s'",
17310 lang_printable_name (array_type, 0));
17311 TREE_TYPE (node) = error_mark_node;
17312 error_found = 1;
17313 }
17314
17315 /* The array index undergoes unary numeric promotion. The promoted
17316 type must be int */
17317 index = do_unary_numeric_promotion (index);
17318 if (TREE_TYPE (index) != int_type_node)
17319 {
17320 if (valid_cast_to_p (index_type, int_type_node))
17321 parse_error_context (wfl_operator,
17322 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
17323 lang_printable_name (index_type, 0));
17324 else
17325 parse_error_context (wfl_operator,
17326 "Incompatible type for `[]'. Can't convert `%s' to `int'",
17327 lang_printable_name (index_type, 0));
17328 TREE_TYPE (node) = error_mark_node;
17329 error_found = 1;
17330 }
17331
17332 if (error_found)
17333 return error_mark_node;
17334
17335 array_type = TYPE_ARRAY_ELEMENT (array_type);
17336
17337 if (flag_emit_class_files || flag_emit_xref)
17338 {
17339 TREE_OPERAND (node, 0) = array;
17340 TREE_OPERAND (node, 1) = index;
17341 }
17342 else
17343 node = build_java_arrayaccess (array, array_type, index);
17344 TREE_TYPE (node) = array_type;
17345 return node;
17346 }
17347
17348 /* 15.9 Array Creation Expressions */
17349
17350 static tree
build_newarray_node(tree type,tree dims,int extra_dims)17351 build_newarray_node (tree type, tree dims, int extra_dims)
17352 {
17353 tree node =
17354 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
17355 build_int_2 (extra_dims, 0));
17356 return node;
17357 }
17358
17359 static tree
patch_newarray(tree node)17360 patch_newarray (tree node)
17361 {
17362 tree type = TREE_OPERAND (node, 0);
17363 tree dims = TREE_OPERAND (node, 1);
17364 tree cdim, array_type;
17365 int error_found = 0;
17366 int ndims = 0;
17367 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
17368
17369 /* Dimension types are verified. It's better for the types to be
17370 verified in order. */
17371 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
17372 {
17373 int dim_error = 0;
17374 tree dim = TREE_VALUE (cdim);
17375
17376 /* Dim might have been saved during its evaluation */
17377 dim = (TREE_CODE (dim) == SAVE_EXPR ? TREE_OPERAND (dim, 0) : dim);
17378
17379 /* The type of each specified dimension must be an integral type. */
17380 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
17381 dim_error = 1;
17382
17383 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
17384 promoted type must be int. */
17385 else
17386 {
17387 dim = do_unary_numeric_promotion (dim);
17388 if (TREE_TYPE (dim) != int_type_node)
17389 dim_error = 1;
17390 }
17391
17392 /* Report errors on types here */
17393 if (dim_error)
17394 {
17395 parse_error_context
17396 (TREE_PURPOSE (cdim),
17397 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
17398 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
17399 "Explicit cast needed to" : "Can't"),
17400 lang_printable_name (TREE_TYPE (dim), 0));
17401 error_found = 1;
17402 }
17403
17404 TREE_PURPOSE (cdim) = NULL_TREE;
17405 }
17406
17407 /* Resolve array base type if unresolved */
17408 if (!(type = resolve_type_during_patch (type)))
17409 error_found = 1;
17410
17411 if (error_found)
17412 {
17413 /* We don't want further evaluation of this bogus array creation
17414 operation */
17415 TREE_TYPE (node) = error_mark_node;
17416 return error_mark_node;
17417 }
17418
17419 /* Set array_type to the actual (promoted) array type of the result. */
17420 if (TREE_CODE (type) == RECORD_TYPE)
17421 type = build_pointer_type (type);
17422 while (--xdims >= 0)
17423 {
17424 type = promote_type (build_java_array_type (type, -1));
17425 }
17426 dims = nreverse (dims);
17427 array_type = type;
17428 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
17429 {
17430 type = array_type;
17431 array_type
17432 = build_java_array_type (type,
17433 TREE_CODE (cdim) == INTEGER_CST
17434 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
17435 : -1);
17436 array_type = promote_type (array_type);
17437 }
17438 dims = nreverse (dims);
17439
17440 /* The node is transformed into a function call. Things are done
17441 differently according to the number of dimensions. If the number
17442 of dimension is equal to 1, then the nature of the base type
17443 (primitive or not) matters. */
17444 if (ndims == 1)
17445 return build_new_array (type, TREE_VALUE (dims));
17446
17447 /* Can't reuse what's already written in expr.c because it uses the
17448 JVM stack representation. Provide a build_multianewarray. FIXME */
17449 return build (CALL_EXPR, array_type,
17450 build_address_of (soft_multianewarray_node),
17451 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
17452 tree_cons (NULL_TREE,
17453 build_int_2 (ndims, 0), dims )),
17454 NULL_TREE);
17455 }
17456
17457 /* 10.6 Array initializer. */
17458
17459 /* Build a wfl for array element that don't have one, so we can
17460 pin-point errors. */
17461
17462 static tree
maybe_build_array_element_wfl(tree node)17463 maybe_build_array_element_wfl (tree node)
17464 {
17465 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
17466 return build_expr_wfl (NULL_TREE, ctxp->filename,
17467 ctxp->elc.line, ctxp->elc.prev_col);
17468 else
17469 return NULL_TREE;
17470 }
17471
17472 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
17473 identification of initialized arrays easier to detect during walk
17474 and expansion. */
17475
17476 static tree
build_new_array_init(int location,tree values)17477 build_new_array_init (int location, tree values)
17478 {
17479 tree constructor = build_constructor (NULL_TREE, values);
17480 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
17481 EXPR_WFL_LINECOL (to_return) = location;
17482 return to_return;
17483 }
17484
17485 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
17486 occurred. Otherwise return NODE after having set its type
17487 appropriately. */
17488
17489 static tree
patch_new_array_init(tree type,tree node)17490 patch_new_array_init (tree type, tree node)
17491 {
17492 int error_seen = 0;
17493 tree current, element_type;
17494 HOST_WIDE_INT length;
17495 int all_constant = 1;
17496 tree init = TREE_OPERAND (node, 0);
17497
17498 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
17499 {
17500 parse_error_context (node,
17501 "Invalid array initializer for non-array type `%s'",
17502 lang_printable_name (type, 1));
17503 return error_mark_node;
17504 }
17505 type = TREE_TYPE (type);
17506 element_type = TYPE_ARRAY_ELEMENT (type);
17507
17508 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
17509
17510 for (length = 0, current = CONSTRUCTOR_ELTS (init);
17511 current; length++, current = TREE_CHAIN (current))
17512 {
17513 tree elt = TREE_VALUE (current);
17514 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
17515 {
17516 error_seen |= array_constructor_check_entry (element_type, current);
17517 elt = TREE_VALUE (current);
17518 /* When compiling to native code, STRING_CST is converted to
17519 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
17520 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
17521 all_constant = 0;
17522 }
17523 else
17524 {
17525 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
17526 TREE_PURPOSE (current) = NULL_TREE;
17527 all_constant = 0;
17528 }
17529 if (elt && TREE_CODE (elt) == TREE_LIST
17530 && TREE_VALUE (elt) == error_mark_node)
17531 error_seen = 1;
17532 }
17533
17534 if (error_seen)
17535 return error_mark_node;
17536
17537 /* Create a new type. We can't reuse the one we have here by
17538 patching its dimension because it originally is of dimension -1
17539 hence reused by gcc. This would prevent triangular arrays. */
17540 type = build_java_array_type (element_type, length);
17541 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
17542 TREE_TYPE (node) = promote_type (type);
17543 TREE_CONSTANT (init) = all_constant;
17544 TREE_CONSTANT (node) = all_constant;
17545 return node;
17546 }
17547
17548 /* Verify that one entry of the initializer element list can be
17549 assigned to the array base type. Report 1 if an error occurred, 0
17550 otherwise. */
17551
17552 static int
array_constructor_check_entry(tree type,tree entry)17553 array_constructor_check_entry (tree type, tree entry)
17554 {
17555 char *array_type_string = NULL; /* For error reports */
17556 tree value, type_value, new_value, wfl_value, patched;
17557 int error_seen = 0;
17558
17559 new_value = NULL_TREE;
17560 wfl_value = TREE_VALUE (entry);
17561
17562 value = java_complete_tree (TREE_VALUE (entry));
17563 /* patch_string return error_mark_node if arg is error_mark_node */
17564 if ((patched = patch_string (value)))
17565 value = patched;
17566 if (value == error_mark_node)
17567 return 1;
17568
17569 type_value = TREE_TYPE (value);
17570
17571 /* At anytime, try_builtin_assignconv can report a warning on
17572 constant overflow during narrowing. */
17573 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
17574 new_value = try_builtin_assignconv (wfl_operator, type, value);
17575 if (!new_value && (new_value = try_reference_assignconv (type, value)))
17576 type_value = promote_type (type);
17577
17578 /* Check and report errors */
17579 if (!new_value)
17580 {
17581 const char *const msg = (!valid_cast_to_p (type_value, type) ?
17582 "Can't" : "Explicit cast needed to");
17583 if (!array_type_string)
17584 array_type_string = xstrdup (lang_printable_name (type, 1));
17585 parse_error_context
17586 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
17587 msg, lang_printable_name (type_value, 1), array_type_string);
17588 error_seen = 1;
17589 }
17590
17591 if (new_value)
17592 TREE_VALUE (entry) = new_value;
17593
17594 if (array_type_string)
17595 free (array_type_string);
17596
17597 TREE_PURPOSE (entry) = NULL_TREE;
17598 return error_seen;
17599 }
17600
17601 static tree
build_this(int location)17602 build_this (int location)
17603 {
17604 tree node = build_wfl_node (this_identifier_node);
17605 TREE_SET_CODE (node, THIS_EXPR);
17606 EXPR_WFL_LINECOL (node) = location;
17607 return node;
17608 }
17609
17610 /* 14.15 The return statement. It builds a modify expression that
17611 assigns the returned value to the RESULT_DECL that hold the value
17612 to be returned. */
17613
17614 static tree
build_return(int location,tree op)17615 build_return (int location, tree op)
17616 {
17617 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
17618 EXPR_WFL_LINECOL (node) = location;
17619 node = build_debugable_stmt (location, node);
17620 return node;
17621 }
17622
17623 static tree
patch_return(tree node)17624 patch_return (tree node)
17625 {
17626 tree return_exp = TREE_OPERAND (node, 0);
17627 tree meth = current_function_decl;
17628 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
17629 int error_found = 0;
17630
17631 TREE_TYPE (node) = error_mark_node;
17632 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
17633
17634 /* It's invalid to have a return value within a function that is
17635 declared with the keyword void or that is a constructor */
17636 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
17637 error_found = 1;
17638
17639 /* It's invalid to use a return statement in a static block */
17640 if (DECL_CLINIT_P (current_function_decl))
17641 error_found = 1;
17642
17643 /* It's invalid to have a no return value within a function that
17644 isn't declared with the keyword `void' */
17645 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
17646 error_found = 2;
17647
17648 if (DECL_INSTINIT_P (current_function_decl))
17649 error_found = 1;
17650
17651 if (error_found)
17652 {
17653 if (DECL_INSTINIT_P (current_function_decl))
17654 parse_error_context (wfl_operator,
17655 "`return' inside instance initializer");
17656
17657 else if (DECL_CLINIT_P (current_function_decl))
17658 parse_error_context (wfl_operator,
17659 "`return' inside static initializer");
17660
17661 else if (!DECL_CONSTRUCTOR_P (meth))
17662 {
17663 char *t = xstrdup (lang_printable_name (mtype, 0));
17664 parse_error_context (wfl_operator,
17665 "`return' with%s value from `%s %s'",
17666 (error_found == 1 ? "" : "out"),
17667 t, lang_printable_name (meth, 0));
17668 free (t);
17669 }
17670 else
17671 parse_error_context (wfl_operator,
17672 "`return' with value from constructor `%s'",
17673 lang_printable_name (meth, 0));
17674 return error_mark_node;
17675 }
17676
17677 /* If we have a return_exp, build a modify expression and expand
17678 it. Note: at that point, the assignment is declared valid, but we
17679 may want to carry some more hacks */
17680 if (return_exp)
17681 {
17682 tree exp = java_complete_tree (return_exp);
17683 tree modify, patched;
17684
17685 if ((patched = patch_string (exp)))
17686 exp = patched;
17687
17688 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
17689 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
17690 modify = java_complete_tree (modify);
17691
17692 if (modify != error_mark_node)
17693 {
17694 TREE_SIDE_EFFECTS (modify) = 1;
17695 TREE_OPERAND (node, 0) = modify;
17696 }
17697 else
17698 return error_mark_node;
17699 }
17700 TREE_TYPE (node) = void_type_node;
17701 TREE_SIDE_EFFECTS (node) = 1;
17702 return node;
17703 }
17704
17705 /* 14.8 The if Statement */
17706
17707 static tree
build_if_else_statement(int location,tree expression,tree if_body,tree else_body)17708 build_if_else_statement (int location, tree expression, tree if_body,
17709 tree else_body)
17710 {
17711 tree node;
17712 if (!else_body)
17713 else_body = empty_stmt_node;
17714 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
17715 EXPR_WFL_LINECOL (node) = location;
17716 node = build_debugable_stmt (location, node);
17717 return node;
17718 }
17719
17720 static tree
patch_if_else_statement(tree node)17721 patch_if_else_statement (tree node)
17722 {
17723 tree expression = TREE_OPERAND (node, 0);
17724 int can_complete_normally
17725 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
17726 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2)));
17727
17728 TREE_TYPE (node) = error_mark_node;
17729 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
17730
17731 /* The type of expression must be boolean */
17732 if (TREE_TYPE (expression) != boolean_type_node
17733 && TREE_TYPE (expression) != promoted_boolean_type_node)
17734 {
17735 parse_error_context
17736 (wfl_operator,
17737 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
17738 lang_printable_name (TREE_TYPE (expression), 0));
17739 return error_mark_node;
17740 }
17741
17742 if (TREE_CODE (expression) == INTEGER_CST)
17743 {
17744 if (integer_zerop (expression))
17745 node = TREE_OPERAND (node, 2);
17746 else
17747 node = TREE_OPERAND (node, 1);
17748 if (CAN_COMPLETE_NORMALLY (node) != can_complete_normally)
17749 {
17750 node = build (COMPOUND_EXPR, void_type_node, node, empty_stmt_node);
17751 CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
17752 }
17753 return node;
17754 }
17755 TREE_TYPE (node) = void_type_node;
17756 TREE_SIDE_EFFECTS (node) = 1;
17757 CAN_COMPLETE_NORMALLY (node) = can_complete_normally;
17758 return node;
17759 }
17760
17761 /* 14.6 Labeled Statements */
17762
17763 /* Action taken when a labeled statement is parsed. a new
17764 LABELED_BLOCK_EXPR is created. No statement is attached to the
17765 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
17766
17767 static tree
build_labeled_block(int location,tree label)17768 build_labeled_block (int location, tree label)
17769 {
17770 tree label_name ;
17771 tree label_decl, node;
17772 if (label == NULL_TREE || label == continue_identifier_node)
17773 label_name = label;
17774 else
17775 {
17776 label_name = merge_qualified_name (label_id, label);
17777 /* Issue an error if we try to reuse a label that was previously
17778 declared */
17779 if (IDENTIFIER_LOCAL_VALUE (label_name))
17780 {
17781 EXPR_WFL_LINECOL (wfl_operator) = location;
17782 parse_error_context (wfl_operator,
17783 "Declaration of `%s' shadows a previous label declaration",
17784 IDENTIFIER_POINTER (label));
17785 EXPR_WFL_LINECOL (wfl_operator) =
17786 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
17787 parse_error_context (wfl_operator,
17788 "This is the location of the previous declaration of label `%s'",
17789 IDENTIFIER_POINTER (label));
17790 java_error_count--;
17791 }
17792 }
17793
17794 label_decl = create_label_decl (label_name);
17795 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
17796 EXPR_WFL_LINECOL (node) = location;
17797 TREE_SIDE_EFFECTS (node) = 1;
17798 return node;
17799 }
17800
17801 /* A labeled statement LBE is attached a statement. */
17802
17803 static tree
finish_labeled_statement(tree lbe,tree statement)17804 finish_labeled_statement (tree lbe, /* Labeled block expr */
17805 tree statement)
17806 {
17807 /* In anyways, tie the loop to its statement */
17808 LABELED_BLOCK_BODY (lbe) = statement;
17809 pop_labeled_block ();
17810 POP_LABELED_BLOCK ();
17811 return lbe;
17812 }
17813
17814 /* 14.10, 14.11, 14.12 Loop Statements */
17815
17816 /* Create an empty LOOP_EXPR and make it the last in the nested loop
17817 list. */
17818
17819 static tree
build_new_loop(tree loop_body)17820 build_new_loop (tree loop_body)
17821 {
17822 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
17823 TREE_SIDE_EFFECTS (loop) = 1;
17824 PUSH_LOOP (loop);
17825 return loop;
17826 }
17827
17828 /* Create a loop body according to the following structure:
17829 COMPOUND_EXPR
17830 COMPOUND_EXPR (loop main body)
17831 EXIT_EXPR (this order is for while/for loops.
17832 LABELED_BLOCK_EXPR the order is reversed for do loops)
17833 LABEL_DECL (a continue occurring here branches at the
17834 BODY end of this labeled block)
17835 INCREMENT (if any)
17836
17837 REVERSED, if nonzero, tells that the loop condition expr comes
17838 after the body, like in the do-while loop.
17839
17840 To obtain a loop, the loop body structure described above is
17841 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
17842
17843 LABELED_BLOCK_EXPR
17844 LABEL_DECL (use this label to exit the loop)
17845 LOOP_EXPR
17846 <structure described above> */
17847
17848 static tree
build_loop_body(int location,tree condition,int reversed)17849 build_loop_body (int location, tree condition, int reversed)
17850 {
17851 tree first, second, body;
17852
17853 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
17854 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
17855 condition = build_debugable_stmt (location, condition);
17856 TREE_SIDE_EFFECTS (condition) = 1;
17857
17858 body = build_labeled_block (0, continue_identifier_node);
17859 first = (reversed ? body : condition);
17860 second = (reversed ? condition : body);
17861 return
17862 build (COMPOUND_EXPR, NULL_TREE,
17863 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
17864 }
17865
17866 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
17867 their order) on the current loop. Unlink the current loop from the
17868 loop list. */
17869
17870 static tree
finish_loop_body(int location,tree condition,tree body,int reversed)17871 finish_loop_body (int location, tree condition, tree body, int reversed)
17872 {
17873 tree to_return = ctxp->current_loop;
17874 tree loop_body = LOOP_EXPR_BODY (to_return);
17875 if (condition)
17876 {
17877 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
17878 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
17879 The real EXIT_EXPR is one operand further. */
17880 EXPR_WFL_LINECOL (cnode) = location;
17881 /* This one is for accurate error reports */
17882 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
17883 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
17884 }
17885 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
17886 POP_LOOP ();
17887 return to_return;
17888 }
17889
17890 /* Tailored version of finish_loop_body for FOR loops, when FOR
17891 loops feature the condition part */
17892
17893 static tree
finish_for_loop(int location,tree condition,tree update,tree body)17894 finish_for_loop (int location, tree condition, tree update, tree body)
17895 {
17896 /* Put the condition and the loop body in place */
17897 tree loop = finish_loop_body (location, condition, body, 0);
17898 /* LOOP is the current loop which has been now popped of the loop
17899 stack. Mark the update block as reachable and install it. We do
17900 this because the (current interpretation of the) JLS requires
17901 that the update expression be considered reachable even if the
17902 for loop's body doesn't complete normally. */
17903 if (update != NULL_TREE && update != empty_stmt_node)
17904 {
17905 tree up2 = update;
17906 if (TREE_CODE (up2) == EXPR_WITH_FILE_LOCATION)
17907 up2 = EXPR_WFL_NODE (up2);
17908 /* It is possible for the update expression to be an
17909 EXPR_WFL_NODE wrapping nothing. */
17910 if (up2 != NULL_TREE && up2 != empty_stmt_node)
17911 {
17912 /* Try to detect constraint violations. These would be
17913 programming errors somewhere. */
17914 if (! IS_EXPR_CODE_CLASS (TREE_CODE_CLASS (TREE_CODE (up2)))
17915 || TREE_CODE (up2) == LOOP_EXPR)
17916 abort ();
17917 SUPPRESS_UNREACHABLE_ERROR (up2) = 1;
17918 }
17919 }
17920 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
17921 return loop;
17922 }
17923
17924 /* Try to find the loop a block might be related to. This comprises
17925 the case where the LOOP_EXPR is found as the second operand of a
17926 COMPOUND_EXPR, because the loop happens to have an initialization
17927 part, then expressed as the first operand of the COMPOUND_EXPR. If
17928 the search finds something, 1 is returned. Otherwise, 0 is
17929 returned. The search is assumed to start from a
17930 LABELED_BLOCK_EXPR's block. */
17931
17932 static tree
search_loop(tree statement)17933 search_loop (tree statement)
17934 {
17935 if (TREE_CODE (statement) == LOOP_EXPR)
17936 return statement;
17937
17938 if (TREE_CODE (statement) == BLOCK)
17939 statement = BLOCK_SUBBLOCKS (statement);
17940 else
17941 return NULL_TREE;
17942
17943 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
17944 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
17945 statement = TREE_OPERAND (statement, 1);
17946
17947 return (TREE_CODE (statement) == LOOP_EXPR
17948 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
17949 }
17950
17951 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
17952 returned otherwise. */
17953
17954 static int
labeled_block_contains_loop_p(tree block,tree loop)17955 labeled_block_contains_loop_p (tree block, tree loop)
17956 {
17957 if (!block)
17958 return 0;
17959
17960 if (LABELED_BLOCK_BODY (block) == loop)
17961 return 1;
17962
17963 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
17964 return 1;
17965
17966 return 0;
17967 }
17968
17969 /* If the loop isn't surrounded by a labeled statement, create one and
17970 insert LOOP as its body. */
17971
17972 static tree
patch_loop_statement(tree loop)17973 patch_loop_statement (tree loop)
17974 {
17975 tree loop_label;
17976
17977 TREE_TYPE (loop) = void_type_node;
17978 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
17979 return loop;
17980
17981 loop_label = build_labeled_block (0, NULL_TREE);
17982 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
17983 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
17984 LABELED_BLOCK_BODY (loop_label) = loop;
17985 PUSH_LABELED_BLOCK (loop_label);
17986 return loop_label;
17987 }
17988
17989 /* 14.13, 14.14: break and continue Statements */
17990
17991 /* Build a break or a continue statement. a null NAME indicates an
17992 unlabeled break/continue statement. */
17993
17994 static tree
build_bc_statement(int location,int is_break,tree name)17995 build_bc_statement (int location, int is_break, tree name)
17996 {
17997 tree break_continue, label_block_expr = NULL_TREE;
17998
17999 if (name)
18000 {
18001 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
18002 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
18003 /* Null means that we don't have a target for this named
18004 break/continue. In this case, we make the target to be the
18005 label name, so that the error can be reported accurately in
18006 patch_bc_statement. */
18007 label_block_expr = EXPR_WFL_NODE (name);
18008 }
18009 /* Unlabeled break/continue will be handled during the
18010 break/continue patch operation */
18011 break_continue
18012 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
18013
18014 IS_BREAK_STMT_P (break_continue) = is_break;
18015 TREE_SIDE_EFFECTS (break_continue) = 1;
18016 EXPR_WFL_LINECOL (break_continue) = location;
18017 break_continue = build_debugable_stmt (location, break_continue);
18018 return break_continue;
18019 }
18020
18021 /* Verification of a break/continue statement. */
18022
18023 static tree
patch_bc_statement(tree node)18024 patch_bc_statement (tree node)
18025 {
18026 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
18027 tree labeled_block = ctxp->current_labeled_block;
18028 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
18029
18030 /* Having an identifier here means that the target is unknown. */
18031 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
18032 {
18033 parse_error_context (wfl_operator, "No label definition found for `%s'",
18034 IDENTIFIER_POINTER (bc_label));
18035 return error_mark_node;
18036 }
18037 if (! IS_BREAK_STMT_P (node))
18038 {
18039 /* It's a continue statement. */
18040 for (;; labeled_block = TREE_CHAIN (labeled_block))
18041 {
18042 if (labeled_block == NULL_TREE)
18043 {
18044 if (bc_label == NULL_TREE)
18045 parse_error_context (wfl_operator,
18046 "`continue' must be in loop");
18047 else
18048 parse_error_context
18049 (wfl_operator, "continue label `%s' does not name a loop",
18050 IDENTIFIER_POINTER (bc_label));
18051 return error_mark_node;
18052 }
18053 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
18054 == continue_identifier_node)
18055 && (bc_label == NULL_TREE
18056 || TREE_CHAIN (labeled_block) == bc_label))
18057 {
18058 bc_label = labeled_block;
18059 break;
18060 }
18061 }
18062 }
18063 else if (!bc_label)
18064 {
18065 for (;; labeled_block = TREE_CHAIN (labeled_block))
18066 {
18067 if (labeled_block == NULL_TREE)
18068 {
18069 parse_error_context (wfl_operator,
18070 "`break' must be in loop or switch");
18071 return error_mark_node;
18072 }
18073 target_stmt = LABELED_BLOCK_BODY (labeled_block);
18074 if (TREE_CODE (target_stmt) == SWITCH_EXPR
18075 || search_loop (target_stmt))
18076 {
18077 bc_label = labeled_block;
18078 break;
18079 }
18080 }
18081 }
18082
18083 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
18084 CAN_COMPLETE_NORMALLY (bc_label) = 1;
18085
18086 /* Our break/continue don't return values. */
18087 TREE_TYPE (node) = void_type_node;
18088 /* Encapsulate the break within a compound statement so that it's
18089 expanded all the times by expand_expr (and not clobbered
18090 sometimes, like after a if statement) */
18091 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
18092 TREE_SIDE_EFFECTS (node) = 1;
18093 return node;
18094 }
18095
18096 /* Process the exit expression belonging to a loop. Its type must be
18097 boolean. */
18098
18099 static tree
patch_exit_expr(tree node)18100 patch_exit_expr (tree node)
18101 {
18102 tree expression = TREE_OPERAND (node, 0);
18103 TREE_TYPE (node) = error_mark_node;
18104 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
18105
18106 /* The type of expression must be boolean */
18107 if (TREE_TYPE (expression) != boolean_type_node)
18108 {
18109 parse_error_context
18110 (wfl_operator,
18111 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
18112 lang_printable_name (TREE_TYPE (expression), 0));
18113 return error_mark_node;
18114 }
18115 /* Now we know things are allright, invert the condition, fold and
18116 return */
18117 TREE_OPERAND (node, 0) =
18118 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
18119
18120 if (! integer_zerop (TREE_OPERAND (node, 0))
18121 && ctxp->current_loop != NULL_TREE
18122 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
18123 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
18124 if (! integer_onep (TREE_OPERAND (node, 0)))
18125 CAN_COMPLETE_NORMALLY (node) = 1;
18126
18127
18128 TREE_TYPE (node) = void_type_node;
18129 return node;
18130 }
18131
18132 /* 14.9 Switch statement */
18133
18134 static tree
patch_switch_statement(tree node)18135 patch_switch_statement (tree node)
18136 {
18137 tree se = TREE_OPERAND (node, 0), se_type;
18138 tree save, iter;
18139
18140 /* Complete the switch expression */
18141 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
18142 se_type = TREE_TYPE (se);
18143 /* The type of the switch expression must be char, byte, short or
18144 int */
18145 if (! JINTEGRAL_TYPE_P (se_type) || se_type == long_type_node)
18146 {
18147 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
18148 parse_error_context (wfl_operator,
18149 "Incompatible type for `switch'. Can't convert `%s' to `int'",
18150 lang_printable_name (se_type, 0));
18151 /* This is what java_complete_tree will check */
18152 TREE_OPERAND (node, 0) = error_mark_node;
18153 return error_mark_node;
18154 }
18155
18156 /* Save and restore the outer case label list. */
18157 save = case_label_list;
18158 case_label_list = NULL_TREE;
18159
18160 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
18161
18162 /* See if we've found a duplicate label. We can't leave this until
18163 code generation, because in `--syntax-only' and `-C' modes we
18164 don't do ordinary code generation. */
18165 for (iter = case_label_list; iter != NULL_TREE; iter = TREE_CHAIN (iter))
18166 {
18167 HOST_WIDE_INT val = TREE_INT_CST_LOW (TREE_VALUE (iter));
18168 tree subiter;
18169 for (subiter = TREE_CHAIN (iter);
18170 subiter != NULL_TREE;
18171 subiter = TREE_CHAIN (subiter))
18172 {
18173 HOST_WIDE_INT subval = TREE_INT_CST_LOW (TREE_VALUE (subiter));
18174 if (val == subval)
18175 {
18176 EXPR_WFL_LINECOL (wfl_operator)
18177 = EXPR_WFL_LINECOL (TREE_PURPOSE (iter));
18178 /* The case_label_list is in reverse order, so print the
18179 outer label first. */
18180 parse_error_context (wfl_operator, "duplicate case label: `"
18181 HOST_WIDE_INT_PRINT_DEC "'", subval);
18182 EXPR_WFL_LINECOL (wfl_operator)
18183 = EXPR_WFL_LINECOL (TREE_PURPOSE (subiter));
18184 parse_error_context (wfl_operator, "original label is here");
18185
18186 break;
18187 }
18188 }
18189 }
18190
18191 case_label_list = save;
18192
18193 /* Ready to return */
18194 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
18195 {
18196 TREE_TYPE (node) = error_mark_node;
18197 return error_mark_node;
18198 }
18199 TREE_TYPE (node) = void_type_node;
18200 TREE_SIDE_EFFECTS (node) = 1;
18201 CAN_COMPLETE_NORMALLY (node)
18202 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
18203 || ! SWITCH_HAS_DEFAULT (node);
18204 return node;
18205 }
18206
18207 /* Assertions. */
18208
18209 /* Build an assertion expression for `assert CONDITION : VALUE'; VALUE
18210 might be NULL_TREE. */
18211 static tree
build_assertion(int location,tree condition,tree value)18212 build_assertion (int location, tree condition, tree value)
18213 {
18214 tree node;
18215 tree klass = GET_CPC ();
18216
18217 if (! CLASS_USES_ASSERTIONS (klass))
18218 {
18219 tree field, classdollar, id, call;
18220 tree class_type = TREE_TYPE (klass);
18221
18222 field = add_field (class_type,
18223 get_identifier ("$assertionsDisabled"),
18224 boolean_type_node,
18225 ACC_PRIVATE | ACC_STATIC | ACC_FINAL);
18226 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (field);
18227 FIELD_SYNTHETIC (field) = 1;
18228
18229 if (!TYPE_DOT_CLASS (class_type))
18230 build_dot_class_method (class_type);
18231 classdollar = build_dot_class_method_invocation (class_type, class_type);
18232
18233 /* Call CLASS.desiredAssertionStatus(). */
18234 id = build_wfl_node (get_identifier ("desiredAssertionStatus"));
18235 call = build (CALL_EXPR, NULL_TREE, id, NULL_TREE, NULL_TREE);
18236 call = make_qualified_primary (classdollar, call, location);
18237 TREE_SIDE_EFFECTS (call) = 1;
18238
18239 /* Invert to obtain !CLASS.desiredAssertionStatus(). This may
18240 seem odd, but we do it to generate code identical to that of
18241 the JDK. */
18242 call = build1 (TRUTH_NOT_EXPR, NULL_TREE, call);
18243 TREE_SIDE_EFFECTS (call) = 1;
18244 DECL_INITIAL (field) = call;
18245
18246 /* Record the initializer in the initializer statement list. */
18247 call = build (MODIFY_EXPR, NULL_TREE, field, call);
18248 TREE_CHAIN (call) = CPC_STATIC_INITIALIZER_STMT (ctxp);
18249 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, call);
18250 MODIFY_EXPR_FROM_INITIALIZATION_P (call) = 1;
18251
18252 CLASS_USES_ASSERTIONS (klass) = 1;
18253 }
18254
18255 if (value != NULL_TREE)
18256 value = tree_cons (NULL_TREE, value, NULL_TREE);
18257
18258 node = build_wfl_node (get_identifier ("java"));
18259 node = make_qualified_name (node, build_wfl_node (get_identifier ("lang")),
18260 location);
18261 node = make_qualified_name (node, build_wfl_node (get_identifier ("AssertionError")),
18262 location);
18263
18264 node = build (NEW_CLASS_EXPR, NULL_TREE, node, value, NULL_TREE);
18265 TREE_SIDE_EFFECTS (node) = 1;
18266 /* It is too early to use BUILD_THROW. */
18267 node = build1 (THROW_EXPR, NULL_TREE, node);
18268 TREE_SIDE_EFFECTS (node) = 1;
18269
18270 /* We invert the condition; if we just put NODE as the `else' part
18271 then we generate weird-looking bytecode. */
18272 condition = build1 (TRUTH_NOT_EXPR, NULL_TREE, condition);
18273 /* Check $assertionsDisabled. */
18274 condition
18275 = build (TRUTH_ANDIF_EXPR, NULL_TREE,
18276 build1 (TRUTH_NOT_EXPR, NULL_TREE,
18277 build_wfl_node (get_identifier ("$assertionsDisabled"))),
18278 condition);
18279 node = build_if_else_statement (location, condition, node, NULL_TREE);
18280 return node;
18281 }
18282
18283 /* 14.18 The try/catch statements */
18284
18285 /* Encapsulate TRY_STMTS' in a try catch sequence. The catch clause
18286 catches TYPE and executes CATCH_STMTS. */
18287
18288 static tree
encapsulate_with_try_catch(int location,tree type_or_name,tree try_stmts,tree catch_stmts)18289 encapsulate_with_try_catch (int location, tree type_or_name, tree try_stmts,
18290 tree catch_stmts)
18291 {
18292 tree try_block, catch_clause_param, catch_block, catch;
18293
18294 /* First build a try block */
18295 try_block = build_expr_block (try_stmts, NULL_TREE);
18296
18297 /* Build a catch block: we need a catch clause parameter */
18298 if (TREE_CODE (type_or_name) == EXPR_WITH_FILE_LOCATION)
18299 {
18300 tree catch_type = obtain_incomplete_type (type_or_name);
18301 jdep *dep;
18302 catch_clause_param = build_decl (VAR_DECL, wpv_id, catch_type);
18303 register_incomplete_type (JDEP_VARIABLE, type_or_name,
18304 catch_clause_param, catch_type);
18305 dep = CLASSD_LAST (ctxp->classd_list);
18306 JDEP_GET_PATCH (dep) = &TREE_TYPE (catch_clause_param);
18307 }
18308 else
18309 catch_clause_param = build_decl (VAR_DECL, wpv_id,
18310 build_pointer_type (type_or_name));
18311
18312 /* And a block */
18313 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
18314
18315 /* Initialize the variable and store in the block */
18316 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
18317 build (JAVA_EXC_OBJ_EXPR, ptr_type_node));
18318 add_stmt_to_block (catch_block, NULL_TREE, catch);
18319
18320 /* Add the catch statements */
18321 add_stmt_to_block (catch_block, NULL_TREE, catch_stmts);
18322
18323 /* Now we can build a CATCH_EXPR */
18324 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
18325
18326 return build_try_statement (location, try_block, catch_block);
18327 }
18328
18329 static tree
build_try_statement(int location,tree try_block,tree catches)18330 build_try_statement (int location, tree try_block, tree catches)
18331 {
18332 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
18333 EXPR_WFL_LINECOL (node) = location;
18334 return node;
18335 }
18336
18337 static tree
build_try_finally_statement(int location,tree try_block,tree finally)18338 build_try_finally_statement (int location, tree try_block, tree finally)
18339 {
18340 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
18341 EXPR_WFL_LINECOL (node) = location;
18342 return node;
18343 }
18344
18345 static tree
patch_try_statement(tree node)18346 patch_try_statement (tree node)
18347 {
18348 int error_found = 0;
18349 tree try = TREE_OPERAND (node, 0);
18350 /* Exception handlers are considered in left to right order */
18351 tree catch = nreverse (TREE_OPERAND (node, 1));
18352 tree current, caught_type_list = NULL_TREE;
18353
18354 /* Check catch clauses, if any. Every time we find an error, we try
18355 to process the next catch clause. We process the catch clause before
18356 the try block so that when processing the try block we can check thrown
18357 exceptions againts the caught type list. */
18358 for (current = catch; current; current = TREE_CHAIN (current))
18359 {
18360 tree carg_decl, carg_type;
18361 tree sub_current, catch_block, catch_clause;
18362 int unreachable;
18363
18364 /* At this point, the structure of the catch clause is
18365 CATCH_EXPR (catch node)
18366 BLOCK (with the decl of the parameter)
18367 COMPOUND_EXPR
18368 MODIFY_EXPR (assignment of the catch parameter)
18369 BLOCK (catch clause block)
18370 */
18371 catch_clause = TREE_OPERAND (current, 0);
18372 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
18373 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
18374
18375 /* Catch clauses can't have more than one parameter declared,
18376 but it's already enforced by the grammar. Make sure that the
18377 only parameter of the clause statement in of class Throwable
18378 or a subclass of Throwable, but that was done earlier. The
18379 catch clause parameter type has also been resolved. */
18380
18381 /* Just make sure that the catch clause parameter type inherits
18382 from java.lang.Throwable */
18383 if (!inherits_from_p (carg_type, throwable_type_node))
18384 {
18385 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
18386 parse_error_context (wfl_operator,
18387 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
18388 lang_printable_name (carg_type, 0));
18389 error_found = 1;
18390 continue;
18391 }
18392
18393 /* Partial check for unreachable catch statement: The catch
18394 clause is reachable iff is no earlier catch block A in
18395 the try statement such that the type of the catch
18396 clause's parameter is the same as or a subclass of the
18397 type of A's parameter */
18398 unreachable = 0;
18399 for (sub_current = catch;
18400 sub_current != current; sub_current = TREE_CHAIN (sub_current))
18401 {
18402 tree sub_catch_clause, decl;
18403 sub_catch_clause = TREE_OPERAND (sub_current, 0);
18404 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
18405
18406 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
18407 {
18408 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
18409 parse_error_context
18410 (wfl_operator,
18411 "`catch' not reached because of the catch clause at line %d",
18412 EXPR_WFL_LINENO (sub_current));
18413 unreachable = error_found = 1;
18414 break;
18415 }
18416 }
18417 /* Complete the catch clause block */
18418 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
18419 if (catch_block == error_mark_node)
18420 {
18421 error_found = 1;
18422 continue;
18423 }
18424 if (CAN_COMPLETE_NORMALLY (catch_block))
18425 CAN_COMPLETE_NORMALLY (node) = 1;
18426 TREE_OPERAND (current, 0) = catch_block;
18427
18428 if (unreachable)
18429 continue;
18430
18431 /* Things to do here: the exception must be thrown */
18432
18433 /* Link this type to the caught type list */
18434 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
18435 }
18436
18437 PUSH_EXCEPTIONS (caught_type_list);
18438 if ((try = java_complete_tree (try)) == error_mark_node)
18439 error_found = 1;
18440 if (CAN_COMPLETE_NORMALLY (try))
18441 CAN_COMPLETE_NORMALLY (node) = 1;
18442 POP_EXCEPTIONS ();
18443
18444 /* Verification ends here */
18445 if (error_found)
18446 return error_mark_node;
18447
18448 TREE_OPERAND (node, 0) = try;
18449 TREE_OPERAND (node, 1) = catch;
18450 TREE_TYPE (node) = void_type_node;
18451 return node;
18452 }
18453
18454 /* 14.17 The synchronized Statement */
18455
18456 static tree
patch_synchronized_statement(tree node,tree wfl_op1)18457 patch_synchronized_statement (tree node, tree wfl_op1)
18458 {
18459 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
18460 tree block = TREE_OPERAND (node, 1);
18461
18462 tree tmp, enter, exit, expr_decl, assignment;
18463
18464 if (expr == error_mark_node)
18465 {
18466 block = java_complete_tree (block);
18467 return expr;
18468 }
18469
18470 /* We might be trying to synchronize on a STRING_CST */
18471 if ((tmp = patch_string (expr)))
18472 expr = tmp;
18473
18474 /* The TYPE of expr must be a reference type */
18475 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
18476 {
18477 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
18478 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
18479 lang_printable_name (TREE_TYPE (expr), 0));
18480 return error_mark_node;
18481 }
18482
18483 if (flag_emit_xref)
18484 {
18485 TREE_OPERAND (node, 0) = expr;
18486 TREE_OPERAND (node, 1) = java_complete_tree (block);
18487 CAN_COMPLETE_NORMALLY (node) = 1;
18488 return node;
18489 }
18490
18491 /* Generate a try-finally for the synchronized statement, except
18492 that the handler that catches all throw exception calls
18493 _Jv_MonitorExit and then rethrow the exception.
18494 The synchronized statement is then implemented as:
18495 TRY
18496 {
18497 _Jv_MonitorEnter (expression)
18498 synchronized_block
18499 _Jv_MonitorExit (expression)
18500 }
18501 CATCH_ALL
18502 {
18503 e = _Jv_exception_info ();
18504 _Jv_MonitorExit (expression)
18505 Throw (e);
18506 } */
18507
18508 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
18509 BUILD_MONITOR_ENTER (enter, expr_decl);
18510 BUILD_MONITOR_EXIT (exit, expr_decl);
18511 CAN_COMPLETE_NORMALLY (enter) = 1;
18512 CAN_COMPLETE_NORMALLY (exit) = 1;
18513 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
18514 TREE_SIDE_EFFECTS (assignment) = 1;
18515 node = build (COMPOUND_EXPR, NULL_TREE,
18516 build (COMPOUND_EXPR, NULL_TREE, assignment, enter),
18517 build (TRY_FINALLY_EXPR, NULL_TREE, block, exit));
18518 node = build_expr_block (node, expr_decl);
18519
18520 return java_complete_tree (node);
18521 }
18522
18523 /* 14.16 The throw Statement */
18524
18525 static tree
patch_throw_statement(tree node,tree wfl_op1)18526 patch_throw_statement (tree node, tree wfl_op1)
18527 {
18528 tree expr = TREE_OPERAND (node, 0);
18529 tree type = TREE_TYPE (expr);
18530 int unchecked_ok = 0, tryblock_throws_ok = 0;
18531
18532 /* Thrown expression must be assignable to java.lang.Throwable */
18533 if (!try_reference_assignconv (throwable_type_node, expr))
18534 {
18535 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
18536 parse_error_context (wfl_operator,
18537 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
18538 lang_printable_name (type, 0));
18539 /* If the thrown expression was a reference, we further the
18540 compile-time check. */
18541 if (!JREFERENCE_TYPE_P (type))
18542 return error_mark_node;
18543 }
18544
18545 /* At least one of the following must be true */
18546
18547 /* The type of the throw expression is a not checked exception,
18548 i.e. is a unchecked expression. */
18549 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
18550
18551 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
18552 /* An instance can't throw a checked exception unless that exception
18553 is explicitly declared in the `throws' clause of each
18554 constructor. This doesn't apply to anonymous classes, since they
18555 don't have declared constructors. */
18556 if (!unchecked_ok
18557 && DECL_INSTINIT_P (current_function_decl)
18558 && !ANONYMOUS_CLASS_P (current_class))
18559 {
18560 tree current;
18561 for (current = TYPE_METHODS (current_class); current;
18562 current = TREE_CHAIN (current))
18563 if (DECL_CONSTRUCTOR_P (current)
18564 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
18565 {
18566 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)",
18567 lang_printable_name (TREE_TYPE (expr), 0));
18568 return error_mark_node;
18569 }
18570 }
18571
18572 /* Throw is contained in a try statement and at least one catch
18573 clause can receive the thrown expression or the current method is
18574 declared to throw such an exception. Or, the throw statement is
18575 contained in a method or constructor declaration and the type of
18576 the Expression is assignable to at least one type listed in the
18577 throws clause the declaration. */
18578 if (!unchecked_ok)
18579 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
18580 if (!(unchecked_ok || tryblock_throws_ok))
18581 {
18582 /* If there is a surrounding try block that has no matching
18583 clatch clause, report it first. A surrounding try block exits
18584 only if there is something after the list of checked
18585 exception thrown by the current function (if any). */
18586 if (IN_TRY_BLOCK_P ())
18587 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
18588 lang_printable_name (type, 0));
18589 /* If we have no surrounding try statement and the method doesn't have
18590 any throws, report it now. FIXME */
18591
18592 /* We report that the exception can't be throw from a try block
18593 in all circumstances but when the `throw' is inside a static
18594 block. */
18595 else if (!EXCEPTIONS_P (currently_caught_type_list)
18596 && !tryblock_throws_ok)
18597 {
18598 if (DECL_CLINIT_P (current_function_decl))
18599 parse_error_context (wfl_operator,
18600 "Checked exception `%s' can't be thrown in initializer",
18601 lang_printable_name (type, 0));
18602 else
18603 parse_error_context (wfl_operator,
18604 "Checked exception `%s' isn't thrown from a `try' block",
18605 lang_printable_name (type, 0));
18606 }
18607 /* Otherwise, the current method doesn't have the appropriate
18608 throws declaration */
18609 else
18610 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
18611 lang_printable_name (type, 0));
18612 return error_mark_node;
18613 }
18614
18615 if (! flag_emit_class_files && ! flag_emit_xref)
18616 BUILD_THROW (node, expr);
18617
18618 /* If doing xrefs, keep the location where the `throw' was seen. */
18619 if (flag_emit_xref)
18620 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
18621 return node;
18622 }
18623
18624 /* Check that exception said to be thrown by method DECL can be
18625 effectively caught from where DECL is invoked. THIS_EXPR is the
18626 expression that computes `this' for the method call. */
18627 static void
check_thrown_exceptions(int location,tree decl,tree this_expr)18628 check_thrown_exceptions (int location, tree decl, tree this_expr)
18629 {
18630 tree throws;
18631 int is_array_call = 0;
18632
18633 /* Skip check within generated methods, such as access$<n>. */
18634 if (OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (current_function_decl)))
18635 return;
18636
18637 if (this_expr != NULL_TREE
18638 && TREE_CODE (TREE_TYPE (this_expr)) == POINTER_TYPE
18639 && TYPE_ARRAY_P (TREE_TYPE (TREE_TYPE (this_expr))))
18640 is_array_call = 1;
18641
18642 /* For all the unchecked exceptions thrown by DECL. */
18643 for (throws = DECL_FUNCTION_THROWS (decl); throws;
18644 throws = TREE_CHAIN (throws))
18645 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
18646 {
18647 /* Suppress errors about cloning arrays. */
18648 if (is_array_call && DECL_NAME (decl) == get_identifier ("clone"))
18649 continue;
18650
18651 EXPR_WFL_LINECOL (wfl_operator) = location;
18652 if (DECL_FINIT_P (current_function_decl))
18653 parse_error_context
18654 (wfl_operator, "Exception `%s' can't be thrown in initializer",
18655 lang_printable_name (TREE_VALUE (throws), 0));
18656 else
18657 {
18658 parse_error_context
18659 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
18660 lang_printable_name (TREE_VALUE (throws), 0),
18661 (DECL_INIT_P (current_function_decl) ?
18662 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
18663 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
18664 }
18665 }
18666 }
18667
18668 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
18669 try-catch blocks, OR is listed in the `throws' clause of the
18670 current method. */
18671
18672 static int
check_thrown_exceptions_do(tree exception)18673 check_thrown_exceptions_do (tree exception)
18674 {
18675 tree list = currently_caught_type_list;
18676 resolve_and_layout (exception, NULL_TREE);
18677 /* First, all the nested try-catch-finally at that stage. The
18678 last element contains `throws' clause exceptions, if any. */
18679 if (IS_UNCHECKED_EXCEPTION_P (exception))
18680 return 1;
18681 while (list)
18682 {
18683 tree caught;
18684 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
18685 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
18686 return 1;
18687 list = TREE_CHAIN (list);
18688 }
18689 return 0;
18690 }
18691
18692 static void
purge_unchecked_exceptions(tree mdecl)18693 purge_unchecked_exceptions (tree mdecl)
18694 {
18695 tree throws = DECL_FUNCTION_THROWS (mdecl);
18696 tree new = NULL_TREE;
18697
18698 while (throws)
18699 {
18700 tree next = TREE_CHAIN (throws);
18701 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
18702 {
18703 TREE_CHAIN (throws) = new;
18704 new = throws;
18705 }
18706 throws = next;
18707 }
18708 /* List is inverted here, but it doesn't matter */
18709 DECL_FUNCTION_THROWS (mdecl) = new;
18710 }
18711
18712 /* This function goes over all of CLASS_TYPE ctors and checks whether
18713 each of them features at least one unchecked exception in its
18714 `throws' clause. If it's the case, it returns `true', `false'
18715 otherwise. */
18716
18717 static bool
ctors_unchecked_throws_clause_p(tree class_type)18718 ctors_unchecked_throws_clause_p (tree class_type)
18719 {
18720 tree current;
18721
18722 for (current = TYPE_METHODS (class_type); current;
18723 current = TREE_CHAIN (current))
18724 {
18725 bool ctu = false; /* Ctor Throws Unchecked */
18726 if (DECL_CONSTRUCTOR_P (current))
18727 {
18728 tree throws;
18729 for (throws = DECL_FUNCTION_THROWS (current); throws && !ctu;
18730 throws = TREE_CHAIN (throws))
18731 if (inherits_from_p (TREE_VALUE (throws), exception_type_node))
18732 ctu = true;
18733 }
18734 /* We return false as we found one ctor that is unfit. */
18735 if (!ctu && DECL_CONSTRUCTOR_P (current))
18736 return false;
18737 }
18738 /* All ctors feature at least one unchecked exception in their
18739 `throws' clause. */
18740 return true;
18741 }
18742
18743 /* 15.24 Conditional Operator ?: */
18744
18745 static tree
patch_conditional_expr(tree node,tree wfl_cond,tree wfl_op1)18746 patch_conditional_expr (tree node, tree wfl_cond, tree wfl_op1)
18747 {
18748 tree cond = TREE_OPERAND (node, 0);
18749 tree op1 = TREE_OPERAND (node, 1);
18750 tree op2 = TREE_OPERAND (node, 2);
18751 tree resulting_type = NULL_TREE;
18752 tree t1, t2, patched;
18753 int error_found = 0;
18754
18755 /* Operands of ?: might be StringBuffers crafted as a result of a
18756 string concatenation. Obtain a descent operand here. */
18757 if ((patched = patch_string (op1)))
18758 TREE_OPERAND (node, 1) = op1 = patched;
18759 if ((patched = patch_string (op2)))
18760 TREE_OPERAND (node, 2) = op2 = patched;
18761
18762 t1 = TREE_TYPE (op1);
18763 t2 = TREE_TYPE (op2);
18764
18765 /* The first expression must be a boolean */
18766 if (TREE_TYPE (cond) != boolean_type_node)
18767 {
18768 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
18769 parse_error_context (wfl_operator,
18770 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
18771 lang_printable_name (TREE_TYPE (cond), 0));
18772 error_found = 1;
18773 }
18774
18775 /* Second and third can be numeric, boolean (i.e. primitive),
18776 references or null. Anything else results in an error */
18777 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
18778 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
18779 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
18780 || (t1 == boolean_type_node && t2 == boolean_type_node)))
18781 error_found = 1;
18782
18783 /* Determine the type of the conditional expression. Same types are
18784 easy to deal with */
18785 else if (t1 == t2)
18786 resulting_type = t1;
18787
18788 /* There are different rules for numeric types */
18789 else if (JNUMERIC_TYPE_P (t1))
18790 {
18791 /* if byte/short found, the resulting type is short */
18792 if ((t1 == byte_type_node && t2 == short_type_node)
18793 || (t1 == short_type_node && t2 == byte_type_node))
18794 resulting_type = short_type_node;
18795
18796 /* If t1 is a constant int and t2 is of type byte, short or char
18797 and t1's value fits in t2, then the resulting type is t2 */
18798 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
18799 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
18800 resulting_type = t2;
18801
18802 /* If t2 is a constant int and t1 is of type byte, short or char
18803 and t2's value fits in t1, then the resulting type is t1 */
18804 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
18805 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
18806 resulting_type = t1;
18807
18808 /* Otherwise, binary numeric promotion is applied and the
18809 resulting type is the promoted type of operand 1 and 2 */
18810 else
18811 resulting_type = binary_numeric_promotion (t1, t2,
18812 &TREE_OPERAND (node, 1),
18813 &TREE_OPERAND (node, 2));
18814 }
18815
18816 /* Cases of a reference and a null type */
18817 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
18818 resulting_type = t1;
18819
18820 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
18821 resulting_type = t2;
18822
18823 /* Last case: different reference types. If a type can be converted
18824 into the other one by assignment conversion, the latter
18825 determines the type of the expression */
18826 else if ((resulting_type = try_reference_assignconv (t1, op2)))
18827 resulting_type = promote_type (t1);
18828
18829 else if ((resulting_type = try_reference_assignconv (t2, op1)))
18830 resulting_type = promote_type (t2);
18831
18832 /* If we don't have any resulting type, we're in trouble */
18833 if (!resulting_type)
18834 {
18835 char *t = xstrdup (lang_printable_name (t1, 0));
18836 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
18837 parse_error_context (wfl_operator,
18838 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
18839 t, lang_printable_name (t2, 0));
18840 free (t);
18841 error_found = 1;
18842 }
18843
18844 if (error_found)
18845 {
18846 TREE_TYPE (node) = error_mark_node;
18847 return error_mark_node;
18848 }
18849
18850 TREE_TYPE (node) = resulting_type;
18851 TREE_SET_CODE (node, COND_EXPR);
18852 CAN_COMPLETE_NORMALLY (node) = 1;
18853 return node;
18854 }
18855
18856 /* Wrap EXPR with code to initialize DECL's class, if appropriate. */
18857
18858 static tree
maybe_build_class_init_for_field(tree decl,tree expr)18859 maybe_build_class_init_for_field (tree decl, tree expr)
18860 {
18861 tree clas = DECL_CONTEXT (decl);
18862 if (flag_emit_class_files || flag_emit_xref)
18863 return expr;
18864
18865 if (TREE_CODE (decl) == VAR_DECL && FIELD_STATIC (decl)
18866 && FIELD_FINAL (decl))
18867 {
18868 tree init = DECL_INITIAL (decl);
18869 if (init != NULL_TREE)
18870 init = fold_constant_for_init (init, decl);
18871 if (init != NULL_TREE && CONSTANT_VALUE_P (init))
18872 return expr;
18873 }
18874
18875 return build_class_init (clas, expr);
18876 }
18877
18878 /* Try to constant fold NODE.
18879 If NODE is not a constant expression, return NULL_EXPR.
18880 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
18881
18882 static tree
fold_constant_for_init(tree node,tree context)18883 fold_constant_for_init (tree node, tree context)
18884 {
18885 tree op0, op1, val;
18886 enum tree_code code = TREE_CODE (node);
18887
18888 switch (code)
18889 {
18890 case INTEGER_CST:
18891 if (node == null_pointer_node)
18892 return NULL_TREE;
18893 case STRING_CST:
18894 case REAL_CST:
18895 return node;
18896
18897 case PLUS_EXPR:
18898 case MINUS_EXPR:
18899 case MULT_EXPR:
18900 case TRUNC_MOD_EXPR:
18901 case RDIV_EXPR:
18902 case LSHIFT_EXPR:
18903 case RSHIFT_EXPR:
18904 case URSHIFT_EXPR:
18905 case BIT_AND_EXPR:
18906 case BIT_XOR_EXPR:
18907 case BIT_IOR_EXPR:
18908 case TRUTH_ANDIF_EXPR:
18909 case TRUTH_ORIF_EXPR:
18910 case EQ_EXPR:
18911 case NE_EXPR:
18912 case GT_EXPR:
18913 case GE_EXPR:
18914 case LT_EXPR:
18915 case LE_EXPR:
18916 op0 = TREE_OPERAND (node, 0);
18917 op1 = TREE_OPERAND (node, 1);
18918 val = fold_constant_for_init (op0, context);
18919 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18920 return NULL_TREE;
18921 TREE_OPERAND (node, 0) = val;
18922 val = fold_constant_for_init (op1, context);
18923 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18924 return NULL_TREE;
18925 TREE_OPERAND (node, 1) = val;
18926 return patch_binop (node, op0, op1);
18927
18928 case UNARY_PLUS_EXPR:
18929 case NEGATE_EXPR:
18930 case TRUTH_NOT_EXPR:
18931 case BIT_NOT_EXPR:
18932 case CONVERT_EXPR:
18933 op0 = TREE_OPERAND (node, 0);
18934 val = fold_constant_for_init (op0, context);
18935 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18936 return NULL_TREE;
18937 TREE_OPERAND (node, 0) = val;
18938 val = patch_unaryop (node, op0);
18939 if (! TREE_CONSTANT (val))
18940 return NULL_TREE;
18941 return val;
18942
18943 break;
18944
18945 case COND_EXPR:
18946 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
18947 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18948 return NULL_TREE;
18949 TREE_OPERAND (node, 0) = val;
18950 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
18951 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18952 return NULL_TREE;
18953 TREE_OPERAND (node, 1) = val;
18954 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
18955 if (val == NULL_TREE || ! TREE_CONSTANT (val))
18956 return NULL_TREE;
18957 TREE_OPERAND (node, 2) = val;
18958 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
18959 : TREE_OPERAND (node, 2);
18960
18961 case VAR_DECL:
18962 case FIELD_DECL:
18963 if (! FIELD_FINAL (node)
18964 || DECL_INITIAL (node) == NULL_TREE)
18965 return NULL_TREE;
18966 val = DECL_INITIAL (node);
18967 /* Guard against infinite recursion. */
18968 DECL_INITIAL (node) = NULL_TREE;
18969 val = fold_constant_for_init (val, node);
18970 if (val != NULL_TREE && TREE_CODE (val) != STRING_CST)
18971 val = try_builtin_assignconv (NULL_TREE, TREE_TYPE (node), val);
18972 DECL_INITIAL (node) = val;
18973 return val;
18974
18975 case EXPR_WITH_FILE_LOCATION:
18976 /* Compare java_complete_tree and resolve_expression_name. */
18977 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
18978 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
18979 {
18980 tree name = EXPR_WFL_NODE (node);
18981 tree decl;
18982 if (PRIMARY_P (node))
18983 return NULL_TREE;
18984 else if (! QUALIFIED_P (name))
18985 {
18986 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
18987 if (decl == NULL_TREE
18988 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
18989 return NULL_TREE;
18990 return fold_constant_for_init (decl, decl);
18991 }
18992 else
18993 {
18994 /* Install the proper context for the field resolution.
18995 The prior context is restored once the name is
18996 properly qualified. */
18997 tree saved_current_class = current_class;
18998 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
18999 current_class = DECL_CONTEXT (context);
19000 qualify_ambiguous_name (node);
19001 current_class = saved_current_class;
19002 if (resolve_field_access (node, &decl, NULL)
19003 && decl != NULL_TREE)
19004 return fold_constant_for_init (decl, decl);
19005 return NULL_TREE;
19006 }
19007 }
19008 else
19009 {
19010 op0 = TREE_OPERAND (node, 0);
19011 val = fold_constant_for_init (op0, context);
19012 if (val == NULL_TREE || ! TREE_CONSTANT (val))
19013 return NULL_TREE;
19014 TREE_OPERAND (node, 0) = val;
19015 return val;
19016 }
19017
19018 #ifdef USE_COMPONENT_REF
19019 case IDENTIFIER:
19020 case COMPONENT_REF:
19021 ?;
19022 #endif
19023
19024 default:
19025 return NULL_TREE;
19026 }
19027 }
19028
19029 #ifdef USE_COMPONENT_REF
19030 /* Context is 'T' for TypeName, 'P' for PackageName,
19031 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
19032
19033 tree
resolve_simple_name(tree name,int context)19034 resolve_simple_name (tree name, int context)
19035 {
19036 }
19037
19038 tree
resolve_qualified_name(tree name,int context)19039 resolve_qualified_name (tree name, int context)
19040 {
19041 }
19042 #endif
19043
19044 void
init_src_parse(void)19045 init_src_parse (void)
19046 {
19047 /* Sanity check; we've been bit by this before. */
19048 if (ARRAY_SIZE (ctxp->modifier_ctx) != MODIFIER_TK - PUBLIC_TK)
19049 abort ();
19050 }
19051
19052
19053
19054 /* This section deals with the functions that are called when tables
19055 recording class initialization information are traversed. */
19056
19057 /* Attach to PTR (a block) the declaration found in ENTRY. */
19058
19059 static int
attach_init_test_initialization_flags(void ** entry,void * ptr)19060 attach_init_test_initialization_flags (void **entry, void *ptr)
19061 {
19062 tree block = (tree)ptr;
19063 struct treetreehash_entry *ite = (struct treetreehash_entry *) *entry;
19064
19065 if (block != error_mark_node)
19066 {
19067 TREE_CHAIN (ite->value) = BLOCK_EXPR_DECLS (block);
19068 BLOCK_EXPR_DECLS (block) = ite->value;
19069 }
19070 return true;
19071 }
19072
19073 /* This function is called for each class that is known definitely
19074 initialized when a given static method was called. This function
19075 augments a compound expression (INFO) storing all assignment to
19076 initialized static class flags if a flag already existed, otherwise
19077 a new one is created. */
19078
19079 static int
emit_test_initialization(void ** entry_p,void * info)19080 emit_test_initialization (void **entry_p, void *info)
19081 {
19082 tree l = (tree) info;
19083 tree decl, init;
19084 tree key = (tree) *entry_p;
19085 tree *ite;
19086 htab_t cf_ht = DECL_FUNCTION_INIT_TEST_TABLE (current_function_decl);
19087
19088 /* If we haven't found a flag and we're dealing with self registered
19089 with current_function_decl, then don't do anything. Self is
19090 always added as definitely initialized but this information is
19091 valid only if used outside the current function. */
19092 if (current_function_decl == TREE_PURPOSE (l)
19093 && java_treetreehash_find (cf_ht, key) == NULL)
19094 return true;
19095
19096 ite = java_treetreehash_new (cf_ht, key);
19097
19098 /* If we don't have a variable, create one and install it. */
19099 if (*ite == NULL)
19100 {
19101 tree block;
19102
19103 decl = build_decl (VAR_DECL, NULL_TREE, boolean_type_node);
19104 MAYBE_CREATE_VAR_LANG_DECL_SPECIFIC (decl);
19105 LOCAL_CLASS_INITIALIZATION_FLAG (decl) = 1;
19106 DECL_CONTEXT (decl) = current_function_decl;
19107 DECL_INITIAL (decl) = boolean_true_node;
19108 /* Don't emit any symbolic debugging info for this decl. */
19109 DECL_IGNORED_P (decl) = 1;
19110
19111 /* The trick is to find the right context for it. */
19112 block = BLOCK_SUBBLOCKS (GET_CURRENT_BLOCK (current_function_decl));
19113 TREE_CHAIN (decl) = BLOCK_EXPR_DECLS (block);
19114 BLOCK_EXPR_DECLS (block) = decl;
19115 *ite = decl;
19116 }
19117 else
19118 decl = *ite;
19119
19120 /* Now simply augment the compound that holds all the assignments
19121 pertaining to this method invocation. */
19122 init = build (MODIFY_EXPR, boolean_type_node, decl, boolean_true_node);
19123 TREE_SIDE_EFFECTS (init) = 1;
19124 TREE_VALUE (l) = add_stmt_to_compound (TREE_VALUE (l), void_type_node, init);
19125 TREE_SIDE_EFFECTS (TREE_VALUE (l)) = 1;
19126
19127 return true;
19128 }
19129
19130 #include "gt-java-parse.h"
19131 #include "gtype-java.h"
19132