Remove Dwarf2 restriction on EH frame generation
[official-gcc.git] / gcc / java / parse.c
blobf65e21fccf13d23ee66464445a08361e0ce6586d
2 /* A Bison parser, made from ./parse.y
3 by GNU Bison version 1.25
4 */
6 #define YYBISON 1 /* Identify Bison output. */
8 #define yyparse java_parse
9 #define yylex java_lex
10 #define yyerror java_error
11 #define yylval java_lval
12 #define yychar java_char
13 #define yydebug java_debug
14 #define yynerrs java_nerrs
15 #define PLUS_TK 258
16 #define MINUS_TK 259
17 #define MULT_TK 260
18 #define DIV_TK 261
19 #define REM_TK 262
20 #define LS_TK 263
21 #define SRS_TK 264
22 #define ZRS_TK 265
23 #define AND_TK 266
24 #define XOR_TK 267
25 #define OR_TK 268
26 #define BOOL_AND_TK 269
27 #define BOOL_OR_TK 270
28 #define EQ_TK 271
29 #define NEQ_TK 272
30 #define GT_TK 273
31 #define GTE_TK 274
32 #define LT_TK 275
33 #define LTE_TK 276
34 #define PLUS_ASSIGN_TK 277
35 #define MINUS_ASSIGN_TK 278
36 #define MULT_ASSIGN_TK 279
37 #define DIV_ASSIGN_TK 280
38 #define REM_ASSIGN_TK 281
39 #define LS_ASSIGN_TK 282
40 #define SRS_ASSIGN_TK 283
41 #define ZRS_ASSIGN_TK 284
42 #define AND_ASSIGN_TK 285
43 #define XOR_ASSIGN_TK 286
44 #define OR_ASSIGN_TK 287
45 #define PUBLIC_TK 288
46 #define PRIVATE_TK 289
47 #define PROTECTED_TK 290
48 #define STATIC_TK 291
49 #define FINAL_TK 292
50 #define SYNCHRONIZED_TK 293
51 #define VOLATILE_TK 294
52 #define TRANSIENT_TK 295
53 #define NATIVE_TK 296
54 #define PAD_TK 297
55 #define ABSTRACT_TK 298
56 #define MODIFIER_TK 299
57 #define DECR_TK 300
58 #define INCR_TK 301
59 #define DEFAULT_TK 302
60 #define IF_TK 303
61 #define THROW_TK 304
62 #define BOOLEAN_TK 305
63 #define DO_TK 306
64 #define IMPLEMENTS_TK 307
65 #define THROWS_TK 308
66 #define BREAK_TK 309
67 #define IMPORT_TK 310
68 #define ELSE_TK 311
69 #define INSTANCEOF_TK 312
70 #define RETURN_TK 313
71 #define VOID_TK 314
72 #define CATCH_TK 315
73 #define INTERFACE_TK 316
74 #define CASE_TK 317
75 #define EXTENDS_TK 318
76 #define FINALLY_TK 319
77 #define SUPER_TK 320
78 #define WHILE_TK 321
79 #define CLASS_TK 322
80 #define SWITCH_TK 323
81 #define CONST_TK 324
82 #define TRY_TK 325
83 #define FOR_TK 326
84 #define NEW_TK 327
85 #define CONTINUE_TK 328
86 #define GOTO_TK 329
87 #define PACKAGE_TK 330
88 #define THIS_TK 331
89 #define BYTE_TK 332
90 #define SHORT_TK 333
91 #define INT_TK 334
92 #define LONG_TK 335
93 #define CHAR_TK 336
94 #define INTEGRAL_TK 337
95 #define FLOAT_TK 338
96 #define DOUBLE_TK 339
97 #define FP_TK 340
98 #define ID_TK 341
99 #define REL_QM_TK 342
100 #define REL_CL_TK 343
101 #define NOT_TK 344
102 #define NEG_TK 345
103 #define ASSIGN_ANY_TK 346
104 #define ASSIGN_TK 347
105 #define OP_TK 348
106 #define CP_TK 349
107 #define OCB_TK 350
108 #define CCB_TK 351
109 #define OSB_TK 352
110 #define CSB_TK 353
111 #define SC_TK 354
112 #define C_TK 355
113 #define DOT_TK 356
114 #define STRING_LIT_TK 357
115 #define CHAR_LIT_TK 358
116 #define INT_LIT_TK 359
117 #define FP_LIT_TK 360
118 #define TRUE_TK 361
119 #define FALSE_TK 362
120 #define BOOL_LIT_TK 363
121 #define NULL_TK 364
123 #line 48 "./parse.y"
125 #include "config.h"
126 #include "system.h"
127 #include <dirent.h>
128 #include "tree.h"
129 #include "rtl.h"
130 #include "obstack.h"
131 #include "toplev.h"
132 #include "flags.h"
133 #include "java-tree.h"
134 #include "jcf.h"
135 #include "lex.h"
136 #include "parse.h"
137 #include "zipfile.h"
138 #include "convert.h"
139 #include "buffer.h"
140 #include "xref.h"
141 #include "function.h"
142 #include "except.h"
143 #include "defaults.h"
145 #ifndef DIR_SEPARATOR
146 #define DIR_SEPARATOR '/'
147 #endif
149 /* Local function prototypes */
150 static char *java_accstring_lookup PARAMS ((int));
151 static void classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
152 static void variable_redefinition_error PARAMS ((tree, tree, tree, int));
153 static tree create_class PARAMS ((int, tree, tree, tree));
154 static tree create_interface PARAMS ((int, tree, tree));
155 static void end_class_declaration PARAMS ((int));
156 static tree find_field PARAMS ((tree, tree));
157 static tree lookup_field_wrapper PARAMS ((tree, tree));
158 static int duplicate_declaration_error_p PARAMS ((tree, tree, tree));
159 static void register_fields PARAMS ((int, tree, tree));
160 static tree parser_qualified_classname PARAMS ((int, tree));
161 static int parser_check_super PARAMS ((tree, tree, tree));
162 static int parser_check_super_interface PARAMS ((tree, tree, tree));
163 static void check_modifiers_consistency PARAMS ((int));
164 static tree lookup_cl PARAMS ((tree));
165 static tree lookup_java_method2 PARAMS ((tree, tree, int));
166 static tree method_header PARAMS ((int, tree, tree, tree));
167 static void fix_method_argument_names PARAMS ((tree ,tree));
168 static tree method_declarator PARAMS ((tree, tree));
169 static void parse_warning_context PARAMS ((tree cl, const char *msg, ...))
170 ATTRIBUTE_PRINTF_2;
171 static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list));
172 static void parse_ctor_invocation_error PARAMS ((void));
173 static tree parse_jdk1_1_error PARAMS ((const char *));
174 static void complete_class_report_errors PARAMS ((jdep *));
175 static int process_imports PARAMS ((void));
176 static void read_import_dir PARAMS ((tree));
177 static int find_in_imports_on_demand PARAMS ((tree));
178 static int find_in_imports PARAMS ((tree));
179 static int check_pkg_class_access PARAMS ((tree, tree));
180 static tree resolve_package PARAMS ((tree, tree *));
181 static tree lookup_package_type PARAMS ((const char *, int));
182 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
183 static tree resolve_class PARAMS ((tree, tree, tree, tree));
184 static void declare_local_variables PARAMS ((int, tree, tree));
185 static void source_start_java_method PARAMS ((tree));
186 static void source_end_java_method PARAMS ((void));
187 static void expand_start_java_method PARAMS ((tree));
188 static tree find_name_in_single_imports PARAMS ((tree));
189 static void check_abstract_method_header PARAMS ((tree));
190 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
191 static tree resolve_expression_name PARAMS ((tree, tree *));
192 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
193 static int check_class_interface_creation PARAMS ((int, int, tree,
194 tree, tree, tree));
195 static tree patch_method_invocation PARAMS ((tree, tree, tree,
196 int *, tree *));
197 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
198 static tree resolve_and_layout PARAMS ((tree, tree));
199 static tree resolve_no_layout PARAMS ((tree, tree));
200 static int invocation_mode PARAMS ((tree, int));
201 static tree find_applicable_accessible_methods_list PARAMS ((int, tree,
202 tree, tree));
203 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree,
204 tree *, tree *));
205 static tree find_most_specific_methods_list PARAMS ((tree));
206 static int argument_types_convertible PARAMS ((tree, tree));
207 static tree patch_invoke PARAMS ((tree, tree, tree));
208 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
209 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
210 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
211 static tree obtain_incomplete_type PARAMS ((tree));
212 static tree java_complete_lhs PARAMS ((tree));
213 static tree java_complete_tree PARAMS ((tree));
214 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
215 static void java_complete_expand_method PARAMS ((tree));
216 static int unresolved_type_p PARAMS ((tree, tree *));
217 static void create_jdep_list PARAMS ((struct parser_ctxt *));
218 static tree build_expr_block PARAMS ((tree, tree));
219 static tree enter_block PARAMS ((void));
220 static tree enter_a_block PARAMS ((tree));
221 static tree exit_block PARAMS ((void));
222 static tree lookup_name_in_blocks PARAMS ((tree));
223 static void maybe_absorb_scoping_blocks PARAMS ((void));
224 static tree build_method_invocation PARAMS ((tree, tree));
225 static tree build_new_invocation PARAMS ((tree, tree));
226 static tree build_assignment PARAMS ((int, int, tree, tree));
227 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
228 static int check_final_assignment PARAMS ((tree ,tree));
229 static tree patch_assignment PARAMS ((tree, tree, tree ));
230 static tree patch_binop PARAMS ((tree, tree, tree));
231 static tree build_unaryop PARAMS ((int, int, tree));
232 static tree build_incdec PARAMS ((int, int, tree, int));
233 static tree patch_unaryop PARAMS ((tree, tree));
234 static tree build_cast PARAMS ((int, tree, tree));
235 static tree build_null_of_type PARAMS ((tree));
236 static tree patch_cast PARAMS ((tree, tree));
237 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
238 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
239 static int valid_cast_to_p PARAMS ((tree, tree));
240 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
241 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
242 static tree try_reference_assignconv PARAMS ((tree, tree));
243 static tree build_unresolved_array_type PARAMS ((tree));
244 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
245 static tree build_array_ref PARAMS ((int, tree, tree));
246 static tree patch_array_ref PARAMS ((tree));
247 static tree make_qualified_name PARAMS ((tree, tree, int));
248 static tree merge_qualified_name PARAMS ((tree, tree));
249 static tree make_qualified_primary PARAMS ((tree, tree, int));
250 static int resolve_qualified_expression_name PARAMS ((tree, tree *,
251 tree *, tree *));
252 static void qualify_ambiguous_name PARAMS ((tree));
253 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
254 static tree build_newarray_node PARAMS ((tree, tree, int));
255 static tree patch_newarray PARAMS ((tree));
256 static tree resolve_type_during_patch PARAMS ((tree));
257 static tree build_this PARAMS ((int));
258 static tree build_wfl_wrap PARAMS ((tree));
259 static tree build_return PARAMS ((int, tree));
260 static tree patch_return PARAMS ((tree));
261 static tree maybe_access_field PARAMS ((tree, tree, tree));
262 static int complete_function_arguments PARAMS ((tree));
263 static int check_for_static_method_reference PARAMS ((tree, tree, tree,
264 tree, tree));
265 static int not_accessible_p PARAMS ((tree, tree, int));
266 static void check_deprecation PARAMS ((tree, tree));
267 static int class_in_current_package PARAMS ((tree));
268 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
269 static tree patch_if_else_statement PARAMS ((tree));
270 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
271 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
272 static tree patch_exit_expr PARAMS ((tree));
273 static tree build_labeled_block PARAMS ((int, tree));
274 static tree finish_labeled_statement PARAMS ((tree, tree));
275 static tree build_bc_statement PARAMS ((int, int, tree));
276 static tree patch_bc_statement PARAMS ((tree));
277 static tree patch_loop_statement PARAMS ((tree));
278 static tree build_new_loop PARAMS ((tree));
279 static tree build_loop_body PARAMS ((int, tree, int));
280 static tree finish_loop_body PARAMS ((int, tree, tree, int));
281 static tree build_debugable_stmt PARAMS ((int, tree));
282 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
283 static tree patch_switch_statement PARAMS ((tree));
284 static tree string_constant_concatenation PARAMS ((tree, tree));
285 static tree build_string_concatenation PARAMS ((tree, tree));
286 static tree patch_string_cst PARAMS ((tree));
287 static tree patch_string PARAMS ((tree));
288 static tree build_try_statement PARAMS ((int, tree, tree));
289 static tree build_try_finally_statement PARAMS ((int, tree, tree));
290 static tree patch_try_statement PARAMS ((tree));
291 static tree patch_synchronized_statement PARAMS ((tree, tree));
292 static tree patch_throw_statement PARAMS ((tree, tree));
293 static void check_thrown_exceptions PARAMS ((int, tree));
294 static int check_thrown_exceptions_do PARAMS ((tree));
295 static void purge_unchecked_exceptions PARAMS ((tree));
296 static void check_throws_clauses PARAMS ((tree, tree, tree));
297 static void finish_method_declaration PARAMS ((tree));
298 static tree build_super_invocation PARAMS ((tree));
299 static int verify_constructor_circularity PARAMS ((tree, tree));
300 static char *constructor_circularity_msg PARAMS ((tree, tree));
301 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
302 int, int));
303 static const char *get_printable_method_name PARAMS ((tree));
304 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
305 static tree generate_finit PARAMS ((tree));
306 static void add_instance_initializer PARAMS ((tree));
307 static void fix_constructors PARAMS ((tree));
308 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
309 tree, int *));
310 static void craft_constructor PARAMS ((tree, tree));
311 static int verify_constructor_super PARAMS ((tree));
312 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
313 static void start_artificial_method_body PARAMS ((tree));
314 static void end_artificial_method_body PARAMS ((tree));
315 static int check_method_redefinition PARAMS ((tree, tree));
316 static int reset_method_name PARAMS ((tree));
317 static int check_method_types_complete PARAMS ((tree));
318 static void java_check_regular_methods PARAMS ((tree));
319 static void java_check_abstract_methods PARAMS ((tree));
320 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
321 static void unreachable_stmt_error PARAMS ((tree));
322 static tree find_expr_with_wfl PARAMS ((tree));
323 static void missing_return_error PARAMS ((tree));
324 static tree build_new_array_init PARAMS ((int, tree));
325 static tree patch_new_array_init PARAMS ((tree, tree));
326 static tree maybe_build_array_element_wfl PARAMS ((tree));
327 static int array_constructor_check_entry PARAMS ((tree, tree));
328 static const char *purify_type_name PARAMS ((const char *));
329 static tree fold_constant_for_init PARAMS ((tree, tree));
330 static tree strip_out_static_field_access_decl PARAMS ((tree));
331 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
332 static void static_ref_err PARAMS ((tree, tree, tree));
333 static void parser_add_interface PARAMS ((tree, tree, tree));
334 static void add_superinterfaces PARAMS ((tree, tree));
335 static tree jdep_resolve_class PARAMS ((jdep *));
336 static int note_possible_classname PARAMS ((const char *, int));
337 static void java_complete_expand_classes PARAMS ((void));
338 static void java_complete_expand_class PARAMS ((tree));
339 static void java_complete_expand_methods PARAMS ((tree));
340 static tree cut_identifier_in_qualified PARAMS ((tree));
341 static tree java_stabilize_reference PARAMS ((tree));
342 static tree do_unary_numeric_promotion PARAMS ((tree));
343 static char * operator_string PARAMS ((tree));
344 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
345 static tree merge_string_cste PARAMS ((tree, tree, int));
346 static tree java_refold PARAMS ((tree));
347 static int java_decl_equiv PARAMS ((tree, tree));
348 static int binop_compound_p PARAMS ((enum tree_code));
349 static tree search_loop PARAMS ((tree));
350 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
351 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
352 static void java_check_abstract_method_definitions PARAMS ((tree));
353 static void java_debug_context_do PARAMS ((int));
354 static void java_parser_context_push_initialized_field PARAMS ((void));
355 static void java_parser_context_pop_initialized_field PARAMS ((void));
356 static tree reorder_static_initialized PARAMS ((tree));
357 static void java_parser_context_suspend PARAMS ((void));
358 static void java_parser_context_resume PARAMS ((void));
360 /* JDK 1.1 work. FIXME */
362 static tree maybe_make_nested_class_name PARAMS ((tree));
363 static void make_nested_class_name PARAMS ((tree));
364 static void set_nested_class_simple_name_value PARAMS ((tree, int));
365 static void link_nested_class_to_enclosing PARAMS ((void));
366 static tree find_as_inner_class PARAMS ((tree, tree, tree));
367 static tree find_as_inner_class_do PARAMS ((tree, tree));
368 static int check_inner_class_redefinition PARAMS ((tree, tree));
370 static tree build_thisn_assign PARAMS ((void));
371 static tree build_current_thisn PARAMS ((tree));
372 static tree build_access_to_thisn PARAMS ((tree, tree, int));
373 static tree maybe_build_thisn_access_method PARAMS ((tree));
375 static tree build_outer_field_access PARAMS ((tree, tree));
376 static tree build_outer_field_access_methods PARAMS ((tree));
377 static tree build_outer_field_access_expr PARAMS ((int, tree, tree,
378 tree, tree));
379 static tree build_outer_method_access_method PARAMS ((tree));
380 static tree build_new_access_id PARAMS ((void));
381 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
382 tree, tree));
384 static int outer_field_access_p PARAMS ((tree, tree));
385 static int outer_field_expanded_access_p PARAMS ((tree, tree *,
386 tree *, tree *));
387 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
388 static tree build_incomplete_class_ref PARAMS ((int, tree));
389 static tree patch_incomplete_class_ref PARAMS ((tree));
390 static tree create_anonymous_class PARAMS ((int, tree));
391 static void patch_anonymous_class PARAMS ((tree, tree, tree));
392 static void add_inner_class_fields PARAMS ((tree, tree));
394 static tree build_dot_class_method PARAMS ((tree));
395 static tree build_dot_class_method_invocation PARAMS ((tree));
396 static void create_new_parser_context PARAMS ((int));
398 /* Number of error found so far. */
399 int java_error_count;
400 /* Number of warning found so far. */
401 int java_warning_count;
402 /* Tell when not to fold, when doing xrefs */
403 int do_not_fold;
404 /* Cyclic inheritance report, as it can be set by layout_class */
405 char *cyclic_inheritance_report;
407 /* Tell when we're within an instance initializer */
408 static int in_instance_initializer;
410 /* The current parser context */
411 struct parser_ctxt *ctxp;
413 /* List of things that were analyzed for which code will be generated */
414 static struct parser_ctxt *ctxp_for_generation = NULL;
416 /* binop_lookup maps token to tree_code. It is used where binary
417 operations are involved and required by the parser. RDIV_EXPR
418 covers both integral/floating point division. The code is changed
419 once the type of both operator is worked out. */
421 static enum tree_code binop_lookup[19] =
423 PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
424 LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR,
425 BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
426 TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
427 EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
429 #define BINOP_LOOKUP(VALUE) \
430 binop_lookup [((VALUE) - PLUS_TK)% \
431 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
433 /* This is the end index for binary operators that can also be used
434 in compound assignements. */
435 #define BINOP_COMPOUND_CANDIDATES 11
437 /* Fake WFL used to report error message. It is initialized once if
438 needed and reused with it's location information is overriden. */
439 tree wfl_operator = NULL_TREE;
441 /* The "$L" identifier we use to create labels. */
442 static tree label_id = NULL_TREE;
444 /* The "StringBuffer" identifier used for the String `+' operator. */
445 static tree wfl_string_buffer = NULL_TREE;
447 /* The "append" identifier used for String `+' operator. */
448 static tree wfl_append = NULL_TREE;
450 /* The "toString" identifier used for String `+' operator. */
451 static tree wfl_to_string = NULL_TREE;
453 /* The "java.lang" import qualified name. */
454 static tree java_lang_id = NULL_TREE;
456 /* The generated `inst$' identifier used for generated enclosing
457 instance/field access functions. */
458 static tree inst_id = NULL_TREE;
460 /* The "java.lang.Cloneable" qualified name. */
461 static tree java_lang_cloneable = NULL_TREE;
463 /* Context and flag for static blocks */
464 static tree current_static_block = NULL_TREE;
466 /* The generated `write_parm_value$' identifier. */
467 static tree wpv_id;
469 /* The list of all packages we've seen so far */
470 static tree package_list = NULL_TREE;
472 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
473 line and point it out. */
474 /* Should point out the one that don't fit. ASCII/unicode, going
475 backward. FIXME */
477 #define check_modifiers(__message, __value, __mask) do { \
478 if ((__value) & ~(__mask)) \
480 int i, remainder = (__value) & ~(__mask); \
481 for (i = 0; i <= 10; i++) \
482 if ((1 << i) & remainder) \
483 parse_error_context (ctxp->modifier_ctx [i], (__message), \
484 java_accstring_lookup (1 << i)); \
486 } while (0)
489 #line 414 "./parse.y"
490 typedef union {
491 tree node;
492 int sub_token;
493 struct {
494 int token;
495 int location;
496 } operator;
497 int value;
498 } YYSTYPE;
499 #line 424 "./parse.y"
501 #include "lex.c"
502 #ifndef YYDEBUG
503 #define YYDEBUG 1
504 #endif
506 #include <stdio.h>
508 #ifndef __cplusplus
509 #ifndef __STDC__
510 #define const
511 #endif
512 #endif
516 #define YYFINAL 791
517 #define YYFLAG -32768
518 #define YYNTBASE 110
520 #define YYTRANSLATE(x) ((unsigned)(x) <= 364 ? yytranslate[x] : 272)
522 static const char yytranslate[] = { 0,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
541 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
542 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
544 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 2, 2, 2, 2, 2, 1, 2, 3, 4, 5,
549 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
550 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
551 26, 27, 28, 29, 30, 31, 32, 33, 34, 35,
552 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
553 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
554 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
555 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
556 76, 77, 78, 79, 80, 81, 82, 83, 84, 85,
557 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
558 96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
559 106, 107, 108, 109
562 #if YYDEBUG != 0
563 static const short yyprhs[] = { 0,
564 0, 2, 4, 6, 8, 10, 12, 14, 16, 18,
565 20, 22, 24, 26, 28, 30, 32, 34, 38, 42,
566 46, 50, 54, 56, 58, 60, 64, 66, 67, 69,
567 71, 73, 76, 79, 82, 86, 88, 91, 93, 96,
568 100, 103, 107, 109, 111, 115, 118, 122, 128, 133,
569 139, 141, 143, 145, 147, 149, 152, 153, 161, 162,
570 169, 173, 176, 180, 185, 186, 189, 193, 196, 197,
571 200, 203, 205, 209, 213, 216, 220, 222, 225, 227,
572 229, 231, 233, 235, 238, 240, 242, 244, 248, 253,
573 255, 259, 263, 265, 269, 273, 278, 280, 284, 287,
574 291, 295, 297, 299, 300, 304, 307, 311, 315, 320,
575 325, 328, 332, 335, 339, 342, 346, 351, 355, 359,
576 363, 365, 369, 373, 376, 380, 383, 387, 389, 390,
577 393, 396, 398, 402, 406, 408, 411, 413, 416, 420,
578 422, 423, 427, 430, 434, 438, 443, 446, 450, 454,
579 459, 461, 464, 469, 475, 483, 490, 492, 494, 495,
580 500, 501, 507, 508, 514, 515, 522, 526, 531, 534,
581 538, 541, 545, 548, 552, 554, 557, 559, 561, 563,
582 565, 567, 570, 573, 576, 580, 585, 587, 591, 595,
583 598, 602, 604, 606, 608, 611, 613, 615, 617, 620,
584 623, 627, 629, 631, 633, 635, 637, 639, 641, 643,
585 645, 647, 649, 651, 653, 655, 657, 659, 661, 663,
586 665, 667, 669, 671, 673, 676, 679, 682, 685, 688,
587 691, 694, 697, 701, 706, 711, 717, 722, 728, 735,
588 743, 750, 752, 754, 756, 758, 760, 762, 764, 770,
589 773, 777, 782, 790, 798, 799, 803, 808, 811, 815,
590 821, 824, 828, 832, 837, 839, 842, 845, 847, 850,
591 854, 857, 860, 864, 867, 872, 875, 878, 882, 887,
592 890, 892, 900, 908, 915, 919, 925, 930, 938, 945,
593 948, 951, 955, 958, 959, 961, 963, 966, 967, 969,
594 971, 975, 979, 982, 986, 989, 993, 996, 1000, 1003,
595 1007, 1010, 1014, 1017, 1021, 1025, 1028, 1032, 1038, 1044,
596 1047, 1052, 1056, 1058, 1062, 1066, 1071, 1074, 1076, 1079,
597 1082, 1087, 1090, 1094, 1099, 1102, 1105, 1107, 1109, 1111,
598 1113, 1117, 1119, 1121, 1123, 1125, 1127, 1131, 1135, 1139,
599 1143, 1147, 1151, 1155, 1159, 1163, 1167, 1171, 1177, 1182,
600 1184, 1189, 1195, 1201, 1208, 1212, 1216, 1221, 1227, 1230,
601 1234, 1235, 1243, 1244, 1251, 1255, 1259, 1261, 1265, 1269,
602 1273, 1277, 1282, 1287, 1292, 1297, 1301, 1305, 1307, 1310,
603 1314, 1318, 1321, 1324, 1328, 1332, 1336, 1340, 1343, 1347,
604 1352, 1358, 1365, 1371, 1378, 1383, 1388, 1393, 1398, 1402,
605 1407, 1411, 1416, 1418, 1420, 1422, 1424, 1427, 1430, 1432,
606 1434, 1437, 1440, 1442, 1445, 1448, 1451, 1454, 1457, 1460,
607 1462, 1465, 1468, 1470, 1473, 1476, 1482, 1487, 1492, 1498,
608 1503, 1506, 1512, 1517, 1523, 1525, 1529, 1533, 1537, 1541,
609 1545, 1549, 1551, 1555, 1559, 1563, 1567, 1569, 1573, 1577,
610 1581, 1585, 1589, 1593, 1595, 1599, 1603, 1607, 1611, 1615,
611 1619, 1623, 1627, 1631, 1635, 1637, 1641, 1645, 1649, 1653,
612 1655, 1659, 1663, 1665, 1669, 1673, 1675, 1679, 1683, 1685,
613 1689, 1693, 1695, 1699, 1703, 1705, 1711, 1716, 1720, 1726,
614 1728, 1730, 1734, 1738, 1740, 1742, 1744, 1746, 1748, 1750
617 static const short yyrhs[] = { 123,
618 0, 104, 0, 105, 0, 108, 0, 103, 0, 102,
619 0, 109, 0, 113, 0, 114, 0, 82, 0, 85,
620 0, 50, 0, 115, 0, 118, 0, 119, 0, 115,
621 0, 115, 0, 113, 97, 98, 0, 119, 97, 98,
622 0, 118, 97, 98, 0, 113, 97, 1, 0, 118,
623 97, 1, 0, 120, 0, 121, 0, 122, 0, 119,
624 101, 122, 0, 86, 0, 0, 126, 0, 124, 0,
625 125, 0, 126, 124, 0, 126, 125, 0, 124, 125,
626 0, 126, 124, 125, 0, 127, 0, 124, 127, 0,
627 130, 0, 125, 130, 0, 75, 119, 99, 0, 75,
628 1, 0, 75, 119, 1, 0, 128, 0, 129, 0,
629 55, 119, 99, 0, 55, 1, 0, 55, 119, 1,
630 0, 55, 119, 101, 5, 99, 0, 55, 119, 101,
631 1, 0, 55, 119, 101, 5, 1, 0, 132, 0,
632 167, 0, 99, 0, 1, 0, 44, 0, 131, 44,
633 0, 0, 131, 67, 122, 135, 136, 133, 138, 0,
634 0, 67, 122, 135, 136, 134, 138, 0, 131, 67,
635 1, 0, 67, 1, 0, 67, 122, 1, 0, 131,
636 67, 122, 1, 0, 0, 63, 116, 0, 63, 116,
637 1, 0, 63, 1, 0, 0, 52, 137, 0, 52,
638 1, 0, 117, 0, 137, 100, 117, 0, 137, 100,
639 1, 0, 95, 96, 0, 95, 139, 96, 0, 140,
640 0, 139, 140, 0, 141, 0, 157, 0, 159, 0,
641 180, 0, 142, 0, 142, 99, 0, 147, 0, 132,
642 0, 167, 0, 112, 143, 99, 0, 131, 112, 143,
643 99, 0, 144, 0, 143, 100, 144, 0, 143, 100,
644 1, 0, 145, 0, 145, 92, 146, 0, 145, 92,
645 1, 0, 145, 92, 146, 1, 0, 122, 0, 145,
646 97, 98, 0, 122, 1, 0, 145, 97, 1, 0,
647 145, 98, 1, 0, 270, 0, 178, 0, 0, 149,
648 148, 156, 0, 149, 1, 0, 112, 150, 154, 0,
649 59, 150, 154, 0, 131, 112, 150, 154, 0, 131,
650 59, 150, 154, 0, 112, 1, 0, 131, 112, 1,
651 0, 59, 1, 0, 131, 59, 1, 0, 131, 1,
652 0, 122, 93, 94, 0, 122, 93, 151, 94, 0,
653 150, 97, 98, 0, 122, 93, 1, 0, 150, 97,
654 1, 0, 152, 0, 151, 100, 152, 0, 151, 100,
655 1, 0, 112, 145, 0, 153, 112, 145, 0, 112,
656 1, 0, 153, 112, 1, 0, 131, 0, 0, 53,
657 155, 0, 53, 1, 0, 116, 0, 155, 100, 116,
658 0, 155, 100, 1, 0, 180, 0, 180, 99, 0,
659 99, 0, 158, 180, 0, 158, 180, 99, 0, 131,
660 0, 0, 161, 160, 163, 0, 162, 154, 0, 131,
661 162, 154, 0, 120, 93, 94, 0, 120, 93, 151,
662 94, 0, 181, 164, 0, 181, 165, 164, 0, 181,
663 183, 164, 0, 181, 165, 183, 164, 0, 182, 0,
664 182, 99, 0, 166, 93, 94, 99, 0, 166, 93,
665 239, 94, 99, 0, 119, 101, 65, 93, 239, 94,
666 99, 0, 119, 101, 65, 93, 94, 99, 0, 76,
667 0, 65, 0, 0, 61, 122, 168, 173, 0, 0,
668 131, 61, 122, 169, 173, 0, 0, 61, 122, 172,
669 170, 173, 0, 0, 131, 61, 122, 172, 171, 173,
670 0, 61, 122, 1, 0, 131, 61, 122, 1, 0,
671 63, 117, 0, 172, 100, 117, 0, 63, 1, 0,
672 172, 100, 1, 0, 95, 96, 0, 95, 174, 96,
673 0, 175, 0, 174, 175, 0, 176, 0, 177, 0,
674 132, 0, 167, 0, 142, 0, 149, 99, 0, 149,
675 1, 0, 95, 96, 0, 95, 179, 96, 0, 95,
676 179, 100, 96, 0, 146, 0, 179, 100, 146, 0,
677 179, 100, 1, 0, 95, 96, 0, 181, 183, 182,
678 0, 95, 0, 96, 0, 184, 0, 183, 184, 0,
679 185, 0, 187, 0, 132, 0, 186, 99, 0, 112,
680 143, 0, 153, 112, 143, 0, 189, 0, 192, 0,
681 196, 0, 197, 0, 208, 0, 212, 0, 189, 0,
682 193, 0, 198, 0, 209, 0, 213, 0, 180, 0,
683 190, 0, 194, 0, 199, 0, 211, 0, 219, 0,
684 220, 0, 221, 0, 223, 0, 222, 0, 225, 0,
685 99, 0, 122, 88, 0, 191, 187, 0, 122, 1,
686 0, 191, 188, 0, 195, 99, 0, 1, 99, 0,
687 1, 95, 0, 1, 96, 0, 166, 93, 1, 0,
688 166, 93, 94, 1, 0, 166, 93, 239, 1, 0,
689 166, 93, 239, 94, 1, 0, 119, 101, 65, 1,
690 0, 119, 101, 65, 93, 1, 0, 119, 101, 65,
691 93, 239, 1, 0, 119, 101, 65, 93, 239, 94,
692 1, 0, 119, 101, 65, 93, 94, 1, 0, 267,
693 0, 251, 0, 252, 0, 248, 0, 249, 0, 245,
694 0, 234, 0, 48, 93, 270, 94, 187, 0, 48,
695 1, 0, 48, 93, 1, 0, 48, 93, 270, 1,
696 0, 48, 93, 270, 94, 188, 56, 187, 0, 48,
697 93, 270, 94, 188, 56, 188, 0, 0, 201, 200,
698 202, 0, 68, 93, 270, 94, 0, 68, 1, 0,
699 68, 93, 1, 0, 68, 93, 270, 94, 1, 0,
700 95, 96, 0, 95, 205, 96, 0, 95, 203, 96,
701 0, 95, 203, 205, 96, 0, 204, 0, 203, 204,
702 0, 205, 183, 0, 206, 0, 205, 206, 0, 62,
703 271, 88, 0, 47, 88, 0, 62, 1, 0, 62,
704 271, 1, 0, 47, 1, 0, 66, 93, 270, 94,
705 0, 207, 187, 0, 66, 1, 0, 66, 93, 1,
706 0, 66, 93, 270, 1, 0, 207, 188, 0, 51,
707 0, 210, 187, 66, 93, 270, 94, 99, 0, 215,
708 99, 270, 99, 217, 94, 187, 0, 215, 99, 99,
709 217, 94, 187, 0, 215, 99, 1, 0, 215, 99,
710 270, 99, 1, 0, 215, 99, 99, 1, 0, 215,
711 99, 270, 99, 217, 94, 188, 0, 215, 99, 99,
712 217, 94, 188, 0, 71, 93, 0, 71, 1, 0,
713 71, 93, 1, 0, 214, 216, 0, 0, 218, 0,
714 186, 0, 218, 1, 0, 0, 218, 0, 195, 0,
715 218, 100, 195, 0, 218, 100, 1, 0, 54, 99,
716 0, 54, 122, 99, 0, 54, 1, 0, 54, 122,
717 1, 0, 73, 99, 0, 73, 122, 99, 0, 73,
718 1, 0, 73, 122, 1, 0, 58, 99, 0, 58,
719 270, 99, 0, 58, 1, 0, 58, 270, 1, 0,
720 49, 270, 99, 0, 49, 1, 0, 49, 270, 1,
721 0, 224, 93, 270, 94, 180, 0, 224, 93, 270,
722 94, 1, 0, 224, 1, 0, 224, 93, 1, 94,
723 0, 224, 93, 1, 0, 131, 0, 70, 180, 226,
724 0, 70, 180, 229, 0, 70, 180, 226, 229, 0,
725 70, 1, 0, 227, 0, 226, 227, 0, 228, 180,
726 0, 60, 93, 152, 94, 0, 60, 1, 0, 60,
727 93, 1, 0, 60, 93, 1, 94, 0, 64, 180,
728 0, 64, 1, 0, 231, 0, 240, 0, 111, 0,
729 76, 0, 93, 270, 94, 0, 234, 0, 244, 0,
730 245, 0, 246, 0, 233, 0, 119, 101, 76, 0,
731 93, 270, 1, 0, 119, 101, 1, 0, 113, 101,
732 1, 0, 59, 101, 1, 0, 113, 97, 98, 0,
733 119, 97, 98, 0, 119, 101, 67, 0, 232, 101,
734 67, 0, 113, 101, 67, 0, 59, 101, 67, 0,
735 72, 116, 93, 239, 94, 0, 72, 116, 93, 94,
736 0, 235, 0, 238, 122, 93, 94, 0, 238, 122,
737 93, 94, 138, 0, 238, 122, 93, 239, 94, 0,
738 238, 122, 93, 239, 94, 138, 0, 72, 1, 99,
739 0, 72, 116, 1, 0, 72, 116, 93, 1, 0,
740 72, 116, 93, 239, 1, 0, 238, 1, 0, 238,
741 122, 1, 0, 0, 72, 116, 93, 239, 94, 236,
742 138, 0, 0, 72, 116, 93, 94, 237, 138, 0,
743 119, 101, 72, 0, 230, 101, 72, 0, 270, 0,
744 239, 100, 270, 0, 239, 100, 1, 0, 72, 113,
745 241, 0, 72, 115, 241, 0, 72, 113, 241, 243,
746 0, 72, 115, 241, 243, 0, 72, 115, 243, 178,
747 0, 72, 113, 243, 178, 0, 72, 1, 98, 0,
748 72, 1, 97, 0, 242, 0, 241, 242, 0, 97,
749 270, 98, 0, 97, 270, 1, 0, 97, 1, 0,
750 97, 98, 0, 243, 97, 98, 0, 243, 97, 1,
751 0, 230, 101, 122, 0, 65, 101, 122, 0, 65,
752 1, 0, 119, 93, 94, 0, 119, 93, 239, 94,
753 0, 230, 101, 122, 93, 94, 0, 230, 101, 122,
754 93, 239, 94, 0, 65, 101, 122, 93, 94, 0,
755 65, 101, 122, 93, 239, 94, 0, 65, 101, 1,
756 94, 0, 65, 101, 1, 101, 0, 119, 97, 270,
757 98, 0, 231, 97, 270, 98, 0, 119, 97, 1,
758 0, 119, 97, 270, 1, 0, 231, 97, 1, 0,
759 231, 97, 270, 1, 0, 230, 0, 119, 0, 248,
760 0, 249, 0, 247, 46, 0, 247, 45, 0, 251,
761 0, 252, 0, 3, 250, 0, 4, 250, 0, 253,
762 0, 3, 1, 0, 4, 1, 0, 46, 250, 0,
763 46, 1, 0, 45, 250, 0, 45, 1, 0, 247,
764 0, 89, 250, 0, 90, 250, 0, 254, 0, 89,
765 1, 0, 90, 1, 0, 93, 113, 243, 94, 250,
766 0, 93, 113, 94, 250, 0, 93, 270, 94, 253,
767 0, 93, 119, 243, 94, 253, 0, 93, 113, 97,
768 1, 0, 93, 1, 0, 93, 113, 243, 94, 1,
769 0, 93, 113, 94, 1, 0, 93, 119, 243, 94,
770 1, 0, 250, 0, 255, 5, 250, 0, 255, 6,
771 250, 0, 255, 7, 250, 0, 255, 5, 1, 0,
772 255, 6, 1, 0, 255, 7, 1, 0, 255, 0,
773 256, 3, 255, 0, 256, 4, 255, 0, 256, 3,
774 1, 0, 256, 4, 1, 0, 256, 0, 257, 8,
775 256, 0, 257, 9, 256, 0, 257, 10, 256, 0,
776 257, 8, 1, 0, 257, 9, 1, 0, 257, 10,
777 1, 0, 257, 0, 258, 20, 257, 0, 258, 18,
778 257, 0, 258, 21, 257, 0, 258, 19, 257, 0,
779 258, 57, 114, 0, 258, 20, 1, 0, 258, 18,
780 1, 0, 258, 21, 1, 0, 258, 19, 1, 0,
781 258, 57, 1, 0, 258, 0, 259, 16, 258, 0,
782 259, 17, 258, 0, 259, 16, 1, 0, 259, 17,
783 1, 0, 259, 0, 260, 11, 259, 0, 260, 11,
784 1, 0, 260, 0, 261, 12, 260, 0, 261, 12,
785 1, 0, 261, 0, 262, 13, 261, 0, 262, 13,
786 1, 0, 262, 0, 263, 14, 262, 0, 263, 14,
787 1, 0, 263, 0, 264, 15, 263, 0, 264, 15,
788 1, 0, 264, 0, 264, 87, 270, 88, 265, 0,
789 264, 87, 88, 1, 0, 264, 87, 1, 0, 264,
790 87, 270, 88, 1, 0, 265, 0, 267, 0, 268,
791 269, 266, 0, 268, 269, 1, 0, 119, 0, 244,
792 0, 246, 0, 91, 0, 92, 0, 266, 0, 270,
796 #endif
798 #if YYDEBUG != 0
799 static const short yyrline[] = { 0,
800 573, 579, 581, 582, 583, 584, 585, 589, 591, 594,
801 596, 597, 600, 602, 605, 609, 613, 617, 623, 625,
802 627, 629, 634, 636, 639, 643, 648, 653, 655, 656,
803 657, 658, 659, 660, 661, 664, 669, 675, 677, 680,
804 686, 688, 692, 694, 697, 724, 726, 730, 743, 745,
805 749, 752, 754, 756, 766, 771, 786, 790, 790, 793,
806 793, 795, 797, 802, 806, 808, 810, 812, 816, 818,
807 820, 827, 833, 838, 842, 851, 861, 863, 866, 868,
808 869, 870, 877, 879, 881, 882, 884, 889, 892, 902,
809 905, 907, 911, 914, 921, 927, 935, 937, 939, 941,
810 943, 947, 949, 953, 964, 965, 969, 972, 974, 976,
811 978, 983, 985, 987, 989, 996, 1002, 1004, 1013, 1015,
812 1019, 1024, 1029, 1033, 1038, 1043, 1048, 1055, 1065, 1067,
813 1069, 1073, 1076, 1078, 1082, 1084, 1085, 1090, 1096, 1103,
814 1119, 1126, 1129, 1132, 1136, 1142, 1146, 1155, 1157, 1159,
815 1163, 1165, 1168, 1175, 1183, 1185, 1189, 1196, 1206, 1210,
816 1210, 1213, 1213, 1216, 1216, 1219, 1219, 1221, 1225, 1231,
817 1236, 1238, 1242, 1245, 1249, 1251, 1254, 1256, 1257, 1259,
818 1263, 1267, 1273, 1278, 1281, 1283, 1287, 1293, 1297, 1302,
819 1311, 1315, 1320, 1332, 1334, 1337, 1339, 1341, 1348, 1352,
820 1355, 1359, 1361, 1362, 1363, 1364, 1365, 1369, 1371, 1372,
821 1373, 1374, 1378, 1380, 1381, 1382, 1383, 1384, 1385, 1386,
822 1387, 1388, 1389, 1392, 1397, 1408, 1411, 1415, 1422, 1432,
823 1438, 1444, 1450, 1452, 1457, 1459, 1464, 1466, 1468, 1470,
824 1472, 1476, 1478, 1479, 1480, 1481, 1482, 1483, 1486, 1492,
825 1494, 1496, 1500, 1505, 1510, 1516, 1526, 1532, 1534, 1536,
826 1543, 1546, 1548, 1550, 1554, 1556, 1559, 1563, 1565, 1568,
827 1575, 1581, 1583, 1585, 1589, 1597, 1600, 1602, 1604, 1608,
828 1613, 1622, 1627, 1630, 1637, 1639, 1641, 1645, 1648, 1657,
829 1664, 1666, 1670, 1683, 1685, 1691, 1697, 1701, 1703, 1707,
830 1710, 1712, 1716, 1719, 1721, 1723, 1727, 1730, 1732, 1734,
831 1738, 1741, 1743, 1745, 1749, 1755, 1757, 1761, 1768, 1770,
832 1772, 1774, 1778, 1790, 1793, 1795, 1800, 1804, 1806, 1813,
833 1821, 1838, 1840, 1845, 1849, 1852, 1857, 1859, 1862, 1864,
834 1866, 1868, 1869, 1870, 1871, 1872, 1876, 1881, 1883, 1885,
835 1887, 1894, 1900, 1909, 1912, 1914, 1916, 1920, 1923, 1925,
836 1929, 1935, 1936, 1942, 1943, 1945, 1947, 1949, 1951, 1953,
837 1962, 1966, 1996, 1999, 2013, 2016, 2020, 2026, 2031, 2035,
838 2038, 2040, 2042, 2046, 2055, 2063, 2065, 2069, 2072, 2076,
839 2082, 2084, 2092, 2119, 2121, 2125, 2130, 2137, 2141, 2144,
840 2146, 2157, 2168, 2173, 2182, 2184, 2188, 2191, 2193, 2198,
841 2203, 2208, 2215, 2217, 2218, 2219, 2222, 2227, 2232, 2234,
842 2235, 2237, 2239, 2240, 2242, 2246, 2249, 2253, 2256, 2260,
843 2262, 2264, 2266, 2267, 2269, 2273, 2282, 2284, 2286, 2299,
844 2301, 2307, 2309, 2311, 2315, 2317, 2322, 2327, 2332, 2334,
845 2336, 2340, 2342, 2347, 2352, 2354, 2358, 2360, 2365, 2370,
846 2375, 2377, 2379, 2383, 2385, 2390, 2395, 2400, 2405, 2407,
847 2409, 2411, 2413, 2415, 2419, 2421, 2426, 2431, 2433, 2437,
848 2439, 2444, 2448, 2450, 2455, 2459, 2461, 2466, 2470, 2472,
849 2477, 2481, 2483, 2488, 2492, 2494, 2499, 2505, 2507, 2511,
850 2513, 2516, 2519, 2527, 2529, 2530, 2533, 2535, 2538, 2542
852 #endif
855 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
857 static const char * const yytname[] = { "$","error","$undefined.","PLUS_TK",
858 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
859 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
860 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
861 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
862 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
863 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
864 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
865 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
866 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
867 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
868 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
869 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
870 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
871 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
872 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
873 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
874 "class_type","interface_type","array_type","name","simple_name","qualified_name",
875 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
876 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
877 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
878 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
879 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
880 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
881 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
882 "class_type_list","method_body","static_initializer","static","constructor_declaration",
883 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
884 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
885 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
886 "interface_member_declaration","constant_declaration","abstract_method_declaration",
887 "array_initializer","variable_initializers","block","block_begin","block_end",
888 "block_statements","block_statement","local_variable_declaration_statement",
889 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
890 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
891 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
892 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
893 "switch_block_statement_group","switch_labels","switch_label","while_expression",
894 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
895 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
896 "statement_expression_list","break_statement","continue_statement","return_statement",
897 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
898 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
899 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
900 "@10","@11","something_dot_new","argument_list","array_creation_expression",
901 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
902 "postfix_expression","post_increment_expression","post_decrement_expression",
903 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
904 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
905 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
906 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
907 "conditional_expression","assignment_expression","assignment","left_hand_side",
908 "assignment_operator","expression","constant_expression", NULL
910 #endif
912 static const short yyr1[] = { 0,
913 110, 111, 111, 111, 111, 111, 111, 112, 112, 113,
914 113, 113, 114, 114, 115, 116, 117, 118, 118, 118,
915 118, 118, 119, 119, 120, 121, 122, 123, 123, 123,
916 123, 123, 123, 123, 123, 124, 124, 125, 125, 126,
917 126, 126, 127, 127, 128, 128, 128, 129, 129, 129,
918 130, 130, 130, 130, 131, 131, 133, 132, 134, 132,
919 132, 132, 132, 132, 135, 135, 135, 135, 136, 136,
920 136, 137, 137, 137, 138, 138, 139, 139, 140, 140,
921 140, 140, 141, 141, 141, 141, 141, 142, 142, 143,
922 143, 143, 144, 144, 144, 144, 145, 145, 145, 145,
923 145, 146, 146, 148, 147, 147, 149, 149, 149, 149,
924 149, 149, 149, 149, 149, 150, 150, 150, 150, 150,
925 151, 151, 151, 152, 152, 152, 152, 153, 154, 154,
926 154, 155, 155, 155, 156, 156, 156, 157, 157, 158,
927 160, 159, 161, 161, 162, 162, 163, 163, 163, 163,
928 164, 164, 165, 165, 165, 165, 166, 166, 168, 167,
929 169, 167, 170, 167, 171, 167, 167, 167, 172, 172,
930 172, 172, 173, 173, 174, 174, 175, 175, 175, 175,
931 176, 177, 177, 178, 178, 178, 179, 179, 179, 180,
932 180, 181, 182, 183, 183, 184, 184, 184, 185, 186,
933 186, 187, 187, 187, 187, 187, 187, 188, 188, 188,
934 188, 188, 189, 189, 189, 189, 189, 189, 189, 189,
935 189, 189, 189, 190, 191, 192, 192, 193, 194, 194,
936 194, 194, 194, 194, 194, 194, 194, 194, 194, 194,
937 194, 195, 195, 195, 195, 195, 195, 195, 196, 196,
938 196, 196, 197, 198, 200, 199, 201, 201, 201, 201,
939 202, 202, 202, 202, 203, 203, 204, 205, 205, 206,
940 206, 206, 206, 206, 207, 208, 208, 208, 208, 209,
941 210, 211, 212, 212, 212, 212, 212, 213, 213, 214,
942 214, 214, 215, 216, 216, 216, 216, 217, 217, 218,
943 218, 218, 219, 219, 219, 219, 220, 220, 220, 220,
944 221, 221, 221, 221, 222, 222, 222, 223, 223, 223,
945 223, 223, 224, 225, 225, 225, 225, 226, 226, 227,
946 228, 228, 228, 228, 229, 229, 230, 230, 231, 231,
947 231, 231, 231, 231, 231, 231, 231, 231, 231, 231,
948 231, 232, 232, 233, 233, 233, 233, 234, 234, 234,
949 234, 234, 234, 234, 234, 234, 234, 234, 234, 234,
950 236, 235, 237, 235, 238, 238, 239, 239, 239, 240,
951 240, 240, 240, 240, 240, 240, 240, 241, 241, 242,
952 242, 242, 243, 243, 243, 244, 244, 244, 245, 245,
953 245, 245, 245, 245, 245, 245, 246, 246, 246, 246,
954 246, 246, 247, 247, 247, 247, 248, 249, 250, 250,
955 250, 250, 250, 250, 250, 251, 251, 252, 252, 253,
956 253, 253, 253, 253, 253, 254, 254, 254, 254, 254,
957 254, 254, 254, 254, 255, 255, 255, 255, 255, 255,
958 255, 256, 256, 256, 256, 256, 257, 257, 257, 257,
959 257, 257, 257, 258, 258, 258, 258, 258, 258, 258,
960 258, 258, 258, 258, 259, 259, 259, 259, 259, 260,
961 260, 260, 261, 261, 261, 262, 262, 262, 263, 263,
962 263, 264, 264, 264, 265, 265, 265, 265, 265, 266,
963 266, 267, 267, 268, 268, 268, 269, 269, 270, 271
966 static const short yyr2[] = { 0,
967 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
968 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
969 3, 3, 1, 1, 1, 3, 1, 0, 1, 1,
970 1, 2, 2, 2, 3, 1, 2, 1, 2, 3,
971 2, 3, 1, 1, 3, 2, 3, 5, 4, 5,
972 1, 1, 1, 1, 1, 2, 0, 7, 0, 6,
973 3, 2, 3, 4, 0, 2, 3, 2, 0, 2,
974 2, 1, 3, 3, 2, 3, 1, 2, 1, 1,
975 1, 1, 1, 2, 1, 1, 1, 3, 4, 1,
976 3, 3, 1, 3, 3, 4, 1, 3, 2, 3,
977 3, 1, 1, 0, 3, 2, 3, 3, 4, 4,
978 2, 3, 2, 3, 2, 3, 4, 3, 3, 3,
979 1, 3, 3, 2, 3, 2, 3, 1, 0, 2,
980 2, 1, 3, 3, 1, 2, 1, 2, 3, 1,
981 0, 3, 2, 3, 3, 4, 2, 3, 3, 4,
982 1, 2, 4, 5, 7, 6, 1, 1, 0, 4,
983 0, 5, 0, 5, 0, 6, 3, 4, 2, 3,
984 2, 3, 2, 3, 1, 2, 1, 1, 1, 1,
985 1, 2, 2, 2, 3, 4, 1, 3, 3, 2,
986 3, 1, 1, 1, 2, 1, 1, 1, 2, 2,
987 3, 1, 1, 1, 1, 1, 1, 1, 1, 1,
988 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
989 1, 1, 1, 1, 2, 2, 2, 2, 2, 2,
990 2, 2, 3, 4, 4, 5, 4, 5, 6, 7,
991 6, 1, 1, 1, 1, 1, 1, 1, 5, 2,
992 3, 4, 7, 7, 0, 3, 4, 2, 3, 5,
993 2, 3, 3, 4, 1, 2, 2, 1, 2, 3,
994 2, 2, 3, 2, 4, 2, 2, 3, 4, 2,
995 1, 7, 7, 6, 3, 5, 4, 7, 6, 2,
996 2, 3, 2, 0, 1, 1, 2, 0, 1, 1,
997 3, 3, 2, 3, 2, 3, 2, 3, 2, 3,
998 2, 3, 2, 3, 3, 2, 3, 5, 5, 2,
999 4, 3, 1, 3, 3, 4, 2, 1, 2, 2,
1000 4, 2, 3, 4, 2, 2, 1, 1, 1, 1,
1001 3, 1, 1, 1, 1, 1, 3, 3, 3, 3,
1002 3, 3, 3, 3, 3, 3, 3, 5, 4, 1,
1003 4, 5, 5, 6, 3, 3, 4, 5, 2, 3,
1004 0, 7, 0, 6, 3, 3, 1, 3, 3, 3,
1005 3, 4, 4, 4, 4, 3, 3, 1, 2, 3,
1006 3, 2, 2, 3, 3, 3, 3, 2, 3, 4,
1007 5, 6, 5, 6, 4, 4, 4, 4, 3, 4,
1008 3, 4, 1, 1, 1, 1, 2, 2, 1, 1,
1009 2, 2, 1, 2, 2, 2, 2, 2, 2, 1,
1010 2, 2, 1, 2, 2, 5, 4, 4, 5, 4,
1011 2, 5, 4, 5, 1, 3, 3, 3, 3, 3,
1012 3, 1, 3, 3, 3, 3, 1, 3, 3, 3,
1013 3, 3, 3, 1, 3, 3, 3, 3, 3, 3,
1014 3, 3, 3, 3, 1, 3, 3, 3, 3, 1,
1015 3, 3, 1, 3, 3, 1, 3, 3, 1, 3,
1016 3, 1, 3, 3, 1, 5, 4, 3, 5, 1,
1017 1, 3, 3, 1, 1, 1, 1, 1, 1, 1
1020 static const short yydefact[] = { 0,
1021 54, 55, 0, 0, 0, 0, 53, 1, 0, 0,
1022 0, 36, 43, 44, 38, 0, 51, 52, 46, 27,
1023 0, 23, 24, 25, 0, 62, 0, 41, 0, 0,
1024 37, 39, 0, 0, 56, 0, 0, 47, 45, 0,
1025 167, 0, 0, 163, 63, 0, 69, 42, 40, 0,
1026 0, 0, 61, 0, 49, 0, 26, 171, 17, 169,
1027 15, 0, 160, 0, 0, 68, 16, 0, 0, 59,
1028 168, 0, 165, 64, 69, 50, 48, 12, 0, 10,
1029 11, 173, 0, 8, 9, 13, 14, 15, 0, 179,
1030 181, 0, 180, 0, 175, 177, 178, 172, 170, 164,
1031 67, 71, 72, 70, 0, 162, 0, 57, 113, 0,
1032 129, 111, 0, 0, 90, 93, 129, 0, 0, 0,
1033 115, 0, 0, 183, 182, 174, 176, 0, 0, 60,
1034 166, 0, 0, 0, 0, 108, 99, 88, 0, 0,
1035 0, 0, 107, 21, 18, 22, 20, 19, 114, 129,
1036 112, 0, 129, 74, 73, 192, 75, 23, 0, 86,
1037 0, 77, 79, 83, 85, 0, 80, 0, 81, 141,
1038 129, 87, 82, 0, 58, 119, 116, 0, 128, 0,
1039 121, 0, 131, 132, 130, 120, 118, 92, 0, 91,
1040 95, 0, 0, 0, 0, 0, 0, 0, 340, 0,
1041 0, 0, 0, 6, 5, 2, 3, 4, 7, 339,
1042 0, 414, 0, 103, 413, 337, 0, 346, 342, 360,
1043 0, 338, 343, 344, 345, 430, 415, 416, 445, 419,
1044 420, 423, 433, 452, 457, 464, 475, 480, 483, 486,
1045 489, 492, 495, 500, 509, 501, 0, 102, 100, 98,
1046 101, 110, 89, 109, 190, 0, 129, 76, 78, 84,
1047 106, 0, 138, 0, 143, 0, 0, 0, 281, 0,
1048 0, 0, 0, 0, 0, 0, 0, 340, 0, 224,
1049 0, 8, 414, 0, 128, 198, 0, 0, 213, 0,
1050 194, 196, 0, 197, 202, 214, 0, 203, 215, 0,
1051 204, 205, 216, 255, 0, 206, 0, 217, 207, 294,
1052 0, 218, 219, 220, 222, 221, 0, 223, 248, 247,
1053 0, 245, 246, 243, 244, 242, 126, 124, 117, 0,
1054 0, 0, 424, 414, 343, 345, 421, 425, 422, 429,
1055 428, 427, 426, 0, 398, 0, 0, 0, 16, 0,
1056 434, 431, 435, 432, 441, 0, 414, 0, 184, 187,
1057 0, 0, 0, 0, 0, 0, 96, 0, 0, 0,
1058 369, 0, 418, 417, 0, 0, 0, 0, 0, 0,
1059 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1060 0, 0, 0, 0, 0, 507, 508, 0, 145, 0,
1061 144, 137, 105, 135, 139, 192, 142, 0, 231, 232,
1062 230, 250, 0, 316, 0, 305, 303, 0, 313, 311,
1063 0, 277, 0, 258, 0, 327, 0, 291, 0, 309,
1064 307, 0, 0, 200, 0, 0, 0, 227, 225, 0,
1065 0, 193, 191, 195, 199, 414, 323, 226, 229, 0,
1066 276, 0, 414, 296, 300, 293, 0, 0, 320, 0,
1067 123, 122, 127, 125, 134, 133, 351, 357, 0, 397,
1068 387, 386, 365, 0, 380, 388, 0, 381, 0, 366,
1069 0, 0, 0, 0, 0, 0, 348, 341, 185, 0,
1070 352, 350, 356, 399, 0, 377, 409, 353, 0, 349,
1071 354, 375, 347, 376, 396, 411, 0, 355, 370, 0,
1072 449, 446, 450, 447, 451, 448, 455, 453, 456, 454,
1073 461, 458, 462, 459, 463, 460, 471, 466, 473, 468,
1074 470, 465, 472, 467, 474, 0, 469, 478, 476, 479,
1075 477, 482, 481, 485, 484, 488, 487, 491, 490, 494,
1076 493, 498, 0, 0, 503, 502, 146, 136, 414, 147,
1077 0, 0, 151, 0, 251, 0, 317, 315, 306, 304,
1078 314, 312, 278, 0, 259, 0, 0, 0, 324, 328,
1079 0, 325, 292, 310, 308, 341, 18, 19, 0, 201,
1080 233, 0, 0, 0, 256, 0, 297, 0, 285, 0,
1081 0, 322, 0, 405, 406, 0, 392, 393, 0, 389,
1082 382, 0, 385, 383, 384, 367, 359, 0, 443, 437,
1083 440, 393, 0, 393, 0, 438, 189, 186, 188, 400,
1084 0, 410, 407, 0, 412, 408, 361, 0, 497, 0,
1085 0, 148, 0, 0, 152, 149, 252, 0, 279, 275,
1086 0, 332, 0, 336, 335, 329, 326, 330, 237, 0,
1087 234, 235, 0, 0, 0, 261, 0, 265, 0, 268,
1088 0, 302, 301, 287, 0, 299, 0, 321, 0, 403,
1089 0, 391, 390, 395, 394, 0, 368, 358, 442, 436,
1090 444, 439, 379, 378, 401, 0, 362, 363, 499, 496,
1091 0, 150, 0, 0, 0, 249, 0, 202, 0, 209,
1092 210, 0, 211, 212, 0, 260, 333, 0, 238, 0,
1093 0, 236, 274, 271, 272, 510, 0, 263, 266, 0,
1094 262, 0, 269, 0, 0, 286, 0, 319, 318, 404,
1095 374, 0, 402, 364, 0, 153, 0, 0, 0, 228,
1096 280, 0, 334, 331, 241, 239, 0, 273, 270, 264,
1097 0, 284, 0, 372, 0, 0, 154, 0, 253, 0,
1098 0, 240, 282, 283, 156, 0, 0, 0, 0, 155,
1099 0, 0, 0, 0, 289, 0, 254, 288, 0, 0,
1103 static const short yydefgoto[] = { 789,
1104 210, 281, 211, 85, 86, 68, 60, 87, 212, 22,
1105 23, 24, 8, 9, 10, 11, 12, 13, 14, 15,
1106 447, 286, 132, 105, 47, 70, 104, 130, 161, 162,
1107 163, 91, 114, 115, 116, 213, 165, 262, 92, 111,
1108 180, 181, 287, 136, 185, 403, 167, 168, 169, 264,
1109 170, 171, 407, 560, 561, 288, 18, 43, 72, 65,
1110 107, 44, 63, 94, 95, 96, 97, 214, 361, 289,
1111 174, 563, 732, 291, 292, 293, 294, 707, 295, 296,
1112 297, 298, 710, 299, 300, 301, 302, 711, 303, 450,
1113 304, 595, 667, 668, 669, 670, 305, 306, 713, 307,
1114 308, 309, 714, 310, 311, 456, 675, 676, 312, 313,
1115 314, 315, 316, 317, 318, 579, 580, 581, 582, 215,
1116 216, 217, 218, 219, 220, 742, 686, 221, 495, 222,
1117 475, 476, 477, 223, 224, 225, 226, 227, 228, 229,
1118 230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
1119 240, 241, 242, 243, 244, 245, 246, 247, 398, 496,
1123 static const short yypact[] = { 356,
1124 -32768,-32768, 158, -35, 339, 439,-32768,-32768, 433, 247,
1125 473,-32768,-32768,-32768,-32768, 29,-32768,-32768,-32768,-32768,
1126 12,-32768,-32768,-32768, 331,-32768, 491,-32768, 71, 469,
1127 -32768,-32768, 520, 562,-32768, -35, 510,-32768,-32768, 278,
1128 -32768, 521, -25, -8,-32768, 526, 349,-32768,-32768, -35,
1129 591, 343,-32768, 508,-32768, 25,-32768,-32768,-32768,-32768,
1130 7, 1014,-32768, 568, -25,-32768,-32768, 346, 594,-32768,
1131 -32768, -25, -8,-32768, 349,-32768,-32768,-32768, 597,-32768,
1132 -32768,-32768, 607, 165,-32768,-32768, 315, 181, 676,-32768,
1133 -32768, 30,-32768, 1034,-32768,-32768,-32768,-32768,-32768,-32768,
1134 -32768,-32768,-32768, 328, 354,-32768, -25,-32768,-32768, 370,
1135 -4,-32768, 449, 733,-32768, 201, -4, 122, 208, 377,
1136 -32768, 608, 616,-32768,-32768,-32768,-32768, 617, 938,-32768,
1137 -32768, 354, 629, 630, 215,-32768,-32768,-32768, 648, 2189,
1138 227, 489,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -4,
1139 -32768, 743, -4,-32768,-32768, 412,-32768, 425, 577,-32768,
1140 943,-32768,-32768, 438,-32768, 47,-32768, 455,-32768,-32768,
1141 506,-32768,-32768, 1916,-32768,-32768,-32768, 655, 569, 321,
1142 -32768, 589,-32768,-32768, 532,-32768,-32768,-32768, 485,-32768,
1143 -32768, 3001, 3052, 3117, 3168, 533, 18, 615,-32768, 3233,
1144 3284, 3349, 5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1145 302, 915, 63,-32768, 542, 581, 587,-32768,-32768,-32768,
1146 656,-32768, 766,-32768, 780, 846,-32768,-32768,-32768,-32768,
1147 -32768,-32768,-32768, 879, 896, 937, 893, 880, 697, 701,
1148 717, 741, 74,-32768,-32768,-32768, 841,-32768,-32768,-32768,
1149 -32768,-32768,-32768,-32768,-32768, 774, 506,-32768,-32768,-32768,
1150 -32768, 565, 690, 685,-32768, 600, 172, 3400,-32768, 206,
1151 2240, 17, 311, 342, 82, 426, 211, 700, 5597,-32768,
1152 -35, 651, 837, 229, 522,-32768, 589, 705,-32768, 1848,
1153 -32768,-32768, 702,-32768,-32768,-32768, 1984,-32768,-32768, 709,
1154 -32768,-32768,-32768,-32768, 1984,-32768, 1984,-32768,-32768, 5648,
1155 738,-32768,-32768,-32768,-32768,-32768, 436,-32768, 806, 808,
1156 846, 891, 908,-32768,-32768,-32768,-32768, 869,-32768, 654,
1157 684, 686,-32768, 722,-32768,-32768,-32768,-32768,-32768,-32768,
1158 -32768,-32768,-32768, 27,-32768, 691, 860, 724, 724, 452,
1159 -32768,-32768,-32768,-32768,-32768, 694, 1044, 43,-32768,-32768,
1160 669, 747, 222, 5365, 2305, 538,-32768, 279, 3465, 772,
1161 -32768, 458,-32768,-32768, 3516, 3581, 3632, 3697, 3748, 3813,
1162 3864, 3929, 3980, 4045, 4096, 4161, 721, 4212, 4277, 4328,
1163 4393, 4444, 4509, 4560, 2356,-32768,-32768, 4625,-32768, 368,
1164 -32768,-32768,-32768, 750,-32768,-32768,-32768, 1848,-32768,-32768,
1165 -32768,-32768, 4676,-32768, 35,-32768,-32768, 56,-32768,-32768,
1166 70,-32768, 4741,-32768, 4792,-32768, 718,-32768, 5206,-32768,
1167 -32768, 144, 259, 762, 235, 2421, 652,-32768,-32768, -35,
1168 2472,-32768,-32768,-32768,-32768, 1096, 569,-32768,-32768, 779,
1169 -32768, 810, 1032,-32768,-32768,-32768, 76, 2537,-32768, 4857,
1170 -32768,-32768,-32768, 869,-32768,-32768,-32768,-32768, -49, 789,
1171 -32768,-32768,-32768, 2588, 724,-32768, 479, 724, 479,-32768,
1172 2653, 4908, 240, 135, 2704, 657,-32768, 1671,-32768, 2124,
1173 -32768,-32768,-32768,-32768, 547,-32768,-32768,-32768, 244,-32768,
1174 -32768,-32768,-32768,-32768, 801,-32768, 251,-32768,-32768, 5416,
1175 -32768,-32768,-32768,-32768,-32768,-32768,-32768, 879,-32768, 879,
1176 -32768, 896,-32768, 896,-32768, 896,-32768, 937,-32768, 937,
1177 -32768, 937,-32768, 937,-32768, 165,-32768,-32768, 893,-32768,
1178 893,-32768, 880,-32768, 697,-32768, 701,-32768, 717,-32768,
1179 741,-32768, 901, 818,-32768,-32768,-32768,-32768, 1076,-32768,
1180 1848, 815, 811, 1848,-32768, 335,-32768,-32768,-32768,-32768,
1181 -32768,-32768,-32768, 351,-32768, 823, 463, 132, 718,-32768,
1182 455,-32768,-32768,-32768,-32768,-32768, 819, 824, 464, 762,
1183 -32768, 941, 66, -9,-32768, 851,-32768, 5340,-32768, 5231,
1184 840, 854, 857,-32768,-32768, 5481,-32768,-32768, 272,-32768,
1185 864, 294,-32768, 864,-32768,-32768, 878, 94,-32768,-32768,
1186 -32768, 819, 4973, 824, 1120,-32768,-32768,-32768,-32768,-32768,
1187 5024,-32768,-32768, 5532,-32768,-32768, 354, 548,-32768, 5089,
1188 744,-32768, 1848, 2769,-32768,-32768,-32768, 2050,-32768,-32768,
1189 263,-32768, 681,-32768,-32768,-32768,-32768,-32768,-32768, 2820,
1190 -32768,-32768, 963, 212, 5140,-32768, 419,-32768, 1564,-32768,
1191 5597,-32768,-32768,-32768, 881, 886, 5273,-32768, 268,-32768,
1192 728,-32768,-32768,-32768,-32768, 354,-32768, 903,-32768,-32768,
1193 -32768,-32768,-32768,-32768,-32768, 731,-32768, 354,-32768,-32768,
1194 504,-32768, 173, 121, 509,-32768, 940, 944, 2050,-32768,
1195 -32768, 2050,-32768,-32768, 904,-32768, 923, 925,-32768, 1020,
1196 137,-32768,-32768,-32768,-32768,-32768, 262,-32768,-32768, 1646,
1197 -32768, 1780,-32768, 932, 1984,-32768, 942,-32768,-32768,-32768,
1198 -32768, 354,-32768,-32768, 2885,-32768, 182, 4676, 1984,-32768,
1199 -32768, 2936,-32768,-32768,-32768,-32768, 1029,-32768,-32768,-32768,
1200 945,-32768, 1984,-32768, 210, 177,-32768, 401,-32768, 5231,
1201 946,-32768,-32768,-32768,-32768, 224, 2050, 947, 5273,-32768,
1202 975, 2050, 949, 2050,-32768, 2050,-32768,-32768, 1037, 1040,
1203 -32768
1206 static const short yypgoto[] = {-32768,
1207 -32768, -54, 157, 660, 16, -122, 582,-32768, -3, 319,
1208 -32768, 64,-32768, 1038, 413,-32768, 69,-32768,-32768, 734,
1209 106, 409,-32768,-32768, 997, 979,-32768, -131,-32768, 898,
1210 -32768, -79, -116, 918, -167, -194,-32768,-32768, -64, 285,
1211 805, -325, -129, -90,-32768,-32768,-32768,-32768,-32768,-32768,
1212 -32768, 907,-32768, -544,-32768, 662, -20,-32768,-32768,-32768,
1213 -32768, 1011, 561,-32768, 978,-32768,-32768, -176,-32768, -127,
1214 813, 784, -168, -276,-32768, 769, -251, 93, -560,-32768,
1215 -528,-32768,-32768,-32768, -263,-32768,-32768,-32768,-32768,-32768,
1216 -32768,-32768,-32768, 415, 416, -632, -527,-32768,-32768,-32768,
1217 -32768,-32768,-32768,-32768, -516,-32768, -667, 770,-32768,-32768,
1218 -32768,-32768,-32768,-32768,-32768,-32768, 511,-32768, 513,-32768,
1219 -32768,-32768,-32768, 186,-32768,-32768,-32768,-32768, -426,-32768,
1220 736, 126, -324, 1163, 192, 1197, 283, 379, 507, -171,
1221 583, 704, -472,-32768, 602, 603, 481, 601, 696, 698,
1222 695, 710, 703,-32768, 454, 706, 745,-32768,-32768, 936,
1223 -32768
1227 #define YYLAST 5757
1230 static const short yytable[] = { 21,
1231 175, 173, 29, 182, 462, 290, 152, 83, 360, 737,
1232 328, 184, 38, 444, 593, 626, 642, 345, 345, 646,
1233 337, 339, 341, 343, 479, 76, 143, 467, 352, 354,
1234 124, 484, 486, 173, 123, 567, 733, 664, 61, 83,
1235 263, 93, 61, 487, 604, 448, 455, 261, 134, 164,
1236 20, 605, 665, 451, 618, 452, 569, 59, 88, 252,
1237 61, 67, 254, 367, 166, 61, 662, 25, 27, 62,
1238 571, 48, 35, 93, 83, 350, 597, 31, 178, 59,
1239 265, 164, 426, 638, 59, 88, 666, 708, 394, 36,
1240 88, 64, 135, 468, 687, 37, 166, 733, 702, 52,
1241 54, 31, 778, 57, 123, 16, 83, 50, 172, -158,
1242 39, 783, 40, 57, 16, 16, 16, 346, 346, 709,
1243 712, 662, 144, 77, 61, 88, 182, 331, 125, 88,
1244 61, 715, 654, 568, 404, 16, 488, 756, 16, 16,
1245 172, -104, 110, 59, 584, -104, 113, 427, 708, 67,
1246 611, 708, 692, 614, 570, 88, 16, 88, 19, 663,
1247 395, -94, -94, 464, 434, 631, 401, 89, 572, 49,
1248 283, 50, 412, 661, -295, 598, 156, 756, 88, 681,
1249 709, 712, 722, 709, 712, 110, 113, 688, 334, 334,
1250 334, 334, 715, 631, 61, 715, 334, 334, 357, 89,
1251 182, 178, 189, 512, 514, 516, 416, 696, 146, 466,
1252 755, 430, 723, 349, 747, 186, 708, 704, 84, 145,
1253 631, 708, 492, 708, 772, 708, 156, 249, 623, 438,
1254 757, 612, 440, 721, 159, 144, 631, 284, 179, 564,
1255 621, 189, 585, 20, 632, 84, -31, 1, 709, 712,
1256 84, 635, 88, 709, 712, 709, 712, 709, 712, 487,
1257 715, 118, 758, 716, 413, 715, 159, 715, 738, 715,
1258 776, 746, 682, -25, -25, 178, 631, 120, 55, 285,
1259 767, 50, 56, 88, 372, 84, 283, 444, 493, 84,
1260 2, 20, 140, 446, 684, 629, 20, 141, 142, 724,
1261 613, 446, 615, 446, 417, 147, 453, 4, 775, 431,
1262 620, 422, 187, 5, -25, 84, 439, 84, 766, -25,
1263 -25, -25, 780, 590, 250, -25, 88, 718, 61, -25,
1264 282, 41, 587, 418, 673, 647, 455, 622, 84, 26,
1265 432, 633, 424, 71, 189, 7, 101, 67, 636, 759,
1266 504, 649, 586, 284, 348, -28, 1, -257, 356, 319,
1267 284, 179, 156, 20, 20, 320, 444, 117, 284, 683,
1268 284, 334, 334, 334, 334, 334, 334, 334, 334, 334,
1269 334, 334, 334, 88, 334, 334, 334, 334, 334, 334,
1270 334, 685, 643, 42, 189, 285, 706, -66, 362, 2,
1271 69, 647, 363, 423, 559, 42, 150, 153, 17, 470,
1272 3, 119, 84, 455, 329, 179, 4, 17, 17, 17,
1273 330, 30, 5, 34, 20, -159, 428, 128, 648, 57,
1274 6, 505, -30, 1, 425, 179, 459, -161, 17, 28,
1275 -66, 17, 17, 84, 650, 51, 282, 158, 129, 137,
1276 655, 690, 480, 658, 7, 444, 321, 448, 509, 17,
1277 451, 557, 133, 652, 659, 664, 282, 330, -34, 1,
1278 90, 284, -29, 1, 148, 319, 2, 158, 334, 158,
1279 665, 320, 319, 762, 334, 137, 84, 3, 320, 251,
1280 319, 45, 319, 4, 777, 319, 320, 769, 320, 5,
1281 57, 320, 90, 189, 659, 697, 455, 255, 74, 412,
1282 53, 774, 2, 285, 728, 455, 2, 256, 429, -32,
1283 1, 58, -323, 182, 20, 706, 66, 3, 460, 4,
1284 762, 7, 769, 4, 774, 5, 260, 160, 500, 5,
1285 -97, 133, -65, 536, 481, -97, -97, -97, -97, 156,
1286 510, 739, 322, 46, 741, 653, 660, 283, 134, -65,
1287 283, -33, 1, 2, 282, 35, 744, 7, 98, 160,
1288 46, 7, 321, 203, 3, 612, -97, 121, -97, 321,
1289 4, -97, -97, -97, -97, -65, 5, 321, 37, 321,
1290 -35, 1, 321, 319, 102, 20, 745, 109, 178, 320,
1291 610, 748, -65, 610, 501, 2, 20, 112, 149, 502,
1292 764, 20, 35, 503, -323, 347, 151, 154, 7, 334,
1293 35, 334, 4, 20, 284, 100, 78, 284, 5, 176,
1294 183, 332, 106, 344, 2, 122, 334, 36, 78, 283,
1295 630, 698, 368, 37, 446, 99, 631, 631, 188, 88,
1296 103, 4, 500, 20, 461, 327, 371, 5, 80, 156,
1297 7, 81, 20, 402, 78, 283, 285, 131, 322, 285,
1298 80, -140, 2, 81, 20, 322, 121, 369, 78, 20,
1299 323, 717, 20, 322, 463, 322, 465, 370, 322, 7,
1300 321, 469, 20, 20, 409, 410, 80, 2, 411, 81,
1301 20, 20, 20, 78, 57, 446, 284, 390, 446, 155,
1302 80, 284, 391, 81, 20, 20, 589, 282, 501, 35,
1303 282, 535, 177, 502, 2, 78, 283, 503, 283, 392,
1304 78, 446, 284, 20, 122, 80, 36, 20, 81, 20,
1305 20, 20, 37, 32, 500, 446, 319, 435, 285, 319,
1306 625, 363, 320, 612, 393, 320, 324, 80, 179, 446,
1307 81, 20, 80, 32, 489, 81, 20, 32, 490, 20,
1308 78, 20, 284, 446, 285, 284, 20, 577, 446, 406,
1309 446, 578, 446, 319, 32, 319, 322, 482, 405, 320,
1310 483, 320, -157, 284, 363, 284, 323, 441, 284, 282,
1311 445, 750, 80, 323, 751, 81, 20, 449, 701, 84,
1312 501, 323, 284, 323, 364, 502, 323, 2, 365, 503,
1313 474, 740, 366, 78, 743, 282, 284, 631, 319, 20,
1314 631, 138, 139, 319, 320, 285, 458, 285, 508, 320,
1315 284, 253, 139, 321, 491, 284, 321, 284, 558, 284,
1316 -342, -342, -344, -344, 319, 80, -505, -505, 81, 20,
1317 320, 139, 319, 528, 530, 532, 534, 399, 320, 781,
1318 -506, -506, 324, 594, 785, 596, 787, 325, 788, 324,
1319 321, 606, 321, 375, 376, 377, 282, 324, 282, 324,
1320 373, 374, 324, 634, 319, 388, 389, 319, 378, 379,
1321 320, 639, -342, 320, -344, 640, -342, 644, -344, 645,
1322 383, 384, 385, 386, 323, 319, 651, 319, 326, -352,
1323 319, 320, -15, 320, -353, 321, 320, -504, -504, 364,
1324 321, 396, 397, 436, 319, -415, -415, 437, 677, 322,
1325 320, 661, 322, 671, 380, 381, 382, 678, 319, 387,
1326 679, 321, -416, -416, 320, 319, 471, 472, 473, 321,
1327 612, 320, 319, 722, 319, 141, 142, 319, 320, 319,
1328 320, 319, -373, 320, 735, 320, 322, 320, 322, 518,
1329 520, 2, 522, 524, 526, 598, 2, 78, 539, 541,
1330 324, 321, 78, 325, 321, 749, 79, -371, 4, -208,
1331 325, 79, 752, 4, 5, -504, -504, 364, 325, 5,
1332 325, 365, 321, 325, 321, 366, 753, 321, 754, 80,
1333 755, 322, 81, 20, 80, 761, 322, 81, 20, 772,
1334 784, 321, 156, 157, 326, 763, 790, 156, 258, 791,
1335 782, 326, 786, 773, 779, 321, 537, 322, 33, 326,
1336 75, 326, 321, 108, 326, 322, 190, 2, 259, 321,
1337 400, 321, 73, 78, 321, 257, 321, 323, 321, 562,
1338 323, 127, 79, 443, 4, 248, 408, 2, 454, 457,
1339 5, 729, 730, 78, 478, 543, 547, 322, 545, 656,
1340 322, 657, 79, 700, 4, 80, 551, 0, 81, 20,
1341 5, 0, 549, 556, 323, 0, 323, 0, 322, 82,
1342 322, 325, 0, 322, 0, 80, 0, -15, 81, 20,
1343 691, 0, -504, -504, 364, 0, 0, 322, 436, 126,
1344 0, 0, 366, 0, -504, -504, 364, 358, 248, 0,
1345 485, 322, 0, 324, 366, 0, 324, 0, 322, 323,
1346 0, 0, 326, 0, 323, 322, 0, 322, 0, 0,
1347 322, -15, 322, 0, 322, 0, -504, -504, 364, 78,
1348 0, 0, 436, 0, 0, 323, 641, 0, 196, 0,
1349 324, 0, 324, 323, 197, 0, -504, -504, 364, 0,
1350 0, 198, 365, 0, 0, 199, 437, 0, 0, 0,
1351 0, 80, 0, 415, 81, 20, 421, 0, 200, 201,
1352 0, 0, 202, 0, 433, 323, 0, 0, 323, 0,
1353 0, 204, 205, 206, 207, 324, 0, 208, 209, 0,
1354 324, 0, 0, 0, 0, 0, 323, 0, 323, 0,
1355 0, 323, 0, 0, 0, 0, 0, 0, 0, 0,
1356 0, 324, 0, 0, 0, 323, 0, 0, 0, 324,
1357 0, 0, 0, 0, 325, 0, 0, 325, 0, 323,
1358 0, 0, 0, 0, 0, 0, 323, 0, 0, 0,
1359 0, 0, 0, 323, 0, 323, 0, 0, 323, 0,
1360 323, 324, 323, 0, 324, 0, 0, 0, 0, 0,
1361 499, 325, 0, 325, 507, 326, 0, 0, 326, 0,
1362 0, 0, 324, 0, 324, 0, 0, 324, 0, 0,
1363 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1364 554, 324, 0, 0, 0, 0, 0, 0, 0, 0,
1365 0, 0, 326, 0, 326, 324, 325, 0, 566, 0,
1366 0, 325, 324, 0, 335, 335, 335, 335, 574, 324,
1367 576, 324, 335, 335, 324, 0, 324, 0, 324, 0,
1368 0, 499, 325, 0, 0, 0, 0, 0, 0, 0,
1369 325, 0, 0, 0, 0, 0, 0, 326, 336, 336,
1370 336, 336, 326, 601, 0, 603, 336, 336, 0, 0,
1371 0, 0, 0, 0, 0, 0, 0, 0, 0, 609,
1372 0, 0, 325, 326, 0, 325, 0, 0, 0, 0,
1373 499, 326, 0, 0, 0, 248, 0, 0, 0, 0,
1374 0, 0, 0, 325, 0, 325, 0, 0, 325, 0,
1375 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1376 0, 0, 325, 326, 0, 0, 326, 0, 0, 0,
1377 0, 0, 0, 0, 0, 0, 325, 0, 0, 0,
1378 0, 0, 0, 325, 326, 0, 326, 0, 0, 326,
1379 325, 0, 325, 0, 0, 325, 0, 325, 0, 325,
1380 0, 0, 0, 326, 0, 0, 0, 0, 0, 0,
1381 0, 0, 0, 0, 0, 0, 0, 326, 0, 0,
1382 0, 0, 0, 0, 326, 0, 0, 0, 0, 0,
1383 0, 326, 0, 326, 0, 0, 326, 0, 326, 0,
1384 326, 0, 0, 0, 0, 0, 0, 335, 335, 335,
1385 335, 335, 335, 335, 335, 335, 335, 335, 335, 0,
1386 335, 335, 335, 335, 335, 335, 335, 0, 0, 0,
1387 0, 0, 0, 0, 266, 0, 694, 0, 0, 0,
1388 0, 336, 336, 336, 336, 336, 336, 336, 336, 336,
1389 336, 336, 336, 0, 336, 336, 336, 336, 336, 336,
1390 336, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1391 726, 0, 0, 0, 0, 0, 734, 2, 194, 195,
1392 664, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1393 0, 271, 196, 0, 0, 665, 0, 0, 272, 273,
1394 5, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1395 0, 0, 0, 0, 335, 80, 266, 0, 81, 20,
1396 335, 0, 0, 0, 0, 0, 279, 0, 156, 731,
1397 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1398 0, 208, 209, 0, 0, 0, 0, 0, 336, 0,
1399 0, 0, 0, 768, 336, 0, 0, 771, 0, 2,
1400 194, 195, 664, 267, 268, 78, 269, 0, 0, 270,
1401 0, 0, 0, 271, 196, 0, 0, 665, 0, 0,
1402 272, 273, 5, 274, 0, 275, 276, 198, 277, 0,
1403 78, 278, 0, 0, 0, 0, 0, 80, 0, 196,
1404 81, 20, 0, 0, 0, 197, 0, 0, 279, 0,
1405 156, 760, 198, 0, 280, 0, 199, 204, 205, 206,
1406 207, 0, 80, 208, 209, 81, 20, 0, 0, 200,
1407 201, 0, 0, 202, 0, 0, 0, 0, 0, 0,
1408 0, 0, 204, 205, 206, 207, 0, 0, 208, 209,
1409 266, 0, 0, 0, 0, 335, 0, 335, 0, 0,
1410 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
1411 0, 0, 335, 0, 0, 0, 0, 0, 0, 0,
1412 0, 0, 0, 0, 0, 0, 0, 0, 0, 336,
1413 0, 336, 0, 2, 194, 195, -267, 267, 268, 78,
1414 269, 0, 0, 270, 0, 0, 336, 271, 196, 0,
1415 0, -267, 0, 0, 272, 273, 5, 274, 266, 275,
1416 276, 198, 277, 0, 0, 278, 0, 0, 0, 0,
1417 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1418 0, 0, 279, 0, 156, -267, 0, 0, 280, 0,
1419 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1420 0, 2, 194, 195, 0, 267, 268, 78, 269, 0,
1421 0, 270, 0, 0, 0, 271, 196, 0, 0, 0,
1422 0, 0, 272, 273, 5, 274, 266, 275, 276, 198,
1423 277, 0, 0, 278, 0, 0, 0, 0, 0, 80,
1424 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1425 279, 0, 156, 442, 0, 0, 280, 0, 0, 204,
1426 205, 206, 207, 0, 0, 208, 209, 0, 0, 2,
1427 194, 195, 0, 267, 268, 78, 269, 0, 0, 270,
1428 0, 0, 0, 271, 196, 0, 0, 0, 0, 0,
1429 272, 273, 5, 274, 266, 275, 276, 198, 277, 0,
1430 0, 278, 0, 0, 0, 0, 0, 80, 0, 0,
1431 81, 20, 0, 0, 0, 0, 0, 0, 279, 0,
1432 156, 0, 0, 0, 280, 0, 0, 204, 205, 206,
1433 207, 0, 0, 208, 209, 0, 0, 2, 194, 195,
1434 0, 267, 268, 78, 269, 0, 0, 270, 0, 0,
1435 0, 271, 196, 0, 0, 0, 0, 0, 272, 273,
1436 266, 274, 0, 275, 276, 198, 277, 0, 0, 278,
1437 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1438 0, 0, 0, 0, 0, 0, 279, 0, 156, 0,
1439 0, 0, 280, 0, 0, 204, 205, 206, 207, 0,
1440 0, 208, 209, 2, 194, 195, 0, 705, 268, 78,
1441 269, 0, 0, 270, 0, 0, 0, 271, 196, 0,
1442 0, 0, 0, 0, 272, 273, 0, 274, 0, 275,
1443 276, 198, 277, 0, 627, 278, 192, 193, 0, 0,
1444 0, 80, 0, 0, 81, 20, 0, 0, 0, 0,
1445 0, 0, 279, 0, 156, 0, 0, 0, 280, 0,
1446 0, 204, 205, 206, 207, 0, 0, 208, 209, 0,
1447 0, 0, 0, 0, 0, 0, 0, 0, 194, 195,
1448 0, 0, 0, 78, 0, 0, 0, 0, 0, 0,
1449 0, 0, 196, 0, 0, 0, 0, 0, 197, 191,
1450 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1451 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1452 0, 0, 200, 201, 0, 0, 202, 0, 203, 628,
1453 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1454 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1455 419, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1456 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1457 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1458 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1459 0, 202, 0, 203, 194, 195, 0, 0, 0, 78,
1460 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1461 0, 0, 0, 0, 197, 497, 0, 192, 193, 0,
1462 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1463 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1464 0, 0, 202, 0, 0, 0, 0, 0, 420, 0,
1465 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1466 195, 0, 0, 0, 78, 0, 552, 0, 192, 193,
1467 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1468 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1469 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1470 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1471 194, 195, 498, 0, 0, 78, 204, 205, 206, 207,
1472 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1473 197, 497, 0, 192, 193, 0, 0, 198, 0, 0,
1474 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1475 81, 20, 0, 553, 200, 201, 0, 0, 202, 0,
1476 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1477 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1478 78, 0, 591, 0, 192, 193, 0, 0, 0, 196,
1479 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1480 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1481 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1482 201, 0, 0, 202, 0, 0, 194, 195, 588, 0,
1483 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1484 196, 0, 0, 0, 0, 0, 197, 599, 0, 192,
1485 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1486 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1487 200, 201, 0, 0, 202, 592, 0, 0, 0, 0,
1488 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1489 209, 194, 195, 0, 0, 0, 78, 0, 607, 0,
1490 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1491 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1492 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1493 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1494 0, 0, 194, 195, 0, 600, 0, 78, 204, 205,
1495 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1496 0, 0, 197, 616, 0, 192, 193, 0, 0, 198,
1497 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1498 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1499 202, 0, 0, 0, 0, 608, 0, 0, 0, 204,
1500 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1501 0, 0, 78, 0, 497, 0, 192, 193, 0, 0,
1502 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1503 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1504 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1505 0, 200, 201, 0, 0, 202, 617, 0, 194, 195,
1506 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1507 208, 209, 196, 0, 0, 0, 0, 0, 197, 591,
1508 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1509 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1510 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1511 0, 624, 0, 0, 0, 204, 205, 206, 207, 0,
1512 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1513 719, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1514 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1515 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1516 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1517 0, 202, 703, 0, 194, 195, 0, 0, 0, 78,
1518 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1519 0, 0, 0, 0, 197, 719, 0, 192, 193, 0,
1520 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1521 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1522 0, 0, 202, 720, 0, 0, 0, 0, 0, 0,
1523 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1524 195, 0, 0, 0, 78, 0, 599, 0, 192, 193,
1525 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1526 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1527 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1528 20, 0, 0, 200, 201, 0, 0, 202, 765, 0,
1529 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1530 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1531 197, 333, 0, 192, 193, 0, 0, 198, 0, 0,
1532 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1533 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1534 0, 0, 0, 0, 770, 0, 0, 204, 205, 206,
1535 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1536 78, 0, 338, 0, 192, 193, 0, 0, 0, 196,
1537 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1538 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1539 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1540 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1541 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1542 196, 0, 0, 0, 0, 0, 197, 340, 0, 192,
1543 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1544 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1545 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1546 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1547 209, 194, 195, 0, 0, 0, 78, 0, 342, 0,
1548 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1549 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1550 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1551 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1552 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1553 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1554 0, 0, 197, 351, 0, 192, 193, 0, 0, 198,
1555 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1556 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1557 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1558 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1559 0, 0, 78, 0, 353, 0, 192, 193, 0, 0,
1560 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1561 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1562 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1563 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1564 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1565 208, 209, 196, 0, 0, 0, 0, 0, 197, 355,
1566 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1567 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1568 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1569 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1570 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1571 414, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1572 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1573 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1574 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1575 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1576 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1577 0, 0, 0, 0, 197, 506, 0, 192, 193, 0,
1578 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1579 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1580 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1581 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1582 195, 0, 0, 0, 78, 0, 511, 0, 192, 193,
1583 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1584 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1585 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1586 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1587 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1588 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1589 197, 513, 0, 192, 193, 0, 0, 198, 0, 0,
1590 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1591 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1592 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1593 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1594 78, 0, 515, 0, 192, 193, 0, 0, 0, 196,
1595 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1596 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1597 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1598 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1599 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1600 196, 0, 0, 0, 0, 0, 197, 517, 0, 192,
1601 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1602 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1603 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1604 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1605 209, 194, 195, 0, 0, 0, 78, 0, 519, 0,
1606 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1607 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1608 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1609 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1610 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1611 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1612 0, 0, 197, 521, 0, 192, 193, 0, 0, 198,
1613 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1614 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1615 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1616 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1617 0, 0, 78, 0, 523, 0, 192, 193, 0, 0,
1618 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1619 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1620 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1621 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1622 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1623 208, 209, 196, 0, 0, 0, 0, 0, 197, 525,
1624 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1625 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1626 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1627 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1628 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1629 527, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1630 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1631 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1632 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1633 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1634 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1635 0, 0, 0, 0, 197, 529, 0, 192, 193, 0,
1636 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1637 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1638 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1639 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1640 195, 0, 0, 0, 78, 0, 531, 0, 192, 193,
1641 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1642 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1643 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1644 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1645 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1646 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1647 197, 533, 0, 192, 193, 0, 0, 198, 0, 0,
1648 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1649 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1650 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1651 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1652 78, 0, 538, 0, 192, 193, 0, 0, 0, 196,
1653 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1654 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1655 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1656 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1657 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1658 196, 0, 0, 0, 0, 0, 197, 540, 0, 192,
1659 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1660 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1661 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1662 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1663 209, 194, 195, 0, 0, 0, 78, 0, 542, 0,
1664 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1665 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1666 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1667 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1668 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1669 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1670 0, 0, 197, 544, 0, 192, 193, 0, 0, 198,
1671 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1672 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1673 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1674 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1675 0, 0, 78, 0, 546, 0, 192, 193, 0, 0,
1676 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1677 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1678 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1679 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1680 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1681 208, 209, 196, 0, 0, 0, 0, 0, 197, 548,
1682 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1683 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1684 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1685 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1686 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1687 550, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1688 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1689 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1690 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1691 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1692 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1693 0, 0, 0, 0, 197, 555, 0, 192, 193, 0,
1694 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1695 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1696 0, 0, 202, 0, 0, 0, 0, 0, 0, 0,
1697 0, 204, 205, 206, 207, 0, 0, 208, 209, 194,
1698 195, 0, 0, 0, 78, 0, 565, 0, 192, 193,
1699 0, 0, 0, 196, 0, 0, 0, 0, 0, 197,
1700 0, 0, 0, 0, 0, 0, 198, 0, 0, 0,
1701 199, 0, 0, 0, 0, 0, 80, 0, 0, 81,
1702 20, 0, 0, 200, 201, 0, 0, 202, 0, 0,
1703 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1704 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1705 197, 573, 0, 192, 193, 0, 0, 198, 0, 0,
1706 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1707 81, 20, 0, 0, 200, 201, 0, 0, 202, 0,
1708 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1709 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1710 78, 0, 575, 0, 192, 193, 0, 0, 0, 196,
1711 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1712 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1713 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1714 201, 0, 0, 202, 0, 0, 194, 195, 0, 0,
1715 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1716 196, 0, 0, 0, 0, 0, 197, 602, 0, 192,
1717 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1718 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1719 200, 201, 0, 0, 202, 0, 0, 0, 0, 0,
1720 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1721 209, 194, 195, 0, 0, 0, 78, 0, 619, 0,
1722 192, 193, 0, 0, 0, 196, 0, 0, 0, 0,
1723 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1724 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1725 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1726 0, 0, 194, 195, 0, 0, 0, 78, 204, 205,
1727 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1728 0, 0, 197, 689, 0, 192, 193, 0, 0, 198,
1729 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1730 0, 0, 81, 20, 0, 0, 200, 201, 0, 0,
1731 202, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1732 205, 206, 207, 0, 0, 208, 209, 194, 195, 0,
1733 0, 0, 78, 0, 693, 0, 192, 193, 0, 0,
1734 0, 196, 0, 0, 0, 0, 0, 197, 0, 0,
1735 0, 0, 0, 0, 198, 0, 0, 0, 199, 0,
1736 0, 0, 0, 0, 80, 0, 0, 81, 20, 0,
1737 0, 200, 201, 0, 0, 202, 0, 0, 194, 195,
1738 0, 0, 0, 78, 204, 205, 206, 207, 0, 0,
1739 208, 209, 196, 0, 0, 0, 0, 0, 197, 699,
1740 0, 192, 193, 0, 0, 198, 0, 0, 0, 199,
1741 0, 0, 0, 0, 0, 80, 0, 0, 81, 20,
1742 0, 0, 200, 201, 0, 0, 202, 0, 0, 0,
1743 0, 0, 0, 0, 0, 204, 205, 206, 207, 0,
1744 0, 208, 209, 194, 195, 0, 0, 0, 78, 0,
1745 725, 0, 192, 193, 0, 0, 0, 196, 0, 0,
1746 0, 0, 0, 197, 0, 0, 0, 0, 0, 0,
1747 198, 0, 0, 0, 199, 0, 0, 0, 0, 0,
1748 80, 0, 0, 81, 20, 0, 0, 200, 201, 0,
1749 0, 202, 0, 0, 194, 195, 0, 0, 0, 78,
1750 204, 205, 206, 207, 0, 0, 208, 209, 196, 0,
1751 0, 0, 0, 0, 197, 0, 583, 0, 0, 0,
1752 0, 198, 0, 0, 0, 199, 0, 0, 0, 0,
1753 0, 80, 0, 0, 81, 20, 0, 0, 200, 201,
1754 0, 674, 202, 0, 0, 0, 0, 0, 0, 0,
1755 0, 204, 205, 206, 207, 0, 0, 208, 209, -290,
1756 -290, -290, 0, 0, 0, -290, 0, 0, 0, 0,
1757 0, 0, 0, 0, -290, 0, 0, 0, 0, 0,
1758 -290, 0, 0, 736, 0, 194, 195, -290, 0, 0,
1759 78, -290, 0, 0, 0, 0, 0, -290, 0, 196,
1760 -290, -290, 0, 0, 0, 197, 0, 0, -290, 0,
1761 192, 193, 198, 0, -290, 0, 199, -290, -290, -290,
1762 -290, 0, 80, -290, -290, 81, 20, 194, 195, 0,
1763 0, 0, 78, 279, -298, 0, 0, 0, 0, 0,
1764 0, 196, 204, 205, 206, 207, 0, 197, 208, 209,
1765 672, 0, 194, 195, 198, 0, 0, 78, 199, 0,
1766 0, 0, 0, 0, 80, 0, 196, 81, 20, 0,
1767 0, 0, 197, 0, 0, 279, -298, 192, 193, 198,
1768 0, 0, 0, 199, 204, 205, 206, 207, 0, 80,
1769 208, 209, 81, 20, 194, 195, 200, 201, 0, 78,
1770 202, 0, 203, 359, 0, 0, 0, 0, 196, 204,
1771 205, 206, 207, 0, 197, 208, 209, 0, 0, 194,
1772 195, 198, 0, 0, 78, 199, 0, 0, 192, 193,
1773 0, 80, 0, 196, 81, 20, 0, 0, 0, 197,
1774 0, 0, 279, 0, 0, 0, 198, 0, 0, 0,
1775 199, 204, 205, 206, 207, 0, 80, 208, 209, 81,
1776 20, 0, 0, 200, 201, 0, 0, 202, 494, 0,
1777 194, 195, 0, 0, 0, 78, 204, 205, 206, 207,
1778 0, 0, 208, 209, 196, 0, 0, 0, 0, 0,
1779 197, 0, 0, 192, 193, 0, 0, 198, 0, 0,
1780 0, 199, 0, 0, 0, 0, 0, 80, 0, 0,
1781 81, 20, 0, 0, 200, 201, 0, 0, 202, 637,
1782 0, 0, 0, 0, 0, 0, 0, 204, 205, 206,
1783 207, 0, 0, 208, 209, 194, 195, 0, 0, 0,
1784 78, 0, 0, 0, 192, 193, 0, 0, 0, 196,
1785 0, 0, 0, 0, 0, 197, 0, 0, 0, 0,
1786 0, 0, 198, 0, 0, 0, 199, 0, 0, 0,
1787 0, 0, 80, 0, 0, 81, 20, 0, 0, 200,
1788 201, 0, 0, 202, 680, 0, 194, 195, 0, 0,
1789 0, 78, 204, 205, 206, 207, 0, 0, 208, 209,
1790 196, 0, 0, 0, 0, 0, 197, 0, 0, 192,
1791 193, 0, 0, 198, 0, 0, 0, 199, 0, 0,
1792 0, 0, 0, 80, 0, 0, 81, 20, 0, 0,
1793 200, 201, 0, 0, 202, 695, 0, 0, 0, 0,
1794 0, 0, 0, 204, 205, 206, 207, 0, 0, 208,
1795 209, 194, 195, 0, 0, 0, 78, 0, 0, 0,
1796 0, 0, 0, 0, 0, 196, 0, 0, 0, 0,
1797 0, 197, 0, 0, 0, 0, 0, 0, 198, 0,
1798 0, 0, 199, 0, 0, 0, 0, 0, 80, 0,
1799 0, 81, 20, 0, 0, 200, 201, 0, 0, 202,
1800 0, 2, 194, 195, 0, 0, 0, 78, 204, 205,
1801 206, 207, 0, 0, 208, 209, 196, 0, 0, 0,
1802 0, 0, 197, 0, 0, 0, 0, 0, 0, 198,
1803 0, 0, 0, 199, 0, 0, 0, 0, 0, 80,
1804 0, 0, 81, 20, 0, 0, 0, 0, 0, 0,
1805 279, 0, 0, 0, 0, 0, 0, 0, 0, 204,
1806 205, 206, 207, 0, 0, 208, 209
1809 static const short yycheck[] = { 3,
1810 132, 129, 6, 133, 330, 174, 123, 62, 203, 677,
1811 178, 134, 1, 290, 441, 488, 561, 1, 1, 564,
1812 192, 193, 194, 195, 349, 1, 117, 1, 200, 201,
1813 1, 356, 357, 161, 89, 1, 669, 47, 42, 94,
1814 168, 62, 46, 1, 94, 297, 310, 1, 53, 129,
1815 86, 101, 62, 305, 481, 307, 1, 42, 62, 150,
1816 64, 46, 153, 1, 129, 69, 1, 4, 5, 95,
1817 1, 1, 44, 94, 129, 198, 1, 9, 133, 64,
1818 171, 161, 1, 510, 69, 89, 96, 648, 15, 61,
1819 94, 100, 97, 67, 1, 67, 161, 730, 643, 36,
1820 37, 33, 770, 40, 159, 0, 161, 101, 129, 93,
1821 99, 779, 101, 50, 9, 10, 11, 101, 101, 648,
1822 648, 1, 1, 99, 128, 129, 256, 182, 99, 133,
1823 134, 648, 1, 99, 262, 30, 94, 1, 33, 34,
1824 161, 95, 79, 128, 1, 99, 83, 275, 709, 134,
1825 475, 712, 625, 478, 99, 159, 51, 161, 1, 94,
1826 87, 99, 100, 331, 281, 100, 257, 62, 99, 99,
1827 174, 101, 1, 1, 99, 100, 95, 1, 182, 606,
1828 709, 709, 1, 712, 712, 122, 123, 94, 192, 193,
1829 194, 195, 709, 100, 198, 712, 200, 201, 202, 94,
1830 330, 256, 139, 375, 376, 377, 1, 634, 1, 332,
1831 1, 1, 1, 198, 94, 1, 777, 644, 62, 98,
1832 100, 782, 1, 784, 1, 786, 95, 1, 94, 1,
1833 94, 97, 287, 660, 129, 1, 100, 174, 133, 408,
1834 1, 178, 99, 86, 1, 89, 0, 1, 777, 777,
1835 94, 1, 256, 782, 782, 784, 784, 786, 786, 1,
1836 777, 97, 1, 1, 93, 782, 161, 784, 1, 786,
1837 94, 99, 1, 45, 46, 330, 100, 97, 1, 174,
1838 99, 101, 5, 287, 221, 129, 290, 564, 67, 133,
1839 44, 86, 92, 297, 1, 490, 86, 97, 98, 88,
1840 477, 305, 479, 307, 99, 98, 310, 61, 99, 99,
1841 482, 1, 98, 67, 86, 159, 88, 161, 745, 91,
1842 92, 93, 99, 440, 98, 97, 330, 653, 332, 101,
1843 174, 1, 98, 270, 598, 1, 600, 98, 182, 1,
1844 277, 98, 1, 1, 281, 99, 1, 332, 98, 88,
1845 72, 1, 94, 290, 198, 0, 1, 95, 202, 174,
1846 297, 256, 95, 86, 86, 174, 643, 83, 305, 98,
1847 307, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1848 384, 385, 386, 387, 388, 389, 390, 391, 392, 393,
1849 394, 98, 561, 63, 331, 290, 648, 52, 97, 44,
1850 52, 1, 101, 93, 408, 63, 122, 123, 0, 346,
1851 55, 97, 256, 677, 94, 310, 61, 9, 10, 11,
1852 100, 9, 67, 11, 86, 95, 1, 100, 94, 366,
1853 75, 368, 0, 1, 93, 330, 1, 95, 30, 1,
1854 95, 33, 34, 287, 94, 33, 290, 129, 95, 1,
1855 578, 623, 1, 581, 99, 732, 174, 709, 1, 51,
1856 712, 94, 93, 1, 1, 47, 310, 100, 0, 1,
1857 62, 408, 0, 1, 98, 290, 44, 159, 482, 161,
1858 62, 290, 297, 735, 488, 1, 330, 55, 297, 1,
1859 305, 1, 307, 61, 94, 310, 305, 749, 307, 67,
1860 437, 310, 94, 440, 1, 637, 770, 96, 1, 1,
1861 1, 763, 44, 408, 96, 779, 44, 93, 93, 0,
1862 1, 1, 1, 653, 86, 777, 1, 55, 93, 61,
1863 782, 99, 784, 61, 786, 67, 99, 129, 1, 67,
1864 92, 93, 52, 387, 93, 97, 98, 99, 100, 95,
1865 93, 679, 174, 63, 686, 93, 93, 561, 53, 52,
1866 564, 0, 1, 44, 408, 44, 698, 99, 1, 161,
1867 63, 99, 290, 95, 55, 97, 92, 1, 94, 297,
1868 61, 97, 98, 99, 100, 95, 67, 305, 67, 307,
1869 0, 1, 310, 408, 1, 86, 93, 1, 653, 408,
1870 475, 93, 95, 478, 67, 44, 86, 1, 1, 72,
1871 742, 86, 44, 76, 93, 1, 1, 1, 99, 623,
1872 44, 625, 61, 86, 561, 65, 50, 564, 67, 1,
1873 1, 100, 72, 101, 44, 59, 640, 61, 50, 643,
1874 94, 94, 101, 67, 648, 64, 100, 100, 1, 653,
1875 69, 61, 1, 86, 1, 1, 1, 67, 82, 95,
1876 99, 85, 86, 99, 50, 669, 561, 107, 290, 564,
1877 82, 95, 44, 85, 86, 297, 1, 97, 50, 86,
1878 174, 1, 86, 305, 1, 307, 1, 101, 310, 99,
1879 408, 1, 86, 86, 95, 96, 82, 44, 99, 85,
1880 86, 86, 86, 50, 641, 709, 643, 11, 712, 128,
1881 82, 648, 12, 85, 86, 86, 65, 561, 67, 44,
1882 564, 1, 94, 72, 44, 50, 730, 76, 732, 13,
1883 50, 735, 669, 86, 59, 82, 61, 86, 85, 86,
1884 86, 86, 67, 10, 1, 749, 561, 97, 643, 564,
1885 94, 101, 561, 97, 14, 564, 174, 82, 653, 763,
1886 85, 86, 82, 30, 96, 85, 86, 34, 100, 86,
1887 50, 86, 709, 777, 669, 712, 86, 60, 782, 95,
1888 784, 64, 786, 598, 51, 600, 408, 94, 99, 598,
1889 97, 600, 93, 730, 101, 732, 290, 93, 735, 643,
1890 99, 709, 82, 297, 712, 85, 86, 99, 65, 653,
1891 67, 305, 749, 307, 93, 72, 310, 44, 97, 76,
1892 97, 94, 101, 50, 94, 669, 763, 100, 643, 86,
1893 100, 99, 100, 648, 643, 730, 99, 732, 67, 648,
1894 777, 99, 100, 561, 98, 782, 564, 784, 99, 786,
1895 45, 46, 45, 46, 669, 82, 91, 92, 85, 86,
1896 669, 100, 677, 383, 384, 385, 386, 94, 677, 777,
1897 91, 92, 290, 95, 782, 66, 784, 174, 786, 297,
1898 598, 93, 600, 5, 6, 7, 730, 305, 732, 307,
1899 45, 46, 310, 93, 709, 16, 17, 712, 3, 4,
1900 709, 1, 97, 712, 97, 88, 101, 93, 101, 99,
1901 18, 19, 20, 21, 408, 730, 94, 732, 174, 101,
1902 735, 730, 86, 732, 101, 643, 735, 91, 92, 93,
1903 648, 91, 92, 97, 749, 45, 46, 101, 99, 561,
1904 749, 1, 564, 93, 8, 9, 10, 94, 763, 57,
1905 94, 669, 45, 46, 763, 770, 97, 98, 99, 677,
1906 97, 770, 777, 1, 779, 97, 98, 782, 777, 784,
1907 779, 786, 95, 782, 94, 784, 598, 786, 600, 378,
1908 379, 44, 380, 381, 382, 100, 44, 50, 388, 389,
1909 408, 709, 50, 290, 712, 56, 59, 95, 61, 56,
1910 297, 59, 99, 61, 67, 91, 92, 93, 305, 67,
1911 307, 97, 730, 310, 732, 101, 94, 735, 94, 82,
1912 1, 643, 85, 86, 82, 94, 648, 85, 86, 1,
1913 56, 749, 95, 96, 290, 94, 0, 95, 96, 0,
1914 94, 297, 94, 99, 99, 763, 387, 669, 11, 305,
1915 54, 307, 770, 75, 310, 677, 139, 44, 161, 777,
1916 256, 779, 52, 50, 782, 159, 784, 561, 786, 408,
1917 564, 94, 59, 290, 61, 140, 264, 44, 310, 310,
1918 67, 667, 667, 50, 349, 390, 392, 709, 391, 579,
1919 712, 579, 59, 640, 61, 82, 394, -1, 85, 86,
1920 67, -1, 393, 398, 598, -1, 600, -1, 730, 96,
1921 732, 408, -1, 735, -1, 82, -1, 86, 85, 86,
1922 1, -1, 91, 92, 93, -1, -1, 749, 97, 96,
1923 -1, -1, 101, -1, 91, 92, 93, 202, 203, -1,
1924 97, 763, -1, 561, 101, -1, 564, -1, 770, 643,
1925 -1, -1, 408, -1, 648, 777, -1, 779, -1, -1,
1926 782, 86, 784, -1, 786, -1, 91, 92, 93, 50,
1927 -1, -1, 97, -1, -1, 669, 101, -1, 59, -1,
1928 598, -1, 600, 677, 65, -1, 91, 92, 93, -1,
1929 -1, 72, 97, -1, -1, 76, 101, -1, -1, -1,
1930 -1, 82, -1, 268, 85, 86, 271, -1, 89, 90,
1931 -1, -1, 93, -1, 279, 709, -1, -1, 712, -1,
1932 -1, 102, 103, 104, 105, 643, -1, 108, 109, -1,
1933 648, -1, -1, -1, -1, -1, 730, -1, 732, -1,
1934 -1, 735, -1, -1, -1, -1, -1, -1, -1, -1,
1935 -1, 669, -1, -1, -1, 749, -1, -1, -1, 677,
1936 -1, -1, -1, -1, 561, -1, -1, 564, -1, 763,
1937 -1, -1, -1, -1, -1, -1, 770, -1, -1, -1,
1938 -1, -1, -1, 777, -1, 779, -1, -1, 782, -1,
1939 784, 709, 786, -1, 712, -1, -1, -1, -1, -1,
1940 365, 598, -1, 600, 369, 561, -1, -1, 564, -1,
1941 -1, -1, 730, -1, 732, -1, -1, 735, -1, -1,
1942 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1943 395, 749, -1, -1, -1, -1, -1, -1, -1, -1,
1944 -1, -1, 598, -1, 600, 763, 643, -1, 413, -1,
1945 -1, 648, 770, -1, 192, 193, 194, 195, 423, 777,
1946 425, 779, 200, 201, 782, -1, 784, -1, 786, -1,
1947 -1, 436, 669, -1, -1, -1, -1, -1, -1, -1,
1948 677, -1, -1, -1, -1, -1, -1, 643, 192, 193,
1949 194, 195, 648, 458, -1, 460, 200, 201, -1, -1,
1950 -1, -1, -1, -1, -1, -1, -1, -1, -1, 474,
1951 -1, -1, 709, 669, -1, 712, -1, -1, -1, -1,
1952 485, 677, -1, -1, -1, 490, -1, -1, -1, -1,
1953 -1, -1, -1, 730, -1, 732, -1, -1, 735, -1,
1954 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1955 -1, -1, 749, 709, -1, -1, 712, -1, -1, -1,
1956 -1, -1, -1, -1, -1, -1, 763, -1, -1, -1,
1957 -1, -1, -1, 770, 730, -1, 732, -1, -1, 735,
1958 777, -1, 779, -1, -1, 782, -1, 784, -1, 786,
1959 -1, -1, -1, 749, -1, -1, -1, -1, -1, -1,
1960 -1, -1, -1, -1, -1, -1, -1, 763, -1, -1,
1961 -1, -1, -1, -1, 770, -1, -1, -1, -1, -1,
1962 -1, 777, -1, 779, -1, -1, 782, -1, 784, -1,
1963 786, -1, -1, -1, -1, -1, -1, 375, 376, 377,
1964 378, 379, 380, 381, 382, 383, 384, 385, 386, -1,
1965 388, 389, 390, 391, 392, 393, 394, -1, -1, -1,
1966 -1, -1, -1, -1, 1, -1, 631, -1, -1, -1,
1967 -1, 375, 376, 377, 378, 379, 380, 381, 382, 383,
1968 384, 385, 386, -1, 388, 389, 390, 391, 392, 393,
1969 394, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1970 665, -1, -1, -1, -1, -1, 671, 44, 45, 46,
1971 47, 48, 49, 50, 51, -1, -1, 54, -1, -1,
1972 -1, 58, 59, -1, -1, 62, -1, -1, 65, 66,
1973 67, 68, -1, 70, 71, 72, 73, -1, -1, 76,
1974 -1, -1, -1, -1, 482, 82, 1, -1, 85, 86,
1975 488, -1, -1, -1, -1, -1, 93, -1, 95, 96,
1976 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
1977 -1, 108, 109, -1, -1, -1, -1, -1, 482, -1,
1978 -1, -1, -1, 748, 488, -1, -1, 752, -1, 44,
1979 45, 46, 47, 48, 49, 50, 51, -1, -1, 54,
1980 -1, -1, -1, 58, 59, -1, -1, 62, -1, -1,
1981 65, 66, 67, 68, -1, 70, 71, 72, 73, -1,
1982 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
1983 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
1984 95, 96, 72, -1, 99, -1, 76, 102, 103, 104,
1985 105, -1, 82, 108, 109, 85, 86, -1, -1, 89,
1986 90, -1, -1, 93, -1, -1, -1, -1, -1, -1,
1987 -1, -1, 102, 103, 104, 105, -1, -1, 108, 109,
1988 1, -1, -1, -1, -1, 623, -1, 625, -1, -1,
1989 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
1990 -1, -1, 640, -1, -1, -1, -1, -1, -1, -1,
1991 -1, -1, -1, -1, -1, -1, -1, -1, -1, 623,
1992 -1, 625, -1, 44, 45, 46, 47, 48, 49, 50,
1993 51, -1, -1, 54, -1, -1, 640, 58, 59, -1,
1994 -1, 62, -1, -1, 65, 66, 67, 68, 1, 70,
1995 71, 72, 73, -1, -1, 76, -1, -1, -1, -1,
1996 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
1997 -1, -1, 93, -1, 95, 96, -1, -1, 99, -1,
1998 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
1999 -1, 44, 45, 46, -1, 48, 49, 50, 51, -1,
2000 -1, 54, -1, -1, -1, 58, 59, -1, -1, -1,
2001 -1, -1, 65, 66, 67, 68, 1, 70, 71, 72,
2002 73, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2003 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2004 93, -1, 95, 96, -1, -1, 99, -1, -1, 102,
2005 103, 104, 105, -1, -1, 108, 109, -1, -1, 44,
2006 45, 46, -1, 48, 49, 50, 51, -1, -1, 54,
2007 -1, -1, -1, 58, 59, -1, -1, -1, -1, -1,
2008 65, 66, 67, 68, 1, 70, 71, 72, 73, -1,
2009 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2010 85, 86, -1, -1, -1, -1, -1, -1, 93, -1,
2011 95, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2012 105, -1, -1, 108, 109, -1, -1, 44, 45, 46,
2013 -1, 48, 49, 50, 51, -1, -1, 54, -1, -1,
2014 -1, 58, 59, -1, -1, -1, -1, -1, 65, 66,
2015 1, 68, -1, 70, 71, 72, 73, -1, -1, 76,
2016 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2017 -1, -1, -1, -1, -1, -1, 93, -1, 95, -1,
2018 -1, -1, 99, -1, -1, 102, 103, 104, 105, -1,
2019 -1, 108, 109, 44, 45, 46, -1, 48, 49, 50,
2020 51, -1, -1, 54, -1, -1, -1, 58, 59, -1,
2021 -1, -1, -1, -1, 65, 66, -1, 68, -1, 70,
2022 71, 72, 73, -1, 1, 76, 3, 4, -1, -1,
2023 -1, 82, -1, -1, 85, 86, -1, -1, -1, -1,
2024 -1, -1, 93, -1, 95, -1, -1, -1, 99, -1,
2025 -1, 102, 103, 104, 105, -1, -1, 108, 109, -1,
2026 -1, -1, -1, -1, -1, -1, -1, -1, 45, 46,
2027 -1, -1, -1, 50, -1, -1, -1, -1, -1, -1,
2028 -1, -1, 59, -1, -1, -1, -1, -1, 65, 1,
2029 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2030 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2031 -1, -1, 89, 90, -1, -1, 93, -1, 95, 96,
2032 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2033 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2034 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2035 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2036 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2037 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2038 -1, 93, -1, 95, 45, 46, -1, -1, -1, 50,
2039 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2040 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2041 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2042 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2043 -1, -1, 93, -1, -1, -1, -1, -1, 99, -1,
2044 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2045 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2046 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2047 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2048 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2049 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2050 45, 46, 98, -1, -1, 50, 102, 103, 104, 105,
2051 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2052 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2053 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2054 85, 86, -1, 88, 89, 90, -1, -1, 93, -1,
2055 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2056 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2057 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2058 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2059 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2060 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2061 90, -1, -1, 93, -1, -1, 45, 46, 98, -1,
2062 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2063 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2064 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2065 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2066 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2067 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2068 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2069 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2070 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2071 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2072 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2073 -1, -1, 45, 46, -1, 99, -1, 50, 102, 103,
2074 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2075 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2076 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2077 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2078 93, -1, -1, -1, -1, 98, -1, -1, -1, 102,
2079 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2080 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2081 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2082 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2083 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2084 -1, 89, 90, -1, -1, 93, 94, -1, 45, 46,
2085 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2086 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2087 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2088 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2089 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2090 -1, 98, -1, -1, -1, 102, 103, 104, 105, -1,
2091 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2092 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2093 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2094 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2095 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2096 -1, 93, 94, -1, 45, 46, -1, -1, -1, 50,
2097 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2098 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2099 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2100 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2101 -1, -1, 93, 94, -1, -1, -1, -1, -1, -1,
2102 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2103 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2104 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2105 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2106 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2107 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2108 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2109 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2110 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2111 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2112 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2113 -1, -1, -1, -1, 99, -1, -1, 102, 103, 104,
2114 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2115 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2116 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2117 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2118 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2119 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2120 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2121 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2122 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2123 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2124 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2125 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2126 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2127 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2128 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2129 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2130 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2131 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2132 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2133 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2134 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2135 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2136 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2137 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2138 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2139 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2140 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2141 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2142 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2143 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2144 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2145 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2146 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2147 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2148 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2149 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2150 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2151 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2152 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2153 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2154 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2155 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2156 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2157 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2158 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2159 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2160 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2161 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2162 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2163 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2164 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2165 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2166 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2167 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2168 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2169 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2170 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2171 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2172 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2173 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2174 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2175 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2176 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2177 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2178 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2179 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2180 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2181 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2182 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2183 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2184 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2185 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2186 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2187 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2188 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2189 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2190 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2191 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2192 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2193 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2194 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2195 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2196 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2197 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2198 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2199 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2200 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2201 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2202 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2203 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2204 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2205 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2206 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2207 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2208 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2209 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2210 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2211 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2212 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2213 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2214 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2215 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2216 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2217 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2218 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2219 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2220 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2221 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2222 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2223 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2224 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2225 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2226 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2227 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2228 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2229 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2230 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2231 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2232 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2233 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2234 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2235 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2236 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2237 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2238 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2239 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2240 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2241 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2242 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2243 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2244 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2245 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2246 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2247 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2248 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2249 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2250 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2251 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2252 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2253 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2254 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2255 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2256 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2257 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2258 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2259 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2260 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2261 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2262 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2263 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2264 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2265 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2266 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2267 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2268 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2269 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2270 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2271 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2272 -1, -1, -1, -1, 65, 1, -1, 3, 4, -1,
2273 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2274 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2275 -1, -1, 93, -1, -1, -1, -1, -1, -1, -1,
2276 -1, 102, 103, 104, 105, -1, -1, 108, 109, 45,
2277 46, -1, -1, -1, 50, -1, 1, -1, 3, 4,
2278 -1, -1, -1, 59, -1, -1, -1, -1, -1, 65,
2279 -1, -1, -1, -1, -1, -1, 72, -1, -1, -1,
2280 76, -1, -1, -1, -1, -1, 82, -1, -1, 85,
2281 86, -1, -1, 89, 90, -1, -1, 93, -1, -1,
2282 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2283 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2284 65, 1, -1, 3, 4, -1, -1, 72, -1, -1,
2285 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2286 85, 86, -1, -1, 89, 90, -1, -1, 93, -1,
2287 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2288 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2289 50, -1, 1, -1, 3, 4, -1, -1, -1, 59,
2290 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2291 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2292 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2293 90, -1, -1, 93, -1, -1, 45, 46, -1, -1,
2294 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2295 59, -1, -1, -1, -1, -1, 65, 1, -1, 3,
2296 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2297 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2298 89, 90, -1, -1, 93, -1, -1, -1, -1, -1,
2299 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2300 109, 45, 46, -1, -1, -1, 50, -1, 1, -1,
2301 3, 4, -1, -1, -1, 59, -1, -1, -1, -1,
2302 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2303 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2304 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2305 -1, -1, 45, 46, -1, -1, -1, 50, 102, 103,
2306 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2307 -1, -1, 65, 1, -1, 3, 4, -1, -1, 72,
2308 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2309 -1, -1, 85, 86, -1, -1, 89, 90, -1, -1,
2310 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2311 103, 104, 105, -1, -1, 108, 109, 45, 46, -1,
2312 -1, -1, 50, -1, 1, -1, 3, 4, -1, -1,
2313 -1, 59, -1, -1, -1, -1, -1, 65, -1, -1,
2314 -1, -1, -1, -1, 72, -1, -1, -1, 76, -1,
2315 -1, -1, -1, -1, 82, -1, -1, 85, 86, -1,
2316 -1, 89, 90, -1, -1, 93, -1, -1, 45, 46,
2317 -1, -1, -1, 50, 102, 103, 104, 105, -1, -1,
2318 108, 109, 59, -1, -1, -1, -1, -1, 65, 1,
2319 -1, 3, 4, -1, -1, 72, -1, -1, -1, 76,
2320 -1, -1, -1, -1, -1, 82, -1, -1, 85, 86,
2321 -1, -1, 89, 90, -1, -1, 93, -1, -1, -1,
2322 -1, -1, -1, -1, -1, 102, 103, 104, 105, -1,
2323 -1, 108, 109, 45, 46, -1, -1, -1, 50, -1,
2324 1, -1, 3, 4, -1, -1, -1, 59, -1, -1,
2325 -1, -1, -1, 65, -1, -1, -1, -1, -1, -1,
2326 72, -1, -1, -1, 76, -1, -1, -1, -1, -1,
2327 82, -1, -1, 85, 86, -1, -1, 89, 90, -1,
2328 -1, 93, -1, -1, 45, 46, -1, -1, -1, 50,
2329 102, 103, 104, 105, -1, -1, 108, 109, 59, -1,
2330 -1, -1, -1, -1, 65, -1, 1, -1, -1, -1,
2331 -1, 72, -1, -1, -1, 76, -1, -1, -1, -1,
2332 -1, 82, -1, -1, 85, 86, -1, -1, 89, 90,
2333 -1, 1, 93, -1, -1, -1, -1, -1, -1, -1,
2334 -1, 102, 103, 104, 105, -1, -1, 108, 109, 44,
2335 45, 46, -1, -1, -1, 50, -1, -1, -1, -1,
2336 -1, -1, -1, -1, 59, -1, -1, -1, -1, -1,
2337 65, -1, -1, 1, -1, 45, 46, 72, -1, -1,
2338 50, 76, -1, -1, -1, -1, -1, 82, -1, 59,
2339 85, 86, -1, -1, -1, 65, -1, -1, 93, -1,
2340 3, 4, 72, -1, 99, -1, 76, 102, 103, 104,
2341 105, -1, 82, 108, 109, 85, 86, 45, 46, -1,
2342 -1, -1, 50, 93, 94, -1, -1, -1, -1, -1,
2343 -1, 59, 102, 103, 104, 105, -1, 65, 108, 109,
2344 1, -1, 45, 46, 72, -1, -1, 50, 76, -1,
2345 -1, -1, -1, -1, 82, -1, 59, 85, 86, -1,
2346 -1, -1, 65, -1, -1, 93, 94, 3, 4, 72,
2347 -1, -1, -1, 76, 102, 103, 104, 105, -1, 82,
2348 108, 109, 85, 86, 45, 46, 89, 90, -1, 50,
2349 93, -1, 95, 96, -1, -1, -1, -1, 59, 102,
2350 103, 104, 105, -1, 65, 108, 109, -1, -1, 45,
2351 46, 72, -1, -1, 50, 76, -1, -1, 3, 4,
2352 -1, 82, -1, 59, 85, 86, -1, -1, -1, 65,
2353 -1, -1, 93, -1, -1, -1, 72, -1, -1, -1,
2354 76, 102, 103, 104, 105, -1, 82, 108, 109, 85,
2355 86, -1, -1, 89, 90, -1, -1, 93, 94, -1,
2356 45, 46, -1, -1, -1, 50, 102, 103, 104, 105,
2357 -1, -1, 108, 109, 59, -1, -1, -1, -1, -1,
2358 65, -1, -1, 3, 4, -1, -1, 72, -1, -1,
2359 -1, 76, -1, -1, -1, -1, -1, 82, -1, -1,
2360 85, 86, -1, -1, 89, 90, -1, -1, 93, 94,
2361 -1, -1, -1, -1, -1, -1, -1, 102, 103, 104,
2362 105, -1, -1, 108, 109, 45, 46, -1, -1, -1,
2363 50, -1, -1, -1, 3, 4, -1, -1, -1, 59,
2364 -1, -1, -1, -1, -1, 65, -1, -1, -1, -1,
2365 -1, -1, 72, -1, -1, -1, 76, -1, -1, -1,
2366 -1, -1, 82, -1, -1, 85, 86, -1, -1, 89,
2367 90, -1, -1, 93, 94, -1, 45, 46, -1, -1,
2368 -1, 50, 102, 103, 104, 105, -1, -1, 108, 109,
2369 59, -1, -1, -1, -1, -1, 65, -1, -1, 3,
2370 4, -1, -1, 72, -1, -1, -1, 76, -1, -1,
2371 -1, -1, -1, 82, -1, -1, 85, 86, -1, -1,
2372 89, 90, -1, -1, 93, 94, -1, -1, -1, -1,
2373 -1, -1, -1, 102, 103, 104, 105, -1, -1, 108,
2374 109, 45, 46, -1, -1, -1, 50, -1, -1, -1,
2375 -1, -1, -1, -1, -1, 59, -1, -1, -1, -1,
2376 -1, 65, -1, -1, -1, -1, -1, -1, 72, -1,
2377 -1, -1, 76, -1, -1, -1, -1, -1, 82, -1,
2378 -1, 85, 86, -1, -1, 89, 90, -1, -1, 93,
2379 -1, 44, 45, 46, -1, -1, -1, 50, 102, 103,
2380 104, 105, -1, -1, 108, 109, 59, -1, -1, -1,
2381 -1, -1, 65, -1, -1, -1, -1, -1, -1, 72,
2382 -1, -1, -1, 76, -1, -1, -1, -1, -1, 82,
2383 -1, -1, 85, 86, -1, -1, -1, -1, -1, -1,
2384 93, -1, -1, -1, -1, -1, -1, -1, -1, 102,
2385 103, 104, 105, -1, -1, 108, 109
2387 #define YYPURE 1
2389 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
2390 #line 3 "/usr/share/misc/bison.simple"
2392 /* Skeleton output parser for bison,
2393 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2395 This program is free software; you can redistribute it and/or modify
2396 it under the terms of the GNU General Public License as published by
2397 the Free Software Foundation; either version 2, or (at your option)
2398 any later version.
2400 This program is distributed in the hope that it will be useful,
2401 but WITHOUT ANY WARRANTY; without even the implied warranty of
2402 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2403 GNU General Public License for more details.
2405 You should have received a copy of the GNU General Public License
2406 along with this program; if not, write to the Free Software
2407 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
2409 /* As a special exception, when this file is copied by Bison into a
2410 Bison output file, you may use that output file without restriction.
2411 This special exception was added by the Free Software Foundation
2412 in version 1.24 of Bison. */
2414 #ifndef alloca
2415 #ifdef __GNUC__
2416 #define alloca __builtin_alloca
2417 #else /* not GNU C. */
2418 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi)
2419 #include <alloca.h>
2420 #else /* not sparc */
2421 #if defined (MSDOS) && !defined (__TURBOC__)
2422 #include <malloc.h>
2423 #else /* not MSDOS, or __TURBOC__ */
2424 #if defined(_AIX)
2425 #include <malloc.h>
2426 #pragma alloca
2427 #else /* not MSDOS, __TURBOC__, or _AIX */
2428 #ifdef __hpux
2429 #ifdef __cplusplus
2430 extern "C" {
2431 void *alloca (unsigned int);
2433 #else /* not __cplusplus */
2434 void *alloca ();
2435 #endif /* not __cplusplus */
2436 #endif /* __hpux */
2437 #endif /* not _AIX */
2438 #endif /* not MSDOS, or __TURBOC__ */
2439 #endif /* not sparc. */
2440 #endif /* not GNU C. */
2441 #endif /* alloca not defined. */
2443 /* This is the parser code that is written into each bison parser
2444 when the %semantic_parser declaration is not specified in the grammar.
2445 It was written by Richard Stallman by simplifying the hairy parser
2446 used when %semantic_parser is specified. */
2448 /* Note: there must be only one dollar sign in this file.
2449 It is replaced by the list of actions, each action
2450 as one case of the switch. */
2452 #define yyerrok (yyerrstatus = 0)
2453 #define yyclearin (yychar = YYEMPTY)
2454 #define YYEMPTY -2
2455 #define YYEOF 0
2456 #define YYACCEPT return(0)
2457 #define YYABORT return(1)
2458 #define YYERROR goto yyerrlab1
2459 /* Like YYERROR except do call yyerror.
2460 This remains here temporarily to ease the
2461 transition to the new meaning of YYERROR, for GCC.
2462 Once GCC version 2 has supplanted version 1, this can go. */
2463 #define YYFAIL goto yyerrlab
2464 #define YYRECOVERING() (!!yyerrstatus)
2465 #define YYBACKUP(token, value) \
2466 do \
2467 if (yychar == YYEMPTY && yylen == 1) \
2468 { yychar = (token), yylval = (value); \
2469 yychar1 = YYTRANSLATE (yychar); \
2470 YYPOPSTACK; \
2471 goto yybackup; \
2473 else \
2474 { yyerror ("syntax error: cannot back up"); YYERROR; } \
2475 while (0)
2477 #define YYTERROR 1
2478 #define YYERRCODE 256
2480 #ifndef YYPURE
2481 #define YYLEX yylex()
2482 #endif
2484 #ifdef YYPURE
2485 #ifdef YYLSP_NEEDED
2486 #ifdef YYLEX_PARAM
2487 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
2488 #else
2489 #define YYLEX yylex(&yylval, &yylloc)
2490 #endif
2491 #else /* not YYLSP_NEEDED */
2492 #ifdef YYLEX_PARAM
2493 #define YYLEX yylex(&yylval, YYLEX_PARAM)
2494 #else
2495 #define YYLEX yylex(&yylval)
2496 #endif
2497 #endif /* not YYLSP_NEEDED */
2498 #endif
2500 /* If nonreentrant, generate the variables here */
2502 #ifndef YYPURE
2504 int yychar; /* the lookahead symbol */
2505 YYSTYPE yylval; /* the semantic value of the */
2506 /* lookahead symbol */
2508 #ifdef YYLSP_NEEDED
2509 YYLTYPE yylloc; /* location data for the lookahead */
2510 /* symbol */
2511 #endif
2513 int yynerrs; /* number of parse errors so far */
2514 #endif /* not YYPURE */
2516 #if YYDEBUG != 0
2517 int yydebug; /* nonzero means print parse trace */
2518 /* Since this is uninitialized, it does not stop multiple parsers
2519 from coexisting. */
2520 #endif
2522 /* YYINITDEPTH indicates the initial size of the parser's stacks */
2524 #ifndef YYINITDEPTH
2525 #define YYINITDEPTH 200
2526 #endif
2528 /* YYMAXDEPTH is the maximum size the stacks can grow to
2529 (effective only if the built-in stack extension method is used). */
2531 #if YYMAXDEPTH == 0
2532 #undef YYMAXDEPTH
2533 #endif
2535 #ifndef YYMAXDEPTH
2536 #define YYMAXDEPTH 10000
2537 #endif
2539 /* Prevent warning if -Wstrict-prototypes. */
2540 #ifdef __GNUC__
2541 #ifndef YYPARSE_PARAM
2542 int yyparse (void);
2543 #endif
2544 #endif
2546 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
2547 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
2548 #else /* not GNU C or C++ */
2549 #ifndef __cplusplus
2551 /* This is the most reliable way to avoid incompatibilities
2552 in available built-in functions on various systems. */
2553 static void
2554 __yy_memcpy (to, from, count)
2555 char *to;
2556 char *from;
2557 int count;
2559 register char *f = from;
2560 register char *t = to;
2561 register int i = count;
2563 while (i-- > 0)
2564 *t++ = *f++;
2567 #else /* __cplusplus */
2569 /* This is the most reliable way to avoid incompatibilities
2570 in available built-in functions on various systems. */
2571 static void
2572 __yy_memcpy (char *to, char *from, int count)
2574 register char *f = from;
2575 register char *t = to;
2576 register int i = count;
2578 while (i-- > 0)
2579 *t++ = *f++;
2582 #endif
2583 #endif
2585 #line 196 "/usr/share/misc/bison.simple"
2587 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2588 into yyparse. The argument should have type void *.
2589 It should actually point to an object.
2590 Grammar actions can access the variable by casting it
2591 to the proper pointer type. */
2593 #ifdef YYPARSE_PARAM
2594 #ifdef __cplusplus
2595 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2596 #define YYPARSE_PARAM_DECL
2597 #else /* not __cplusplus */
2598 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2599 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2600 #endif /* not __cplusplus */
2601 #else /* not YYPARSE_PARAM */
2602 #define YYPARSE_PARAM_ARG
2603 #define YYPARSE_PARAM_DECL
2604 #endif /* not YYPARSE_PARAM */
2607 yyparse(YYPARSE_PARAM_ARG)
2608 YYPARSE_PARAM_DECL
2610 register int yystate;
2611 register int yyn;
2612 register short *yyssp;
2613 register YYSTYPE *yyvsp;
2614 int yyerrstatus; /* number of tokens to shift before error messages enabled */
2615 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
2617 short yyssa[YYINITDEPTH]; /* the state stack */
2618 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
2620 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
2621 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
2623 #ifdef YYLSP_NEEDED
2624 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
2625 YYLTYPE *yyls = yylsa;
2626 YYLTYPE *yylsp;
2628 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
2629 #else
2630 #define YYPOPSTACK (yyvsp--, yyssp--)
2631 #endif
2633 int yystacksize = YYINITDEPTH;
2635 #ifdef YYPURE
2636 int yychar;
2637 YYSTYPE yylval;
2638 int yynerrs;
2639 #ifdef YYLSP_NEEDED
2640 YYLTYPE yylloc;
2641 #endif
2642 #endif
2644 YYSTYPE yyval; /* the variable used to return */
2645 /* semantic values from the action */
2646 /* routines */
2648 int yylen;
2650 #if YYDEBUG != 0
2651 if (yydebug)
2652 fprintf(stderr, "Starting parse\n");
2653 #endif
2655 yystate = 0;
2656 yyerrstatus = 0;
2657 yynerrs = 0;
2658 yychar = YYEMPTY; /* Cause a token to be read. */
2660 /* Initialize stack pointers.
2661 Waste one element of value and location stack
2662 so that they stay on the same level as the state stack.
2663 The wasted elements are never initialized. */
2665 yyssp = yyss - 1;
2666 yyvsp = yyvs;
2667 #ifdef YYLSP_NEEDED
2668 yylsp = yyls;
2669 #endif
2671 /* Push a new state, which is found in yystate . */
2672 /* In all cases, when you get here, the value and location stacks
2673 have just been pushed. so pushing a state here evens the stacks. */
2674 yynewstate:
2676 *++yyssp = yystate;
2678 if (yyssp >= yyss + yystacksize - 1)
2680 /* Give user a chance to reallocate the stack */
2681 /* Use copies of these so that the &'s don't force the real ones into memory. */
2682 YYSTYPE *yyvs1 = yyvs;
2683 short *yyss1 = yyss;
2684 #ifdef YYLSP_NEEDED
2685 YYLTYPE *yyls1 = yyls;
2686 #endif
2688 /* Get the current used size of the three stacks, in elements. */
2689 int size = yyssp - yyss + 1;
2691 #ifdef yyoverflow
2692 /* Each stack pointer address is followed by the size of
2693 the data in use in that stack, in bytes. */
2694 #ifdef YYLSP_NEEDED
2695 /* This used to be a conditional around just the two extra args,
2696 but that might be undefined if yyoverflow is a macro. */
2697 yyoverflow("parser stack overflow",
2698 &yyss1, size * sizeof (*yyssp),
2699 &yyvs1, size * sizeof (*yyvsp),
2700 &yyls1, size * sizeof (*yylsp),
2701 &yystacksize);
2702 #else
2703 yyoverflow("parser stack overflow",
2704 &yyss1, size * sizeof (*yyssp),
2705 &yyvs1, size * sizeof (*yyvsp),
2706 &yystacksize);
2707 #endif
2709 yyss = yyss1; yyvs = yyvs1;
2710 #ifdef YYLSP_NEEDED
2711 yyls = yyls1;
2712 #endif
2713 #else /* no yyoverflow */
2714 /* Extend the stack our own way. */
2715 if (yystacksize >= YYMAXDEPTH)
2717 yyerror("parser stack overflow");
2718 return 2;
2720 yystacksize *= 2;
2721 if (yystacksize > YYMAXDEPTH)
2722 yystacksize = YYMAXDEPTH;
2723 yyss = (short *) alloca (yystacksize * sizeof (*yyssp));
2724 __yy_memcpy ((char *)yyss, (char *)yyss1, size * sizeof (*yyssp));
2725 yyvs = (YYSTYPE *) alloca (yystacksize * sizeof (*yyvsp));
2726 __yy_memcpy ((char *)yyvs, (char *)yyvs1, size * sizeof (*yyvsp));
2727 #ifdef YYLSP_NEEDED
2728 yyls = (YYLTYPE *) alloca (yystacksize * sizeof (*yylsp));
2729 __yy_memcpy ((char *)yyls, (char *)yyls1, size * sizeof (*yylsp));
2730 #endif
2731 #endif /* no yyoverflow */
2733 yyssp = yyss + size - 1;
2734 yyvsp = yyvs + size - 1;
2735 #ifdef YYLSP_NEEDED
2736 yylsp = yyls + size - 1;
2737 #endif
2739 #if YYDEBUG != 0
2740 if (yydebug)
2741 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2742 #endif
2744 if (yyssp >= yyss + yystacksize - 1)
2745 YYABORT;
2748 #if YYDEBUG != 0
2749 if (yydebug)
2750 fprintf(stderr, "Entering state %d\n", yystate);
2751 #endif
2753 goto yybackup;
2754 yybackup:
2756 /* Do appropriate processing given the current state. */
2757 /* Read a lookahead token if we need one and don't already have one. */
2758 /* yyresume: */
2760 /* First try to decide what to do without reference to lookahead token. */
2762 yyn = yypact[yystate];
2763 if (yyn == YYFLAG)
2764 goto yydefault;
2766 /* Not known => get a lookahead token if don't already have one. */
2768 /* yychar is either YYEMPTY or YYEOF
2769 or a valid token in external form. */
2771 if (yychar == YYEMPTY)
2773 #if YYDEBUG != 0
2774 if (yydebug)
2775 fprintf(stderr, "Reading a token: ");
2776 #endif
2777 yychar = YYLEX;
2780 /* Convert token to internal form (in yychar1) for indexing tables with */
2782 if (yychar <= 0) /* This means end of input. */
2784 yychar1 = 0;
2785 yychar = YYEOF; /* Don't call YYLEX any more */
2787 #if YYDEBUG != 0
2788 if (yydebug)
2789 fprintf(stderr, "Now at end of input.\n");
2790 #endif
2792 else
2794 yychar1 = YYTRANSLATE(yychar);
2796 #if YYDEBUG != 0
2797 if (yydebug)
2799 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2800 /* Give the individual parser a way to print the precise meaning
2801 of a token, for further debugging info. */
2802 #ifdef YYPRINT
2803 YYPRINT (stderr, yychar, yylval);
2804 #endif
2805 fprintf (stderr, ")\n");
2807 #endif
2810 yyn += yychar1;
2811 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2812 goto yydefault;
2814 yyn = yytable[yyn];
2816 /* yyn is what to do for this token type in this state.
2817 Negative => reduce, -yyn is rule number.
2818 Positive => shift, yyn is new state.
2819 New state is final state => don't bother to shift,
2820 just return success.
2821 0, or most negative number => error. */
2823 if (yyn < 0)
2825 if (yyn == YYFLAG)
2826 goto yyerrlab;
2827 yyn = -yyn;
2828 goto yyreduce;
2830 else if (yyn == 0)
2831 goto yyerrlab;
2833 if (yyn == YYFINAL)
2834 YYACCEPT;
2836 /* Shift the lookahead token. */
2838 #if YYDEBUG != 0
2839 if (yydebug)
2840 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2841 #endif
2843 /* Discard the token being shifted unless it is eof. */
2844 if (yychar != YYEOF)
2845 yychar = YYEMPTY;
2847 *++yyvsp = yylval;
2848 #ifdef YYLSP_NEEDED
2849 *++yylsp = yylloc;
2850 #endif
2852 /* count tokens shifted since error; after three, turn off error status. */
2853 if (yyerrstatus) yyerrstatus--;
2855 yystate = yyn;
2856 goto yynewstate;
2858 /* Do the default action for the current state. */
2859 yydefault:
2861 yyn = yydefact[yystate];
2862 if (yyn == 0)
2863 goto yyerrlab;
2865 /* Do a reduction. yyn is the number of a rule to reduce with. */
2866 yyreduce:
2867 yylen = yyr2[yyn];
2868 if (yylen > 0)
2869 yyval = yyvsp[1-yylen]; /* implement default value of the action */
2871 #if YYDEBUG != 0
2872 if (yydebug)
2874 int i;
2876 fprintf (stderr, "Reducing via rule %d (line %d), ",
2877 yyn, yyrline[yyn]);
2879 /* Print the symbols being reduced, and their result. */
2880 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2881 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2882 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2884 #endif
2887 switch (yyn) {
2889 case 1:
2890 #line 575 "./parse.y"
2892 break;}
2893 case 18:
2894 #line 619 "./parse.y"
2896 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2897 CLASS_LOADED_P (yyval.node) = 1;
2899 break;}
2900 case 19:
2901 #line 624 "./parse.y"
2902 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2903 break;}
2904 case 20:
2905 #line 626 "./parse.y"
2906 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2907 break;}
2908 case 21:
2909 #line 628 "./parse.y"
2910 {RULE ("']' expected"); RECOVER;;
2911 break;}
2912 case 22:
2913 #line 630 "./parse.y"
2914 {RULE ("']' expected"); RECOVER;;
2915 break;}
2916 case 26:
2917 #line 645 "./parse.y"
2918 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2919 break;}
2920 case 28:
2921 #line 654 "./parse.y"
2922 {yyval.node = NULL;;
2923 break;}
2924 case 36:
2925 #line 666 "./parse.y"
2927 yyval.node = NULL;
2929 break;}
2930 case 37:
2931 #line 670 "./parse.y"
2933 yyval.node = NULL;
2935 break;}
2936 case 40:
2937 #line 682 "./parse.y"
2939 ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2940 package_list = tree_cons (ctxp->package, NULL, package_list);
2942 break;}
2943 case 41:
2944 #line 687 "./parse.y"
2945 {yyerror ("Missing name"); RECOVER;;
2946 break;}
2947 case 42:
2948 #line 689 "./parse.y"
2949 {yyerror ("';' expected"); RECOVER;;
2950 break;}
2951 case 45:
2952 #line 699 "./parse.y"
2954 tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2955 int i = IDENTIFIER_LENGTH (name)-1;
2956 const char *last = &IDENTIFIER_POINTER (name)[i];
2957 while (last != IDENTIFIER_POINTER (name))
2959 if (last [0] == '.')
2960 break;
2961 last--;
2963 last_name = get_identifier (++last);
2964 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
2966 tree err = find_name_in_single_imports (last_name);
2967 if (err && err != name)
2968 parse_error_context
2969 (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
2970 IDENTIFIER_POINTER (name),
2971 IDENTIFIER_POINTER (err));
2972 else
2973 REGISTER_IMPORT (yyvsp[-1].node, last_name)
2975 else
2976 REGISTER_IMPORT (yyvsp[-1].node, last_name);
2978 break;}
2979 case 46:
2980 #line 725 "./parse.y"
2981 {yyerror ("Missing name"); RECOVER;;
2982 break;}
2983 case 47:
2984 #line 727 "./parse.y"
2985 {yyerror ("';' expected"); RECOVER;;
2986 break;}
2987 case 48:
2988 #line 732 "./parse.y"
2990 tree name = EXPR_WFL_NODE (yyvsp[-3].node);
2991 /* Don't import java.lang.* twice. */
2992 if (name != java_lang_id)
2994 tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
2995 read_import_dir (yyvsp[-3].node);
2996 TREE_CHAIN (node) = ctxp->import_demand_list;
2997 ctxp->import_demand_list = node;
3000 break;}
3001 case 49:
3002 #line 744 "./parse.y"
3003 {yyerror ("'*' expected"); RECOVER;;
3004 break;}
3005 case 50:
3006 #line 746 "./parse.y"
3007 {yyerror ("';' expected"); RECOVER;;
3008 break;}
3009 case 51:
3010 #line 751 "./parse.y"
3011 { end_class_declaration (0); ;
3012 break;}
3013 case 52:
3014 #line 753 "./parse.y"
3015 { end_class_declaration (0); ;
3016 break;}
3017 case 53:
3018 #line 755 "./parse.y"
3019 { yyval.node = NULL; ;
3020 break;}
3021 case 54:
3022 #line 757 "./parse.y"
3024 YYERROR_NOW;
3025 yyerror ("Class or interface declaration expected");
3027 break;}
3028 case 55:
3029 #line 768 "./parse.y"
3031 yyval.value = (1 << yyvsp[0].value);
3033 break;}
3034 case 56:
3035 #line 772 "./parse.y"
3037 int acc = (1 << yyvsp[0].value);
3038 if (yyval.value & acc)
3039 parse_error_context
3040 (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3041 java_accstring_lookup (acc));
3042 else
3044 yyval.value |= acc;
3047 break;}
3048 case 57:
3049 #line 788 "./parse.y"
3050 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3051 break;}
3052 case 59:
3053 #line 791 "./parse.y"
3054 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3055 break;}
3056 case 61:
3057 #line 794 "./parse.y"
3058 {yyerror ("Missing class name"); RECOVER;;
3059 break;}
3060 case 62:
3061 #line 796 "./parse.y"
3062 {yyerror ("Missing class name"); RECOVER;;
3063 break;}
3064 case 63:
3065 #line 798 "./parse.y"
3067 if (!ctxp->class_err) yyerror ("'{' expected");
3068 DRECOVER(class1);
3070 break;}
3071 case 64:
3072 #line 803 "./parse.y"
3073 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3074 break;}
3075 case 65:
3076 #line 807 "./parse.y"
3077 { yyval.node = NULL; ;
3078 break;}
3079 case 66:
3080 #line 809 "./parse.y"
3081 { yyval.node = yyvsp[0].node; ;
3082 break;}
3083 case 67:
3084 #line 811 "./parse.y"
3085 {yyerror ("'{' expected"); ctxp->class_err=1;;
3086 break;}
3087 case 68:
3088 #line 813 "./parse.y"
3089 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3090 break;}
3091 case 69:
3092 #line 817 "./parse.y"
3093 { yyval.node = NULL_TREE; ;
3094 break;}
3095 case 70:
3096 #line 819 "./parse.y"
3097 { yyval.node = yyvsp[0].node; ;
3098 break;}
3099 case 71:
3100 #line 821 "./parse.y"
3102 ctxp->class_err=1;
3103 yyerror ("Missing interface name");
3105 break;}
3106 case 72:
3107 #line 829 "./parse.y"
3109 ctxp->interface_number = 1;
3110 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3112 break;}
3113 case 73:
3114 #line 834 "./parse.y"
3116 ctxp->interface_number++;
3117 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3119 break;}
3120 case 74:
3121 #line 839 "./parse.y"
3122 {yyerror ("Missing interface name"); RECOVER;;
3123 break;}
3124 case 75:
3125 #line 844 "./parse.y"
3127 /* Store the location of the `}' when doing xrefs */
3128 if (flag_emit_xref)
3129 DECL_END_SOURCE_LINE (GET_CPC ()) =
3130 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3131 yyval.node = GET_CPC ();
3133 break;}
3134 case 76:
3135 #line 852 "./parse.y"
3137 /* Store the location of the `}' when doing xrefs */
3138 if (flag_emit_xref)
3139 DECL_END_SOURCE_LINE (GET_CPC ()) =
3140 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3141 yyval.node = GET_CPC ();
3143 break;}
3144 case 82:
3145 #line 871 "./parse.y"
3147 TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3148 SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3150 break;}
3151 case 84:
3152 #line 880 "./parse.y"
3153 { yyval.node = yyvsp[-1].node; ;
3154 break;}
3155 case 86:
3156 #line 883 "./parse.y"
3157 { end_class_declaration (1); ;
3158 break;}
3159 case 87:
3160 #line 885 "./parse.y"
3161 { end_class_declaration (1); ;
3162 break;}
3163 case 88:
3164 #line 891 "./parse.y"
3165 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3166 break;}
3167 case 89:
3168 #line 893 "./parse.y"
3170 check_modifiers
3171 ("Illegal modifier `%s' for field declaration",
3172 yyvsp[-3].value, FIELD_MODIFIERS);
3173 check_modifiers_consistency (yyvsp[-3].value);
3174 register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3176 break;}
3177 case 91:
3178 #line 906 "./parse.y"
3179 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3180 break;}
3181 case 92:
3182 #line 908 "./parse.y"
3183 {yyerror ("Missing term"); RECOVER;;
3184 break;}
3185 case 93:
3186 #line 913 "./parse.y"
3187 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3188 break;}
3189 case 94:
3190 #line 915 "./parse.y"
3192 if (java_error_count)
3193 yyvsp[0].node = NULL_TREE;
3194 yyval.node = build_tree_list
3195 (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3197 break;}
3198 case 95:
3199 #line 922 "./parse.y"
3201 yyerror ("Missing variable initializer");
3202 yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3203 RECOVER;
3205 break;}
3206 case 96:
3207 #line 928 "./parse.y"
3209 yyerror ("';' expected");
3210 yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3211 RECOVER;
3213 break;}
3214 case 98:
3215 #line 938 "./parse.y"
3216 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3217 break;}
3218 case 99:
3219 #line 940 "./parse.y"
3220 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3221 break;}
3222 case 100:
3223 #line 942 "./parse.y"
3224 {yyerror ("']' expected"); DRECOVER(vdi);;
3225 break;}
3226 case 101:
3227 #line 944 "./parse.y"
3228 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3229 break;}
3230 case 104:
3231 #line 955 "./parse.y"
3233 current_function_decl = yyvsp[0].node;
3234 if (current_function_decl
3235 && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3236 source_start_java_method (current_function_decl);
3237 else
3238 current_function_decl = NULL_TREE;
3240 break;}
3241 case 105:
3242 #line 964 "./parse.y"
3243 { finish_method_declaration (yyvsp[0].node); ;
3244 break;}
3245 case 106:
3246 #line 966 "./parse.y"
3247 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3248 break;}
3249 case 107:
3250 #line 971 "./parse.y"
3251 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3252 break;}
3253 case 108:
3254 #line 973 "./parse.y"
3255 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3256 break;}
3257 case 109:
3258 #line 975 "./parse.y"
3259 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3260 break;}
3261 case 110:
3262 #line 977 "./parse.y"
3263 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3264 break;}
3265 case 111:
3266 #line 979 "./parse.y"
3268 yyerror ("Invalid method declaration, method name required");
3269 RECOVER;
3271 break;}
3272 case 112:
3273 #line 984 "./parse.y"
3274 {RECOVER;;
3275 break;}
3276 case 113:
3277 #line 986 "./parse.y"
3278 {yyerror ("Identifier expected"); RECOVER;;
3279 break;}
3280 case 114:
3281 #line 988 "./parse.y"
3282 {yyerror ("Identifier expected"); RECOVER;;
3283 break;}
3284 case 115:
3285 #line 990 "./parse.y"
3287 yyerror ("Invalid method declaration, return type required");
3288 RECOVER;
3290 break;}
3291 case 116:
3292 #line 998 "./parse.y"
3294 ctxp->formal_parameter_number = 0;
3295 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3297 break;}
3298 case 117:
3299 #line 1003 "./parse.y"
3300 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3301 break;}
3302 case 118:
3303 #line 1005 "./parse.y"
3305 EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3306 TREE_PURPOSE (yyvsp[-2].node) =
3307 build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3308 parse_warning_context
3309 (wfl_operator,
3310 "Discouraged form of returned type specification");
3312 break;}
3313 case 119:
3314 #line 1014 "./parse.y"
3315 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3316 break;}
3317 case 120:
3318 #line 1016 "./parse.y"
3319 {yyerror ("']' expected"); RECOVER;;
3320 break;}
3321 case 121:
3322 #line 1021 "./parse.y"
3324 ctxp->formal_parameter_number = 1;
3326 break;}
3327 case 122:
3328 #line 1025 "./parse.y"
3330 ctxp->formal_parameter_number += 1;
3331 yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3333 break;}
3334 case 123:
3335 #line 1030 "./parse.y"
3336 { yyerror ("Missing formal parameter term"); RECOVER; ;
3337 break;}
3338 case 124:
3339 #line 1035 "./parse.y"
3341 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3343 break;}
3344 case 125:
3345 #line 1039 "./parse.y"
3347 yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3348 ARG_FINAL_P (yyval.node) = 1;
3350 break;}
3351 case 126:
3352 #line 1044 "./parse.y"
3354 yyerror ("Missing identifier"); RECOVER;
3355 yyval.node = NULL_TREE;
3357 break;}
3358 case 127:
3359 #line 1049 "./parse.y"
3361 yyerror ("Missing identifier"); RECOVER;
3362 yyval.node = NULL_TREE;
3364 break;}
3365 case 128:
3366 #line 1057 "./parse.y"
3368 check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3369 yyvsp[0].value, ACC_FINAL);
3370 if (yyvsp[0].value != ACC_FINAL)
3371 MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3373 break;}
3374 case 129:
3375 #line 1066 "./parse.y"
3376 { yyval.node = NULL_TREE; ;
3377 break;}
3378 case 130:
3379 #line 1068 "./parse.y"
3380 { yyval.node = yyvsp[0].node; ;
3381 break;}
3382 case 131:
3383 #line 1070 "./parse.y"
3384 {yyerror ("Missing class type term"); RECOVER;;
3385 break;}
3386 case 132:
3387 #line 1075 "./parse.y"
3388 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3389 break;}
3390 case 133:
3391 #line 1077 "./parse.y"
3392 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3393 break;}
3394 case 134:
3395 #line 1079 "./parse.y"
3396 {yyerror ("Missing class type term"); RECOVER;;
3397 break;}
3398 case 137:
3399 #line 1086 "./parse.y"
3400 { yyval.node = NULL_TREE; ;
3401 break;}
3402 case 138:
3403 #line 1092 "./parse.y"
3405 TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3406 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3408 break;}
3409 case 139:
3410 #line 1097 "./parse.y"
3412 TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3413 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3415 break;}
3416 case 140:
3417 #line 1105 "./parse.y"
3419 check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3420 /* Can't have a static initializer in an innerclass */
3421 if (yyvsp[0].value | ACC_STATIC &&
3422 GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3423 parse_error_context
3424 (MODIFIER_WFL (STATIC_TK),
3425 "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3426 IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3427 SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3429 break;}
3430 case 141:
3431 #line 1121 "./parse.y"
3433 current_function_decl = yyvsp[0].node;
3434 source_start_java_method (current_function_decl);
3436 break;}
3437 case 142:
3438 #line 1126 "./parse.y"
3439 { finish_method_declaration (yyvsp[0].node); ;
3440 break;}
3441 case 143:
3442 #line 1131 "./parse.y"
3443 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3444 break;}
3445 case 144:
3446 #line 1133 "./parse.y"
3447 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3448 break;}
3449 case 145:
3450 #line 1138 "./parse.y"
3452 ctxp->formal_parameter_number = 0;
3453 yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3455 break;}
3456 case 146:
3457 #line 1143 "./parse.y"
3458 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3459 break;}
3460 case 147:
3461 #line 1151 "./parse.y"
3463 BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3464 yyval.node = yyvsp[0].node;
3466 break;}
3467 case 148:
3468 #line 1156 "./parse.y"
3469 { yyval.node = yyvsp[0].node; ;
3470 break;}
3471 case 149:
3472 #line 1158 "./parse.y"
3473 { yyval.node = yyvsp[0].node; ;
3474 break;}
3475 case 150:
3476 #line 1160 "./parse.y"
3477 { yyval.node = yyvsp[0].node; ;
3478 break;}
3479 case 153:
3480 #line 1170 "./parse.y"
3482 yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE);
3483 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3484 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3486 break;}
3487 case 154:
3488 #line 1176 "./parse.y"
3490 yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node);
3491 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3492 yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3494 break;}
3495 case 155:
3496 #line 1184 "./parse.y"
3497 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3498 break;}
3499 case 156:
3500 #line 1186 "./parse.y"
3501 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3502 break;}
3503 case 157:
3504 #line 1191 "./parse.y"
3506 tree wfl = build_wfl_node (this_identifier_node);
3507 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3508 yyval.node = wfl;
3510 break;}
3511 case 158:
3512 #line 1197 "./parse.y"
3514 tree wfl = build_wfl_node (super_identifier_node);
3515 EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3516 yyval.node = wfl;
3518 break;}
3519 case 159:
3520 #line 1208 "./parse.y"
3521 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3522 break;}
3523 case 161:
3524 #line 1211 "./parse.y"
3525 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3526 break;}
3527 case 163:
3528 #line 1214 "./parse.y"
3529 { create_interface (0, yyvsp[-1].node, yyvsp[0].node); ;
3530 break;}
3531 case 165:
3532 #line 1217 "./parse.y"
3533 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3534 break;}
3535 case 167:
3536 #line 1220 "./parse.y"
3537 {yyerror ("'{' expected"); RECOVER;;
3538 break;}
3539 case 168:
3540 #line 1222 "./parse.y"
3541 {yyerror ("'{' expected"); RECOVER;;
3542 break;}
3543 case 169:
3544 #line 1227 "./parse.y"
3546 ctxp->interface_number = 1;
3547 yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3549 break;}
3550 case 170:
3551 #line 1232 "./parse.y"
3553 ctxp->interface_number++;
3554 yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3556 break;}
3557 case 171:
3558 #line 1237 "./parse.y"
3559 {yyerror ("Invalid interface type"); RECOVER;;
3560 break;}
3561 case 172:
3562 #line 1239 "./parse.y"
3563 {yyerror ("Missing term"); RECOVER;;
3564 break;}
3565 case 173:
3566 #line 1244 "./parse.y"
3567 { yyval.node = NULL_TREE; ;
3568 break;}
3569 case 174:
3570 #line 1246 "./parse.y"
3571 { yyval.node = NULL_TREE; ;
3572 break;}
3573 case 179:
3574 #line 1258 "./parse.y"
3575 { end_class_declaration (1); ;
3576 break;}
3577 case 180:
3578 #line 1260 "./parse.y"
3579 { end_class_declaration (1); ;
3580 break;}
3581 case 182:
3582 #line 1269 "./parse.y"
3584 check_abstract_method_header (yyvsp[-1].node);
3585 current_function_decl = NULL_TREE; /* FIXME ? */
3587 break;}
3588 case 183:
3589 #line 1274 "./parse.y"
3590 {yyerror ("';' expected"); RECOVER;;
3591 break;}
3592 case 184:
3593 #line 1280 "./parse.y"
3594 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3595 break;}
3596 case 185:
3597 #line 1282 "./parse.y"
3598 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3599 break;}
3600 case 186:
3601 #line 1284 "./parse.y"
3602 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3603 break;}
3604 case 187:
3605 #line 1289 "./parse.y"
3607 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node),
3608 yyvsp[0].node, NULL_TREE);
3610 break;}
3611 case 188:
3612 #line 1294 "./parse.y"
3614 yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3616 break;}
3617 case 189:
3618 #line 1298 "./parse.y"
3619 {yyerror ("Missing term"); RECOVER;;
3620 break;}
3621 case 190:
3622 #line 1304 "./parse.y"
3624 /* Store the location of the `}' when doing xrefs */
3625 if (current_function_decl && flag_emit_xref)
3626 DECL_END_SOURCE_LINE (current_function_decl) =
3627 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3628 yyval.node = empty_stmt_node;
3630 break;}
3631 case 191:
3632 #line 1312 "./parse.y"
3633 { yyval.node = yyvsp[0].node; ;
3634 break;}
3635 case 192:
3636 #line 1317 "./parse.y"
3637 { enter_block (); ;
3638 break;}
3639 case 193:
3640 #line 1322 "./parse.y"
3642 maybe_absorb_scoping_blocks ();
3643 /* Store the location of the `}' when doing xrefs */
3644 if (current_function_decl && flag_emit_xref)
3645 DECL_END_SOURCE_LINE (current_function_decl) =
3646 EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3647 yyval.node = exit_block ();
3649 break;}
3650 case 197:
3651 #line 1340 "./parse.y"
3652 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3653 break;}
3654 case 198:
3655 #line 1342 "./parse.y"
3657 LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3658 end_class_declaration (1);
3660 break;}
3661 case 200:
3662 #line 1354 "./parse.y"
3663 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3664 break;}
3665 case 201:
3666 #line 1356 "./parse.y"
3667 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3668 break;}
3669 case 207:
3670 #line 1366 "./parse.y"
3671 { yyval.node = exit_block (); ;
3672 break;}
3673 case 212:
3674 #line 1375 "./parse.y"
3675 { yyval.node = exit_block (); ;
3676 break;}
3677 case 224:
3678 #line 1394 "./parse.y"
3679 { yyval.node = empty_stmt_node; ;
3680 break;}
3681 case 225:
3682 #line 1399 "./parse.y"
3684 yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node),
3685 EXPR_WFL_NODE (yyvsp[-1].node));
3686 pushlevel (2);
3687 push_labeled_block (yyval.node);
3688 PUSH_LABELED_BLOCK (yyval.node);
3690 break;}
3691 case 226:
3692 #line 1410 "./parse.y"
3693 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3694 break;}
3695 case 227:
3696 #line 1412 "./parse.y"
3697 {yyerror ("':' expected"); RECOVER;;
3698 break;}
3699 case 228:
3700 #line 1417 "./parse.y"
3701 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3702 break;}
3703 case 229:
3704 #line 1424 "./parse.y"
3706 /* We have a statement. Generate a WFL around it so
3707 we can debug it */
3708 yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3709 /* We know we have a statement, so set the debug
3710 info to be eventually generate here. */
3711 yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3713 break;}
3714 case 230:
3715 #line 1433 "./parse.y"
3717 if (ctxp->prevent_ese != lineno)
3718 yyerror ("Invalid expression statement");
3719 DRECOVER (expr_stmt);
3721 break;}
3722 case 231:
3723 #line 1439 "./parse.y"
3725 if (ctxp->prevent_ese != lineno)
3726 yyerror ("Invalid expression statement");
3727 DRECOVER (expr_stmt);
3729 break;}
3730 case 232:
3731 #line 1445 "./parse.y"
3733 if (ctxp->prevent_ese != lineno)
3734 yyerror ("Invalid expression statement");
3735 DRECOVER (expr_stmt);
3737 break;}
3738 case 233:
3739 #line 1451 "./parse.y"
3740 {yyerror ("')' expected"); RECOVER;;
3741 break;}
3742 case 234:
3743 #line 1453 "./parse.y"
3745 parse_ctor_invocation_error ();
3746 RECOVER;
3748 break;}
3749 case 235:
3750 #line 1458 "./parse.y"
3751 {yyerror ("')' expected"); RECOVER;;
3752 break;}
3753 case 236:
3754 #line 1460 "./parse.y"
3756 parse_ctor_invocation_error ();
3757 RECOVER;
3759 break;}
3760 case 237:
3761 #line 1465 "./parse.y"
3762 {yyerror ("'(' expected"); RECOVER;;
3763 break;}
3764 case 238:
3765 #line 1467 "./parse.y"
3766 {yyerror ("')' expected"); RECOVER;;
3767 break;}
3768 case 239:
3769 #line 1469 "./parse.y"
3770 {yyerror ("')' expected"); RECOVER;;
3771 break;}
3772 case 240:
3773 #line 1471 "./parse.y"
3774 {yyerror ("';' expected"); RECOVER;;
3775 break;}
3776 case 241:
3777 #line 1473 "./parse.y"
3778 {yyerror ("';' expected"); RECOVER;;
3779 break;}
3780 case 249:
3781 #line 1488 "./parse.y"
3783 yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node,
3784 yyvsp[0].node, NULL_TREE);
3786 break;}
3787 case 250:
3788 #line 1493 "./parse.y"
3789 {yyerror ("'(' expected"); RECOVER;;
3790 break;}
3791 case 251:
3792 #line 1495 "./parse.y"
3793 {yyerror ("Missing term"); RECOVER;;
3794 break;}
3795 case 252:
3796 #line 1497 "./parse.y"
3797 {yyerror ("')' expected"); RECOVER;;
3798 break;}
3799 case 253:
3800 #line 1502 "./parse.y"
3801 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3802 break;}
3803 case 254:
3804 #line 1507 "./parse.y"
3805 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3806 break;}
3807 case 255:
3808 #line 1512 "./parse.y"
3810 enter_block ();
3812 break;}
3813 case 256:
3814 #line 1516 "./parse.y"
3816 /* Make into "proper list" of COMPOUND_EXPRs.
3817 I.e. make the last statment also have its own
3818 COMPOUND_EXPR. */
3819 maybe_absorb_scoping_blocks ();
3820 TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3821 yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3823 break;}
3824 case 257:
3825 #line 1528 "./parse.y"
3827 yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3828 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3830 break;}
3831 case 258:
3832 #line 1533 "./parse.y"
3833 {yyerror ("'(' expected"); RECOVER;;
3834 break;}
3835 case 259:
3836 #line 1535 "./parse.y"
3837 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3838 break;}
3839 case 260:
3840 #line 1537 "./parse.y"
3841 {yyerror ("'{' expected"); RECOVER;;
3842 break;}
3843 case 261:
3844 #line 1545 "./parse.y"
3845 { yyval.node = NULL_TREE; ;
3846 break;}
3847 case 262:
3848 #line 1547 "./parse.y"
3849 { yyval.node = NULL_TREE; ;
3850 break;}
3851 case 263:
3852 #line 1549 "./parse.y"
3853 { yyval.node = NULL_TREE; ;
3854 break;}
3855 case 264:
3856 #line 1551 "./parse.y"
3857 { yyval.node = NULL_TREE; ;
3858 break;}
3859 case 270:
3860 #line 1570 "./parse.y"
3862 tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3863 EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3864 java_method_add_stmt (current_function_decl, lab);
3866 break;}
3867 case 271:
3868 #line 1576 "./parse.y"
3870 tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3871 EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3872 java_method_add_stmt (current_function_decl, lab);
3874 break;}
3875 case 272:
3876 #line 1582 "./parse.y"
3877 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3878 break;}
3879 case 273:
3880 #line 1584 "./parse.y"
3881 {yyerror ("':' expected"); RECOVER;;
3882 break;}
3883 case 274:
3884 #line 1586 "./parse.y"
3885 {yyerror ("':' expected"); RECOVER;;
3886 break;}
3887 case 275:
3888 #line 1591 "./parse.y"
3890 tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3891 yyval.node = build_new_loop (body);
3893 break;}
3894 case 276:
3895 #line 1599 "./parse.y"
3896 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3897 break;}
3898 case 277:
3899 #line 1601 "./parse.y"
3900 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3901 break;}
3902 case 278:
3903 #line 1603 "./parse.y"
3904 {yyerror ("Missing term and ')' expected"); RECOVER;;
3905 break;}
3906 case 279:
3907 #line 1605 "./parse.y"
3908 {yyerror ("')' expected"); RECOVER;;
3909 break;}
3910 case 280:
3911 #line 1610 "./parse.y"
3912 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3913 break;}
3914 case 281:
3915 #line 1615 "./parse.y"
3917 tree body = build_loop_body (0, NULL_TREE, 1);
3918 yyval.node = build_new_loop (body);
3920 break;}
3921 case 282:
3922 #line 1624 "./parse.y"
3923 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3924 break;}
3925 case 283:
3926 #line 1629 "./parse.y"
3927 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3928 break;}
3929 case 284:
3930 #line 1631 "./parse.y"
3932 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3933 /* We have not condition, so we get rid of the EXIT_EXPR */
3934 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3935 empty_stmt_node;
3937 break;}
3938 case 285:
3939 #line 1638 "./parse.y"
3940 {yyerror ("Invalid control expression"); RECOVER;;
3941 break;}
3942 case 286:
3943 #line 1640 "./parse.y"
3944 {yyerror ("Invalid update expression"); RECOVER;;
3945 break;}
3946 case 287:
3947 #line 1642 "./parse.y"
3948 {yyerror ("Invalid update expression"); RECOVER;;
3949 break;}
3950 case 288:
3951 #line 1647 "./parse.y"
3952 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3953 break;}
3954 case 289:
3955 #line 1649 "./parse.y"
3957 yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3958 /* We have not condition, so we get rid of the EXIT_EXPR */
3959 LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) =
3960 empty_stmt_node;
3962 break;}
3963 case 290:
3964 #line 1659 "./parse.y"
3966 /* This scope defined for local variable that may be
3967 defined within the scope of the for loop */
3968 enter_block ();
3970 break;}
3971 case 291:
3972 #line 1665 "./parse.y"
3973 {yyerror ("'(' expected"); DRECOVER(for_1);;
3974 break;}
3975 case 292:
3976 #line 1667 "./parse.y"
3977 {yyerror ("Invalid init statement"); RECOVER;;
3978 break;}
3979 case 293:
3980 #line 1672 "./parse.y"
3982 /* We now declare the loop body. The loop is
3983 declared as a for loop. */
3984 tree body = build_loop_body (0, NULL_TREE, 0);
3985 yyval.node = build_new_loop (body);
3986 FOR_LOOP_P (yyval.node) = 1;
3987 /* The loop is added to the current block the for
3988 statement is defined within */
3989 java_method_add_stmt (current_function_decl, yyval.node);
3991 break;}
3992 case 294:
3993 #line 1684 "./parse.y"
3994 { yyval.node = empty_stmt_node; ;
3995 break;}
3996 case 295:
3997 #line 1686 "./parse.y"
3999 /* Init statement recorded within the previously
4000 defined block scope */
4001 yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4003 break;}
4004 case 296:
4005 #line 1692 "./parse.y"
4007 /* Local variable are recorded within the previously
4008 defined block scope */
4009 yyval.node = NULL_TREE;
4011 break;}
4012 case 297:
4013 #line 1698 "./parse.y"
4014 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4015 break;}
4016 case 298:
4017 #line 1702 "./parse.y"
4018 {yyval.node = empty_stmt_node;;
4019 break;}
4020 case 299:
4021 #line 1704 "./parse.y"
4022 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4023 break;}
4024 case 300:
4025 #line 1709 "./parse.y"
4026 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4027 break;}
4028 case 301:
4029 #line 1711 "./parse.y"
4030 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4031 break;}
4032 case 302:
4033 #line 1713 "./parse.y"
4034 {yyerror ("Missing term"); RECOVER;;
4035 break;}
4036 case 303:
4037 #line 1718 "./parse.y"
4038 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4039 break;}
4040 case 304:
4041 #line 1720 "./parse.y"
4042 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4043 break;}
4044 case 305:
4045 #line 1722 "./parse.y"
4046 {yyerror ("Missing term"); RECOVER;;
4047 break;}
4048 case 306:
4049 #line 1724 "./parse.y"
4050 {yyerror ("';' expected"); RECOVER;;
4051 break;}
4052 case 307:
4053 #line 1729 "./parse.y"
4054 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4055 break;}
4056 case 308:
4057 #line 1731 "./parse.y"
4058 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4059 break;}
4060 case 309:
4061 #line 1733 "./parse.y"
4062 {yyerror ("Missing term"); RECOVER;;
4063 break;}
4064 case 310:
4065 #line 1735 "./parse.y"
4066 {yyerror ("';' expected"); RECOVER;;
4067 break;}
4068 case 311:
4069 #line 1740 "./parse.y"
4070 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4071 break;}
4072 case 312:
4073 #line 1742 "./parse.y"
4074 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4075 break;}
4076 case 313:
4077 #line 1744 "./parse.y"
4078 {yyerror ("Missing term"); RECOVER;;
4079 break;}
4080 case 314:
4081 #line 1746 "./parse.y"
4082 {yyerror ("';' expected"); RECOVER;;
4083 break;}
4084 case 315:
4085 #line 1751 "./parse.y"
4087 yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4088 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4090 break;}
4091 case 316:
4092 #line 1756 "./parse.y"
4093 {yyerror ("Missing term"); RECOVER;;
4094 break;}
4095 case 317:
4096 #line 1758 "./parse.y"
4097 {yyerror ("';' expected"); RECOVER;;
4098 break;}
4099 case 318:
4100 #line 1763 "./parse.y"
4102 yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4103 EXPR_WFL_LINECOL (yyval.node) =
4104 EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4106 break;}
4107 case 319:
4108 #line 1769 "./parse.y"
4109 {yyerror ("'{' expected"); RECOVER;;
4110 break;}
4111 case 320:
4112 #line 1771 "./parse.y"
4113 {yyerror ("'(' expected"); RECOVER;;
4114 break;}
4115 case 321:
4116 #line 1773 "./parse.y"
4117 {yyerror ("Missing term"); RECOVER;;
4118 break;}
4119 case 322:
4120 #line 1775 "./parse.y"
4121 {yyerror ("Missing term"); RECOVER;;
4122 break;}
4123 case 323:
4124 #line 1780 "./parse.y"
4126 check_modifiers (
4127 "Illegal modifier `%s'. Only `synchronized' was expected here",
4128 yyvsp[0].value, ACC_SYNCHRONIZED);
4129 if (yyvsp[0].value != ACC_SYNCHRONIZED)
4130 MODIFIER_WFL (SYNCHRONIZED_TK) =
4131 build_wfl_node (NULL_TREE);
4133 break;}
4134 case 324:
4135 #line 1792 "./parse.y"
4136 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4137 break;}
4138 case 325:
4139 #line 1794 "./parse.y"
4140 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4141 break;}
4142 case 326:
4143 #line 1796 "./parse.y"
4144 { yyval.node = build_try_finally_statement
4145 (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4146 yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4148 break;}
4149 case 327:
4150 #line 1801 "./parse.y"
4151 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4152 break;}
4153 case 329:
4154 #line 1807 "./parse.y"
4156 TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4157 yyval.node = yyvsp[0].node;
4159 break;}
4160 case 330:
4161 #line 1815 "./parse.y"
4163 java_method_add_stmt (current_function_decl, yyvsp[0].node);
4164 exit_block ();
4165 yyval.node = yyvsp[-1].node;
4167 break;}
4168 case 331:
4169 #line 1823 "./parse.y"
4171 /* We add a block to define a scope for
4172 formal_parameter (CCBP). The formal parameter is
4173 declared initialized by the appropriate function
4174 call */
4175 tree ccpb = enter_block ();
4176 tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location,
4177 TREE_PURPOSE (yyvsp[-1].node),
4178 soft_exceptioninfo_call_node);
4179 declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4180 build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4181 init));
4182 yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4183 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4185 break;}
4186 case 332:
4187 #line 1839 "./parse.y"
4188 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4189 break;}
4190 case 333:
4191 #line 1841 "./parse.y"
4193 yyerror ("Missing term or ')' expected");
4194 RECOVER; yyval.node = NULL_TREE;
4196 break;}
4197 case 334:
4198 #line 1846 "./parse.y"
4199 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4200 break;}
4201 case 335:
4202 #line 1851 "./parse.y"
4203 { yyval.node = yyvsp[0].node; ;
4204 break;}
4205 case 336:
4206 #line 1853 "./parse.y"
4207 {yyerror ("'{' expected"); RECOVER; ;
4208 break;}
4209 case 340:
4210 #line 1865 "./parse.y"
4211 { yyval.node = build_this (yyvsp[0].operator.location); ;
4212 break;}
4213 case 341:
4214 #line 1867 "./parse.y"
4215 {yyval.node = yyvsp[-1].node;;
4216 break;}
4217 case 347:
4218 #line 1877 "./parse.y"
4220 tree wfl = build_wfl_node (this_identifier_node);
4221 yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4223 break;}
4224 case 348:
4225 #line 1882 "./parse.y"
4226 {yyerror ("')' expected"); RECOVER;;
4227 break;}
4228 case 349:
4229 #line 1884 "./parse.y"
4230 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4231 break;}
4232 case 350:
4233 #line 1886 "./parse.y"
4234 {yyerror ("'class' expected" ); RECOVER;;
4235 break;}
4236 case 351:
4237 #line 1888 "./parse.y"
4238 {yyerror ("'class' expected" ); RECOVER;;
4239 break;}
4240 case 352:
4241 #line 1896 "./parse.y"
4243 yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4244 CLASS_LOADED_P (yyval.node) = 1;
4246 break;}
4247 case 353:
4248 #line 1901 "./parse.y"
4249 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4250 break;}
4251 case 354:
4252 #line 1911 "./parse.y"
4253 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4254 break;}
4255 case 355:
4256 #line 1913 "./parse.y"
4257 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4258 break;}
4259 case 356:
4260 #line 1915 "./parse.y"
4261 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4262 break;}
4263 case 357:
4264 #line 1917 "./parse.y"
4265 { yyval.node = build_class_ref (void_type_node); ;
4266 break;}
4267 case 358:
4268 #line 1922 "./parse.y"
4269 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4270 break;}
4271 case 359:
4272 #line 1924 "./parse.y"
4273 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4274 break;}
4275 case 361:
4276 #line 1930 "./parse.y"
4278 tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4279 yyval.node = make_qualified_primary (yyvsp[-3].node, ctor,
4280 EXPR_WFL_LINECOL (yyvsp[-3].node));
4282 break;}
4283 case 363:
4284 #line 1937 "./parse.y"
4286 tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4287 yyval.node = make_qualified_primary (yyvsp[-4].node, ctor,
4288 EXPR_WFL_LINECOL (yyvsp[-4].node));
4290 break;}
4291 case 365:
4292 #line 1944 "./parse.y"
4293 {yyerror ("'(' expected"); DRECOVER(new_1);;
4294 break;}
4295 case 366:
4296 #line 1946 "./parse.y"
4297 {yyerror ("'(' expected"); RECOVER;;
4298 break;}
4299 case 367:
4300 #line 1948 "./parse.y"
4301 {yyerror ("')' or term expected"); RECOVER;;
4302 break;}
4303 case 368:
4304 #line 1950 "./parse.y"
4305 {yyerror ("')' expected"); RECOVER;;
4306 break;}
4307 case 369:
4308 #line 1952 "./parse.y"
4309 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4310 break;}
4311 case 370:
4312 #line 1954 "./parse.y"
4313 {yyerror ("'(' expected"); RECOVER;;
4314 break;}
4315 case 371:
4316 #line 1964 "./parse.y"
4317 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4318 break;}
4319 case 372:
4320 #line 1966 "./parse.y"
4322 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4323 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4325 end_class_declaration (1);
4327 /* Now we can craft the new expression */
4328 yyval.node = build_new_invocation (id, yyvsp[-3].node);
4330 /* Note that we can't possibly be here if
4331 `class_type' is an interface (in which case the
4332 anonymous class extends Object and implements
4333 `class_type', hence its constructor can't have
4334 arguments.) */
4336 /* Otherwise, the innerclass must feature a
4337 constructor matching `argument_list'. Anonymous
4338 classes are a bit special: it's impossible to
4339 define constructor for them, hence constructors
4340 must be generated following the hints provided by
4341 the `new' expression. Whether a super constructor
4342 of that nature exists or not is to be verified
4343 later on in verify_constructor_super.
4345 It's during the expansion of a `new' statement
4346 refering to an anonymous class that a ctor will
4347 be generated for the anonymous class, with the
4348 right arguments. */
4351 break;}
4352 case 373:
4353 #line 1997 "./parse.y"
4354 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4355 break;}
4356 case 374:
4357 #line 1999 "./parse.y"
4359 tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4360 EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4362 end_class_declaration (1);
4364 /* Now we can craft the new expression. The
4365 statement doesn't need to be remember so that a
4366 constructor can be generated, since its signature
4367 is already known. */
4368 yyval.node = build_new_invocation (id, NULL_TREE);
4370 break;}
4371 case 375:
4372 #line 2015 "./parse.y"
4373 { yyval.node = yyvsp[-2].node; ;
4374 break;}
4375 case 376:
4376 #line 2017 "./parse.y"
4377 { yyval.node = yyvsp[-2].node; ;
4378 break;}
4379 case 377:
4380 #line 2022 "./parse.y"
4382 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4383 ctxp->formal_parameter_number = 1;
4385 break;}
4386 case 378:
4387 #line 2027 "./parse.y"
4389 ctxp->formal_parameter_number += 1;
4390 yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4392 break;}
4393 case 379:
4394 #line 2032 "./parse.y"
4395 {yyerror ("Missing term"); RECOVER;;
4396 break;}
4397 case 380:
4398 #line 2037 "./parse.y"
4399 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4400 break;}
4401 case 381:
4402 #line 2039 "./parse.y"
4403 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4404 break;}
4405 case 382:
4406 #line 2041 "./parse.y"
4407 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4408 break;}
4409 case 383:
4410 #line 2043 "./parse.y"
4411 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4412 break;}
4413 case 384:
4414 #line 2047 "./parse.y"
4416 char *sig;
4417 while (CURRENT_OSB (ctxp)--)
4418 obstack_1grow (&temporary_obstack, '[');
4419 sig = obstack_finish (&temporary_obstack);
4420 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4421 yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4423 break;}
4424 case 385:
4425 #line 2056 "./parse.y"
4427 tree type = yyvsp[-2].node;
4428 while (CURRENT_OSB (ctxp)--)
4429 type = build_java_array_type (type, -1);
4430 yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4431 build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4433 break;}
4434 case 386:
4435 #line 2064 "./parse.y"
4436 {yyerror ("'[' expected"); DRECOVER ("]");;
4437 break;}
4438 case 387:
4439 #line 2066 "./parse.y"
4440 {yyerror ("']' expected"); RECOVER;;
4441 break;}
4442 case 388:
4443 #line 2071 "./parse.y"
4444 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4445 break;}
4446 case 389:
4447 #line 2073 "./parse.y"
4448 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4449 break;}
4450 case 390:
4451 #line 2078 "./parse.y"
4453 EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4454 yyval.node = yyvsp[-1].node;
4456 break;}
4457 case 391:
4458 #line 2083 "./parse.y"
4459 {yyerror ("']' expected"); RECOVER;;
4460 break;}
4461 case 392:
4462 #line 2085 "./parse.y"
4464 yyerror ("Missing term");
4465 yyerror ("']' expected");
4466 RECOVER;
4468 break;}
4469 case 393:
4470 #line 2094 "./parse.y"
4472 int allocate = 0;
4473 /* If not initialized, allocate memory for the osb
4474 numbers stack */
4475 if (!ctxp->osb_limit)
4477 allocate = ctxp->osb_limit = 32;
4478 ctxp->osb_depth = -1;
4480 /* If capacity overflown, reallocate a bigger chunk */
4481 else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4482 allocate = ctxp->osb_limit << 1;
4484 if (allocate)
4486 allocate *= sizeof (int);
4487 if (ctxp->osb_number)
4488 ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4489 allocate);
4490 else
4491 ctxp->osb_number = (int *)xmalloc (allocate);
4493 ctxp->osb_depth++;
4494 CURRENT_OSB (ctxp) = 1;
4496 break;}
4497 case 394:
4498 #line 2120 "./parse.y"
4499 { CURRENT_OSB (ctxp)++; ;
4500 break;}
4501 case 395:
4502 #line 2122 "./parse.y"
4503 { yyerror ("']' expected"); RECOVER;;
4504 break;}
4505 case 396:
4506 #line 2127 "./parse.y"
4507 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4508 break;}
4509 case 397:
4510 #line 2131 "./parse.y"
4512 tree super_wfl =
4513 build_wfl_node (super_identifier_node);
4514 EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4515 yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4517 break;}
4518 case 398:
4519 #line 2138 "./parse.y"
4520 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4521 break;}
4522 case 399:
4523 #line 2143 "./parse.y"
4524 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4525 break;}
4526 case 400:
4527 #line 2145 "./parse.y"
4528 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4529 break;}
4530 case 401:
4531 #line 2147 "./parse.y"
4533 if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4534 yyval.node = build_this_super_qualified_invocation
4535 (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4536 else
4538 tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4539 yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4542 break;}
4543 case 402:
4544 #line 2158 "./parse.y"
4546 if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4547 yyval.node = build_this_super_qualified_invocation
4548 (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4549 else
4551 tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4552 yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4555 break;}
4556 case 403:
4557 #line 2169 "./parse.y"
4559 yyval.node = build_this_super_qualified_invocation
4560 (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4562 break;}
4563 case 404:
4564 #line 2174 "./parse.y"
4566 yyval.node = build_this_super_qualified_invocation
4567 (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4569 break;}
4570 case 405:
4571 #line 2183 "./parse.y"
4572 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4573 break;}
4574 case 406:
4575 #line 2185 "./parse.y"
4576 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4577 break;}
4578 case 407:
4579 #line 2190 "./parse.y"
4580 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4581 break;}
4582 case 408:
4583 #line 2192 "./parse.y"
4584 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4585 break;}
4586 case 409:
4587 #line 2194 "./parse.y"
4589 yyerror ("Missing term and ']' expected");
4590 DRECOVER(array_access);
4592 break;}
4593 case 410:
4594 #line 2199 "./parse.y"
4596 yyerror ("']' expected");
4597 DRECOVER(array_access);
4599 break;}
4600 case 411:
4601 #line 2204 "./parse.y"
4603 yyerror ("Missing term and ']' expected");
4604 DRECOVER(array_access);
4606 break;}
4607 case 412:
4608 #line 2209 "./parse.y"
4610 yyerror ("']' expected");
4611 DRECOVER(array_access);
4613 break;}
4614 case 417:
4615 #line 2224 "./parse.y"
4616 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4617 break;}
4618 case 418:
4619 #line 2229 "./parse.y"
4620 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4621 break;}
4622 case 421:
4623 #line 2236 "./parse.y"
4624 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4625 break;}
4626 case 422:
4627 #line 2238 "./parse.y"
4628 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4629 break;}
4630 case 424:
4631 #line 2241 "./parse.y"
4632 {yyerror ("Missing term"); RECOVER;
4633 break;}
4634 case 425:
4635 #line 2243 "./parse.y"
4636 {yyerror ("Missing term"); RECOVER;
4637 break;}
4638 case 426:
4639 #line 2248 "./parse.y"
4640 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4641 break;}
4642 case 427:
4643 #line 2250 "./parse.y"
4644 {yyerror ("Missing term"); RECOVER;
4645 break;}
4646 case 428:
4647 #line 2255 "./parse.y"
4648 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4649 break;}
4650 case 429:
4651 #line 2257 "./parse.y"
4652 {yyerror ("Missing term"); RECOVER;
4653 break;}
4654 case 431:
4655 #line 2263 "./parse.y"
4656 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4657 break;}
4658 case 432:
4659 #line 2265 "./parse.y"
4660 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4661 break;}
4662 case 434:
4663 #line 2268 "./parse.y"
4664 {yyerror ("Missing term"); RECOVER;
4665 break;}
4666 case 435:
4667 #line 2270 "./parse.y"
4668 {yyerror ("Missing term"); RECOVER;
4669 break;}
4670 case 436:
4671 #line 2275 "./parse.y"
4673 tree type = yyvsp[-3].node;
4674 while (CURRENT_OSB (ctxp)--)
4675 type = build_java_array_type (type, -1);
4676 ctxp->osb_depth--;
4677 yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node);
4679 break;}
4680 case 437:
4681 #line 2283 "./parse.y"
4682 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4683 break;}
4684 case 438:
4685 #line 2285 "./parse.y"
4686 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4687 break;}
4688 case 439:
4689 #line 2287 "./parse.y"
4691 const char *ptr;
4692 while (CURRENT_OSB (ctxp)--)
4693 obstack_1grow (&temporary_obstack, '[');
4694 ctxp->osb_depth--;
4695 obstack_grow0 (&temporary_obstack,
4696 IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4697 IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4698 ptr = obstack_finish (&temporary_obstack);
4699 EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4700 yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4702 break;}
4703 case 440:
4704 #line 2300 "./parse.y"
4705 {yyerror ("']' expected, invalid type expression");;
4706 break;}
4707 case 441:
4708 #line 2302 "./parse.y"
4710 if (ctxp->prevent_ese != lineno)
4711 yyerror ("Invalid type expression"); RECOVER;
4712 RECOVER;
4714 break;}
4715 case 442:
4716 #line 2308 "./parse.y"
4717 {yyerror ("Missing term"); RECOVER;;
4718 break;}
4719 case 443:
4720 #line 2310 "./parse.y"
4721 {yyerror ("Missing term"); RECOVER;;
4722 break;}
4723 case 444:
4724 #line 2312 "./parse.y"
4725 {yyerror ("Missing term"); RECOVER;;
4726 break;}
4727 case 446:
4728 #line 2318 "./parse.y"
4730 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token),
4731 yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4733 break;}
4734 case 447:
4735 #line 2323 "./parse.y"
4737 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4738 yyvsp[-2].node, yyvsp[0].node);
4740 break;}
4741 case 448:
4742 #line 2328 "./parse.y"
4744 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4745 yyvsp[-2].node, yyvsp[0].node);
4747 break;}
4748 case 449:
4749 #line 2333 "./parse.y"
4750 {yyerror ("Missing term"); RECOVER;;
4751 break;}
4752 case 450:
4753 #line 2335 "./parse.y"
4754 {yyerror ("Missing term"); RECOVER;;
4755 break;}
4756 case 451:
4757 #line 2337 "./parse.y"
4758 {yyerror ("Missing term"); RECOVER;;
4759 break;}
4760 case 453:
4761 #line 2343 "./parse.y"
4763 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4764 yyvsp[-2].node, yyvsp[0].node);
4766 break;}
4767 case 454:
4768 #line 2348 "./parse.y"
4770 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4771 yyvsp[-2].node, yyvsp[0].node);
4773 break;}
4774 case 455:
4775 #line 2353 "./parse.y"
4776 {yyerror ("Missing term"); RECOVER;;
4777 break;}
4778 case 456:
4779 #line 2355 "./parse.y"
4780 {yyerror ("Missing term"); RECOVER;;
4781 break;}
4782 case 458:
4783 #line 2361 "./parse.y"
4785 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4786 yyvsp[-2].node, yyvsp[0].node);
4788 break;}
4789 case 459:
4790 #line 2366 "./parse.y"
4792 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4793 yyvsp[-2].node, yyvsp[0].node);
4795 break;}
4796 case 460:
4797 #line 2371 "./parse.y"
4799 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4800 yyvsp[-2].node, yyvsp[0].node);
4802 break;}
4803 case 461:
4804 #line 2376 "./parse.y"
4805 {yyerror ("Missing term"); RECOVER;;
4806 break;}
4807 case 462:
4808 #line 2378 "./parse.y"
4809 {yyerror ("Missing term"); RECOVER;;
4810 break;}
4811 case 463:
4812 #line 2380 "./parse.y"
4813 {yyerror ("Missing term"); RECOVER;;
4814 break;}
4815 case 465:
4816 #line 2386 "./parse.y"
4818 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4819 yyvsp[-2].node, yyvsp[0].node);
4821 break;}
4822 case 466:
4823 #line 2391 "./parse.y"
4825 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4826 yyvsp[-2].node, yyvsp[0].node);
4828 break;}
4829 case 467:
4830 #line 2396 "./parse.y"
4832 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4833 yyvsp[-2].node, yyvsp[0].node);
4835 break;}
4836 case 468:
4837 #line 2401 "./parse.y"
4839 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4840 yyvsp[-2].node, yyvsp[0].node);
4842 break;}
4843 case 469:
4844 #line 2406 "./parse.y"
4845 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4846 break;}
4847 case 470:
4848 #line 2408 "./parse.y"
4849 {yyerror ("Missing term"); RECOVER;;
4850 break;}
4851 case 471:
4852 #line 2410 "./parse.y"
4853 {yyerror ("Missing term"); RECOVER;;
4854 break;}
4855 case 472:
4856 #line 2412 "./parse.y"
4857 {yyerror ("Missing term"); RECOVER;;
4858 break;}
4859 case 473:
4860 #line 2414 "./parse.y"
4861 {yyerror ("Missing term"); RECOVER;;
4862 break;}
4863 case 474:
4864 #line 2416 "./parse.y"
4865 {yyerror ("Invalid reference type"); RECOVER;;
4866 break;}
4867 case 476:
4868 #line 2422 "./parse.y"
4870 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4871 yyvsp[-2].node, yyvsp[0].node);
4873 break;}
4874 case 477:
4875 #line 2427 "./parse.y"
4877 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4878 yyvsp[-2].node, yyvsp[0].node);
4880 break;}
4881 case 478:
4882 #line 2432 "./parse.y"
4883 {yyerror ("Missing term"); RECOVER;;
4884 break;}
4885 case 479:
4886 #line 2434 "./parse.y"
4887 {yyerror ("Missing term"); RECOVER;;
4888 break;}
4889 case 481:
4890 #line 2440 "./parse.y"
4892 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4893 yyvsp[-2].node, yyvsp[0].node);
4895 break;}
4896 case 482:
4897 #line 2445 "./parse.y"
4898 {yyerror ("Missing term"); RECOVER;;
4899 break;}
4900 case 484:
4901 #line 2451 "./parse.y"
4903 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4904 yyvsp[-2].node, yyvsp[0].node);
4906 break;}
4907 case 485:
4908 #line 2456 "./parse.y"
4909 {yyerror ("Missing term"); RECOVER;;
4910 break;}
4911 case 487:
4912 #line 2462 "./parse.y"
4914 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4915 yyvsp[-2].node, yyvsp[0].node);
4917 break;}
4918 case 488:
4919 #line 2467 "./parse.y"
4920 {yyerror ("Missing term"); RECOVER;;
4921 break;}
4922 case 490:
4923 #line 2473 "./parse.y"
4925 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4926 yyvsp[-2].node, yyvsp[0].node);
4928 break;}
4929 case 491:
4930 #line 2478 "./parse.y"
4931 {yyerror ("Missing term"); RECOVER;;
4932 break;}
4933 case 493:
4934 #line 2484 "./parse.y"
4936 yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4937 yyvsp[-2].node, yyvsp[0].node);
4939 break;}
4940 case 494:
4941 #line 2489 "./parse.y"
4942 {yyerror ("Missing term"); RECOVER;;
4943 break;}
4944 case 496:
4945 #line 2495 "./parse.y"
4947 yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4948 EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4950 break;}
4951 case 497:
4952 #line 2500 "./parse.y"
4954 YYERROR_NOW;
4955 yyerror ("Missing term");
4956 DRECOVER (1);
4958 break;}
4959 case 498:
4960 #line 2506 "./parse.y"
4961 {yyerror ("Missing term"); DRECOVER (2);;
4962 break;}
4963 case 499:
4964 #line 2508 "./parse.y"
4965 {yyerror ("Missing term"); DRECOVER (3);;
4966 break;}
4967 case 502:
4968 #line 2518 "./parse.y"
4969 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4970 break;}
4971 case 503:
4972 #line 2520 "./parse.y"
4974 if (ctxp->prevent_ese != lineno)
4975 yyerror ("Missing term");
4976 DRECOVER (assign);
4978 break;}
4980 /* the action file gets copied in in place of this dollarsign */
4981 #line 498 "/usr/share/misc/bison.simple"
4983 yyvsp -= yylen;
4984 yyssp -= yylen;
4985 #ifdef YYLSP_NEEDED
4986 yylsp -= yylen;
4987 #endif
4989 #if YYDEBUG != 0
4990 if (yydebug)
4992 short *ssp1 = yyss - 1;
4993 fprintf (stderr, "state stack now");
4994 while (ssp1 != yyssp)
4995 fprintf (stderr, " %d", *++ssp1);
4996 fprintf (stderr, "\n");
4998 #endif
5000 *++yyvsp = yyval;
5002 #ifdef YYLSP_NEEDED
5003 yylsp++;
5004 if (yylen == 0)
5006 yylsp->first_line = yylloc.first_line;
5007 yylsp->first_column = yylloc.first_column;
5008 yylsp->last_line = (yylsp-1)->last_line;
5009 yylsp->last_column = (yylsp-1)->last_column;
5010 yylsp->text = 0;
5012 else
5014 yylsp->last_line = (yylsp+yylen-1)->last_line;
5015 yylsp->last_column = (yylsp+yylen-1)->last_column;
5017 #endif
5019 /* Now "shift" the result of the reduction.
5020 Determine what state that goes to,
5021 based on the state we popped back to
5022 and the rule number reduced by. */
5024 yyn = yyr1[yyn];
5026 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5027 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5028 yystate = yytable[yystate];
5029 else
5030 yystate = yydefgoto[yyn - YYNTBASE];
5032 goto yynewstate;
5034 yyerrlab: /* here on detecting error */
5036 if (! yyerrstatus)
5037 /* If not already recovering from an error, report this error. */
5039 ++yynerrs;
5041 #ifdef YYERROR_VERBOSE
5042 yyn = yypact[yystate];
5044 if (yyn > YYFLAG && yyn < YYLAST)
5046 int size = 0;
5047 char *msg;
5048 int x, count;
5050 count = 0;
5051 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
5052 for (x = (yyn < 0 ? -yyn : 0);
5053 x < (sizeof(yytname) / sizeof(char *)); x++)
5054 if (yycheck[x + yyn] == x)
5055 size += strlen(yytname[x]) + 15, count++;
5056 msg = (char *) malloc(size + 15);
5057 if (msg != 0)
5059 strcpy(msg, "parse error");
5061 if (count < 5)
5063 count = 0;
5064 for (x = (yyn < 0 ? -yyn : 0);
5065 x < (sizeof(yytname) / sizeof(char *)); x++)
5066 if (yycheck[x + yyn] == x)
5068 strcat(msg, count == 0 ? ", expecting `" : " or `");
5069 strcat(msg, yytname[x]);
5070 strcat(msg, "'");
5071 count++;
5074 yyerror(msg);
5075 free(msg);
5077 else
5078 yyerror ("parse error; also virtual memory exceeded");
5080 else
5081 #endif /* YYERROR_VERBOSE */
5082 yyerror("parse error");
5085 goto yyerrlab1;
5086 yyerrlab1: /* here on error raised explicitly by an action */
5088 if (yyerrstatus == 3)
5090 /* if just tried and failed to reuse lookahead token after an error, discard it. */
5092 /* return failure if at end of input */
5093 if (yychar == YYEOF)
5094 YYABORT;
5096 #if YYDEBUG != 0
5097 if (yydebug)
5098 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5099 #endif
5101 yychar = YYEMPTY;
5104 /* Else will try to reuse lookahead token
5105 after shifting the error token. */
5107 yyerrstatus = 3; /* Each real token shifted decrements this */
5109 goto yyerrhandle;
5111 yyerrdefault: /* current state does not do anything special for the error token. */
5113 #if 0
5114 /* This is wrong; only states that explicitly want error tokens
5115 should shift them. */
5116 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
5117 if (yyn) goto yydefault;
5118 #endif
5120 yyerrpop: /* pop the current state because it cannot handle the error token */
5122 if (yyssp == yyss) YYABORT;
5123 yyvsp--;
5124 yystate = *--yyssp;
5125 #ifdef YYLSP_NEEDED
5126 yylsp--;
5127 #endif
5129 #if YYDEBUG != 0
5130 if (yydebug)
5132 short *ssp1 = yyss - 1;
5133 fprintf (stderr, "Error: state stack now");
5134 while (ssp1 != yyssp)
5135 fprintf (stderr, " %d", *++ssp1);
5136 fprintf (stderr, "\n");
5138 #endif
5140 yyerrhandle:
5142 yyn = yypact[yystate];
5143 if (yyn == YYFLAG)
5144 goto yyerrdefault;
5146 yyn += YYTERROR;
5147 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5148 goto yyerrdefault;
5150 yyn = yytable[yyn];
5151 if (yyn < 0)
5153 if (yyn == YYFLAG)
5154 goto yyerrpop;
5155 yyn = -yyn;
5156 goto yyreduce;
5158 else if (yyn == 0)
5159 goto yyerrpop;
5161 if (yyn == YYFINAL)
5162 YYACCEPT;
5164 #if YYDEBUG != 0
5165 if (yydebug)
5166 fprintf(stderr, "Shifting error token, ");
5167 #endif
5169 *++yyvsp = yylval;
5170 #ifdef YYLSP_NEEDED
5171 *++yylsp = yylloc;
5172 #endif
5174 yystate = yyn;
5175 goto yynewstate;
5177 #line 2546 "./parse.y"
5181 /* This section of the code deal with save/restoring parser contexts.
5182 Add mode documentation here. FIXME */
5184 /* Helper function. Create a new parser context. With
5185 COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5186 context is copied, otherwise, the new context is zeroed. The newly
5187 created context becomes the current one. */
5189 static void
5190 create_new_parser_context (copy_from_previous)
5191 int copy_from_previous;
5193 struct parser_ctxt *new;
5195 new = (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5196 if (copy_from_previous)
5198 memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5199 new->saved_data_ctx = 1;
5201 else
5202 bzero ((PTR) new, sizeof (struct parser_ctxt));
5204 new->next = ctxp;
5205 ctxp = new;
5208 /* Create a new parser context and make it the current one. */
5210 void
5211 java_push_parser_context ()
5213 create_new_parser_context (0);
5214 if (ctxp->next)
5216 ctxp->incomplete_class = ctxp->next->incomplete_class;
5217 ctxp->gclass_list = ctxp->next->gclass_list;
5221 void
5222 java_pop_parser_context (generate)
5223 int generate;
5225 tree current;
5226 struct parser_ctxt *toFree, *next;
5228 if (!ctxp)
5229 return;
5231 toFree = ctxp;
5232 next = ctxp->next;
5233 if (next)
5235 next->incomplete_class = ctxp->incomplete_class;
5236 next->gclass_list = ctxp->gclass_list;
5237 lineno = ctxp->lineno;
5238 finput = ctxp->finput;
5239 current_class = ctxp->current_class;
5242 /* Set the single import class file flag to 0 for the current list
5243 of imported things */
5244 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5245 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5247 /* And restore those of the previous context */
5248 if ((ctxp = next)) /* Assignment is really meant here */
5249 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5250 IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5252 /* If we pushed a context to parse a class intended to be generated,
5253 we keep it so we can remember the class. What we could actually
5254 do is to just update a list of class names. */
5255 if (generate)
5257 toFree->next = ctxp_for_generation;
5258 ctxp_for_generation = toFree;
5260 else
5261 free (toFree);
5264 /* Create a parser context for the use of saving some global
5265 variables. */
5267 void
5268 java_parser_context_save_global ()
5270 if (!ctxp)
5272 java_push_parser_context ();
5273 ctxp->saved_data_ctx = 1;
5276 /* If this context already stores data, create a new one suitable
5277 for data storage. */
5278 else if (ctxp->saved_data)
5279 create_new_parser_context (1);
5281 ctxp->finput = finput;
5282 ctxp->lineno = lineno;
5283 ctxp->current_class = current_class;
5284 ctxp->filename = input_filename;
5285 ctxp->current_function_decl = current_function_decl;
5286 ctxp->saved_data = 1;
5289 /* Restore some global variables from the previous context. Make the
5290 previous context the current one. */
5292 void
5293 java_parser_context_restore_global ()
5295 finput = ctxp->finput;
5296 lineno = ctxp->lineno;
5297 current_class = ctxp->current_class;
5298 input_filename = ctxp->filename;
5299 current_function_decl = ctxp->current_function_decl;
5300 ctxp->saved_data = 0;
5301 if (ctxp->saved_data_ctx)
5302 java_pop_parser_context (0);
5305 /* Suspend vital data for the current class/function being parsed so
5306 that an other class can be parsed. Used to let local/anonymous
5307 classes be parsed. */
5309 static void
5310 java_parser_context_suspend ()
5312 /* This makes debugging through java_debug_context easier */
5313 static char *name = "<inner buffer context>";
5315 /* Duplicate the previous context, use it to save the globals we're
5316 interested in */
5317 create_new_parser_context (1);
5318 ctxp->current_function_decl = current_function_decl;
5319 ctxp->current_class = current_class;
5321 /* Then create a new context which inherits all data from the
5322 previous one. This will be the new current context */
5323 create_new_parser_context (1);
5325 /* Help debugging */
5326 ctxp->next->filename = name;
5329 /* Resume vital data for the current class/function being parsed so
5330 that an other class can be parsed. Used to let local/anonymous
5331 classes be parsed. The trick is the data storing file position
5332 informations must be restored to their current value, so parsing
5333 can resume as if no context was ever saved. */
5335 static void
5336 java_parser_context_resume ()
5338 struct parser_ctxt *old = ctxp; /* This one is to be discarded */
5339 struct parser_ctxt *saver = old->next; /* This one contain saved info */
5340 struct parser_ctxt *restored = saver->next; /* This one is the old current */
5342 /* We need to inherit the list of classes to complete/generate */
5343 restored->incomplete_class = old->incomplete_class;
5344 restored->gclass_list = old->gclass_list;
5345 restored->classd_list = old->classd_list;
5346 restored->class_list = old->class_list;
5348 /* Restore the current class and function from the saver */
5349 current_class = saver->current_class;
5350 current_function_decl = saver->current_function_decl;
5352 /* Retrive the restored context */
5353 ctxp = restored;
5355 /* Re-installed the data for the parsing to carry on */
5356 bcopy (&old->marker_begining, &ctxp->marker_begining,
5357 (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5359 /* Buffer context can now be discarded */
5360 free (saver);
5361 free (old);
5364 /* Add a new anchor node to which all statement(s) initializing static
5365 and non static initialized upon declaration field(s) will be
5366 linked. */
5368 static void
5369 java_parser_context_push_initialized_field ()
5371 tree node;
5373 node = build_tree_list (NULL_TREE, NULL_TREE);
5374 TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5375 CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5377 node = build_tree_list (NULL_TREE, NULL_TREE);
5378 TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5379 CPC_INITIALIZER_LIST (ctxp) = node;
5381 node = build_tree_list (NULL_TREE, NULL_TREE);
5382 TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5383 CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5386 /* Pop the lists of initialized field. If this lists aren't empty,
5387 remember them so we can use it to create and populate the $finit$
5388 or <clinit> functions. */
5390 static void
5391 java_parser_context_pop_initialized_field ()
5393 tree stmts;
5394 tree class_type = TREE_TYPE (GET_CPC ());
5396 if (CPC_INITIALIZER_LIST (ctxp))
5398 stmts = CPC_INITIALIZER_STMT (ctxp);
5399 CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5400 if (stmts && !java_error_count)
5401 TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5404 if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5406 stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5407 CPC_STATIC_INITIALIZER_LIST (ctxp) =
5408 TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5409 /* Keep initialization in order to enforce 8.5 */
5410 if (stmts && !java_error_count)
5411 TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5414 /* JDK 1.1 instance initializers */
5415 if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5417 stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5418 CPC_INSTANCE_INITIALIZER_LIST (ctxp) =
5419 TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5420 if (stmts && !java_error_count)
5421 TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5425 static tree
5426 reorder_static_initialized (list)
5427 tree list;
5429 /* We have to keep things in order. The alias initializer have to
5430 come first, then the initialized regular field, in reverse to
5431 keep them in lexical order. */
5432 tree marker, previous = NULL_TREE;
5433 for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5434 if (TREE_CODE (marker) == TREE_LIST
5435 && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5436 break;
5438 /* No static initialized, the list is fine as is */
5439 if (!previous)
5440 list = TREE_CHAIN (marker);
5442 /* No marker? reverse the whole list */
5443 else if (!marker)
5444 list = nreverse (list);
5446 /* Otherwise, reverse what's after the marker and the new reordered
5447 sublist will replace the marker. */
5448 else
5450 TREE_CHAIN (previous) = NULL_TREE;
5451 list = nreverse (list);
5452 list = chainon (TREE_CHAIN (marker), list);
5454 return list;
5457 /* Helper functions to dump the parser context stack. */
5459 #define TAB_CONTEXT(C) \
5460 {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5462 static void
5463 java_debug_context_do (tab)
5464 int tab;
5466 struct parser_ctxt *copy = ctxp;
5467 while (copy)
5469 TAB_CONTEXT (tab);
5470 fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5471 TAB_CONTEXT (tab);
5472 fprintf (stderr, "filename: %s\n", copy->filename);
5473 TAB_CONTEXT (tab);
5474 fprintf (stderr, "lineno: %d\n", copy->lineno);
5475 TAB_CONTEXT (tab);
5476 fprintf (stderr, "package: %s\n",
5477 (copy->package ?
5478 IDENTIFIER_POINTER (copy->package) : "<none>"));
5479 TAB_CONTEXT (tab);
5480 fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5481 TAB_CONTEXT (tab);
5482 fprintf (stderr, "saved data: %d\n", copy->saved_data);
5483 copy = copy->next;
5484 tab += 2;
5488 /* Dump the stacked up parser contexts. Intended to be called from a
5489 debugger. */
5491 void
5492 java_debug_context ()
5494 java_debug_context_do (0);
5499 /* Flag for the error report routine to issue the error the first time
5500 it's called (overriding the default behavior which is to drop the
5501 first invocation and honor the second one, taking advantage of a
5502 richer context. */
5503 static int force_error = 0;
5505 /* Reporting an constructor invocation error. */
5506 static void
5507 parse_ctor_invocation_error ()
5509 if (DECL_CONSTRUCTOR_P (current_function_decl))
5510 yyerror ("Constructor invocation must be first thing in a constructor");
5511 else
5512 yyerror ("Only constructors can invoke constructors");
5515 /* Reporting JDK1.1 features not implemented. */
5517 static tree
5518 parse_jdk1_1_error (msg)
5519 const char *msg;
5521 sorry (": `%s' JDK1.1(TM) feature", msg);
5522 java_error_count++;
5523 return empty_stmt_node;
5526 static int do_warning = 0;
5528 void
5529 yyerror (msg)
5530 const char *msg;
5532 static java_lc elc;
5533 static int prev_lineno;
5534 static const char *prev_msg;
5536 int save_lineno;
5537 char *remainder, *code_from_source;
5538 extern struct obstack temporary_obstack;
5540 if (!force_error && prev_lineno == lineno)
5541 return;
5543 /* Save current error location but report latter, when the context is
5544 richer. */
5545 if (ctxp->java_error_flag == 0)
5547 ctxp->java_error_flag = 1;
5548 elc = ctxp->elc;
5549 /* Do something to use the previous line if we're reaching the
5550 end of the file... */
5551 #ifdef VERBOSE_SKELETON
5552 printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5553 #endif
5554 return;
5557 /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5558 if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5559 return;
5561 ctxp->java_error_flag = 0;
5562 if (do_warning)
5563 java_warning_count++;
5564 else
5565 java_error_count++;
5567 if (elc.col == 0 && msg[1] == ';')
5569 elc.col = ctxp->p_line->char_col-1;
5570 elc.line = ctxp->p_line->lineno;
5573 save_lineno = lineno;
5574 prev_lineno = lineno = elc.line;
5575 prev_msg = msg;
5577 code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5578 obstack_grow0 (&temporary_obstack,
5579 code_from_source, strlen (code_from_source));
5580 remainder = obstack_finish (&temporary_obstack);
5581 if (do_warning)
5582 warning ("%s.\n%s", msg, remainder);
5583 else
5584 error ("%s.\n%s", msg, remainder);
5586 /* This allow us to cheaply avoid an extra 'Invalid expression
5587 statement' error report when errors have been already reported on
5588 the same line. This occurs when we report an error but don't have
5589 a synchronization point other than ';', which
5590 expression_statement is the only one to take care of. */
5591 ctxp->prevent_ese = lineno = save_lineno;
5594 static void
5595 issue_warning_error_from_context (cl, msg, ap)
5596 tree cl;
5597 const char *msg;
5598 va_list ap;
5600 char *saved, *saved_input_filename;
5601 char buffer [4096];
5602 vsprintf (buffer, msg, ap);
5603 force_error = 1;
5605 ctxp->elc.line = EXPR_WFL_LINENO (cl);
5606 ctxp->elc.col = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 :
5607 (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5609 /* We have a CL, that's a good reason for using it if it contains data */
5610 saved = ctxp->filename;
5611 if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5612 ctxp->filename = EXPR_WFL_FILENAME (cl);
5613 saved_input_filename = input_filename;
5614 input_filename = ctxp->filename;
5615 java_error (NULL);
5616 java_error (buffer);
5617 ctxp->filename = saved;
5618 input_filename = saved_input_filename;
5619 force_error = 0;
5622 /* Issue an error message at a current source line CL */
5624 void
5625 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5627 #ifndef ANSI_PROTOTYPES
5628 tree cl;
5629 const char *msg;
5630 #endif
5631 va_list ap;
5633 VA_START (ap, msg);
5634 #ifndef ANSI_PROTOTYPES
5635 cl = va_arg (ap, tree);
5636 msg = va_arg (ap, const char *);
5637 #endif
5638 issue_warning_error_from_context (cl, msg, ap);
5639 va_end (ap);
5642 /* Issue a warning at a current source line CL */
5644 static void
5645 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5647 #ifndef ANSI_PROTOTYPES
5648 tree cl;
5649 const char *msg;
5650 #endif
5651 va_list ap;
5653 VA_START (ap, msg);
5654 #ifndef ANSI_PROTOTYPES
5655 cl = va_arg (ap, tree);
5656 msg = va_arg (ap, const char *);
5657 #endif
5659 force_error = do_warning = 1;
5660 issue_warning_error_from_context (cl, msg, ap);
5661 do_warning = force_error = 0;
5662 va_end (ap);
5665 static tree
5666 find_expr_with_wfl (node)
5667 tree node;
5669 while (node)
5671 char code;
5672 tree to_return;
5674 switch (TREE_CODE (node))
5676 case BLOCK:
5677 node = BLOCK_EXPR_BODY (node);
5678 continue;
5680 case COMPOUND_EXPR:
5681 to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5682 if (to_return)
5683 return to_return;
5684 node = TREE_OPERAND (node, 1);
5685 continue;
5687 case LOOP_EXPR:
5688 node = TREE_OPERAND (node, 0);
5689 continue;
5691 case LABELED_BLOCK_EXPR:
5692 node = TREE_OPERAND (node, 1);
5693 continue;
5695 default:
5696 code = TREE_CODE_CLASS (TREE_CODE (node));
5697 if (((code == '1') || (code == '2') || (code == 'e'))
5698 && EXPR_WFL_LINECOL (node))
5699 return node;
5700 return NULL_TREE;
5703 return NULL_TREE;
5706 /* Issue a missing return statement error. Uses METHOD to figure the
5707 last line of the method the error occurs in. */
5709 static void
5710 missing_return_error (method)
5711 tree method;
5713 EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5714 parse_error_context (wfl_operator, "Missing return statement");
5717 /* Issue an unreachable statement error. From NODE, find the next
5718 statement to report appropriately. */
5719 static void
5720 unreachable_stmt_error (node)
5721 tree node;
5723 /* Browse node to find the next expression node that has a WFL. Use
5724 the location to report the error */
5725 if (TREE_CODE (node) == COMPOUND_EXPR)
5726 node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5727 else
5728 node = find_expr_with_wfl (node);
5730 if (node)
5732 EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5733 parse_error_context (wfl_operator, "Unreachable statement");
5735 else
5736 fatal ("Can't get valid statement - unreachable_stmt_error");
5740 java_report_errors ()
5742 if (java_error_count)
5743 fprintf (stderr, "%d error%s",
5744 java_error_count, (java_error_count == 1 ? "" : "s"));
5745 if (java_warning_count)
5746 fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5747 java_warning_count, (java_warning_count == 1 ? "" : "s"));
5748 if (java_error_count || java_warning_count)
5749 putc ('\n', stderr);
5750 return java_error_count;
5753 static char *
5754 java_accstring_lookup (flags)
5755 int flags;
5757 static char buffer [80];
5758 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5760 /* Access modifier looked-up first for easier report on forbidden
5761 access. */
5762 if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5763 if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5764 if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5765 if (flags & ACC_STATIC) COPY_RETURN ("static");
5766 if (flags & ACC_FINAL) COPY_RETURN ("final");
5767 if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5768 if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5769 if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5770 if (flags & ACC_NATIVE) COPY_RETURN ("native");
5771 if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5772 if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5774 buffer [0] = '\0';
5775 return buffer;
5776 #undef COPY_RETURN
5779 /* Issuing error messages upon redefinition of classes, interfaces or
5780 variables. */
5782 static void
5783 classitf_redefinition_error (context, id, decl, cl)
5784 const char *context;
5785 tree id, decl, cl;
5787 parse_error_context (cl, "%s `%s' already defined in %s:%d",
5788 context, IDENTIFIER_POINTER (id),
5789 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5790 /* Here we should point out where its redefined. It's a unicode. FIXME */
5793 static void
5794 variable_redefinition_error (context, name, type, line)
5795 tree context, name, type;
5796 int line;
5798 const char *type_name;
5800 /* Figure a proper name for type. We might haven't resolved it */
5801 if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5802 type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5803 else
5804 type_name = lang_printable_name (type, 0);
5806 parse_error_context (context,
5807 "Variable `%s' is already defined in this method and was declared `%s %s' at line %d",
5808 IDENTIFIER_POINTER (name),
5809 type_name, IDENTIFIER_POINTER (name), line);
5812 static tree
5813 build_array_from_name (type, type_wfl, name, ret_name)
5814 tree type, type_wfl, name, *ret_name;
5816 int more_dims = 0;
5817 const char *string;
5819 /* Eventually get more dims */
5820 string = IDENTIFIER_POINTER (name);
5821 while (string [more_dims] == '[')
5822 more_dims++;
5824 /* If we have, then craft a new type for this variable */
5825 if (more_dims)
5827 name = get_identifier (&string [more_dims]);
5829 /* If we have a pointer, use its type */
5830 if (TREE_CODE (type) == POINTER_TYPE)
5831 type = TREE_TYPE (type);
5833 /* Building the first dimension of a primitive type uses this
5834 function */
5835 if (JPRIMITIVE_TYPE_P (type))
5837 type = build_java_array_type (type, -1);
5838 CLASS_LOADED_P (type) = 1;
5839 more_dims--;
5841 /* Otherwise, if we have a WFL for this type, use it (the type
5842 is already an array on an unresolved type, and we just keep
5843 on adding dimensions) */
5844 else if (type_wfl)
5845 type = type_wfl;
5847 /* Add all the dimensions */
5848 while (more_dims--)
5849 type = build_unresolved_array_type (type);
5851 /* The type may have been incomplete in the first place */
5852 if (type_wfl)
5853 type = obtain_incomplete_type (type);
5856 if (ret_name)
5857 *ret_name = name;
5858 return type;
5861 /* Build something that the type identifier resolver will identify as
5862 being an array to an unresolved type. TYPE_WFL is a WFL on a
5863 identifier. */
5865 static tree
5866 build_unresolved_array_type (type_or_wfl)
5867 tree type_or_wfl;
5869 const char *ptr;
5871 /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5872 just create a array type */
5873 if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5875 tree type = build_java_array_type (type_or_wfl, -1);
5876 CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5877 return type;
5880 obstack_1grow (&temporary_obstack, '[');
5881 obstack_grow0 (&temporary_obstack,
5882 IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5883 IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5884 ptr = obstack_finish (&temporary_obstack);
5885 return build_expr_wfl (get_identifier (ptr),
5886 EXPR_WFL_FILENAME (type_or_wfl),
5887 EXPR_WFL_LINENO (type_or_wfl),
5888 EXPR_WFL_COLNO (type_or_wfl));
5891 static void
5892 parser_add_interface (class_decl, interface_decl, wfl)
5893 tree class_decl, interface_decl, wfl;
5895 if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5896 parse_error_context (wfl, "Interface `%s' repeated",
5897 IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5900 /* Bulk of common class/interface checks. Return 1 if an error was
5901 encountered. TAG is 0 for a class, 1 for an interface. */
5903 static int
5904 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5905 int is_interface, flags;
5906 tree raw_name, qualified_name, decl, cl;
5908 tree node;
5909 int sca = 0; /* Static class allowed */
5910 int icaf = 0; /* Inner class allowed flags */
5911 int uaaf = CLASS_MODIFIERS; /* Usually allowed access flags */
5913 if (!quiet_flag)
5914 fprintf (stderr, " %s%s %s",
5915 (CPC_INNER_P () ? "inner" : ""),
5916 (is_interface ? "interface" : "class"),
5917 IDENTIFIER_POINTER (qualified_name));
5919 /* Scope of an interface/class type name:
5920 - Can't be imported by a single type import
5921 - Can't already exists in the package */
5922 if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5923 && (node = find_name_in_single_imports (raw_name)))
5925 parse_error_context
5926 (cl, "%s name `%s' clashes with imported type `%s'",
5927 (is_interface ? "Interface" : "Class"),
5928 IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5929 return 1;
5931 if (decl && CLASS_COMPLETE_P (decl))
5933 classitf_redefinition_error ((is_interface ? "Interface" : "Class"),
5934 qualified_name, decl, cl);
5935 return 1;
5938 if (check_inner_class_redefinition (raw_name, cl))
5939 return 1;
5941 /* If public, file name should match class/interface name, except
5942 when dealing with an inner class */
5943 if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
5945 const char *f;
5947 /* Contains OS dependent assumption on path separator. FIXME */
5948 for (f = &input_filename [strlen (input_filename)];
5949 f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
5950 f--)
5952 if (f[0] == '/' || f[0] == DIR_SEPARATOR)
5953 f++;
5954 if (strncmp (IDENTIFIER_POINTER (raw_name),
5955 f , IDENTIFIER_LENGTH (raw_name)) ||
5956 f [IDENTIFIER_LENGTH (raw_name)] != '.')
5957 parse_error_context
5958 (cl, "Public %s `%s' must be defined in a file called `%s.java'",
5959 (is_interface ? "interface" : "class"),
5960 IDENTIFIER_POINTER (qualified_name),
5961 IDENTIFIER_POINTER (raw_name));
5964 /* Static classes can be declared only in top level classes. Note:
5965 once static, a inner class is a top level class. */
5966 if (flags & ACC_STATIC)
5968 /* Catch the specific error of declaring an class inner class
5969 with no toplevel enclosing class. Prevent check_modifiers from
5970 complaining a second time */
5971 if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
5973 parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes",
5974 IDENTIFIER_POINTER (qualified_name));
5975 sca = ACC_STATIC;
5977 /* Else, in the context of a top-level class declaration, let
5978 `check_modifiers' do its job, otherwise, give it a go */
5979 else
5980 sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
5983 /* Inner classes and interfaces can be declared private or protected
5984 within their enclosing classes. */
5985 if (CPC_INNER_P ())
5987 /* A class which is local to a block can't be public, private,
5988 protected or static. But it is created final, so allow this
5989 one. */
5990 if (current_function_decl)
5991 icaf = sca = uaaf = ACC_FINAL;
5992 else
5994 check_modifiers_consistency (flags);
5995 icaf = ACC_PRIVATE|ACC_PROTECTED;
5999 if (is_interface)
6000 check_modifiers ("Illegal modifier `%s' for interface declaration",
6001 flags, INTERFACE_MODIFIERS);
6002 else
6003 check_modifiers ("Illegal modifier `%s' for class declaration",
6004 flags, uaaf|sca|icaf);
6005 return 0;
6008 static void
6009 make_nested_class_name (cpc_list)
6010 tree cpc_list;
6012 tree name;
6014 if (!cpc_list)
6015 return;
6016 else
6017 make_nested_class_name (TREE_CHAIN (cpc_list));
6019 /* Pick the qualified name when dealing with the first upmost
6020 enclosing class */
6021 name = (TREE_CHAIN (cpc_list) ?
6022 TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6023 obstack_grow (&temporary_obstack,
6024 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6025 /* Why is NO_DOLLAR_IN_LABEL defined? */
6026 #if 0
6027 #ifdef NO_DOLLAR_IN_LABEL
6028 fatal ("make_nested_class_name: Can't use '$' as a separator "
6029 "for inner classes");
6030 #endif
6031 #endif
6032 obstack_1grow (&temporary_obstack, '$');
6035 /* Can't redefine a class already defined in an earlier scope. */
6037 static int
6038 check_inner_class_redefinition (raw_name, cl)
6039 tree raw_name, cl;
6041 tree scope_list;
6043 for (scope_list = GET_CPC_LIST (); scope_list;
6044 scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6045 if (raw_name == GET_CPC_UN_NODE (scope_list))
6047 parse_error_context
6048 (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",
6049 IDENTIFIER_POINTER (raw_name));
6050 return 1;
6052 return 0;
6055 static tree
6056 find_as_inner_class (enclosing, name, cl)
6057 tree enclosing, name, cl;
6059 tree qual, to_return;
6060 if (!enclosing)
6061 return NULL_TREE;
6063 name = TYPE_NAME (name);
6065 /* First search: within the scope of `enclosing', search for name */
6066 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6067 qual = EXPR_WFL_QUALIFICATION (cl);
6068 else if (cl)
6069 qual = build_tree_list (cl, NULL_TREE);
6070 else
6071 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6073 if ((to_return = find_as_inner_class_do (qual, enclosing)))
6074 return to_return;
6076 /* We're dealing with a qualified name. Try to resolve thing until
6077 we get something that is an enclosing class. */
6078 if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6080 tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6082 for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl;
6083 qual = TREE_CHAIN (qual))
6085 acc = merge_qualified_name (acc,
6086 EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6087 BUILD_PTR_FROM_NAME (ptr, acc);
6088 decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6091 /* A NULL qual and a decl means that the search ended
6092 successfully?!? We have to do something then. FIXME */
6094 if (decl)
6095 enclosing = decl;
6096 else
6097 qual = EXPR_WFL_QUALIFICATION (cl);
6099 /* Otherwise, create a qual for the other part of the resolution. */
6100 else
6101 qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6103 return find_as_inner_class_do (qual, enclosing);
6106 /* We go inside the list of sub classes and try to find a way
6107 through. */
6109 static tree
6110 find_as_inner_class_do (qual, enclosing)
6111 tree qual, enclosing;
6113 if (!qual)
6114 return NULL_TREE;
6116 for (; qual && enclosing; qual = TREE_CHAIN (qual))
6118 tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6119 tree next_enclosing = NULL_TREE;
6120 tree inner_list;
6122 for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6123 inner_list; inner_list = TREE_CHAIN (inner_list))
6125 if (TREE_VALUE (inner_list) == name_to_match)
6127 next_enclosing = TREE_PURPOSE (inner_list);
6128 break;
6131 enclosing = next_enclosing;
6134 return (!qual && enclosing ? enclosing : NULL_TREE);
6137 /* Reach all inner classes and tie their unqualified name to a
6138 DECL. */
6140 static void
6141 set_nested_class_simple_name_value (outer, set)
6142 tree outer;
6143 int set;
6145 tree l;
6147 for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6148 IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ?
6149 TREE_PURPOSE (l) : NULL_TREE);
6152 static void
6153 link_nested_class_to_enclosing ()
6155 if (GET_ENCLOSING_CPC ())
6157 tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6158 DECL_INNER_CLASS_LIST (enclosing) =
6159 tree_cons (GET_CPC (), GET_CPC_UN (),
6160 DECL_INNER_CLASS_LIST (enclosing));
6161 enclosing = enclosing;
6165 static tree
6166 maybe_make_nested_class_name (name)
6167 tree name;
6169 tree id = NULL_TREE;
6171 if (CPC_INNER_P ())
6173 make_nested_class_name (GET_CPC_LIST ());
6174 obstack_grow (&temporary_obstack,
6175 IDENTIFIER_POINTER (name),
6176 IDENTIFIER_LENGTH (name));
6177 id = get_identifier (obstack_finish (&temporary_obstack));
6178 if (ctxp->package)
6179 QUALIFIED_P (id) = 1;
6181 return id;
6184 /* If DECL is NULL, create and push a new DECL, record the current
6185 line CL and do other maintenance things. */
6187 static tree
6188 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6189 tree decl, raw_name, qualified_name, cl;
6191 if (!decl)
6192 decl = push_class (make_class (), qualified_name);
6194 /* Take care of the file and line business */
6195 DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6196 /* If we're emiting xrefs, store the line/col number information */
6197 if (flag_emit_xref)
6198 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6199 else
6200 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6201 CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6202 CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6203 IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6205 PUSH_CPC (decl, raw_name);
6206 DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6208 /* Link the declaration to the already seen ones */
6209 TREE_CHAIN (decl) = ctxp->class_list;
6210 ctxp->class_list = decl;
6212 /* Create a new nodes in the global lists */
6213 ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6214 all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6216 /* Install a new dependency list element */
6217 create_jdep_list (ctxp);
6219 SOURCE_FRONTEND_DEBUG (("Defining class/interface %s",
6220 IDENTIFIER_POINTER (qualified_name)));
6221 return decl;
6224 static void
6225 add_superinterfaces (decl, interface_list)
6226 tree decl, interface_list;
6228 tree node;
6229 /* Superinterface(s): if present and defined, parser_check_super_interface ()
6230 takes care of ensuring that:
6231 - This is an accessible interface type,
6232 - Circularity detection.
6233 parser_add_interface is then called. If present but not defined,
6234 the check operation is delayed until the super interface gets
6235 defined. */
6236 for (node = interface_list; node; node = TREE_CHAIN (node))
6238 tree current = TREE_PURPOSE (node);
6239 tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6240 if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6242 if (!parser_check_super_interface (idecl, decl, current))
6243 parser_add_interface (decl, idecl, current);
6245 else
6246 register_incomplete_type (JDEP_INTERFACE,
6247 current, decl, NULL_TREE);
6251 /* Create an interface in pass1 and return its decl. Return the
6252 interface's decl in pass 2. */
6254 static tree
6255 create_interface (flags, id, super)
6256 int flags;
6257 tree id, super;
6259 tree raw_name = EXPR_WFL_NODE (id);
6260 tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6261 tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6263 EXPR_WFL_NODE (id) = q_name; /* Keep source location, even if refined. */
6265 /* Basic checks: scope, redefinition, modifiers */
6266 if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6268 PUSH_ERROR ();
6269 return NULL_TREE;
6272 /* Suspend the current parsing context if we're parsing an inner
6273 interface */
6274 if (CPC_INNER_P ())
6275 java_parser_context_suspend ();
6277 /* Push a new context for (static) initialized upon declaration fields */
6278 java_parser_context_push_initialized_field ();
6280 /* Interface modifiers check
6281 - public/abstract allowed (already done at that point)
6282 - abstract is obsolete (comes first, it's a warning, or should be)
6283 - Can't use twice the same (checked in the modifier rule) */
6284 if ((flags & ACC_ABSTRACT) && flag_redundant)
6285 parse_warning_context
6286 (MODIFIER_WFL (ABSTRACT_TK),
6287 "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6289 /* Create a new decl if DECL is NULL, otherwise fix it */
6290 decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6292 /* Set super info and mark the class a complete */
6293 set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl),
6294 object_type_node, ctxp->interface_number);
6295 ctxp->interface_number = 0;
6296 CLASS_COMPLETE_P (decl) = 1;
6297 add_superinterfaces (decl, super);
6299 return decl;
6302 /* Anonymous class counter. Will be reset to 1 every time a non
6303 anonymous class gets created. */
6304 static int anonymous_class_counter = 1;
6306 /* Patch anonymous class CLASS, by either extending or implementing
6307 DEP. */
6309 static void
6310 patch_anonymous_class (type_decl, class_decl, wfl)
6311 tree type_decl, class_decl, wfl;
6313 tree class = TREE_TYPE (class_decl);
6314 tree type = TREE_TYPE (type_decl);
6315 tree binfo = TYPE_BINFO (class);
6317 /* If it's an interface, implement it */
6318 if (CLASS_INTERFACE (type_decl))
6320 tree s_binfo;
6321 int length;
6323 if (parser_check_super_interface (type_decl, class_decl, wfl))
6324 return;
6326 s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6327 length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6328 TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6329 TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6330 /* And add the interface */
6331 parser_add_interface (class_decl, type_decl, wfl);
6333 /* Otherwise, it's a type we want to extend */
6334 else
6336 if (parser_check_super (type_decl, class_decl, wfl))
6337 return;
6338 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6342 static tree
6343 create_anonymous_class (location, type_name)
6344 int location;
6345 tree type_name;
6347 char buffer [80];
6348 tree super = NULL_TREE, itf = NULL_TREE;
6349 tree id, type_decl, class;
6351 /* The unqualified name of the anonymous class. It's just a number. */
6352 sprintf (buffer, "%d", anonymous_class_counter++);
6353 id = build_wfl_node (get_identifier (buffer));
6354 EXPR_WFL_LINECOL (id) = location;
6356 /* We know about the type to extend/implement. We go ahead */
6357 if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6359 /* Create a class which either implements on extends the designated
6360 class. The class bears an innacessible name. */
6361 if (CLASS_INTERFACE (type_decl))
6363 /* It's OK to modify it here. It's been already used and
6364 shouldn't be reused */
6365 ctxp->interface_number = 1;
6366 /* Interfaces should presented as a list of WFLs */
6367 itf = build_tree_list (type_name, NULL_TREE);
6369 else
6370 super = type_name;
6373 class = create_class (ACC_FINAL, id, super, itf);
6375 /* We didn't know anything about the stuff. We register a dependence. */
6376 if (!type_decl)
6377 register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6379 ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6380 return class;
6383 /* Create an class in pass1 and return its decl. Return class
6384 interface's decl in pass 2. */
6386 static tree
6387 create_class (flags, id, super, interfaces)
6388 int flags;
6389 tree id, super, interfaces;
6391 tree raw_name = EXPR_WFL_NODE (id);
6392 tree class_id, decl;
6393 tree super_decl_type;
6395 class_id = parser_qualified_classname (0, raw_name);
6396 decl = IDENTIFIER_CLASS_VALUE (class_id);
6397 EXPR_WFL_NODE (id) = class_id;
6399 /* Basic check: scope, redefinition, modifiers */
6400 if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6402 PUSH_ERROR ();
6403 return NULL_TREE;
6406 /* Suspend the current parsing context if we're parsing an inner
6407 class or an anonymous class. */
6408 if (CPC_INNER_P ())
6409 java_parser_context_suspend ();
6410 /* Push a new context for (static) initialized upon declaration fields */
6411 java_parser_context_push_initialized_field ();
6413 /* Class modifier check:
6414 - Allowed modifier (already done at that point)
6415 - abstract AND final forbidden
6416 - Public classes defined in the correct file */
6417 if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6418 parse_error_context
6419 (id, "Class `%s' can't be declared both abstract and final",
6420 IDENTIFIER_POINTER (raw_name));
6422 /* Create a new decl if DECL is NULL, otherwise fix it */
6423 decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6425 /* If SUPER exists, use it, otherwise use Object */
6426 if (super)
6428 /* Can't extend java.lang.Object */
6429 if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6431 parse_error_context (id, "Can't extend `java.lang.Object'");
6432 return NULL_TREE;
6435 super_decl_type =
6436 register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6438 else if (TREE_TYPE (decl) != object_type_node)
6439 super_decl_type = object_type_node;
6440 /* We're defining java.lang.Object */
6441 else
6442 super_decl_type = NULL_TREE;
6444 /* Set super info and mark the class a complete */
6445 set_super_info (flags, TREE_TYPE (decl), super_decl_type,
6446 ctxp->interface_number);
6447 ctxp->interface_number = 0;
6448 CLASS_COMPLETE_P (decl) = 1;
6449 add_superinterfaces (decl, interfaces);
6451 /* If the class is a top level inner class, install an alias. */
6452 if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6454 tree alias = parser_qualified_classname (1, raw_name);
6455 IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6458 /* Add the private this$<n> field, Replicate final locals still in
6459 scope as private final fields mangled like val$<local_name>.
6460 This doesn't not occur for top level (static) inner classes. */
6461 if (PURE_INNER_CLASS_DECL_P (decl))
6462 add_inner_class_fields (decl, current_function_decl);
6464 /* If doing xref, store the location at which the inherited class
6465 (if any) was seen. */
6466 if (flag_emit_xref && super)
6467 DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6469 /* Eventually sets the @deprecated tag flag */
6470 CHECK_DEPRECATED (decl);
6472 /* Reset the anonymous class counter when declaring non inner classes */
6473 if (!INNER_CLASS_DECL_P (decl))
6474 anonymous_class_counter = 1;
6476 return decl;
6479 /* End a class declaration: register the statements used to create
6480 $finit$ and <clinit>, pop the current class and resume the prior
6481 parser context if necessary. */
6483 static void
6484 end_class_declaration (resume)
6485 int resume;
6487 /* If an error occured, context weren't pushed and won't need to be
6488 popped by a resume. */
6489 int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6491 java_parser_context_pop_initialized_field ();
6492 POP_CPC ();
6493 if (resume && no_error_occured)
6494 java_parser_context_resume ();
6497 static void
6498 add_inner_class_fields (class_decl, fct_decl)
6499 tree class_decl;
6500 tree fct_decl;
6502 tree block, marker, f;
6504 f = add_field (TREE_TYPE (class_decl),
6505 build_current_thisn (TREE_TYPE (class_decl)),
6506 build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))),
6507 ACC_PRIVATE);
6508 FIELD_THISN (f) = 1;
6510 if (!fct_decl)
6511 return;
6513 for (block = GET_CURRENT_BLOCK (fct_decl);
6514 block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6516 tree decl;
6517 for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6519 char *name, *pname;
6520 tree wfl, init, list;
6522 /* Avoid non final arguments. */
6523 if (!LOCAL_FINAL (decl))
6524 continue;
6526 MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6527 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6528 wfl = build_wfl_node (get_identifier (name));
6529 init = build_wfl_node (get_identifier (pname));
6530 /* Build an initialization for the field: it will be
6531 initialized by a parameter added to $finit$, bearing a
6532 mangled name of the field itself (param$<n>.) The
6533 parameter is provided to $finit$ by the constructor
6534 invoking it (hence the constructor will also feature a
6535 hidden parameter, set to the value of the outer context
6536 local at the time the inner class is created.)
6538 Note: we take into account all possible locals that can
6539 be accessed by the inner class. It's actually not trivial
6540 to minimize these aliases down to the ones really
6541 used. One way to do that would be to expand all regular
6542 methods first, then $finit$ to get a picture of what's
6543 used. It works with the exception that we would have to
6544 go back on all constructor invoked in regular methods to
6545 have their invokation reworked (to include the right amount
6546 of alias initializer parameters.)
6548 The only real way around, I think, is a first pass to
6549 identify locals really used in the inner class. We leave
6550 the flag FIELD_LOCAL_ALIAS_USED around for that future
6551 use.
6553 On the other hand, it only affect local inner classes,
6554 whose constructors (and $finit$ call) will be featuring
6555 unecessary arguments. It's easy for a developper to keep
6556 this number of parameter down by using the `final'
6557 keyword only when necessary. For the time being, we can
6558 issue a warning on unecessary finals. FIXME */
6559 init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl),
6560 wfl, init);
6562 /* Register the field. The TREE_LIST holding the part
6563 initialized/initializer will be marked ARG_FINAL_P so
6564 that the created field can be marked
6565 FIELD_LOCAL_ALIAS. */
6566 list = build_tree_list (wfl, init);
6567 ARG_FINAL_P (list) = 1;
6568 register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6572 if (!CPC_INITIALIZER_STMT (ctxp))
6573 return;
6575 /* If we ever registered an alias field, insert and marker to
6576 remeber where the list ends. The second part of the list (the one
6577 featuring initialized fields) so it can be later reversed to
6578 enforce 8.5. The marker will be removed during that operation. */
6579 marker = build_tree_list (NULL_TREE, NULL_TREE);
6580 TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6581 SET_CPC_INITIALIZER_STMT (ctxp, marker);
6584 /* Can't use lookup_field () since we don't want to load the class and
6585 can't set the CLASS_LOADED_P flag */
6587 static tree
6588 find_field (class, name)
6589 tree class;
6590 tree name;
6592 tree decl;
6593 for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6595 if (DECL_NAME (decl) == name)
6596 return decl;
6598 return NULL_TREE;
6601 /* Wrap around lookup_field that doesn't potentially upset the value
6602 of CLASS */
6604 static tree
6605 lookup_field_wrapper (class, name)
6606 tree class, name;
6608 tree type = class;
6609 tree decl;
6610 java_parser_context_save_global ();
6611 decl = lookup_field (&type, name);
6612 java_parser_context_restore_global ();
6613 return decl == error_mark_node ? NULL : decl;
6616 /* Find duplicate field within the same class declarations and report
6617 the error. Returns 1 if a duplicated field was found, 0
6618 otherwise. */
6620 static int
6621 duplicate_declaration_error_p (new_field_name, new_type, cl)
6622 tree new_field_name, new_type, cl;
6624 /* This might be modified to work with method decl as well */
6625 tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6626 if (decl)
6628 char *t1 = xstrdup (purify_type_name
6629 ((TREE_CODE (new_type) == POINTER_TYPE
6630 && TREE_TYPE (new_type) == NULL_TREE) ?
6631 IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6632 lang_printable_name (new_type, 1)));
6633 /* The type may not have been completed by the time we report
6634 the error */
6635 char *t2 = xstrdup (purify_type_name
6636 ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE
6637 && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6638 IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6639 lang_printable_name (TREE_TYPE (decl), 1)));
6640 parse_error_context
6641 (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)",
6642 t1, IDENTIFIER_POINTER (new_field_name),
6643 t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6644 DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6645 free (t1);
6646 free (t2);
6647 return 1;
6649 return 0;
6652 /* Field registration routine. If TYPE doesn't exist, field
6653 declarations are linked to the undefined TYPE dependency list, to
6654 be later resolved in java_complete_class () */
6656 static void
6657 register_fields (flags, type, variable_list)
6658 int flags;
6659 tree type, variable_list;
6661 tree current, saved_type;
6662 tree class_type = NULL_TREE;
6663 int saved_lineno = lineno;
6664 int must_chain = 0;
6665 tree wfl = NULL_TREE;
6667 if (GET_CPC ())
6668 class_type = TREE_TYPE (GET_CPC ());
6670 if (!class_type || class_type == error_mark_node)
6671 return;
6673 /* If we're adding fields to interfaces, those fields are public,
6674 static, final */
6675 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6677 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6678 flags, ACC_PUBLIC, "interface field(s)");
6679 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6680 flags, ACC_STATIC, "interface field(s)");
6681 OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6682 flags, ACC_FINAL, "interface field(s)");
6683 check_modifiers ("Illegal interface member modifier `%s'", flags,
6684 INTERFACE_FIELD_MODIFIERS);
6685 flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6688 /* Obtain a suitable type for resolution, if necessary */
6689 SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6691 /* If TYPE is fully resolved and we don't have a reference, make one */
6692 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6694 for (current = variable_list, saved_type = type; current;
6695 current = TREE_CHAIN (current), type = saved_type)
6697 tree real_type;
6698 tree field_decl;
6699 tree cl = TREE_PURPOSE (current);
6700 tree init = TREE_VALUE (current);
6701 tree current_name = EXPR_WFL_NODE (cl);
6703 /* Can't declare static fields in inner classes */
6704 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6705 && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6706 parse_error_context
6707 (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6708 IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6709 lang_printable_name (class_type, 0));
6711 /* Process NAME, as it may specify extra dimension(s) for it */
6712 type = build_array_from_name (type, wfl, current_name, &current_name);
6714 /* Type adjustment. We may have just readjusted TYPE because
6715 the variable specified more dimensions. Make sure we have
6716 a reference if we can and don't have one already. Also
6717 change the name if we have an init. */
6718 if (type != saved_type)
6720 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6721 if (init)
6722 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6725 real_type = GET_REAL_TYPE (type);
6726 /* Check for redeclarations */
6727 if (duplicate_declaration_error_p (current_name, real_type, cl))
6728 continue;
6730 /* Set lineno to the line the field was found and create a
6731 declaration for it. Eventually sets the @deprecated tag flag. */
6732 if (flag_emit_xref)
6733 lineno = EXPR_WFL_LINECOL (cl);
6734 else
6735 lineno = EXPR_WFL_LINENO (cl);
6736 field_decl = add_field (class_type, current_name, real_type, flags);
6737 CHECK_DEPRECATED (field_decl);
6739 /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6740 mark the created field FIELD_LOCAL_ALIAS, so that we can
6741 hide parameters to this inner class $finit$ and constructors. */
6742 if (ARG_FINAL_P (current))
6743 FIELD_LOCAL_ALIAS (field_decl) = 1;
6745 /* Check if we must chain. */
6746 if (must_chain)
6747 register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6749 /* If we have an initialization value tied to the field */
6750 if (init)
6752 /* The field is declared static */
6753 if (flags & ACC_STATIC)
6755 /* We include the field and its initialization part into
6756 a list used to generate <clinit>. After <clinit> is
6757 walked, field initializations will be processed and
6758 fields initialized with known constants will be taken
6759 out of <clinit> and have their DECL_INITIAL set
6760 appropriately. */
6761 TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6762 SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6763 if (TREE_OPERAND (init, 1)
6764 && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6765 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6767 /* A non-static field declared with an immediate initialization is
6768 to be initialized in <init>, if any. This field is remembered
6769 to be processed at the time of the generation of <init>. */
6770 else
6772 TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6773 SET_CPC_INITIALIZER_STMT (ctxp, init);
6775 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6776 DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6779 lineno = saved_lineno;
6782 /* Generate $finit$, using the list of initialized fields to populate
6783 its body. $finit$'s parameter(s) list is adjusted to include the
6784 one(s) used to initialized the field(s) caching outer context
6785 local(s). */
6787 static tree
6788 generate_finit (class_type)
6789 tree class_type;
6791 int count = 0;
6792 tree list = TYPE_FINIT_STMT_LIST (class_type);
6793 tree mdecl, current, parms;
6795 parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
6796 class_type, NULL_TREE,
6797 &count);
6798 CRAFTED_PARAM_LIST_FIXUP (parms);
6799 mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6800 finit_identifier_node, parms);
6801 fix_method_argument_names (parms, mdecl);
6802 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6803 mdecl, NULL_TREE);
6804 DECL_FUNCTION_NAP (mdecl) = count;
6805 start_artificial_method_body (mdecl);
6807 for (current = list; current; current = TREE_CHAIN (current))
6808 java_method_add_stmt (mdecl,
6809 build_debugable_stmt (EXPR_WFL_LINECOL (current),
6810 current));
6811 end_artificial_method_body (mdecl);
6812 return mdecl;
6815 static void
6816 add_instance_initializer (mdecl)
6817 tree mdecl;
6819 tree current;
6820 tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6821 tree compound = NULL_TREE;
6823 if (stmt_list)
6825 for (current = stmt_list; current; current = TREE_CHAIN (current))
6826 compound = add_stmt_to_compound (compound, NULL_TREE, current);
6828 java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6829 NULL_TREE, compound));
6833 /* Shared accros method_declarator and method_header to remember the
6834 patch stage that was reached during the declaration of the method.
6835 A method DECL is built differently is there is no patch
6836 (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6837 pending on the currently defined method. */
6839 static int patch_stage;
6841 /* Check the method declaration and add the method to its current
6842 class. If the argument list is known to contain incomplete types,
6843 the method is partially added and the registration will be resume
6844 once the method arguments resolved. If TYPE is NULL, we're dealing
6845 with a constructor. */
6847 static tree
6848 method_header (flags, type, mdecl, throws)
6849 int flags;
6850 tree type, mdecl, throws;
6852 tree meth = TREE_VALUE (mdecl);
6853 tree id = TREE_PURPOSE (mdecl);
6854 tree type_wfl = NULL_TREE;
6855 tree meth_name = NULL_TREE;
6856 tree current, orig_arg, this_class = NULL;
6857 int saved_lineno;
6858 int constructor_ok = 0, must_chain;
6859 int count;
6861 check_modifiers_consistency (flags);
6863 if (GET_CPC ())
6864 this_class = TREE_TYPE (GET_CPC ());
6866 if (!this_class || this_class == error_mark_node)
6867 return NULL_TREE;
6869 /* There are some forbidden modifiers for an abstract method and its
6870 class must be abstract as well. */
6871 if (type && (flags & ACC_ABSTRACT))
6873 ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6874 ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6875 ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6876 ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6877 ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6878 if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6879 && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6880 parse_error_context
6881 (id, "Class `%s' must be declared abstract to define abstract method `%s'",
6882 IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6883 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6886 /* Things to be checked when declaring a constructor */
6887 if (!type)
6889 int ec = java_error_count;
6890 /* 8.6: Constructor declarations: we might be trying to define a
6891 method without specifying a return type. */
6892 if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6893 parse_error_context
6894 (id, "Invalid method declaration, return type required");
6895 /* 8.6.3: Constructor modifiers */
6896 else
6898 JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6899 JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
6900 JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
6901 JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
6902 JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
6904 /* If we found error here, we don't consider it's OK to tread
6905 the method definition as a constructor, for the rest of this
6906 function */
6907 if (ec == java_error_count)
6908 constructor_ok = 1;
6911 /* Method declared within the scope of an interface are implicitly
6912 abstract and public. Conflicts with other erroneously provided
6913 modifiers are checked right after. */
6915 if (CLASS_INTERFACE (TYPE_NAME (this_class)))
6917 /* If FLAGS isn't set because of a modifier, turn the
6918 corresponding modifier WFL to NULL so we issue a warning on
6919 the obsolete use of the modifier */
6920 if (!(flags & ACC_PUBLIC))
6921 MODIFIER_WFL (PUBLIC_TK) = NULL;
6922 if (!(flags & ACC_ABSTRACT))
6923 MODIFIER_WFL (ABSTRACT_TK) = NULL;
6924 flags |= ACC_PUBLIC;
6925 flags |= ACC_ABSTRACT;
6928 /* Inner class can't declare static methods */
6929 if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
6931 parse_error_context
6932 (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
6933 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
6934 lang_printable_name (this_class, 0));
6937 /* Modifiers context reset moved up, so abstract method declaration
6938 modifiers can be later checked. */
6940 /* Set constructor returned type to void and method name to <init>,
6941 unless we found an error identifier the constructor (in which
6942 case we retain the original name) */
6943 if (!type)
6945 type = void_type_node;
6946 if (constructor_ok)
6947 meth_name = init_identifier_node;
6949 else
6950 meth_name = EXPR_WFL_NODE (id);
6952 /* Do the returned type resolution and registration if necessary */
6953 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
6955 if (meth_name)
6956 type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
6957 EXPR_WFL_NODE (id) = meth_name;
6958 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6960 if (must_chain)
6962 patch_stage = JDEP_METHOD_RETURN;
6963 register_incomplete_type (patch_stage, type_wfl, id, type);
6964 TREE_TYPE (meth) = GET_REAL_TYPE (type);
6966 else
6967 TREE_TYPE (meth) = type;
6969 saved_lineno = lineno;
6970 /* When defining an abstract or interface method, the curly
6971 bracket at level 1 doesn't exist because there is no function
6972 body */
6973 lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 :
6974 EXPR_WFL_LINENO (id));
6976 /* Remember the original argument list */
6977 orig_arg = TYPE_ARG_TYPES (meth);
6979 if (patch_stage) /* includes ret type and/or all args */
6981 jdep *jdep;
6982 meth = add_method_1 (this_class, flags, meth_name, meth);
6983 /* Patch for the return type */
6984 if (patch_stage == JDEP_METHOD_RETURN)
6986 jdep = CLASSD_LAST (ctxp->classd_list);
6987 JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
6989 /* This is the stop JDEP. METH allows the function's signature
6990 to be computed. */
6991 register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
6993 else
6994 meth = add_method (this_class, flags, meth_name,
6995 build_java_signature (meth));
6997 /* Remember final parameters */
6998 MARK_FINAL_PARMS (meth, orig_arg);
7000 /* Fix the method argument list so we have the argument name
7001 information */
7002 fix_method_argument_names (orig_arg, meth);
7004 /* Register the parameter number and re-install the current line
7005 number */
7006 DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7007 lineno = saved_lineno;
7009 /* Register exception specified by the `throws' keyword for
7010 resolution and set the method decl appropriate field to the list.
7011 Note: the grammar ensures that what we get here are class
7012 types. */
7013 if (throws)
7015 throws = nreverse (throws);
7016 for (current = throws; current; current = TREE_CHAIN (current))
7018 register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7019 NULL_TREE, NULL_TREE);
7020 JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) =
7021 &TREE_VALUE (current);
7023 DECL_FUNCTION_THROWS (meth) = throws;
7026 /* We set the DECL_NAME to ID so we can track the location where
7027 the function was declared. This allow us to report
7028 redefinition error accurately. When method are verified,
7029 DECL_NAME is reinstalled properly (using the content of the
7030 WFL node ID) (see check_method_redefinition). We don't do that
7031 when Object is being defined. Constructor <init> names will be
7032 reinstalled the same way. */
7033 if (TREE_TYPE (GET_CPC ()) != object_type_node)
7034 DECL_NAME (meth) = id;
7036 /* Set the flag if we correctly processed a constructor */
7037 if (constructor_ok)
7039 DECL_CONSTRUCTOR_P (meth) = 1;
7040 /* Compute and store the number of artificial parameters declared
7041 for this constructor */
7042 for (count = 0, current = TYPE_FIELDS (this_class); current;
7043 current = TREE_CHAIN (current))
7044 if (FIELD_LOCAL_ALIAS (current))
7045 count++;
7046 DECL_FUNCTION_NAP (meth) = count;
7049 /* Eventually set the @deprecated tag flag */
7050 CHECK_DEPRECATED (meth);
7052 /* If doing xref, store column and line number information instead
7053 of the line number only. */
7054 if (flag_emit_xref)
7055 DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7057 return meth;
7060 static void
7061 fix_method_argument_names (orig_arg, meth)
7062 tree orig_arg, meth;
7064 tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7065 if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7067 TREE_PURPOSE (arg) = this_identifier_node;
7068 arg = TREE_CHAIN (arg);
7070 while (orig_arg != end_params_node)
7072 TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7073 orig_arg = TREE_CHAIN (orig_arg);
7074 arg = TREE_CHAIN (arg);
7078 /* Complete the method declaration with METHOD_BODY. */
7080 static void
7081 finish_method_declaration (method_body)
7082 tree method_body;
7084 int flags;
7086 if (!current_function_decl)
7087 return;
7089 flags = get_access_flags_from_decl (current_function_decl);
7091 /* 8.4.5 Method Body */
7092 if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7094 tree wfl = DECL_NAME (current_function_decl);
7095 parse_error_context (wfl,
7096 "%s method `%s' can't have a body defined",
7097 (METHOD_NATIVE (current_function_decl) ?
7098 "Native" : "Abstract"),
7099 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7100 method_body = NULL_TREE;
7102 else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7104 tree wfl = DECL_NAME (current_function_decl);
7105 parse_error_context
7106 (wfl,
7107 "Non native and non abstract method `%s' must have a body defined",
7108 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7109 method_body = NULL_TREE;
7112 if (flag_emit_class_files && method_body
7113 && TREE_CODE (method_body) == NOP_EXPR
7114 && TREE_TYPE (current_function_decl)
7115 && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7116 method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7118 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7119 maybe_absorb_scoping_blocks ();
7120 /* Exit function's body */
7121 exit_block ();
7122 /* Merge last line of the function with first line, directly in the
7123 function decl. It will be used to emit correct debug info. */
7124 if (!flag_emit_xref)
7125 DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7127 /* Since function's argument's list are shared, reset the
7128 ARG_FINAL_P parameter that might have been set on some of this
7129 function parameters. */
7130 UNMARK_FINAL_PARMS (current_function_decl);
7132 /* So we don't have an irrelevant function declaration context for
7133 the next static block we'll see. */
7134 current_function_decl = NULL_TREE;
7137 /* Build a an error message for constructor circularity errors. */
7139 static char *
7140 constructor_circularity_msg (from, to)
7141 tree from, to;
7143 static char string [4096];
7144 char *t = xstrdup (lang_printable_name (from, 0));
7145 sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7146 free (t);
7147 return string;
7150 /* Verify a circular call to METH. Return 1 if an error is found, 0
7151 otherwise. */
7153 static int
7154 verify_constructor_circularity (meth, current)
7155 tree meth, current;
7157 static tree list = NULL_TREE;
7158 tree c;
7159 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7161 if (TREE_VALUE (c) == meth)
7163 char *t;
7164 if (list)
7166 tree liste;
7167 list = nreverse (list);
7168 for (liste = list; liste; liste = TREE_CHAIN (liste))
7170 parse_error_context
7171 (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7172 constructor_circularity_msg
7173 (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste))));
7174 java_error_count--;
7177 t = xstrdup (lang_printable_name (meth, 0));
7178 parse_error_context (TREE_PURPOSE (c),
7179 "%s: recursive invocation of constructor `%s'",
7180 constructor_circularity_msg (current, meth), t);
7181 free (t);
7182 list = NULL_TREE;
7183 return 1;
7186 for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7188 list = tree_cons (c, current, list);
7189 if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7190 return 1;
7191 list = TREE_CHAIN (list);
7193 return 0;
7196 /* Check modifiers that can be declared but exclusively */
7198 static void
7199 check_modifiers_consistency (flags)
7200 int flags;
7202 int acc_count = 0;
7203 tree cl = NULL_TREE;
7205 THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7206 THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7207 THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7208 if (acc_count > 1)
7209 parse_error_context
7210 (cl, "Inconsistent member declaration. At most one of `public', `private', or `protected' may be specified");
7212 acc_count = 0;
7213 cl = NULL_TREE;
7214 THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7215 acc_count, cl);
7216 THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7217 acc_count, cl);
7218 if (acc_count > 1)
7219 parse_error_context (cl,
7220 "Inconsistent member declaration. At most one of `final' or `volatile' may be specified");
7223 /* Check the methode header METH for abstract specifics features */
7225 static void
7226 check_abstract_method_header (meth)
7227 tree meth;
7229 int flags = get_access_flags_from_decl (meth);
7230 /* DECL_NAME might still be a WFL node */
7231 tree name = GET_METHOD_NAME (meth);
7233 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7234 ACC_ABSTRACT, "abstract method",
7235 IDENTIFIER_POINTER (name));
7236 OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags,
7237 ACC_PUBLIC, "abstract method",
7238 IDENTIFIER_POINTER (name));
7240 check_modifiers ("Illegal modifier `%s' for interface method",
7241 flags, INTERFACE_METHOD_MODIFIERS);
7244 /* Create a FUNCTION_TYPE node and start augmenting it with the
7245 declared function arguments. Arguments type that can't be resolved
7246 are left as they are, but the returned node is marked as containing
7247 incomplete types. */
7249 static tree
7250 method_declarator (id, list)
7251 tree id, list;
7253 tree arg_types = NULL_TREE, current, node;
7254 tree meth = make_node (FUNCTION_TYPE);
7255 jdep *jdep;
7257 patch_stage = JDEP_NO_PATCH;
7259 /* If we're dealing with an inner class constructor, we hide the
7260 this$<n> decl in the name field of its parameter declaration. We
7261 also might have to hide the outer context local alias
7262 initializers. Not done when the class is a toplevel class. */
7263 if (PURE_INNER_CLASS_DECL_P (GET_CPC ())
7264 && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7266 tree aliases_list, type, thisn;
7267 /* First the aliases, linked to the regular parameters */
7268 aliases_list =
7269 build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION,
7270 TREE_TYPE (GET_CPC ()),
7271 NULL_TREE, NULL);
7272 list = chainon (nreverse (aliases_list), list);
7274 /* Then this$<n> */
7275 type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7276 thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7277 list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7278 list);
7281 for (current = list; current; current = TREE_CHAIN (current))
7283 int must_chain = 0;
7284 tree wfl_name = TREE_PURPOSE (current);
7285 tree type = TREE_VALUE (current);
7286 tree name = EXPR_WFL_NODE (wfl_name);
7287 tree already, arg_node;
7288 tree type_wfl = NULL_TREE;
7289 tree real_type;
7291 /* Obtain a suitable type for resolution, if necessary */
7292 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7294 /* Process NAME, as it may specify extra dimension(s) for it */
7295 type = build_array_from_name (type, type_wfl, name, &name);
7296 EXPR_WFL_NODE (wfl_name) = name;
7298 real_type = GET_REAL_TYPE (type);
7299 if (TREE_CODE (real_type) == RECORD_TYPE)
7301 real_type = promote_type (real_type);
7302 if (TREE_CODE (type) == TREE_LIST)
7303 TREE_PURPOSE (type) = real_type;
7306 /* Check redefinition */
7307 for (already = arg_types; already; already = TREE_CHAIN (already))
7308 if (TREE_PURPOSE (already) == name)
7310 parse_error_context
7311 (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7312 IDENTIFIER_POINTER (name),
7313 IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7314 break;
7317 /* If we've an incomplete argument type, we know there is a location
7318 to patch when the type get resolved, later. */
7319 jdep = NULL;
7320 if (must_chain)
7322 patch_stage = JDEP_METHOD;
7323 type = register_incomplete_type (patch_stage,
7324 type_wfl, wfl_name, type);
7325 jdep = CLASSD_LAST (ctxp->classd_list);
7326 JDEP_MISC (jdep) = id;
7329 /* The argument node: a name and a (possibly) incomplete type. */
7330 arg_node = build_tree_list (name, real_type);
7331 /* Remeber arguments declared final. */
7332 ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7334 if (jdep)
7335 JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7336 TREE_CHAIN (arg_node) = arg_types;
7337 arg_types = arg_node;
7339 TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7340 node = build_tree_list (id, meth);
7341 return node;
7344 static int
7345 unresolved_type_p (wfl, returned)
7346 tree wfl;
7347 tree *returned;
7350 if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7352 if (returned)
7354 tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7355 if (decl && current_class && (decl == TYPE_NAME (current_class)))
7356 *returned = TREE_TYPE (decl);
7357 else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7358 *returned = TREE_TYPE (GET_CPC ());
7359 else
7360 *returned = NULL_TREE;
7362 return 1;
7364 if (returned)
7365 *returned = wfl;
7366 return 0;
7369 /* From NAME, build a qualified identifier node using the
7370 qualification from the current package definition. */
7372 static tree
7373 parser_qualified_classname (is_static, name)
7374 int is_static;
7375 tree name;
7377 tree nested_class_name;
7379 if (!is_static
7380 && (nested_class_name = maybe_make_nested_class_name (name)))
7381 return nested_class_name;
7383 if (ctxp->package)
7384 return merge_qualified_name (ctxp->package, name);
7385 else
7386 return name;
7389 /* Called once the type a interface extends is resolved. Returns 0 if
7390 everything is OK. */
7392 static int
7393 parser_check_super_interface (super_decl, this_decl, this_wfl)
7394 tree super_decl, this_decl, this_wfl;
7396 tree super_type = TREE_TYPE (super_decl);
7398 /* Has to be an interface */
7399 if (!CLASS_INTERFACE (super_decl))
7401 parse_error_context
7402 (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7403 (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7404 IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7405 (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ?
7406 "interface" : "class"),
7407 IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7408 return 1;
7411 /* Check scope: same package OK, other package: OK if public */
7412 if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7413 return 1;
7415 SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7416 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7417 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7418 return 0;
7421 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7422 0 if everthing is OK. */
7424 static int
7425 parser_check_super (super_decl, this_decl, wfl)
7426 tree super_decl, this_decl, wfl;
7428 tree super_type = TREE_TYPE (super_decl);
7430 /* SUPER should be a CLASS (neither an array nor an interface) */
7431 if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7433 parse_error_context
7434 (wfl, "Class `%s' can't subclass %s `%s'",
7435 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7436 (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7437 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7438 return 1;
7441 if (CLASS_FINAL (TYPE_NAME (super_type)))
7443 parse_error_context (wfl, "Can't subclass final classes: %s",
7444 IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7445 return 1;
7448 /* Check scope: same package OK, other package: OK if public */
7449 if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7450 return 1;
7452 SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7453 IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7454 IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7455 return 0;
7458 /* Create a new dependency list and link it (in a LIFO manner) to the
7459 CTXP list of type dependency list. */
7461 static void
7462 create_jdep_list (ctxp)
7463 struct parser_ctxt *ctxp;
7465 jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));
7466 new->first = new->last = NULL;
7467 new->next = ctxp->classd_list;
7468 ctxp->classd_list = new;
7471 static jdeplist *
7472 reverse_jdep_list (ctxp)
7473 struct parser_ctxt *ctxp;
7475 register jdeplist *prev = NULL, *current, *next;
7476 for (current = ctxp->classd_list; current; current = next)
7478 next = current->next;
7479 current->next = prev;
7480 prev = current;
7482 return prev;
7485 /* Create a fake pointer based on the ID stored in
7486 TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7487 registered again. */
7489 static tree
7490 obtain_incomplete_type (type_name)
7491 tree type_name;
7493 tree ptr, name;
7495 if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7496 name = EXPR_WFL_NODE (type_name);
7497 else if (INCOMPLETE_TYPE_P (type_name))
7498 name = TYPE_NAME (type_name);
7499 else
7500 fatal ("invalid type name - obtain_incomplete_type");
7502 for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7503 if (TYPE_NAME (ptr) == name)
7504 break;
7506 if (!ptr)
7508 push_obstacks (&permanent_obstack, &permanent_obstack);
7509 BUILD_PTR_FROM_NAME (ptr, name);
7510 layout_type (ptr);
7511 pop_obstacks ();
7512 TREE_CHAIN (ptr) = ctxp->incomplete_class;
7513 ctxp->incomplete_class = ptr;
7516 return ptr;
7519 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7520 non NULL instead of computing a new fake type based on WFL. The new
7521 dependency is inserted in the current type dependency list, in FIFO
7522 manner. */
7524 static tree
7525 register_incomplete_type (kind, wfl, decl, ptr)
7526 int kind;
7527 tree wfl, decl, ptr;
7529 jdep *new = (jdep *)xmalloc (sizeof (jdep));
7531 if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7532 ptr = obtain_incomplete_type (wfl);
7534 JDEP_KIND (new) = kind;
7535 JDEP_DECL (new) = decl;
7536 JDEP_SOLV (new) = ptr;
7537 JDEP_WFL (new) = wfl;
7538 JDEP_CHAIN (new) = NULL;
7539 JDEP_MISC (new) = NULL_TREE;
7540 if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
7541 && GET_ENCLOSING_CPC ())
7542 JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7543 else
7544 JDEP_ENCLOSING (new) = GET_CPC ();
7545 JDEP_GET_PATCH (new) = (tree *)NULL;
7547 JDEP_INSERT (ctxp->classd_list, new);
7549 return ptr;
7552 void
7553 java_check_circular_reference ()
7555 tree current;
7556 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7558 tree type = TREE_TYPE (current);
7559 if (CLASS_INTERFACE (current))
7561 /* Check all interfaces this class extends */
7562 tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7563 int n, i;
7565 if (!basetype_vec)
7566 return;
7567 n = TREE_VEC_LENGTH (basetype_vec);
7568 for (i = 0; i < n; i++)
7570 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7571 if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node
7572 && interface_of_p (type, BINFO_TYPE (vec_elt)))
7573 parse_error_context (lookup_cl (current),
7574 "Cyclic interface inheritance");
7577 else
7578 if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7579 parse_error_context (lookup_cl (current),
7580 "Cyclic class inheritance%s",
7581 (cyclic_inheritance_report ?
7582 cyclic_inheritance_report : ""));
7586 /* Augment the parameter list PARM with parameters crafted to
7587 initialize outer context locals aliases. Through ARTIFICIAL, a
7588 count is kept of the number of crafted parameters. MODE governs
7589 what eventually gets created: something suitable for a function
7590 creation or a function invocation, either the constructor or
7591 $finit$. */
7593 static tree
7594 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7595 int mode;
7596 tree class_type, parm;
7597 int *artificial;
7599 tree field;
7600 for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7601 if (FIELD_LOCAL_ALIAS (field))
7603 char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7604 tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7606 switch (mode)
7608 case AIPL_FUNCTION_DECLARATION:
7609 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7610 purpose = build_wfl_node (get_identifier (buffer));
7611 if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7612 value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7613 else
7614 value = TREE_TYPE (field);
7615 break;
7617 case AIPL_FUNCTION_CREATION:
7618 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7619 purpose = get_identifier (buffer);
7620 value = TREE_TYPE (field);
7621 break;
7623 case AIPL_FUNCTION_FINIT_INVOCATION:
7624 MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7625 /* Now, this is wrong. purpose should always be the NAME
7626 of something and value its matching value (decl, type,
7627 etc...) FIXME -- but there is a lot to fix. */
7629 /* When invoked for this kind of operation, we already
7630 know whether a field is used or not. */
7631 purpose = TREE_TYPE (field);
7632 value = build_wfl_node (get_identifier (buffer));
7633 break;
7635 case AIPL_FUNCTION_CTOR_INVOCATION:
7636 /* There are two case: the constructor invokation happends
7637 outside the local inner, in which case, locales from the outer
7638 context are directly used.
7640 Otherwise, we fold to using the alias directly. */
7641 if (class_type == current_class)
7642 value = field;
7643 else
7645 name = get_identifier (&buffer[4]);
7646 value = IDENTIFIER_LOCAL_VALUE (name);
7648 break;
7650 parm = tree_cons (purpose, value, parm);
7651 if (artificial)
7652 *artificial +=1;
7654 return parm;
7657 /* Craft a constructor for CLASS_DECL -- what we should do when none
7658 where found. ARGS is non NULL when a special signature must be
7659 enforced. This is the case for anonymous classes. */
7661 static void
7662 craft_constructor (class_decl, args)
7663 tree class_decl, args;
7665 tree class_type = TREE_TYPE (class_decl);
7666 tree parm = NULL_TREE;
7667 int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7668 ACC_PUBLIC : 0);
7669 int i = 0, artificial = 0;
7670 tree decl, ctor_name;
7671 char buffer [80];
7673 push_obstacks (&permanent_obstack, &permanent_obstack);
7675 /* The constructor name is <init> unless we're dealing with an
7676 anonymous class, in which case the name will be fixed after having
7677 be expanded. */
7678 if (ANONYMOUS_CLASS_P (class_type))
7679 ctor_name = DECL_NAME (class_decl);
7680 else
7681 ctor_name = init_identifier_node;
7683 /* If we're dealing with an inner class constructor, we hide the
7684 this$<n> decl in the name field of its parameter declaration. */
7685 if (PURE_INNER_CLASS_TYPE_P (class_type))
7687 tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7688 parm = tree_cons (build_current_thisn (class_type),
7689 build_pointer_type (type), parm);
7691 /* Some more arguments to be hidden here. The values of the local
7692 variables of the outer context that the inner class needs to see. */
7693 parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7694 class_type, parm,
7695 &artificial);
7698 /* Then if there are any args to be enforced, enforce them now */
7699 for (; args && args != end_params_node; args = TREE_CHAIN (args))
7701 sprintf (buffer, "parm%d", i++);
7702 parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7705 CRAFTED_PARAM_LIST_FIXUP (parm);
7706 decl = create_artificial_method (class_type, flags, void_type_node,
7707 ctor_name, parm);
7708 fix_method_argument_names (parm, decl);
7709 /* Now, mark the artificial parameters. */
7710 DECL_FUNCTION_NAP (decl) = artificial;
7712 pop_obstacks ();
7713 DECL_CONSTRUCTOR_P (decl) = 1;
7717 /* Fix the constructors. This will be called right after circular
7718 references have been checked. It is necessary to fix constructors
7719 early even if no code generation will take place for that class:
7720 some generated constructor might be required by the class whose
7721 compilation triggered this one to be simply loaded. */
7723 void
7724 java_fix_constructors ()
7726 tree current;
7728 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7730 tree class_type = TREE_TYPE (current);
7731 int saw_ctor = 0;
7732 tree decl;
7734 if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7735 continue;
7737 for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7739 if (DECL_CONSTRUCTOR_P (decl))
7741 fix_constructors (decl);
7742 saw_ctor = 1;
7746 /* Anonymous class constructor can't be generated that early. */
7747 if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7748 craft_constructor (current, NULL_TREE);
7752 /* safe_layout_class just makes sure that we can load a class without
7753 disrupting the current_class, input_file, lineno, etc, information
7754 about the class processed currently. */
7756 void
7757 safe_layout_class (class)
7758 tree class;
7760 tree save_current_class = current_class;
7761 char *save_input_filename = input_filename;
7762 int save_lineno = lineno;
7764 push_obstacks (&permanent_obstack, &permanent_obstack);
7766 layout_class (class);
7767 pop_obstacks ();
7769 current_class = save_current_class;
7770 input_filename = save_input_filename;
7771 lineno = save_lineno;
7772 CLASS_LOADED_P (class) = 1;
7775 static tree
7776 jdep_resolve_class (dep)
7777 jdep *dep;
7779 tree decl;
7781 if (JDEP_RESOLVED_P (dep))
7782 decl = JDEP_RESOLVED_DECL (dep);
7783 else
7785 decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7786 JDEP_DECL (dep), JDEP_WFL (dep));
7787 JDEP_RESOLVED (dep, decl);
7790 if (!decl)
7791 complete_class_report_errors (dep);
7793 return decl;
7796 /* Complete unsatisfied class declaration and their dependencies */
7798 void
7799 java_complete_class ()
7801 tree cclass;
7802 jdeplist *cclassd;
7803 int error_found;
7804 tree type;
7806 push_obstacks (&permanent_obstack, &permanent_obstack);
7808 /* Process imports and reverse the import on demand list */
7809 process_imports ();
7810 if (ctxp->import_demand_list)
7811 ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7813 /* Rever things so we have the right order */
7814 ctxp->class_list = nreverse (ctxp->class_list);
7815 ctxp->classd_list = reverse_jdep_list (ctxp);
7817 for (cclassd = ctxp->classd_list, cclass = ctxp->class_list;
7818 cclass && cclassd;
7819 cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7821 jdep *dep;
7822 for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7824 tree decl;
7825 if (!(decl = jdep_resolve_class (dep)))
7826 continue;
7828 /* Now it's time to patch */
7829 switch (JDEP_KIND (dep))
7831 case JDEP_SUPER:
7832 /* Simply patch super */
7833 if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7834 continue;
7835 BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO
7836 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7837 break;
7839 case JDEP_FIELD:
7841 /* We do part of the job done in add_field */
7842 tree field_decl = JDEP_DECL (dep);
7843 tree field_type = TREE_TYPE (decl);
7844 push_obstacks (&permanent_obstack, &permanent_obstack);
7845 if (TREE_CODE (field_type) == RECORD_TYPE)
7846 field_type = promote_type (field_type);
7847 pop_obstacks ();
7848 TREE_TYPE (field_decl) = field_type;
7849 DECL_ALIGN (field_decl) = 0;
7850 layout_decl (field_decl, 0);
7851 SOURCE_FRONTEND_DEBUG
7852 (("Completed field/var decl `%s' with `%s'",
7853 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7854 IDENTIFIER_POINTER (DECL_NAME (decl))));
7855 break;
7857 case JDEP_METHOD: /* We start patching a method */
7858 case JDEP_METHOD_RETURN:
7859 error_found = 0;
7860 while (1)
7862 if (decl)
7864 type = TREE_TYPE(decl);
7865 if (TREE_CODE (type) == RECORD_TYPE)
7866 type = promote_type (type);
7867 JDEP_APPLY_PATCH (dep, type);
7868 SOURCE_FRONTEND_DEBUG
7869 (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7870 "Completing fct `%s' with ret type `%s'":
7871 "Completing arg `%s' with type `%s'"),
7872 IDENTIFIER_POINTER (EXPR_WFL_NODE
7873 (JDEP_DECL_WFL (dep))),
7874 IDENTIFIER_POINTER (DECL_NAME (decl))));
7876 else
7877 error_found = 1;
7878 dep = JDEP_CHAIN (dep);
7879 if (JDEP_KIND (dep) == JDEP_METHOD_END)
7880 break;
7881 else
7882 decl = jdep_resolve_class (dep);
7884 if (!error_found)
7886 tree mdecl = JDEP_DECL (dep), signature;
7887 push_obstacks (&permanent_obstack, &permanent_obstack);
7888 /* Recompute and reset the signature, check first that
7889 all types are now defined. If they're not,
7890 dont build the signature. */
7891 if (check_method_types_complete (mdecl))
7893 signature = build_java_signature (TREE_TYPE (mdecl));
7894 set_java_signature (TREE_TYPE (mdecl), signature);
7896 pop_obstacks ();
7898 else
7899 continue;
7900 break;
7902 case JDEP_INTERFACE:
7903 if (parser_check_super_interface (decl, JDEP_DECL (dep),
7904 JDEP_WFL (dep)))
7905 continue;
7906 parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
7907 break;
7909 case JDEP_PARM:
7910 case JDEP_VARIABLE:
7911 type = TREE_TYPE(decl);
7912 if (TREE_CODE (type) == RECORD_TYPE)
7913 type = promote_type (type);
7914 JDEP_APPLY_PATCH (dep, type);
7915 break;
7917 case JDEP_TYPE:
7918 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7919 SOURCE_FRONTEND_DEBUG
7920 (("Completing a random type dependency on a '%s' node",
7921 tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
7922 break;
7924 case JDEP_EXCEPTION:
7925 JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7926 SOURCE_FRONTEND_DEBUG
7927 (("Completing `%s' `throws' argument node",
7928 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
7929 break;
7931 case JDEP_ANONYMOUS:
7932 patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
7933 break;
7935 default:
7936 fatal ("Can't handle patch code %d - java_complete_class",
7937 JDEP_KIND (dep));
7941 pop_obstacks ();
7942 return;
7945 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
7946 array. */
7948 static tree
7949 resolve_class (enclosing, class_type, decl, cl)
7950 tree enclosing, class_type, decl, cl;
7952 const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
7953 const char *base = name;
7954 tree resolved_type = TREE_TYPE (class_type);
7955 tree resolved_type_decl;
7957 if (resolved_type != NULL_TREE)
7959 tree resolved_type_decl = TYPE_NAME (resolved_type);
7960 if (resolved_type_decl == NULL_TREE
7961 || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
7963 resolved_type_decl = build_decl (TYPE_DECL,
7964 TYPE_NAME (class_type),
7965 resolved_type);
7967 return resolved_type_decl;
7970 /* 1- Check to see if we have an array. If true, find what we really
7971 want to resolve */
7972 while (name[0] == '[')
7973 name++;
7974 if (base != name)
7975 TYPE_NAME (class_type) = get_identifier (name);
7977 /* 2- Resolve the bare type */
7978 if (!(resolved_type_decl = do_resolve_class (enclosing, class_type,
7979 decl, cl)))
7980 return NULL_TREE;
7981 resolved_type = TREE_TYPE (resolved_type_decl);
7983 /* 3- If we have and array, reconstruct the array down to its nesting */
7984 if (base != name)
7986 while (base != name)
7988 if (TREE_CODE (resolved_type) == RECORD_TYPE)
7989 resolved_type = promote_type (resolved_type);
7990 resolved_type = build_java_array_type (resolved_type, -1);
7991 CLASS_LOADED_P (resolved_type) = 1;
7992 name--;
7994 /* Build a fake decl for this, since this is what is expected to
7995 be returned. */
7996 resolved_type_decl =
7997 build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
7998 /* Figure how those two things are important for error report. FIXME */
7999 DECL_SOURCE_LINE (resolved_type_decl) = 0;
8000 DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8001 TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8003 TREE_TYPE (class_type) = resolved_type;
8004 return resolved_type_decl;
8007 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8008 are used to report error messages. */
8010 tree
8011 do_resolve_class (enclosing, class_type, decl, cl)
8012 tree enclosing, class_type, decl, cl;
8014 tree new_class_decl;
8015 tree original_name = NULL_TREE;
8017 /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8018 its is changed by find_in_imports{_on_demand} */
8020 /* 0- Search in the current class as an inner class */
8022 /* Maybe some code here should be added to load the class or
8023 something, at least if the class isn't an inner class and ended
8024 being loaded from class file. FIXME. */
8025 if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8026 return new_class_decl;
8028 /* 1- Check for the type in single imports */
8029 if (find_in_imports (class_type))
8030 return NULL_TREE;
8032 /* 2- And check for the type in the current compilation unit. If it fails,
8033 try with a name qualified with the package name we've seen so far */
8034 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8036 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8037 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8038 load_class (TYPE_NAME (class_type), 0);
8039 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8042 original_name = TYPE_NAME (class_type);
8043 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8045 tree package;
8046 for (package = package_list; package; package = TREE_CHAIN (package))
8048 tree new_qualified;
8050 new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8051 original_name);
8052 TYPE_NAME (class_type) = new_qualified;
8053 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8054 if (!new_class_decl)
8055 load_class (TYPE_NAME (class_type), 0);
8056 new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8057 if (new_class_decl)
8059 if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8060 !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8061 load_class (TYPE_NAME (class_type), 0);
8062 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8067 TYPE_NAME (class_type) = original_name;
8069 /* 3- Check an other compilation unit that bears the name of type */
8070 load_class (TYPE_NAME (class_type), 0);
8071 if (check_pkg_class_access (TYPE_NAME (class_type),
8072 (cl ? cl : lookup_cl (decl))))
8073 return NULL_TREE;
8075 if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8076 return new_class_decl;
8078 /* 4- Check the import on demands. Don't allow bar.baz to be
8079 imported from foo.* */
8080 if (!QUALIFIED_P (TYPE_NAME (class_type)))
8081 if (find_in_imports_on_demand (class_type))
8082 return NULL_TREE;
8084 /* 5- Last call for a resolution */
8085 return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8088 /* Resolve NAME and lay it out (if not done and if not the current
8089 parsed class). Return a decl node. This function is meant to be
8090 called when type resolution is necessary during the walk pass. */
8092 static tree
8093 resolve_and_layout (something, cl)
8094 tree something;
8095 tree cl;
8097 tree decl;
8099 /* Don't do that on the current class */
8100 if (something == current_class)
8101 return TYPE_NAME (current_class);
8103 /* Don't do anything for void and other primitive types */
8104 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8105 return NULL_TREE;
8107 /* Pointer types can be reall pointer types or fake pointers. When
8108 finding a real pointer, recheck for primitive types */
8109 if (TREE_CODE (something) == POINTER_TYPE)
8111 if (TREE_TYPE (something))
8113 something = TREE_TYPE (something);
8114 if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8115 return NULL_TREE;
8117 else
8118 something = TYPE_NAME (something);
8121 /* Don't do anything for arrays of primitive types */
8122 if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8123 && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8124 return NULL_TREE;
8126 /* Something might be a WFL */
8127 if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8128 something = EXPR_WFL_NODE (something);
8130 /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8131 TYPE_DECL or a real TYPE */
8132 else if (TREE_CODE (something) != IDENTIFIER_NODE)
8133 something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8134 DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8136 if (!(decl = resolve_no_layout (something, cl)))
8137 return NULL_TREE;
8139 /* Resolve and layout if necessary */
8140 layout_class_methods (TREE_TYPE (decl));
8141 /* Check methods, but only once */
8142 if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl))
8143 && !CLASS_LOADED_P (TREE_TYPE (decl)))
8144 CHECK_METHODS (decl);
8145 if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8146 safe_layout_class (TREE_TYPE (decl));
8148 return decl;
8151 /* Resolve a class, returns its decl but doesn't perform any
8152 layout. The current parsing context is saved and restored */
8154 static tree
8155 resolve_no_layout (name, cl)
8156 tree name, cl;
8158 tree ptr, decl;
8159 BUILD_PTR_FROM_NAME (ptr, name);
8160 java_parser_context_save_global ();
8161 decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8162 java_parser_context_restore_global ();
8164 return decl;
8167 /* Called when reporting errors. Skip leader '[' in a complex array
8168 type description that failed to be resolved. */
8170 static const char *
8171 purify_type_name (name)
8172 const char *name;
8174 while (*name && *name == '[')
8175 name++;
8176 return name;
8179 /* The type CURRENT refers to can't be found. We print error messages. */
8181 static void
8182 complete_class_report_errors (dep)
8183 jdep *dep;
8185 const char *name;
8187 if (!JDEP_WFL (dep))
8188 return;
8190 name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8191 switch (JDEP_KIND (dep))
8193 case JDEP_SUPER:
8194 parse_error_context
8195 (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8196 purify_type_name (name),
8197 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8198 break;
8199 case JDEP_FIELD:
8200 parse_error_context
8201 (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8202 purify_type_name (name),
8203 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8204 break;
8205 case JDEP_METHOD: /* Covers arguments */
8206 parse_error_context
8207 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8208 purify_type_name (name),
8209 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8210 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8211 break;
8212 case JDEP_METHOD_RETURN: /* Covers return type */
8213 parse_error_context
8214 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'",
8215 purify_type_name (name),
8216 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8217 break;
8218 case JDEP_INTERFACE:
8219 parse_error_context
8220 (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8221 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8222 (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8223 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8224 break;
8225 case JDEP_VARIABLE:
8226 parse_error_context
8227 (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'",
8228 purify_type_name (IDENTIFIER_POINTER
8229 (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8230 IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8231 break;
8232 case JDEP_EXCEPTION: /* As specified by `throws' */
8233 parse_error_context
8234 (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8235 IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8236 break;
8237 default:
8238 /* Fix for -Wall. Just break doing nothing. The error will be
8239 caught later */
8240 break;
8244 /* Return a static string containing the DECL prototype string. If
8245 DECL is a constructor, use the class name instead of the form
8246 <init> */
8248 static const char *
8249 get_printable_method_name (decl)
8250 tree decl;
8252 const char *to_return;
8253 tree name = NULL_TREE;
8255 if (DECL_CONSTRUCTOR_P (decl))
8257 name = DECL_NAME (decl);
8258 DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8261 to_return = lang_printable_name (decl, 0);
8262 if (DECL_CONSTRUCTOR_P (decl))
8263 DECL_NAME (decl) = name;
8265 return to_return;
8268 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8269 nevertheless needs to be verfied, 1 otherwise. */
8271 static int
8272 reset_method_name (method)
8273 tree method;
8275 if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8277 /* NAME is just the plain name when Object is being defined */
8278 if (DECL_CONTEXT (method) != object_type_node)
8279 DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ?
8280 init_identifier_node : GET_METHOD_NAME (method));
8281 return 0;
8283 else
8284 return 1;
8287 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8289 tree
8290 java_get_real_method_name (method_decl)
8291 tree method_decl;
8293 tree method_name = DECL_NAME (method_decl);
8294 if (DECL_CONSTRUCTOR_P (method_decl))
8295 return init_identifier_node;
8297 /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8298 and still can be a constructor. FIXME */
8300 /* Don't confuse method only bearing the name of their class as
8301 constructors */
8302 else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8303 && ctxp
8304 && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8305 && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8306 && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8307 return init_identifier_node;
8308 else
8309 return EXPR_WFL_NODE (method_name);
8312 /* Track method being redefined inside the same class. As a side
8313 effect, set DECL_NAME to an IDENTIFIER (prior entering this
8314 function it's a FWL, so we can track errors more accurately.) */
8316 static int
8317 check_method_redefinition (class, method)
8318 tree class, method;
8320 tree redef, name;
8321 tree cl = DECL_NAME (method);
8322 tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8323 /* decl name of artificial <clinit> and $finit$ doesn't need to be
8324 fixed and checked */
8326 /* Reset the method name before running the check. If it returns 1,
8327 the method doesn't need to be verified with respect to method
8328 redeclaration and we return 0 */
8329 if (reset_method_name (method))
8330 return 0;
8332 name = DECL_NAME (method);
8333 for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8335 if (redef == method)
8336 break;
8337 if (DECL_NAME (redef) == name
8338 && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8340 parse_error_context
8341 (cl, "Duplicate %s declaration `%s'",
8342 (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8343 get_printable_method_name (redef));
8344 return 1;
8347 return 0;
8350 static void
8351 check_abstract_method_definitions (do_interface, class_decl, type)
8352 int do_interface;
8353 tree class_decl, type;
8355 tree class = TREE_TYPE (class_decl);
8356 tree method, end_type;
8358 end_type = (do_interface ? object_type_node : type);
8359 for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8361 tree other_super, other_method, method_sig, method_name;
8362 int found = 0;
8363 int end_type_reached = 0;
8365 if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8366 continue;
8368 /* Now verify that somewhere in between TYPE and CLASS,
8369 abstract method METHOD gets a non abstract definition
8370 that is inherited by CLASS. */
8372 method_sig = build_java_signature (TREE_TYPE (method));
8373 method_name = DECL_NAME (method);
8374 if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8375 method_name = EXPR_WFL_NODE (method_name);
8377 other_super = class;
8378 do {
8379 if (other_super == end_type)
8380 end_type_reached = 1;
8382 /* Method search */
8383 for (other_method = TYPE_METHODS (other_super); other_method;
8384 other_method = TREE_CHAIN (other_method))
8386 tree s = build_java_signature (TREE_TYPE (other_method));
8387 tree other_name = DECL_NAME (other_method);
8389 if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8390 other_name = EXPR_WFL_NODE (other_name);
8391 if (!DECL_CLINIT_P (other_method)
8392 && !DECL_CONSTRUCTOR_P (other_method)
8393 && method_name == other_name && method_sig == s)
8395 found = 1;
8396 break;
8399 other_super = CLASSTYPE_SUPER (other_super);
8400 } while (!end_type_reached);
8402 /* Report that abstract METHOD didn't find an implementation
8403 that CLASS can use. */
8404 if (!found)
8406 char *t = xstrdup (lang_printable_name
8407 (TREE_TYPE (TREE_TYPE (method)), 0));
8408 tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8409 tree saved_wfl = NULL_TREE;
8411 if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8413 saved_wfl = DECL_NAME (method);
8414 DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8417 parse_error_context
8418 (lookup_cl (class_decl),
8419 "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",
8420 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8421 t, lang_printable_name (method, 0),
8422 (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ?
8423 "interface" : "class"),
8424 IDENTIFIER_POINTER (ccn),
8425 (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8426 IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8428 free (t);
8430 if (saved_wfl)
8431 DECL_NAME (method) = saved_wfl;
8436 /* Check that CLASS_DECL somehow implements all inherited abstract
8437 methods. */
8439 static void
8440 java_check_abstract_method_definitions (class_decl)
8441 tree class_decl;
8443 tree class = TREE_TYPE (class_decl);
8444 tree super, vector;
8445 int i;
8447 if (CLASS_ABSTRACT (class_decl))
8448 return;
8450 /* Check for inherited types */
8451 super = class;
8452 do {
8453 super = CLASSTYPE_SUPER (super);
8454 check_abstract_method_definitions (0, class_decl, super);
8455 } while (super != object_type_node);
8457 /* Check for implemented interfaces. */
8458 vector = TYPE_BINFO_BASETYPES (class);
8459 for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8461 super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8462 check_abstract_method_definitions (1, class_decl, super);
8466 /* Check all the types method DECL uses and return 1 if all of them
8467 are now complete, 0 otherwise. This is used to check whether its
8468 safe to build a method signature or not. */
8470 static int
8471 check_method_types_complete (decl)
8472 tree decl;
8474 tree type = TREE_TYPE (decl);
8475 tree args;
8477 if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8478 return 0;
8480 args = TYPE_ARG_TYPES (type);
8481 if (TREE_CODE (type) == METHOD_TYPE)
8482 args = TREE_CHAIN (args);
8483 for (; args != end_params_node; args = TREE_CHAIN (args))
8484 if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8485 return 0;
8487 return 1;
8490 /* Check all the methods of CLASS_DECL. Methods are first completed
8491 then checked according to regular method existance rules. If no
8492 constructor for CLASS_DECL were encountered, then build its
8493 declaration. */
8495 static void
8496 java_check_regular_methods (class_decl)
8497 tree class_decl;
8499 int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8500 tree method;
8501 tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8502 tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8503 tree mthrows;
8505 /* It is not necessary to check methods defined in java.lang.Object */
8506 if (class == object_type_node)
8507 return;
8509 if (!TYPE_NVIRTUALS (class))
8510 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8512 /* Should take interfaces into account. FIXME */
8513 for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8515 tree sig;
8516 tree method_wfl = DECL_NAME (method);
8517 int aflags;
8519 /* If we previously found something and its name was saved,
8520 reinstall it now */
8521 if (found && saved_found_wfl)
8523 DECL_NAME (found) = saved_found_wfl;
8524 saved_found_wfl = NULL_TREE;
8527 /* Check for redefinitions */
8528 if (check_method_redefinition (class, method))
8529 continue;
8531 /* If we see one constructor a mark so we don't generate the
8532 default one. Also skip other verifications: constructors
8533 can't be inherited hence hiden or overriden */
8534 if (DECL_CONSTRUCTOR_P (method))
8536 saw_constructor = 1;
8537 continue;
8540 /* We verify things thrown by the method. They must inherits from
8541 java.lang.Throwable */
8542 for (mthrows = DECL_FUNCTION_THROWS (method);
8543 mthrows; mthrows = TREE_CHAIN (mthrows))
8545 if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8546 parse_error_context
8547 (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8548 IDENTIFIER_POINTER
8549 (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8552 sig = build_java_argument_signature (TREE_TYPE (method));
8553 found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8555 /* Inner class can't declare static methods */
8556 if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8558 char *t = xstrdup (lang_printable_name (class, 0));
8559 parse_error_context
8560 (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8561 lang_printable_name (method, 0), t);
8562 free (t);
8565 /* Nothing overrides or it's a private method. */
8566 if (!found)
8567 continue;
8568 if (METHOD_PRIVATE (found))
8570 found = NULL_TREE;
8571 continue;
8574 /* If found wasn't verified, it's DECL_NAME won't be set properly.
8575 We set it temporarily for the sake of the error report. */
8576 saved_found_wfl = DECL_NAME (found);
8577 reset_method_name (found);
8579 /* If `found' is declared in an interface, make sure the
8580 modifier matches. */
8581 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8582 && clinit_identifier_node != DECL_NAME (found)
8583 && !METHOD_PUBLIC (method))
8585 tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8586 parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8587 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8588 lang_printable_name (method, 0),
8589 IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8592 /* Can't override a method with the same name and different return
8593 types. */
8594 if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8596 char *t = xstrdup
8597 (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8598 parse_error_context
8599 (method_wfl,
8600 "Method `%s' was defined with return type `%s' in class `%s'",
8601 lang_printable_name (found, 0), t,
8602 IDENTIFIER_POINTER
8603 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8604 free (t);
8607 aflags = get_access_flags_from_decl (found);
8608 /* If the method has default, access in an other package, then
8609 issue a warning that the current method doesn't override the
8610 one that was found elsewhere. Do not issue this warning when
8611 the match was found in java.lang.Object. */
8612 if (DECL_CONTEXT (found) != object_type_node
8613 && ((aflags & ACC_VISIBILITY) == 0)
8614 && !class_in_current_package (DECL_CONTEXT (found))
8615 && !DECL_CLINIT_P (found)
8616 && flag_not_overriding)
8618 parse_warning_context
8619 (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8620 lang_printable_name (found, 0),
8621 IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8622 IDENTIFIER_POINTER (DECL_NAME
8623 (TYPE_NAME (DECL_CONTEXT (found)))));
8624 continue;
8627 /* Can't override final. Can't override static. */
8628 if (METHOD_FINAL (found) || METHOD_STATIC (found))
8630 /* Static *can* override static */
8631 if (METHOD_STATIC (found) && METHOD_STATIC (method))
8632 continue;
8633 parse_error_context
8634 (method_wfl,
8635 "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8636 (METHOD_FINAL (found) ? "Final" : "Static"),
8637 lang_printable_name (found, 0),
8638 (METHOD_FINAL (found) ? "final" : "static"),
8639 IDENTIFIER_POINTER
8640 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8641 continue;
8644 /* Static method can't override instance method. */
8645 if (METHOD_STATIC (method))
8647 parse_error_context
8648 (method_wfl,
8649 "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8650 lang_printable_name (found, 0),
8651 IDENTIFIER_POINTER
8652 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8653 continue;
8656 /* - Overriding/hiding public must be public
8657 - Overriding/hiding protected must be protected or public
8658 - If the overriden or hidden method has default (package)
8659 access, then the overriding or hiding method must not be
8660 private; otherwise, a compile-time error occurs. If
8661 `found' belongs to an interface, things have been already
8662 taken care of. */
8663 if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8664 && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8665 || (METHOD_PROTECTED (found)
8666 && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8667 || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8668 && METHOD_PRIVATE (method))))
8670 parse_error_context
8671 (method_wfl,
8672 "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8673 (METHOD_PUBLIC (method) ? "public" :
8674 (METHOD_PRIVATE (method) ? "private" : "protected")),
8675 IDENTIFIER_POINTER (DECL_NAME
8676 (TYPE_NAME (DECL_CONTEXT (found)))));
8677 continue;
8680 /* Overriding methods must have compatible `throws' clauses on checked
8681 exceptions, if any */
8682 check_throws_clauses (method, method_wfl, found);
8684 /* Inheriting multiple methods with the same signature. FIXME */
8687 /* Don't forget eventual pending found and saved_found_wfl. Take
8688 into account that we might have exited because we saw an
8689 artificial method as the last entry. */
8691 if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8692 DECL_NAME (found) = saved_found_wfl;
8694 if (!TYPE_NVIRTUALS (class))
8695 TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8697 /* Search for inherited abstract method not yet implemented in this
8698 class. */
8699 java_check_abstract_method_definitions (class_decl);
8701 if (!saw_constructor)
8702 fatal ("No constructor found");
8705 /* Return a non zero value if the `throws' clause of METHOD (if any)
8706 is incompatible with the `throws' clause of FOUND (if any). */
8708 static void
8709 check_throws_clauses (method, method_wfl, found)
8710 tree method, method_wfl, found;
8712 tree mthrows, fthrows;
8714 /* Can't check these things with class loaded from bytecode. FIXME */
8715 if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8716 return;
8718 for (mthrows = DECL_FUNCTION_THROWS (method);
8719 mthrows; mthrows = TREE_CHAIN (mthrows))
8721 /* We don't verify unchecked expressions */
8722 if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8723 continue;
8724 /* Checked expression must be compatible */
8725 for (fthrows = DECL_FUNCTION_THROWS (found);
8726 fthrows; fthrows = TREE_CHAIN (fthrows))
8727 if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8728 break;
8729 if (!fthrows)
8731 parse_error_context
8732 (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'",
8733 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8734 lang_printable_name (found, 0),
8735 IDENTIFIER_POINTER
8736 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8741 /* Check abstract method of interface INTERFACE */
8743 static void
8744 java_check_abstract_methods (interface_decl)
8745 tree interface_decl;
8747 int i, n;
8748 tree method, basetype_vec, found;
8749 tree interface = TREE_TYPE (interface_decl);
8751 for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8753 tree method_wfl = DECL_NAME (method);
8755 /* 2- Check for double definition inside the defining interface */
8756 if (check_method_redefinition (interface, method))
8757 continue;
8759 /* 3- Overriding is OK as far as we preserve the return type and
8760 the thrown exceptions (FIXME) */
8761 found = lookup_java_interface_method2 (interface, method);
8762 if (found)
8764 char *t;
8765 tree saved_found_wfl = DECL_NAME (found);
8766 reset_method_name (found);
8767 t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8768 parse_error_context
8769 (method_wfl,
8770 "Method `%s' was defined with return type `%s' in class `%s'",
8771 lang_printable_name (found, 0), t,
8772 IDENTIFIER_POINTER
8773 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8774 free (t);
8775 DECL_NAME (found) = saved_found_wfl;
8776 continue;
8780 /* 4- Inherited methods can't differ by their returned types */
8781 if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8782 return;
8783 n = TREE_VEC_LENGTH (basetype_vec);
8784 for (i = 0; i < n; i++)
8786 tree sub_interface_method, sub_interface;
8787 tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8788 if (!vec_elt)
8789 continue;
8790 sub_interface = BINFO_TYPE (vec_elt);
8791 for (sub_interface_method = TYPE_METHODS (sub_interface);
8792 sub_interface_method;
8793 sub_interface_method = TREE_CHAIN (sub_interface_method))
8795 found = lookup_java_interface_method2 (interface,
8796 sub_interface_method);
8797 if (found && (found != sub_interface_method))
8799 tree saved_found_wfl = DECL_NAME (found);
8800 reset_method_name (found);
8801 parse_error_context
8802 (lookup_cl (sub_interface_method),
8803 "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8804 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8805 lang_printable_name (found, 0),
8806 IDENTIFIER_POINTER
8807 (DECL_NAME (TYPE_NAME
8808 (DECL_CONTEXT (sub_interface_method)))),
8809 IDENTIFIER_POINTER
8810 (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8811 DECL_NAME (found) = saved_found_wfl;
8817 /* Lookup methods in interfaces using their name and partial
8818 signature. Return a matching method only if their types differ. */
8820 static tree
8821 lookup_java_interface_method2 (class, method_decl)
8822 tree class, method_decl;
8824 int i, n;
8825 tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8827 if (!basetype_vec)
8828 return NULL_TREE;
8830 n = TREE_VEC_LENGTH (basetype_vec);
8831 for (i = 0; i < n; i++)
8833 tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8834 if ((BINFO_TYPE (vec_elt) != object_type_node)
8835 && (to_return =
8836 lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8837 return to_return;
8839 for (i = 0; i < n; i++)
8841 to_return = lookup_java_interface_method2
8842 (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8843 if (to_return)
8844 return to_return;
8847 return NULL_TREE;
8850 /* Lookup method using their name and partial signature. Return a
8851 matching method only if their types differ. */
8853 static tree
8854 lookup_java_method2 (clas, method_decl, do_interface)
8855 tree clas, method_decl;
8856 int do_interface;
8858 tree method, method_signature, method_name, method_type, name;
8860 method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8861 name = DECL_NAME (method_decl);
8862 method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8863 EXPR_WFL_NODE (name) : name);
8864 method_type = TREE_TYPE (TREE_TYPE (method_decl));
8866 while (clas != NULL_TREE)
8868 for (method = TYPE_METHODS (clas);
8869 method != NULL_TREE; method = TREE_CHAIN (method))
8871 tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8872 tree name = DECL_NAME (method);
8873 if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8874 EXPR_WFL_NODE (name) : name) == method_name
8875 && method_sig == method_signature
8876 && TREE_TYPE (TREE_TYPE (method)) != method_type)
8877 return method;
8879 clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
8881 return NULL_TREE;
8884 /* Return the line that matches DECL line number, and try its best to
8885 position the column number. Used during error reports. */
8887 static tree
8888 lookup_cl (decl)
8889 tree decl;
8891 static tree cl = NULL_TREE;
8892 char *line, *found;
8894 if (!decl)
8895 return NULL_TREE;
8897 if (cl == NULL_TREE)
8898 cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
8900 EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
8901 EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
8903 line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
8904 EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
8906 found = strstr ((const char *)line,
8907 (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
8908 if (found)
8909 EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
8911 return cl;
8914 /* Look for a simple name in the single-type import list */
8916 static tree
8917 find_name_in_single_imports (name)
8918 tree name;
8920 tree node;
8922 for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
8923 if (TREE_VALUE (node) == name)
8924 return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
8926 return NULL_TREE;
8929 /* Process all single-type import. */
8931 static int
8932 process_imports ()
8934 tree import;
8935 int error_found;
8937 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
8939 tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
8941 /* Don't load twice something already defined. */
8942 if (IDENTIFIER_CLASS_VALUE (to_be_found))
8943 continue;
8944 QUALIFIED_P (to_be_found) = 1;
8945 load_class (to_be_found, 0);
8946 error_found =
8947 check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
8948 if (!IDENTIFIER_CLASS_VALUE (to_be_found))
8950 parse_error_context (TREE_PURPOSE (import),
8951 "Class or interface `%s' not found in import",
8952 IDENTIFIER_POINTER (to_be_found));
8953 return 1;
8955 if (error_found)
8956 return 1;
8958 return 0;
8961 /* Possibly find a class imported by a single-type import statement. Return
8962 1 if an error occured, 0 otherwise. */
8964 static int
8965 find_in_imports (class_type)
8966 tree class_type;
8968 tree import;
8970 for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
8971 if (TREE_VALUE (import) == TYPE_NAME (class_type))
8973 TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
8974 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
8976 return 0;
8979 static int
8980 note_possible_classname (name, len)
8981 const char *name;
8982 int len;
8984 tree node;
8985 if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
8986 len = len - 5;
8987 else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
8988 len = len - 6;
8989 else
8990 return 0;
8991 node = ident_subst (name, len, "", '/', '.', "");
8992 IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
8993 QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
8994 return 1;
8997 /* Read a import directory, gathering potential match for further type
8998 references. Indifferently reads a filesystem or a ZIP archive
8999 directory. */
9001 static void
9002 read_import_dir (wfl)
9003 tree wfl;
9005 tree package_id = EXPR_WFL_NODE (wfl);
9006 const char *package_name = IDENTIFIER_POINTER (package_id);
9007 int package_length = IDENTIFIER_LENGTH (package_id);
9008 DIR *dirp = NULL;
9009 JCF *saved_jcf = current_jcf;
9011 int found = 0;
9012 int k;
9013 void *entry;
9014 struct buffer filename[1];
9017 if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9018 return;
9019 IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9021 BUFFER_INIT (filename);
9022 buffer_grow (filename, package_length + 100);
9024 for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9026 const char *entry_name = jcf_path_name (entry);
9027 int entry_length = strlen (entry_name);
9028 if (jcf_path_is_zipfile (entry))
9030 ZipFile *zipf;
9031 buffer_grow (filename, entry_length);
9032 memcpy (filename->data, entry_name, entry_length - 1);
9033 filename->data[entry_length-1] = '\0';
9034 zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9035 if (zipf == NULL)
9036 error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9037 else
9039 ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9040 BUFFER_RESET (filename);
9041 for (k = 0; k < package_length; k++)
9043 char ch = package_name[k];
9044 *filename->ptr++ = ch == '.' ? '/' : ch;
9046 *filename->ptr++ = '/';
9048 for (k = 0; k < zipf->count; k++, zipd = ZIPDIR_NEXT (zipd))
9050 const char *current_entry = ZIPDIR_FILENAME (zipd);
9051 int current_entry_len = zipd->filename_length;
9053 if (current_entry_len >= BUFFER_LENGTH (filename)
9054 && strncmp (filename->data, current_entry,
9055 BUFFER_LENGTH (filename)) != 0)
9056 continue;
9057 found |= note_possible_classname (current_entry,
9058 current_entry_len);
9062 else
9064 BUFFER_RESET (filename);
9065 buffer_grow (filename, entry_length + package_length + 4);
9066 strcpy (filename->data, entry_name);
9067 filename->ptr = filename->data + entry_length;
9068 for (k = 0; k < package_length; k++)
9070 char ch = package_name[k];
9071 *filename->ptr++ = ch == '.' ? '/' : ch;
9073 *filename->ptr = '\0';
9075 dirp = opendir (filename->data);
9076 if (dirp == NULL)
9077 continue;
9078 *filename->ptr++ = '/';
9079 for (;;)
9081 int len;
9082 const char *d_name;
9083 struct dirent *direntp = readdir (dirp);
9084 if (!direntp)
9085 break;
9086 d_name = direntp->d_name;
9087 len = strlen (direntp->d_name);
9088 buffer_grow (filename, len+1);
9089 strcpy (filename->ptr, d_name);
9090 found |= note_possible_classname (filename->data + entry_length,
9091 package_length+len+1);
9093 if (dirp)
9094 closedir (dirp);
9098 free (filename->data);
9100 /* Here we should have a unified way of retrieving an entry, to be
9101 indexed. */
9102 if (!found)
9104 static int first = 1;
9105 if (first)
9107 error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9108 java_error_count++;
9109 first = 0;
9111 else
9112 parse_error_context (wfl, "Package `%s' not found in import",
9113 package_name);
9114 current_jcf = saved_jcf;
9115 return;
9117 current_jcf = saved_jcf;
9120 /* Possibly find a type in the import on demands specified
9121 types. Returns 1 if an error occured, 0 otherwise. Run throught the
9122 entire list, to detected potential double definitions. */
9124 static int
9125 find_in_imports_on_demand (class_type)
9126 tree class_type;
9128 tree node, import, node_to_use = NULL_TREE;
9129 int seen_once = -1;
9130 tree cl = NULL_TREE;
9132 for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9134 const char *id_name;
9135 obstack_grow (&temporary_obstack,
9136 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9137 IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9138 obstack_1grow (&temporary_obstack, '.');
9139 obstack_grow0 (&temporary_obstack,
9140 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9141 IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9142 id_name = obstack_finish (&temporary_obstack);
9144 node = maybe_get_identifier (id_name);
9145 if (node && IS_A_CLASSFILE_NAME (node))
9147 if (seen_once < 0)
9149 cl = TREE_PURPOSE (import);
9150 seen_once = 1;
9151 node_to_use = node;
9153 else
9155 seen_once++;
9156 parse_error_context
9157 (import, "Type `%s' also potentially defined in package `%s'",
9158 IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9159 IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9164 if (seen_once == 1)
9166 /* Setup lineno so that it refers to the line of the import (in
9167 case we parse a class file and encounter errors */
9168 tree decl;
9169 int saved_lineno = lineno;
9170 lineno = EXPR_WFL_LINENO (cl);
9171 TYPE_NAME (class_type) = node_to_use;
9172 QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9173 decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9174 /* If there is no DECL set for the class or if the class isn't
9175 loaded and not seen in source yet, the load */
9176 if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9177 && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9178 load_class (node_to_use, 0);
9179 lineno = saved_lineno;
9180 return check_pkg_class_access (TYPE_NAME (class_type), cl);
9182 else
9183 return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9186 static tree
9187 resolve_package (pkg, next)
9188 tree pkg, *next;
9190 tree current, acc;
9191 tree type_name = NULL_TREE;
9192 const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9194 /* The trick is to determine when the package name stops and were
9195 the name of something contained in the package starts. Then we
9196 return a fully qualified name of what we want to get. */
9198 /* Do a quick search on well known package names */
9199 if (!strncmp (name, "java.lang.reflect", 17))
9201 *next =
9202 TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9203 type_name = lookup_package_type (name, 17);
9205 else if (!strncmp (name, "java.lang", 9))
9207 *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9208 type_name = lookup_package_type (name, 9);
9211 /* If we found something here, return */
9212 if (type_name)
9213 return type_name;
9215 *next = EXPR_WFL_QUALIFICATION (pkg);
9217 /* Try the current package. */
9218 if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),
9219 IDENTIFIER_LENGTH (ctxp->package)))
9221 type_name =
9222 lookup_package_type_and_set_next (name,
9223 IDENTIFIER_LENGTH (ctxp->package),
9224 next );
9225 if (type_name)
9226 return type_name;
9229 /* Search in imported package */
9230 for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9232 tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9233 int len = IDENTIFIER_LENGTH (current_pkg_name);
9234 if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9236 tree left, dummy;
9238 breakdown_qualified (&left, &dummy, current_pkg_name);
9239 len = IDENTIFIER_LENGTH (left);
9240 type_name = lookup_package_type_and_set_next (name, len, next);
9241 if (type_name)
9242 break;
9246 /* Try to progressively construct a type name */
9247 if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9248 for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg);
9249 current; current = TREE_CHAIN (current))
9251 acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9252 if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9254 type_name = acc;
9255 *next = TREE_CHAIN (current);
9256 break;
9259 return type_name;
9262 static tree
9263 lookup_package_type_and_set_next (name, len, next)
9264 const char *name;
9265 int len;
9266 tree *next;
9268 const char *ptr;
9269 tree type_name = lookup_package_type (name, len);
9271 if (!type_name)
9272 return NULL;
9274 ptr = IDENTIFIER_POINTER (type_name);
9275 while (ptr && (ptr = strchr (ptr, '.')))
9277 *next = TREE_CHAIN (*next);
9278 ptr++;
9280 return type_name;
9283 static tree
9284 lookup_package_type (name, from)
9285 const char *name;
9286 int from;
9288 char subname [128];
9289 const char *sub = &name[from+1];
9290 while (*sub != '.' && *sub)
9291 sub++;
9292 strncpy (subname, name, sub-name);
9293 subname [sub-name] = '\0';
9294 return get_identifier (subname);
9297 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9298 access violations were found, 1 otherwise. */
9300 static int
9301 check_pkg_class_access (class_name, cl)
9302 tree class_name;
9303 tree cl;
9305 tree type;
9307 if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9308 return 0;
9310 if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9311 return 0;
9313 if (!CLASS_PUBLIC (TYPE_NAME (type)))
9315 /* Access to a private class within the same package is
9316 allowed. */
9317 tree l, r;
9318 breakdown_qualified (&l, &r, class_name);
9319 if (l == ctxp->package)
9320 return 0;
9322 parse_error_context
9323 (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9324 (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9325 IDENTIFIER_POINTER (class_name));
9326 return 1;
9328 return 0;
9331 /* Local variable declaration. */
9333 static void
9334 declare_local_variables (modifier, type, vlist)
9335 int modifier;
9336 tree type;
9337 tree vlist;
9339 tree decl, current, saved_type;
9340 tree type_wfl = NULL_TREE;
9341 int must_chain = 0;
9342 int final_p = 0;
9344 /* Push a new block if statements were seen between the last time we
9345 pushed a block and now. Keep a cound of block to close */
9346 if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9348 tree body = GET_CURRENT_BLOCK (current_function_decl);
9349 tree b = enter_block ();
9350 BLOCK_EXPR_ORIGIN (b) = body;
9353 if (modifier)
9355 int i;
9356 for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9357 if (modifier == ACC_FINAL)
9358 final_p = 1;
9359 else
9361 parse_error_context
9362 (ctxp->modifier_ctx [i],
9363 "Only `final' is allowed as a local variables modifier");
9364 return;
9368 /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9369 hold the TYPE value if a new incomplete has to be created (as
9370 opposed to being found already existing and reused). */
9371 SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9373 /* If TYPE is fully resolved and we don't have a reference, make one */
9374 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9376 /* Go through all the declared variables */
9377 for (current = vlist, saved_type = type; current;
9378 current = TREE_CHAIN (current), type = saved_type)
9380 tree other, real_type;
9381 tree wfl = TREE_PURPOSE (current);
9382 tree name = EXPR_WFL_NODE (wfl);
9383 tree init = TREE_VALUE (current);
9385 /* Process NAME, as it may specify extra dimension(s) for it */
9386 type = build_array_from_name (type, type_wfl, name, &name);
9388 /* Variable redefinition check */
9389 if ((other = lookup_name_in_blocks (name)))
9391 variable_redefinition_error (wfl, name, TREE_TYPE (other),
9392 DECL_SOURCE_LINE (other));
9393 continue;
9396 /* Type adjustment. We may have just readjusted TYPE because
9397 the variable specified more dimensions. Make sure we have
9398 a reference if we can and don't have one already. */
9399 PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9401 real_type = GET_REAL_TYPE (type);
9402 /* Never layout this decl. This will be done when its scope
9403 will be entered */
9404 decl = build_decl (VAR_DECL, name, real_type);
9405 LOCAL_FINAL (decl) = final_p;
9406 BLOCK_CHAIN_DECL (decl);
9408 /* If doing xreferencing, replace the line number with the WFL
9409 compound value */
9410 if (flag_emit_xref)
9411 DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9413 /* Don't try to use an INIT statement when an error was found */
9414 if (init && java_error_count)
9415 init = NULL_TREE;
9417 /* Add the initialization function to the current function's code */
9418 if (init)
9420 /* Name might have been readjusted */
9421 EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9422 MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9423 java_method_add_stmt (current_function_decl,
9424 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9425 init));
9428 /* Setup dependency the type of the decl */
9429 if (must_chain)
9431 jdep *dep;
9432 register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9433 dep = CLASSD_LAST (ctxp->classd_list);
9434 JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9437 SOURCE_FRONTEND_DEBUG (("Defined locals"));
9440 /* Called during parsing. Build decls from argument list. */
9442 static void
9443 source_start_java_method (fndecl)
9444 tree fndecl;
9446 tree tem;
9447 tree parm_decl;
9448 int i;
9449 #if 0
9450 int flag_inner = DECL_CONSTRUCTOR_P (fndecl)
9451 && (INNER_CLASS_TYPE_P (DECL_CONTEXT (fndecl)) ? 1 : 0);
9452 #endif
9454 if (!fndecl)
9455 return;
9457 current_function_decl = fndecl;
9459 /* New scope for the function */
9460 enter_block ();
9461 for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9462 tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9464 tree type = TREE_VALUE (tem);
9465 tree name = TREE_PURPOSE (tem);
9467 /* If type is incomplete. Create an incomplete decl and ask for
9468 the decl to be patched later */
9469 if (INCOMPLETE_TYPE_P (type))
9471 jdep *jdep;
9472 tree real_type = GET_REAL_TYPE (type);
9473 parm_decl = build_decl (PARM_DECL, name, real_type);
9474 type = obtain_incomplete_type (type);
9475 register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9476 jdep = CLASSD_LAST (ctxp->classd_list);
9477 JDEP_MISC (jdep) = name;
9478 JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9480 else
9481 parm_decl = build_decl (PARM_DECL, name, type);
9483 /* Remember if a local variable was declared final (via its
9484 TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9485 if (ARG_FINAL_P (tem))
9486 LOCAL_FINAL (parm_decl) = 1;
9488 BLOCK_CHAIN_DECL (parm_decl);
9490 #if 0
9491 /* If this is a constructor of a inner class, hide the extra
9492 this$<n> parameter */
9493 if (i == 0 && flag_inner)
9495 tree link = TREE_CHAIN (tem);
9496 tree type = DECL_CONTEXT (TYPE_NAME (DECL_CONTEXT (fndecl)));
9498 type = build_pointer_type (TREE_TYPE (type));
9499 parm_decl = build_decl (PARM_DECL,
9500 build_current_thisn (current_class), type);
9501 BLOCK_CHAIN_DECL (parm_decl);
9502 /* We hide the this$<n> decl in the name field of its
9503 parameter declaration. */
9504 parm_decl = build_tree_list (DECL_NAME (parm_decl), type);
9505 TREE_CHAIN (tem) = parm_decl;
9506 TREE_CHAIN (parm_decl) = link;
9507 tem = parm_decl;
9508 i++;
9510 #endif
9513 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9514 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9515 nreverse (tem);
9516 DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9517 DECL_MAX_LOCALS (current_function_decl) = i;
9520 /* Called during parsing. Creates an artificial method declaration. */
9522 static tree
9523 create_artificial_method (class, flags, type, name, args)
9524 tree class;
9525 int flags;
9526 tree type, name, args;
9528 tree mdecl;
9530 java_parser_context_save_global ();
9531 lineno = 0;
9532 mdecl = make_node (FUNCTION_TYPE);
9533 TREE_TYPE (mdecl) = type;
9534 TYPE_ARG_TYPES (mdecl) = args;
9535 mdecl = add_method (class, flags, name, build_java_signature (mdecl));
9536 java_parser_context_restore_global ();
9537 DECL_ARTIFICIAL (mdecl) = 1;
9538 return mdecl;
9541 /* Starts the body if an artifical method. */
9543 static void
9544 start_artificial_method_body (mdecl)
9545 tree mdecl;
9547 DECL_SOURCE_LINE (mdecl) = 1;
9548 DECL_SOURCE_LINE_MERGE (mdecl, 1);
9549 source_start_java_method (mdecl);
9550 enter_block ();
9553 static void
9554 end_artificial_method_body (mdecl)
9555 tree mdecl;
9557 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9558 exit_block ();
9561 /* Called during expansion. Push decls formerly built from argument
9562 list so they're usable during expansion. */
9564 static void
9565 expand_start_java_method (fndecl)
9566 tree fndecl;
9568 tree tem, *ptr;
9570 current_function_decl = fndecl;
9572 if (! quiet_flag)
9573 fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9574 announce_function (fndecl);
9575 if (! quiet_flag)
9576 fprintf (stderr, "]");
9578 pushlevel (1); /* Prepare for a parameter push */
9579 ptr = &DECL_ARGUMENTS (fndecl);
9580 tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9581 while (tem)
9583 tree next = TREE_CHAIN (tem);
9584 tree type = TREE_TYPE (tem);
9585 if (PROMOTE_PROTOTYPES
9586 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9587 && INTEGRAL_TYPE_P (type))
9588 type = integer_type_node;
9589 DECL_ARG_TYPE (tem) = type;
9590 layout_decl (tem, 0);
9591 pushdecl (tem);
9592 *ptr = tem;
9593 ptr = &TREE_CHAIN (tem);
9594 tem = next;
9596 *ptr = NULL_TREE;
9597 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9598 lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9601 /* Terminate a function and expand its body. */
9603 static void
9604 source_end_java_method ()
9606 tree fndecl = current_function_decl;
9607 int flag_asynchronous_exceptions = asynchronous_exceptions;
9609 if (!fndecl)
9610 return;
9612 java_parser_context_save_global ();
9613 lineno = ctxp->last_ccb_indent1;
9615 /* Set EH language codes */
9616 java_set_exception_lang_code ();
9618 /* Turn function bodies with only a NOP expr null, so they don't get
9619 generated at all and we won't get warnings when using the -W
9620 -Wall flags. */
9621 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9622 BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9624 /* Generate function's code */
9625 if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9626 && ! flag_emit_class_files
9627 && ! flag_emit_xref)
9628 expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9630 /* pop out of its parameters */
9631 pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9632 poplevel (1, 0, 1);
9633 BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9635 /* Generate rtl for function exit. */
9636 if (! flag_emit_class_files && ! flag_emit_xref)
9638 lineno = DECL_SOURCE_LINE_LAST (fndecl);
9639 /* Emit catch-finally clauses */
9640 emit_handlers ();
9641 expand_function_end (input_filename, lineno, 0);
9643 /* FIXME: If the current method contains any exception handlers,
9644 force asynchronous_exceptions: this is necessary because signal
9645 handlers in libjava may throw exceptions. This is far from being
9646 a perfect solution, but it's better than doing nothing at all.*/
9647 if (catch_clauses)
9648 asynchronous_exceptions = 1;
9650 /* Run the optimizers and output assembler code for this function. */
9651 rest_of_compilation (fndecl);
9654 current_function_decl = NULL_TREE;
9655 permanent_allocation (1);
9656 java_parser_context_restore_global ();
9657 asynchronous_exceptions = flag_asynchronous_exceptions;
9660 /* Record EXPR in the current function block. Complements compound
9661 expression second operand if necessary. */
9663 tree
9664 java_method_add_stmt (fndecl, expr)
9665 tree fndecl, expr;
9667 if (!GET_CURRENT_BLOCK (fndecl))
9668 return NULL_TREE;
9669 return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9672 static tree
9673 add_stmt_to_block (b, type, stmt)
9674 tree b, type, stmt;
9676 tree body = BLOCK_EXPR_BODY (b), c;
9678 if (java_error_count)
9679 return body;
9681 if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9682 return body;
9684 BLOCK_EXPR_BODY (b) = c;
9685 TREE_SIDE_EFFECTS (c) = 1;
9686 return c;
9689 /* Add STMT to EXISTING if possible, otherwise create a new
9690 COMPOUND_EXPR and add STMT to it. */
9692 static tree
9693 add_stmt_to_compound (existing, type, stmt)
9694 tree existing, type, stmt;
9696 if (existing)
9697 return build (COMPOUND_EXPR, type, existing, stmt);
9698 else
9699 return stmt;
9702 /* Hold THIS for the scope of the current public method decl. */
9703 static tree current_this;
9705 void java_layout_seen_class_methods ()
9707 tree previous_list = all_class_list;
9708 tree end = NULL_TREE;
9709 tree current;
9711 while (1)
9713 for (current = previous_list;
9714 current != end; current = TREE_CHAIN (current))
9715 layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9717 if (previous_list != all_class_list)
9719 end = previous_list;
9720 previous_list = all_class_list;
9722 else
9723 break;
9727 void
9728 java_reorder_fields ()
9730 static tree stop_reordering = NULL_TREE;
9732 tree current;
9733 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9735 current_class = TREE_TYPE (TREE_VALUE (current));
9737 if (current_class == stop_reordering)
9738 break;
9740 /* Reverse the fields, but leave the dummy field in front.
9741 Fields are already ordered for Object and Class */
9742 if (TYPE_FIELDS (current_class) && current_class != object_type_node
9743 && current_class != class_type_node)
9745 /* If the dummy field is there, reverse the right fields and
9746 just layout the type for proper fields offset */
9747 if (!DECL_NAME (TYPE_FIELDS (current_class)))
9749 tree fields = TYPE_FIELDS (current_class);
9750 TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9751 TYPE_SIZE (current_class) = NULL_TREE;
9753 /* We don't have a dummy field, we need to layout the class,
9754 after having reversed the fields */
9755 else
9757 TYPE_FIELDS (current_class) =
9758 nreverse (TYPE_FIELDS (current_class));
9759 TYPE_SIZE (current_class) = NULL_TREE;
9763 stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9766 /* Layout the methods of all classes loaded in one way on an
9767 other. Check methods of source parsed classes. Then reorder the
9768 fields and layout the classes or the type of all source parsed
9769 classes */
9771 void
9772 java_layout_classes ()
9774 tree current;
9775 int save_error_count = java_error_count;
9777 /* Layout the methods of all classes seen so far */
9778 java_layout_seen_class_methods ();
9779 java_parse_abort_on_error ();
9780 all_class_list = NULL_TREE;
9782 /* Then check the methods of all parsed classes */
9783 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9784 if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9785 CHECK_METHODS (TREE_VALUE (current));
9786 java_parse_abort_on_error ();
9788 for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9790 current_class = TREE_TYPE (TREE_VALUE (current));
9791 layout_class (current_class);
9793 /* From now on, the class is considered completely loaded */
9794 CLASS_LOADED_P (current_class) = 1;
9796 /* Error reported by the caller */
9797 if (java_error_count)
9798 return;
9801 /* We might have reloaded classes durign the process of laying out
9802 classes for code generation. We must layout the methods of those
9803 late additions, as constructor checks might use them */
9804 java_layout_seen_class_methods ();
9805 java_parse_abort_on_error ();
9808 /* Expand methods in the current set of classes rememebered for
9809 generation. */
9811 static void
9812 java_complete_expand_classes ()
9814 tree current;
9816 do_not_fold = flag_emit_xref;
9818 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9819 if (!INNER_CLASS_DECL_P (current))
9820 java_complete_expand_class (current);
9823 /* Expand the methods found in OUTER, starting first by OUTER's inner
9824 classes, if any. */
9826 static void
9827 java_complete_expand_class (outer)
9828 tree outer;
9830 tree inner_list;
9832 set_nested_class_simple_name_value (outer, 1); /* Set */
9834 /* We need to go after all inner classes and start expanding them,
9835 starting with most nested ones. We have to do that because nested
9836 classes might add functions to outer classes */
9838 for (inner_list = DECL_INNER_CLASS_LIST (outer);
9839 inner_list; inner_list = TREE_CHAIN (inner_list))
9840 java_complete_expand_class (TREE_PURPOSE (inner_list));
9842 java_complete_expand_methods (outer);
9843 set_nested_class_simple_name_value (outer, 0); /* Reset */
9846 /* Expand methods registered in CLASS_DECL. The general idea is that
9847 we expand regular methods first. This allows us get an estimate on
9848 how outer context local alias fields are really used so we can add
9849 to the constructor just enough code to initialize them properly (it
9850 also lets us generate $finit$ correctly.) Then we expand the
9851 constructors and then <clinit>. */
9853 static void
9854 java_complete_expand_methods (class_decl)
9855 tree class_decl;
9857 tree clinit, finit, decl, first_decl;
9859 current_class = TREE_TYPE (class_decl);
9861 /* Initialize a new constant pool */
9862 init_outgoing_cpool ();
9864 /* Pre-expand <clinit> to figure whether we really need it or
9865 not. If we do need it, we pre-expand the static fields so they're
9866 ready to be used somewhere else. <clinit> will be fully expanded
9867 after we processed the constructors. */
9868 first_decl = TYPE_METHODS (current_class);
9869 clinit = maybe_generate_pre_expand_clinit (current_class);
9871 /* Then generate $finit$ (if we need to) because constructor will
9872 try to use it.*/
9873 if (TYPE_FINIT_STMT_LIST (current_class))
9875 finit = generate_finit (current_class);
9876 java_complete_expand_method (finit);
9879 /* Now do the constructors */
9880 for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9882 int no_body;
9884 if (!DECL_CONSTRUCTOR_P (decl))
9885 continue;
9887 no_body = !DECL_FUNCTION_BODY (decl);
9888 /* Don't generate debug info on line zero when expanding a
9889 generated constructor. */
9890 if (no_body)
9891 restore_line_number_status (1);
9893 java_complete_expand_method (decl);
9895 if (no_body)
9896 restore_line_number_status (0);
9899 /* First, do the ordinary methods. */
9900 for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
9902 /* Skip abstract or native methods */
9903 if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl)
9904 || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
9905 continue;
9906 java_complete_expand_method (decl);
9909 /* If there is indeed a <clinit>, fully expand it now */
9910 if (clinit)
9912 /* Prevent the use of `this' inside <clinit> */
9913 ctxp->explicit_constructor_p = 1;
9914 java_complete_expand_method (clinit);
9915 ctxp->explicit_constructor_p = 0;
9918 /* We might have generated a class$ that we now want to expand */
9919 if (TYPE_DOT_CLASS (current_class))
9920 java_complete_expand_method (TYPE_DOT_CLASS (current_class));
9922 /* Now verify constructor circularity (stop after the first one we
9923 prove wrong.) */
9924 if (!CLASS_INTERFACE (class_decl))
9925 for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
9926 if (DECL_CONSTRUCTOR_P (decl)
9927 && verify_constructor_circularity (decl, decl))
9928 break;
9930 /* Save the constant pool. We'll need to restore it later. */
9931 TYPE_CPOOL (current_class) = outgoing_cpool;
9934 /* Hold a list of catch clauses list. The first element of this list is
9935 the list of the catch clauses of the currently analysed try block. */
9936 static tree currently_caught_type_list;
9938 /* Attempt to create <clinit>. Pre-expand static fields so they can be
9939 safely used in some other methods/constructors. */
9941 static tree
9942 maybe_generate_pre_expand_clinit (class_type)
9943 tree class_type;
9945 tree current, mdecl;
9947 if (!TYPE_CLINIT_STMT_LIST (class_type))
9948 return NULL_TREE;
9950 /* Go through all static fields and pre expand them */
9951 for (current = TYPE_FIELDS (class_type); current;
9952 current = TREE_CHAIN (current))
9953 if (FIELD_STATIC (current))
9954 build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
9956 /* Then build the <clinit> method */
9957 mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
9958 clinit_identifier_node, end_params_node);
9959 layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
9960 mdecl, NULL_TREE);
9961 start_artificial_method_body (mdecl);
9963 /* We process the list of assignment we produced as the result of
9964 the declaration of initialized static field and add them as
9965 statement to the <clinit> method. */
9966 for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
9967 current = TREE_CHAIN (current))
9969 /* We build the assignment expression that will initialize the
9970 field to its value. There are strict rules on static
9971 initializers (8.5). FIXME */
9972 tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
9973 java_method_add_stmt (mdecl, stmt);
9976 end_artificial_method_body (mdecl);
9978 /* Now we want to place <clinit> as the last method for interface so
9979 that it doesn't interfere with the dispatch table based
9980 lookup. */
9981 if (CLASS_INTERFACE (TYPE_NAME (class_type))
9982 && TREE_CHAIN (TYPE_METHODS (class_type)))
9984 tree current =
9985 TYPE_METHODS (class_type) = TREE_CHAIN (TYPE_METHODS (class_type));
9987 while (TREE_CHAIN (current))
9988 current = TREE_CHAIN (current);
9989 TREE_CHAIN (current) = mdecl;
9990 TREE_CHAIN (mdecl) = NULL_TREE;
9993 return mdecl;
9996 /* Complete and expand a method. */
9998 static void
9999 java_complete_expand_method (mdecl)
10000 tree mdecl;
10002 current_function_decl = mdecl;
10003 /* Fix constructors before expanding them */
10004 if (DECL_CONSTRUCTOR_P (mdecl))
10005 fix_constructors (mdecl);
10007 /* Expand functions that have a body */
10008 if (DECL_FUNCTION_BODY (mdecl))
10010 tree fbody = DECL_FUNCTION_BODY (mdecl);
10011 tree block_body = BLOCK_EXPR_BODY (fbody);
10012 tree exception_copy = NULL_TREE;
10013 expand_start_java_method (mdecl);
10014 build_result_decl (mdecl);
10016 current_this
10017 = (!METHOD_STATIC (mdecl) ?
10018 BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10020 /* Purge the `throws' list of unchecked exceptions. If we're
10021 doing xref, save a copy of the list and re-install it
10022 later. */
10023 if (flag_emit_xref)
10024 exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10026 purge_unchecked_exceptions (mdecl);
10028 /* Install exceptions thrown with `throws' */
10029 PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10031 if (block_body != NULL_TREE)
10033 block_body = java_complete_tree (block_body);
10035 if (!flag_emit_xref)
10036 check_for_initialization (block_body);
10037 ctxp->explicit_constructor_p = 0;
10039 BLOCK_EXPR_BODY (fbody) = block_body;
10041 /* If we saw a return but couldn't evaluate it properly, we'll
10042 have an error_mark_node here. */
10043 if (block_body != error_mark_node
10044 && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10045 && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10046 && !flag_emit_xref)
10047 missing_return_error (current_function_decl);
10049 complete_start_java_method (mdecl);
10051 /* Don't go any further if we've found error(s) during the
10052 expansion */
10053 if (!java_error_count)
10054 source_end_java_method ();
10055 else
10057 pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10058 poplevel (1, 0, 1);
10061 /* Pop the exceptions and sanity check */
10062 POP_EXCEPTIONS();
10063 if (currently_caught_type_list)
10064 fatal ("Exception list non empty - java_complete_expand_method");
10066 if (flag_emit_xref)
10067 DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10073 /* This section of the code deals with accessing enclosing context
10074 fields either directly by using the relevant access to this$<n> or
10075 by invoking an access method crafted for that purpose. */
10077 /* Build the necessary access from an inner class to an outer
10078 class. This routine could be optimized to cache previous result
10079 (decl, current_class and returned access). When an access method
10080 needs to be generated, it always takes the form of a read. It might
10081 be later turned into a write by calling outer_field_access_fix. */
10083 static tree
10084 build_outer_field_access (id, decl)
10085 tree id, decl;
10087 tree access = NULL_TREE;
10088 tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10090 /* If decl's class is the direct outer class of the current_class,
10091 build the access as `this$<n>.<field>'. Not that we will break
10092 the `private' barrier if we're not emitting bytecodes. */
10093 if (ctx == DECL_CONTEXT (decl)
10094 && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10096 tree thisn = build_current_thisn (current_class);
10097 access = make_qualified_primary (build_wfl_node (thisn),
10098 id, EXPR_WFL_LINECOL (id));
10100 /* Otherwise, generate access methods to outer this and access the
10101 field (either using an access method or by direct access.) */
10102 else
10104 int lc = EXPR_WFL_LINECOL (id);
10106 /* Now we chain the required number of calls to the access$0 to
10107 get a hold to the enclosing instance we need, and the we
10108 build the field access. */
10109 access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10111 /* If the field is private and we're generating bytecode, then
10112 we generate an access method */
10113 if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10115 tree name = build_outer_field_access_methods (decl);
10116 access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10117 name, access, NULL_TREE);
10119 /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10120 Once again we break the `private' access rule from a foreign
10121 class. */
10122 else
10123 access = make_qualified_primary (access, id, lc);
10125 return resolve_expression_name (access, NULL);
10128 /* Return a non zero value if NODE describes an outer field inner
10129 access. */
10131 static int
10132 outer_field_access_p (type, decl)
10133 tree type, decl;
10135 if (!INNER_CLASS_TYPE_P (type)
10136 || TREE_CODE (decl) != FIELD_DECL
10137 || DECL_CONTEXT (decl) == type)
10138 return 0;
10140 for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10141 type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10143 if (type == DECL_CONTEXT (decl))
10144 return 1;
10145 if (!DECL_CONTEXT (TYPE_NAME (type)))
10146 break;
10149 return 0;
10152 /* Return a non zero value if NODE represents an outer field inner
10153 access that was been already expanded. As a side effect, it returns
10154 the name of the field being accessed and the argument passed to the
10155 access function, suitable for a regeneration of the access method
10156 call if necessary. */
10158 static int
10159 outer_field_expanded_access_p (node, name, arg_type, arg)
10160 tree node, *name, *arg_type, *arg;
10162 int identified = 0;
10164 if (TREE_CODE (node) != CALL_EXPR)
10165 return 0;
10167 /* Well, gcj generates slightly different tree nodes when compiling
10168 to native or bytecodes. It's the case for function calls. */
10170 if (flag_emit_class_files
10171 && TREE_CODE (node) == CALL_EXPR
10172 && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10173 identified = 1;
10174 else if (!flag_emit_class_files)
10176 node = TREE_OPERAND (node, 0);
10178 if (node && TREE_OPERAND (node, 0)
10179 && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10181 node = TREE_OPERAND (node, 0);
10182 if (TREE_OPERAND (node, 0)
10183 && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10184 && (OUTER_FIELD_ACCESS_IDENTIFIER_P
10185 (DECL_NAME (TREE_OPERAND (node, 0)))))
10186 identified = 1;
10190 if (identified && name && arg_type && arg)
10192 tree argument = TREE_OPERAND (node, 1);
10193 *name = DECL_NAME (TREE_OPERAND (node, 0));
10194 *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10195 *arg = TREE_VALUE (argument);
10197 return identified;
10200 /* Detect in NODE an outer field read access from an inner class and
10201 transform it into a write with RHS as an argument. This function is
10202 called from the java_complete_lhs when an assignment to a LHS can
10203 be identified. */
10205 static tree
10206 outer_field_access_fix (wfl, node, rhs)
10207 tree wfl, node, rhs;
10209 tree name, arg_type, arg;
10211 if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10213 /* At any rate, check whether we're trying to assign a value to
10214 a final. */
10215 tree accessed = (JDECL_P (node) ? node :
10216 (TREE_CODE (node) == COMPONENT_REF ?
10217 TREE_OPERAND (node, 1) : node));
10218 if (check_final_assignment (accessed, wfl))
10219 return error_mark_node;
10221 node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl),
10222 arg_type, name, arg, rhs);
10223 return java_complete_tree (node);
10225 return NULL_TREE;
10228 /* Construct the expression that calls an access method:
10229 <type>.access$<n>(<arg1> [, <arg2>]);
10231 ARG2 can be NULL and will be omitted in that case. It will denote a
10232 read access. */
10234 static tree
10235 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10236 int lc;
10237 tree type, access_method_name, arg1, arg2;
10239 tree args, cn, access;
10241 args = arg1 ? arg1 :
10242 build_wfl_node (build_current_thisn (current_class));
10243 args = build_tree_list (NULL_TREE, args);
10245 if (arg2)
10246 args = tree_cons (NULL_TREE, arg2, args);
10248 access = build_method_invocation (build_wfl_node (access_method_name), args);
10249 cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10250 return make_qualified_primary (cn, access, lc);
10253 static tree
10254 build_new_access_id ()
10256 static int access_n_counter = 1;
10257 char buffer [128];
10259 sprintf (buffer, "access$%d", access_n_counter++);
10260 return get_identifier (buffer);
10263 /* Create the static access functions for the outer field DECL. We define a
10264 read:
10265 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10266 return inst$.field;
10268 and a write access:
10269 TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10270 TREE_TYPE (<field>) value$) {
10271 return inst$.field = value$;
10273 We should have a usage flags on the DECL so we can lazily turn the ones
10274 we're using for code generation. FIXME.
10277 static tree
10278 build_outer_field_access_methods (decl)
10279 tree decl;
10281 tree id, args, stmt, mdecl;
10283 /* Check point, to be removed. FIXME */
10284 if (FIELD_INNER_ACCESS (decl)
10285 && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10286 abort ();
10288 if (FIELD_INNER_ACCESS (decl))
10289 return FIELD_INNER_ACCESS (decl);
10291 push_obstacks (&permanent_obstack, &permanent_obstack);
10293 /* Create the identifier and a function named after it. */
10294 id = build_new_access_id ();
10296 /* The identifier is marked as bearing the name of a generated write
10297 access function for outer field accessed from inner classes. */
10298 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10300 /* Create the read access */
10301 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10302 TREE_CHAIN (args) = end_params_node;
10303 stmt = make_qualified_primary (build_wfl_node (inst_id),
10304 build_wfl_node (DECL_NAME (decl)), 0);
10305 stmt = build_return (0, stmt);
10306 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10307 TREE_TYPE (decl), id, args, stmt);
10308 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10310 /* Create the write access method */
10311 args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10312 TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10313 TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10314 stmt = make_qualified_primary (build_wfl_node (inst_id),
10315 build_wfl_node (DECL_NAME (decl)), 0);
10316 stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10317 build_wfl_node (wpv_id)));
10319 mdecl = build_outer_field_access_method (DECL_CONTEXT (decl),
10320 TREE_TYPE (decl), id, args, stmt);
10321 DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10322 pop_obstacks ();
10324 /* Return the access name */
10325 return FIELD_INNER_ACCESS (decl) = id;
10328 /* Build an field access method NAME. */
10330 static tree
10331 build_outer_field_access_method (class, type, name, args, body)
10332 tree class, type, name, args, body;
10334 tree saved_current_function_decl, mdecl;
10336 /* Create the method */
10337 mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10338 fix_method_argument_names (args, mdecl);
10339 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10341 /* Attach the method body. */
10342 saved_current_function_decl = current_function_decl;
10343 start_artificial_method_body (mdecl);
10344 java_method_add_stmt (mdecl, body);
10345 end_artificial_method_body (mdecl);
10346 current_function_decl = saved_current_function_decl;
10348 return mdecl;
10352 /* This section deals with building access function necessary for
10353 certain kinds of method invocation from inner classes. */
10355 static tree
10356 build_outer_method_access_method (decl)
10357 tree decl;
10359 tree saved_current_function_decl, mdecl;
10360 tree args = NULL_TREE, call_args = NULL_TREE;
10361 tree carg, id, body, class;
10362 char buffer [80];
10363 int parm_id_count = 0;
10365 /* Test this abort with an access to a private field */
10366 if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10367 abort ();
10369 /* Check the cache first */
10370 if (DECL_FUNCTION_INNER_ACCESS (decl))
10371 return DECL_FUNCTION_INNER_ACCESS (decl);
10373 class = DECL_CONTEXT (decl);
10375 /* Obtain an access identifier and mark it */
10376 id = build_new_access_id ();
10377 OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10379 push_obstacks (&permanent_obstack, &permanent_obstack);
10381 carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10382 /* Create the arguments, as much as the original */
10383 for (; carg && carg != end_params_node;
10384 carg = TREE_CHAIN (carg))
10386 sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10387 args = chainon (args, build_tree_list (get_identifier (buffer),
10388 TREE_VALUE (carg)));
10390 args = chainon (args, end_params_node);
10392 /* Create the method */
10393 mdecl = create_artificial_method (class, ACC_STATIC,
10394 TREE_TYPE (TREE_TYPE (decl)), id, args);
10395 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10396 /* There is a potential bug here. We should be able to use
10397 fix_method_argument_names, but then arg names get mixed up and
10398 eventually a constructor will have its this$0 altered and the
10399 outer context won't be assignment properly. The test case is
10400 stub.java FIXME */
10401 TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10403 /* Attach the method body. */
10404 saved_current_function_decl = current_function_decl;
10405 start_artificial_method_body (mdecl);
10407 /* The actual method invocation uses the same args. When invoking a
10408 static methods that way, we don't want to skip the first
10409 argument. */
10410 carg = args;
10411 if (!METHOD_STATIC (decl))
10412 carg = TREE_CHAIN (carg);
10413 for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10414 call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10415 call_args);
10417 body = build_method_invocation (build_wfl_node (DECL_NAME (decl)),
10418 call_args);
10419 if (!METHOD_STATIC (decl))
10420 body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)),
10421 body, 0);
10422 if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10423 body = build_return (0, body);
10424 java_method_add_stmt (mdecl,body);
10425 end_artificial_method_body (mdecl);
10426 current_function_decl = saved_current_function_decl;
10427 pop_obstacks ();
10429 /* Back tag the access function so it know what it accesses */
10430 DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10432 /* Tag the current method so it knows it has an access generated */
10433 return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10437 /* This section of the code deals with building expressions to access
10438 the enclosing instance of an inner class. The enclosing instance is
10439 kept in a generated field called this$<n>, with <n> being the
10440 inner class nesting level (starting from 0.) */
10442 /* Build an access to a given this$<n>, possibly by chaining access
10443 call to others. Access methods to this$<n> are build on the fly if
10444 necessary */
10446 static tree
10447 build_access_to_thisn (from, to, lc)
10448 tree from, to;
10449 int lc;
10451 tree access = NULL_TREE;
10453 while (from != to)
10455 tree access0_wfl, cn;
10457 maybe_build_thisn_access_method (from);
10458 access0_wfl = build_wfl_node (access0_identifier_node);
10459 cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10460 EXPR_WFL_LINECOL (access0_wfl) = lc;
10462 if (!access)
10464 access = build_current_thisn (current_class);
10465 access = build_wfl_node (access);
10467 access = build_tree_list (NULL_TREE, access);
10468 access = build_method_invocation (access0_wfl, access);
10469 access = make_qualified_primary (cn, access, lc);
10471 from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10473 return access;
10476 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10477 is returned if nothing needs to be generated. Otherwise, the method
10478 generated, fully walked and a method decl is returned.
10480 NOTE: These generated methods should be declared in a class file
10481 attribute so that they can't be referred to directly. */
10483 static tree
10484 maybe_build_thisn_access_method (type)
10485 tree type;
10487 tree mdecl, args, stmt, rtype;
10488 tree saved_current_function_decl;
10490 /* If TYPE is a top-level class, no access method is required.
10491 If there already is such an access method, bail out. */
10492 if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10493 return NULL_TREE;
10495 /* We generate the method. The method looks like:
10496 static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10498 push_obstacks (&permanent_obstack, &permanent_obstack);
10499 args = build_tree_list (inst_id, build_pointer_type (type));
10500 TREE_CHAIN (args) = end_params_node;
10501 rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10502 mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10503 access0_identifier_node, args);
10504 fix_method_argument_names (args, mdecl);
10505 layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10506 stmt = build_current_thisn (type);
10507 stmt = make_qualified_primary (build_wfl_node (inst_id),
10508 build_wfl_node (stmt), 0);
10509 stmt = build_return (0, stmt);
10511 saved_current_function_decl = current_function_decl;
10512 start_artificial_method_body (mdecl);
10513 java_method_add_stmt (mdecl, stmt);
10514 end_artificial_method_body (mdecl);
10515 current_function_decl = saved_current_function_decl;
10516 pop_obstacks ();
10518 CLASS_ACCESS0_GENERATED_P (type) = 1;
10520 return mdecl;
10523 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10524 the first level of innerclassing. this$1 for the next one, etc...
10525 This function can be invoked with TYPE to NULL, available and then
10526 has to count the parser context. */
10528 static tree
10529 build_current_thisn (type)
10530 tree type;
10532 static int saved_i = -1;
10533 static tree saved_thisn = NULL_TREE;
10535 tree decl;
10536 char buffer [80];
10537 int i = 0;
10539 if (type)
10541 static tree saved_type = NULL_TREE;
10542 static int saved_type_i = 0;
10544 if (type == saved_type)
10545 i = saved_type_i;
10546 else
10548 for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type));
10549 decl; decl = DECL_CONTEXT (decl), i++)
10552 saved_type = type;
10553 saved_type_i = i;
10556 else
10557 i = list_length (GET_CPC_LIST ())-2;
10559 if (i == saved_i)
10560 return saved_thisn;
10562 sprintf (buffer, "this$%d", i);
10563 saved_i = i;
10564 saved_thisn = get_identifier (buffer);
10565 return saved_thisn;
10568 /* Return the assignement to the hidden enclosing context `this$<n>'
10569 by the second incoming parameter to the innerclass constructor. The
10570 form used is `this.this$<n> = this$<n>;'. */
10572 static tree
10573 build_thisn_assign ()
10575 if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10577 tree thisn = build_current_thisn (current_class);
10578 tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10579 build_wfl_node (thisn), 0);
10580 tree rhs = build_wfl_node (thisn);
10581 EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10582 return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10584 return NULL_TREE;
10588 /* Building the synthetic `class$' used to implement the `.class' 1.1
10589 extension for non primitive types. This method looks like:
10591 static Class class$(String type) throws NoClassDefFoundError
10593 try {return (java.lang.Class.forName (String));}
10594 catch (ClassNotFoundException e) {
10595 throw new NoClassDefFoundError(e.getMessage());}
10596 } */
10598 static tree
10599 build_dot_class_method (class)
10600 tree class;
10602 #define BWF(S) build_wfl_node (get_identifier ((S)))
10603 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10604 tree args, tmp, saved_current_function_decl, mdecl;
10605 tree stmt, throw_stmt, catch, catch_block, try_block;
10606 tree catch_clause_param;
10607 tree class_not_found_exception, no_class_def_found_error;
10609 static tree get_message_wfl, type_parm_wfl;
10611 if (!get_message_wfl)
10613 get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10614 type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10617 /* Build the arguments */
10618 args = build_tree_list (get_identifier ("type$"),
10619 build_pointer_type (string_type_node));
10620 TREE_CHAIN (args) = end_params_node;
10622 /* Build the qualified name java.lang.Class.forName */
10623 tmp = MQN (MQN (MQN (BWF ("java"),
10624 BWF ("lang")), BWF ("Class")), BWF ("forName"));
10626 /* For things we have to catch and throw */
10627 class_not_found_exception =
10628 lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10629 no_class_def_found_error =
10630 lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10631 load_class (class_not_found_exception, 1);
10632 load_class (no_class_def_found_error, 1);
10634 /* Create the "class$" function */
10635 mdecl = create_artificial_method (class, ACC_STATIC,
10636 build_pointer_type (class_type_node),
10637 get_identifier ("class$"), args);
10638 DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10639 no_class_def_found_error);
10641 /* We start by building the try block. We need to build:
10642 return (java.lang.Class.forName (type)); */
10643 stmt = build_method_invocation (tmp,
10644 build_tree_list (NULL_TREE, type_parm_wfl));
10645 stmt = build_return (0, stmt);
10646 /* Put it in a block. That's the try block */
10647 try_block = build_expr_block (stmt, NULL_TREE);
10649 /* Now onto the catch block. We start by building the expression
10650 throwing a new exception:
10651 throw new NoClassDefFoundError (_.getMessage); */
10652 throw_stmt = make_qualified_name (build_wfl_node (wpv_id),
10653 get_message_wfl, 0);
10654 throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10656 /* Build new NoClassDefFoundError (_.getMessage) */
10657 throw_stmt = build_new_invocation
10658 (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10659 build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10661 /* Build the throw, (it's too early to use BUILD_THROW) */
10662 throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10664 /* Build the catch block to encapsulate all this. We begin by
10665 building an decl for the catch clause parameter and link it to
10666 newly created block, the catch block. */
10667 catch_clause_param =
10668 build_decl (VAR_DECL, wpv_id,
10669 build_pointer_type (class_not_found_exception));
10670 catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10672 /* We initialize the variable with the exception handler. */
10673 catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10674 soft_exceptioninfo_call_node);
10675 add_stmt_to_block (catch_block, NULL_TREE, catch);
10677 /* We add the statement throwing the new exception */
10678 add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10680 /* Build a catch expression for all this */
10681 catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10683 /* Build the try/catch sequence */
10684 stmt = build_try_statement (0, try_block, catch_block);
10686 fix_method_argument_names (args, mdecl);
10687 layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10688 saved_current_function_decl = current_function_decl;
10689 start_artificial_method_body (mdecl);
10690 java_method_add_stmt (mdecl, stmt);
10691 end_artificial_method_body (mdecl);
10692 current_function_decl = saved_current_function_decl;
10693 TYPE_DOT_CLASS (class) = mdecl;
10695 return mdecl;
10698 static tree
10699 build_dot_class_method_invocation (name)
10700 tree name;
10702 tree s = make_node (STRING_CST);
10703 TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10704 TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10705 TREE_STRING_LENGTH (s)+1);
10706 strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10707 return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10708 build_tree_list (NULL_TREE, s));
10711 /* This section of the code deals with constructor. */
10713 /* Craft a body for default constructor. Patch existing constructor
10714 bodies with call to super() and field initialization statements if
10715 necessary. */
10717 static void
10718 fix_constructors (mdecl)
10719 tree mdecl;
10721 tree body = DECL_FUNCTION_BODY (mdecl);
10722 tree thisn_assign, compound = NULL_TREE;
10723 tree class_type = DECL_CONTEXT (mdecl);
10725 if (!body)
10727 /* It is an error for the compiler to generate a default
10728 constructor if the superclass doesn't have a constructor that
10729 takes no argument, or the same args for an anonymous class */
10730 if (verify_constructor_super (mdecl))
10732 tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10733 tree save = DECL_NAME (mdecl);
10734 const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10735 DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10736 parse_error_context
10737 (lookup_cl (TYPE_NAME (class_type)),
10738 "No constructor matching `%s' found in class `%s'",
10739 lang_printable_name (mdecl, 0), n);
10740 DECL_NAME (mdecl) = save;
10743 /* The constructor body must be crafted by hand. It's the
10744 constructor we defined when we realize we didn't have the
10745 CLASSNAME() constructor */
10746 start_artificial_method_body (mdecl);
10748 /* We don't generate a super constructor invocation if we're
10749 compiling java.lang.Object. build_super_invocation takes care
10750 of that. */
10751 compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10753 /* Insert the instance initializer block right here, after the
10754 super invocation. */
10755 add_instance_initializer (mdecl);
10757 /* Insert an assignment to the this$<n> hidden field, if
10758 necessary */
10759 if ((thisn_assign = build_thisn_assign ()))
10760 java_method_add_stmt (mdecl, thisn_assign);
10762 end_artificial_method_body (mdecl);
10764 /* Search for an explicit constructor invocation */
10765 else
10767 int found = 0;
10768 tree main_block = BLOCK_EXPR_BODY (body);
10770 while (body)
10771 switch (TREE_CODE (body))
10773 case CALL_EXPR:
10774 found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10775 body = NULL_TREE;
10776 break;
10777 case COMPOUND_EXPR:
10778 case EXPR_WITH_FILE_LOCATION:
10779 body = TREE_OPERAND (body, 0);
10780 break;
10781 case BLOCK:
10782 body = BLOCK_EXPR_BODY (body);
10783 break;
10784 default:
10785 found = 0;
10786 body = NULL_TREE;
10788 /* The constructor is missing an invocation of super() */
10789 if (!found)
10790 compound = add_stmt_to_compound (compound, NULL_TREE,
10791 build_super_invocation (mdecl));
10793 /* Insert the instance initializer block right here, after the
10794 super invocation. */
10795 add_instance_initializer (mdecl);
10797 /* Generate the assignment to this$<n>, if necessary */
10798 if ((thisn_assign = build_thisn_assign ()))
10799 compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10801 /* Fix the constructor main block if we're adding extra stmts */
10802 if (compound)
10804 compound = add_stmt_to_compound (compound, NULL_TREE,
10805 BLOCK_EXPR_BODY (main_block));
10806 BLOCK_EXPR_BODY (main_block) = compound;
10811 /* Browse constructors in the super class, searching for a constructor
10812 that doesn't take any argument. Return 0 if one is found, 1
10813 otherwise. If the current class is an anonymous inner class, look
10814 for something that has the same signature. */
10816 static int
10817 verify_constructor_super (mdecl)
10818 tree mdecl;
10820 tree class = CLASSTYPE_SUPER (current_class);
10821 tree sdecl;
10823 if (!class)
10824 return 0;
10826 if (ANONYMOUS_CLASS_P (current_class))
10828 tree mdecl_arg_type;
10829 SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10830 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10831 if (DECL_CONSTRUCTOR_P (sdecl))
10833 tree arg_type;
10834 for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
10835 arg_type != end_params_node &&
10836 mdecl_arg_type != end_params_node;
10837 arg_type = TREE_CHAIN (arg_type),
10838 mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
10839 if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
10840 break;
10842 if (arg_type == end_params_node &&
10843 mdecl_arg_type == end_params_node)
10844 return 0;
10847 else
10849 for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10851 if (DECL_CONSTRUCTOR_P (sdecl)
10852 && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)))
10853 == end_params_node)
10854 return 0;
10857 return 1;
10860 /* Generate code for all context remembered for code generation. */
10862 void
10863 java_expand_classes ()
10865 int save_error_count = 0;
10866 static struct parser_ctxt *saved_ctxp = NULL;
10868 java_parse_abort_on_error ();
10869 if (!(ctxp = ctxp_for_generation))
10870 return;
10871 java_layout_classes ();
10872 java_parse_abort_on_error ();
10874 saved_ctxp = ctxp_for_generation;
10875 for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10877 ctxp = ctxp_for_generation;
10878 lang_init_source (2); /* Error msgs have method prototypes */
10879 java_complete_expand_classes (); /* Complete and expand classes */
10880 java_parse_abort_on_error ();
10883 /* Find anonymous classes and expand their constructor, now they
10884 have been fixed. */
10885 for (ctxp_for_generation = saved_ctxp;
10886 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10888 tree current;
10889 ctxp = ctxp_for_generation;
10890 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10892 current_class = TREE_TYPE (current);
10893 if (ANONYMOUS_CLASS_P (current_class))
10895 tree d;
10896 for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
10898 if (DECL_CONSTRUCTOR_P (d))
10900 restore_line_number_status (1);
10901 reset_method_name (d);
10902 java_complete_expand_method (d);
10903 restore_line_number_status (0);
10904 break; /* We now there are no other ones */
10911 /* If we've found error at that stage, don't try to generate
10912 anything, unless we're emitting xrefs or checking the syntax only
10913 (but not using -fsyntax-only for the purpose of generating
10914 bytecode. */
10915 if (java_error_count && !flag_emit_xref
10916 && (!flag_syntax_only && !flag_emit_class_files))
10917 return;
10919 /* Now things are stable, go for generation of the class data. */
10920 for (ctxp_for_generation = saved_ctxp;
10921 ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10923 tree current;
10924 ctxp = ctxp_for_generation;
10925 for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10927 current_class = TREE_TYPE (current);
10928 outgoing_cpool = TYPE_CPOOL (current_class);
10929 if (flag_emit_class_files)
10930 write_classfile (current_class);
10931 if (flag_emit_xref)
10932 expand_xref (current_class);
10933 else if (! flag_syntax_only)
10934 finish_class ();
10939 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
10940 a tree list node containing RIGHT. Fore coming RIGHTs will be
10941 chained to this hook. LOCATION contains the location of the
10942 separating `.' operator. */
10944 static tree
10945 make_qualified_primary (primary, right, location)
10946 tree primary, right;
10947 int location;
10949 tree wfl;
10951 if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
10952 wfl = build_wfl_wrap (primary);
10953 else
10955 wfl = primary;
10956 /* If wfl wasn't qualified, we build a first anchor */
10957 if (!EXPR_WFL_QUALIFICATION (wfl))
10958 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
10961 /* And chain them */
10962 EXPR_WFL_LINECOL (right) = location;
10963 chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
10964 PRIMARY_P (wfl) = 1;
10965 return wfl;
10968 /* Simple merge of two name separated by a `.' */
10970 static tree
10971 merge_qualified_name (left, right)
10972 tree left, right;
10974 tree node;
10975 if (!left && !right)
10976 return NULL_TREE;
10978 if (!left)
10979 return right;
10981 if (!right)
10982 return left;
10984 obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
10985 IDENTIFIER_LENGTH (left));
10986 obstack_1grow (&temporary_obstack, '.');
10987 obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
10988 IDENTIFIER_LENGTH (right));
10989 node = get_identifier (obstack_base (&temporary_obstack));
10990 obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
10991 QUALIFIED_P (node) = 1;
10992 return node;
10995 /* Merge the two parts of a qualified name into LEFT. Set the
10996 location information of the resulting node to LOCATION, usually
10997 inherited from the location information of the `.' operator. */
10999 static tree
11000 make_qualified_name (left, right, location)
11001 tree left, right;
11002 int location;
11004 #ifdef USE_COMPONENT_REF
11005 tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11006 EXPR_WFL_LINECOL (node) = location;
11007 return node;
11008 #else
11009 tree left_id = EXPR_WFL_NODE (left);
11010 tree right_id = EXPR_WFL_NODE (right);
11011 tree wfl, merge;
11013 merge = merge_qualified_name (left_id, right_id);
11015 /* Left wasn't qualified and is now qualified */
11016 if (!QUALIFIED_P (left_id))
11018 tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11019 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11020 EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11023 wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11024 EXPR_WFL_LINECOL (wfl) = location;
11025 chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11027 EXPR_WFL_NODE (left) = merge;
11028 return left;
11029 #endif
11032 /* Extract the last identifier component of the qualified in WFL. The
11033 last identifier is removed from the linked list */
11035 static tree
11036 cut_identifier_in_qualified (wfl)
11037 tree wfl;
11039 tree q;
11040 tree previous = NULL_TREE;
11041 for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11042 if (!TREE_CHAIN (q))
11044 if (!previous)
11045 fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11046 TREE_CHAIN (previous) = NULL_TREE;
11047 return TREE_PURPOSE (q);
11051 /* Resolve the expression name NAME. Return its decl. */
11053 static tree
11054 resolve_expression_name (id, orig)
11055 tree id;
11056 tree *orig;
11058 tree name = EXPR_WFL_NODE (id);
11059 tree decl;
11061 /* 6.5.5.1: Simple expression names */
11062 if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11064 /* 15.13.1: NAME can appear within the scope of a local variable
11065 declaration */
11066 if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11067 return decl;
11069 /* 15.13.1: NAME can appear within a class declaration */
11070 else
11072 decl = lookup_field_wrapper (current_class, name);
11074 /* Last chance: if we're within the context of an inner
11075 class, we might be trying to access a local variable
11076 defined in an outer context. We try to look for it
11077 now. */
11078 if (!decl && INNER_CLASS_TYPE_P (current_class))
11080 char *alias_buffer;
11081 MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
11082 name = get_identifier (alias_buffer);
11083 decl = lookup_field_wrapper (current_class, name);
11084 if (decl)
11085 FIELD_LOCAL_ALIAS_USED (decl) = 1;
11088 if (decl)
11090 tree access = NULL_TREE;
11091 int fs = FIELD_STATIC (decl);
11092 /* Instance variable (8.3.1.1) can't appear within
11093 static method, static initializer or initializer for
11094 a static variable. */
11095 if (!fs && METHOD_STATIC (current_function_decl))
11097 static_ref_err (id, name, current_class);
11098 return error_mark_node;
11100 /* Instance variables can't appear as an argument of
11101 an explicit constructor invocation */
11102 if (!fs && ctxp->explicit_constructor_p)
11104 parse_error_context
11105 (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11106 return error_mark_node;
11109 /* If we're processing an inner class and we're trying
11110 to access a field belonging to an outer class, build
11111 the access to the field */
11112 if (!fs && outer_field_access_p (current_class, decl))
11113 return build_outer_field_access (id, decl);
11115 /* Otherwise build what it takes to access the field */
11116 access = build_field_ref ((fs ? NULL_TREE : current_this),
11117 DECL_CONTEXT (decl), name);
11118 if (fs && !flag_emit_class_files && !flag_emit_xref)
11119 access = build_class_init (DECL_CONTEXT (access), access);
11120 /* We may be asked to save the real field access node */
11121 if (orig)
11122 *orig = access;
11123 /* And we return what we got */
11124 return access;
11126 /* Fall down to error report on undefined variable */
11129 /* 6.5.5.2 Qualified Expression Names */
11130 else
11132 if (orig)
11133 *orig = NULL_TREE;
11134 qualify_ambiguous_name (id);
11135 /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11136 /* 15.10.2: Accessing Superclass Members using super */
11137 return resolve_field_access (id, orig, NULL);
11140 /* We've got an error here */
11141 parse_error_context (id, "Undefined variable `%s'",
11142 IDENTIFIER_POINTER (name));
11144 return error_mark_node;
11147 static void
11148 static_ref_err (wfl, field_id, class_type)
11149 tree wfl, field_id, class_type;
11151 parse_error_context
11152 (wfl,
11153 "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11154 IDENTIFIER_POINTER (field_id),
11155 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11158 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11159 We return something suitable to generate the field access. We also
11160 return the field decl in FIELD_DECL and its type in FIELD_TYPE. If
11161 recipient's address can be null. */
11163 static tree
11164 resolve_field_access (qual_wfl, field_decl, field_type)
11165 tree qual_wfl;
11166 tree *field_decl, *field_type;
11168 int is_static = 0;
11169 tree field_ref;
11170 tree decl, where_found, type_found;
11172 if (resolve_qualified_expression_name (qual_wfl, &decl,
11173 &where_found, &type_found))
11174 return error_mark_node;
11176 /* Resolve the LENGTH field of an array here */
11177 if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11178 && ! flag_emit_class_files && ! flag_emit_xref)
11180 tree length = build_java_array_length_access (where_found);
11181 field_ref =
11182 build_java_arraynull_check (type_found, length, int_type_node);
11184 /* We might have been trying to resolve field.method(). In which
11185 case, the resolution is over and decl is the answer */
11186 else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11187 field_ref = decl;
11188 else if (JDECL_P (decl))
11190 int static_final_found = 0;
11191 if (!type_found)
11192 type_found = DECL_CONTEXT (decl);
11193 is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11194 if (FIELD_FINAL (decl)
11195 && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11196 && DECL_LANG_SPECIFIC (decl)
11197 && DECL_INITIAL (decl))
11199 field_ref = DECL_INITIAL (decl);
11200 static_final_found = 1;
11202 else
11203 field_ref = build_field_ref ((is_static && !flag_emit_xref?
11204 NULL_TREE : where_found),
11205 type_found, DECL_NAME (decl));
11206 if (field_ref == error_mark_node)
11207 return error_mark_node;
11208 if (is_static && !static_final_found
11209 && !flag_emit_class_files && !flag_emit_xref)
11210 field_ref = build_class_init (type_found, field_ref);
11212 else
11213 field_ref = decl;
11215 if (field_decl)
11216 *field_decl = decl;
11217 if (field_type)
11218 *field_type = (QUAL_DECL_TYPE (decl) ?
11219 QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11220 return field_ref;
11223 /* If NODE is an access to f static field, strip out the class
11224 initialization part and return the field decl, otherwise, return
11225 NODE. */
11227 static tree
11228 strip_out_static_field_access_decl (node)
11229 tree node;
11231 if (TREE_CODE (node) == COMPOUND_EXPR)
11233 tree op1 = TREE_OPERAND (node, 1);
11234 if (TREE_CODE (op1) == COMPOUND_EXPR)
11236 tree call = TREE_OPERAND (op1, 0);
11237 if (TREE_CODE (call) == CALL_EXPR
11238 && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11239 && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11240 == soft_initclass_node)
11241 return TREE_OPERAND (op1, 1);
11243 else if (JDECL_P (op1))
11244 return op1;
11246 return node;
11249 /* 6.5.5.2: Qualified Expression Names */
11251 static int
11252 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11253 tree wfl;
11254 tree *found_decl, *type_found, *where_found;
11256 int from_type = 0; /* Field search initiated from a type */
11257 int from_super = 0, from_cast = 0, from_qualified_this = 0;
11258 int previous_call_static = 0;
11259 int is_static;
11260 tree decl = NULL_TREE, type = NULL_TREE, q;
11261 /* For certain for of inner class instantiation */
11262 tree saved_current, saved_this;
11263 #define RESTORE_THIS_AND_CURRENT_CLASS \
11264 { current_class = saved_current; current_this = saved_this;}
11266 *type_found = *where_found = NULL_TREE;
11268 for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11270 tree qual_wfl = QUAL_WFL (q);
11271 tree ret_decl; /* for EH checking */
11272 int location; /* for EH checking */
11274 /* 15.10.1 Field Access Using a Primary */
11275 switch (TREE_CODE (qual_wfl))
11277 case CALL_EXPR:
11278 case NEW_CLASS_EXPR:
11279 /* If the access to the function call is a non static field,
11280 build the code to access it. */
11281 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11283 decl = maybe_access_field (decl, *where_found,
11284 DECL_CONTEXT (decl));
11285 if (decl == error_mark_node)
11286 return 1;
11289 /* And code for the function call */
11290 if (complete_function_arguments (qual_wfl))
11291 return 1;
11293 /* We might have to setup a new current class and a new this
11294 for the search of an inner class, relative to the type of
11295 a expression resolved as `decl'. The current values are
11296 saved and restored shortly after */
11297 saved_current = current_class;
11298 saved_this = current_this;
11299 if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11301 current_class = type;
11302 current_this = decl;
11305 if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11306 CALL_USING_SUPER (qual_wfl) = 1;
11307 location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11308 EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11309 *where_found = patch_method_invocation (qual_wfl, decl, type,
11310 &is_static, &ret_decl);
11311 if (*where_found == error_mark_node)
11313 RESTORE_THIS_AND_CURRENT_CLASS;
11314 return 1;
11316 *type_found = type = QUAL_DECL_TYPE (*where_found);
11318 /* If we're creating an inner class instance, check for that
11319 an enclosing instance is in scope */
11320 if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11321 && INNER_ENCLOSING_SCOPE_CHECK (type))
11323 parse_error_context
11324 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11325 lang_printable_name (type, 0),
11326 (!current_this ? "" :
11327 "; an explicit one must be provided when creating this inner class"));
11328 RESTORE_THIS_AND_CURRENT_CLASS;
11329 return 1;
11332 /* In case we had to change then to resolve a inner class
11333 instantiation using a primary qualified by a `new' */
11334 RESTORE_THIS_AND_CURRENT_CLASS;
11336 /* EH check */
11337 if (location)
11338 check_thrown_exceptions (location, ret_decl);
11340 /* If the previous call was static and this one is too,
11341 build a compound expression to hold the two (because in
11342 that case, previous function calls aren't transported as
11343 forcoming function's argument. */
11344 if (previous_call_static && is_static)
11346 decl = build (COMPOUND_EXPR, type, decl, *where_found);
11347 TREE_SIDE_EFFECTS (decl) = 1;
11349 else
11351 previous_call_static = is_static;
11352 decl = *where_found;
11354 from_type = 0;
11355 continue;
11357 case NEW_ARRAY_EXPR:
11358 case NEW_ANONYMOUS_ARRAY_EXPR:
11359 *where_found = decl = java_complete_tree (qual_wfl);
11360 if (decl == error_mark_node)
11361 return 1;
11362 *type_found = type = QUAL_DECL_TYPE (decl);
11363 CLASS_LOADED_P (type) = 1;
11364 continue;
11366 case CONVERT_EXPR:
11367 *where_found = decl = java_complete_tree (qual_wfl);
11368 if (decl == error_mark_node)
11369 return 1;
11370 *type_found = type = QUAL_DECL_TYPE (decl);
11371 from_cast = 1;
11372 continue;
11374 case CONDITIONAL_EXPR:
11375 case STRING_CST:
11376 case MODIFY_EXPR:
11377 *where_found = decl = java_complete_tree (qual_wfl);
11378 if (decl == error_mark_node)
11379 return 1;
11380 *type_found = type = QUAL_DECL_TYPE (decl);
11381 continue;
11383 case ARRAY_REF:
11384 /* If the access to the function call is a non static field,
11385 build the code to access it. */
11386 if (JDECL_P (decl) && !FIELD_STATIC (decl))
11388 decl = maybe_access_field (decl, *where_found, type);
11389 if (decl == error_mark_node)
11390 return 1;
11392 /* And code for the array reference expression */
11393 decl = java_complete_tree (qual_wfl);
11394 if (decl == error_mark_node)
11395 return 1;
11396 type = QUAL_DECL_TYPE (decl);
11397 continue;
11399 case PLUS_EXPR:
11400 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11401 return 1;
11402 if ((type = patch_string (decl)))
11403 decl = type;
11404 *where_found = QUAL_RESOLUTION (q) = decl;
11405 *type_found = type = TREE_TYPE (decl);
11406 break;
11408 case CLASS_LITERAL:
11409 if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11410 return 1;
11411 *where_found = QUAL_RESOLUTION (q) = decl;
11412 *type_found = type = TREE_TYPE (decl);
11413 break;
11415 default:
11416 /* Fix for -Wall Just go to the next statement. Don't
11417 continue */
11418 break;
11421 /* If we fall here, we weren't processing a (static) function call. */
11422 previous_call_static = 0;
11424 /* It can be the keyword THIS */
11425 if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11427 if (!current_this)
11429 parse_error_context
11430 (wfl, "Keyword `this' used outside allowed context");
11431 return 1;
11433 if (ctxp->explicit_constructor_p)
11435 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11436 return 1;
11438 /* We have to generate code for intermediate acess */
11439 if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11441 *where_found = decl = current_this;
11442 *type_found = type = QUAL_DECL_TYPE (decl);
11444 /* We're trying to access the this from somewhere else... */
11445 else
11447 *where_found = decl = build_current_thisn (type);
11448 from_qualified_this = 1;
11451 from_type = 0;
11452 continue;
11455 /* 15.10.2 Accessing Superclass Members using SUPER */
11456 if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11458 tree node;
11459 /* Check on the restricted use of SUPER */
11460 if (METHOD_STATIC (current_function_decl)
11461 || current_class == object_type_node)
11463 parse_error_context
11464 (wfl, "Keyword `super' used outside allowed context");
11465 return 1;
11467 /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11468 node = build_cast (EXPR_WFL_LINECOL (qual_wfl),
11469 CLASSTYPE_SUPER (current_class),
11470 build_this (EXPR_WFL_LINECOL (qual_wfl)));
11471 *where_found = decl = java_complete_tree (node);
11472 if (decl == error_mark_node)
11473 return 1;
11474 *type_found = type = QUAL_DECL_TYPE (decl);
11475 from_super = from_type = 1;
11476 continue;
11479 /* 15.13.1: Can't search for field name in packages, so we
11480 assume a variable/class name was meant. */
11481 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11483 tree name = resolve_package (wfl, &q);
11484 if (name)
11486 tree list;
11487 *where_found = decl = resolve_no_layout (name, qual_wfl);
11488 /* We wan't to be absolutely that the class is laid
11489 out. We're going to search something inside it. */
11490 *type_found = type = TREE_TYPE (decl);
11491 layout_class (type);
11492 from_type = 1;
11494 /* Fix them all the way down, if any are left. */
11495 if (q)
11497 list = TREE_CHAIN (q);
11498 while (list)
11500 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11501 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11502 list = TREE_CHAIN (list);
11506 else
11508 if (from_super || from_cast)
11509 parse_error_context
11510 ((from_cast ? qual_wfl : wfl),
11511 "No variable `%s' defined in class `%s'",
11512 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11513 lang_printable_name (type, 0));
11514 else
11515 parse_error_context
11516 (qual_wfl, "Undefined variable or class name: `%s'",
11517 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11518 return 1;
11522 /* We have a type name. It's been already resolved when the
11523 expression was qualified. */
11524 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11526 if (!(decl = QUAL_RESOLUTION (q)))
11527 return 1; /* Error reported already */
11529 /* Sneak preview. If next we see a `new', we're facing a
11530 qualification with resulted in a type being selected
11531 instead of a field. Report the error */
11532 if(TREE_CHAIN (q)
11533 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11535 parse_error_context (qual_wfl, "Undefined variable `%s'",
11536 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11537 return 1;
11540 if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11542 parse_error_context
11543 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11544 java_accstring_lookup (get_access_flags_from_decl (decl)),
11545 GET_TYPE_NAME (type),
11546 IDENTIFIER_POINTER (DECL_NAME (decl)),
11547 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11548 return 1;
11550 check_deprecation (qual_wfl, decl);
11552 type = TREE_TYPE (decl);
11553 from_type = 1;
11555 /* We resolve and expression name */
11556 else
11558 tree field_decl = NULL_TREE;
11560 /* If there exists an early resolution, use it. That occurs
11561 only once and we know that there are more things to
11562 come. Don't do that when processing something after SUPER
11563 (we need more thing to be put in place below */
11564 if (!from_super && QUAL_RESOLUTION (q))
11566 decl = QUAL_RESOLUTION (q);
11567 if (!type)
11569 if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11571 if (current_this)
11572 *where_found = current_this;
11573 else
11575 static_ref_err (qual_wfl, DECL_NAME (decl),
11576 current_class);
11577 return 1;
11580 else
11582 *where_found = TREE_TYPE (decl);
11583 if (TREE_CODE (*where_found) == POINTER_TYPE)
11584 *where_found = TREE_TYPE (*where_found);
11589 /* We have to search for a field, knowing the type of its
11590 container. The flag FROM_TYPE indicates that we resolved
11591 the last member of the expression as a type name, which
11592 means that for the resolution of this field, we'll look
11593 for other errors than if it was resolved as a member of
11594 an other field. */
11595 else
11597 int is_static;
11598 tree field_decl_type; /* For layout */
11600 if (!from_type && !JREFERENCE_TYPE_P (type))
11602 parse_error_context
11603 (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11604 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11605 lang_printable_name (type, 0),
11606 IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11607 return 1;
11610 field_decl = lookup_field_wrapper (type,
11611 EXPR_WFL_NODE (qual_wfl));
11612 if (field_decl == NULL_TREE)
11614 parse_error_context
11615 (qual_wfl, "No variable `%s' defined in type `%s'",
11616 IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11617 GET_TYPE_NAME (type));
11618 return 1;
11620 if (field_decl == error_mark_node)
11621 return 1;
11623 /* Layout the type of field_decl, since we may need
11624 it. Don't do primitive types or loaded classes. The
11625 situation of non primitive arrays may not handled
11626 properly here. FIXME */
11627 if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11628 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11629 else
11630 field_decl_type = TREE_TYPE (field_decl);
11631 if (!JPRIMITIVE_TYPE_P (field_decl_type)
11632 && !CLASS_LOADED_P (field_decl_type)
11633 && !TYPE_ARRAY_P (field_decl_type))
11634 resolve_and_layout (field_decl_type, NULL_TREE);
11635 if (TYPE_ARRAY_P (field_decl_type))
11636 CLASS_LOADED_P (field_decl_type) = 1;
11638 /* Check on accessibility here */
11639 if (not_accessible_p (type, field_decl, from_super))
11641 parse_error_context
11642 (qual_wfl,
11643 "Can't access %s field `%s.%s' from `%s'",
11644 java_accstring_lookup
11645 (get_access_flags_from_decl (field_decl)),
11646 GET_TYPE_NAME (type),
11647 IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11648 IDENTIFIER_POINTER
11649 (DECL_NAME (TYPE_NAME (current_class))));
11650 return 1;
11652 check_deprecation (qual_wfl, field_decl);
11654 /* There are things to check when fields are accessed
11655 from type. There are no restrictions on a static
11656 declaration of the field when it is accessed from an
11657 interface */
11658 is_static = FIELD_STATIC (field_decl);
11659 if (!from_super && from_type
11660 && !TYPE_INTERFACE_P (type)
11661 && !is_static
11662 && (current_function_decl
11663 && METHOD_STATIC (current_function_decl)))
11665 static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11666 return 1;
11668 from_cast = from_super = 0;
11670 /* It's an access from a type but it isn't static, we
11671 make it relative to `this'. */
11672 if (!is_static && from_type)
11673 decl = current_this;
11675 /* If we need to generate something to get a proper
11676 handle on what this field is accessed from, do it
11677 now. */
11678 if (!is_static)
11680 decl = maybe_access_field (decl, *where_found, *type_found);
11681 if (decl == error_mark_node)
11682 return 1;
11685 /* We want to keep the location were found it, and the type
11686 we found. */
11687 *where_found = decl;
11688 *type_found = type;
11690 /* Generate the correct expression for field access from
11691 qualified this */
11692 if (from_qualified_this)
11694 field_decl = build_outer_field_access (qual_wfl, field_decl);
11695 from_qualified_this = 0;
11698 /* This is the decl found and eventually the next one to
11699 search from */
11700 decl = field_decl;
11702 from_type = 0;
11703 type = QUAL_DECL_TYPE (decl);
11705 /* Sneak preview. If decl is qualified by a `new', report
11706 the error here to be accurate on the peculiar construct */
11707 if (TREE_CHAIN (q)
11708 && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11709 && !JREFERENCE_TYPE_P (type))
11711 parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'",
11712 lang_printable_name (type, 0));
11713 return 1;
11716 /* `q' might have changed due to a after package resolution
11717 re-qualification */
11718 if (!q)
11719 break;
11721 *found_decl = decl;
11722 return 0;
11725 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11726 can't be accessed from REFERENCE (a record type). */
11728 static int
11729 not_accessible_p (reference, member, from_super)
11730 tree reference, member;
11731 int from_super;
11733 int access_flag = get_access_flags_from_decl (member);
11735 /* Access always granted for members declared public */
11736 if (access_flag & ACC_PUBLIC)
11737 return 0;
11739 /* Check access on protected members */
11740 if (access_flag & ACC_PROTECTED)
11742 /* Access granted if it occurs from within the package
11743 containing the class in which the protected member is
11744 declared */
11745 if (class_in_current_package (DECL_CONTEXT (member)))
11746 return 0;
11748 /* If accessed with the form `super.member', then access is granted */
11749 if (from_super)
11750 return 0;
11752 /* Otherwise, access is granted if occuring from the class where
11753 member is declared or a subclass of it */
11754 if (inherits_from_p (reference, current_class))
11755 return 0;
11756 return 1;
11759 /* Check access on private members. Access is granted only if it
11760 occurs from within the class in witch it is declared. Exceptions
11761 are access from inner-classes. This section is probably not
11762 complete. FIXME */
11763 if (access_flag & ACC_PRIVATE)
11764 return (current_class == DECL_CONTEXT (member) ? 0 :
11765 (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11767 /* Default access are permitted only when occuring within the
11768 package in which the type (REFERENCE) is declared. In other words,
11769 REFERENCE is defined in the current package */
11770 if (ctxp->package)
11771 return !class_in_current_package (reference);
11773 /* Otherwise, access is granted */
11774 return 0;
11777 /* Test deprecated decl access. */
11778 static void
11779 check_deprecation (wfl, decl)
11780 tree wfl, decl;
11782 const char *file = DECL_SOURCE_FILE (decl);
11783 /* Complain if the field is deprecated and the file it was defined
11784 in isn't compiled at the same time the file which contains its
11785 use is */
11786 if (DECL_DEPRECATED (decl)
11787 && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11789 char the [20];
11790 switch (TREE_CODE (decl))
11792 case FUNCTION_DECL:
11793 strcpy (the, "method");
11794 break;
11795 case FIELD_DECL:
11796 strcpy (the, "field");
11797 break;
11798 case TYPE_DECL:
11799 strcpy (the, "class");
11800 break;
11801 default:
11802 fatal ("unexpected DECL code - check_deprecation");
11804 parse_warning_context
11805 (wfl, "The %s `%s' in class `%s' has been deprecated",
11806 the, lang_printable_name (decl, 0),
11807 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11811 /* Returns 1 if class was declared in the current package, 0 otherwise */
11813 static int
11814 class_in_current_package (class)
11815 tree class;
11817 static tree cache = NULL_TREE;
11818 int qualified_flag;
11819 tree left;
11821 if (cache == class)
11822 return 1;
11824 qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11826 /* If the current package is empty and the name of CLASS is
11827 qualified, class isn't in the current package. If there is a
11828 current package and the name of the CLASS is not qualified, class
11829 isn't in the current package */
11830 if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11831 return 0;
11833 /* If there is not package and the name of CLASS isn't qualified,
11834 they belong to the same unnamed package */
11835 if (!ctxp->package && !qualified_flag)
11836 return 1;
11838 /* Compare the left part of the name of CLASS with the package name */
11839 breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
11840 if (ctxp->package == left)
11842 cache = class;
11843 return 1;
11845 return 0;
11848 /* This function may generate code to access DECL from WHERE. This is
11849 done only if certain conditions meet. */
11851 static tree
11852 maybe_access_field (decl, where, type)
11853 tree decl, where, type;
11855 if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
11856 && !FIELD_STATIC (decl))
11857 decl = build_field_ref (where ? where : current_this,
11858 (type ? type : DECL_CONTEXT (decl)),
11859 DECL_NAME (decl));
11860 return decl;
11863 /* Build a method invocation, by patching PATCH. If non NULL
11864 and according to the situation, PRIMARY and WHERE may be
11865 used. IS_STATIC is set to 1 if the invoked function is static. */
11867 static tree
11868 patch_method_invocation (patch, primary, where, is_static, ret_decl)
11869 tree patch, primary, where;
11870 int *is_static;
11871 tree *ret_decl;
11873 tree wfl = TREE_OPERAND (patch, 0);
11874 tree args = TREE_OPERAND (patch, 1);
11875 tree name = EXPR_WFL_NODE (wfl);
11876 tree list;
11877 int is_static_flag = 0;
11878 int is_super_init = 0;
11879 tree this_arg = NULL_TREE;
11881 /* Should be overriden if everything goes well. Otherwise, if
11882 something fails, it should keep this value. It stop the
11883 evaluation of a bogus assignment. See java_complete_tree,
11884 MODIFY_EXPR: for the reasons why we sometimes want to keep on
11885 evaluating an assignment */
11886 TREE_TYPE (patch) = error_mark_node;
11888 /* Since lookup functions are messing with line numbers, save the
11889 context now. */
11890 java_parser_context_save_global ();
11892 /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
11894 /* Resolution of qualified name, excluding constructors */
11895 if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
11897 tree identifier, identifier_wfl, type, resolved;
11898 /* Extract the last IDENTIFIER of the qualified
11899 expression. This is a wfl and we will use it's location
11900 data during error report. */
11901 identifier_wfl = cut_identifier_in_qualified (wfl);
11902 identifier = EXPR_WFL_NODE (identifier_wfl);
11904 /* Given the context, IDENTIFIER is syntactically qualified
11905 as a MethodName. We need to qualify what's before */
11906 qualify_ambiguous_name (wfl);
11907 resolved = resolve_field_access (wfl, NULL, NULL);
11909 if (resolved == error_mark_node)
11910 PATCH_METHOD_RETURN_ERROR ();
11912 type = GET_SKIP_TYPE (resolved);
11913 resolve_and_layout (type, NULL_TREE);
11914 list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
11915 args = nreverse (args);
11917 /* We're resolving a call from a type */
11918 if (TREE_CODE (resolved) == TYPE_DECL)
11920 if (CLASS_INTERFACE (resolved))
11922 parse_error_context
11923 (identifier_wfl,
11924 "Can't make static reference to method `%s' in interface `%s'",
11925 IDENTIFIER_POINTER (identifier),
11926 IDENTIFIER_POINTER (name));
11927 PATCH_METHOD_RETURN_ERROR ();
11929 if (list && !METHOD_STATIC (list))
11931 char *fct_name = xstrdup (lang_printable_name (list, 0));
11932 parse_error_context
11933 (identifier_wfl,
11934 "Can't make static reference to method `%s %s' in class `%s'",
11935 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
11936 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
11937 free (fct_name);
11938 PATCH_METHOD_RETURN_ERROR ();
11941 else
11942 this_arg = primary = resolved;
11944 /* IDENTIFIER_WFL will be used to report any problem further */
11945 wfl = identifier_wfl;
11947 /* Resolution of simple names, names generated after a primary: or
11948 constructors */
11949 else
11951 tree class_to_search = NULL_TREE;
11952 int lc; /* Looking for Constructor */
11954 /* We search constructor in their target class */
11955 if (CALL_CONSTRUCTOR_P (patch))
11957 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
11958 class_to_search = EXPR_WFL_NODE (wfl);
11959 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
11960 this_identifier_node)
11961 class_to_search = NULL_TREE;
11962 else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
11963 super_identifier_node)
11965 is_super_init = 1;
11966 if (CLASSTYPE_SUPER (current_class))
11967 class_to_search =
11968 DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
11969 else
11971 parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
11972 PATCH_METHOD_RETURN_ERROR ();
11976 /* Class to search is NULL if we're searching the current one */
11977 if (class_to_search)
11979 class_to_search = resolve_and_layout (class_to_search, wfl);
11981 if (!class_to_search)
11983 parse_error_context
11984 (wfl, "Class `%s' not found in type declaration",
11985 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11986 PATCH_METHOD_RETURN_ERROR ();
11989 /* Can't instantiate an abstract class, but we can
11990 invoke it's constructor. It's use within the `new'
11991 context is denied here. */
11992 if (CLASS_ABSTRACT (class_to_search)
11993 && TREE_CODE (patch) == NEW_CLASS_EXPR)
11995 parse_error_context
11996 (wfl, "Class `%s' is an abstract class. It can't be instantiated",
11997 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11998 PATCH_METHOD_RETURN_ERROR ();
12001 class_to_search = TREE_TYPE (class_to_search);
12003 else
12004 class_to_search = current_class;
12005 lc = 1;
12007 /* This is a regular search in the local class, unless an
12008 alternate class is specified. */
12009 else
12011 class_to_search = (where ? where : current_class);
12012 lc = 0;
12015 /* NAME is a simple identifier or comes from a primary. Search
12016 in the class whose declaration contain the method being
12017 invoked. */
12018 resolve_and_layout (class_to_search, NULL_TREE);
12020 list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12021 /* Don't continue if no method were found, as the next statement
12022 can't be executed then. */
12023 if (!list)
12024 PATCH_METHOD_RETURN_ERROR ();
12026 /* Check for static reference if non static methods */
12027 if (check_for_static_method_reference (wfl, patch, list,
12028 class_to_search, primary))
12029 PATCH_METHOD_RETURN_ERROR ();
12031 /* Check for inner classes creation from illegal contexts */
12032 if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12033 && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12034 && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12036 parse_error_context
12037 (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12038 lang_printable_name (class_to_search, 0),
12039 (!current_this ? "" :
12040 "; an explicit one must be provided when creating this inner class"));
12041 PATCH_METHOD_RETURN_ERROR ();
12044 /* Non static methods are called with the current object extra
12045 argument. If patch a `new TYPE()', the argument is the value
12046 returned by the object allocator. If method is resolved as a
12047 primary, use the primary otherwise use the current THIS. */
12048 args = nreverse (args);
12049 if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12051 this_arg = primary ? primary : current_this;
12053 /* If we're using an access method, things are different.
12054 There are two familly of cases:
12056 1) We're not generating bytecodes:
12058 - LIST is non static. It's invocation is transformed from
12059 x(a1,...,an) into this$<n>.x(a1,....an).
12060 - LIST is static. It's invocation is transformed from
12061 x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12063 2) We're generating bytecodes:
12065 - LIST is non static. It's invocation is transformed from
12066 x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12067 - LIST is static. It's invocation is transformed from
12068 x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12070 Of course, this$<n> can be abitrary complex, ranging from
12071 this$0 (the immediate outer context) to
12072 access$0(access$0(...(this$0))).
12074 maybe_use_access_method returns a non zero value if the
12075 this_arg has to be deplaced into the (then generated)
12076 stub argument list. In the mean time, the selected
12077 function might have be replaced by a generated stub. */
12078 if (maybe_use_access_method (is_super_init, &list, &this_arg))
12079 args = tree_cons (NULL_TREE, this_arg, args);
12083 /* Merge point of all resolution schemes. If we have nothing, this
12084 is an error, already signaled */
12085 if (!list)
12086 PATCH_METHOD_RETURN_ERROR ();
12088 /* Check accessibility, position the is_static flag, build and
12089 return the call */
12090 if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12092 char *fct_name = xstrdup (lang_printable_name (list, 0));
12093 parse_error_context
12094 (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12095 java_accstring_lookup (get_access_flags_from_decl (list)),
12096 lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0),
12097 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))),
12098 fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12099 free (fct_name);
12100 PATCH_METHOD_RETURN_ERROR ();
12102 check_deprecation (wfl, list);
12104 /* If invoking a innerclass constructor, there are hidden parameters
12105 to pass */
12106 if (TREE_CODE (patch) == NEW_CLASS_EXPR
12107 && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12109 /* And make sure we add the accessed local variables to be saved
12110 in field aliases. */
12111 args = build_alias_initializer_parameter_list
12112 (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12114 /* We have to reverse things. Find out why. FIXME */
12115 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12116 args = nreverse (args);
12118 /* Secretely pass the current_this/primary as a second argument */
12119 if (primary || current_this)
12120 args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12121 else
12122 args = tree_cons (NULL_TREE, integer_zero_node, args);
12125 is_static_flag = METHOD_STATIC (list);
12126 if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12127 args = tree_cons (NULL_TREE, this_arg, args);
12129 /* In the context of an explicit constructor invocation, we can't
12130 invoke any method relying on `this'. Exceptions are: we're
12131 invoking a static function, primary exists and is not the current
12132 this, we're creating a new object. */
12133 if (ctxp->explicit_constructor_p
12134 && !is_static_flag
12135 && (!primary || primary == current_this)
12136 && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12138 parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12139 PATCH_METHOD_RETURN_ERROR ();
12141 java_parser_context_restore_global ();
12142 if (is_static)
12143 *is_static = is_static_flag;
12144 /* Sometimes, we want the decl of the selected method. Such as for
12145 EH checking */
12146 if (ret_decl)
12147 *ret_decl = list;
12148 patch = patch_invoke (patch, list, args);
12149 if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12151 tree finit_parms, finit_call;
12153 /* Prepare to pass hidden parameters to $finit$, if any. */
12154 finit_parms = build_alias_initializer_parameter_list
12155 (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12157 finit_call =
12158 build_method_invocation (build_wfl_node (finit_identifier_node),
12159 finit_parms);
12161 /* Generate the code used to initialize fields declared with an
12162 initialization statement and build a compound statement along
12163 with the super constructor invocation. */
12164 patch = build (COMPOUND_EXPR, void_type_node, patch,
12165 java_complete_tree (finit_call));
12166 CAN_COMPLETE_NORMALLY (patch) = 1;
12168 return patch;
12171 /* Check that we're not trying to do a static reference to a method in
12172 non static method. Return 1 if it's the case, 0 otherwise. */
12174 static int
12175 check_for_static_method_reference (wfl, node, method, where, primary)
12176 tree wfl, node, method, where, primary;
12178 if (METHOD_STATIC (current_function_decl)
12179 && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12181 char *fct_name = xstrdup (lang_printable_name (method, 0));
12182 parse_error_context
12183 (wfl, "Can't make static reference to method `%s %s' in class `%s'",
12184 lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12185 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12186 free (fct_name);
12187 return 1;
12189 return 0;
12192 /* Fix the invocation of *MDECL if necessary in the case of a
12193 invocation from an inner class. *THIS_ARG might be modified
12194 appropriately and an alternative access to *MDECL might be
12195 returned. */
12197 static int
12198 maybe_use_access_method (is_super_init, mdecl, this_arg)
12199 int is_super_init;
12200 tree *mdecl, *this_arg;
12202 tree ctx;
12203 tree md = *mdecl, ta = *this_arg;
12204 int to_return = 0;
12205 int non_static_context = !METHOD_STATIC (md);
12207 if (is_super_init
12208 || DECL_CONTEXT (md) == current_class
12209 || !PURE_INNER_CLASS_TYPE_P (current_class)
12210 || DECL_FINIT_P (md))
12211 return 0;
12213 /* If we're calling a method found in an enclosing class, generate
12214 what it takes to retrieve the right this. Don't do that if we're
12215 invoking a static method. */
12217 if (non_static_context)
12219 ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12220 if (ctx == DECL_CONTEXT (md))
12222 ta = build_current_thisn (current_class);
12223 ta = build_wfl_node (ta);
12225 else
12227 tree type = ctx;
12228 while (type)
12230 maybe_build_thisn_access_method (type);
12231 if (type == DECL_CONTEXT (md))
12233 ta = build_access_to_thisn (ctx, type, 0);
12234 break;
12236 type = (DECL_CONTEXT (TYPE_NAME (type)) ?
12237 TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12240 ta = java_complete_tree (ta);
12243 /* We might have to use an access method to get to MD. We can
12244 break the method access rule as far as we're not generating
12245 bytecode */
12246 if (METHOD_PRIVATE (md) && flag_emit_class_files)
12248 md = build_outer_method_access_method (md);
12249 to_return = 1;
12252 *mdecl = md;
12253 *this_arg = ta;
12255 /* Returnin a non zero value indicates we were doing a non static
12256 method invokation that is now a static invocation. It will have
12257 callee displace `this' to insert it in the regular argument
12258 list. */
12259 return (non_static_context && to_return);
12262 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12263 mode. */
12265 static tree
12266 patch_invoke (patch, method, args)
12267 tree patch, method, args;
12269 tree dtable, func;
12270 tree original_call, t, ta;
12272 /* Last step for args: convert build-in types. If we're dealing with
12273 a new TYPE() type call, the first argument to the constructor
12274 isn't found in the incomming argument list, but delivered by
12275 `new' */
12276 t = TYPE_ARG_TYPES (TREE_TYPE (method));
12277 if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12278 t = TREE_CHAIN (t);
12279 for (ta = args; t != end_params_node && ta;
12280 t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12281 if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12282 TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12283 TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12285 /* Resolve unresolved returned type isses */
12286 t = TREE_TYPE (TREE_TYPE (method));
12287 if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12288 resolve_and_layout (TREE_TYPE (t), NULL);
12290 if (flag_emit_class_files || flag_emit_xref)
12291 func = method;
12292 else
12294 tree signature = build_java_signature (TREE_TYPE (method));
12295 switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12297 case INVOKE_VIRTUAL:
12298 dtable = invoke_build_dtable (0, args);
12299 func = build_invokevirtual (dtable, method);
12300 break;
12302 case INVOKE_SUPER:
12303 case INVOKE_STATIC:
12304 func = build_known_method_ref (method, TREE_TYPE (method),
12305 DECL_CONTEXT (method),
12306 signature, args);
12307 break;
12309 case INVOKE_INTERFACE:
12310 dtable = invoke_build_dtable (1, args);
12311 func = build_invokeinterface (dtable, method);
12312 break;
12314 default:
12315 fatal ("internal error - unknown invocation_mode result");
12318 /* Ensure self_type is initialized, (invokestatic). FIXME */
12319 func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12322 TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12323 TREE_OPERAND (patch, 0) = func;
12324 TREE_OPERAND (patch, 1) = args;
12325 original_call = patch;
12327 /* We're processing a `new TYPE ()' form. New is called an its
12328 returned value is the first argument to the constructor. We build
12329 a COMPOUND_EXPR and use saved expression so that the overall NEW
12330 expression value is a pointer to a newly created and initialized
12331 class. */
12332 if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12334 tree class = DECL_CONTEXT (method);
12335 tree c1, saved_new, size, new;
12336 if (flag_emit_class_files || flag_emit_xref)
12338 TREE_TYPE (patch) = build_pointer_type (class);
12339 return patch;
12341 if (!TYPE_SIZE (class))
12342 safe_layout_class (class);
12343 size = size_in_bytes (class);
12344 new = build (CALL_EXPR, promote_type (class),
12345 build_address_of (alloc_object_node),
12346 tree_cons (NULL_TREE, build_class_ref (class),
12347 build_tree_list (NULL_TREE,
12348 size_in_bytes (class))),
12349 NULL_TREE);
12350 saved_new = save_expr (new);
12351 c1 = build_tree_list (NULL_TREE, saved_new);
12352 TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12353 TREE_OPERAND (original_call, 1) = c1;
12354 TREE_SET_CODE (original_call, CALL_EXPR);
12355 patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12357 return patch;
12360 static int
12361 invocation_mode (method, super)
12362 tree method;
12363 int super;
12365 int access = get_access_flags_from_decl (method);
12367 if (super)
12368 return INVOKE_SUPER;
12370 if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
12371 return INVOKE_STATIC;
12373 if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12374 return INVOKE_STATIC;
12376 if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12377 return INVOKE_INTERFACE;
12379 if (DECL_CONSTRUCTOR_P (method))
12380 return INVOKE_STATIC;
12382 return INVOKE_VIRTUAL;
12385 /* Retrieve a refined list of matching methods. It covers the step
12386 15.11.2 (Compile-Time Step 2) */
12388 static tree
12389 lookup_method_invoke (lc, cl, class, name, arg_list)
12390 int lc;
12391 tree cl;
12392 tree class, name, arg_list;
12394 tree atl = end_params_node; /* Arg Type List */
12395 tree method, signature, list, node;
12396 const char *candidates; /* Used for error report */
12397 char *dup;
12399 /* Fix the arguments */
12400 for (node = arg_list; node; node = TREE_CHAIN (node))
12402 tree current_arg = TREE_TYPE (TREE_VALUE (node));
12403 /* Non primitive type may have to be resolved */
12404 if (!JPRIMITIVE_TYPE_P (current_arg))
12405 resolve_and_layout (current_arg, NULL_TREE);
12406 /* And promoted */
12407 if (TREE_CODE (current_arg) == RECORD_TYPE)
12408 current_arg = promote_type (current_arg);
12409 atl = tree_cons (NULL_TREE, current_arg, atl);
12412 /* Presto. If we're dealing with an anonymous class and a
12413 constructor call, generate the right constructor now, since we
12414 know the arguments' types. */
12416 if (lc && ANONYMOUS_CLASS_P (class))
12417 craft_constructor (TYPE_NAME (class), atl);
12419 /* Find all candidates and then refine the list, searching for the
12420 most specific method. */
12421 list = find_applicable_accessible_methods_list (lc, class, name, atl);
12422 list = find_most_specific_methods_list (list);
12423 if (list && !TREE_CHAIN (list))
12424 return TREE_VALUE (list);
12426 /* Issue an error. List candidates if any. Candidates are listed
12427 only if accessible (non accessible methods may end-up here for
12428 the sake of a better error report). */
12429 candidates = NULL;
12430 if (list)
12432 tree current;
12433 obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12434 for (current = list; current; current = TREE_CHAIN (current))
12436 tree cm = TREE_VALUE (current);
12437 char string [4096];
12438 if (!cm || not_accessible_p (class, cm, 0))
12439 continue;
12440 sprintf
12441 (string, " `%s' in `%s'%s",
12442 get_printable_method_name (cm),
12443 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12444 (TREE_CHAIN (current) ? "\n" : ""));
12445 obstack_grow (&temporary_obstack, string, strlen (string));
12447 obstack_1grow (&temporary_obstack, '\0');
12448 candidates = obstack_finish (&temporary_obstack);
12450 /* Issue the error message */
12451 method = make_node (FUNCTION_TYPE);
12452 TYPE_ARG_TYPES (method) = atl;
12453 signature = build_java_argument_signature (method);
12454 dup = xstrdup (lang_printable_name (class, 0));
12455 parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12456 (lc ? "constructor" : "method"),
12457 (lc ? dup : IDENTIFIER_POINTER (name)),
12458 IDENTIFIER_POINTER (signature), dup,
12459 (candidates ? candidates : ""));
12460 free (dup);
12461 return NULL_TREE;
12464 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12465 when we're looking for a constructor. */
12467 static tree
12468 find_applicable_accessible_methods_list (lc, class, name, arglist)
12469 int lc;
12470 tree class, name, arglist;
12472 static int object_done = 0;
12473 tree list = NULL_TREE, all_list = NULL_TREE;
12475 if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12477 load_class (class, 1);
12478 safe_layout_class (class);
12481 /* Search interfaces */
12482 if (CLASS_INTERFACE (TYPE_NAME (class)))
12484 static struct hash_table t, *searched_interfaces = NULL;
12485 static int search_not_done = 0;
12486 int i, n;
12487 tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12489 /* Search in the hash table, otherwise create a new one if
12490 necessary and insert the new entry. */
12492 if (searched_interfaces)
12494 if (hash_lookup (searched_interfaces,
12495 (const hash_table_key) class, FALSE, NULL))
12496 return NULL;
12498 else
12500 hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12501 java_hash_compare_tree_node);
12502 searched_interfaces = &t;
12505 hash_lookup (searched_interfaces,
12506 (const hash_table_key) class, TRUE, NULL);
12508 search_applicable_methods_list (lc, TYPE_METHODS (class),
12509 name, arglist, &list, &all_list);
12510 n = TREE_VEC_LENGTH (basetype_vec);
12511 for (i = 1; i < n; i++)
12513 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12514 tree rlist;
12516 search_not_done++;
12517 rlist = find_applicable_accessible_methods_list (lc, t, name,
12518 arglist);
12519 list = chainon (rlist, list);
12520 search_not_done--;
12523 /* We're done. Reset the searched interfaces list and finally search
12524 java.lang.Object */
12525 if (!search_not_done)
12527 if (!object_done)
12528 search_applicable_methods_list (lc,
12529 TYPE_METHODS (object_type_node),
12530 name, arglist, &list, &all_list);
12531 hash_table_free (searched_interfaces);
12532 searched_interfaces = NULL;
12535 /* Search classes */
12536 else
12538 tree sc = class;
12539 int seen_inner_class = 0;
12540 search_applicable_methods_list (lc, TYPE_METHODS (class),
12541 name, arglist, &list, &all_list);
12543 /* We must search all interfaces of this class */
12544 if (!lc)
12546 tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12547 int n = TREE_VEC_LENGTH (basetype_vec), i;
12548 object_done = 1;
12549 for (i = 1; i < n; i++)
12551 tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12552 tree rlist;
12553 if (t != object_type_node)
12554 rlist = find_applicable_accessible_methods_list (lc, t,
12555 name, arglist);
12556 list = chainon (rlist, list);
12558 object_done = 0;
12561 /* Search enclosing context of inner classes before looking
12562 ancestors up. */
12563 while (!lc && INNER_CLASS_TYPE_P (class))
12565 tree rlist;
12566 seen_inner_class = 1;
12567 class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12568 rlist = find_applicable_accessible_methods_list (lc, class,
12569 name, arglist);
12570 list = chainon (rlist, list);
12573 if (!lc && seen_inner_class
12574 && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12575 class = CLASSTYPE_SUPER (sc);
12576 else
12577 class = sc;
12579 for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class));
12580 class; class = CLASSTYPE_SUPER (class))
12581 search_applicable_methods_list (lc, TYPE_METHODS (class),
12582 name, arglist, &list, &all_list);
12585 /* Either return the list obtained or all selected (but
12586 inaccessible) methods for better error report. */
12587 return (!list ? all_list : list);
12590 /* Effectively search for the approriate method in method */
12592 static void
12593 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12594 int lc;
12595 tree method, name, arglist;
12596 tree *list, *all_list;
12598 for (; method; method = TREE_CHAIN (method))
12600 /* When dealing with constructor, stop here, otherwise search
12601 other classes */
12602 if (lc && !DECL_CONSTRUCTOR_P (method))
12603 continue;
12604 else if (!lc && (DECL_CONSTRUCTOR_P (method)
12605 || (GET_METHOD_NAME (method) != name)))
12606 continue;
12608 if (argument_types_convertible (method, arglist))
12610 /* Retain accessible methods only */
12611 if (!not_accessible_p (DECL_CONTEXT (current_function_decl),
12612 method, 0))
12613 *list = tree_cons (NULL_TREE, method, *list);
12614 else
12615 /* Also retain all selected method here */
12616 *all_list = tree_cons (NULL_TREE, method, *list);
12621 /* 15.11.2.2 Choose the Most Specific Method */
12623 static tree
12624 find_most_specific_methods_list (list)
12625 tree list;
12627 int max = 0;
12628 tree current, new_list = NULL_TREE;
12629 for (current = list; current; current = TREE_CHAIN (current))
12631 tree method;
12632 DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12634 for (method = list; method; method = TREE_CHAIN (method))
12636 /* Don't test a method against itself */
12637 if (method == current)
12638 continue;
12640 /* Compare arguments and location where method where declared */
12641 if (argument_types_convertible (TREE_VALUE (method),
12642 TREE_VALUE (current))
12643 && valid_method_invocation_conversion_p
12644 (DECL_CONTEXT (TREE_VALUE (method)),
12645 DECL_CONTEXT (TREE_VALUE (current))))
12647 int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12648 max = (v > max ? v : max);
12653 /* Review the list and select the maximally specific methods */
12654 for (current = list; current; current = TREE_CHAIN (current))
12655 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12656 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12658 /* If we have several and they're all abstract, just pick the
12659 closest one. */
12661 if (new_list && TREE_CHAIN (new_list))
12663 tree c;
12664 for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c));
12665 c = TREE_CHAIN (c))
12667 if (!c)
12669 new_list = nreverse (new_list);
12670 TREE_CHAIN (new_list) = NULL_TREE;
12674 /* If we can't find one, lower expectations and try to gather multiple
12675 maximally specific methods */
12676 while (!new_list && max)
12678 while (--max > 0)
12680 if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12681 new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12685 return new_list;
12688 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12689 converted by method invocation conversion (5.3) to the type of the
12690 corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12691 to change less often than M1. */
12693 static int
12694 argument_types_convertible (m1, m2_or_arglist)
12695 tree m1, m2_or_arglist;
12697 static tree m2_arg_value = NULL_TREE;
12698 static tree m2_arg_cache = NULL_TREE;
12700 register tree m1_arg, m2_arg;
12702 SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12704 if (m2_arg_value == m2_or_arglist)
12705 m2_arg = m2_arg_cache;
12706 else
12708 /* M2_OR_ARGLIST can be a function DECL or a raw list of
12709 argument types */
12710 if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12712 m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12713 if (!METHOD_STATIC (m2_or_arglist))
12714 m2_arg = TREE_CHAIN (m2_arg);
12716 else
12717 m2_arg = m2_or_arglist;
12719 m2_arg_value = m2_or_arglist;
12720 m2_arg_cache = m2_arg;
12723 while (m1_arg != end_params_node && m2_arg != end_params_node)
12725 resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12726 if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12727 TREE_VALUE (m2_arg)))
12728 break;
12729 m1_arg = TREE_CHAIN (m1_arg);
12730 m2_arg = TREE_CHAIN (m2_arg);
12732 return m1_arg == end_params_node && m2_arg == end_params_node;
12735 /* Qualification routines */
12737 static void
12738 qualify_ambiguous_name (id)
12739 tree id;
12741 tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12742 saved_current_class;
12743 int again, super_found = 0, this_found = 0, new_array_found = 0;
12744 int code;
12746 /* We first qualify the first element, then derive qualification of
12747 others based on the first one. If the first element is qualified
12748 by a resolution (field or type), this resolution is stored in the
12749 QUAL_RESOLUTION of the qual element being examined. We need to
12750 save the current_class since the use of SUPER might change the
12751 its value. */
12752 saved_current_class = current_class;
12753 qual = EXPR_WFL_QUALIFICATION (id);
12754 do {
12756 /* Simple qualified expression feature a qual_wfl that is a
12757 WFL. Expression derived from a primary feature more complicated
12758 things like a CALL_EXPR. Expression from primary need to be
12759 worked out to extract the part on which the qualification will
12760 take place. */
12761 qual_wfl = QUAL_WFL (qual);
12762 switch (TREE_CODE (qual_wfl))
12764 case CALL_EXPR:
12765 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12766 if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
12768 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12769 qual_wfl = QUAL_WFL (qual);
12771 break;
12772 case NEW_ARRAY_EXPR:
12773 case NEW_ANONYMOUS_ARRAY_EXPR:
12774 qual = TREE_CHAIN (qual);
12775 again = new_array_found = 1;
12776 continue;
12777 case NEW_CLASS_EXPR:
12778 case CONVERT_EXPR:
12779 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12780 break;
12781 case ARRAY_REF:
12782 while (TREE_CODE (qual_wfl) == ARRAY_REF)
12783 qual_wfl = TREE_OPERAND (qual_wfl, 0);
12784 break;
12785 case STRING_CST:
12786 qual = TREE_CHAIN (qual);
12787 qual_wfl = QUAL_WFL (qual);
12788 break;
12789 case CLASS_LITERAL:
12790 qual = TREE_CHAIN (qual);
12791 qual_wfl = QUAL_WFL (qual);
12792 break;
12793 default:
12794 /* Fix for -Wall. Just break doing nothing */
12795 break;
12798 ptr_type = current_class;
12799 again = 0;
12800 code = TREE_CODE (qual_wfl);
12802 /* Pos evaluation: non WFL leading expression nodes */
12803 if (code == CONVERT_EXPR
12804 && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
12805 name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
12807 else if (code == INTEGER_CST)
12808 name = qual_wfl;
12810 else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
12811 TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
12812 name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
12814 else if (code == TREE_LIST)
12815 name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
12817 else if (code == STRING_CST || code == CONDITIONAL_EXPR
12818 || code == PLUS_EXPR)
12820 qual = TREE_CHAIN (qual);
12821 qual_wfl = QUAL_WFL (qual);
12822 again = 1;
12824 else
12826 name = EXPR_WFL_NODE (qual_wfl);
12827 if (!name)
12829 qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12830 again = 1;
12834 /* If we have a THIS (from a primary), we set the context accordingly */
12835 if (name == this_identifier_node)
12837 qual = TREE_CHAIN (qual);
12838 qual_wfl = QUAL_WFL (qual);
12839 if (TREE_CODE (qual_wfl) == CALL_EXPR)
12840 again = 1;
12841 else
12842 name = EXPR_WFL_NODE (qual_wfl);
12843 this_found = 1;
12845 /* If we have a SUPER, we set the context accordingly */
12846 if (name == super_identifier_node)
12848 current_class = CLASSTYPE_SUPER (ptr_type);
12849 /* Check that there is such a thing as a super class. If not,
12850 return. The error will be caught later on, during the
12851 resolution */
12852 if (!current_class)
12854 current_class = saved_current_class;
12855 return;
12857 qual = TREE_CHAIN (qual);
12858 /* Do one more interation to set things up */
12859 super_found = again = 1;
12861 } while (again);
12863 /* If name appears within the scope of a location variable
12864 declaration or parameter declaration, then it is an expression
12865 name. We don't carry this test out if we're in the context of the
12866 use of SUPER or THIS */
12867 if (!this_found && !super_found
12868 && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
12869 && (decl = IDENTIFIER_LOCAL_VALUE (name)))
12871 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12872 QUAL_RESOLUTION (qual) = decl;
12875 /* If within the class/interface NAME was found to be used there
12876 exists a (possibly inherited) field named NAME, then this is an
12877 expression name. If we saw a NEW_ARRAY_EXPR before and want to
12878 address length, it is OK. */
12879 else if ((decl = lookup_field_wrapper (ptr_type, name))
12880 || (new_array_found && name == length_identifier_node))
12882 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12883 QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
12886 /* We reclassify NAME as yielding to a type name resolution if:
12887 - NAME is a class/interface declared within the compilation
12888 unit containing NAME,
12889 - NAME is imported via a single-type-import declaration,
12890 - NAME is declared in an another compilation unit of the package
12891 of the compilation unit containing NAME,
12892 - NAME is declared by exactly on type-import-on-demand declaration
12893 of the compilation unit containing NAME.
12894 - NAME is actually a STRING_CST. */
12895 else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
12896 || (decl = resolve_and_layout (name, NULL_TREE)))
12898 RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
12899 QUAL_RESOLUTION (qual) = decl;
12902 /* Method call are expression name */
12903 else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
12904 || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
12905 || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
12906 RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12908 /* Check here that NAME isn't declared by more than one
12909 type-import-on-demand declaration of the compilation unit
12910 containing NAME. FIXME */
12912 /* Otherwise, NAME is reclassified as a package name */
12913 else
12914 RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
12916 /* Propagate the qualification accross other components of the
12917 qualified name */
12918 for (qual = TREE_CHAIN (qual); qual;
12919 qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
12921 if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
12922 RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
12923 else
12924 RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
12927 /* Store the global qualification for the ambiguous part of ID back
12928 into ID fields */
12929 if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
12930 RESOLVE_EXPRESSION_NAME_P (id) = 1;
12931 else if (RESOLVE_TYPE_NAME_P (qual_wfl))
12932 RESOLVE_TYPE_NAME_P (id) = 1;
12933 else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
12934 RESOLVE_PACKAGE_NAME_P (id) = 1;
12936 /* Restore the current class */
12937 current_class = saved_current_class;
12940 static int
12941 breakdown_qualified (left, right, source)
12942 tree *left, *right, source;
12944 char *p = IDENTIFIER_POINTER (source), *base;
12945 int l = IDENTIFIER_LENGTH (source);
12947 /* Breakdown NAME into REMAINDER . IDENTIFIER */
12948 base = p;
12949 p += (l-1);
12950 while (*p != '.' && p != base)
12951 p--;
12953 /* We didn't find a '.'. Return an error */
12954 if (p == base)
12955 return 1;
12957 *p = '\0';
12958 if (right)
12959 *right = get_identifier (p+1);
12960 *left = get_identifier (IDENTIFIER_POINTER (source));
12961 *p = '.';
12963 return 0;
12966 /* Patch tree nodes in a function body. When a BLOCK is found, push
12967 local variable decls if present.
12968 Same as java_complete_lhs, but does resolve static finals to values. */
12970 static tree
12971 java_complete_tree (node)
12972 tree node;
12974 node = java_complete_lhs (node);
12975 if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
12976 && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
12977 && !flag_emit_xref)
12979 tree value = DECL_INITIAL (node);
12980 DECL_INITIAL (node) = NULL_TREE;
12981 push_obstacks (&permanent_obstack, &permanent_obstack);
12982 value = fold_constant_for_init (value, node);
12983 pop_obstacks ();
12984 DECL_INITIAL (node) = value;
12985 if (value != NULL_TREE)
12987 /* fold_constant_for_init sometimes widen the original type
12988 of the constant (i.e. byte to int.) It's not desirable,
12989 especially if NODE is a function argument. */
12990 if (TREE_CODE (value) == INTEGER_CST
12991 && TREE_TYPE (node) != TREE_TYPE (value))
12992 return convert (TREE_TYPE (node), value);
12993 else
12994 return value;
12997 return node;
13000 static tree
13001 java_stabilize_reference (node)
13002 tree node;
13004 if (TREE_CODE (node) == COMPOUND_EXPR)
13006 tree op0 = TREE_OPERAND (node, 0);
13007 tree op1 = TREE_OPERAND (node, 1);
13008 TREE_OPERAND (node, 0) = save_expr (op0);
13009 TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13010 return node;
13012 return stabilize_reference (node);
13015 /* Patch tree nodes in a function body. When a BLOCK is found, push
13016 local variable decls if present.
13017 Same as java_complete_tree, but does not resolve static finals to values. */
13019 static tree
13020 java_complete_lhs (node)
13021 tree node;
13023 tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13024 int flag;
13026 /* CONVERT_EXPR always has its type set, even though it needs to be
13027 worked out. */
13028 if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13029 return node;
13031 /* The switch block implements cases processing container nodes
13032 first. Contained nodes are always written back. Leaves come
13033 next and return a value. */
13034 switch (TREE_CODE (node))
13036 case BLOCK:
13038 /* 1- Block section.
13039 Set the local values on decl names so we can identify them
13040 faster when they're referenced. At that stage, identifiers
13041 are legal so we don't check for declaration errors. */
13042 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13044 DECL_CONTEXT (cn) = current_function_decl;
13045 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13047 if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13048 CAN_COMPLETE_NORMALLY (node) = 1;
13049 else
13051 tree stmt = BLOCK_EXPR_BODY (node);
13052 tree *ptr;
13053 int error_seen = 0;
13054 if (TREE_CODE (stmt) == COMPOUND_EXPR)
13056 /* Re-order from (((A; B); C); ...; Z) to
13057 (A; (B; (C ; (...; Z)))).
13058 This makes it easier to scan the statements left-to-right
13059 without using recursion (which might overflow the stack
13060 if the block has many statements. */
13061 for (;;)
13063 tree left = TREE_OPERAND (stmt, 0);
13064 if (TREE_CODE (left) != COMPOUND_EXPR)
13065 break;
13066 TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13067 TREE_OPERAND (left, 1) = stmt;
13068 stmt = left;
13070 BLOCK_EXPR_BODY (node) = stmt;
13073 /* Now do the actual complete, without deep recursion for
13074 long blocks. */
13075 ptr = &BLOCK_EXPR_BODY (node);
13076 while (TREE_CODE (*ptr) == COMPOUND_EXPR
13077 && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13079 tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13080 tree *next = &TREE_OPERAND (*ptr, 1);
13081 TREE_OPERAND (*ptr, 0) = cur;
13082 if (cur == empty_stmt_node)
13084 /* Optimization; makes it easier to detect empty bodies.
13085 Most useful for <clinit> with all-constant initializer. */
13086 *ptr = *next;
13087 continue;
13089 if (TREE_CODE (cur) == ERROR_MARK)
13090 error_seen++;
13091 else if (! CAN_COMPLETE_NORMALLY (cur))
13093 wfl_op2 = *next;
13094 for (;;)
13096 if (TREE_CODE (wfl_op2) == BLOCK)
13097 wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13098 else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13099 wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13100 else
13101 break;
13103 if (TREE_CODE (wfl_op2) != CASE_EXPR
13104 && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13105 unreachable_stmt_error (*ptr);
13107 ptr = next;
13109 *ptr = java_complete_tree (*ptr);
13111 if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13112 return error_mark_node;
13113 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13115 /* Turn local bindings to null */
13116 for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13117 IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13119 TREE_TYPE (node) = void_type_node;
13120 break;
13122 /* 2- They are expressions but ultimately deal with statements */
13124 case THROW_EXPR:
13125 wfl_op1 = TREE_OPERAND (node, 0);
13126 COMPLETE_CHECK_OP_0 (node);
13127 /* 14.19 A throw statement cannot complete normally. */
13128 CAN_COMPLETE_NORMALLY (node) = 0;
13129 return patch_throw_statement (node, wfl_op1);
13131 case SYNCHRONIZED_EXPR:
13132 wfl_op1 = TREE_OPERAND (node, 0);
13133 return patch_synchronized_statement (node, wfl_op1);
13135 case TRY_EXPR:
13136 return patch_try_statement (node);
13138 case TRY_FINALLY_EXPR:
13139 COMPLETE_CHECK_OP_0 (node);
13140 COMPLETE_CHECK_OP_1 (node);
13141 CAN_COMPLETE_NORMALLY (node)
13142 = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13143 && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13144 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13145 return node;
13147 case CLEANUP_POINT_EXPR:
13148 COMPLETE_CHECK_OP_0 (node);
13149 TREE_TYPE (node) = void_type_node;
13150 CAN_COMPLETE_NORMALLY (node) =
13151 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13152 return node;
13154 case WITH_CLEANUP_EXPR:
13155 COMPLETE_CHECK_OP_0 (node);
13156 COMPLETE_CHECK_OP_2 (node);
13157 CAN_COMPLETE_NORMALLY (node) =
13158 CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13159 TREE_TYPE (node) = void_type_node;
13160 return node;
13162 case LABELED_BLOCK_EXPR:
13163 PUSH_LABELED_BLOCK (node);
13164 if (LABELED_BLOCK_BODY (node))
13165 COMPLETE_CHECK_OP_1 (node);
13166 TREE_TYPE (node) = void_type_node;
13167 POP_LABELED_BLOCK ();
13169 if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13171 LABELED_BLOCK_BODY (node) = NULL_TREE;
13172 CAN_COMPLETE_NORMALLY (node) = 1;
13174 else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13175 CAN_COMPLETE_NORMALLY (node) = 1;
13176 return node;
13178 case EXIT_BLOCK_EXPR:
13179 /* We don't complete operand 1, because it's the return value of
13180 the EXIT_BLOCK_EXPR which doesn't exist it Java */
13181 return patch_bc_statement (node);
13183 case CASE_EXPR:
13184 cn = java_complete_tree (TREE_OPERAND (node, 0));
13185 if (cn == error_mark_node)
13186 return cn;
13188 /* First, the case expression must be constant. Values of final
13189 fields are accepted. */
13190 cn = fold (cn);
13191 if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13192 && JDECL_P (TREE_OPERAND (cn, 1))
13193 && FIELD_FINAL (TREE_OPERAND (cn, 1))
13194 && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13196 push_obstacks (&permanent_obstack, &permanent_obstack);
13197 cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13198 TREE_OPERAND (cn, 1));
13199 pop_obstacks ();
13202 if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13204 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13205 parse_error_context (node, "Constant expression required");
13206 return error_mark_node;
13209 nn = ctxp->current_loop;
13211 /* It must be assignable to the type of the switch expression. */
13212 if (!try_builtin_assignconv (NULL_TREE,
13213 TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13215 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13216 parse_error_context
13217 (wfl_operator,
13218 "Incompatible type for case. Can't convert `%s' to `int'",
13219 lang_printable_name (TREE_TYPE (cn), 0));
13220 return error_mark_node;
13223 cn = fold (convert (int_type_node, cn));
13225 /* Multiple instance of a case label bearing the same
13226 value is checked during code generation. The case
13227 expression is allright so far. */
13228 TREE_OPERAND (node, 0) = cn;
13229 TREE_TYPE (node) = void_type_node;
13230 CAN_COMPLETE_NORMALLY (node) = 1;
13231 TREE_SIDE_EFFECTS (node) = 1;
13232 break;
13234 case DEFAULT_EXPR:
13235 nn = ctxp->current_loop;
13236 /* Only one default label is allowed per switch statement */
13237 if (SWITCH_HAS_DEFAULT (nn))
13239 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13240 parse_error_context (wfl_operator,
13241 "Duplicate case label: `default'");
13242 return error_mark_node;
13244 else
13245 SWITCH_HAS_DEFAULT (nn) = 1;
13246 TREE_TYPE (node) = void_type_node;
13247 TREE_SIDE_EFFECTS (node) = 1;
13248 CAN_COMPLETE_NORMALLY (node) = 1;
13249 break;
13251 case SWITCH_EXPR:
13252 case LOOP_EXPR:
13253 PUSH_LOOP (node);
13254 /* Check whether the loop was enclosed in a labeled
13255 statement. If not, create one, insert the loop in it and
13256 return the node */
13257 nn = patch_loop_statement (node);
13259 /* Anyways, walk the body of the loop */
13260 if (TREE_CODE (node) == LOOP_EXPR)
13261 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13262 /* Switch statement: walk the switch expression and the cases */
13263 else
13264 node = patch_switch_statement (node);
13266 if (TREE_OPERAND (node, 0) == error_mark_node)
13267 nn = error_mark_node;
13268 else
13270 TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13271 /* If we returned something different, that's because we
13272 inserted a label. Pop the label too. */
13273 if (nn != node)
13275 if (CAN_COMPLETE_NORMALLY (node))
13276 CAN_COMPLETE_NORMALLY (nn) = 1;
13277 POP_LABELED_BLOCK ();
13280 POP_LOOP ();
13281 return nn;
13283 case EXIT_EXPR:
13284 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13285 return patch_exit_expr (node);
13287 case COND_EXPR:
13288 /* Condition */
13289 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13290 if (TREE_OPERAND (node, 0) == error_mark_node)
13291 return error_mark_node;
13292 /* then-else branches */
13293 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13294 if (TREE_OPERAND (node, 1) == error_mark_node)
13295 return error_mark_node;
13296 TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13297 if (TREE_OPERAND (node, 2) == error_mark_node)
13298 return error_mark_node;
13299 return patch_if_else_statement (node);
13300 break;
13302 case CONDITIONAL_EXPR:
13303 /* Condition */
13304 wfl_op1 = TREE_OPERAND (node, 0);
13305 COMPLETE_CHECK_OP_0 (node);
13306 wfl_op2 = TREE_OPERAND (node, 1);
13307 COMPLETE_CHECK_OP_1 (node);
13308 wfl_op3 = TREE_OPERAND (node, 2);
13309 COMPLETE_CHECK_OP_2 (node);
13310 return patch_conditional_expr (node, wfl_op1, wfl_op2);
13312 /* 3- Expression section */
13313 case COMPOUND_EXPR:
13314 wfl_op2 = TREE_OPERAND (node, 1);
13315 TREE_OPERAND (node, 0) = nn =
13316 java_complete_tree (TREE_OPERAND (node, 0));
13317 if (wfl_op2 == empty_stmt_node)
13318 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13319 else
13321 if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13323 /* An unreachable condition in a do-while statement
13324 is *not* (technically) an unreachable statement. */
13325 nn = wfl_op2;
13326 if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13327 nn = EXPR_WFL_NODE (nn);
13328 if (TREE_CODE (nn) != EXIT_EXPR)
13330 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13331 parse_error_context (wfl_operator, "Unreachable statement");
13334 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13335 if (TREE_OPERAND (node, 1) == error_mark_node)
13336 return error_mark_node;
13337 CAN_COMPLETE_NORMALLY (node)
13338 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13340 TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13341 break;
13343 case RETURN_EXPR:
13344 /* CAN_COMPLETE_NORMALLY (node) = 0; */
13345 return patch_return (node);
13347 case EXPR_WITH_FILE_LOCATION:
13348 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13349 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13351 tree wfl = node;
13352 node = resolve_expression_name (node, NULL);
13353 if (node == error_mark_node)
13354 return node;
13355 /* Keep line number information somewhere were it doesn't
13356 disrupt the completion process. */
13357 if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13359 EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13360 TREE_OPERAND (node, 1) = wfl;
13362 CAN_COMPLETE_NORMALLY (node) = 1;
13364 else
13366 tree body;
13367 int save_lineno = lineno;
13368 lineno = EXPR_WFL_LINENO (node);
13369 body = java_complete_tree (EXPR_WFL_NODE (node));
13370 lineno = save_lineno;
13371 EXPR_WFL_NODE (node) = body;
13372 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13373 CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13374 if (body == empty_stmt_node)
13376 /* Optimization; makes it easier to detect empty bodies. */
13377 return body;
13379 if (body == error_mark_node)
13381 /* Its important for the evaluation of assignment that
13382 this mark on the TREE_TYPE is propagated. */
13383 TREE_TYPE (node) = error_mark_node;
13384 return error_mark_node;
13386 else
13387 TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13390 break;
13392 case NEW_ARRAY_EXPR:
13393 /* Patch all the dimensions */
13394 flag = 0;
13395 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13397 int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13398 tree dim = convert (int_type_node,
13399 java_complete_tree (TREE_VALUE (cn)));
13400 if (dim == error_mark_node)
13402 flag = 1;
13403 continue;
13405 else
13407 TREE_VALUE (cn) = dim;
13408 /* Setup the location of the current dimension, for
13409 later error report. */
13410 TREE_PURPOSE (cn) =
13411 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13412 EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13415 /* They complete the array creation expression, if no errors
13416 were found. */
13417 CAN_COMPLETE_NORMALLY (node) = 1;
13418 return (flag ? error_mark_node
13419 : force_evaluation_order (patch_newarray (node)));
13421 case NEW_ANONYMOUS_ARRAY_EXPR:
13422 /* Create the array type if necessary. */
13423 if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13425 tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13426 if (!(type = resolve_type_during_patch (type)))
13427 return error_mark_node;
13428 type = build_array_from_name (type, NULL_TREE,
13429 ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13430 ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13432 node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13433 ANONYMOUS_ARRAY_INITIALIZER (node));
13434 if (node == error_mark_node)
13435 return error_mark_node;
13436 CAN_COMPLETE_NORMALLY (node) = 1;
13437 return node;
13439 case NEW_CLASS_EXPR:
13440 case CALL_EXPR:
13441 /* Complete function's argument(s) first */
13442 if (complete_function_arguments (node))
13443 return error_mark_node;
13444 else
13446 tree decl, wfl = TREE_OPERAND (node, 0);
13447 int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13449 node = patch_method_invocation (node, NULL_TREE,
13450 NULL_TREE, 0, &decl);
13451 if (node == error_mark_node)
13452 return error_mark_node;
13454 check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13455 /* If we call this(...), register signature and positions */
13456 if (in_this)
13457 DECL_CONSTRUCTOR_CALLS (current_function_decl) =
13458 tree_cons (wfl, decl,
13459 DECL_CONSTRUCTOR_CALLS (current_function_decl));
13460 CAN_COMPLETE_NORMALLY (node) = 1;
13461 return force_evaluation_order (node);
13464 case MODIFY_EXPR:
13465 /* Save potential wfls */
13466 wfl_op1 = TREE_OPERAND (node, 0);
13467 TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13469 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13470 && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13471 && DECL_INITIAL (nn) != NULL_TREE)
13473 tree value;
13475 push_obstacks (&permanent_obstack, &permanent_obstack);
13476 value = fold_constant_for_init (nn, nn);
13477 pop_obstacks ();
13479 if (value != NULL_TREE)
13481 tree type = TREE_TYPE (value);
13482 if (JPRIMITIVE_TYPE_P (type) ||
13483 (type == string_ptr_type_node && ! flag_emit_class_files))
13484 return empty_stmt_node;
13486 DECL_INITIAL (nn) = NULL_TREE;
13488 wfl_op2 = TREE_OPERAND (node, 1);
13490 if (TREE_OPERAND (node, 0) == error_mark_node)
13491 return error_mark_node;
13493 flag = COMPOUND_ASSIGN_P (wfl_op2);
13494 if (flag)
13496 /* This might break when accessing outer field from inner
13497 class. TESTME, FIXME */
13498 tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0));
13500 /* Hand stablize the lhs on both places */
13501 TREE_OPERAND (node, 0) = lvalue;
13502 TREE_OPERAND (TREE_OPERAND (node, 1), 0) =
13503 (flag_emit_class_files ? lvalue : save_expr (lvalue));
13505 /* 15.25.2.a: Left hand is not an array access. FIXME */
13506 /* Now complete the RHS. We write it back later on. */
13507 nn = java_complete_tree (TREE_OPERAND (node, 1));
13509 if ((cn = patch_string (nn)))
13510 nn = cn;
13512 /* The last part of the rewrite for E1 op= E2 is to have
13513 E1 = (T)(E1 op E2), with T being the type of E1. */
13514 nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2),
13515 TREE_TYPE (lvalue), nn));
13517 /* 15.25.2.b: Left hand is an array access. FIXME */
13520 /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13521 function to complete this RHS. Note that a NEW_ARRAY_INIT
13522 might have been already fully expanded if created as a result
13523 of processing an anonymous array initializer. We avoid doing
13524 the operation twice by testing whether the node already bears
13525 a type. */
13526 else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13527 nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13528 TREE_OPERAND (node, 1));
13529 /* Otherwise we simply complete the RHS */
13530 else
13531 nn = java_complete_tree (TREE_OPERAND (node, 1));
13533 if (nn == error_mark_node)
13534 return error_mark_node;
13536 /* Write back the RHS as we evaluated it. */
13537 TREE_OPERAND (node, 1) = nn;
13539 /* In case we're handling = with a String as a RHS, we need to
13540 produce a String out of the RHS (it might still be a
13541 STRING_CST or a StringBuffer at this stage */
13542 if ((nn = patch_string (TREE_OPERAND (node, 1))))
13543 TREE_OPERAND (node, 1) = nn;
13545 if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13546 TREE_OPERAND (node, 1))))
13548 /* We return error_mark_node if outer_field_access_fix
13549 detects we write into a final. */
13550 if (nn == error_mark_node)
13551 return error_mark_node;
13552 node = nn;
13554 else
13556 node = patch_assignment (node, wfl_op1, wfl_op2);
13557 /* Reorganize the tree if necessary. */
13558 if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node))
13559 || JSTRING_P (TREE_TYPE (node))))
13560 node = java_refold (node);
13563 CAN_COMPLETE_NORMALLY (node) = 1;
13564 return node;
13566 case MULT_EXPR:
13567 case PLUS_EXPR:
13568 case MINUS_EXPR:
13569 case LSHIFT_EXPR:
13570 case RSHIFT_EXPR:
13571 case URSHIFT_EXPR:
13572 case BIT_AND_EXPR:
13573 case BIT_XOR_EXPR:
13574 case BIT_IOR_EXPR:
13575 case TRUNC_MOD_EXPR:
13576 case TRUNC_DIV_EXPR:
13577 case RDIV_EXPR:
13578 case TRUTH_ANDIF_EXPR:
13579 case TRUTH_ORIF_EXPR:
13580 case EQ_EXPR:
13581 case NE_EXPR:
13582 case GT_EXPR:
13583 case GE_EXPR:
13584 case LT_EXPR:
13585 case LE_EXPR:
13586 /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13587 knows how to handle those cases. */
13588 wfl_op1 = TREE_OPERAND (node, 0);
13589 wfl_op2 = TREE_OPERAND (node, 1);
13591 CAN_COMPLETE_NORMALLY (node) = 1;
13592 /* Don't complete string nodes if dealing with the PLUS operand. */
13593 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13595 nn = java_complete_tree (wfl_op1);
13596 if (nn == error_mark_node)
13597 return error_mark_node;
13598 if ((cn = patch_string (nn)))
13599 nn = cn;
13600 TREE_OPERAND (node, 0) = nn;
13602 if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13604 nn = java_complete_tree (wfl_op2);
13605 if (nn == error_mark_node)
13606 return error_mark_node;
13607 if ((cn = patch_string (nn)))
13608 nn = cn;
13609 TREE_OPERAND (node, 1) = nn;
13611 return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13613 case INSTANCEOF_EXPR:
13614 wfl_op1 = TREE_OPERAND (node, 0);
13615 COMPLETE_CHECK_OP_0 (node);
13616 if (flag_emit_xref)
13618 TREE_TYPE (node) = boolean_type_node;
13619 return node;
13621 return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13623 case UNARY_PLUS_EXPR:
13624 case NEGATE_EXPR:
13625 case TRUTH_NOT_EXPR:
13626 case BIT_NOT_EXPR:
13627 case PREDECREMENT_EXPR:
13628 case PREINCREMENT_EXPR:
13629 case POSTDECREMENT_EXPR:
13630 case POSTINCREMENT_EXPR:
13631 case CONVERT_EXPR:
13632 /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13633 how to handle those cases. */
13634 wfl_op1 = TREE_OPERAND (node, 0);
13635 CAN_COMPLETE_NORMALLY (node) = 1;
13636 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13637 if (TREE_OPERAND (node, 0) == error_mark_node)
13638 return error_mark_node;
13639 node = patch_unaryop (node, wfl_op1);
13640 CAN_COMPLETE_NORMALLY (node) = 1;
13641 break;
13643 case ARRAY_REF:
13644 /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13645 how to handle those cases. */
13646 wfl_op1 = TREE_OPERAND (node, 0);
13647 TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13648 if (TREE_OPERAND (node, 0) == error_mark_node)
13649 return error_mark_node;
13650 if (!flag_emit_class_files && !flag_emit_xref)
13651 TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13652 /* The same applies to wfl_op2 */
13653 wfl_op2 = TREE_OPERAND (node, 1);
13654 TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13655 if (TREE_OPERAND (node, 1) == error_mark_node)
13656 return error_mark_node;
13657 if (!flag_emit_class_files && !flag_emit_xref)
13658 TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13659 return patch_array_ref (node);
13661 case RECORD_TYPE:
13662 return node;;
13664 case COMPONENT_REF:
13665 /* The first step in the re-write of qualified name handling. FIXME.
13666 So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13667 TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13668 if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13670 tree name = TREE_OPERAND (node, 1);
13671 tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13672 if (field == NULL_TREE)
13674 error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13675 return error_mark_node;
13677 if (! FIELD_STATIC (field))
13679 error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13680 return error_mark_node;
13682 return field;
13684 else
13685 fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13686 break;
13688 case THIS_EXPR:
13689 /* Can't use THIS in a static environment */
13690 if (!current_this)
13692 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13693 parse_error_context (wfl_operator,
13694 "Keyword `this' used outside allowed context");
13695 TREE_TYPE (node) = error_mark_node;
13696 return error_mark_node;
13698 if (ctxp->explicit_constructor_p)
13700 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13701 parse_error_context
13702 (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13703 TREE_TYPE (node) = error_mark_node;
13704 return error_mark_node;
13706 return current_this;
13708 case CLASS_LITERAL:
13709 CAN_COMPLETE_NORMALLY (node) = 1;
13710 node = patch_incomplete_class_ref (node);
13711 if (node == error_mark_node)
13712 return error_mark_node;
13713 break;
13715 case INSTANCE_INITIALIZERS_EXPR:
13716 in_instance_initializer++;
13717 node = java_complete_tree (TREE_OPERAND (node, 0));
13718 in_instance_initializer--;
13719 if (node != error_mark_node)
13720 TREE_TYPE (node) = void_type_node;
13721 else
13722 return error_mark_node;
13723 break;
13725 default:
13726 CAN_COMPLETE_NORMALLY (node) = 1;
13727 /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13728 and it's time to turn it into the appropriate String object */
13729 if ((nn = patch_string (node)))
13730 node = nn;
13731 else
13732 fatal ("No case for tree code `%s' - java_complete_tree\n",
13733 tree_code_name [TREE_CODE (node)]);
13735 return node;
13738 /* Complete function call's argument. Return a non zero value is an
13739 error was found. */
13741 static int
13742 complete_function_arguments (node)
13743 tree node;
13745 int flag = 0;
13746 tree cn;
13748 ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13749 for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13751 tree wfl = TREE_VALUE (cn), parm, temp;
13752 parm = java_complete_tree (wfl);
13754 if (parm == error_mark_node)
13756 flag = 1;
13757 continue;
13759 /* If have a string literal that we haven't transformed yet or a
13760 crafted string buffer, as a result of use of the the String
13761 `+' operator. Build `parm.toString()' and expand it. */
13762 if ((temp = patch_string (parm)))
13763 parm = temp;
13764 /* Inline PRIMTYPE.TYPE read access */
13765 parm = maybe_build_primttype_type_ref (parm, wfl);
13767 TREE_VALUE (cn) = parm;
13769 ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13770 return flag;
13773 /* Sometimes (for loops and variable initialized during their
13774 declaration), we want to wrap a statement around a WFL and turn it
13775 debugable. */
13777 static tree
13778 build_debugable_stmt (location, stmt)
13779 int location;
13780 tree stmt;
13782 if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
13784 stmt = build_expr_wfl (stmt, input_filename, 0, 0);
13785 EXPR_WFL_LINECOL (stmt) = location;
13787 JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
13788 return stmt;
13791 static tree
13792 build_expr_block (body, decls)
13793 tree body, decls;
13795 tree node = make_node (BLOCK);
13796 BLOCK_EXPR_DECLS (node) = decls;
13797 BLOCK_EXPR_BODY (node) = body;
13798 if (body)
13799 TREE_TYPE (node) = TREE_TYPE (body);
13800 TREE_SIDE_EFFECTS (node) = 1;
13801 return node;
13804 /* Create a new function block and link it approriately to current
13805 function block chain */
13807 static tree
13808 enter_block ()
13810 return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
13813 /* Link block B supercontext to the previous block. The current
13814 function DECL is used as supercontext when enter_a_block is called
13815 for the first time for a given function. The current function body
13816 (DECL_FUNCTION_BODY) is set to be block B. */
13818 static tree
13819 enter_a_block (b)
13820 tree b;
13822 tree fndecl = current_function_decl;
13824 if (!fndecl) {
13825 BLOCK_SUPERCONTEXT (b) = current_static_block;
13826 current_static_block = b;
13829 else if (!DECL_FUNCTION_BODY (fndecl))
13831 BLOCK_SUPERCONTEXT (b) = fndecl;
13832 DECL_FUNCTION_BODY (fndecl) = b;
13834 else
13836 BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
13837 DECL_FUNCTION_BODY (fndecl) = b;
13839 return b;
13842 /* Exit a block by changing the current function body
13843 (DECL_FUNCTION_BODY) to the current block super context, only if
13844 the block being exited isn't the method's top level one. */
13846 static tree
13847 exit_block ()
13849 tree b;
13850 if (current_function_decl)
13852 b = DECL_FUNCTION_BODY (current_function_decl);
13853 if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
13854 DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
13856 else
13858 b = current_static_block;
13860 if (BLOCK_SUPERCONTEXT (b))
13861 current_static_block = BLOCK_SUPERCONTEXT (b);
13863 return b;
13866 /* Lookup for NAME in the nested function's blocks, all the way up to
13867 the current toplevel one. It complies with Java's local variable
13868 scoping rules. */
13870 static tree
13871 lookup_name_in_blocks (name)
13872 tree name;
13874 tree b = GET_CURRENT_BLOCK (current_function_decl);
13876 while (b != current_function_decl)
13878 tree current;
13880 /* Paranoid sanity check. To be removed */
13881 if (TREE_CODE (b) != BLOCK)
13882 fatal ("non block expr function body - lookup_name_in_blocks");
13884 for (current = BLOCK_EXPR_DECLS (b); current;
13885 current = TREE_CHAIN (current))
13886 if (DECL_NAME (current) == name)
13887 return current;
13888 b = BLOCK_SUPERCONTEXT (b);
13890 return NULL_TREE;
13893 static void
13894 maybe_absorb_scoping_blocks ()
13896 while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
13898 tree b = exit_block ();
13899 java_method_add_stmt (current_function_decl, b);
13900 SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
13905 /* This section of the source is reserved to build_* functions that
13906 are building incomplete tree nodes and the patch_* functions that
13907 are completing them. */
13909 /* Wrap a non WFL node around a WFL. */
13910 static tree
13911 build_wfl_wrap (node)
13912 tree node;
13914 tree wfl, node_to_insert = node;
13916 /* We want to process THIS . xxx symbolicaly, to keep it consistent
13917 with the way we're processing SUPER. A THIS from a primary as a
13918 different form than a SUPER. Turn THIS into something symbolic */
13919 if (TREE_CODE (node) == THIS_EXPR)
13920 node_to_insert = wfl = build_wfl_node (this_identifier_node);
13921 else
13922 wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
13924 EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
13925 EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
13926 return wfl;
13930 /* Build a super() constructor invocation. Returns empty_stmt_node if
13931 we're currently dealing with the class java.lang.Object. */
13933 static tree
13934 build_super_invocation (mdecl)
13935 tree mdecl;
13937 if (DECL_CONTEXT (mdecl) == object_type_node)
13938 return empty_stmt_node;
13939 else
13941 tree super_wfl = build_wfl_node (super_identifier_node);
13942 tree a = NULL_TREE, t;
13943 /* If we're dealing with an anonymous class, pass the arguments
13944 of the crafted constructor along. */
13945 if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
13947 SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
13948 for (; t != end_params_node; t = TREE_CHAIN (t))
13949 a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
13951 return build_method_invocation (super_wfl, a);
13955 /* Build a SUPER/THIS qualified method invocation. */
13957 static tree
13958 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
13959 int use_this;
13960 tree name, args;
13961 int lloc, rloc;
13963 tree invok;
13964 tree wfl =
13965 build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
13966 EXPR_WFL_LINECOL (wfl) = lloc;
13967 invok = build_method_invocation (name, args);
13968 return make_qualified_primary (wfl, invok, rloc);
13971 /* Build an incomplete CALL_EXPR node. */
13973 static tree
13974 build_method_invocation (name, args)
13975 tree name;
13976 tree args;
13978 tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
13979 TREE_SIDE_EFFECTS (call) = 1;
13980 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
13981 return call;
13984 /* Build an incomplete new xxx(...) node. */
13986 static tree
13987 build_new_invocation (name, args)
13988 tree name, args;
13990 tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
13991 TREE_SIDE_EFFECTS (call) = 1;
13992 EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
13993 return call;
13996 /* Build an incomplete assignment expression. */
13998 static tree
13999 build_assignment (op, op_location, lhs, rhs)
14000 int op, op_location;
14001 tree lhs, rhs;
14003 tree assignment;
14004 /* Build the corresponding binop if we deal with a Compound
14005 Assignment operator. Mark the binop sub-tree as part of a
14006 Compound Assignment expression */
14007 if (op != ASSIGN_TK)
14009 rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14010 COMPOUND_ASSIGN_P (rhs) = 1;
14012 assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14013 TREE_SIDE_EFFECTS (assignment) = 1;
14014 EXPR_WFL_LINECOL (assignment) = op_location;
14015 return assignment;
14018 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14020 char *
14021 print_int_node (node)
14022 tree node;
14024 static char buffer [80];
14025 if (TREE_CONSTANT_OVERFLOW (node))
14026 sprintf (buffer, "<overflow>");
14028 if (TREE_INT_CST_HIGH (node) == 0)
14029 sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14030 TREE_INT_CST_LOW (node));
14031 else if (TREE_INT_CST_HIGH (node) == -1
14032 && TREE_INT_CST_LOW (node) != 0)
14034 buffer [0] = '-';
14035 sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14036 -TREE_INT_CST_LOW (node));
14038 else
14039 sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14040 TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14042 return buffer;
14045 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14046 context. */
14048 static int
14049 check_final_assignment (lvalue, wfl)
14050 tree lvalue, wfl;
14052 if (TREE_CODE (lvalue) == COMPOUND_EXPR
14053 && JDECL_P (TREE_OPERAND (lvalue, 1)))
14054 lvalue = TREE_OPERAND (lvalue, 1);
14056 /* When generating class files, references to the `length' field
14057 look a bit different. */
14058 if ((flag_emit_class_files
14059 && TREE_CODE (lvalue) == COMPONENT_REF
14060 && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14061 && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14062 || (TREE_CODE (lvalue) == FIELD_DECL
14063 && FIELD_FINAL (lvalue)
14064 && !DECL_CLINIT_P (current_function_decl)
14065 && !DECL_FINIT_P (current_function_decl)))
14067 parse_error_context
14068 (wfl, "Can't assign a value to the final variable `%s'",
14069 IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14070 return 1;
14072 return 0;
14075 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14076 read. This is needed to avoid circularities in the implementation
14077 of these fields in libjava. */
14079 static tree
14080 maybe_build_primttype_type_ref (rhs, wfl)
14081 tree rhs, wfl;
14083 tree to_return = NULL_TREE;
14084 tree rhs_type = TREE_TYPE (rhs);
14085 if (TREE_CODE (rhs) == COMPOUND_EXPR)
14087 tree n = TREE_OPERAND (rhs, 1);
14088 if (TREE_CODE (n) == VAR_DECL
14089 && DECL_NAME (n) == TYPE_identifier_node
14090 && rhs_type == class_ptr_type)
14092 const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14093 if (!strncmp (self_name, "java.lang.", 10))
14094 to_return = build_primtype_type_ref (self_name);
14097 return (to_return ? to_return : rhs );
14100 /* 15.25 Assignment operators. */
14102 static tree
14103 patch_assignment (node, wfl_op1, wfl_op2)
14104 tree node;
14105 tree wfl_op1;
14106 tree wfl_op2;
14108 tree rhs = TREE_OPERAND (node, 1);
14109 tree lvalue = TREE_OPERAND (node, 0), llvalue;
14110 tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14111 int error_found = 0;
14112 int lvalue_from_array = 0;
14114 /* Can't assign to a (blank) final. */
14115 if (check_final_assignment (lvalue, wfl_op1))
14116 error_found = 1;
14118 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14120 /* Lhs can be a named variable */
14121 if (JDECL_P (lvalue))
14123 lhs_type = TREE_TYPE (lvalue);
14125 /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14126 comment on reason why */
14127 else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14129 lhs_type = TREE_TYPE (lvalue);
14130 lvalue_from_array = 1;
14132 /* Or a field access */
14133 else if (TREE_CODE (lvalue) == COMPONENT_REF)
14134 lhs_type = TREE_TYPE (lvalue);
14135 /* Or a function return slot */
14136 else if (TREE_CODE (lvalue) == RESULT_DECL)
14137 lhs_type = TREE_TYPE (lvalue);
14138 /* Otherwise, we might want to try to write into an optimized static
14139 final, this is an of a different nature, reported further on. */
14140 else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14141 && resolve_expression_name (wfl_op1, &llvalue))
14143 if (!error_found && check_final_assignment (llvalue, wfl_op1))
14145 /* What we should do instead is resetting the all the flags
14146 previously set, exchange lvalue for llvalue and continue. */
14147 error_found = 1;
14148 return error_mark_node;
14150 else
14151 lhs_type = TREE_TYPE (lvalue);
14153 else
14155 parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14156 error_found = 1;
14159 rhs_type = TREE_TYPE (rhs);
14160 /* 5.1 Try the assignment conversion for builtin type. */
14161 new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14163 /* 5.2 If it failed, try a reference conversion */
14164 if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14165 lhs_type = promote_type (rhs_type);
14167 /* 15.25.2 If we have a compound assignment, convert RHS into the
14168 type of the LHS */
14169 else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14170 new_rhs = convert (lhs_type, rhs);
14172 /* Explicit cast required. This is an error */
14173 if (!new_rhs)
14175 char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14176 char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14177 tree wfl;
14178 char operation [32]; /* Max size known */
14180 /* If the assignment is part of a declaration, we use the WFL of
14181 the declared variable to point out the error and call it a
14182 declaration problem. If the assignment is a genuine =
14183 operator, we call is a operator `=' problem, otherwise we
14184 call it an assignment problem. In both of these last cases,
14185 we use the WFL of the operator to indicate the error. */
14187 if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14189 wfl = wfl_op1;
14190 strcpy (operation, "declaration");
14192 else
14194 wfl = wfl_operator;
14195 if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14196 strcpy (operation, "assignment");
14197 else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14198 strcpy (operation, "`return'");
14199 else
14200 strcpy (operation, "`='");
14203 if (!valid_cast_to_p (rhs_type, lhs_type))
14204 parse_error_context
14205 (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14206 operation, t1, t2);
14207 else
14208 parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14209 operation, t1, t2);
14210 free (t1); free (t2);
14211 error_found = 1;
14214 /* Inline read access to java.lang.PRIMTYPE.TYPE */
14215 if (new_rhs)
14216 new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14218 if (error_found)
14219 return error_mark_node;
14221 /* 10.10: Array Store Exception runtime check */
14222 if (!flag_emit_class_files
14223 && !flag_emit_xref
14224 && lvalue_from_array
14225 && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14227 tree check;
14228 tree base = lvalue;
14230 /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14231 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14232 base = TREE_OPERAND (lvalue, 0);
14233 else
14235 if (flag_bounds_check)
14236 base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14237 else
14238 base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14241 /* Build the invocation of _Jv_CheckArrayStore */
14242 new_rhs = save_expr (new_rhs);
14243 check = build (CALL_EXPR, void_type_node,
14244 build_address_of (soft_checkarraystore_node),
14245 tree_cons (NULL_TREE, base,
14246 build_tree_list (NULL_TREE, new_rhs)),
14247 NULL_TREE);
14248 TREE_SIDE_EFFECTS (check) = 1;
14250 /* We have to decide on an insertion point */
14251 if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14253 tree t;
14254 if (flag_bounds_check)
14256 t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14257 TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14258 build (COMPOUND_EXPR, void_type_node, t, check);
14260 else
14261 TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14262 check, TREE_OPERAND (lvalue, 1));
14264 else
14266 /* Make sure the bound check will happen before the store check */
14267 if (flag_bounds_check)
14268 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14269 build (COMPOUND_EXPR, void_type_node,
14270 TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14271 else
14272 lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14276 TREE_OPERAND (node, 0) = lvalue;
14277 TREE_OPERAND (node, 1) = new_rhs;
14278 TREE_TYPE (node) = lhs_type;
14279 return node;
14282 /* Check that type SOURCE can be cast into type DEST. If the cast
14283 can't occur at all, return 0 otherwise 1. This function is used to
14284 produce accurate error messages on the reasons why an assignment
14285 failed. */
14287 static tree
14288 try_reference_assignconv (lhs_type, rhs)
14289 tree lhs_type, rhs;
14291 tree new_rhs = NULL_TREE;
14292 tree rhs_type = TREE_TYPE (rhs);
14294 if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14296 /* `null' may be assigned to any reference type */
14297 if (rhs == null_pointer_node)
14298 new_rhs = null_pointer_node;
14299 /* Try the reference assignment conversion */
14300 else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14301 new_rhs = rhs;
14302 /* This is a magic assignment that we process differently */
14303 else if (rhs == soft_exceptioninfo_call_node)
14304 new_rhs = rhs;
14306 return new_rhs;
14309 /* Check that RHS can be converted into LHS_TYPE by the assignment
14310 conversion (5.2), for the cases of RHS being a builtin type. Return
14311 NULL_TREE if the conversion fails or if because RHS isn't of a
14312 builtin type. Return a converted RHS if the conversion is possible. */
14314 static tree
14315 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14316 tree wfl_op1, lhs_type, rhs;
14318 tree new_rhs = NULL_TREE;
14319 tree rhs_type = TREE_TYPE (rhs);
14321 /* Zero accepted everywhere */
14322 if (TREE_CODE (rhs) == INTEGER_CST
14323 && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14324 && JPRIMITIVE_TYPE_P (rhs_type))
14325 new_rhs = convert (lhs_type, rhs);
14327 /* 5.1.1 Try Identity Conversion,
14328 5.1.2 Try Widening Primitive Conversion */
14329 else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14330 new_rhs = convert (lhs_type, rhs);
14332 /* Try a narrowing primitive conversion (5.1.3):
14333 - expression is a constant expression of type int AND
14334 - variable is byte, short or char AND
14335 - The value of the expression is representable in the type of the
14336 variable */
14337 else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14338 && (lhs_type == byte_type_node || lhs_type == char_type_node
14339 || lhs_type == short_type_node))
14341 if (int_fits_type_p (rhs, lhs_type))
14342 new_rhs = convert (lhs_type, rhs);
14343 else if (wfl_op1) /* Might be called with a NULL */
14344 parse_warning_context
14345 (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'",
14346 print_int_node (rhs), lang_printable_name (lhs_type, 0));
14347 /* Reported a warning that will turn into an error further
14348 down, so we don't return */
14351 return new_rhs;
14354 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14355 conversion (5.1.1) or widening primitve conversion (5.1.2). Return
14356 0 is the conversion test fails. This implements parts the method
14357 invocation convertion (5.3). */
14359 static int
14360 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14361 tree lhs_type, rhs_type;
14363 /* 5.1.1: This is the identity conversion part. */
14364 if (lhs_type == rhs_type)
14365 return 1;
14367 /* Reject non primitive types */
14368 if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14369 return 0;
14371 /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14372 than a char can't be converted into a char. Short can't too, but
14373 the < test below takes care of that */
14374 if (lhs_type == char_type_node && rhs_type == byte_type_node)
14375 return 0;
14377 /* Accept all promoted type here. Note, we can't use <= in the test
14378 below, because we still need to bounce out assignments of short
14379 to char and the likes */
14380 if (lhs_type == int_type_node
14381 && (rhs_type == promoted_byte_type_node
14382 || rhs_type == promoted_short_type_node
14383 || rhs_type == promoted_char_type_node
14384 || rhs_type == promoted_boolean_type_node))
14385 return 1;
14387 /* From here, an integral is widened if its precision is smaller
14388 than the precision of the LHS or if the LHS is a floating point
14389 type, or the RHS is a float and the RHS a double. */
14390 if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type)
14391 && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14392 || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14393 || (rhs_type == float_type_node && lhs_type == double_type_node))
14394 return 1;
14396 return 0;
14399 /* Check that something of SOURCE type can be assigned or cast to
14400 something of DEST type at runtime. Return 1 if the operation is
14401 valid, 0 otherwise. If CAST is set to 1, we're treating the case
14402 were SOURCE is cast into DEST, which borrows a lot of the
14403 assignment check. */
14405 static int
14406 valid_ref_assignconv_cast_p (source, dest, cast)
14407 tree source;
14408 tree dest;
14409 int cast;
14411 /* SOURCE or DEST might be null if not from a declared entity. */
14412 if (!source || !dest)
14413 return 0;
14414 if (JNULLP_TYPE_P (source))
14415 return 1;
14416 if (TREE_CODE (source) == POINTER_TYPE)
14417 source = TREE_TYPE (source);
14418 if (TREE_CODE (dest) == POINTER_TYPE)
14419 dest = TREE_TYPE (dest);
14420 /* Case where SOURCE is a class type */
14421 if (TYPE_CLASS_P (source))
14423 if (TYPE_CLASS_P (dest))
14424 return (source == dest
14425 || inherits_from_p (source, dest)
14426 || enclosing_context_p (dest, source /*source, dest*/)
14427 || (cast && inherits_from_p (dest, source)));
14428 if (TYPE_INTERFACE_P (dest))
14430 /* If doing a cast and SOURCE is final, the operation is
14431 always correct a compile time (because even if SOURCE
14432 does not implement DEST, a subclass of SOURCE might). */
14433 if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14434 return 1;
14435 /* Otherwise, SOURCE must implement DEST */
14436 return interface_of_p (dest, source);
14438 /* DEST is an array, cast permited if SOURCE is of Object type */
14439 return (cast && source == object_type_node ? 1 : 0);
14441 if (TYPE_INTERFACE_P (source))
14443 if (TYPE_CLASS_P (dest))
14445 /* If not casting, DEST must be the Object type */
14446 if (!cast)
14447 return dest == object_type_node;
14448 /* We're doing a cast. The cast is always valid is class
14449 DEST is not final, otherwise, DEST must implement SOURCE */
14450 else if (!CLASS_FINAL (TYPE_NAME (dest)))
14451 return 1;
14452 else
14453 return interface_of_p (source, dest);
14455 if (TYPE_INTERFACE_P (dest))
14457 /* If doing a cast, then if SOURCE and DEST contain method
14458 with the same signature but different return type, then
14459 this is a (compile time) error */
14460 if (cast)
14462 tree method_source, method_dest;
14463 tree source_type;
14464 tree source_sig;
14465 tree source_name;
14466 for (method_source = TYPE_METHODS (source); method_source;
14467 method_source = TREE_CHAIN (method_source))
14469 source_sig =
14470 build_java_argument_signature (TREE_TYPE (method_source));
14471 source_type = TREE_TYPE (TREE_TYPE (method_source));
14472 source_name = DECL_NAME (method_source);
14473 for (method_dest = TYPE_METHODS (dest);
14474 method_dest; method_dest = TREE_CHAIN (method_dest))
14475 if (source_sig ==
14476 build_java_argument_signature (TREE_TYPE (method_dest))
14477 && source_name == DECL_NAME (method_dest)
14478 && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14479 return 0;
14481 return 1;
14483 else
14484 return source == dest || interface_of_p (dest, source);
14486 else /* Array */
14487 return (cast ?
14488 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14490 if (TYPE_ARRAY_P (source))
14492 if (TYPE_CLASS_P (dest))
14493 return dest == object_type_node;
14494 /* Can't cast an array to an interface unless the interface is
14495 java.lang.Cloneable */
14496 if (TYPE_INTERFACE_P (dest))
14497 return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14498 else /* Arrays */
14500 tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14501 tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14503 /* In case of severe errors, they turn out null */
14504 if (!dest_element_type || !source_element_type)
14505 return 0;
14506 if (source_element_type == dest_element_type)
14507 return 1;
14508 return valid_ref_assignconv_cast_p (source_element_type,
14509 dest_element_type, cast);
14511 return 0;
14513 return 0;
14516 static int
14517 valid_cast_to_p (source, dest)
14518 tree source;
14519 tree dest;
14521 if (TREE_CODE (source) == POINTER_TYPE)
14522 source = TREE_TYPE (source);
14523 if (TREE_CODE (dest) == POINTER_TYPE)
14524 dest = TREE_TYPE (dest);
14526 if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14527 return valid_ref_assignconv_cast_p (source, dest, 1);
14529 else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14530 return 1;
14532 return 0;
14535 /* Method invocation conversion test. Return 1 if type SOURCE can be
14536 converted to type DEST through the methond invocation conversion
14537 process (5.3) */
14539 static tree
14540 do_unary_numeric_promotion (arg)
14541 tree arg;
14543 tree type = TREE_TYPE (arg);
14544 if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14545 : TREE_CODE (type) == CHAR_TYPE)
14546 arg = convert (int_type_node, arg);
14547 return arg;
14550 /* Return a non zero value if SOURCE can be converted into DEST using
14551 the method invocation conversion rule (5.3). */
14552 static int
14553 valid_method_invocation_conversion_p (dest, source)
14554 tree dest, source;
14556 return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14557 && valid_builtin_assignconv_identity_widening_p (dest, source))
14558 || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14559 && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14560 && valid_ref_assignconv_cast_p (source, dest, 0)));
14563 /* Build an incomplete binop expression. */
14565 static tree
14566 build_binop (op, op_location, op1, op2)
14567 enum tree_code op;
14568 int op_location;
14569 tree op1, op2;
14571 tree binop = build (op, NULL_TREE, op1, op2);
14572 TREE_SIDE_EFFECTS (binop) = 1;
14573 /* Store the location of the operator, for better error report. The
14574 string of the operator will be rebuild based on the OP value. */
14575 EXPR_WFL_LINECOL (binop) = op_location;
14576 return binop;
14579 /* Build the string of the operator retained by NODE. If NODE is part
14580 of a compound expression, add an '=' at the end of the string. This
14581 function is called when an error needs to be reported on an
14582 operator. The string is returned as a pointer to a static character
14583 buffer. */
14585 static char *
14586 operator_string (node)
14587 tree node;
14589 #define BUILD_OPERATOR_STRING(S) \
14591 sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14592 return buffer; \
14595 static char buffer [10];
14596 switch (TREE_CODE (node))
14598 case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14599 case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14600 case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14601 case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14602 case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14603 case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14604 case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14605 case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14606 case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14607 case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14608 case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14609 case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14610 case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14611 case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14612 case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14613 case GT_EXPR: BUILD_OPERATOR_STRING (">");
14614 case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14615 case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14616 case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14617 case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14618 case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14619 case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14620 case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14621 case PREINCREMENT_EXPR: /* Fall through */
14622 case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14623 case PREDECREMENT_EXPR: /* Fall through */
14624 case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14625 default:
14626 fatal ("unregistered operator %s - operator_string",
14627 tree_code_name [TREE_CODE (node)]);
14629 return NULL;
14630 #undef BUILD_OPERATOR_STRING
14633 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2. */
14635 static int
14636 java_decl_equiv (var_acc1, var_acc2)
14637 tree var_acc1, var_acc2;
14639 if (JDECL_P (var_acc1))
14640 return (var_acc1 == var_acc2);
14642 return (TREE_CODE (var_acc1) == COMPONENT_REF
14643 && TREE_CODE (var_acc2) == COMPONENT_REF
14644 && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14645 == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14646 && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14649 /* Return a non zero value if CODE is one of the operators that can be
14650 used in conjunction with the `=' operator in a compound assignment. */
14652 static int
14653 binop_compound_p (code)
14654 enum tree_code code;
14656 int i;
14657 for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14658 if (binop_lookup [i] == code)
14659 break;
14661 return i < BINOP_COMPOUND_CANDIDATES;
14664 /* Reorganize after a fold to get SAVE_EXPR to generate what we want. */
14666 static tree
14667 java_refold (t)
14668 tree t;
14670 tree c, b, ns, decl;
14672 if (TREE_CODE (t) != MODIFY_EXPR)
14673 return t;
14675 c = TREE_OPERAND (t, 1);
14676 if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14677 && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14678 && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14679 return t;
14681 /* Now the left branch of the binary operator. */
14682 b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14683 if (! (b && TREE_CODE (b) == NOP_EXPR
14684 && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14685 return t;
14687 ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14688 if (! (ns && TREE_CODE (ns) == NOP_EXPR
14689 && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14690 return t;
14692 decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14693 if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14694 /* It's got to be the an equivalent decl */
14695 && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14697 /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14698 TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14699 /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14700 TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14701 /* Change the right part of the BINOP_EXPR */
14702 TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14705 return t;
14708 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14709 errors but we modify NODE so that it contains the type computed
14710 according to the expression, when it's fixed. Otherwise, we write
14711 error_mark_node as the type. It allows us to further the analysis
14712 of remaining nodes and detects more errors in certain cases. */
14714 static tree
14715 patch_binop (node, wfl_op1, wfl_op2)
14716 tree node;
14717 tree wfl_op1;
14718 tree wfl_op2;
14720 tree op1 = TREE_OPERAND (node, 0);
14721 tree op2 = TREE_OPERAND (node, 1);
14722 tree op1_type = TREE_TYPE (op1);
14723 tree op2_type = TREE_TYPE (op2);
14724 tree prom_type = NULL_TREE;
14725 int code = TREE_CODE (node);
14727 /* If 1, tell the routine that we have to return error_mark_node
14728 after checking for the initialization of the RHS */
14729 int error_found = 0;
14731 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14733 switch (code)
14735 /* 15.16 Multiplicative operators */
14736 case MULT_EXPR: /* 15.16.1 Multiplication Operator * */
14737 case RDIV_EXPR: /* 15.16.2 Division Operator / */
14738 case TRUNC_DIV_EXPR: /* 15.16.2 Integral type Division Operator / */
14739 case TRUNC_MOD_EXPR: /* 15.16.3 Remainder operator % */
14740 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14742 if (!JPRIMITIVE_TYPE_P (op1_type))
14743 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14744 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14745 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14746 TREE_TYPE (node) = error_mark_node;
14747 error_found = 1;
14748 break;
14750 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14751 /* Change the division operator if necessary */
14752 if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14753 TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14755 if (TREE_CODE (prom_type) == INTEGER_TYPE
14756 && flag_use_divide_subroutine
14757 && ! flag_emit_class_files
14758 && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14759 return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14761 /* This one is more complicated. FLOATs are processed by a
14762 function call to soft_fmod. Duplicate the value of the
14763 COMPOUND_ASSIGN_P flag. */
14764 if (code == TRUNC_MOD_EXPR)
14766 tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
14767 COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
14768 TREE_SIDE_EFFECTS (mod)
14769 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14770 return mod;
14772 break;
14774 /* 15.17 Additive Operators */
14775 case PLUS_EXPR: /* 15.17.1 String Concatenation Operator + */
14777 /* Operation is valid if either one argument is a string
14778 constant, a String object or a StringBuffer crafted for the
14779 purpose of the a previous usage of the String concatenation
14780 operator */
14782 if (TREE_CODE (op1) == STRING_CST
14783 || TREE_CODE (op2) == STRING_CST
14784 || JSTRING_TYPE_P (op1_type)
14785 || JSTRING_TYPE_P (op2_type)
14786 || IS_CRAFTED_STRING_BUFFER_P (op1)
14787 || IS_CRAFTED_STRING_BUFFER_P (op2))
14788 return build_string_concatenation (op1, op2);
14790 case MINUS_EXPR: /* 15.17.2 Additive Operators (+ and -) for
14791 Numeric Types */
14792 if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14794 if (!JPRIMITIVE_TYPE_P (op1_type))
14795 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14796 if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14797 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14798 TREE_TYPE (node) = error_mark_node;
14799 error_found = 1;
14800 break;
14802 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14803 break;
14805 /* 15.18 Shift Operators */
14806 case LSHIFT_EXPR:
14807 case RSHIFT_EXPR:
14808 case URSHIFT_EXPR:
14809 if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
14811 if (!JINTEGRAL_TYPE_P (op1_type))
14812 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14813 else
14815 if (JPRIMITIVE_TYPE_P (op2_type))
14816 parse_error_context (wfl_operator,
14817 "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
14818 operator_string (node),
14819 lang_printable_name (op2_type, 0));
14820 else
14821 parse_error_context (wfl_operator,
14822 "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral",
14823 operator_string (node),
14824 lang_printable_name (op2_type, 0));
14826 TREE_TYPE (node) = error_mark_node;
14827 error_found = 1;
14828 break;
14831 /* Unary numeric promotion (5.6.1) is performed on each operand
14832 separatly */
14833 op1 = do_unary_numeric_promotion (op1);
14834 op2 = do_unary_numeric_promotion (op2);
14836 /* The type of the shift expression is the type of the promoted
14837 type of the left-hand operand */
14838 prom_type = TREE_TYPE (op1);
14840 /* Shift int only up to 0x1f and long up to 0x3f */
14841 if (prom_type == int_type_node)
14842 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14843 build_int_2 (0x1f, 0)));
14844 else
14845 op2 = fold (build (BIT_AND_EXPR, int_type_node, op2,
14846 build_int_2 (0x3f, 0)));
14848 /* The >>> operator is a >> operating on unsigned quantities */
14849 if (code == URSHIFT_EXPR && ! flag_emit_class_files)
14851 tree to_return;
14852 tree utype = unsigned_type (prom_type);
14853 op1 = convert (utype, op1);
14854 TREE_SET_CODE (node, RSHIFT_EXPR);
14855 TREE_OPERAND (node, 0) = op1;
14856 TREE_OPERAND (node, 1) = op2;
14857 TREE_TYPE (node) = utype;
14858 to_return = convert (prom_type, node);
14859 /* Copy the original value of the COMPOUND_ASSIGN_P flag */
14860 COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
14861 TREE_SIDE_EFFECTS (to_return)
14862 = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14863 return to_return;
14865 break;
14867 /* 15.19.1 Type Comparison Operator instaceof */
14868 case INSTANCEOF_EXPR:
14870 TREE_TYPE (node) = boolean_type_node;
14872 if (!(op2_type = resolve_type_during_patch (op2)))
14873 return error_mark_node;
14875 /* The first operand must be a reference type or the null type */
14876 if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
14877 error_found = 1; /* Error reported further below */
14879 /* The second operand must be a reference type */
14880 if (!JREFERENCE_TYPE_P (op2_type))
14882 SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14883 parse_error_context
14884 (wfl_operator, "Invalid argument `%s' for `instanceof'",
14885 lang_printable_name (op2_type, 0));
14886 error_found = 1;
14889 if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
14891 /* If the first operand is null, the result is always false */
14892 if (op1 == null_pointer_node)
14893 return boolean_false_node;
14894 else if (flag_emit_class_files)
14896 TREE_OPERAND (node, 1) = op2_type;
14897 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
14898 return node;
14900 /* Otherwise we have to invoke instance of to figure it out */
14901 else
14903 tree call =
14904 build (CALL_EXPR, boolean_type_node,
14905 build_address_of (soft_instanceof_node),
14906 tree_cons
14907 (NULL_TREE, op1,
14908 build_tree_list (NULL_TREE,
14909 build_class_ref (op2_type))),
14910 NULL_TREE);
14911 TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
14912 return call;
14915 /* There is no way the expression operand can be an instance of
14916 the type operand. This is a compile time error. */
14917 else
14919 char *t1 = xstrdup (lang_printable_name (op1_type, 0));
14920 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14921 parse_error_context
14922 (wfl_operator, "Impossible for `%s' to be instance of `%s'",
14923 t1, lang_printable_name (op2_type, 0));
14924 free (t1);
14925 error_found = 1;
14928 break;
14930 /* 15.21 Bitwise and Logical Operators */
14931 case BIT_AND_EXPR:
14932 case BIT_XOR_EXPR:
14933 case BIT_IOR_EXPR:
14934 if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
14935 /* Binary numeric promotion is performed on both operand and the
14936 expression retain that type */
14937 prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14939 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE
14940 && TREE_CODE (op1_type) == BOOLEAN_TYPE)
14941 /* The type of the bitwise operator expression is BOOLEAN */
14942 prom_type = boolean_type_node;
14943 else
14945 if (!JINTEGRAL_TYPE_P (op1_type))
14946 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14947 if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
14948 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
14949 TREE_TYPE (node) = error_mark_node;
14950 error_found = 1;
14951 /* Insert a break here if adding thing before the switch's
14952 break for this case */
14954 break;
14956 /* 15.22 Conditional-And Operator */
14957 case TRUTH_ANDIF_EXPR:
14958 /* 15.23 Conditional-Or Operator */
14959 case TRUTH_ORIF_EXPR:
14960 /* Operands must be of BOOLEAN type */
14961 if (TREE_CODE (op1_type) != BOOLEAN_TYPE ||
14962 TREE_CODE (op2_type) != BOOLEAN_TYPE)
14964 if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
14965 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
14966 if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
14967 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
14968 TREE_TYPE (node) = boolean_type_node;
14969 error_found = 1;
14970 break;
14972 /* The type of the conditional operators is BOOLEAN */
14973 prom_type = boolean_type_node;
14974 break;
14976 /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
14977 case LT_EXPR:
14978 case GT_EXPR:
14979 case LE_EXPR:
14980 case GE_EXPR:
14981 /* The type of each of the operands must be a primitive numeric
14982 type */
14983 if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
14985 if (!JNUMERIC_TYPE_P (op1_type))
14986 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14987 if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
14988 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14989 TREE_TYPE (node) = boolean_type_node;
14990 error_found = 1;
14991 break;
14993 /* Binary numeric promotion is performed on the operands */
14994 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14995 /* The type of the relation expression is always BOOLEAN */
14996 prom_type = boolean_type_node;
14997 break;
14999 /* 15.20 Equality Operator */
15000 case EQ_EXPR:
15001 case NE_EXPR:
15002 /* 15.20.1 Numerical Equality Operators == and != */
15003 /* Binary numeric promotion is performed on the operands */
15004 if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15005 binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15007 /* 15.20.2 Boolean Equality Operators == and != */
15008 else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15009 TREE_CODE (op2_type) == BOOLEAN_TYPE)
15010 ; /* Nothing to do here */
15012 /* 15.20.3 Reference Equality Operators == and != */
15013 /* Types have to be either references or the null type. If
15014 they're references, it must be possible to convert either
15015 type to the other by casting conversion. */
15016 else if (op1 == null_pointer_node || op2 == null_pointer_node
15017 || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15018 && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15019 || valid_ref_assignconv_cast_p (op2_type,
15020 op1_type, 1))))
15021 ; /* Nothing to do here */
15023 /* Else we have an error figure what can't be converted into
15024 what and report the error */
15025 else
15027 char *t1;
15028 t1 = xstrdup (lang_printable_name (op1_type, 0));
15029 parse_error_context
15030 (wfl_operator,
15031 "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15032 operator_string (node), t1,
15033 lang_printable_name (op2_type, 0));
15034 free (t1);
15035 TREE_TYPE (node) = boolean_type_node;
15036 error_found = 1;
15037 break;
15039 prom_type = boolean_type_node;
15040 break;
15043 if (error_found)
15044 return error_mark_node;
15046 TREE_OPERAND (node, 0) = op1;
15047 TREE_OPERAND (node, 1) = op2;
15048 TREE_TYPE (node) = prom_type;
15049 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15051 if (flag_emit_xref)
15052 return node;
15054 /* fold does not respect side-effect order as required for Java but not C.
15055 * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15056 * bytecode.
15058 if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15059 : ! TREE_SIDE_EFFECTS (node))
15060 node = fold (node);
15061 return node;
15064 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15065 zero value, the value of CSTE comes after the valude of STRING */
15067 static tree
15068 do_merge_string_cste (cste, string, string_len, after)
15069 tree cste;
15070 const char *string;
15071 int string_len, after;
15073 int len = TREE_STRING_LENGTH (cste) + string_len;
15074 const char *old = TREE_STRING_POINTER (cste);
15075 TREE_STRING_LENGTH (cste) = len;
15076 TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15077 if (after)
15079 strcpy (TREE_STRING_POINTER (cste), string);
15080 strcat (TREE_STRING_POINTER (cste), old);
15082 else
15084 strcpy (TREE_STRING_POINTER (cste), old);
15085 strcat (TREE_STRING_POINTER (cste), string);
15087 return cste;
15090 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15091 new STRING_CST on success, NULL_TREE on failure */
15093 static tree
15094 merge_string_cste (op1, op2, after)
15095 tree op1, op2;
15096 int after;
15098 /* Handle two string constants right away */
15099 if (TREE_CODE (op2) == STRING_CST)
15100 return do_merge_string_cste (op1, TREE_STRING_POINTER (op2),
15101 TREE_STRING_LENGTH (op2), after);
15103 /* Reasonable integer constant can be treated right away */
15104 if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15106 static const char *boolean_true = "true";
15107 static const char *boolean_false = "false";
15108 static const char *null_pointer = "null";
15109 char ch[3];
15110 const char *string;
15112 if (op2 == boolean_true_node)
15113 string = boolean_true;
15114 else if (op2 == boolean_false_node)
15115 string = boolean_false;
15116 else if (op2 == null_pointer_node)
15117 string = null_pointer;
15118 else if (TREE_TYPE (op2) == char_type_node)
15120 ch[0] = (char )TREE_INT_CST_LOW (op2);
15121 ch[1] = '\0';
15122 string = ch;
15124 else
15125 string = print_int_node (op2);
15127 return do_merge_string_cste (op1, string, strlen (string), after);
15129 return NULL_TREE;
15132 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15133 has to be a STRING_CST and the other part must be a STRING_CST or a
15134 INTEGRAL constant. Return a new STRING_CST if the operation
15135 succeed, NULL_TREE otherwise.
15137 If the case we want to optimize for space, we might want to return
15138 NULL_TREE for each invocation of this routine. FIXME */
15140 static tree
15141 string_constant_concatenation (op1, op2)
15142 tree op1, op2;
15144 if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15146 tree string, rest;
15147 int invert;
15149 string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15150 rest = (string == op1 ? op2 : op1);
15151 invert = (string == op1 ? 0 : 1 );
15153 /* Walk REST, only if it looks reasonable */
15154 if (TREE_CODE (rest) != STRING_CST
15155 && !IS_CRAFTED_STRING_BUFFER_P (rest)
15156 && !JSTRING_TYPE_P (TREE_TYPE (rest))
15157 && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15159 rest = java_complete_tree (rest);
15160 if (rest == error_mark_node)
15161 return error_mark_node;
15162 rest = fold (rest);
15164 return merge_string_cste (string, rest, invert);
15166 return NULL_TREE;
15169 /* Implement the `+' operator. Does static optimization if possible,
15170 otherwise create (if necessary) and append elements to a
15171 StringBuffer. The StringBuffer will be carried around until it is
15172 used for a function call or an assignment. Then toString() will be
15173 called on it to turn it into a String object. */
15175 static tree
15176 build_string_concatenation (op1, op2)
15177 tree op1, op2;
15179 tree result;
15180 int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15182 if (flag_emit_xref)
15183 return build (PLUS_EXPR, string_type_node, op1, op2);
15185 /* Try to do some static optimization */
15186 if ((result = string_constant_concatenation (op1, op2)))
15187 return result;
15189 /* Discard empty strings on either side of the expression */
15190 if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15192 op1 = op2;
15193 op2 = NULL_TREE;
15195 else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15196 op2 = NULL_TREE;
15198 /* If operands are string constant, turn then into object references */
15199 if (TREE_CODE (op1) == STRING_CST)
15200 op1 = patch_string_cst (op1);
15201 if (op2 && TREE_CODE (op2) == STRING_CST)
15202 op2 = patch_string_cst (op2);
15204 /* If either one of the constant is null and the other non null
15205 operand is a String object, return it. */
15206 if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15207 return op1;
15209 /* If OP1 isn't already a StringBuffer, create and
15210 initialize a new one */
15211 if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15213 /* Two solutions here:
15214 1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15215 2) OP1 is something else, we call new StringBuffer().append(OP1). */
15216 if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15217 op1 = BUILD_STRING_BUFFER (op1);
15218 else
15220 tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15221 op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15225 if (op2)
15227 /* OP1 is no longer the last node holding a crafted StringBuffer */
15228 IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15229 /* Create a node for `{new...,xxx}.append (op2)' */
15230 if (op2)
15231 op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15234 /* Mark the last node holding a crafted StringBuffer */
15235 IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15237 TREE_SIDE_EFFECTS (op1) = side_effects;
15238 return op1;
15241 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15242 StringBuffer. If no string were found to be patched, return
15243 NULL. */
15245 static tree
15246 patch_string (node)
15247 tree node;
15249 if (node == error_mark_node)
15250 return error_mark_node;
15251 if (TREE_CODE (node) == STRING_CST)
15252 return patch_string_cst (node);
15253 else if (IS_CRAFTED_STRING_BUFFER_P (node))
15255 int saved = ctxp->explicit_constructor_p;
15256 tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15257 tree ret;
15258 /* Temporary disable forbid the use of `this'. */
15259 ctxp->explicit_constructor_p = 0;
15260 ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15261 /* String concatenation arguments must be evaluated in order too. */
15262 ret = force_evaluation_order (ret);
15263 /* Restore it at its previous value */
15264 ctxp->explicit_constructor_p = saved;
15265 return ret;
15267 return NULL_TREE;
15270 /* Build the internal representation of a string constant. */
15272 static tree
15273 patch_string_cst (node)
15274 tree node;
15276 int location;
15277 if (! flag_emit_class_files)
15279 push_obstacks (&permanent_obstack, &permanent_obstack);
15280 node = get_identifier (TREE_STRING_POINTER (node));
15281 location = alloc_name_constant (CONSTANT_String, node);
15282 node = build_ref_from_constant_pool (location);
15283 pop_obstacks ();
15285 TREE_TYPE (node) = string_ptr_type_node;
15286 TREE_CONSTANT (node) = 1;
15287 return node;
15290 /* Build an incomplete unary operator expression. */
15292 static tree
15293 build_unaryop (op_token, op_location, op1)
15294 int op_token, op_location;
15295 tree op1;
15297 enum tree_code op;
15298 tree unaryop;
15299 switch (op_token)
15301 case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15302 case MINUS_TK: op = NEGATE_EXPR; break;
15303 case NEG_TK: op = TRUTH_NOT_EXPR; break;
15304 case NOT_TK: op = BIT_NOT_EXPR; break;
15305 default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15306 op_token);
15309 unaryop = build1 (op, NULL_TREE, op1);
15310 TREE_SIDE_EFFECTS (unaryop) = 1;
15311 /* Store the location of the operator, for better error report. The
15312 string of the operator will be rebuild based on the OP value. */
15313 EXPR_WFL_LINECOL (unaryop) = op_location;
15314 return unaryop;
15317 /* Special case for the ++/-- operators, since they require an extra
15318 argument to build, which is set to NULL and patched
15319 later. IS_POST_P is 1 if the operator, 0 otherwise. */
15321 static tree
15322 build_incdec (op_token, op_location, op1, is_post_p)
15323 int op_token, op_location;
15324 tree op1;
15325 int is_post_p;
15327 static enum tree_code lookup [2][2] =
15329 { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15330 { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15332 tree node = build (lookup [is_post_p][(op_token - DECR_TK)],
15333 NULL_TREE, op1, NULL_TREE);
15334 TREE_SIDE_EFFECTS (node) = 1;
15335 /* Store the location of the operator, for better error report. The
15336 string of the operator will be rebuild based on the OP value. */
15337 EXPR_WFL_LINECOL (node) = op_location;
15338 return node;
15341 /* Build an incomplete cast operator, based on the use of the
15342 CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15343 set. java_complete_tree is trained to walk a CONVERT_EXPR even
15344 though its type is already set. */
15346 static tree
15347 build_cast (location, type, exp)
15348 int location;
15349 tree type, exp;
15351 tree node = build1 (CONVERT_EXPR, type, exp);
15352 EXPR_WFL_LINECOL (node) = location;
15353 return node;
15356 /* Build an incomplete class reference operator. */
15357 static tree
15358 build_incomplete_class_ref (location, class_name)
15359 int location;
15360 tree class_name;
15362 tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15363 EXPR_WFL_LINECOL (node) = location;
15364 return node;
15367 /* Complete an incomplete class reference operator. */
15368 static tree
15369 patch_incomplete_class_ref (node)
15370 tree node;
15372 tree type = TREE_OPERAND (node, 0);
15373 tree ref_type;
15375 if (!(ref_type = resolve_type_during_patch (type)))
15376 return error_mark_node;
15378 if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15379 return build_class_ref (ref_type);
15381 /* If we're emitting class files and we have to deal with non
15382 primitive types, we invoke (and consider generating) the
15383 synthetic static method `class$'. */
15384 if (!TYPE_DOT_CLASS (current_class))
15385 build_dot_class_method (current_class);
15386 ref_type =
15387 build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15388 return java_complete_tree (ref_type);
15391 /* 15.14 Unary operators. We return error_mark_node in case of error,
15392 but preserve the type of NODE if the type is fixed. */
15394 static tree
15395 patch_unaryop (node, wfl_op)
15396 tree node;
15397 tree wfl_op;
15399 tree op = TREE_OPERAND (node, 0);
15400 tree op_type = TREE_TYPE (op);
15401 tree prom_type = NULL_TREE, value, decl;
15402 int outer_field_flag = 0;
15403 int code = TREE_CODE (node);
15404 int error_found = 0;
15406 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15408 switch (code)
15410 /* 15.13.2 Postfix Increment Operator ++ */
15411 case POSTINCREMENT_EXPR:
15412 /* 15.13.3 Postfix Increment Operator -- */
15413 case POSTDECREMENT_EXPR:
15414 /* 15.14.1 Prefix Increment Operator ++ */
15415 case PREINCREMENT_EXPR:
15416 /* 15.14.2 Prefix Decrement Operator -- */
15417 case PREDECREMENT_EXPR:
15418 op = decl = strip_out_static_field_access_decl (op);
15419 outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15420 /* We might be trying to change an outer field accessed using
15421 access method. */
15422 if (outer_field_flag)
15424 /* Retrieve the decl of the field we're trying to access. We
15425 do that by first retrieving the function we would call to
15426 access the field. It has been already verified that this
15427 field isn't final */
15428 if (flag_emit_class_files)
15429 decl = TREE_OPERAND (op, 0);
15430 else
15431 decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15432 decl = DECL_FUNCTION_ACCESS_DECL (decl);
15434 /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15435 else if (!JDECL_P (decl)
15436 && TREE_CODE (decl) != COMPONENT_REF
15437 && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15438 && TREE_CODE (decl) != INDIRECT_REF
15439 && !(TREE_CODE (decl) == COMPOUND_EXPR
15440 && TREE_OPERAND (decl, 1)
15441 && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15443 tree lvalue;
15444 /* Before screaming, check that we're not in fact trying to
15445 increment a optimized static final access, in which case
15446 we issue an different error message. */
15447 if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15448 && resolve_expression_name (wfl_op, &lvalue)
15449 && check_final_assignment (lvalue, wfl_op)))
15450 parse_error_context (wfl_operator, "Invalid argument to `%s'",
15451 operator_string (node));
15452 TREE_TYPE (node) = error_mark_node;
15453 error_found = 1;
15456 if (check_final_assignment (op, wfl_op))
15457 error_found = 1;
15459 /* From now on, we know that op if a variable and that it has a
15460 valid wfl. We use wfl_op to locate errors related to the
15461 ++/-- operand. */
15462 else if (!JNUMERIC_TYPE_P (op_type))
15464 parse_error_context
15465 (wfl_op, "Invalid argument type `%s' to `%s'",
15466 lang_printable_name (op_type, 0), operator_string (node));
15467 TREE_TYPE (node) = error_mark_node;
15468 error_found = 1;
15470 else
15472 /* Before the addition, binary numeric promotion is performed on
15473 both operands, if really necessary */
15474 if (JINTEGRAL_TYPE_P (op_type))
15476 value = build_int_2 (1, 0);
15477 TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15479 else
15481 value = build_int_2 (1, 0);
15482 TREE_TYPE (node) =
15483 binary_numeric_promotion (op_type,
15484 TREE_TYPE (value), &op, &value);
15487 /* We remember we might be accessing an outer field */
15488 if (outer_field_flag)
15490 /* We re-generate an access to the field */
15491 value = build (PLUS_EXPR, TREE_TYPE (op),
15492 build_outer_field_access (wfl_op, decl), value);
15494 /* And we patch the original access$() into a write
15495 with plus_op as a rhs */
15496 return outer_field_access_fix (node, op, value);
15499 /* And write back into the node. */
15500 TREE_OPERAND (node, 0) = op;
15501 TREE_OPERAND (node, 1) = value;
15502 /* Convert the overall back into its original type, if
15503 necessary, and return */
15504 if (JINTEGRAL_TYPE_P (op_type))
15505 return fold (node);
15506 else
15507 return fold (convert (op_type, node));
15509 break;
15511 /* 15.14.3 Unary Plus Operator + */
15512 case UNARY_PLUS_EXPR:
15513 /* 15.14.4 Unary Minus Operator - */
15514 case NEGATE_EXPR:
15515 if (!JNUMERIC_TYPE_P (op_type))
15517 ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15518 TREE_TYPE (node) = error_mark_node;
15519 error_found = 1;
15521 /* Unary numeric promotion is performed on operand */
15522 else
15524 op = do_unary_numeric_promotion (op);
15525 prom_type = TREE_TYPE (op);
15526 if (code == UNARY_PLUS_EXPR)
15527 return fold (op);
15529 break;
15531 /* 15.14.5 Bitwise Complement Operator ~ */
15532 case BIT_NOT_EXPR:
15533 if (!JINTEGRAL_TYPE_P (op_type))
15535 ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15536 TREE_TYPE (node) = error_mark_node;
15537 error_found = 1;
15539 else
15541 op = do_unary_numeric_promotion (op);
15542 prom_type = TREE_TYPE (op);
15544 break;
15546 /* 15.14.6 Logical Complement Operator ! */
15547 case TRUTH_NOT_EXPR:
15548 if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15550 ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15551 /* But the type is known. We will report an error if further
15552 attempt of a assignment is made with this rhs */
15553 TREE_TYPE (node) = boolean_type_node;
15554 error_found = 1;
15556 else
15557 prom_type = boolean_type_node;
15558 break;
15560 /* 15.15 Cast Expression */
15561 case CONVERT_EXPR:
15562 value = patch_cast (node, wfl_operator);
15563 if (value == error_mark_node)
15565 /* If this cast is part of an assignment, we tell the code
15566 that deals with it not to complain about a mismatch,
15567 because things have been cast, anyways */
15568 TREE_TYPE (node) = error_mark_node;
15569 error_found = 1;
15571 else
15573 value = fold (value);
15574 TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15575 return value;
15577 break;
15580 if (error_found)
15581 return error_mark_node;
15583 /* There are cases where node has been replaced by something else
15584 and we don't end up returning here: UNARY_PLUS_EXPR,
15585 CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15586 TREE_OPERAND (node, 0) = fold (op);
15587 TREE_TYPE (node) = prom_type;
15588 TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15589 return fold (node);
15592 /* Generic type resolution that sometimes takes place during node
15593 patching. Returned the resolved type or generate an error
15594 message. Return the resolved type or NULL_TREE. */
15596 static tree
15597 resolve_type_during_patch (type)
15598 tree type;
15600 if (unresolved_type_p (type, NULL))
15602 tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15603 if (!type_decl)
15605 parse_error_context (type,
15606 "Class `%s' not found in type declaration",
15607 IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15608 return NULL_TREE;
15610 else
15612 CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15613 return TREE_TYPE (type_decl);
15616 return type;
15618 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15619 found. Otherwise NODE or something meant to replace it is returned. */
15621 static tree
15622 patch_cast (node, wfl_operator)
15623 tree node;
15624 tree wfl_operator;
15626 tree op = TREE_OPERAND (node, 0);
15627 tree op_type = TREE_TYPE (op);
15628 tree cast_type = TREE_TYPE (node);
15629 char *t1;
15631 /* First resolve OP_TYPE if unresolved */
15632 if (!(cast_type = resolve_type_during_patch (cast_type)))
15633 return error_mark_node;
15635 /* Check on cast that are proven correct at compile time */
15636 if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15638 /* Same type */
15639 if (cast_type == op_type)
15640 return node;
15642 /* float and double type are converted to the original type main
15643 variant and then to the target type. */
15644 if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15645 op = convert (integer_type_node, op);
15647 /* Try widening/narowwing convertion. Potentially, things need
15648 to be worked out in gcc so we implement the extreme cases
15649 correctly. fold_convert() needs to be fixed. */
15650 return convert (cast_type, op);
15653 /* It's also valid to cast a boolean into a boolean */
15654 if (op_type == boolean_type_node && cast_type == boolean_type_node)
15655 return node;
15657 /* null can be casted to references */
15658 if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15659 return build_null_of_type (cast_type);
15661 /* The remaining legal casts involve conversion between reference
15662 types. Check for their compile time correctness. */
15663 if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type)
15664 && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15666 TREE_TYPE (node) = promote_type (cast_type);
15667 /* Now, the case can be determined correct at compile time if
15668 OP_TYPE can be converted into CAST_TYPE by assignment
15669 conversion (5.2) */
15671 if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15673 TREE_SET_CODE (node, NOP_EXPR);
15674 return node;
15677 if (flag_emit_class_files)
15679 TREE_SET_CODE (node, CONVERT_EXPR);
15680 return node;
15683 /* The cast requires a run-time check */
15684 return build (CALL_EXPR, promote_type (cast_type),
15685 build_address_of (soft_checkcast_node),
15686 tree_cons (NULL_TREE, build_class_ref (cast_type),
15687 build_tree_list (NULL_TREE, op)),
15688 NULL_TREE);
15691 /* Any other casts are proven incorrect at compile time */
15692 t1 = xstrdup (lang_printable_name (op_type, 0));
15693 parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15694 t1, lang_printable_name (cast_type, 0));
15695 free (t1);
15696 return error_mark_node;
15699 /* Build a null constant and give it the type TYPE. */
15701 static tree
15702 build_null_of_type (type)
15703 tree type;
15705 tree node = build_int_2 (0, 0);
15706 TREE_TYPE (node) = promote_type (type);
15707 return node;
15710 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15711 a list of indices. */
15712 static tree
15713 build_array_ref (location, array, index)
15714 int location;
15715 tree array, index;
15717 tree node = build (ARRAY_REF, NULL_TREE, array, index);
15718 EXPR_WFL_LINECOL (node) = location;
15719 return node;
15722 /* 15.12 Array Access Expression */
15724 static tree
15725 patch_array_ref (node)
15726 tree node;
15728 tree array = TREE_OPERAND (node, 0);
15729 tree array_type = TREE_TYPE (array);
15730 tree index = TREE_OPERAND (node, 1);
15731 tree index_type = TREE_TYPE (index);
15732 int error_found = 0;
15734 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15736 if (TREE_CODE (array_type) == POINTER_TYPE)
15737 array_type = TREE_TYPE (array_type);
15739 /* The array reference must be an array */
15740 if (!TYPE_ARRAY_P (array_type))
15742 parse_error_context
15743 (wfl_operator,
15744 "`[]' can only be applied to arrays. It can't be applied to `%s'",
15745 lang_printable_name (array_type, 0));
15746 TREE_TYPE (node) = error_mark_node;
15747 error_found = 1;
15750 /* The array index undergoes unary numeric promotion. The promoted
15751 type must be int */
15752 index = do_unary_numeric_promotion (index);
15753 if (TREE_TYPE (index) != int_type_node)
15755 if (valid_cast_to_p (index_type, int_type_node))
15756 parse_error_context (wfl_operator,
15757 "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15758 lang_printable_name (index_type, 0));
15759 else
15760 parse_error_context (wfl_operator,
15761 "Incompatible type for `[]'. Can't convert `%s' to `int'",
15762 lang_printable_name (index_type, 0));
15763 TREE_TYPE (node) = error_mark_node;
15764 error_found = 1;
15767 if (error_found)
15768 return error_mark_node;
15770 array_type = TYPE_ARRAY_ELEMENT (array_type);
15772 if (flag_emit_class_files || flag_emit_xref)
15774 TREE_OPERAND (node, 0) = array;
15775 TREE_OPERAND (node, 1) = index;
15777 else
15779 /* The save_expr is for correct evaluation order. It would be cleaner
15780 to use force_evaluation_order (see comment there), but that is
15781 difficult when we also have to deal with bounds checking. */
15782 if (TREE_SIDE_EFFECTS (index))
15783 array = save_expr (array);
15784 node = build_java_arrayaccess (array, array_type, index);
15785 if (TREE_SIDE_EFFECTS (index))
15786 node = build (COMPOUND_EXPR, array_type, array, node);
15788 TREE_TYPE (node) = array_type;
15789 return node;
15792 /* 15.9 Array Creation Expressions */
15794 static tree
15795 build_newarray_node (type, dims, extra_dims)
15796 tree type;
15797 tree dims;
15798 int extra_dims;
15800 tree node =
15801 build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims),
15802 build_int_2 (extra_dims, 0));
15803 return node;
15806 static tree
15807 patch_newarray (node)
15808 tree node;
15810 tree type = TREE_OPERAND (node, 0);
15811 tree dims = TREE_OPERAND (node, 1);
15812 tree cdim, array_type;
15813 int error_found = 0;
15814 int ndims = 0;
15815 int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
15817 /* Dimension types are verified. It's better for the types to be
15818 verified in order. */
15819 for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
15821 int dim_error = 0;
15822 tree dim = TREE_VALUE (cdim);
15824 /* Dim might have been saved during its evaluation */
15825 dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
15827 /* The type of each specified dimension must be an integral type. */
15828 if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
15829 dim_error = 1;
15831 /* Each expression undergoes an unary numeric promotion (5.6.1) and the
15832 promoted type must be int. */
15833 else
15835 dim = do_unary_numeric_promotion (dim);
15836 if (TREE_TYPE (dim) != int_type_node)
15837 dim_error = 1;
15840 /* Report errors on types here */
15841 if (dim_error)
15843 parse_error_context
15844 (TREE_PURPOSE (cdim),
15845 "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'",
15846 (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
15847 "Explicit cast needed to" : "Can't"),
15848 lang_printable_name (TREE_TYPE (dim), 0));
15849 error_found = 1;
15852 TREE_PURPOSE (cdim) = NULL_TREE;
15855 /* Resolve array base type if unresolved */
15856 if (!(type = resolve_type_during_patch (type)))
15857 error_found = 1;
15859 if (error_found)
15861 /* We don't want further evaluation of this bogus array creation
15862 operation */
15863 TREE_TYPE (node) = error_mark_node;
15864 return error_mark_node;
15867 /* Set array_type to the actual (promoted) array type of the result. */
15868 if (TREE_CODE (type) == RECORD_TYPE)
15869 type = build_pointer_type (type);
15870 while (--xdims >= 0)
15872 type = promote_type (build_java_array_type (type, -1));
15874 dims = nreverse (dims);
15875 array_type = type;
15876 for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
15878 type = array_type;
15879 array_type
15880 = build_java_array_type (type,
15881 TREE_CODE (cdim) == INTEGER_CST
15882 ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
15883 : -1);
15884 array_type = promote_type (array_type);
15886 dims = nreverse (dims);
15888 /* The node is transformed into a function call. Things are done
15889 differently according to the number of dimensions. If the number
15890 of dimension is equal to 1, then the nature of the base type
15891 (primitive or not) matters. */
15892 if (ndims == 1)
15893 return build_new_array (type, TREE_VALUE (dims));
15895 /* Can't reuse what's already written in expr.c because it uses the
15896 JVM stack representation. Provide a build_multianewarray. FIXME */
15897 return build (CALL_EXPR, array_type,
15898 build_address_of (soft_multianewarray_node),
15899 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
15900 tree_cons (NULL_TREE,
15901 build_int_2 (ndims, 0), dims )),
15902 NULL_TREE);
15905 /* 10.6 Array initializer. */
15907 /* Build a wfl for array element that don't have one, so we can
15908 pin-point errors. */
15910 static tree
15911 maybe_build_array_element_wfl (node)
15912 tree node;
15914 if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
15915 return build_expr_wfl (NULL_TREE, ctxp->filename,
15916 ctxp->elc.line, ctxp->elc.prev_col);
15917 else
15918 return NULL_TREE;
15921 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
15922 identification of initialized arrays easier to detect during walk
15923 and expansion. */
15925 static tree
15926 build_new_array_init (location, values)
15927 int location;
15928 tree values;
15930 tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
15931 tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
15932 EXPR_WFL_LINECOL (to_return) = location;
15933 return to_return;
15936 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
15937 occurred. Otherwise return NODE after having set its type
15938 appropriately. */
15940 static tree
15941 patch_new_array_init (type, node)
15942 tree type, node;
15944 int error_seen = 0;
15945 tree current, element_type;
15946 HOST_WIDE_INT length;
15947 int all_constant = 1;
15948 tree init = TREE_OPERAND (node, 0);
15950 if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
15952 parse_error_context (node,
15953 "Invalid array initializer for non-array type `%s'",
15954 lang_printable_name (type, 1));
15955 return error_mark_node;
15957 type = TREE_TYPE (type);
15958 element_type = TYPE_ARRAY_ELEMENT (type);
15960 CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
15962 for (length = 0, current = CONSTRUCTOR_ELTS (init);
15963 current; length++, current = TREE_CHAIN (current))
15965 tree elt = TREE_VALUE (current);
15966 if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
15968 error_seen |= array_constructor_check_entry (element_type, current);
15969 elt = TREE_VALUE (current);
15970 /* When compiling to native code, STRING_CST is converted to
15971 INDIRECT_REF, but still with a TREE_CONSTANT flag. */
15972 if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
15973 all_constant = 0;
15975 else
15977 TREE_VALUE (current) = patch_new_array_init (element_type, elt);
15978 TREE_PURPOSE (current) = NULL_TREE;
15979 all_constant = 0;
15981 if (elt && TREE_VALUE (elt) == error_mark_node)
15982 error_seen = 1;
15985 if (error_seen)
15986 return error_mark_node;
15988 /* Create a new type. We can't reuse the one we have here by
15989 patching its dimension because it originally is of dimension -1
15990 hence reused by gcc. This would prevent triangular arrays. */
15991 type = build_java_array_type (element_type, length);
15992 TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
15993 TREE_TYPE (node) = promote_type (type);
15994 TREE_CONSTANT (init) = all_constant;
15995 TREE_CONSTANT (node) = all_constant;
15996 return node;
15999 /* Verify that one entry of the initializer element list can be
16000 assigned to the array base type. Report 1 if an error occurred, 0
16001 otherwise. */
16003 static int
16004 array_constructor_check_entry (type, entry)
16005 tree type, entry;
16007 char *array_type_string = NULL; /* For error reports */
16008 tree value, type_value, new_value, wfl_value, patched;
16009 int error_seen = 0;
16011 new_value = NULL_TREE;
16012 wfl_value = TREE_VALUE (entry);
16014 push_obstacks (&permanent_obstack, &permanent_obstack);
16015 value = java_complete_tree (TREE_VALUE (entry));
16016 /* patch_string return error_mark_node if arg is error_mark_node */
16017 if ((patched = patch_string (value)))
16018 value = patched;
16019 if (value == error_mark_node)
16020 return 1;
16022 type_value = TREE_TYPE (value);
16024 /* At anytime, try_builtin_assignconv can report a warning on
16025 constant overflow during narrowing. */
16026 SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16027 new_value = try_builtin_assignconv (wfl_operator, type, value);
16028 if (!new_value && (new_value = try_reference_assignconv (type, value)))
16029 type_value = promote_type (type);
16031 pop_obstacks ();
16032 /* Check and report errors */
16033 if (!new_value)
16035 const char *msg = (!valid_cast_to_p (type_value, type) ?
16036 "Can't" : "Explicit cast needed to");
16037 if (!array_type_string)
16038 array_type_string = xstrdup (lang_printable_name (type, 1));
16039 parse_error_context
16040 (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16041 msg, lang_printable_name (type_value, 1), array_type_string);
16042 error_seen = 1;
16045 if (new_value)
16047 new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
16048 TREE_VALUE (entry) = new_value;
16051 if (array_type_string)
16052 free (array_type_string);
16054 TREE_PURPOSE (entry) = NULL_TREE;
16055 return error_seen;
16058 static tree
16059 build_this (location)
16060 int location;
16062 tree node = build_wfl_node (this_identifier_node);
16063 TREE_SET_CODE (node, THIS_EXPR);
16064 EXPR_WFL_LINECOL (node) = location;
16065 return node;
16068 /* 14.15 The return statement. It builds a modify expression that
16069 assigns the returned value to the RESULT_DECL that hold the value
16070 to be returned. */
16072 static tree
16073 build_return (location, op)
16074 int location;
16075 tree op;
16077 tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16078 EXPR_WFL_LINECOL (node) = location;
16079 node = build_debugable_stmt (location, node);
16080 return node;
16083 static tree
16084 patch_return (node)
16085 tree node;
16087 tree return_exp = TREE_OPERAND (node, 0);
16088 tree meth = current_function_decl;
16089 tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16090 int error_found = 0;
16092 TREE_TYPE (node) = error_mark_node;
16093 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16095 /* It's invalid to have a return value within a function that is
16096 declared with the keyword void or that is a constructor */
16097 if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16098 error_found = 1;
16100 /* It's invalid to use a return statement in a static block */
16101 if (DECL_CLINIT_P (current_function_decl))
16102 error_found = 1;
16104 /* It's invalid to have a no return value within a function that
16105 isn't declared with the keyword `void' */
16106 if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16107 error_found = 2;
16109 if (in_instance_initializer)
16110 error_found = 1;
16112 if (error_found)
16114 if (in_instance_initializer)
16115 parse_error_context (wfl_operator,
16116 "`return' inside instance initializer");
16118 else if (DECL_CLINIT_P (current_function_decl))
16119 parse_error_context (wfl_operator,
16120 "`return' inside static initializer");
16122 else if (!DECL_CONSTRUCTOR_P (meth))
16124 char *t = xstrdup (lang_printable_name (mtype, 0));
16125 parse_error_context (wfl_operator,
16126 "`return' with%s value from `%s %s'",
16127 (error_found == 1 ? "" : "out"),
16128 t, lang_printable_name (meth, 0));
16129 free (t);
16131 else
16132 parse_error_context (wfl_operator,
16133 "`return' with value from constructor `%s'",
16134 lang_printable_name (meth, 0));
16135 return error_mark_node;
16138 /* If we have a return_exp, build a modify expression and expand
16139 it. Note: at that point, the assignment is declared valid, but we
16140 may want to carry some more hacks */
16141 if (return_exp)
16143 tree exp = java_complete_tree (return_exp);
16144 tree modify, patched;
16146 /* If the function returned value and EXP are booleans, EXP has
16147 to be converted into the type of DECL_RESULT, which is integer
16148 (see complete_start_java_method) */
16149 if (TREE_TYPE (exp) == boolean_type_node &&
16150 TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16151 exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16153 /* `null' can be assigned to a function returning a reference */
16154 if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16155 exp == null_pointer_node)
16156 exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16158 if ((patched = patch_string (exp)))
16159 exp = patched;
16161 modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16162 EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16163 modify = java_complete_tree (modify);
16165 if (modify != error_mark_node)
16167 TREE_SIDE_EFFECTS (modify) = 1;
16168 TREE_OPERAND (node, 0) = modify;
16170 else
16171 return error_mark_node;
16173 TREE_TYPE (node) = void_type_node;
16174 TREE_SIDE_EFFECTS (node) = 1;
16175 return node;
16178 /* 14.8 The if Statement */
16180 static tree
16181 build_if_else_statement (location, expression, if_body, else_body)
16182 int location;
16183 tree expression, if_body, else_body;
16185 tree node;
16186 if (!else_body)
16187 else_body = empty_stmt_node;
16188 node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16189 EXPR_WFL_LINECOL (node) = location;
16190 node = build_debugable_stmt (location, node);
16191 return node;
16194 static tree
16195 patch_if_else_statement (node)
16196 tree node;
16198 tree expression = TREE_OPERAND (node, 0);
16200 TREE_TYPE (node) = error_mark_node;
16201 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16203 /* The type of expression must be boolean */
16204 if (TREE_TYPE (expression) != boolean_type_node
16205 && TREE_TYPE (expression) != promoted_boolean_type_node)
16207 parse_error_context
16208 (wfl_operator,
16209 "Incompatible type for `if'. Can't convert `%s' to `boolean'",
16210 lang_printable_name (TREE_TYPE (expression), 0));
16211 return error_mark_node;
16214 TREE_TYPE (node) = void_type_node;
16215 TREE_SIDE_EFFECTS (node) = 1;
16216 CAN_COMPLETE_NORMALLY (node)
16217 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16218 | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16219 return node;
16222 /* 14.6 Labeled Statements */
16224 /* Action taken when a lableled statement is parsed. a new
16225 LABELED_BLOCK_EXPR is created. No statement is attached to the
16226 label, yet. LABEL can be NULL_TREE for artificially-generated blocks. */
16228 static tree
16229 build_labeled_block (location, label)
16230 int location;
16231 tree label;
16233 tree label_name ;
16234 tree label_decl, node;
16235 if (label == NULL_TREE || label == continue_identifier_node)
16236 label_name = label;
16237 else
16239 label_name = merge_qualified_name (label_id, label);
16240 /* Issue an error if we try to reuse a label that was previously
16241 declared */
16242 if (IDENTIFIER_LOCAL_VALUE (label_name))
16244 EXPR_WFL_LINECOL (wfl_operator) = location;
16245 parse_error_context (wfl_operator,
16246 "Declaration of `%s' shadows a previous label declaration",
16247 IDENTIFIER_POINTER (label));
16248 EXPR_WFL_LINECOL (wfl_operator) =
16249 EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16250 parse_error_context (wfl_operator,
16251 "This is the location of the previous declaration of label `%s'",
16252 IDENTIFIER_POINTER (label));
16253 java_error_count--;
16257 label_decl = create_label_decl (label_name);
16258 node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16259 EXPR_WFL_LINECOL (node) = location;
16260 TREE_SIDE_EFFECTS (node) = 1;
16261 return node;
16264 /* A labeled statement LBE is attached a statement. */
16266 static tree
16267 finish_labeled_statement (lbe, statement)
16268 tree lbe; /* Labeled block expr */
16269 tree statement;
16271 /* In anyways, tie the loop to its statement */
16272 LABELED_BLOCK_BODY (lbe) = statement;
16273 pop_labeled_block ();
16274 POP_LABELED_BLOCK ();
16275 return lbe;
16278 /* 14.10, 14.11, 14.12 Loop Statements */
16280 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16281 list. */
16283 static tree
16284 build_new_loop (loop_body)
16285 tree loop_body;
16287 tree loop = build (LOOP_EXPR, NULL_TREE, loop_body);
16288 TREE_SIDE_EFFECTS (loop) = 1;
16289 PUSH_LOOP (loop);
16290 return loop;
16293 /* Create a loop body according to the following structure:
16294 COMPOUND_EXPR
16295 COMPOUND_EXPR (loop main body)
16296 EXIT_EXPR (this order is for while/for loops.
16297 LABELED_BLOCK_EXPR the order is reversed for do loops)
16298 LABEL_DECL (a continue occuring here branches at the
16299 BODY end of this labeled block)
16300 INCREMENT (if any)
16302 REVERSED, if non zero, tells that the loop condition expr comes
16303 after the body, like in the do-while loop.
16305 To obtain a loop, the loop body structure described above is
16306 encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16308 LABELED_BLOCK_EXPR
16309 LABEL_DECL (use this label to exit the loop)
16310 LOOP_EXPR
16311 <structure described above> */
16313 static tree
16314 build_loop_body (location, condition, reversed)
16315 int location;
16316 tree condition;
16317 int reversed;
16319 tree first, second, body;
16321 condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16322 EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16323 condition = build_debugable_stmt (location, condition);
16324 TREE_SIDE_EFFECTS (condition) = 1;
16326 body = build_labeled_block (0, continue_identifier_node);
16327 first = (reversed ? body : condition);
16328 second = (reversed ? condition : body);
16329 return
16330 build (COMPOUND_EXPR, NULL_TREE,
16331 build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16334 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16335 their order) on the current loop. Unlink the current loop from the
16336 loop list. */
16338 static tree
16339 finish_loop_body (location, condition, body, reversed)
16340 int location;
16341 tree condition, body;
16342 int reversed;
16344 tree to_return = ctxp->current_loop;
16345 tree loop_body = LOOP_EXPR_BODY (to_return);
16346 if (condition)
16348 tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16349 /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16350 The real EXIT_EXPR is one operand further. */
16351 EXPR_WFL_LINECOL (cnode) = location;
16352 /* This one is for accurate error reports */
16353 EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16354 TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16356 LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16357 POP_LOOP ();
16358 return to_return;
16361 /* Tailored version of finish_loop_body for FOR loops, when FOR
16362 loops feature the condition part */
16364 static tree
16365 finish_for_loop (location, condition, update, body)
16366 int location;
16367 tree condition, update, body;
16369 /* Put the condition and the loop body in place */
16370 tree loop = finish_loop_body (location, condition, body, 0);
16371 /* LOOP is the current loop which has been now popped of the loop
16372 stack. Install the update block */
16373 LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16374 return loop;
16377 /* Try to find the loop a block might be related to. This comprises
16378 the case where the LOOP_EXPR is found as the second operand of a
16379 COMPOUND_EXPR, because the loop happens to have an initialization
16380 part, then expressed as the first operand of the COMPOUND_EXPR. If
16381 the search finds something, 1 is returned. Otherwise, 0 is
16382 returned. The search is assumed to start from a
16383 LABELED_BLOCK_EXPR's block. */
16385 static tree
16386 search_loop (statement)
16387 tree statement;
16389 if (TREE_CODE (statement) == LOOP_EXPR)
16390 return statement;
16392 if (TREE_CODE (statement) == BLOCK)
16393 statement = BLOCK_SUBBLOCKS (statement);
16394 else
16395 return NULL_TREE;
16397 if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16398 while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16399 statement = TREE_OPERAND (statement, 1);
16401 return (TREE_CODE (statement) == LOOP_EXPR
16402 && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16405 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16406 returned otherwise. */
16408 static int
16409 labeled_block_contains_loop_p (block, loop)
16410 tree block, loop;
16412 if (!block)
16413 return 0;
16415 if (LABELED_BLOCK_BODY (block) == loop)
16416 return 1;
16418 if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16419 return 1;
16421 return 0;
16424 /* If the loop isn't surrounded by a labeled statement, create one and
16425 insert LOOP as its body. */
16427 static tree
16428 patch_loop_statement (loop)
16429 tree loop;
16431 tree loop_label;
16433 TREE_TYPE (loop) = void_type_node;
16434 if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16435 return loop;
16437 loop_label = build_labeled_block (0, NULL_TREE);
16438 /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16439 that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16440 LABELED_BLOCK_BODY (loop_label) = loop;
16441 PUSH_LABELED_BLOCK (loop_label);
16442 return loop_label;
16445 /* 14.13, 14.14: break and continue Statements */
16447 /* Build a break or a continue statement. a null NAME indicates an
16448 unlabeled break/continue statement. */
16450 static tree
16451 build_bc_statement (location, is_break, name)
16452 int location, is_break;
16453 tree name;
16455 tree break_continue, label_block_expr = NULL_TREE;
16457 if (name)
16459 if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE
16460 (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16461 /* Null means that we don't have a target for this named
16462 break/continue. In this case, we make the target to be the
16463 label name, so that the error can be reported accuratly in
16464 patch_bc_statement. */
16465 label_block_expr = EXPR_WFL_NODE (name);
16467 /* Unlabeled break/continue will be handled during the
16468 break/continue patch operation */
16469 break_continue
16470 = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16472 IS_BREAK_STMT_P (break_continue) = is_break;
16473 TREE_SIDE_EFFECTS (break_continue) = 1;
16474 EXPR_WFL_LINECOL (break_continue) = location;
16475 break_continue = build_debugable_stmt (location, break_continue);
16476 return break_continue;
16479 /* Verification of a break/continue statement. */
16481 static tree
16482 patch_bc_statement (node)
16483 tree node;
16485 tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16486 tree labeled_block = ctxp->current_labeled_block;
16487 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16489 /* Having an identifier here means that the target is unknown. */
16490 if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16492 parse_error_context (wfl_operator, "No label definition found for `%s'",
16493 IDENTIFIER_POINTER (bc_label));
16494 return error_mark_node;
16496 if (! IS_BREAK_STMT_P (node))
16498 /* It's a continue statement. */
16499 for (;; labeled_block = TREE_CHAIN (labeled_block))
16501 if (labeled_block == NULL_TREE)
16503 if (bc_label == NULL_TREE)
16504 parse_error_context (wfl_operator,
16505 "`continue' must be in loop");
16506 else
16507 parse_error_context
16508 (wfl_operator, "continue label `%s' does not name a loop",
16509 IDENTIFIER_POINTER (bc_label));
16510 return error_mark_node;
16512 if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16513 == continue_identifier_node)
16514 && (bc_label == NULL_TREE
16515 || TREE_CHAIN (labeled_block) == bc_label))
16517 bc_label = labeled_block;
16518 break;
16522 else if (!bc_label)
16524 for (;; labeled_block = TREE_CHAIN (labeled_block))
16526 if (labeled_block == NULL_TREE)
16528 parse_error_context (wfl_operator,
16529 "`break' must be in loop or switch");
16530 return error_mark_node;
16532 target_stmt = LABELED_BLOCK_BODY (labeled_block);
16533 if (TREE_CODE (target_stmt) == SWITCH_EXPR
16534 || search_loop (target_stmt))
16536 bc_label = labeled_block;
16537 break;
16542 EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16543 CAN_COMPLETE_NORMALLY (bc_label) = 1;
16545 /* Our break/continue don't return values. */
16546 TREE_TYPE (node) = void_type_node;
16547 /* Encapsulate the break within a compound statement so that it's
16548 expanded all the times by expand_expr (and not clobbered
16549 sometimes, like after a if statement) */
16550 node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16551 TREE_SIDE_EFFECTS (node) = 1;
16552 return node;
16555 /* Process the exit expression belonging to a loop. Its type must be
16556 boolean. */
16558 static tree
16559 patch_exit_expr (node)
16560 tree node;
16562 tree expression = TREE_OPERAND (node, 0);
16563 TREE_TYPE (node) = error_mark_node;
16564 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16566 /* The type of expression must be boolean */
16567 if (TREE_TYPE (expression) != boolean_type_node)
16569 parse_error_context
16570 (wfl_operator,
16571 "Incompatible type for loop conditional. Can't convert `%s' to `boolean'",
16572 lang_printable_name (TREE_TYPE (expression), 0));
16573 return error_mark_node;
16575 /* Now we know things are allright, invert the condition, fold and
16576 return */
16577 TREE_OPERAND (node, 0) =
16578 fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16580 if (! integer_zerop (TREE_OPERAND (node, 0))
16581 && ctxp->current_loop != NULL_TREE
16582 && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16583 CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16584 if (! integer_onep (TREE_OPERAND (node, 0)))
16585 CAN_COMPLETE_NORMALLY (node) = 1;
16588 TREE_TYPE (node) = void_type_node;
16589 return node;
16592 /* 14.9 Switch statement */
16594 static tree
16595 patch_switch_statement (node)
16596 tree node;
16598 tree se = TREE_OPERAND (node, 0), se_type;
16600 /* Complete the switch expression */
16601 se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16602 se_type = TREE_TYPE (se);
16603 /* The type of the switch expression must be char, byte, short or
16604 int */
16605 if (!JINTEGRAL_TYPE_P (se_type))
16607 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16608 parse_error_context (wfl_operator,
16609 "Incompatible type for `switch'. Can't convert `%s' to `int'",
16610 lang_printable_name (se_type, 0));
16611 /* This is what java_complete_tree will check */
16612 TREE_OPERAND (node, 0) = error_mark_node;
16613 return error_mark_node;
16616 TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16618 /* Ready to return */
16619 if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16621 TREE_TYPE (node) = error_mark_node;
16622 return error_mark_node;
16624 TREE_TYPE (node) = void_type_node;
16625 TREE_SIDE_EFFECTS (node) = 1;
16626 CAN_COMPLETE_NORMALLY (node)
16627 = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16628 || ! SWITCH_HAS_DEFAULT (node);
16629 return node;
16632 /* 14.18 The try/catch statements */
16634 static tree
16635 build_try_statement (location, try_block, catches)
16636 int location;
16637 tree try_block, catches;
16639 tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16640 EXPR_WFL_LINECOL (node) = location;
16641 return node;
16644 static tree
16645 build_try_finally_statement (location, try_block, finally)
16646 int location;
16647 tree try_block, finally;
16649 tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16650 EXPR_WFL_LINECOL (node) = location;
16651 return node;
16654 static tree
16655 patch_try_statement (node)
16656 tree node;
16658 int error_found = 0;
16659 tree try = TREE_OPERAND (node, 0);
16660 /* Exception handlers are considered in left to right order */
16661 tree catch = nreverse (TREE_OPERAND (node, 1));
16662 tree current, caught_type_list = NULL_TREE;
16664 /* Check catch clauses, if any. Every time we find an error, we try
16665 to process the next catch clause. We process the catch clause before
16666 the try block so that when processing the try block we can check thrown
16667 exceptions againts the caught type list. */
16668 for (current = catch; current; current = TREE_CHAIN (current))
16670 tree carg_decl, carg_type;
16671 tree sub_current, catch_block, catch_clause;
16672 int unreachable;
16674 /* At this point, the structure of the catch clause is
16675 CATCH_EXPR (catch node)
16676 BLOCK (with the decl of the parameter)
16677 COMPOUND_EXPR
16678 MODIFY_EXPR (assignment of the catch parameter)
16679 BLOCK (catch clause block)
16681 catch_clause = TREE_OPERAND (current, 0);
16682 carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16683 carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16685 /* Catch clauses can't have more than one parameter declared,
16686 but it's already enforced by the grammar. Make sure that the
16687 only parameter of the clause statement in of class Throwable
16688 or a subclass of Throwable, but that was done earlier. The
16689 catch clause parameter type has also been resolved. */
16691 /* Just make sure that the catch clause parameter type inherits
16692 from java.lang.Throwable */
16693 if (!inherits_from_p (carg_type, throwable_type_node))
16695 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16696 parse_error_context (wfl_operator,
16697 "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16698 lang_printable_name (carg_type, 0));
16699 error_found = 1;
16700 continue;
16703 /* Partial check for unreachable catch statement: The catch
16704 clause is reachable iff is no earlier catch block A in
16705 the try statement such that the type of the catch
16706 clause's parameter is the same as or a subclass of the
16707 type of A's parameter */
16708 unreachable = 0;
16709 for (sub_current = catch;
16710 sub_current != current; sub_current = TREE_CHAIN (sub_current))
16712 tree sub_catch_clause, decl;
16713 sub_catch_clause = TREE_OPERAND (sub_current, 0);
16714 decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16716 if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16718 EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16719 parse_error_context
16720 (wfl_operator,
16721 "`catch' not reached because of the catch clause at line %d",
16722 EXPR_WFL_LINENO (sub_current));
16723 unreachable = error_found = 1;
16724 break;
16727 /* Complete the catch clause block */
16728 catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16729 if (catch_block == error_mark_node)
16731 error_found = 1;
16732 continue;
16734 if (CAN_COMPLETE_NORMALLY (catch_block))
16735 CAN_COMPLETE_NORMALLY (node) = 1;
16736 TREE_OPERAND (current, 0) = catch_block;
16738 if (unreachable)
16739 continue;
16741 /* Things to do here: the exception must be thrown */
16743 /* Link this type to the caught type list */
16744 caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16747 PUSH_EXCEPTIONS (caught_type_list);
16748 if ((try = java_complete_tree (try)) == error_mark_node)
16749 error_found = 1;
16750 if (CAN_COMPLETE_NORMALLY (try))
16751 CAN_COMPLETE_NORMALLY (node) = 1;
16752 POP_EXCEPTIONS ();
16754 /* Verification ends here */
16755 if (error_found)
16756 return error_mark_node;
16758 TREE_OPERAND (node, 0) = try;
16759 TREE_OPERAND (node, 1) = catch;
16760 TREE_TYPE (node) = void_type_node;
16761 return node;
16764 /* 14.17 The synchronized Statement */
16766 static tree
16767 patch_synchronized_statement (node, wfl_op1)
16768 tree node, wfl_op1;
16770 tree expr = java_complete_tree (TREE_OPERAND (node, 0));
16771 tree block = TREE_OPERAND (node, 1);
16773 tree enter, exit, expr_decl, assignment;
16775 if (expr == error_mark_node)
16777 block = java_complete_tree (block);
16778 return expr;
16781 /* The TYPE of expr must be a reference type */
16782 if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
16784 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16785 parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
16786 lang_printable_name (TREE_TYPE (expr), 0));
16787 return error_mark_node;
16790 if (flag_emit_xref)
16792 TREE_OPERAND (node, 0) = expr;
16793 TREE_OPERAND (node, 1) = java_complete_tree (block);
16794 CAN_COMPLETE_NORMALLY (node) = 1;
16795 return node;
16798 /* Generate a try-finally for the synchronized statement, except
16799 that the handler that catches all throw exception calls
16800 _Jv_MonitorExit and then rethrow the exception.
16801 The synchronized statement is then implemented as:
16802 TRY
16804 _Jv_MonitorEnter (expression)
16805 synchronized_block
16806 _Jv_MonitorExit (expression)
16808 CATCH_ALL
16810 e = _Jv_exception_info ();
16811 _Jv_MonitorExit (expression)
16812 Throw (e);
16813 } */
16815 expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
16816 BUILD_MONITOR_ENTER (enter, expr_decl);
16817 BUILD_MONITOR_EXIT (exit, expr_decl);
16818 CAN_COMPLETE_NORMALLY (enter) = 1;
16819 CAN_COMPLETE_NORMALLY (exit) = 1;
16820 assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
16821 TREE_SIDE_EFFECTS (assignment) = 1;
16822 node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
16823 build (COMPOUND_EXPR, NULL_TREE,
16824 build (WITH_CLEANUP_EXPR, NULL_TREE,
16825 build (COMPOUND_EXPR, NULL_TREE,
16826 assignment, enter),
16827 NULL_TREE, exit),
16828 block));
16829 node = build_expr_block (node, expr_decl);
16831 return java_complete_tree (node);
16834 /* 14.16 The throw Statement */
16836 static tree
16837 patch_throw_statement (node, wfl_op1)
16838 tree node, wfl_op1;
16840 tree expr = TREE_OPERAND (node, 0);
16841 tree type = TREE_TYPE (expr);
16842 int unchecked_ok = 0, tryblock_throws_ok = 0;
16844 /* Thrown expression must be assignable to java.lang.Throwable */
16845 if (!try_reference_assignconv (throwable_type_node, expr))
16847 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16848 parse_error_context (wfl_operator,
16849 "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
16850 lang_printable_name (type, 0));
16851 /* If the thrown expression was a reference, we further the
16852 compile-time check. */
16853 if (!JREFERENCE_TYPE_P (type))
16854 return error_mark_node;
16857 /* At least one of the following must be true */
16859 /* The type of the throw expression is a not checked exception,
16860 i.e. is a unchecked expression. */
16861 unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
16863 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16864 /* An instance can't throw a checked excetion unless that exception
16865 is explicitely declared in the `throws' clause of each
16866 constructor. This doesn't apply to anonymous classes, since they
16867 don't have declared constructors. */
16868 if (!unchecked_ok
16869 && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
16871 tree current;
16872 for (current = TYPE_METHODS (current_class); current;
16873 current = TREE_CHAIN (current))
16874 if (DECL_CONSTRUCTOR_P (current)
16875 && !check_thrown_exceptions_do (TREE_TYPE (expr)))
16877 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)",
16878 lang_printable_name (TREE_TYPE (expr), 0));
16879 return error_mark_node;
16883 /* Throw is contained in a try statement and at least one catch
16884 clause can receive the thrown expression or the current method is
16885 declared to throw such an exception. Or, the throw statement is
16886 contained in a method or constructor declaration and the type of
16887 the Expression is assignable to at least one type listed in the
16888 throws clause the declaration. */
16889 if (!unchecked_ok)
16890 tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
16891 if (!(unchecked_ok || tryblock_throws_ok))
16893 /* If there is a surrounding try block that has no matching
16894 clatch clause, report it first. A surrounding try block exits
16895 only if there is something after the list of checked
16896 exception thrown by the current function (if any). */
16897 if (IN_TRY_BLOCK_P ())
16898 parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
16899 lang_printable_name (type, 0));
16900 /* If we have no surrounding try statement and the method doesn't have
16901 any throws, report it now. FIXME */
16903 /* We report that the exception can't be throw from a try block
16904 in all circumstances but when the `throw' is inside a static
16905 block. */
16906 else if (!EXCEPTIONS_P (currently_caught_type_list)
16907 && !tryblock_throws_ok)
16909 if (DECL_CLINIT_P (current_function_decl))
16910 parse_error_context (wfl_operator,
16911 "Checked exception `%s' can't be thrown in initializer",
16912 lang_printable_name (type, 0));
16913 else
16914 parse_error_context (wfl_operator,
16915 "Checked exception `%s' isn't thrown from a `try' block",
16916 lang_printable_name (type, 0));
16918 /* Otherwise, the current method doesn't have the appropriate
16919 throws declaration */
16920 else
16921 parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)",
16922 lang_printable_name (type, 0));
16923 return error_mark_node;
16926 if (! flag_emit_class_files && ! flag_emit_xref)
16927 BUILD_THROW (node, expr);
16929 /* If doing xrefs, keep the location where the `throw' was seen. */
16930 if (flag_emit_xref)
16931 EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
16932 return node;
16935 /* Check that exception said to be thrown by method DECL can be
16936 effectively caught from where DECL is invoked. */
16938 static void
16939 check_thrown_exceptions (location, decl)
16940 int location;
16941 tree decl;
16943 tree throws;
16944 /* For all the unchecked exceptions thrown by DECL */
16945 for (throws = DECL_FUNCTION_THROWS (decl); throws;
16946 throws = TREE_CHAIN (throws))
16947 if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
16949 #if 1
16950 /* Temporary hack to suppresses errors about cloning arrays. FIXME */
16951 if (DECL_NAME (decl) == get_identifier ("clone"))
16952 continue;
16953 #endif
16954 EXPR_WFL_LINECOL (wfl_operator) = location;
16955 if (DECL_FINIT_P (current_function_decl))
16956 parse_error_context
16957 (wfl_operator, "Exception `%s' can't be thrown in initializer",
16958 lang_printable_name (TREE_VALUE (throws), 0));
16959 else
16961 parse_error_context
16962 (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'",
16963 lang_printable_name (TREE_VALUE (throws), 0),
16964 (DECL_INIT_P (current_function_decl) ?
16965 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
16966 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
16971 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
16972 try-catch blocks, OR is listed in the `throws' clause of the
16973 current method. */
16975 static int
16976 check_thrown_exceptions_do (exception)
16977 tree exception;
16979 tree list = currently_caught_type_list;
16980 resolve_and_layout (exception, NULL_TREE);
16981 /* First, all the nested try-catch-finally at that stage. The
16982 last element contains `throws' clause exceptions, if any. */
16983 if (IS_UNCHECKED_EXCEPTION_P (exception))
16984 return 1;
16985 while (list)
16987 tree caught;
16988 for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
16989 if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
16990 return 1;
16991 list = TREE_CHAIN (list);
16993 return 0;
16996 static void
16997 purge_unchecked_exceptions (mdecl)
16998 tree mdecl;
17000 tree throws = DECL_FUNCTION_THROWS (mdecl);
17001 tree new = NULL_TREE;
17003 while (throws)
17005 tree next = TREE_CHAIN (throws);
17006 if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17008 TREE_CHAIN (throws) = new;
17009 new = throws;
17011 throws = next;
17013 /* List is inverted here, but it doesn't matter */
17014 DECL_FUNCTION_THROWS (mdecl) = new;
17017 /* 15.24 Conditional Operator ?: */
17019 static tree
17020 patch_conditional_expr (node, wfl_cond, wfl_op1)
17021 tree node, wfl_cond, wfl_op1;
17023 tree cond = TREE_OPERAND (node, 0);
17024 tree op1 = TREE_OPERAND (node, 1);
17025 tree op2 = TREE_OPERAND (node, 2);
17026 tree resulting_type = NULL_TREE;
17027 tree t1, t2, patched;
17028 int error_found = 0;
17030 /* Operands of ?: might be StringBuffers crafted as a result of a
17031 string concatenation. Obtain a descent operand here. */
17032 if ((patched = patch_string (op1)))
17033 TREE_OPERAND (node, 1) = op1 = patched;
17034 if ((patched = patch_string (op2)))
17035 TREE_OPERAND (node, 2) = op2 = patched;
17037 t1 = TREE_TYPE (op1);
17038 t2 = TREE_TYPE (op2);
17040 /* The first expression must be a boolean */
17041 if (TREE_TYPE (cond) != boolean_type_node)
17043 SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17044 parse_error_context (wfl_operator,
17045 "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17046 lang_printable_name (TREE_TYPE (cond), 0));
17047 error_found = 1;
17050 /* Second and third can be numeric, boolean (i.e. primitive),
17051 references or null. Anything else results in an error */
17052 if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17053 || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node)
17054 && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17055 || (t1 == boolean_type_node && t2 == boolean_type_node)))
17056 error_found = 1;
17058 /* Determine the type of the conditional expression. Same types are
17059 easy to deal with */
17060 else if (t1 == t2)
17061 resulting_type = t1;
17063 /* There are different rules for numeric types */
17064 else if (JNUMERIC_TYPE_P (t1))
17066 /* if byte/short found, the resulting type is short */
17067 if ((t1 == byte_type_node && t2 == short_type_node)
17068 || (t1 == short_type_node && t2 == byte_type_node))
17069 resulting_type = short_type_node;
17071 /* If t1 is a constant int and t2 is of type byte, short or char
17072 and t1's value fits in t2, then the resulting type is t2 */
17073 else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17074 && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17075 resulting_type = t2;
17077 /* If t2 is a constant int and t1 is of type byte, short or char
17078 and t2's value fits in t1, then the resulting type is t1 */
17079 else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17080 && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17081 resulting_type = t1;
17083 /* Otherwise, binary numeric promotion is applied and the
17084 resulting type is the promoted type of operand 1 and 2 */
17085 else
17086 resulting_type = binary_numeric_promotion (t1, t2,
17087 &TREE_OPERAND (node, 1),
17088 &TREE_OPERAND (node, 2));
17091 /* Cases of a reference and a null type */
17092 else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17093 resulting_type = t1;
17095 else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17096 resulting_type = t2;
17098 /* Last case: different reference types. If a type can be converted
17099 into the other one by assignment conversion, the latter
17100 determines the type of the expression */
17101 else if ((resulting_type = try_reference_assignconv (t1, op2)))
17102 resulting_type = promote_type (t1);
17104 else if ((resulting_type = try_reference_assignconv (t2, op1)))
17105 resulting_type = promote_type (t2);
17107 /* If we don't have any resulting type, we're in trouble */
17108 if (!resulting_type)
17110 char *t = xstrdup (lang_printable_name (t1, 0));
17111 SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17112 parse_error_context (wfl_operator,
17113 "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17114 t, lang_printable_name (t2, 0));
17115 free (t);
17116 error_found = 1;
17119 if (error_found)
17121 TREE_TYPE (node) = error_mark_node;
17122 return error_mark_node;
17125 TREE_TYPE (node) = resulting_type;
17126 TREE_SET_CODE (node, COND_EXPR);
17127 CAN_COMPLETE_NORMALLY (node) = 1;
17128 return node;
17131 /* Try to constant fold NODE.
17132 If NODE is not a constant expression, return NULL_EXPR.
17133 CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17135 static tree
17136 fold_constant_for_init (node, context)
17137 tree node;
17138 tree context;
17140 tree op0, op1, val;
17141 enum tree_code code = TREE_CODE (node);
17143 if (code == STRING_CST)
17144 return node;
17146 if (code == INTEGER_CST || code == REAL_CST)
17147 return convert (TREE_TYPE (context), node);
17148 if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
17149 return NULL_TREE;
17151 switch (code)
17153 case PLUS_EXPR:
17154 case MINUS_EXPR:
17155 case MULT_EXPR:
17156 case TRUNC_MOD_EXPR:
17157 case RDIV_EXPR:
17158 case LSHIFT_EXPR:
17159 case RSHIFT_EXPR:
17160 case URSHIFT_EXPR:
17161 case BIT_AND_EXPR:
17162 case BIT_XOR_EXPR:
17163 case BIT_IOR_EXPR:
17164 case TRUTH_ANDIF_EXPR:
17165 case TRUTH_ORIF_EXPR:
17166 case EQ_EXPR:
17167 case NE_EXPR:
17168 case GT_EXPR:
17169 case GE_EXPR:
17170 case LT_EXPR:
17171 case LE_EXPR:
17172 op0 = TREE_OPERAND (node, 0);
17173 op1 = TREE_OPERAND (node, 1);
17174 val = fold_constant_for_init (op0, context);
17175 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17176 return NULL_TREE;
17177 TREE_OPERAND (node, 0) = val;
17178 val = fold_constant_for_init (op1, context);
17179 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17180 return NULL_TREE;
17181 TREE_OPERAND (node, 1) = val;
17182 return patch_binop (node, op0, op1);
17184 case UNARY_PLUS_EXPR:
17185 case NEGATE_EXPR:
17186 case TRUTH_NOT_EXPR:
17187 case BIT_NOT_EXPR:
17188 case CONVERT_EXPR:
17189 op0 = TREE_OPERAND (node, 0);
17190 val = fold_constant_for_init (op0, context);
17191 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17192 return NULL_TREE;
17193 TREE_OPERAND (node, 0) = val;
17194 return patch_unaryop (node, op0);
17195 break;
17197 case COND_EXPR:
17198 val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17199 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17200 return NULL_TREE;
17201 TREE_OPERAND (node, 0) = val;
17202 val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17203 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17204 return NULL_TREE;
17205 TREE_OPERAND (node, 1) = val;
17206 val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17207 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17208 return NULL_TREE;
17209 TREE_OPERAND (node, 2) = val;
17210 return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17211 : TREE_OPERAND (node, 2);
17213 case VAR_DECL:
17214 case FIELD_DECL:
17215 if (! FIELD_FINAL (node)
17216 || DECL_INITIAL (node) == NULL_TREE)
17217 return NULL_TREE;
17218 val = DECL_INITIAL (node);
17219 /* Guard against infinite recursion. */
17220 DECL_INITIAL (node) = NULL_TREE;
17221 val = fold_constant_for_init (val, node);
17222 DECL_INITIAL (node) = val;
17223 return val;
17225 case EXPR_WITH_FILE_LOCATION:
17226 /* Compare java_complete_tree and resolve_expression_name. */
17227 if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17228 || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17230 tree name = EXPR_WFL_NODE (node);
17231 tree decl;
17232 if (PRIMARY_P (node))
17233 return NULL_TREE;
17234 else if (! QUALIFIED_P (name))
17236 decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17237 if (decl == NULL_TREE
17238 || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17239 return NULL_TREE;
17240 return fold_constant_for_init (decl, decl);
17242 else
17244 /* Wait until the USE_COMPONENT_REF re-write. FIXME. */
17245 qualify_ambiguous_name (node);
17246 if (resolve_field_access (node, &decl, NULL)
17247 && decl != NULL_TREE)
17248 return fold_constant_for_init (decl, decl);
17249 return NULL_TREE;
17252 else
17254 op0 = TREE_OPERAND (node, 0);
17255 val = fold_constant_for_init (op0, context);
17256 if (val == NULL_TREE || ! TREE_CONSTANT (val))
17257 return NULL_TREE;
17258 TREE_OPERAND (node, 0) = val;
17259 return val;
17262 #ifdef USE_COMPONENT_REF
17263 case IDENTIFIER:
17264 case COMPONENT_REF:
17266 #endif
17268 default:
17269 return NULL_TREE;
17273 #ifdef USE_COMPONENT_REF
17274 /* Context is 'T' for TypeName, 'P' for PackageName,
17275 'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17277 tree
17278 resolve_simple_name (name, context)
17279 tree name;
17280 int context;
17284 tree
17285 resolve_qualified_name (name, context)
17286 tree name;
17287 int context;
17290 #endif