OSDN Git Service

2000-04-19 Alexandre Petit-Bianco <apbianco@cygnus.com>
[pf3gnuchains/gcc-fork.git] / gcc / java / parse.c
1
2 /*  A Bison parser, made from ./parse.y
3     by GNU Bison version 1.28  */
4
5 #define YYBISON 1  /* Identify Bison output.  */
6
7 #define yyparse java_parse
8 #define yylex java_lex
9 #define yyerror java_error
10 #define yylval java_lval
11 #define yychar java_char
12 #define yydebug java_debug
13 #define yynerrs java_nerrs
14 #define PLUS_TK 257
15 #define MINUS_TK        258
16 #define MULT_TK 259
17 #define DIV_TK  260
18 #define REM_TK  261
19 #define LS_TK   262
20 #define SRS_TK  263
21 #define ZRS_TK  264
22 #define AND_TK  265
23 #define XOR_TK  266
24 #define OR_TK   267
25 #define BOOL_AND_TK     268
26 #define BOOL_OR_TK      269
27 #define EQ_TK   270
28 #define NEQ_TK  271
29 #define GT_TK   272
30 #define GTE_TK  273
31 #define LT_TK   274
32 #define LTE_TK  275
33 #define PLUS_ASSIGN_TK  276
34 #define MINUS_ASSIGN_TK 277
35 #define MULT_ASSIGN_TK  278
36 #define DIV_ASSIGN_TK   279
37 #define REM_ASSIGN_TK   280
38 #define LS_ASSIGN_TK    281
39 #define SRS_ASSIGN_TK   282
40 #define ZRS_ASSIGN_TK   283
41 #define AND_ASSIGN_TK   284
42 #define XOR_ASSIGN_TK   285
43 #define OR_ASSIGN_TK    286
44 #define PUBLIC_TK       287
45 #define PRIVATE_TK      288
46 #define PROTECTED_TK    289
47 #define STATIC_TK       290
48 #define FINAL_TK        291
49 #define SYNCHRONIZED_TK 292
50 #define VOLATILE_TK     293
51 #define TRANSIENT_TK    294
52 #define NATIVE_TK       295
53 #define PAD_TK  296
54 #define ABSTRACT_TK     297
55 #define MODIFIER_TK     298
56 #define DECR_TK 299
57 #define INCR_TK 300
58 #define DEFAULT_TK      301
59 #define IF_TK   302
60 #define THROW_TK        303
61 #define BOOLEAN_TK      304
62 #define DO_TK   305
63 #define IMPLEMENTS_TK   306
64 #define THROWS_TK       307
65 #define BREAK_TK        308
66 #define IMPORT_TK       309
67 #define ELSE_TK 310
68 #define INSTANCEOF_TK   311
69 #define RETURN_TK       312
70 #define VOID_TK 313
71 #define CATCH_TK        314
72 #define INTERFACE_TK    315
73 #define CASE_TK 316
74 #define EXTENDS_TK      317
75 #define FINALLY_TK      318
76 #define SUPER_TK        319
77 #define WHILE_TK        320
78 #define CLASS_TK        321
79 #define SWITCH_TK       322
80 #define CONST_TK        323
81 #define TRY_TK  324
82 #define FOR_TK  325
83 #define NEW_TK  326
84 #define CONTINUE_TK     327
85 #define GOTO_TK 328
86 #define PACKAGE_TK      329
87 #define THIS_TK 330
88 #define BYTE_TK 331
89 #define SHORT_TK        332
90 #define INT_TK  333
91 #define LONG_TK 334
92 #define CHAR_TK 335
93 #define INTEGRAL_TK     336
94 #define FLOAT_TK        337
95 #define DOUBLE_TK       338
96 #define FP_TK   339
97 #define ID_TK   340
98 #define REL_QM_TK       341
99 #define REL_CL_TK       342
100 #define NOT_TK  343
101 #define NEG_TK  344
102 #define ASSIGN_ANY_TK   345
103 #define ASSIGN_TK       346
104 #define OP_TK   347
105 #define CP_TK   348
106 #define OCB_TK  349
107 #define CCB_TK  350
108 #define OSB_TK  351
109 #define CSB_TK  352
110 #define SC_TK   353
111 #define C_TK    354
112 #define DOT_TK  355
113 #define STRING_LIT_TK   356
114 #define CHAR_LIT_TK     357
115 #define INT_LIT_TK      358
116 #define FP_LIT_TK       359
117 #define TRUE_TK 360
118 #define FALSE_TK        361
119 #define BOOL_LIT_TK     362
120 #define NULL_TK 363
121
122 #line 48 "./parse.y"
123
124 #include "config.h"
125 #include "system.h"
126 #include <dirent.h>
127 #include "tree.h"
128 #include "rtl.h"
129 #include "obstack.h"
130 #include "toplev.h"
131 #include "flags.h"
132 #include "java-tree.h"
133 #include "jcf.h"
134 #include "lex.h"
135 #include "parse.h"
136 #include "zipfile.h"
137 #include "convert.h"
138 #include "buffer.h"
139 #include "xref.h"
140 #include "function.h"
141 #include "except.h"
142 #include "defaults.h"
143
144 #ifndef DIR_SEPARATOR
145 #define DIR_SEPARATOR '/'
146 #endif
147
148 /* Local function prototypes */
149 static char *java_accstring_lookup PARAMS ((int));
150 static void  classitf_redefinition_error PARAMS ((const char *,tree, tree, tree));
151 static void  variable_redefinition_error PARAMS ((tree, tree, tree, int));
152 static tree  create_class PARAMS ((int, tree, tree, tree));
153 static tree  create_interface PARAMS ((int, tree, tree));
154 static void  end_class_declaration PARAMS ((int));
155 static tree  find_field PARAMS ((tree, tree));
156 static tree lookup_field_wrapper PARAMS ((tree, tree));
157 static int   duplicate_declaration_error_p PARAMS ((tree, tree, tree));
158 static void  register_fields PARAMS ((int, tree, tree));
159 static tree parser_qualified_classname PARAMS ((int, tree));
160 static int  parser_check_super PARAMS ((tree, tree, tree));
161 static int  parser_check_super_interface PARAMS ((tree, tree, tree));
162 static void check_modifiers_consistency PARAMS ((int));
163 static tree lookup_cl PARAMS ((tree));
164 static tree lookup_java_method2 PARAMS ((tree, tree, int));
165 static tree method_header PARAMS ((int, tree, tree, tree));
166 static void fix_method_argument_names PARAMS ((tree ,tree));
167 static tree method_declarator PARAMS ((tree, tree));
168 static void parse_warning_context PARAMS ((tree cl, const char *msg, ...))
169   ATTRIBUTE_PRINTF_2;
170 static void issue_warning_error_from_context PARAMS ((tree, const char *msg, va_list));
171 static void parse_ctor_invocation_error PARAMS ((void));
172 static tree parse_jdk1_1_error PARAMS ((const char *));
173 static void complete_class_report_errors PARAMS ((jdep *));
174 static int process_imports PARAMS ((void));
175 static void read_import_dir PARAMS ((tree));
176 static int find_in_imports_on_demand PARAMS ((tree));
177 static int find_in_imports PARAMS ((tree));
178 static int check_pkg_class_access PARAMS ((tree, tree));
179 static tree resolve_package PARAMS ((tree, tree *));
180 static tree lookup_package_type PARAMS ((const char *, int));
181 static tree lookup_package_type_and_set_next PARAMS ((const char *, int, tree *));
182 static tree resolve_class PARAMS ((tree, tree, tree, tree));
183 static void declare_local_variables PARAMS ((int, tree, tree));
184 static void source_start_java_method PARAMS ((tree));
185 static void source_end_java_method PARAMS ((void));
186 static void expand_start_java_method PARAMS ((tree));
187 static tree find_name_in_single_imports PARAMS ((tree));
188 static void check_abstract_method_header PARAMS ((tree));
189 static tree lookup_java_interface_method2 PARAMS ((tree, tree));
190 static tree resolve_expression_name PARAMS ((tree, tree *));
191 static tree maybe_create_class_interface_decl PARAMS ((tree, tree, tree, tree));
192 static int check_class_interface_creation PARAMS ((int, int, tree, 
193                                                   tree, tree, tree));
194 static tree patch_method_invocation PARAMS ((tree, tree, tree, 
195                                             int *, tree *));
196 static int breakdown_qualified PARAMS ((tree *, tree *, tree));
197 static tree resolve_and_layout PARAMS ((tree, tree));
198 static tree resolve_no_layout PARAMS ((tree, tree));
199 static int invocation_mode PARAMS ((tree, int));
200 static tree find_applicable_accessible_methods_list PARAMS ((int, tree, 
201                                                             tree, tree));
202 static void search_applicable_methods_list PARAMS ((int, tree, tree, tree, 
203                                                    tree *, tree *));
204 static tree find_most_specific_methods_list PARAMS ((tree));
205 static int argument_types_convertible PARAMS ((tree, tree));
206 static tree patch_invoke PARAMS ((tree, tree, tree));
207 static int maybe_use_access_method PARAMS ((int, tree *, tree *));
208 static tree lookup_method_invoke PARAMS ((int, tree, tree, tree, tree));
209 static tree register_incomplete_type PARAMS ((int, tree, tree, tree));
210 static tree obtain_incomplete_type PARAMS ((tree));
211 static tree java_complete_lhs PARAMS ((tree));
212 static tree java_complete_tree PARAMS ((tree));
213 static tree maybe_generate_pre_expand_clinit PARAMS ((tree));
214 static void java_complete_expand_method PARAMS ((tree));
215 static int  unresolved_type_p PARAMS ((tree, tree *));
216 static void create_jdep_list PARAMS ((struct parser_ctxt *));
217 static tree build_expr_block PARAMS ((tree, tree));
218 static tree enter_block PARAMS ((void));
219 static tree enter_a_block PARAMS ((tree));
220 static tree exit_block PARAMS ((void));
221 static tree lookup_name_in_blocks PARAMS ((tree));
222 static void maybe_absorb_scoping_blocks PARAMS ((void));
223 static tree build_method_invocation PARAMS ((tree, tree));
224 static tree build_new_invocation PARAMS ((tree, tree));
225 static tree build_assignment PARAMS ((int, int, tree, tree));
226 static tree build_binop PARAMS ((enum tree_code, int, tree, tree));
227 static int check_final_assignment PARAMS ((tree ,tree));
228 static tree patch_assignment PARAMS ((tree, tree, tree ));
229 static tree patch_binop PARAMS ((tree, tree, tree));
230 static tree build_unaryop PARAMS ((int, int, tree));
231 static tree build_incdec PARAMS ((int, int, tree, int));
232 static tree patch_unaryop PARAMS ((tree, tree));
233 static tree build_cast PARAMS ((int, tree, tree));
234 static tree build_null_of_type PARAMS ((tree));
235 static tree patch_cast PARAMS ((tree, tree));
236 static int valid_ref_assignconv_cast_p PARAMS ((tree, tree, int));
237 static int valid_builtin_assignconv_identity_widening_p PARAMS ((tree, tree));
238 static int valid_cast_to_p PARAMS ((tree, tree));
239 static int valid_method_invocation_conversion_p PARAMS ((tree, tree));
240 static tree try_builtin_assignconv PARAMS ((tree, tree, tree));
241 static tree try_reference_assignconv PARAMS ((tree, tree));
242 static tree build_unresolved_array_type PARAMS ((tree));
243 static tree build_array_from_name PARAMS ((tree, tree, tree, tree *));
244 static tree build_array_ref PARAMS ((int, tree, tree));
245 static tree patch_array_ref PARAMS ((tree));
246 static tree make_qualified_name PARAMS ((tree, tree, int));
247 static tree merge_qualified_name PARAMS ((tree, tree));
248 static tree make_qualified_primary PARAMS ((tree, tree, int));
249 static int resolve_qualified_expression_name PARAMS ((tree, tree *, 
250                                                      tree *, tree *));
251 static void qualify_ambiguous_name PARAMS ((tree));
252 static tree resolve_field_access PARAMS ((tree, tree *, tree *));
253 static tree build_newarray_node PARAMS ((tree, tree, int));
254 static tree patch_newarray PARAMS ((tree));
255 static tree resolve_type_during_patch PARAMS ((tree));
256 static tree build_this PARAMS ((int));
257 static tree build_wfl_wrap PARAMS ((tree));
258 static tree build_return PARAMS ((int, tree));
259 static tree patch_return PARAMS ((tree));
260 static tree maybe_access_field PARAMS ((tree, tree, tree));
261 static int complete_function_arguments PARAMS ((tree));
262 static int check_for_static_method_reference PARAMS ((tree, tree, tree, 
263                                                       tree, tree));
264 static int not_accessible_p PARAMS ((tree, tree, int));
265 static void check_deprecation PARAMS ((tree, tree));
266 static int class_in_current_package PARAMS ((tree));
267 static tree build_if_else_statement PARAMS ((int, tree, tree, tree));
268 static tree patch_if_else_statement PARAMS ((tree));
269 static tree add_stmt_to_compound PARAMS ((tree, tree, tree));
270 static tree add_stmt_to_block PARAMS ((tree, tree, tree));
271 static tree patch_exit_expr PARAMS ((tree));
272 static tree build_labeled_block PARAMS ((int, tree));
273 static tree finish_labeled_statement PARAMS ((tree, tree));
274 static tree build_bc_statement PARAMS ((int, int, tree));
275 static tree patch_bc_statement PARAMS ((tree));
276 static tree patch_loop_statement PARAMS ((tree));
277 static tree build_new_loop PARAMS ((tree));
278 static tree build_loop_body PARAMS ((int, tree, int));
279 static tree finish_loop_body PARAMS ((int, tree, tree, int));
280 static tree build_debugable_stmt PARAMS ((int, tree));
281 static tree finish_for_loop PARAMS ((int, tree, tree, tree));
282 static tree patch_switch_statement PARAMS ((tree));
283 static tree string_constant_concatenation PARAMS ((tree, tree));
284 static tree build_string_concatenation PARAMS ((tree, tree));
285 static tree patch_string_cst PARAMS ((tree));
286 static tree patch_string PARAMS ((tree));
287 static tree build_try_statement PARAMS ((int, tree, tree));
288 static tree build_try_finally_statement PARAMS ((int, tree, tree));
289 static tree patch_try_statement PARAMS ((tree));
290 static tree patch_synchronized_statement PARAMS ((tree, tree));
291 static tree patch_throw_statement PARAMS ((tree, tree));
292 static void check_thrown_exceptions PARAMS ((int, tree));
293 static int check_thrown_exceptions_do PARAMS ((tree));
294 static void purge_unchecked_exceptions PARAMS ((tree));
295 static void check_throws_clauses PARAMS ((tree, tree, tree));
296 static void finish_method_declaration PARAMS ((tree));
297 static tree build_super_invocation PARAMS ((tree));
298 static int verify_constructor_circularity PARAMS ((tree, tree));
299 static char *constructor_circularity_msg PARAMS ((tree, tree));
300 static tree build_this_super_qualified_invocation PARAMS ((int, tree, tree,
301                                                           int, int));
302 static const char *get_printable_method_name PARAMS ((tree));
303 static tree patch_conditional_expr PARAMS ((tree, tree, tree));
304 static tree generate_finit PARAMS ((tree));
305 static void add_instance_initializer PARAMS ((tree));
306 static void fix_constructors PARAMS ((tree));
307 static tree build_alias_initializer_parameter_list PARAMS ((int, tree,
308                                                             tree, int *));
309 static void craft_constructor PARAMS ((tree, tree));
310 static int verify_constructor_super PARAMS ((tree));
311 static tree create_artificial_method PARAMS ((tree, int, tree, tree, tree));
312 static void start_artificial_method_body PARAMS ((tree));
313 static void end_artificial_method_body PARAMS ((tree));
314 static int check_method_redefinition PARAMS ((tree, tree));
315 static int reset_method_name PARAMS ((tree));
316 static int check_method_types_complete PARAMS ((tree));
317 static void java_check_regular_methods PARAMS ((tree));
318 static void java_check_abstract_methods PARAMS ((tree));
319 static tree maybe_build_primttype_type_ref PARAMS ((tree, tree));
320 static void unreachable_stmt_error PARAMS ((tree));
321 static tree find_expr_with_wfl PARAMS ((tree));
322 static void missing_return_error PARAMS ((tree));
323 static tree build_new_array_init PARAMS ((int, tree));
324 static tree patch_new_array_init PARAMS ((tree, tree));
325 static tree maybe_build_array_element_wfl PARAMS ((tree));
326 static int array_constructor_check_entry PARAMS ((tree, tree));
327 static const char *purify_type_name PARAMS ((const char *));
328 static tree fold_constant_for_init PARAMS ((tree, tree));
329 static tree strip_out_static_field_access_decl PARAMS ((tree));
330 static jdeplist *reverse_jdep_list PARAMS ((struct parser_ctxt *));
331 static void static_ref_err PARAMS ((tree, tree, tree));
332 static void parser_add_interface PARAMS ((tree, tree, tree));
333 static void add_superinterfaces PARAMS ((tree, tree));
334 static tree jdep_resolve_class PARAMS ((jdep *));
335 static int note_possible_classname PARAMS ((const char *, int));
336 static void java_complete_expand_classes PARAMS ((void));
337 static void java_complete_expand_class PARAMS ((tree));
338 static void java_complete_expand_methods PARAMS ((tree));
339 static tree cut_identifier_in_qualified PARAMS ((tree));
340 static tree java_stabilize_reference PARAMS ((tree));
341 static tree do_unary_numeric_promotion PARAMS ((tree));
342 static char * operator_string PARAMS ((tree));
343 static tree do_merge_string_cste PARAMS ((tree, const char *, int, int));
344 static tree merge_string_cste PARAMS ((tree, tree, int));
345 static tree java_refold PARAMS ((tree));
346 static int java_decl_equiv PARAMS ((tree, tree));
347 static int binop_compound_p PARAMS ((enum tree_code));
348 static tree search_loop PARAMS ((tree));
349 static int labeled_block_contains_loop_p PARAMS ((tree, tree));
350 static void check_abstract_method_definitions PARAMS ((int, tree, tree));
351 static void java_check_abstract_method_definitions PARAMS ((tree));
352 static void java_debug_context_do PARAMS ((int));
353 static void java_parser_context_push_initialized_field PARAMS ((void));
354 static void java_parser_context_pop_initialized_field PARAMS ((void));
355 static tree reorder_static_initialized PARAMS ((tree));
356 static void java_parser_context_suspend PARAMS ((void));
357 static void java_parser_context_resume PARAMS ((void));
358
359 /* JDK 1.1 work. FIXME */
360
361 static tree maybe_make_nested_class_name PARAMS ((tree));
362 static void make_nested_class_name PARAMS ((tree));
363 static void set_nested_class_simple_name_value PARAMS ((tree, int));
364 static void link_nested_class_to_enclosing PARAMS ((void));
365 static tree find_as_inner_class PARAMS ((tree, tree, tree));
366 static tree find_as_inner_class_do PARAMS ((tree, tree));
367 static int check_inner_class_redefinition PARAMS ((tree, tree));
368
369 static tree build_thisn_assign PARAMS ((void));
370 static tree build_current_thisn PARAMS ((tree));
371 static tree build_access_to_thisn PARAMS ((tree, tree, int));
372 static tree maybe_build_thisn_access_method PARAMS ((tree));
373
374 static tree build_outer_field_access PARAMS ((tree, tree));
375 static tree build_outer_field_access_methods PARAMS ((tree));
376 static tree build_outer_field_access_expr PARAMS ((int, tree, tree, 
377                                                   tree, tree));
378 static tree build_outer_method_access_method PARAMS ((tree));
379 static tree build_new_access_id PARAMS ((void));
380 static tree build_outer_field_access_method PARAMS ((tree, tree, tree,
381                                                     tree, tree));
382
383 static int outer_field_access_p PARAMS ((tree, tree));
384 static int outer_field_expanded_access_p PARAMS ((tree, tree *, 
385                                                  tree *, tree *));
386 static tree outer_field_access_fix PARAMS ((tree, tree, tree));
387 static tree build_incomplete_class_ref PARAMS ((int, tree));
388 static tree patch_incomplete_class_ref PARAMS ((tree));
389 static tree create_anonymous_class PARAMS ((int, tree));
390 static void patch_anonymous_class PARAMS ((tree, tree, tree));
391 static void add_inner_class_fields PARAMS ((tree, tree));
392
393 static tree build_dot_class_method PARAMS ((tree));
394 static tree build_dot_class_method_invocation PARAMS ((tree));
395 static void create_new_parser_context PARAMS ((int));
396
397 /* Number of error found so far. */
398 int java_error_count; 
399 /* Number of warning found so far. */
400 int java_warning_count;
401 /* Tell when not to fold, when doing xrefs */
402 int do_not_fold;
403 /* Cyclic inheritance report, as it can be set by layout_class */
404 char *cyclic_inheritance_report;
405
406 /* Tell when we're within an instance initializer */
407 static int in_instance_initializer;
408
409 /* The current parser context */
410 struct parser_ctxt *ctxp;
411
412 /* List of things that were analyzed for which code will be generated */
413 static struct parser_ctxt *ctxp_for_generation = NULL;
414
415 /* binop_lookup maps token to tree_code. It is used where binary
416    operations are involved and required by the parser. RDIV_EXPR
417    covers both integral/floating point division. The code is changed
418    once the type of both operator is worked out.  */
419
420 static enum tree_code binop_lookup[19] = 
421   { 
422     PLUS_EXPR, MINUS_EXPR, MULT_EXPR, RDIV_EXPR, TRUNC_MOD_EXPR,
423     LSHIFT_EXPR, RSHIFT_EXPR, URSHIFT_EXPR, 
424     BIT_AND_EXPR, BIT_XOR_EXPR, BIT_IOR_EXPR,
425     TRUTH_ANDIF_EXPR, TRUTH_ORIF_EXPR,
426     EQ_EXPR, NE_EXPR, GT_EXPR, GE_EXPR, LT_EXPR, LE_EXPR,
427    };
428 #define BINOP_LOOKUP(VALUE)                                             \
429   binop_lookup [((VALUE) - PLUS_TK)%                                    \
430                 (sizeof (binop_lookup) / sizeof (binop_lookup[0]))]
431
432 /* This is the end index for binary operators that can also be used
433    in compound assignements. */
434 #define BINOP_COMPOUND_CANDIDATES 11
435
436 /* Fake WFL used to report error message. It is initialized once if
437    needed and reused with it's location information is overriden.  */
438 tree wfl_operator = NULL_TREE;
439
440 /* The "$L" identifier we use to create labels.  */
441 static tree label_id = NULL_TREE;
442
443 /* The "StringBuffer" identifier used for the String `+' operator. */
444 static tree wfl_string_buffer = NULL_TREE; 
445
446 /* The "append" identifier used for String `+' operator.  */
447 static tree wfl_append = NULL_TREE;
448
449 /* The "toString" identifier used for String `+' operator. */
450 static tree wfl_to_string = NULL_TREE;
451
452 /* The "java.lang" import qualified name.  */
453 static tree java_lang_id = NULL_TREE;
454
455 /* The generated `inst$' identifier used for generated enclosing
456    instance/field access functions.  */
457 static tree inst_id = NULL_TREE;
458
459 /* The "java.lang.Cloneable" qualified name.  */
460 static tree java_lang_cloneable = NULL_TREE;
461
462 /* Context and flag for static blocks */
463 static tree current_static_block = NULL_TREE;
464
465 /* The generated `write_parm_value$' identifier.  */
466 static tree wpv_id;
467
468 /* The list of all packages we've seen so far */
469 static tree package_list = NULL_TREE;
470  
471 /* Check modifiers. If one doesn't fit, retrieve it in its declaration
472    line and point it out.  */
473 /* Should point out the one that don't fit. ASCII/unicode, going
474    backward. FIXME */
475
476 #define check_modifiers(__message, __value, __mask) do {        \
477   if ((__value) & ~(__mask))                                    \
478     {                                                           \
479       int i, remainder = (__value) & ~(__mask);                 \
480       for (i = 0; i <= 10; i++)                                 \
481         if ((1 << i) & remainder)                               \
482           parse_error_context (ctxp->modifier_ctx [i], (__message), \
483                                java_accstring_lookup (1 << i)); \
484     }                                                           \
485 } while (0)
486
487
488 #line 414 "./parse.y"
489 typedef union {
490   tree node;
491   int sub_token;
492   struct {
493     int token;
494     int location;
495   } operator;
496   int value;
497 } YYSTYPE;
498 #line 424 "./parse.y"
499
500 #include "lex.c"
501 #ifndef YYDEBUG
502 #define YYDEBUG 1
503 #endif
504
505 #include <stdio.h>
506
507 #ifndef __cplusplus
508 #ifndef __STDC__
509 #define const
510 #endif
511 #endif
512
513
514
515 #define YYFINAL         791
516 #define YYFLAG          -32768
517 #define YYNTBASE        110
518
519 #define YYTRANSLATE(x) ((unsigned)(x) <= 363 ? yytranslate[x] : 272)
520
521 static const char yytranslate[] = {     0,
522      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
523      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
524      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
525      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
526      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
527      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
528      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
529      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
530      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
531      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
532      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
533      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
534      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
535      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
536      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
537      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
538      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
539      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
540      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
541      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
542      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
543      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
544      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
545      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
546      2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
547      2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
548      7,     8,     9,    10,    11,    12,    13,    14,    15,    16,
549     17,    18,    19,    20,    21,    22,    23,    24,    25,    26,
550     27,    28,    29,    30,    31,    32,    33,    34,    35,    36,
551     37,    38,    39,    40,    41,    42,    43,    44,    45,    46,
552     47,    48,    49,    50,    51,    52,    53,    54,    55,    56,
553     57,    58,    59,    60,    61,    62,    63,    64,    65,    66,
554     67,    68,    69,    70,    71,    72,    73,    74,    75,    76,
555     77,    78,    79,    80,    81,    82,    83,    84,    85,    86,
556     87,    88,    89,    90,    91,    92,    93,    94,    95,    96,
557     97,    98,    99,   100,   101,   102,   103,   104,   105,   106,
558    107,   108,   109
559 };
560
561 #if YYDEBUG != 0
562 static const short yyprhs[] = {     0,
563      0,     2,     4,     6,     8,    10,    12,    14,    16,    18,
564     20,    22,    24,    26,    28,    30,    32,    34,    38,    42,
565     46,    50,    54,    56,    58,    60,    64,    66,    67,    69,
566     71,    73,    76,    79,    82,    86,    88,    91,    93,    96,
567    100,   103,   107,   109,   111,   115,   118,   122,   128,   133,
568    139,   141,   143,   145,   147,   149,   152,   153,   161,   162,
569    169,   173,   176,   180,   185,   186,   189,   193,   196,   197,
570    200,   203,   205,   209,   213,   216,   220,   222,   225,   227,
571    229,   231,   233,   235,   238,   240,   242,   244,   248,   253,
572    255,   259,   263,   265,   269,   273,   278,   280,   284,   287,
573    291,   295,   297,   299,   300,   304,   307,   311,   315,   320,
574    325,   328,   332,   335,   339,   342,   346,   351,   355,   359,
575    363,   365,   369,   373,   376,   380,   383,   387,   389,   390,
576    393,   396,   398,   402,   406,   408,   411,   413,   416,   420,
577    422,   423,   427,   430,   434,   438,   443,   446,   450,   454,
578    459,   461,   464,   469,   475,   483,   490,   492,   494,   495,
579    500,   501,   507,   508,   514,   515,   522,   526,   531,   534,
580    538,   541,   545,   548,   552,   554,   557,   559,   561,   563,
581    565,   567,   570,   573,   576,   580,   585,   587,   591,   595,
582    598,   602,   604,   606,   608,   611,   613,   615,   617,   620,
583    623,   627,   629,   631,   633,   635,   637,   639,   641,   643,
584    645,   647,   649,   651,   653,   655,   657,   659,   661,   663,
585    665,   667,   669,   671,   673,   676,   679,   682,   685,   688,
586    691,   694,   697,   701,   706,   711,   717,   722,   728,   735,
587    743,   750,   752,   754,   756,   758,   760,   762,   764,   770,
588    773,   777,   782,   790,   798,   799,   803,   808,   811,   815,
589    821,   824,   828,   832,   837,   839,   842,   845,   847,   850,
590    854,   857,   860,   864,   867,   872,   875,   878,   882,   887,
591    890,   892,   900,   908,   915,   919,   925,   930,   938,   945,
592    948,   951,   955,   958,   959,   961,   963,   966,   967,   969,
593    971,   975,   979,   982,   986,   989,   993,   996,  1000,  1003,
594   1007,  1010,  1014,  1017,  1021,  1025,  1028,  1032,  1038,  1044,
595   1047,  1052,  1056,  1058,  1062,  1066,  1071,  1074,  1076,  1079,
596   1082,  1087,  1090,  1094,  1099,  1102,  1105,  1107,  1109,  1111,
597   1113,  1117,  1119,  1121,  1123,  1125,  1127,  1131,  1135,  1139,
598   1143,  1147,  1151,  1155,  1159,  1163,  1167,  1171,  1177,  1182,
599   1184,  1189,  1195,  1201,  1208,  1212,  1216,  1221,  1227,  1230,
600   1234,  1235,  1243,  1244,  1251,  1255,  1259,  1261,  1265,  1269,
601   1273,  1277,  1282,  1287,  1292,  1297,  1301,  1305,  1307,  1310,
602   1314,  1318,  1321,  1324,  1328,  1332,  1336,  1340,  1343,  1347,
603   1352,  1358,  1365,  1371,  1378,  1383,  1388,  1393,  1398,  1402,
604   1407,  1411,  1416,  1418,  1420,  1422,  1424,  1427,  1430,  1432,
605   1434,  1437,  1440,  1442,  1445,  1448,  1451,  1454,  1457,  1460,
606   1462,  1465,  1468,  1470,  1473,  1476,  1482,  1487,  1492,  1498,
607   1503,  1506,  1512,  1517,  1523,  1525,  1529,  1533,  1537,  1541,
608   1545,  1549,  1551,  1555,  1559,  1563,  1567,  1569,  1573,  1577,
609   1581,  1585,  1589,  1593,  1595,  1599,  1603,  1607,  1611,  1615,
610   1619,  1623,  1627,  1631,  1635,  1637,  1641,  1645,  1649,  1653,
611   1655,  1659,  1663,  1665,  1669,  1673,  1675,  1679,  1683,  1685,
612   1689,  1693,  1695,  1699,  1703,  1705,  1711,  1716,  1720,  1726,
613   1728,  1730,  1734,  1738,  1740,  1742,  1744,  1746,  1748,  1750
614 };
615
616 static const short yyrhs[] = {   123,
617      0,   104,     0,   105,     0,   108,     0,   103,     0,   102,
618      0,   109,     0,   113,     0,   114,     0,    82,     0,    85,
619      0,    50,     0,   115,     0,   118,     0,   119,     0,   115,
620      0,   115,     0,   113,    97,    98,     0,   119,    97,    98,
621      0,   118,    97,    98,     0,   113,    97,     1,     0,   118,
622     97,     1,     0,   120,     0,   121,     0,   122,     0,   119,
623    101,   122,     0,    86,     0,     0,   126,     0,   124,     0,
624    125,     0,   126,   124,     0,   126,   125,     0,   124,   125,
625      0,   126,   124,   125,     0,   127,     0,   124,   127,     0,
626    130,     0,   125,   130,     0,    75,   119,    99,     0,    75,
627      1,     0,    75,   119,     1,     0,   128,     0,   129,     0,
628     55,   119,    99,     0,    55,     1,     0,    55,   119,     1,
629      0,    55,   119,   101,     5,    99,     0,    55,   119,   101,
630      1,     0,    55,   119,   101,     5,     1,     0,   132,     0,
631    167,     0,    99,     0,     1,     0,    44,     0,   131,    44,
632      0,     0,   131,    67,   122,   135,   136,   133,   138,     0,
633      0,    67,   122,   135,   136,   134,   138,     0,   131,    67,
634      1,     0,    67,     1,     0,    67,   122,     1,     0,   131,
635     67,   122,     1,     0,     0,    63,   116,     0,    63,   116,
636      1,     0,    63,     1,     0,     0,    52,   137,     0,    52,
637      1,     0,   117,     0,   137,   100,   117,     0,   137,   100,
638      1,     0,    95,    96,     0,    95,   139,    96,     0,   140,
639      0,   139,   140,     0,   141,     0,   157,     0,   159,     0,
640    180,     0,   142,     0,   142,    99,     0,   147,     0,   132,
641      0,   167,     0,   112,   143,    99,     0,   131,   112,   143,
642     99,     0,   144,     0,   143,   100,   144,     0,   143,   100,
643      1,     0,   145,     0,   145,    92,   146,     0,   145,    92,
644      1,     0,   145,    92,   146,     1,     0,   122,     0,   145,
645     97,    98,     0,   122,     1,     0,   145,    97,     1,     0,
646    145,    98,     1,     0,   270,     0,   178,     0,     0,   149,
647    148,   156,     0,   149,     1,     0,   112,   150,   154,     0,
648     59,   150,   154,     0,   131,   112,   150,   154,     0,   131,
649     59,   150,   154,     0,   112,     1,     0,   131,   112,     1,
650      0,    59,     1,     0,   131,    59,     1,     0,   131,     1,
651      0,   122,    93,    94,     0,   122,    93,   151,    94,     0,
652    150,    97,    98,     0,   122,    93,     1,     0,   150,    97,
653      1,     0,   152,     0,   151,   100,   152,     0,   151,   100,
654      1,     0,   112,   145,     0,   153,   112,   145,     0,   112,
655      1,     0,   153,   112,     1,     0,   131,     0,     0,    53,
656    155,     0,    53,     1,     0,   116,     0,   155,   100,   116,
657      0,   155,   100,     1,     0,   180,     0,   180,    99,     0,
658     99,     0,   158,   180,     0,   158,   180,    99,     0,   131,
659      0,     0,   161,   160,   163,     0,   162,   154,     0,   131,
660    162,   154,     0,   120,    93,    94,     0,   120,    93,   151,
661     94,     0,   181,   164,     0,   181,   165,   164,     0,   181,
662    183,   164,     0,   181,   165,   183,   164,     0,   182,     0,
663    182,    99,     0,   166,    93,    94,    99,     0,   166,    93,
664    239,    94,    99,     0,   119,   101,    65,    93,   239,    94,
665     99,     0,   119,   101,    65,    93,    94,    99,     0,    76,
666      0,    65,     0,     0,    61,   122,   168,   173,     0,     0,
667    131,    61,   122,   169,   173,     0,     0,    61,   122,   172,
668    170,   173,     0,     0,   131,    61,   122,   172,   171,   173,
669      0,    61,   122,     1,     0,   131,    61,   122,     1,     0,
670     63,   117,     0,   172,   100,   117,     0,    63,     1,     0,
671    172,   100,     1,     0,    95,    96,     0,    95,   174,    96,
672      0,   175,     0,   174,   175,     0,   176,     0,   177,     0,
673    132,     0,   167,     0,   142,     0,   149,    99,     0,   149,
674      1,     0,    95,    96,     0,    95,   179,    96,     0,    95,
675    179,   100,    96,     0,   146,     0,   179,   100,   146,     0,
676    179,   100,     1,     0,    95,    96,     0,   181,   183,   182,
677      0,    95,     0,    96,     0,   184,     0,   183,   184,     0,
678    185,     0,   187,     0,   132,     0,   186,    99,     0,   112,
679    143,     0,   153,   112,   143,     0,   189,     0,   192,     0,
680    196,     0,   197,     0,   208,     0,   212,     0,   189,     0,
681    193,     0,   198,     0,   209,     0,   213,     0,   180,     0,
682    190,     0,   194,     0,   199,     0,   211,     0,   219,     0,
683    220,     0,   221,     0,   223,     0,   222,     0,   225,     0,
684     99,     0,   122,    88,     0,   191,   187,     0,   122,     1,
685      0,   191,   188,     0,   195,    99,     0,     1,    99,     0,
686      1,    95,     0,     1,    96,     0,   166,    93,     1,     0,
687    166,    93,    94,     1,     0,   166,    93,   239,     1,     0,
688    166,    93,   239,    94,     1,     0,   119,   101,    65,     1,
689      0,   119,   101,    65,    93,     1,     0,   119,   101,    65,
690     93,   239,     1,     0,   119,   101,    65,    93,   239,    94,
691      1,     0,   119,   101,    65,    93,    94,     1,     0,   267,
692      0,   251,     0,   252,     0,   248,     0,   249,     0,   245,
693      0,   234,     0,    48,    93,   270,    94,   187,     0,    48,
694      1,     0,    48,    93,     1,     0,    48,    93,   270,     1,
695      0,    48,    93,   270,    94,   188,    56,   187,     0,    48,
696     93,   270,    94,   188,    56,   188,     0,     0,   201,   200,
697    202,     0,    68,    93,   270,    94,     0,    68,     1,     0,
698     68,    93,     1,     0,    68,    93,   270,    94,     1,     0,
699     95,    96,     0,    95,   205,    96,     0,    95,   203,    96,
700      0,    95,   203,   205,    96,     0,   204,     0,   203,   204,
701      0,   205,   183,     0,   206,     0,   205,   206,     0,    62,
702    271,    88,     0,    47,    88,     0,    62,     1,     0,    62,
703    271,     1,     0,    47,     1,     0,    66,    93,   270,    94,
704      0,   207,   187,     0,    66,     1,     0,    66,    93,     1,
705      0,    66,    93,   270,     1,     0,   207,   188,     0,    51,
706      0,   210,   187,    66,    93,   270,    94,    99,     0,   215,
707     99,   270,    99,   217,    94,   187,     0,   215,    99,    99,
708    217,    94,   187,     0,   215,    99,     1,     0,   215,    99,
709    270,    99,     1,     0,   215,    99,    99,     1,     0,   215,
710     99,   270,    99,   217,    94,   188,     0,   215,    99,    99,
711    217,    94,   188,     0,    71,    93,     0,    71,     1,     0,
712     71,    93,     1,     0,   214,   216,     0,     0,   218,     0,
713    186,     0,   218,     1,     0,     0,   218,     0,   195,     0,
714    218,   100,   195,     0,   218,   100,     1,     0,    54,    99,
715      0,    54,   122,    99,     0,    54,     1,     0,    54,   122,
716      1,     0,    73,    99,     0,    73,   122,    99,     0,    73,
717      1,     0,    73,   122,     1,     0,    58,    99,     0,    58,
718    270,    99,     0,    58,     1,     0,    58,   270,     1,     0,
719     49,   270,    99,     0,    49,     1,     0,    49,   270,     1,
720      0,   224,    93,   270,    94,   180,     0,   224,    93,   270,
721     94,     1,     0,   224,     1,     0,   224,    93,     1,    94,
722      0,   224,    93,     1,     0,   131,     0,    70,   180,   226,
723      0,    70,   180,   229,     0,    70,   180,   226,   229,     0,
724     70,     1,     0,   227,     0,   226,   227,     0,   228,   180,
725      0,    60,    93,   152,    94,     0,    60,     1,     0,    60,
726     93,     1,     0,    60,    93,     1,    94,     0,    64,   180,
727      0,    64,     1,     0,   231,     0,   240,     0,   111,     0,
728     76,     0,    93,   270,    94,     0,   234,     0,   244,     0,
729    245,     0,   246,     0,   233,     0,   119,   101,    76,     0,
730     93,   270,     1,     0,   119,   101,     1,     0,   113,   101,
731      1,     0,    59,   101,     1,     0,   113,    97,    98,     0,
732    119,    97,    98,     0,   119,   101,    67,     0,   232,   101,
733     67,     0,   113,   101,    67,     0,    59,   101,    67,     0,
734     72,   116,    93,   239,    94,     0,    72,   116,    93,    94,
735      0,   235,     0,   238,   122,    93,    94,     0,   238,   122,
736     93,    94,   138,     0,   238,   122,    93,   239,    94,     0,
737    238,   122,    93,   239,    94,   138,     0,    72,     1,    99,
738      0,    72,   116,     1,     0,    72,   116,    93,     1,     0,
739     72,   116,    93,   239,     1,     0,   238,     1,     0,   238,
740    122,     1,     0,     0,    72,   116,    93,   239,    94,   236,
741    138,     0,     0,    72,   116,    93,    94,   237,   138,     0,
742    119,   101,    72,     0,   230,   101,    72,     0,   270,     0,
743    239,   100,   270,     0,   239,   100,     1,     0,    72,   113,
744    241,     0,    72,   115,   241,     0,    72,   113,   241,   243,
745      0,    72,   115,   241,   243,     0,    72,   115,   243,   178,
746      0,    72,   113,   243,   178,     0,    72,     1,    98,     0,
747     72,     1,    97,     0,   242,     0,   241,   242,     0,    97,
748    270,    98,     0,    97,   270,     1,     0,    97,     1,     0,
749     97,    98,     0,   243,    97,    98,     0,   243,    97,     1,
750      0,   230,   101,   122,     0,    65,   101,   122,     0,    65,
751      1,     0,   119,    93,    94,     0,   119,    93,   239,    94,
752      0,   230,   101,   122,    93,    94,     0,   230,   101,   122,
753     93,   239,    94,     0,    65,   101,   122,    93,    94,     0,
754     65,   101,   122,    93,   239,    94,     0,    65,   101,     1,
755     94,     0,    65,   101,     1,   101,     0,   119,    97,   270,
756     98,     0,   231,    97,   270,    98,     0,   119,    97,     1,
757      0,   119,    97,   270,     1,     0,   231,    97,     1,     0,
758    231,    97,   270,     1,     0,   230,     0,   119,     0,   248,
759      0,   249,     0,   247,    46,     0,   247,    45,     0,   251,
760      0,   252,     0,     3,   250,     0,     4,   250,     0,   253,
761      0,     3,     1,     0,     4,     1,     0,    46,   250,     0,
762     46,     1,     0,    45,   250,     0,    45,     1,     0,   247,
763      0,    89,   250,     0,    90,   250,     0,   254,     0,    89,
764      1,     0,    90,     1,     0,    93,   113,   243,    94,   250,
765      0,    93,   113,    94,   250,     0,    93,   270,    94,   253,
766      0,    93,   119,   243,    94,   253,     0,    93,   113,    97,
767      1,     0,    93,     1,     0,    93,   113,   243,    94,     1,
768      0,    93,   113,    94,     1,     0,    93,   119,   243,    94,
769      1,     0,   250,     0,   255,     5,   250,     0,   255,     6,
770    250,     0,   255,     7,   250,     0,   255,     5,     1,     0,
771    255,     6,     1,     0,   255,     7,     1,     0,   255,     0,
772    256,     3,   255,     0,   256,     4,   255,     0,   256,     3,
773      1,     0,   256,     4,     1,     0,   256,     0,   257,     8,
774    256,     0,   257,     9,   256,     0,   257,    10,   256,     0,
775    257,     8,     1,     0,   257,     9,     1,     0,   257,    10,
776      1,     0,   257,     0,   258,    20,   257,     0,   258,    18,
777    257,     0,   258,    21,   257,     0,   258,    19,   257,     0,
778    258,    57,   114,     0,   258,    20,     1,     0,   258,    18,
779      1,     0,   258,    21,     1,     0,   258,    19,     1,     0,
780    258,    57,     1,     0,   258,     0,   259,    16,   258,     0,
781    259,    17,   258,     0,   259,    16,     1,     0,   259,    17,
782      1,     0,   259,     0,   260,    11,   259,     0,   260,    11,
783      1,     0,   260,     0,   261,    12,   260,     0,   261,    12,
784      1,     0,   261,     0,   262,    13,   261,     0,   262,    13,
785      1,     0,   262,     0,   263,    14,   262,     0,   263,    14,
786      1,     0,   263,     0,   264,    15,   263,     0,   264,    15,
787      1,     0,   264,     0,   264,    87,   270,    88,   265,     0,
788    264,    87,    88,     1,     0,   264,    87,     1,     0,   264,
789     87,   270,    88,     1,     0,   265,     0,   267,     0,   268,
790    269,   266,     0,   268,   269,     1,     0,   119,     0,   244,
791      0,   246,     0,    91,     0,    92,     0,   266,     0,   270,
792      0
793 };
794
795 #endif
796
797 #if YYDEBUG != 0
798 static const short yyrline[] = { 0,
799    573,   579,   581,   582,   583,   584,   585,   589,   591,   594,
800    596,   597,   600,   602,   605,   609,   613,   617,   623,   625,
801    627,   629,   634,   636,   639,   643,   648,   653,   655,   656,
802    657,   658,   659,   660,   661,   664,   669,   675,   677,   680,
803    686,   688,   692,   694,   697,   724,   726,   730,   743,   745,
804    749,   752,   754,   756,   766,   771,   786,   790,   790,   793,
805    793,   795,   797,   802,   806,   808,   810,   812,   816,   818,
806    820,   827,   833,   838,   842,   851,   861,   863,   866,   868,
807    869,   870,   877,   879,   881,   882,   884,   889,   892,   902,
808    905,   907,   911,   914,   921,   927,   935,   937,   939,   941,
809    943,   947,   949,   953,   964,   965,   969,   972,   974,   976,
810    978,   983,   985,   987,   989,   996,  1002,  1004,  1013,  1015,
811   1019,  1024,  1029,  1033,  1038,  1043,  1048,  1055,  1065,  1067,
812   1069,  1073,  1076,  1078,  1082,  1084,  1085,  1090,  1096,  1103,
813   1119,  1126,  1129,  1132,  1136,  1142,  1146,  1155,  1157,  1159,
814   1163,  1165,  1168,  1175,  1183,  1185,  1189,  1196,  1206,  1210,
815   1210,  1213,  1213,  1216,  1216,  1219,  1219,  1221,  1225,  1231,
816   1236,  1238,  1242,  1245,  1249,  1251,  1254,  1256,  1257,  1259,
817   1263,  1267,  1273,  1278,  1281,  1283,  1287,  1293,  1297,  1302,
818   1311,  1315,  1320,  1332,  1334,  1337,  1339,  1341,  1348,  1352,
819   1355,  1359,  1361,  1362,  1363,  1364,  1365,  1369,  1371,  1372,
820   1373,  1374,  1378,  1380,  1381,  1382,  1383,  1384,  1385,  1386,
821   1387,  1388,  1389,  1392,  1397,  1408,  1411,  1415,  1422,  1432,
822   1438,  1444,  1450,  1452,  1457,  1459,  1464,  1466,  1468,  1470,
823   1472,  1476,  1478,  1479,  1480,  1481,  1482,  1483,  1486,  1492,
824   1494,  1496,  1500,  1505,  1510,  1516,  1526,  1532,  1534,  1536,
825   1543,  1546,  1548,  1550,  1554,  1556,  1559,  1563,  1565,  1568,
826   1575,  1581,  1583,  1585,  1589,  1597,  1600,  1602,  1604,  1608,
827   1613,  1622,  1627,  1630,  1637,  1639,  1641,  1645,  1648,  1657,
828   1664,  1666,  1670,  1683,  1685,  1691,  1697,  1701,  1703,  1707,
829   1710,  1712,  1716,  1719,  1721,  1723,  1727,  1730,  1732,  1734,
830   1738,  1741,  1743,  1745,  1749,  1755,  1757,  1761,  1768,  1770,
831   1772,  1774,  1778,  1790,  1793,  1795,  1800,  1804,  1806,  1813,
832   1821,  1838,  1840,  1845,  1849,  1852,  1857,  1859,  1862,  1864,
833   1866,  1868,  1869,  1870,  1871,  1872,  1876,  1881,  1883,  1885,
834   1887,  1894,  1900,  1909,  1912,  1914,  1916,  1920,  1923,  1925,
835   1929,  1935,  1936,  1942,  1943,  1945,  1947,  1949,  1951,  1953,
836   1962,  1966,  1996,  1999,  2013,  2016,  2020,  2026,  2031,  2035,
837   2038,  2040,  2042,  2046,  2055,  2063,  2065,  2069,  2072,  2076,
838   2082,  2084,  2092,  2119,  2121,  2125,  2130,  2137,  2141,  2144,
839   2146,  2157,  2168,  2173,  2182,  2184,  2188,  2191,  2193,  2198,
840   2203,  2208,  2215,  2217,  2218,  2219,  2222,  2227,  2232,  2234,
841   2235,  2237,  2239,  2240,  2242,  2246,  2249,  2253,  2256,  2260,
842   2262,  2264,  2266,  2267,  2269,  2273,  2282,  2284,  2286,  2299,
843   2301,  2307,  2309,  2311,  2315,  2317,  2322,  2327,  2332,  2334,
844   2336,  2340,  2342,  2347,  2352,  2354,  2358,  2360,  2365,  2370,
845   2375,  2377,  2379,  2383,  2385,  2390,  2395,  2400,  2405,  2407,
846   2409,  2411,  2413,  2415,  2419,  2421,  2426,  2431,  2433,  2437,
847   2439,  2444,  2448,  2450,  2455,  2459,  2461,  2466,  2470,  2472,
848   2477,  2481,  2483,  2488,  2492,  2494,  2499,  2505,  2507,  2511,
849   2513,  2516,  2519,  2527,  2529,  2530,  2533,  2535,  2538,  2542
850 };
851 #endif
852
853
854 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
855
856 static const char * const yytname[] = {   "$","error","$undefined.","PLUS_TK",
857 "MINUS_TK","MULT_TK","DIV_TK","REM_TK","LS_TK","SRS_TK","ZRS_TK","AND_TK","XOR_TK",
858 "OR_TK","BOOL_AND_TK","BOOL_OR_TK","EQ_TK","NEQ_TK","GT_TK","GTE_TK","LT_TK",
859 "LTE_TK","PLUS_ASSIGN_TK","MINUS_ASSIGN_TK","MULT_ASSIGN_TK","DIV_ASSIGN_TK",
860 "REM_ASSIGN_TK","LS_ASSIGN_TK","SRS_ASSIGN_TK","ZRS_ASSIGN_TK","AND_ASSIGN_TK",
861 "XOR_ASSIGN_TK","OR_ASSIGN_TK","PUBLIC_TK","PRIVATE_TK","PROTECTED_TK","STATIC_TK",
862 "FINAL_TK","SYNCHRONIZED_TK","VOLATILE_TK","TRANSIENT_TK","NATIVE_TK","PAD_TK",
863 "ABSTRACT_TK","MODIFIER_TK","DECR_TK","INCR_TK","DEFAULT_TK","IF_TK","THROW_TK",
864 "BOOLEAN_TK","DO_TK","IMPLEMENTS_TK","THROWS_TK","BREAK_TK","IMPORT_TK","ELSE_TK",
865 "INSTANCEOF_TK","RETURN_TK","VOID_TK","CATCH_TK","INTERFACE_TK","CASE_TK","EXTENDS_TK",
866 "FINALLY_TK","SUPER_TK","WHILE_TK","CLASS_TK","SWITCH_TK","CONST_TK","TRY_TK",
867 "FOR_TK","NEW_TK","CONTINUE_TK","GOTO_TK","PACKAGE_TK","THIS_TK","BYTE_TK","SHORT_TK",
868 "INT_TK","LONG_TK","CHAR_TK","INTEGRAL_TK","FLOAT_TK","DOUBLE_TK","FP_TK","ID_TK",
869 "REL_QM_TK","REL_CL_TK","NOT_TK","NEG_TK","ASSIGN_ANY_TK","ASSIGN_TK","OP_TK",
870 "CP_TK","OCB_TK","CCB_TK","OSB_TK","CSB_TK","SC_TK","C_TK","DOT_TK","STRING_LIT_TK",
871 "CHAR_LIT_TK","INT_LIT_TK","FP_LIT_TK","TRUE_TK","FALSE_TK","BOOL_LIT_TK","NULL_TK",
872 "goal","literal","type","primitive_type","reference_type","class_or_interface_type",
873 "class_type","interface_type","array_type","name","simple_name","qualified_name",
874 "identifier","compilation_unit","import_declarations","type_declarations","package_declaration",
875 "import_declaration","single_type_import_declaration","type_import_on_demand_declaration",
876 "type_declaration","modifiers","class_declaration","@1","@2","super","interfaces",
877 "interface_type_list","class_body","class_body_declarations","class_body_declaration",
878 "class_member_declaration","field_declaration","variable_declarators","variable_declarator",
879 "variable_declarator_id","variable_initializer","method_declaration","@3","method_header",
880 "method_declarator","formal_parameter_list","formal_parameter","final","throws",
881 "class_type_list","method_body","static_initializer","static","constructor_declaration",
882 "@4","constructor_header","constructor_declarator","constructor_body","constructor_block_end",
883 "explicit_constructor_invocation","this_or_super","interface_declaration","@5",
884 "@6","@7","@8","extends_interfaces","interface_body","interface_member_declarations",
885 "interface_member_declaration","constant_declaration","abstract_method_declaration",
886 "array_initializer","variable_initializers","block","block_begin","block_end",
887 "block_statements","block_statement","local_variable_declaration_statement",
888 "local_variable_declaration","statement","statement_nsi","statement_without_trailing_substatement",
889 "empty_statement","label_decl","labeled_statement","labeled_statement_nsi","expression_statement",
890 "statement_expression","if_then_statement","if_then_else_statement","if_then_else_statement_nsi",
891 "switch_statement","@9","switch_expression","switch_block","switch_block_statement_groups",
892 "switch_block_statement_group","switch_labels","switch_label","while_expression",
893 "while_statement","while_statement_nsi","do_statement_begin","do_statement",
894 "for_statement","for_statement_nsi","for_header","for_begin","for_init","for_update",
895 "statement_expression_list","break_statement","continue_statement","return_statement",
896 "throw_statement","synchronized_statement","synchronized","try_statement","catches",
897 "catch_clause","catch_clause_parameter","finally","primary","primary_no_new_array",
898 "array_type_literal","type_literals","class_instance_creation_expression","anonymous_class_creation",
899 "@10","@11","something_dot_new","argument_list","array_creation_expression",
900 "dim_exprs","dim_expr","dims","field_access","method_invocation","array_access",
901 "postfix_expression","post_increment_expression","post_decrement_expression",
902 "unary_expression","pre_increment_expression","pre_decrement_expression","unary_expression_not_plus_minus",
903 "cast_expression","multiplicative_expression","additive_expression","shift_expression",
904 "relational_expression","equality_expression","and_expression","exclusive_or_expression",
905 "inclusive_or_expression","conditional_and_expression","conditional_or_expression",
906 "conditional_expression","assignment_expression","assignment","left_hand_side",
907 "assignment_operator","expression","constant_expression", NULL
908 };
909 #endif
910
911 static const short yyr1[] = {     0,
912    110,   111,   111,   111,   111,   111,   111,   112,   112,   113,
913    113,   113,   114,   114,   115,   116,   117,   118,   118,   118,
914    118,   118,   119,   119,   120,   121,   122,   123,   123,   123,
915    123,   123,   123,   123,   123,   124,   124,   125,   125,   126,
916    126,   126,   127,   127,   128,   128,   128,   129,   129,   129,
917    130,   130,   130,   130,   131,   131,   133,   132,   134,   132,
918    132,   132,   132,   132,   135,   135,   135,   135,   136,   136,
919    136,   137,   137,   137,   138,   138,   139,   139,   140,   140,
920    140,   140,   141,   141,   141,   141,   141,   142,   142,   143,
921    143,   143,   144,   144,   144,   144,   145,   145,   145,   145,
922    145,   146,   146,   148,   147,   147,   149,   149,   149,   149,
923    149,   149,   149,   149,   149,   150,   150,   150,   150,   150,
924    151,   151,   151,   152,   152,   152,   152,   153,   154,   154,
925    154,   155,   155,   155,   156,   156,   156,   157,   157,   158,
926    160,   159,   161,   161,   162,   162,   163,   163,   163,   163,
927    164,   164,   165,   165,   165,   165,   166,   166,   168,   167,
928    169,   167,   170,   167,   171,   167,   167,   167,   172,   172,
929    172,   172,   173,   173,   174,   174,   175,   175,   175,   175,
930    176,   177,   177,   178,   178,   178,   179,   179,   179,   180,
931    180,   181,   182,   183,   183,   184,   184,   184,   185,   186,
932    186,   187,   187,   187,   187,   187,   187,   188,   188,   188,
933    188,   188,   189,   189,   189,   189,   189,   189,   189,   189,
934    189,   189,   189,   190,   191,   192,   192,   193,   194,   194,
935    194,   194,   194,   194,   194,   194,   194,   194,   194,   194,
936    194,   195,   195,   195,   195,   195,   195,   195,   196,   196,
937    196,   196,   197,   198,   200,   199,   201,   201,   201,   201,
938    202,   202,   202,   202,   203,   203,   204,   205,   205,   206,
939    206,   206,   206,   206,   207,   208,   208,   208,   208,   209,
940    210,   211,   212,   212,   212,   212,   212,   213,   213,   214,
941    214,   214,   215,   216,   216,   216,   216,   217,   217,   218,
942    218,   218,   219,   219,   219,   219,   220,   220,   220,   220,
943    221,   221,   221,   221,   222,   222,   222,   223,   223,   223,
944    223,   223,   224,   225,   225,   225,   225,   226,   226,   227,
945    228,   228,   228,   228,   229,   229,   230,   230,   231,   231,
946    231,   231,   231,   231,   231,   231,   231,   231,   231,   231,
947    231,   232,   232,   233,   233,   233,   233,   234,   234,   234,
948    234,   234,   234,   234,   234,   234,   234,   234,   234,   234,
949    236,   235,   237,   235,   238,   238,   239,   239,   239,   240,
950    240,   240,   240,   240,   240,   240,   240,   241,   241,   242,
951    242,   242,   243,   243,   243,   244,   244,   244,   245,   245,
952    245,   245,   245,   245,   245,   245,   246,   246,   246,   246,
953    246,   246,   247,   247,   247,   247,   248,   249,   250,   250,
954    250,   250,   250,   250,   250,   251,   251,   252,   252,   253,
955    253,   253,   253,   253,   253,   254,   254,   254,   254,   254,
956    254,   254,   254,   254,   255,   255,   255,   255,   255,   255,
957    255,   256,   256,   256,   256,   256,   257,   257,   257,   257,
958    257,   257,   257,   258,   258,   258,   258,   258,   258,   258,
959    258,   258,   258,   258,   259,   259,   259,   259,   259,   260,
960    260,   260,   261,   261,   261,   262,   262,   262,   263,   263,
961    263,   264,   264,   264,   265,   265,   265,   265,   265,   266,
962    266,   267,   267,   268,   268,   268,   269,   269,   270,   271
963 };
964
965 static const short yyr2[] = {     0,
966      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
967      1,     1,     1,     1,     1,     1,     1,     3,     3,     3,
968      3,     3,     1,     1,     1,     3,     1,     0,     1,     1,
969      1,     2,     2,     2,     3,     1,     2,     1,     2,     3,
970      2,     3,     1,     1,     3,     2,     3,     5,     4,     5,
971      1,     1,     1,     1,     1,     2,     0,     7,     0,     6,
972      3,     2,     3,     4,     0,     2,     3,     2,     0,     2,
973      2,     1,     3,     3,     2,     3,     1,     2,     1,     1,
974      1,     1,     1,     2,     1,     1,     1,     3,     4,     1,
975      3,     3,     1,     3,     3,     4,     1,     3,     2,     3,
976      3,     1,     1,     0,     3,     2,     3,     3,     4,     4,
977      2,     3,     2,     3,     2,     3,     4,     3,     3,     3,
978      1,     3,     3,     2,     3,     2,     3,     1,     0,     2,
979      2,     1,     3,     3,     1,     2,     1,     2,     3,     1,
980      0,     3,     2,     3,     3,     4,     2,     3,     3,     4,
981      1,     2,     4,     5,     7,     6,     1,     1,     0,     4,
982      0,     5,     0,     5,     0,     6,     3,     4,     2,     3,
983      2,     3,     2,     3,     1,     2,     1,     1,     1,     1,
984      1,     2,     2,     2,     3,     4,     1,     3,     3,     2,
985      3,     1,     1,     1,     2,     1,     1,     1,     2,     2,
986      3,     1,     1,     1,     1,     1,     1,     1,     1,     1,
987      1,     1,     1,     1,     1,     1,     1,     1,     1,     1,
988      1,     1,     1,     1,     2,     2,     2,     2,     2,     2,
989      2,     2,     3,     4,     4,     5,     4,     5,     6,     7,
990      6,     1,     1,     1,     1,     1,     1,     1,     5,     2,
991      3,     4,     7,     7,     0,     3,     4,     2,     3,     5,
992      2,     3,     3,     4,     1,     2,     2,     1,     2,     3,
993      2,     2,     3,     2,     4,     2,     2,     3,     4,     2,
994      1,     7,     7,     6,     3,     5,     4,     7,     6,     2,
995      2,     3,     2,     0,     1,     1,     2,     0,     1,     1,
996      3,     3,     2,     3,     2,     3,     2,     3,     2,     3,
997      2,     3,     2,     3,     3,     2,     3,     5,     5,     2,
998      4,     3,     1,     3,     3,     4,     2,     1,     2,     2,
999      4,     2,     3,     4,     2,     2,     1,     1,     1,     1,
1000      3,     1,     1,     1,     1,     1,     3,     3,     3,     3,
1001      3,     3,     3,     3,     3,     3,     3,     5,     4,     1,
1002      4,     5,     5,     6,     3,     3,     4,     5,     2,     3,
1003      0,     7,     0,     6,     3,     3,     1,     3,     3,     3,
1004      3,     4,     4,     4,     4,     3,     3,     1,     2,     3,
1005      3,     2,     2,     3,     3,     3,     3,     2,     3,     4,
1006      5,     6,     5,     6,     4,     4,     4,     4,     3,     4,
1007      3,     4,     1,     1,     1,     1,     2,     2,     1,     1,
1008      2,     2,     1,     2,     2,     2,     2,     2,     2,     1,
1009      2,     2,     1,     2,     2,     5,     4,     4,     5,     4,
1010      2,     5,     4,     5,     1,     3,     3,     3,     3,     3,
1011      3,     1,     3,     3,     3,     3,     1,     3,     3,     3,
1012      3,     3,     3,     1,     3,     3,     3,     3,     3,     3,
1013      3,     3,     3,     3,     1,     3,     3,     3,     3,     1,
1014      3,     3,     1,     3,     3,     1,     3,     3,     1,     3,
1015      3,     1,     3,     3,     1,     5,     4,     3,     5,     1,
1016      1,     3,     3,     1,     1,     1,     1,     1,     1,     1
1017 };
1018
1019 static const short yydefact[] = {     0,
1020     54,    55,     0,     0,     0,     0,    53,     1,     0,     0,
1021      0,    36,    43,    44,    38,     0,    51,    52,    46,    27,
1022      0,    23,    24,    25,     0,    62,     0,    41,     0,     0,
1023     37,    39,     0,     0,    56,     0,     0,    47,    45,     0,
1024    167,     0,     0,   163,    63,     0,    69,    42,    40,     0,
1025      0,     0,    61,     0,    49,     0,    26,   171,    17,   169,
1026     15,     0,   160,     0,     0,    68,    16,     0,     0,    59,
1027    168,     0,   165,    64,    69,    50,    48,    12,     0,    10,
1028     11,   173,     0,     8,     9,    13,    14,    15,     0,   179,
1029    181,     0,   180,     0,   175,   177,   178,   172,   170,   164,
1030     67,    71,    72,    70,     0,   162,     0,    57,   113,     0,
1031    129,   111,     0,     0,    90,    93,   129,     0,     0,     0,
1032    115,     0,     0,   183,   182,   174,   176,     0,     0,    60,
1033    166,     0,     0,     0,     0,   108,    99,    88,     0,     0,
1034      0,     0,   107,    21,    18,    22,    20,    19,   114,   129,
1035    112,     0,   129,    74,    73,   192,    75,    23,     0,    86,
1036      0,    77,    79,    83,    85,     0,    80,     0,    81,   141,
1037    129,    87,    82,     0,    58,   119,   116,     0,   128,     0,
1038    121,     0,   131,   132,   130,   120,   118,    92,     0,    91,
1039     95,     0,     0,     0,     0,     0,     0,     0,   340,     0,
1040      0,     0,     0,     6,     5,     2,     3,     4,     7,   339,
1041      0,   414,     0,   103,   413,   337,     0,   346,   342,   360,
1042      0,   338,   343,   344,   345,   430,   415,   416,   445,   419,
1043    420,   423,   433,   452,   457,   464,   475,   480,   483,   486,
1044    489,   492,   495,   500,   509,   501,     0,   102,   100,    98,
1045    101,   110,    89,   109,   190,     0,   129,    76,    78,    84,
1046    106,     0,   138,     0,   143,     0,     0,     0,   281,     0,
1047      0,     0,     0,     0,     0,     0,     0,   340,     0,   224,
1048      0,     8,   414,     0,   128,   198,     0,     0,   213,     0,
1049    194,   196,     0,   197,   202,   214,     0,   203,   215,     0,
1050    204,   205,   216,   255,     0,   206,     0,   217,   207,   294,
1051      0,   218,   219,   220,   222,   221,     0,   223,   248,   247,
1052      0,   245,   246,   243,   244,   242,   126,   124,   117,     0,
1053      0,     0,   424,   414,   343,   345,   421,   425,   422,   429,
1054    428,   427,   426,     0,   398,     0,     0,     0,    16,     0,
1055    434,   431,   435,   432,   441,     0,   414,     0,   184,   187,
1056      0,     0,     0,     0,     0,     0,    96,     0,     0,     0,
1057    369,     0,   418,   417,     0,     0,     0,     0,     0,     0,
1058      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1059      0,     0,     0,     0,     0,   507,   508,     0,   145,     0,
1060    144,   137,   105,   135,   139,   192,   142,     0,   231,   232,
1061    230,   250,     0,   316,     0,   305,   303,     0,   313,   311,
1062      0,   277,     0,   258,     0,   327,     0,   291,     0,   309,
1063    307,     0,     0,   200,     0,     0,     0,   227,   225,     0,
1064      0,   193,   191,   195,   199,   414,   323,   226,   229,     0,
1065    276,     0,   414,   296,   300,   293,     0,     0,   320,     0,
1066    123,   122,   127,   125,   134,   133,   351,   357,     0,   397,
1067    387,   386,   365,     0,   380,   388,     0,   381,     0,   366,
1068      0,     0,     0,     0,     0,     0,   348,   341,   185,     0,
1069    352,   350,   356,   399,     0,   377,   409,   353,     0,   349,
1070    354,   375,   347,   376,   396,   411,     0,   355,   370,     0,
1071    449,   446,   450,   447,   451,   448,   455,   453,   456,   454,
1072    461,   458,   462,   459,   463,   460,   471,   466,   473,   468,
1073    470,   465,   472,   467,   474,     0,   469,   478,   476,   479,
1074    477,   482,   481,   485,   484,   488,   487,   491,   490,   494,
1075    493,   498,     0,     0,   503,   502,   146,   136,   414,   147,
1076      0,     0,   151,     0,   251,     0,   317,   315,   306,   304,
1077    314,   312,   278,     0,   259,     0,     0,     0,   324,   328,
1078      0,   325,   292,   310,   308,   341,    18,    19,     0,   201,
1079    233,     0,     0,     0,   256,     0,   297,     0,   285,     0,
1080      0,   322,     0,   405,   406,     0,   392,   393,     0,   389,
1081    382,     0,   385,   383,   384,   367,   359,     0,   443,   437,
1082    440,   393,     0,   393,     0,   438,   189,   186,   188,   400,
1083      0,   410,   407,     0,   412,   408,   361,     0,   497,     0,
1084      0,   148,     0,     0,   152,   149,   252,     0,   279,   275,
1085      0,   332,     0,   336,   335,   329,   326,   330,   237,     0,
1086    234,   235,     0,     0,     0,   261,     0,   265,     0,   268,
1087      0,   302,   301,   287,     0,   299,     0,   321,     0,   403,
1088      0,   391,   390,   395,   394,     0,   368,   358,   442,   436,
1089    444,   439,   379,   378,   401,     0,   362,   363,   499,   496,
1090      0,   150,     0,     0,     0,   249,     0,   202,     0,   209,
1091    210,     0,   211,   212,     0,   260,   333,     0,   238,     0,
1092      0,   236,   274,   271,   272,   510,     0,   263,   266,     0,
1093    262,     0,   269,     0,     0,   286,     0,   319,   318,   404,
1094    374,     0,   402,   364,     0,   153,     0,     0,     0,   228,
1095    280,     0,   334,   331,   241,   239,     0,   273,   270,   264,
1096      0,   284,     0,   372,     0,     0,   154,     0,   253,     0,
1097      0,   240,   282,   283,   156,     0,     0,     0,     0,   155,
1098      0,     0,     0,     0,   289,     0,   254,   288,     0,     0,
1099      0
1100 };
1101
1102 static const short yydefgoto[] = {   789,
1103    210,   281,   211,    85,    86,    68,    60,    87,   212,    22,
1104     23,    24,     8,     9,    10,    11,    12,    13,    14,    15,
1105    447,   286,   132,   105,    47,    70,   104,   130,   161,   162,
1106    163,    91,   114,   115,   116,   213,   165,   262,    92,   111,
1107    180,   181,   287,   136,   185,   403,   167,   168,   169,   264,
1108    170,   171,   407,   560,   561,   288,    18,    43,    72,    65,
1109    107,    44,    63,    94,    95,    96,    97,   214,   361,   289,
1110    174,   563,   732,   291,   292,   293,   294,   707,   295,   296,
1111    297,   298,   710,   299,   300,   301,   302,   711,   303,   450,
1112    304,   595,   667,   668,   669,   670,   305,   306,   713,   307,
1113    308,   309,   714,   310,   311,   456,   675,   676,   312,   313,
1114    314,   315,   316,   317,   318,   579,   580,   581,   582,   215,
1115    216,   217,   218,   219,   220,   742,   686,   221,   495,   222,
1116    475,   476,   477,   223,   224,   225,   226,   227,   228,   229,
1117    230,   231,   232,   233,   234,   235,   236,   237,   238,   239,
1118    240,   241,   242,   243,   244,   245,   246,   247,   398,   496,
1119    727
1120 };
1121
1122 static const short yypact[] = {   356,
1123 -32768,-32768,   158,   -35,   339,   439,-32768,-32768,   433,   247,
1124    473,-32768,-32768,-32768,-32768,    29,-32768,-32768,-32768,-32768,
1125     12,-32768,-32768,-32768,   331,-32768,   491,-32768,    71,   469,
1126 -32768,-32768,   520,   562,-32768,   -35,   510,-32768,-32768,   278,
1127 -32768,   521,   -25,    -8,-32768,   526,   349,-32768,-32768,   -35,
1128    591,   343,-32768,   508,-32768,    25,-32768,-32768,-32768,-32768,
1129      7,  1014,-32768,   568,   -25,-32768,-32768,   346,   594,-32768,
1130 -32768,   -25,    -8,-32768,   349,-32768,-32768,-32768,   597,-32768,
1131 -32768,-32768,   607,   165,-32768,-32768,   315,   181,   676,-32768,
1132 -32768,    30,-32768,  1034,-32768,-32768,-32768,-32768,-32768,-32768,
1133 -32768,-32768,-32768,   328,   354,-32768,   -25,-32768,-32768,   370,
1134     -4,-32768,   449,   733,-32768,   201,    -4,   122,   208,   377,
1135 -32768,   608,   616,-32768,-32768,-32768,-32768,   617,   938,-32768,
1136 -32768,   354,   629,   630,   215,-32768,-32768,-32768,   648,  2189,
1137    227,   489,-32768,-32768,-32768,-32768,-32768,-32768,-32768,    -4,
1138 -32768,   743,    -4,-32768,-32768,   412,-32768,   425,   577,-32768,
1139    943,-32768,-32768,   438,-32768,    47,-32768,   455,-32768,-32768,
1140    506,-32768,-32768,  1916,-32768,-32768,-32768,   655,   569,   321,
1141 -32768,   589,-32768,-32768,   532,-32768,-32768,-32768,   485,-32768,
1142 -32768,  3001,  3052,  3117,  3168,   533,    18,   615,-32768,  3233,
1143   3284,  3349,  5298,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
1144    302,   915,    63,-32768,   542,   581,   587,-32768,-32768,-32768,
1145    656,-32768,   766,-32768,   780,   846,-32768,-32768,-32768,-32768,
1146 -32768,-32768,-32768,   879,   896,   937,   893,   880,   697,   701,
1147    717,   741,    74,-32768,-32768,-32768,   841,-32768,-32768,-32768,
1148 -32768,-32768,-32768,-32768,-32768,   774,   506,-32768,-32768,-32768,
1149 -32768,   565,   690,   685,-32768,   600,   172,  3400,-32768,   206,
1150   2240,    17,   311,   342,    82,   426,   211,   700,  5597,-32768,
1151    -35,   651,   837,   229,   522,-32768,   589,   705,-32768,  1848,
1152 -32768,-32768,   702,-32768,-32768,-32768,  1984,-32768,-32768,   709,
1153 -32768,-32768,-32768,-32768,  1984,-32768,  1984,-32768,-32768,  5648,
1154    738,-32768,-32768,-32768,-32768,-32768,   436,-32768,   806,   808,
1155    846,   891,   908,-32768,-32768,-32768,-32768,   869,-32768,   654,
1156    684,   686,-32768,   722,-32768,-32768,-32768,-32768,-32768,-32768,
1157 -32768,-32768,-32768,    27,-32768,   691,   860,   724,   724,   452,
1158 -32768,-32768,-32768,-32768,-32768,   694,  1044,    43,-32768,-32768,
1159    669,   747,   222,  5365,  2305,   538,-32768,   279,  3465,   772,
1160 -32768,   458,-32768,-32768,  3516,  3581,  3632,  3697,  3748,  3813,
1161   3864,  3929,  3980,  4045,  4096,  4161,   721,  4212,  4277,  4328,
1162   4393,  4444,  4509,  4560,  2356,-32768,-32768,  4625,-32768,   368,
1163 -32768,-32768,-32768,   750,-32768,-32768,-32768,  1848,-32768,-32768,
1164 -32768,-32768,  4676,-32768,    35,-32768,-32768,    56,-32768,-32768,
1165     70,-32768,  4741,-32768,  4792,-32768,   718,-32768,  5206,-32768,
1166 -32768,   144,   259,   762,   235,  2421,   652,-32768,-32768,   -35,
1167   2472,-32768,-32768,-32768,-32768,  1096,   569,-32768,-32768,   779,
1168 -32768,   810,  1032,-32768,-32768,-32768,    76,  2537,-32768,  4857,
1169 -32768,-32768,-32768,   869,-32768,-32768,-32768,-32768,   -49,   789,
1170 -32768,-32768,-32768,  2588,   724,-32768,   479,   724,   479,-32768,
1171   2653,  4908,   240,   135,  2704,   657,-32768,  1671,-32768,  2124,
1172 -32768,-32768,-32768,-32768,   547,-32768,-32768,-32768,   244,-32768,
1173 -32768,-32768,-32768,-32768,   801,-32768,   251,-32768,-32768,  5416,
1174 -32768,-32768,-32768,-32768,-32768,-32768,-32768,   879,-32768,   879,
1175 -32768,   896,-32768,   896,-32768,   896,-32768,   937,-32768,   937,
1176 -32768,   937,-32768,   937,-32768,   165,-32768,-32768,   893,-32768,
1177    893,-32768,   880,-32768,   697,-32768,   701,-32768,   717,-32768,
1178    741,-32768,   901,   818,-32768,-32768,-32768,-32768,  1076,-32768,
1179   1848,   815,   811,  1848,-32768,   335,-32768,-32768,-32768,-32768,
1180 -32768,-32768,-32768,   351,-32768,   823,   463,   132,   718,-32768,
1181    455,-32768,-32768,-32768,-32768,-32768,   819,   824,   464,   762,
1182 -32768,   941,    66,    -9,-32768,   851,-32768,  5340,-32768,  5231,
1183    840,   854,   857,-32768,-32768,  5481,-32768,-32768,   272,-32768,
1184    864,   294,-32768,   864,-32768,-32768,   878,    94,-32768,-32768,
1185 -32768,   819,  4973,   824,  1120,-32768,-32768,-32768,-32768,-32768,
1186   5024,-32768,-32768,  5532,-32768,-32768,   354,   548,-32768,  5089,
1187    744,-32768,  1848,  2769,-32768,-32768,-32768,  2050,-32768,-32768,
1188    263,-32768,   681,-32768,-32768,-32768,-32768,-32768,-32768,  2820,
1189 -32768,-32768,   963,   212,  5140,-32768,   419,-32768,  1564,-32768,
1190   5597,-32768,-32768,-32768,   881,   886,  5273,-32768,   268,-32768,
1191    728,-32768,-32768,-32768,-32768,   354,-32768,   903,-32768,-32768,
1192 -32768,-32768,-32768,-32768,-32768,   731,-32768,   354,-32768,-32768,
1193    504,-32768,   173,   121,   509,-32768,   940,   944,  2050,-32768,
1194 -32768,  2050,-32768,-32768,   904,-32768,   923,   925,-32768,  1020,
1195    137,-32768,-32768,-32768,-32768,-32768,   262,-32768,-32768,  1646,
1196 -32768,  1780,-32768,   932,  1984,-32768,   942,-32768,-32768,-32768,
1197 -32768,   354,-32768,-32768,  2885,-32768,   182,  4676,  1984,-32768,
1198 -32768,  2936,-32768,-32768,-32768,-32768,  1029,-32768,-32768,-32768,
1199    945,-32768,  1984,-32768,   210,   177,-32768,   401,-32768,  5231,
1200    946,-32768,-32768,-32768,-32768,   224,  2050,   947,  5273,-32768,
1201    975,  2050,   949,  2050,-32768,  2050,-32768,-32768,  1037,  1040,
1202 -32768
1203 };
1204
1205 static const short yypgoto[] = {-32768,
1206 -32768,   -54,   157,   660,    16,  -122,   582,-32768,    -3,   319,
1207 -32768,    64,-32768,  1038,   413,-32768,    69,-32768,-32768,   734,
1208    106,   409,-32768,-32768,   997,   979,-32768,  -131,-32768,   898,
1209 -32768,   -79,  -116,   918,  -167,  -194,-32768,-32768,   -64,   285,
1210    805,  -325,  -129,   -90,-32768,-32768,-32768,-32768,-32768,-32768,
1211 -32768,   907,-32768,  -544,-32768,   662,   -20,-32768,-32768,-32768,
1212 -32768,  1011,   561,-32768,   978,-32768,-32768,  -176,-32768,  -127,
1213    813,   784,  -168,  -276,-32768,   769,  -251,    93,  -560,-32768,
1214   -528,-32768,-32768,-32768,  -263,-32768,-32768,-32768,-32768,-32768,
1215 -32768,-32768,-32768,   415,   416,  -632,  -527,-32768,-32768,-32768,
1216 -32768,-32768,-32768,-32768,  -516,-32768,  -667,   770,-32768,-32768,
1217 -32768,-32768,-32768,-32768,-32768,-32768,   511,-32768,   513,-32768,
1218 -32768,-32768,-32768,   186,-32768,-32768,-32768,-32768,  -426,-32768,
1219    736,   126,  -324,  1163,   192,  1197,   283,   379,   507,  -171,
1220    583,   704,  -472,-32768,   602,   603,   481,   601,   696,   698,
1221    695,   710,   703,-32768,   454,   706,   745,-32768,-32768,   936,
1222 -32768
1223 };
1224
1225
1226 #define YYLAST          5757
1227
1228
1229 static const short yytable[] = {    21,
1230    175,   173,    29,   182,   462,   290,   152,    83,   360,   737,
1231    328,   184,    38,   444,   593,   626,   642,   345,   345,   646,
1232    337,   339,   341,   343,   479,    76,   143,   467,   352,   354,
1233    124,   484,   486,   173,   123,   567,   733,   664,    61,    83,
1234    263,    93,    61,   487,   604,   448,   455,   261,   134,   164,
1235     20,   605,   665,   451,   618,   452,   569,    59,    88,   252,
1236     61,    67,   254,   367,   166,    61,   662,    25,    27,    62,
1237    571,    48,    35,    93,    83,   350,   597,    31,   178,    59,
1238    265,   164,   426,   638,    59,    88,   666,   708,   394,    36,
1239     88,    64,   135,   468,   687,    37,   166,   733,   702,    52,
1240     54,    31,   778,    57,   123,    16,    83,    50,   172,  -158,
1241     39,   783,    40,    57,    16,    16,    16,   346,   346,   709,
1242    712,   662,   144,    77,    61,    88,   182,   331,   125,    88,
1243     61,   715,   654,   568,   404,    16,   488,   756,    16,    16,
1244    172,  -104,   110,    59,   584,  -104,   113,   427,   708,    67,
1245    611,   708,   692,   614,   570,    88,    16,    88,    19,   663,
1246    395,   -94,   -94,   464,   434,   631,   401,    89,   572,    49,
1247    283,    50,   412,   661,  -295,   598,   156,   756,    88,   681,
1248    709,   712,   722,   709,   712,   110,   113,   688,   334,   334,
1249    334,   334,   715,   631,    61,   715,   334,   334,   357,    89,
1250    182,   178,   189,   512,   514,   516,   416,   696,   146,   466,
1251    755,   430,   723,   349,   747,   186,   708,   704,    84,   145,
1252    631,   708,   492,   708,   772,   708,   156,   249,   623,   438,
1253    757,   612,   440,   721,   159,   144,   631,   284,   179,   564,
1254    621,   189,   585,    20,   632,    84,   -31,     1,   709,   712,
1255     84,   635,    88,   709,   712,   709,   712,   709,   712,   487,
1256    715,   118,   758,   716,   413,   715,   159,   715,   738,   715,
1257    776,   746,   682,   -25,   -25,   178,   631,   120,    55,   285,
1258    767,    50,    56,    88,   372,    84,   283,   444,   493,    84,
1259      2,    20,   140,   446,   684,   629,    20,   141,   142,   724,
1260    613,   446,   615,   446,   417,   147,   453,     4,   775,   431,
1261    620,   422,   187,     5,   -25,    84,   439,    84,   766,   -25,
1262    -25,   -25,   780,   590,   250,   -25,    88,   718,    61,   -25,
1263    282,    41,   587,   418,   673,   647,   455,   622,    84,    26,
1264    432,   633,   424,    71,   189,     7,   101,    67,   636,   759,
1265    504,   649,   586,   284,   348,   -28,     1,  -257,   356,   319,
1266    284,   179,   156,    20,    20,   320,   444,   117,   284,   683,
1267    284,   334,   334,   334,   334,   334,   334,   334,   334,   334,
1268    334,   334,   334,    88,   334,   334,   334,   334,   334,   334,
1269    334,   685,   643,    42,   189,   285,   706,   -66,   362,     2,
1270     69,   647,   363,   423,   559,    42,   150,   153,    17,   470,
1271      3,   119,    84,   455,   329,   179,     4,    17,    17,    17,
1272    330,    30,     5,    34,    20,  -159,   428,   128,   648,    57,
1273      6,   505,   -30,     1,   425,   179,   459,  -161,    17,    28,
1274    -66,    17,    17,    84,   650,    51,   282,   158,   129,   137,
1275    655,   690,   480,   658,     7,   444,   321,   448,   509,    17,
1276    451,   557,   133,   652,   659,   664,   282,   330,   -34,     1,
1277     90,   284,   -29,     1,   148,   319,     2,   158,   334,   158,
1278    665,   320,   319,   762,   334,   137,    84,     3,   320,   251,
1279    319,    45,   319,     4,   777,   319,   320,   769,   320,     5,
1280     57,   320,    90,   189,   659,   697,   455,   255,    74,   412,
1281     53,   774,     2,   285,   728,   455,     2,   256,   429,   -32,
1282      1,    58,  -323,   182,    20,   706,    66,     3,   460,     4,
1283    762,     7,   769,     4,   774,     5,   260,   160,   500,     5,
1284    -97,   133,   -65,   536,   481,   -97,   -97,   -97,   -97,   156,
1285    510,   739,   322,    46,   741,   653,   660,   283,   134,   -65,
1286    283,   -33,     1,     2,   282,    35,   744,     7,    98,   160,
1287     46,     7,   321,   203,     3,   612,   -97,   121,   -97,   321,
1288      4,   -97,   -97,   -97,   -97,   -65,     5,   321,    37,   321,
1289    -35,     1,   321,   319,   102,    20,   745,   109,   178,   320,
1290    610,   748,   -65,   610,   501,     2,    20,   112,   149,   502,
1291    764,    20,    35,   503,  -323,   347,   151,   154,     7,   334,
1292     35,   334,     4,    20,   284,   100,    78,   284,     5,   176,
1293    183,   332,   106,   344,     2,   122,   334,    36,    78,   283,
1294    630,   698,   368,    37,   446,    99,   631,   631,   188,    88,
1295    103,     4,   500,    20,   461,   327,   371,     5,    80,   156,
1296      7,    81,    20,   402,    78,   283,   285,   131,   322,   285,
1297     80,  -140,     2,    81,    20,   322,   121,   369,    78,    20,
1298    323,   717,    20,   322,   463,   322,   465,   370,   322,     7,
1299    321,   469,    20,    20,   409,   410,    80,     2,   411,    81,
1300     20,    20,    20,    78,    57,   446,   284,   390,   446,   155,
1301     80,   284,   391,    81,    20,    20,   589,   282,   501,    35,
1302    282,   535,   177,   502,     2,    78,   283,   503,   283,   392,
1303     78,   446,   284,    20,   122,    80,    36,    20,    81,    20,
1304     20,    20,    37,    32,   500,   446,   319,   435,   285,   319,
1305    625,   363,   320,   612,   393,   320,   324,    80,   179,   446,
1306     81,    20,    80,    32,   489,    81,    20,    32,   490,    20,
1307     78,    20,   284,   446,   285,   284,    20,   577,   446,   406,
1308    446,   578,   446,   319,    32,   319,   322,   482,   405,   320,
1309    483,   320,  -157,   284,   363,   284,   323,   441,   284,   282,
1310    445,   750,    80,   323,   751,    81,    20,   449,   701,    84,
1311    501,   323,   284,   323,   364,   502,   323,     2,   365,   503,
1312    474,   740,   366,    78,   743,   282,   284,   631,   319,    20,
1313    631,   138,   139,   319,   320,   285,   458,   285,   508,   320,
1314    284,   253,   139,   321,   491,   284,   321,   284,   558,   284,
1315   -342,  -342,  -344,  -344,   319,    80,  -505,  -505,    81,    20,
1316    320,   139,   319,   528,   530,   532,   534,   399,   320,   781,
1317   -506,  -506,   324,   594,   785,   596,   787,   325,   788,   324,
1318    321,   606,   321,   375,   376,   377,   282,   324,   282,   324,
1319    373,   374,   324,   634,   319,   388,   389,   319,   378,   379,
1320    320,   639,  -342,   320,  -344,   640,  -342,   644,  -344,   645,
1321    383,   384,   385,   386,   323,   319,   651,   319,   326,  -352,
1322    319,   320,   -15,   320,  -353,   321,   320,  -504,  -504,   364,
1323    321,   396,   397,   436,   319,  -415,  -415,   437,   677,   322,
1324    320,   661,   322,   671,   380,   381,   382,   678,   319,   387,
1325    679,   321,  -416,  -416,   320,   319,   471,   472,   473,   321,
1326    612,   320,   319,   722,   319,   141,   142,   319,   320,   319,
1327    320,   319,  -373,   320,   735,   320,   322,   320,   322,   518,
1328    520,     2,   522,   524,   526,   598,     2,    78,   539,   541,
1329    324,   321,    78,   325,   321,   749,    79,  -371,     4,  -208,
1330    325,    79,   752,     4,     5,  -504,  -504,   364,   325,     5,
1331    325,   365,   321,   325,   321,   366,   753,   321,   754,    80,
1332    755,   322,    81,    20,    80,   761,   322,    81,    20,   772,
1333    784,   321,   156,   157,   326,   763,   790,   156,   258,   791,
1334    782,   326,   786,   773,   779,   321,   537,   322,    33,   326,
1335     75,   326,   321,   108,   326,   322,   190,     2,   259,   321,
1336    400,   321,    73,    78,   321,   257,   321,   323,   321,   562,
1337    323,   127,    79,   443,     4,   248,   408,     2,   454,   457,
1338      5,   729,   730,    78,   478,   543,   547,   322,   545,   656,
1339    322,   657,    79,   700,     4,    80,   551,     0,    81,    20,
1340      5,     0,   549,   556,   323,     0,   323,     0,   322,    82,
1341    322,   325,     0,   322,     0,    80,     0,   -15,    81,    20,
1342    691,     0,  -504,  -504,   364,     0,     0,   322,   436,   126,
1343      0,     0,   366,     0,  -504,  -504,   364,   358,   248,     0,
1344    485,   322,     0,   324,   366,     0,   324,     0,   322,   323,
1345      0,     0,   326,     0,   323,   322,     0,   322,     0,     0,
1346    322,   -15,   322,     0,   322,     0,  -504,  -504,   364,    78,
1347      0,     0,   436,     0,     0,   323,   641,     0,   196,     0,
1348    324,     0,   324,   323,   197,     0,  -504,  -504,   364,     0,
1349      0,   198,   365,     0,     0,   199,   437,     0,     0,     0,
1350      0,    80,     0,   415,    81,    20,   421,     0,   200,   201,
1351      0,     0,   202,     0,   433,   323,     0,     0,   323,     0,
1352      0,   204,   205,   206,   207,   324,     0,   208,   209,     0,
1353    324,     0,     0,     0,     0,     0,   323,     0,   323,     0,
1354      0,   323,     0,     0,     0,     0,     0,     0,     0,     0,
1355      0,   324,     0,     0,     0,   323,     0,     0,     0,   324,
1356      0,     0,     0,     0,   325,     0,     0,   325,     0,   323,
1357      0,     0,     0,     0,     0,     0,   323,     0,     0,     0,
1358      0,     0,     0,   323,     0,   323,     0,     0,   323,     0,
1359    323,   324,   323,     0,   324,     0,     0,     0,     0,     0,
1360    499,   325,     0,   325,   507,   326,     0,     0,   326,     0,
1361      0,     0,   324,     0,   324,     0,     0,   324,     0,     0,
1362      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1363    554,   324,     0,     0,     0,     0,     0,     0,     0,     0,
1364      0,     0,   326,     0,   326,   324,   325,     0,   566,     0,
1365      0,   325,   324,     0,   335,   335,   335,   335,   574,   324,
1366    576,   324,   335,   335,   324,     0,   324,     0,   324,     0,
1367      0,   499,   325,     0,     0,     0,     0,     0,     0,     0,
1368    325,     0,     0,     0,     0,     0,     0,   326,   336,   336,
1369    336,   336,   326,   601,     0,   603,   336,   336,     0,     0,
1370      0,     0,     0,     0,     0,     0,     0,     0,     0,   609,
1371      0,     0,   325,   326,     0,   325,     0,     0,     0,     0,
1372    499,   326,     0,     0,     0,   248,     0,     0,     0,     0,
1373      0,     0,     0,   325,     0,   325,     0,     0,   325,     0,
1374      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1375      0,     0,   325,   326,     0,     0,   326,     0,     0,     0,
1376      0,     0,     0,     0,     0,     0,   325,     0,     0,     0,
1377      0,     0,     0,   325,   326,     0,   326,     0,     0,   326,
1378    325,     0,   325,     0,     0,   325,     0,   325,     0,   325,
1379      0,     0,     0,   326,     0,     0,     0,     0,     0,     0,
1380      0,     0,     0,     0,     0,     0,     0,   326,     0,     0,
1381      0,     0,     0,     0,   326,     0,     0,     0,     0,     0,
1382      0,   326,     0,   326,     0,     0,   326,     0,   326,     0,
1383    326,     0,     0,     0,     0,     0,     0,   335,   335,   335,
1384    335,   335,   335,   335,   335,   335,   335,   335,   335,     0,
1385    335,   335,   335,   335,   335,   335,   335,     0,     0,     0,
1386      0,     0,     0,     0,   266,     0,   694,     0,     0,     0,
1387      0,   336,   336,   336,   336,   336,   336,   336,   336,   336,
1388    336,   336,   336,     0,   336,   336,   336,   336,   336,   336,
1389    336,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1390    726,     0,     0,     0,     0,     0,   734,     2,   194,   195,
1391    664,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1392      0,   271,   196,     0,     0,   665,     0,     0,   272,   273,
1393      5,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1394      0,     0,     0,     0,   335,    80,   266,     0,    81,    20,
1395    335,     0,     0,     0,     0,     0,   279,     0,   156,   731,
1396      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1397      0,   208,   209,     0,     0,     0,     0,     0,   336,     0,
1398      0,     0,     0,   768,   336,     0,     0,   771,     0,     2,
1399    194,   195,   664,   267,   268,    78,   269,     0,     0,   270,
1400      0,     0,     0,   271,   196,     0,     0,   665,     0,     0,
1401    272,   273,     5,   274,     0,   275,   276,   198,   277,     0,
1402     78,   278,     0,     0,     0,     0,     0,    80,     0,   196,
1403     81,    20,     0,     0,     0,   197,     0,     0,   279,     0,
1404    156,   760,   198,     0,   280,     0,   199,   204,   205,   206,
1405    207,     0,    80,   208,   209,    81,    20,     0,     0,   200,
1406    201,     0,     0,   202,     0,     0,     0,     0,     0,     0,
1407      0,     0,   204,   205,   206,   207,     0,     0,   208,   209,
1408    266,     0,     0,     0,     0,   335,     0,   335,     0,     0,
1409      0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
1410      0,     0,   335,     0,     0,     0,     0,     0,     0,     0,
1411      0,     0,     0,     0,     0,     0,     0,     0,     0,   336,
1412      0,   336,     0,     2,   194,   195,  -267,   267,   268,    78,
1413    269,     0,     0,   270,     0,     0,   336,   271,   196,     0,
1414      0,  -267,     0,     0,   272,   273,     5,   274,   266,   275,
1415    276,   198,   277,     0,     0,   278,     0,     0,     0,     0,
1416      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1417      0,     0,   279,     0,   156,  -267,     0,     0,   280,     0,
1418      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1419      0,     2,   194,   195,     0,   267,   268,    78,   269,     0,
1420      0,   270,     0,     0,     0,   271,   196,     0,     0,     0,
1421      0,     0,   272,   273,     5,   274,   266,   275,   276,   198,
1422    277,     0,     0,   278,     0,     0,     0,     0,     0,    80,
1423      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1424    279,     0,   156,   442,     0,     0,   280,     0,     0,   204,
1425    205,   206,   207,     0,     0,   208,   209,     0,     0,     2,
1426    194,   195,     0,   267,   268,    78,   269,     0,     0,   270,
1427      0,     0,     0,   271,   196,     0,     0,     0,     0,     0,
1428    272,   273,     5,   274,   266,   275,   276,   198,   277,     0,
1429      0,   278,     0,     0,     0,     0,     0,    80,     0,     0,
1430     81,    20,     0,     0,     0,     0,     0,     0,   279,     0,
1431    156,     0,     0,     0,   280,     0,     0,   204,   205,   206,
1432    207,     0,     0,   208,   209,     0,     0,     2,   194,   195,
1433      0,   267,   268,    78,   269,     0,     0,   270,     0,     0,
1434      0,   271,   196,     0,     0,     0,     0,     0,   272,   273,
1435    266,   274,     0,   275,   276,   198,   277,     0,     0,   278,
1436      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1437      0,     0,     0,     0,     0,     0,   279,     0,   156,     0,
1438      0,     0,   280,     0,     0,   204,   205,   206,   207,     0,
1439      0,   208,   209,     2,   194,   195,     0,   705,   268,    78,
1440    269,     0,     0,   270,     0,     0,     0,   271,   196,     0,
1441      0,     0,     0,     0,   272,   273,     0,   274,     0,   275,
1442    276,   198,   277,     0,   627,   278,   192,   193,     0,     0,
1443      0,    80,     0,     0,    81,    20,     0,     0,     0,     0,
1444      0,     0,   279,     0,   156,     0,     0,     0,   280,     0,
1445      0,   204,   205,   206,   207,     0,     0,   208,   209,     0,
1446      0,     0,     0,     0,     0,     0,     0,     0,   194,   195,
1447      0,     0,     0,    78,     0,     0,     0,     0,     0,     0,
1448      0,     0,   196,     0,     0,     0,     0,     0,   197,   191,
1449      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1450      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1451      0,     0,   200,   201,     0,     0,   202,     0,   203,   628,
1452      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1453      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1454    419,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1455      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1456    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1457     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1458      0,   202,     0,   203,   194,   195,     0,     0,     0,    78,
1459    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1460      0,     0,     0,     0,   197,   497,     0,   192,   193,     0,
1461      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1462      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1463      0,     0,   202,     0,     0,     0,     0,     0,   420,     0,
1464      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1465    195,     0,     0,     0,    78,     0,   552,     0,   192,   193,
1466      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1467      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1468    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1469     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1470    194,   195,   498,     0,     0,    78,   204,   205,   206,   207,
1471      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1472    197,   497,     0,   192,   193,     0,     0,   198,     0,     0,
1473      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1474     81,    20,     0,   553,   200,   201,     0,     0,   202,     0,
1475      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1476    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1477     78,     0,   591,     0,   192,   193,     0,     0,     0,   196,
1478      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1479      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1480      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1481    201,     0,     0,   202,     0,     0,   194,   195,   588,     0,
1482      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1483    196,     0,     0,     0,     0,     0,   197,   599,     0,   192,
1484    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1485      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1486    200,   201,     0,     0,   202,   592,     0,     0,     0,     0,
1487      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1488    209,   194,   195,     0,     0,     0,    78,     0,   607,     0,
1489    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1490      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1491      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1492      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1493      0,     0,   194,   195,     0,   600,     0,    78,   204,   205,
1494    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1495      0,     0,   197,   616,     0,   192,   193,     0,     0,   198,
1496      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1497      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1498    202,     0,     0,     0,     0,   608,     0,     0,     0,   204,
1499    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1500      0,     0,    78,     0,   497,     0,   192,   193,     0,     0,
1501      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1502      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1503      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1504      0,   200,   201,     0,     0,   202,   617,     0,   194,   195,
1505      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1506    208,   209,   196,     0,     0,     0,     0,     0,   197,   591,
1507      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1508      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1509      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1510      0,   624,     0,     0,     0,   204,   205,   206,   207,     0,
1511      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1512    719,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1513      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1514    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1515     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1516      0,   202,   703,     0,   194,   195,     0,     0,     0,    78,
1517    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1518      0,     0,     0,     0,   197,   719,     0,   192,   193,     0,
1519      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1520      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1521      0,     0,   202,   720,     0,     0,     0,     0,     0,     0,
1522      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1523    195,     0,     0,     0,    78,     0,   599,     0,   192,   193,
1524      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1525      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1526    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1527     20,     0,     0,   200,   201,     0,     0,   202,   765,     0,
1528    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1529      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1530    197,   333,     0,   192,   193,     0,     0,   198,     0,     0,
1531      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1532     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1533      0,     0,     0,     0,   770,     0,     0,   204,   205,   206,
1534    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1535     78,     0,   338,     0,   192,   193,     0,     0,     0,   196,
1536      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1537      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1538      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1539    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1540      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1541    196,     0,     0,     0,     0,     0,   197,   340,     0,   192,
1542    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1543      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1544    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1545      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1546    209,   194,   195,     0,     0,     0,    78,     0,   342,     0,
1547    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1548      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1549      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1550      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1551      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1552    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1553      0,     0,   197,   351,     0,   192,   193,     0,     0,   198,
1554      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1555      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1556    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1557    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1558      0,     0,    78,     0,   353,     0,   192,   193,     0,     0,
1559      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1560      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1561      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1562      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1563      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1564    208,   209,   196,     0,     0,     0,     0,     0,   197,   355,
1565      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1566      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1567      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1568      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1569      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1570    414,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1571      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1572    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1573     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1574      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1575    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1576      0,     0,     0,     0,   197,   506,     0,   192,   193,     0,
1577      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1578      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1579      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1580      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1581    195,     0,     0,     0,    78,     0,   511,     0,   192,   193,
1582      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1583      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1584    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1585     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1586    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1587      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1588    197,   513,     0,   192,   193,     0,     0,   198,     0,     0,
1589      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1590     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1591      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1592    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1593     78,     0,   515,     0,   192,   193,     0,     0,     0,   196,
1594      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1595      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1596      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1597    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1598      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1599    196,     0,     0,     0,     0,     0,   197,   517,     0,   192,
1600    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1601      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1602    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1603      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1604    209,   194,   195,     0,     0,     0,    78,     0,   519,     0,
1605    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1606      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1607      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1608      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1609      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1610    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1611      0,     0,   197,   521,     0,   192,   193,     0,     0,   198,
1612      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1613      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1614    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1615    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1616      0,     0,    78,     0,   523,     0,   192,   193,     0,     0,
1617      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1618      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1619      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1620      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1621      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1622    208,   209,   196,     0,     0,     0,     0,     0,   197,   525,
1623      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1624      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1625      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1626      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1627      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1628    527,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1629      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1630    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1631     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1632      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1633    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1634      0,     0,     0,     0,   197,   529,     0,   192,   193,     0,
1635      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1636      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1637      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1638      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1639    195,     0,     0,     0,    78,     0,   531,     0,   192,   193,
1640      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1641      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1642    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1643     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1644    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1645      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1646    197,   533,     0,   192,   193,     0,     0,   198,     0,     0,
1647      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1648     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1649      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1650    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1651     78,     0,   538,     0,   192,   193,     0,     0,     0,   196,
1652      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1653      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1654      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1655    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1656      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1657    196,     0,     0,     0,     0,     0,   197,   540,     0,   192,
1658    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1659      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1660    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1661      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1662    209,   194,   195,     0,     0,     0,    78,     0,   542,     0,
1663    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1664      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1665      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1666      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1667      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1668    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1669      0,     0,   197,   544,     0,   192,   193,     0,     0,   198,
1670      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1671      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1672    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1673    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1674      0,     0,    78,     0,   546,     0,   192,   193,     0,     0,
1675      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1676      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1677      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1678      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1679      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1680    208,   209,   196,     0,     0,     0,     0,     0,   197,   548,
1681      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1682      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1683      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1684      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1685      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1686    550,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1687      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1688    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1689     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1690      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1691    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1692      0,     0,     0,     0,   197,   555,     0,   192,   193,     0,
1693      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1694      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1695      0,     0,   202,     0,     0,     0,     0,     0,     0,     0,
1696      0,   204,   205,   206,   207,     0,     0,   208,   209,   194,
1697    195,     0,     0,     0,    78,     0,   565,     0,   192,   193,
1698      0,     0,     0,   196,     0,     0,     0,     0,     0,   197,
1699      0,     0,     0,     0,     0,     0,   198,     0,     0,     0,
1700    199,     0,     0,     0,     0,     0,    80,     0,     0,    81,
1701     20,     0,     0,   200,   201,     0,     0,   202,     0,     0,
1702    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1703      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1704    197,   573,     0,   192,   193,     0,     0,   198,     0,     0,
1705      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1706     81,    20,     0,     0,   200,   201,     0,     0,   202,     0,
1707      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1708    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1709     78,     0,   575,     0,   192,   193,     0,     0,     0,   196,
1710      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1711      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1712      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1713    201,     0,     0,   202,     0,     0,   194,   195,     0,     0,
1714      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1715    196,     0,     0,     0,     0,     0,   197,   602,     0,   192,
1716    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1717      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1718    200,   201,     0,     0,   202,     0,     0,     0,     0,     0,
1719      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1720    209,   194,   195,     0,     0,     0,    78,     0,   619,     0,
1721    192,   193,     0,     0,     0,   196,     0,     0,     0,     0,
1722      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1723      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1724      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1725      0,     0,   194,   195,     0,     0,     0,    78,   204,   205,
1726    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1727      0,     0,   197,   689,     0,   192,   193,     0,     0,   198,
1728      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1729      0,     0,    81,    20,     0,     0,   200,   201,     0,     0,
1730    202,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1731    205,   206,   207,     0,     0,   208,   209,   194,   195,     0,
1732      0,     0,    78,     0,   693,     0,   192,   193,     0,     0,
1733      0,   196,     0,     0,     0,     0,     0,   197,     0,     0,
1734      0,     0,     0,     0,   198,     0,     0,     0,   199,     0,
1735      0,     0,     0,     0,    80,     0,     0,    81,    20,     0,
1736      0,   200,   201,     0,     0,   202,     0,     0,   194,   195,
1737      0,     0,     0,    78,   204,   205,   206,   207,     0,     0,
1738    208,   209,   196,     0,     0,     0,     0,     0,   197,   699,
1739      0,   192,   193,     0,     0,   198,     0,     0,     0,   199,
1740      0,     0,     0,     0,     0,    80,     0,     0,    81,    20,
1741      0,     0,   200,   201,     0,     0,   202,     0,     0,     0,
1742      0,     0,     0,     0,     0,   204,   205,   206,   207,     0,
1743      0,   208,   209,   194,   195,     0,     0,     0,    78,     0,
1744    725,     0,   192,   193,     0,     0,     0,   196,     0,     0,
1745      0,     0,     0,   197,     0,     0,     0,     0,     0,     0,
1746    198,     0,     0,     0,   199,     0,     0,     0,     0,     0,
1747     80,     0,     0,    81,    20,     0,     0,   200,   201,     0,
1748      0,   202,     0,     0,   194,   195,     0,     0,     0,    78,
1749    204,   205,   206,   207,     0,     0,   208,   209,   196,     0,
1750      0,     0,     0,     0,   197,     0,   583,     0,     0,     0,
1751      0,   198,     0,     0,     0,   199,     0,     0,     0,     0,
1752      0,    80,     0,     0,    81,    20,     0,     0,   200,   201,
1753      0,   674,   202,     0,     0,     0,     0,     0,     0,     0,
1754      0,   204,   205,   206,   207,     0,     0,   208,   209,  -290,
1755   -290,  -290,     0,     0,     0,  -290,     0,     0,     0,     0,
1756      0,     0,     0,     0,  -290,     0,     0,     0,     0,     0,
1757   -290,     0,     0,   736,     0,   194,   195,  -290,     0,     0,
1758     78,  -290,     0,     0,     0,     0,     0,  -290,     0,   196,
1759   -290,  -290,     0,     0,     0,   197,     0,     0,  -290,     0,
1760    192,   193,   198,     0,  -290,     0,   199,  -290,  -290,  -290,
1761   -290,     0,    80,  -290,  -290,    81,    20,   194,   195,     0,
1762      0,     0,    78,   279,  -298,     0,     0,     0,     0,     0,
1763      0,   196,   204,   205,   206,   207,     0,   197,   208,   209,
1764    672,     0,   194,   195,   198,     0,     0,    78,   199,     0,
1765      0,     0,     0,     0,    80,     0,   196,    81,    20,     0,
1766      0,     0,   197,     0,     0,   279,  -298,   192,   193,   198,
1767      0,     0,     0,   199,   204,   205,   206,   207,     0,    80,
1768    208,   209,    81,    20,   194,   195,   200,   201,     0,    78,
1769    202,     0,   203,   359,     0,     0,     0,     0,   196,   204,
1770    205,   206,   207,     0,   197,   208,   209,     0,     0,   194,
1771    195,   198,     0,     0,    78,   199,     0,     0,   192,   193,
1772      0,    80,     0,   196,    81,    20,     0,     0,     0,   197,
1773      0,     0,   279,     0,     0,     0,   198,     0,     0,     0,
1774    199,   204,   205,   206,   207,     0,    80,   208,   209,    81,
1775     20,     0,     0,   200,   201,     0,     0,   202,   494,     0,
1776    194,   195,     0,     0,     0,    78,   204,   205,   206,   207,
1777      0,     0,   208,   209,   196,     0,     0,     0,     0,     0,
1778    197,     0,     0,   192,   193,     0,     0,   198,     0,     0,
1779      0,   199,     0,     0,     0,     0,     0,    80,     0,     0,
1780     81,    20,     0,     0,   200,   201,     0,     0,   202,   637,
1781      0,     0,     0,     0,     0,     0,     0,   204,   205,   206,
1782    207,     0,     0,   208,   209,   194,   195,     0,     0,     0,
1783     78,     0,     0,     0,   192,   193,     0,     0,     0,   196,
1784      0,     0,     0,     0,     0,   197,     0,     0,     0,     0,
1785      0,     0,   198,     0,     0,     0,   199,     0,     0,     0,
1786      0,     0,    80,     0,     0,    81,    20,     0,     0,   200,
1787    201,     0,     0,   202,   680,     0,   194,   195,     0,     0,
1788      0,    78,   204,   205,   206,   207,     0,     0,   208,   209,
1789    196,     0,     0,     0,     0,     0,   197,     0,     0,   192,
1790    193,     0,     0,   198,     0,     0,     0,   199,     0,     0,
1791      0,     0,     0,    80,     0,     0,    81,    20,     0,     0,
1792    200,   201,     0,     0,   202,   695,     0,     0,     0,     0,
1793      0,     0,     0,   204,   205,   206,   207,     0,     0,   208,
1794    209,   194,   195,     0,     0,     0,    78,     0,     0,     0,
1795      0,     0,     0,     0,     0,   196,     0,     0,     0,     0,
1796      0,   197,     0,     0,     0,     0,     0,     0,   198,     0,
1797      0,     0,   199,     0,     0,     0,     0,     0,    80,     0,
1798      0,    81,    20,     0,     0,   200,   201,     0,     0,   202,
1799      0,     2,   194,   195,     0,     0,     0,    78,   204,   205,
1800    206,   207,     0,     0,   208,   209,   196,     0,     0,     0,
1801      0,     0,   197,     0,     0,     0,     0,     0,     0,   198,
1802      0,     0,     0,   199,     0,     0,     0,     0,     0,    80,
1803      0,     0,    81,    20,     0,     0,     0,     0,     0,     0,
1804    279,     0,     0,     0,     0,     0,     0,     0,     0,   204,
1805    205,   206,   207,     0,     0,   208,   209
1806 };
1807
1808 static const short yycheck[] = {     3,
1809    132,   129,     6,   133,   330,   174,   123,    62,   203,   677,
1810    178,   134,     1,   290,   441,   488,   561,     1,     1,   564,
1811    192,   193,   194,   195,   349,     1,   117,     1,   200,   201,
1812      1,   356,   357,   161,    89,     1,   669,    47,    42,    94,
1813    168,    62,    46,     1,    94,   297,   310,     1,    53,   129,
1814     86,   101,    62,   305,   481,   307,     1,    42,    62,   150,
1815     64,    46,   153,     1,   129,    69,     1,     4,     5,    95,
1816      1,     1,    44,    94,   129,   198,     1,     9,   133,    64,
1817    171,   161,     1,   510,    69,    89,    96,   648,    15,    61,
1818     94,   100,    97,    67,     1,    67,   161,   730,   643,    36,
1819     37,    33,   770,    40,   159,     0,   161,   101,   129,    93,
1820     99,   779,   101,    50,     9,    10,    11,   101,   101,   648,
1821    648,     1,     1,    99,   128,   129,   256,   182,    99,   133,
1822    134,   648,     1,    99,   262,    30,    94,     1,    33,    34,
1823    161,    95,    79,   128,     1,    99,    83,   275,   709,   134,
1824    475,   712,   625,   478,    99,   159,    51,   161,     1,    94,
1825     87,    99,   100,   331,   281,   100,   257,    62,    99,    99,
1826    174,   101,     1,     1,    99,   100,    95,     1,   182,   606,
1827    709,   709,     1,   712,   712,   122,   123,    94,   192,   193,
1828    194,   195,   709,   100,   198,   712,   200,   201,   202,    94,
1829    330,   256,   139,   375,   376,   377,     1,   634,     1,   332,
1830      1,     1,     1,   198,    94,     1,   777,   644,    62,    98,
1831    100,   782,     1,   784,     1,   786,    95,     1,    94,     1,
1832     94,    97,   287,   660,   129,     1,   100,   174,   133,   408,
1833      1,   178,    99,    86,     1,    89,     0,     1,   777,   777,
1834     94,     1,   256,   782,   782,   784,   784,   786,   786,     1,
1835    777,    97,     1,     1,    93,   782,   161,   784,     1,   786,
1836     94,    99,     1,    45,    46,   330,   100,    97,     1,   174,
1837     99,   101,     5,   287,   221,   129,   290,   564,    67,   133,
1838     44,    86,    92,   297,     1,   490,    86,    97,    98,    88,
1839    477,   305,   479,   307,    99,    98,   310,    61,    99,    99,
1840    482,     1,    98,    67,    86,   159,    88,   161,   745,    91,
1841     92,    93,    99,   440,    98,    97,   330,   653,   332,   101,
1842    174,     1,    98,   270,   598,     1,   600,    98,   182,     1,
1843    277,    98,     1,     1,   281,    99,     1,   332,    98,    88,
1844     72,     1,    94,   290,   198,     0,     1,    95,   202,   174,
1845    297,   256,    95,    86,    86,   174,   643,    83,   305,    98,
1846    307,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1847    384,   385,   386,   387,   388,   389,   390,   391,   392,   393,
1848    394,    98,   561,    63,   331,   290,   648,    52,    97,    44,
1849     52,     1,   101,    93,   408,    63,   122,   123,     0,   346,
1850     55,    97,   256,   677,    94,   310,    61,     9,    10,    11,
1851    100,     9,    67,    11,    86,    95,     1,   100,    94,   366,
1852     75,   368,     0,     1,    93,   330,     1,    95,    30,     1,
1853     95,    33,    34,   287,    94,    33,   290,   129,    95,     1,
1854    578,   623,     1,   581,    99,   732,   174,   709,     1,    51,
1855    712,    94,    93,     1,     1,    47,   310,   100,     0,     1,
1856     62,   408,     0,     1,    98,   290,    44,   159,   482,   161,
1857     62,   290,   297,   735,   488,     1,   330,    55,   297,     1,
1858    305,     1,   307,    61,    94,   310,   305,   749,   307,    67,
1859    437,   310,    94,   440,     1,   637,   770,    96,     1,     1,
1860      1,   763,    44,   408,    96,   779,    44,    93,    93,     0,
1861      1,     1,     1,   653,    86,   777,     1,    55,    93,    61,
1862    782,    99,   784,    61,   786,    67,    99,   129,     1,    67,
1863     92,    93,    52,   387,    93,    97,    98,    99,   100,    95,
1864     93,   679,   174,    63,   686,    93,    93,   561,    53,    52,
1865    564,     0,     1,    44,   408,    44,   698,    99,     1,   161,
1866     63,    99,   290,    95,    55,    97,    92,     1,    94,   297,
1867     61,    97,    98,    99,   100,    95,    67,   305,    67,   307,
1868      0,     1,   310,   408,     1,    86,    93,     1,   653,   408,
1869    475,    93,    95,   478,    67,    44,    86,     1,     1,    72,
1870    742,    86,    44,    76,    93,     1,     1,     1,    99,   623,
1871     44,   625,    61,    86,   561,    65,    50,   564,    67,     1,
1872      1,   100,    72,   101,    44,    59,   640,    61,    50,   643,
1873     94,    94,   101,    67,   648,    64,   100,   100,     1,   653,
1874     69,    61,     1,    86,     1,     1,     1,    67,    82,    95,
1875     99,    85,    86,    99,    50,   669,   561,   107,   290,   564,
1876     82,    95,    44,    85,    86,   297,     1,    97,    50,    86,
1877    174,     1,    86,   305,     1,   307,     1,   101,   310,    99,
1878    408,     1,    86,    86,    95,    96,    82,    44,    99,    85,
1879     86,    86,    86,    50,   641,   709,   643,    11,   712,   128,
1880     82,   648,    12,    85,    86,    86,    65,   561,    67,    44,
1881    564,     1,    94,    72,    44,    50,   730,    76,   732,    13,
1882     50,   735,   669,    86,    59,    82,    61,    86,    85,    86,
1883     86,    86,    67,    10,     1,   749,   561,    97,   643,   564,
1884     94,   101,   561,    97,    14,   564,   174,    82,   653,   763,
1885     85,    86,    82,    30,    96,    85,    86,    34,   100,    86,
1886     50,    86,   709,   777,   669,   712,    86,    60,   782,    95,
1887    784,    64,   786,   598,    51,   600,   408,    94,    99,   598,
1888     97,   600,    93,   730,   101,   732,   290,    93,   735,   643,
1889     99,   709,    82,   297,   712,    85,    86,    99,    65,   653,
1890     67,   305,   749,   307,    93,    72,   310,    44,    97,    76,
1891     97,    94,   101,    50,    94,   669,   763,   100,   643,    86,
1892    100,    99,   100,   648,   643,   730,    99,   732,    67,   648,
1893    777,    99,   100,   561,    98,   782,   564,   784,    99,   786,
1894     45,    46,    45,    46,   669,    82,    91,    92,    85,    86,
1895    669,   100,   677,   383,   384,   385,   386,    94,   677,   777,
1896     91,    92,   290,    95,   782,    66,   784,   174,   786,   297,
1897    598,    93,   600,     5,     6,     7,   730,   305,   732,   307,
1898     45,    46,   310,    93,   709,    16,    17,   712,     3,     4,
1899    709,     1,    97,   712,    97,    88,   101,    93,   101,    99,
1900     18,    19,    20,    21,   408,   730,    94,   732,   174,   101,
1901    735,   730,    86,   732,   101,   643,   735,    91,    92,    93,
1902    648,    91,    92,    97,   749,    45,    46,   101,    99,   561,
1903    749,     1,   564,    93,     8,     9,    10,    94,   763,    57,
1904     94,   669,    45,    46,   763,   770,    97,    98,    99,   677,
1905     97,   770,   777,     1,   779,    97,    98,   782,   777,   784,
1906    779,   786,    95,   782,    94,   784,   598,   786,   600,   378,
1907    379,    44,   380,   381,   382,   100,    44,    50,   388,   389,
1908    408,   709,    50,   290,   712,    56,    59,    95,    61,    56,
1909    297,    59,    99,    61,    67,    91,    92,    93,   305,    67,
1910    307,    97,   730,   310,   732,   101,    94,   735,    94,    82,
1911      1,   643,    85,    86,    82,    94,   648,    85,    86,     1,
1912     56,   749,    95,    96,   290,    94,     0,    95,    96,     0,
1913     94,   297,    94,    99,    99,   763,   387,   669,    11,   305,
1914     54,   307,   770,    75,   310,   677,   139,    44,   161,   777,
1915    256,   779,    52,    50,   782,   159,   784,   561,   786,   408,
1916    564,    94,    59,   290,    61,   140,   264,    44,   310,   310,
1917     67,   667,   667,    50,   349,   390,   392,   709,   391,   579,
1918    712,   579,    59,   640,    61,    82,   394,    -1,    85,    86,
1919     67,    -1,   393,   398,   598,    -1,   600,    -1,   730,    96,
1920    732,   408,    -1,   735,    -1,    82,    -1,    86,    85,    86,
1921      1,    -1,    91,    92,    93,    -1,    -1,   749,    97,    96,
1922     -1,    -1,   101,    -1,    91,    92,    93,   202,   203,    -1,
1923     97,   763,    -1,   561,   101,    -1,   564,    -1,   770,   643,
1924     -1,    -1,   408,    -1,   648,   777,    -1,   779,    -1,    -1,
1925    782,    86,   784,    -1,   786,    -1,    91,    92,    93,    50,
1926     -1,    -1,    97,    -1,    -1,   669,   101,    -1,    59,    -1,
1927    598,    -1,   600,   677,    65,    -1,    91,    92,    93,    -1,
1928     -1,    72,    97,    -1,    -1,    76,   101,    -1,    -1,    -1,
1929     -1,    82,    -1,   268,    85,    86,   271,    -1,    89,    90,
1930     -1,    -1,    93,    -1,   279,   709,    -1,    -1,   712,    -1,
1931     -1,   102,   103,   104,   105,   643,    -1,   108,   109,    -1,
1932    648,    -1,    -1,    -1,    -1,    -1,   730,    -1,   732,    -1,
1933     -1,   735,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1934     -1,   669,    -1,    -1,    -1,   749,    -1,    -1,    -1,   677,
1935     -1,    -1,    -1,    -1,   561,    -1,    -1,   564,    -1,   763,
1936     -1,    -1,    -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,
1937     -1,    -1,    -1,   777,    -1,   779,    -1,    -1,   782,    -1,
1938    784,   709,   786,    -1,   712,    -1,    -1,    -1,    -1,    -1,
1939    365,   598,    -1,   600,   369,   561,    -1,    -1,   564,    -1,
1940     -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,    -1,
1941     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1942    395,   749,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1943     -1,    -1,   598,    -1,   600,   763,   643,    -1,   413,    -1,
1944     -1,   648,   770,    -1,   192,   193,   194,   195,   423,   777,
1945    425,   779,   200,   201,   782,    -1,   784,    -1,   786,    -1,
1946     -1,   436,   669,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1947    677,    -1,    -1,    -1,    -1,    -1,    -1,   643,   192,   193,
1948    194,   195,   648,   458,    -1,   460,   200,   201,    -1,    -1,
1949     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   474,
1950     -1,    -1,   709,   669,    -1,   712,    -1,    -1,    -1,    -1,
1951    485,   677,    -1,    -1,    -1,   490,    -1,    -1,    -1,    -1,
1952     -1,    -1,    -1,   730,    -1,   732,    -1,    -1,   735,    -1,
1953     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1954     -1,    -1,   749,   709,    -1,    -1,   712,    -1,    -1,    -1,
1955     -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,    -1,
1956     -1,    -1,    -1,   770,   730,    -1,   732,    -1,    -1,   735,
1957    777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,   786,
1958     -1,    -1,    -1,   749,    -1,    -1,    -1,    -1,    -1,    -1,
1959     -1,    -1,    -1,    -1,    -1,    -1,    -1,   763,    -1,    -1,
1960     -1,    -1,    -1,    -1,   770,    -1,    -1,    -1,    -1,    -1,
1961     -1,   777,    -1,   779,    -1,    -1,   782,    -1,   784,    -1,
1962    786,    -1,    -1,    -1,    -1,    -1,    -1,   375,   376,   377,
1963    378,   379,   380,   381,   382,   383,   384,   385,   386,    -1,
1964    388,   389,   390,   391,   392,   393,   394,    -1,    -1,    -1,
1965     -1,    -1,    -1,    -1,     1,    -1,   631,    -1,    -1,    -1,
1966     -1,   375,   376,   377,   378,   379,   380,   381,   382,   383,
1967    384,   385,   386,    -1,   388,   389,   390,   391,   392,   393,
1968    394,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1969    665,    -1,    -1,    -1,    -1,    -1,   671,    44,    45,    46,
1970     47,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
1971     -1,    58,    59,    -1,    -1,    62,    -1,    -1,    65,    66,
1972     67,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
1973     -1,    -1,    -1,    -1,   482,    82,     1,    -1,    85,    86,
1974    488,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    96,
1975     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
1976     -1,   108,   109,    -1,    -1,    -1,    -1,    -1,   482,    -1,
1977     -1,    -1,    -1,   748,   488,    -1,    -1,   752,    -1,    44,
1978     45,    46,    47,    48,    49,    50,    51,    -1,    -1,    54,
1979     -1,    -1,    -1,    58,    59,    -1,    -1,    62,    -1,    -1,
1980     65,    66,    67,    68,    -1,    70,    71,    72,    73,    -1,
1981     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
1982     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
1983     95,    96,    72,    -1,    99,    -1,    76,   102,   103,   104,
1984    105,    -1,    82,   108,   109,    85,    86,    -1,    -1,    89,
1985     90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,
1986     -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,   109,
1987      1,    -1,    -1,    -1,    -1,   623,    -1,   625,    -1,    -1,
1988     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1989     -1,    -1,   640,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
1990     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   623,
1991     -1,   625,    -1,    44,    45,    46,    47,    48,    49,    50,
1992     51,    -1,    -1,    54,    -1,    -1,   640,    58,    59,    -1,
1993     -1,    62,    -1,    -1,    65,    66,    67,    68,     1,    70,
1994     71,    72,    73,    -1,    -1,    76,    -1,    -1,    -1,    -1,
1995     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
1996     -1,    -1,    93,    -1,    95,    96,    -1,    -1,    99,    -1,
1997     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
1998     -1,    44,    45,    46,    -1,    48,    49,    50,    51,    -1,
1999     -1,    54,    -1,    -1,    -1,    58,    59,    -1,    -1,    -1,
2000     -1,    -1,    65,    66,    67,    68,     1,    70,    71,    72,
2001     73,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2002     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2003     93,    -1,    95,    96,    -1,    -1,    99,    -1,    -1,   102,
2004    103,   104,   105,    -1,    -1,   108,   109,    -1,    -1,    44,
2005     45,    46,    -1,    48,    49,    50,    51,    -1,    -1,    54,
2006     -1,    -1,    -1,    58,    59,    -1,    -1,    -1,    -1,    -1,
2007     65,    66,    67,    68,     1,    70,    71,    72,    73,    -1,
2008     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2009     85,    86,    -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,
2010     95,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2011    105,    -1,    -1,   108,   109,    -1,    -1,    44,    45,    46,
2012     -1,    48,    49,    50,    51,    -1,    -1,    54,    -1,    -1,
2013     -1,    58,    59,    -1,    -1,    -1,    -1,    -1,    65,    66,
2014      1,    68,    -1,    70,    71,    72,    73,    -1,    -1,    76,
2015     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2016     -1,    -1,    -1,    -1,    -1,    -1,    93,    -1,    95,    -1,
2017     -1,    -1,    99,    -1,    -1,   102,   103,   104,   105,    -1,
2018     -1,   108,   109,    44,    45,    46,    -1,    48,    49,    50,
2019     51,    -1,    -1,    54,    -1,    -1,    -1,    58,    59,    -1,
2020     -1,    -1,    -1,    -1,    65,    66,    -1,    68,    -1,    70,
2021     71,    72,    73,    -1,     1,    76,     3,     4,    -1,    -1,
2022     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    -1,    -1,
2023     -1,    -1,    93,    -1,    95,    -1,    -1,    -1,    99,    -1,
2024     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    -1,
2025     -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    45,    46,
2026     -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,    -1,    -1,
2027     -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2028     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2029     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2030     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    95,    96,
2031     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2032     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2033      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2034     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2035     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2036     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2037     -1,    93,    -1,    95,    45,    46,    -1,    -1,    -1,    50,
2038    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2039     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2040     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2041     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2042     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    99,    -1,
2043     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2044     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2045     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2046     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2047     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2048     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2049     45,    46,    98,    -1,    -1,    50,   102,   103,   104,   105,
2050     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2051     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2052     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2053     85,    86,    -1,    88,    89,    90,    -1,    -1,    93,    -1,
2054     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2055    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2056     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2057     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2058     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2059     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2060     90,    -1,    -1,    93,    -1,    -1,    45,    46,    98,    -1,
2061     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2062     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2063      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2064     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2065     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2066     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2067    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2068      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2069     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2070     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2071     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2072     -1,    -1,    45,    46,    -1,    99,    -1,    50,   102,   103,
2073    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2074     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2075     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2076     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2077     93,    -1,    -1,    -1,    -1,    98,    -1,    -1,    -1,   102,
2078    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2079     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2080     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2081     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2082     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2083     -1,    89,    90,    -1,    -1,    93,    94,    -1,    45,    46,
2084     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2085    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2086     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2087     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2088     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2089     -1,    98,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2090     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2091      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2092     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2093     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2094     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2095     -1,    93,    94,    -1,    45,    46,    -1,    -1,    -1,    50,
2096    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2097     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2098     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2099     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2100     -1,    -1,    93,    94,    -1,    -1,    -1,    -1,    -1,    -1,
2101     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2102     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2103     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2104     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2105     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2106     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2107     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2108     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2109     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2110     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2111     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2112     -1,    -1,    -1,    -1,    99,    -1,    -1,   102,   103,   104,
2113    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2114     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2115     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2116     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2117     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2118     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2119     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2120     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2121      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2122     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2123     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2124     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2125    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2126      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2127     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2128     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2129     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2130     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2131    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2132     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2133     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2134     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2135     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2136    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2137     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2138     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2139     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2140     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2141     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2142     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2143    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2144     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2145     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2146     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2147     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2148     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2149      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2150     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2151     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2152     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2153     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2154    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2155     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2156     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2157     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2158     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2159     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2160     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2161     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2162     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2163     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2164     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2165     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2166     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2167     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2168     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2169     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2170     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2171    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2172     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2173     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2174     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2175     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2176     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2177     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2178     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2179      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2180     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2181     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2182     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2183    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2184      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2185     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2186     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2187     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2188     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2189    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2190     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2191     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2192     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2193     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2194    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2195     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2196     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2197     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2198     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2199     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2200     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2201    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2202     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2203     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2204     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2205     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2206     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2207      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2208     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2209     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2210     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2211     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2212    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2213     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2214     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2215     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2216     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2217     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2218     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2219     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2220     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2221     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2222     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2223     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2224     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2225     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2226     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2227     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2228     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2229    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2230     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2231     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2232     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2233     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2234     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2235     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2236     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2237      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2238     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2239     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2240     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2241    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2242      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2243     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2244     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2245     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2246     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2247    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2248     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2249     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2250     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2251     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2252    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2253     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2254     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2255     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2256     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2257     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2258     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2259    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2260     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2261     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2262     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2263     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2264     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2265      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2266     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2267     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2268     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2269     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2270    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2271     -1,    -1,    -1,    -1,    65,     1,    -1,     3,     4,    -1,
2272     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2273     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2274     -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2275     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    45,
2276     46,    -1,    -1,    -1,    50,    -1,     1,    -1,     3,     4,
2277     -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,    65,
2278     -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2279     76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,
2280     86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,
2281     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2282     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2283     65,     1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2284     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2285     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    -1,
2286     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2287    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2288     50,    -1,     1,    -1,     3,     4,    -1,    -1,    -1,    59,
2289     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2290     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2291     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2292     90,    -1,    -1,    93,    -1,    -1,    45,    46,    -1,    -1,
2293     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2294     59,    -1,    -1,    -1,    -1,    -1,    65,     1,    -1,     3,
2295      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2296     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2297     89,    90,    -1,    -1,    93,    -1,    -1,    -1,    -1,    -1,
2298     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2299    109,    45,    46,    -1,    -1,    -1,    50,    -1,     1,    -1,
2300      3,     4,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2301     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2302     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2303     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2304     -1,    -1,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2305    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2306     -1,    -1,    65,     1,    -1,     3,     4,    -1,    -1,    72,
2307     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2308     -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,
2309     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2310    103,   104,   105,    -1,    -1,   108,   109,    45,    46,    -1,
2311     -1,    -1,    50,    -1,     1,    -1,     3,     4,    -1,    -1,
2312     -1,    59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,
2313     -1,    -1,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,
2314     -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,
2315     -1,    89,    90,    -1,    -1,    93,    -1,    -1,    45,    46,
2316     -1,    -1,    -1,    50,   102,   103,   104,   105,    -1,    -1,
2317    108,   109,    59,    -1,    -1,    -1,    -1,    -1,    65,     1,
2318     -1,     3,     4,    -1,    -1,    72,    -1,    -1,    -1,    76,
2319     -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,    85,    86,
2320     -1,    -1,    89,    90,    -1,    -1,    93,    -1,    -1,    -1,
2321     -1,    -1,    -1,    -1,    -1,   102,   103,   104,   105,    -1,
2322     -1,   108,   109,    45,    46,    -1,    -1,    -1,    50,    -1,
2323      1,    -1,     3,     4,    -1,    -1,    -1,    59,    -1,    -1,
2324     -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,
2325     72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,
2326     82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,    -1,
2327     -1,    93,    -1,    -1,    45,    46,    -1,    -1,    -1,    50,
2328    102,   103,   104,   105,    -1,    -1,   108,   109,    59,    -1,
2329     -1,    -1,    -1,    -1,    65,    -1,     1,    -1,    -1,    -1,
2330     -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,
2331     -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,    90,
2332     -1,     1,    93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
2333     -1,   102,   103,   104,   105,    -1,    -1,   108,   109,    44,
2334     45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,    -1,
2335     -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,    -1,
2336     65,    -1,    -1,     1,    -1,    45,    46,    72,    -1,    -1,
2337     50,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    59,
2338     85,    86,    -1,    -1,    -1,    65,    -1,    -1,    93,    -1,
2339      3,     4,    72,    -1,    99,    -1,    76,   102,   103,   104,
2340    105,    -1,    82,   108,   109,    85,    86,    45,    46,    -1,
2341     -1,    -1,    50,    93,    94,    -1,    -1,    -1,    -1,    -1,
2342     -1,    59,   102,   103,   104,   105,    -1,    65,   108,   109,
2343      1,    -1,    45,    46,    72,    -1,    -1,    50,    76,    -1,
2344     -1,    -1,    -1,    -1,    82,    -1,    59,    85,    86,    -1,
2345     -1,    -1,    65,    -1,    -1,    93,    94,     3,     4,    72,
2346     -1,    -1,    -1,    76,   102,   103,   104,   105,    -1,    82,
2347    108,   109,    85,    86,    45,    46,    89,    90,    -1,    50,
2348     93,    -1,    95,    96,    -1,    -1,    -1,    -1,    59,   102,
2349    103,   104,   105,    -1,    65,   108,   109,    -1,    -1,    45,
2350     46,    72,    -1,    -1,    50,    76,    -1,    -1,     3,     4,
2351     -1,    82,    -1,    59,    85,    86,    -1,    -1,    -1,    65,
2352     -1,    -1,    93,    -1,    -1,    -1,    72,    -1,    -1,    -1,
2353     76,   102,   103,   104,   105,    -1,    82,   108,   109,    85,
2354     86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,    -1,
2355     45,    46,    -1,    -1,    -1,    50,   102,   103,   104,   105,
2356     -1,    -1,   108,   109,    59,    -1,    -1,    -1,    -1,    -1,
2357     65,    -1,    -1,     3,     4,    -1,    -1,    72,    -1,    -1,
2358     -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,    -1,
2359     85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,    94,
2360     -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,   103,   104,
2361    105,    -1,    -1,   108,   109,    45,    46,    -1,    -1,    -1,
2362     50,    -1,    -1,    -1,     3,     4,    -1,    -1,    -1,    59,
2363     -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
2364     -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,    -1,
2365     -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,    89,
2366     90,    -1,    -1,    93,    94,    -1,    45,    46,    -1,    -1,
2367     -1,    50,   102,   103,   104,   105,    -1,    -1,   108,   109,
2368     59,    -1,    -1,    -1,    -1,    -1,    65,    -1,    -1,     3,
2369      4,    -1,    -1,    72,    -1,    -1,    -1,    76,    -1,    -1,
2370     -1,    -1,    -1,    82,    -1,    -1,    85,    86,    -1,    -1,
2371     89,    90,    -1,    -1,    93,    94,    -1,    -1,    -1,    -1,
2372     -1,    -1,    -1,   102,   103,   104,   105,    -1,    -1,   108,
2373    109,    45,    46,    -1,    -1,    -1,    50,    -1,    -1,    -1,
2374     -1,    -1,    -1,    -1,    -1,    59,    -1,    -1,    -1,    -1,
2375     -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,    -1,
2376     -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,    -1,
2377     -1,    85,    86,    -1,    -1,    89,    90,    -1,    -1,    93,
2378     -1,    44,    45,    46,    -1,    -1,    -1,    50,   102,   103,
2379    104,   105,    -1,    -1,   108,   109,    59,    -1,    -1,    -1,
2380     -1,    -1,    65,    -1,    -1,    -1,    -1,    -1,    -1,    72,
2381     -1,    -1,    -1,    76,    -1,    -1,    -1,    -1,    -1,    82,
2382     -1,    -1,    85,    86,    -1,    -1,    -1,    -1,    -1,    -1,
2383     93,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,   102,
2384    103,   104,   105,    -1,    -1,   108,   109
2385 };
2386 #define YYPURE 1
2387
2388 /* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
2389 #line 3 "/usr/lib/bison.simple"
2390 /* This file comes from bison-1.28.  */
2391
2392 /* Skeleton output parser for bison,
2393    Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
2394
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.
2399
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.
2404
2405    You should have received a copy of the GNU General Public License
2406    along with this program; if not, write to the Free Software
2407    Foundation, Inc., 59 Temple Place - Suite 330,
2408    Boston, MA 02111-1307, USA.  */
2409
2410 /* As a special exception, when this file is copied by Bison into a
2411    Bison output file, you may use that output file without restriction.
2412    This special exception was added by the Free Software Foundation
2413    in version 1.24 of Bison.  */
2414
2415 /* This is the parser code that is written into each bison parser
2416   when the %semantic_parser declaration is not specified in the grammar.
2417   It was written by Richard Stallman by simplifying the hairy parser
2418   used when %semantic_parser is specified.  */
2419
2420 #ifndef YYSTACK_USE_ALLOCA
2421 #ifdef alloca
2422 #define YYSTACK_USE_ALLOCA
2423 #else /* alloca not defined */
2424 #ifdef __GNUC__
2425 #define YYSTACK_USE_ALLOCA
2426 #define alloca __builtin_alloca
2427 #else /* not GNU C.  */
2428 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
2429 #define YYSTACK_USE_ALLOCA
2430 #include <alloca.h>
2431 #else /* not sparc */
2432 /* We think this test detects Watcom and Microsoft C.  */
2433 /* This used to test MSDOS, but that is a bad idea
2434    since that symbol is in the user namespace.  */
2435 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
2436 #if 0 /* No need for malloc.h, which pollutes the namespace;
2437          instead, just don't use alloca.  */
2438 #include <malloc.h>
2439 #endif
2440 #else /* not MSDOS, or __TURBOC__ */
2441 #if defined(_AIX)
2442 /* I don't know what this was needed for, but it pollutes the namespace.
2443    So I turned it off.   rms, 2 May 1997.  */
2444 /* #include <malloc.h>  */
2445  #pragma alloca
2446 #define YYSTACK_USE_ALLOCA
2447 #else /* not MSDOS, or __TURBOC__, or _AIX */
2448 #if 0
2449 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
2450                  and on HPUX 10.  Eventually we can turn this on.  */
2451 #define YYSTACK_USE_ALLOCA
2452 #define alloca __builtin_alloca
2453 #endif /* __hpux */
2454 #endif
2455 #endif /* not _AIX */
2456 #endif /* not MSDOS, or __TURBOC__ */
2457 #endif /* not sparc */
2458 #endif /* not GNU C */
2459 #endif /* alloca not defined */
2460 #endif /* YYSTACK_USE_ALLOCA not defined */
2461
2462 #ifdef YYSTACK_USE_ALLOCA
2463 #define YYSTACK_ALLOC alloca
2464 #else
2465 #define YYSTACK_ALLOC malloc
2466 #endif
2467
2468 /* Note: there must be only one dollar sign in this file.
2469    It is replaced by the list of actions, each action
2470    as one case of the switch.  */
2471
2472 #define yyerrok         (yyerrstatus = 0)
2473 #define yyclearin       (yychar = YYEMPTY)
2474 #define YYEMPTY         -2
2475 #define YYEOF           0
2476 #define YYACCEPT        goto yyacceptlab
2477 #define YYABORT         goto yyabortlab
2478 #define YYERROR         goto yyerrlab1
2479 /* Like YYERROR except do call yyerror.
2480    This remains here temporarily to ease the
2481    transition to the new meaning of YYERROR, for GCC.
2482    Once GCC version 2 has supplanted version 1, this can go.  */
2483 #define YYFAIL          goto yyerrlab
2484 #define YYRECOVERING()  (!!yyerrstatus)
2485 #define YYBACKUP(token, value) \
2486 do                                                              \
2487   if (yychar == YYEMPTY && yylen == 1)                          \
2488     { yychar = (token), yylval = (value);                       \
2489       yychar1 = YYTRANSLATE (yychar);                           \
2490       YYPOPSTACK;                                               \
2491       goto yybackup;                                            \
2492     }                                                           \
2493   else                                                          \
2494     { yyerror ("syntax error: cannot back up"); YYERROR; }      \
2495 while (0)
2496
2497 #define YYTERROR        1
2498 #define YYERRCODE       256
2499
2500 #ifndef YYPURE
2501 #define YYLEX           yylex()
2502 #endif
2503
2504 #ifdef YYPURE
2505 #ifdef YYLSP_NEEDED
2506 #ifdef YYLEX_PARAM
2507 #define YYLEX           yylex(&yylval, &yylloc, YYLEX_PARAM)
2508 #else
2509 #define YYLEX           yylex(&yylval, &yylloc)
2510 #endif
2511 #else /* not YYLSP_NEEDED */
2512 #ifdef YYLEX_PARAM
2513 #define YYLEX           yylex(&yylval, YYLEX_PARAM)
2514 #else
2515 #define YYLEX           yylex(&yylval)
2516 #endif
2517 #endif /* not YYLSP_NEEDED */
2518 #endif
2519
2520 /* If nonreentrant, generate the variables here */
2521
2522 #ifndef YYPURE
2523
2524 int     yychar;                 /*  the lookahead symbol                */
2525 YYSTYPE yylval;                 /*  the semantic value of the           */
2526                                 /*  lookahead symbol                    */
2527
2528 #ifdef YYLSP_NEEDED
2529 YYLTYPE yylloc;                 /*  location data for the lookahead     */
2530                                 /*  symbol                              */
2531 #endif
2532
2533 int yynerrs;                    /*  number of parse errors so far       */
2534 #endif  /* not YYPURE */
2535
2536 #if YYDEBUG != 0
2537 int yydebug;                    /*  nonzero means print parse trace     */
2538 /* Since this is uninitialized, it does not stop multiple parsers
2539    from coexisting.  */
2540 #endif
2541
2542 /*  YYINITDEPTH indicates the initial size of the parser's stacks       */
2543
2544 #ifndef YYINITDEPTH
2545 #define YYINITDEPTH 200
2546 #endif
2547
2548 /*  YYMAXDEPTH is the maximum size the stacks can grow to
2549     (effective only if the built-in stack extension method is used).  */
2550
2551 #if YYMAXDEPTH == 0
2552 #undef YYMAXDEPTH
2553 #endif
2554
2555 #ifndef YYMAXDEPTH
2556 #define YYMAXDEPTH 10000
2557 #endif
2558 \f
2559 /* Define __yy_memcpy.  Note that the size argument
2560    should be passed with type unsigned int, because that is what the non-GCC
2561    definitions require.  With GCC, __builtin_memcpy takes an arg
2562    of type size_t, but it can handle unsigned int.  */
2563
2564 #if __GNUC__ > 1                /* GNU C and GNU C++ define this.  */
2565 #define __yy_memcpy(TO,FROM,COUNT)      __builtin_memcpy(TO,FROM,COUNT)
2566 #else                           /* not GNU C or C++ */
2567 #ifndef __cplusplus
2568
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 (to, from, count)
2573      char *to;
2574      char *from;
2575      unsigned int count;
2576 {
2577   register char *f = from;
2578   register char *t = to;
2579   register int i = count;
2580
2581   while (i-- > 0)
2582     *t++ = *f++;
2583 }
2584
2585 #else /* __cplusplus */
2586
2587 /* This is the most reliable way to avoid incompatibilities
2588    in available built-in functions on various systems.  */
2589 static void
2590 __yy_memcpy (char *to, char *from, unsigned int count)
2591 {
2592   register char *t = to;
2593   register char *f = from;
2594   register int i = count;
2595
2596   while (i-- > 0)
2597     *t++ = *f++;
2598 }
2599
2600 #endif
2601 #endif
2602 \f
2603 #line 217 "/usr/lib/bison.simple"
2604
2605 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
2606    into yyparse.  The argument should have type void *.
2607    It should actually point to an object.
2608    Grammar actions can access the variable by casting it
2609    to the proper pointer type.  */
2610
2611 #ifdef YYPARSE_PARAM
2612 #ifdef __cplusplus
2613 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
2614 #define YYPARSE_PARAM_DECL
2615 #else /* not __cplusplus */
2616 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
2617 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
2618 #endif /* not __cplusplus */
2619 #else /* not YYPARSE_PARAM */
2620 #define YYPARSE_PARAM_ARG
2621 #define YYPARSE_PARAM_DECL
2622 #endif /* not YYPARSE_PARAM */
2623
2624 /* Prevent warning if -Wstrict-prototypes.  */
2625 #ifdef __GNUC__
2626 #ifdef YYPARSE_PARAM
2627 int yyparse (void *);
2628 #else
2629 int yyparse (void);
2630 #endif
2631 #endif
2632
2633 int
2634 yyparse(YYPARSE_PARAM_ARG)
2635      YYPARSE_PARAM_DECL
2636 {
2637   register int yystate;
2638   register int yyn;
2639   register short *yyssp;
2640   register YYSTYPE *yyvsp;
2641   int yyerrstatus;      /*  number of tokens to shift before error messages enabled */
2642   int yychar1 = 0;              /*  lookahead token as an internal (translated) token number */
2643
2644   short yyssa[YYINITDEPTH];     /*  the state stack                     */
2645   YYSTYPE yyvsa[YYINITDEPTH];   /*  the semantic value stack            */
2646
2647   short *yyss = yyssa;          /*  refer to the stacks thru separate pointers */
2648   YYSTYPE *yyvs = yyvsa;        /*  to allow yyoverflow to reallocate them elsewhere */
2649
2650 #ifdef YYLSP_NEEDED
2651   YYLTYPE yylsa[YYINITDEPTH];   /*  the location stack                  */
2652   YYLTYPE *yyls = yylsa;
2653   YYLTYPE *yylsp;
2654
2655 #define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
2656 #else
2657 #define YYPOPSTACK   (yyvsp--, yyssp--)
2658 #endif
2659
2660   int yystacksize = YYINITDEPTH;
2661   int yyfree_stacks = 0;
2662
2663 #ifdef YYPURE
2664   int yychar;
2665   YYSTYPE yylval;
2666   int yynerrs;
2667 #ifdef YYLSP_NEEDED
2668   YYLTYPE yylloc;
2669 #endif
2670 #endif
2671
2672   YYSTYPE yyval;                /*  the variable used to return         */
2673                                 /*  semantic values from the action     */
2674                                 /*  routines                            */
2675
2676   int yylen;
2677
2678 #if YYDEBUG != 0
2679   if (yydebug)
2680     fprintf(stderr, "Starting parse\n");
2681 #endif
2682
2683   yystate = 0;
2684   yyerrstatus = 0;
2685   yynerrs = 0;
2686   yychar = YYEMPTY;             /* Cause a token to be read.  */
2687
2688   /* Initialize stack pointers.
2689      Waste one element of value and location stack
2690      so that they stay on the same level as the state stack.
2691      The wasted elements are never initialized.  */
2692
2693   yyssp = yyss - 1;
2694   yyvsp = yyvs;
2695 #ifdef YYLSP_NEEDED
2696   yylsp = yyls;
2697 #endif
2698
2699 /* Push a new state, which is found in  yystate  .  */
2700 /* In all cases, when you get here, the value and location stacks
2701    have just been pushed. so pushing a state here evens the stacks.  */
2702 yynewstate:
2703
2704   *++yyssp = yystate;
2705
2706   if (yyssp >= yyss + yystacksize - 1)
2707     {
2708       /* Give user a chance to reallocate the stack */
2709       /* Use copies of these so that the &'s don't force the real ones into memory. */
2710       YYSTYPE *yyvs1 = yyvs;
2711       short *yyss1 = yyss;
2712 #ifdef YYLSP_NEEDED
2713       YYLTYPE *yyls1 = yyls;
2714 #endif
2715
2716       /* Get the current used size of the three stacks, in elements.  */
2717       int size = yyssp - yyss + 1;
2718
2719 #ifdef yyoverflow
2720       /* Each stack pointer address is followed by the size of
2721          the data in use in that stack, in bytes.  */
2722 #ifdef YYLSP_NEEDED
2723       /* This used to be a conditional around just the two extra args,
2724          but that might be undefined if yyoverflow is a macro.  */
2725       yyoverflow("parser stack overflow",
2726                  &yyss1, size * sizeof (*yyssp),
2727                  &yyvs1, size * sizeof (*yyvsp),
2728                  &yyls1, size * sizeof (*yylsp),
2729                  &yystacksize);
2730 #else
2731       yyoverflow("parser stack overflow",
2732                  &yyss1, size * sizeof (*yyssp),
2733                  &yyvs1, size * sizeof (*yyvsp),
2734                  &yystacksize);
2735 #endif
2736
2737       yyss = yyss1; yyvs = yyvs1;
2738 #ifdef YYLSP_NEEDED
2739       yyls = yyls1;
2740 #endif
2741 #else /* no yyoverflow */
2742       /* Extend the stack our own way.  */
2743       if (yystacksize >= YYMAXDEPTH)
2744         {
2745           yyerror("parser stack overflow");
2746           if (yyfree_stacks)
2747             {
2748               free (yyss);
2749               free (yyvs);
2750 #ifdef YYLSP_NEEDED
2751               free (yyls);
2752 #endif
2753             }
2754           return 2;
2755         }
2756       yystacksize *= 2;
2757       if (yystacksize > YYMAXDEPTH)
2758         yystacksize = YYMAXDEPTH;
2759 #ifndef YYSTACK_USE_ALLOCA
2760       yyfree_stacks = 1;
2761 #endif
2762       yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
2763       __yy_memcpy ((char *)yyss, (char *)yyss1,
2764                    size * (unsigned int) sizeof (*yyssp));
2765       yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
2766       __yy_memcpy ((char *)yyvs, (char *)yyvs1,
2767                    size * (unsigned int) sizeof (*yyvsp));
2768 #ifdef YYLSP_NEEDED
2769       yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
2770       __yy_memcpy ((char *)yyls, (char *)yyls1,
2771                    size * (unsigned int) sizeof (*yylsp));
2772 #endif
2773 #endif /* no yyoverflow */
2774
2775       yyssp = yyss + size - 1;
2776       yyvsp = yyvs + size - 1;
2777 #ifdef YYLSP_NEEDED
2778       yylsp = yyls + size - 1;
2779 #endif
2780
2781 #if YYDEBUG != 0
2782       if (yydebug)
2783         fprintf(stderr, "Stack size increased to %d\n", yystacksize);
2784 #endif
2785
2786       if (yyssp >= yyss + yystacksize - 1)
2787         YYABORT;
2788     }
2789
2790 #if YYDEBUG != 0
2791   if (yydebug)
2792     fprintf(stderr, "Entering state %d\n", yystate);
2793 #endif
2794
2795   goto yybackup;
2796  yybackup:
2797
2798 /* Do appropriate processing given the current state.  */
2799 /* Read a lookahead token if we need one and don't already have one.  */
2800 /* yyresume: */
2801
2802   /* First try to decide what to do without reference to lookahead token.  */
2803
2804   yyn = yypact[yystate];
2805   if (yyn == YYFLAG)
2806     goto yydefault;
2807
2808   /* Not known => get a lookahead token if don't already have one.  */
2809
2810   /* yychar is either YYEMPTY or YYEOF
2811      or a valid token in external form.  */
2812
2813   if (yychar == YYEMPTY)
2814     {
2815 #if YYDEBUG != 0
2816       if (yydebug)
2817         fprintf(stderr, "Reading a token: ");
2818 #endif
2819       yychar = YYLEX;
2820     }
2821
2822   /* Convert token to internal form (in yychar1) for indexing tables with */
2823
2824   if (yychar <= 0)              /* This means end of input. */
2825     {
2826       yychar1 = 0;
2827       yychar = YYEOF;           /* Don't call YYLEX any more */
2828
2829 #if YYDEBUG != 0
2830       if (yydebug)
2831         fprintf(stderr, "Now at end of input.\n");
2832 #endif
2833     }
2834   else
2835     {
2836       yychar1 = YYTRANSLATE(yychar);
2837
2838 #if YYDEBUG != 0
2839       if (yydebug)
2840         {
2841           fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
2842           /* Give the individual parser a way to print the precise meaning
2843              of a token, for further debugging info.  */
2844 #ifdef YYPRINT
2845           YYPRINT (stderr, yychar, yylval);
2846 #endif
2847           fprintf (stderr, ")\n");
2848         }
2849 #endif
2850     }
2851
2852   yyn += yychar1;
2853   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
2854     goto yydefault;
2855
2856   yyn = yytable[yyn];
2857
2858   /* yyn is what to do for this token type in this state.
2859      Negative => reduce, -yyn is rule number.
2860      Positive => shift, yyn is new state.
2861        New state is final state => don't bother to shift,
2862        just return success.
2863      0, or most negative number => error.  */
2864
2865   if (yyn < 0)
2866     {
2867       if (yyn == YYFLAG)
2868         goto yyerrlab;
2869       yyn = -yyn;
2870       goto yyreduce;
2871     }
2872   else if (yyn == 0)
2873     goto yyerrlab;
2874
2875   if (yyn == YYFINAL)
2876     YYACCEPT;
2877
2878   /* Shift the lookahead token.  */
2879
2880 #if YYDEBUG != 0
2881   if (yydebug)
2882     fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
2883 #endif
2884
2885   /* Discard the token being shifted unless it is eof.  */
2886   if (yychar != YYEOF)
2887     yychar = YYEMPTY;
2888
2889   *++yyvsp = yylval;
2890 #ifdef YYLSP_NEEDED
2891   *++yylsp = yylloc;
2892 #endif
2893
2894   /* count tokens shifted since error; after three, turn off error status.  */
2895   if (yyerrstatus) yyerrstatus--;
2896
2897   yystate = yyn;
2898   goto yynewstate;
2899
2900 /* Do the default action for the current state.  */
2901 yydefault:
2902
2903   yyn = yydefact[yystate];
2904   if (yyn == 0)
2905     goto yyerrlab;
2906
2907 /* Do a reduction.  yyn is the number of a rule to reduce with.  */
2908 yyreduce:
2909   yylen = yyr2[yyn];
2910   if (yylen > 0)
2911     yyval = yyvsp[1-yylen]; /* implement default value of the action */
2912
2913 #if YYDEBUG != 0
2914   if (yydebug)
2915     {
2916       int i;
2917
2918       fprintf (stderr, "Reducing via rule %d (line %d), ",
2919                yyn, yyrline[yyn]);
2920
2921       /* Print the symbols being reduced, and their result.  */
2922       for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
2923         fprintf (stderr, "%s ", yytname[yyrhs[i]]);
2924       fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
2925     }
2926 #endif
2927
2928
2929   switch (yyn) {
2930
2931 case 1:
2932 #line 575 "./parse.y"
2933 {;
2934     break;}
2935 case 18:
2936 #line 619 "./parse.y"
2937
2938                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
2939                   CLASS_LOADED_P (yyval.node) = 1;
2940                 ;
2941     break;}
2942 case 19:
2943 #line 624 "./parse.y"
2944 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2945     break;}
2946 case 20:
2947 #line 626 "./parse.y"
2948 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
2949     break;}
2950 case 21:
2951 #line 628 "./parse.y"
2952 {RULE ("']' expected"); RECOVER;;
2953     break;}
2954 case 22:
2955 #line 630 "./parse.y"
2956 {RULE ("']' expected"); RECOVER;;
2957     break;}
2958 case 26:
2959 #line 645 "./parse.y"
2960 { yyval.node = make_qualified_name (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
2961     break;}
2962 case 28:
2963 #line 654 "./parse.y"
2964 {yyval.node = NULL;;
2965     break;}
2966 case 36:
2967 #line 666 "./parse.y"
2968 {
2969                   yyval.node = NULL;
2970                 ;
2971     break;}
2972 case 37:
2973 #line 670 "./parse.y"
2974 {
2975                   yyval.node = NULL;
2976                 ;
2977     break;}
2978 case 40:
2979 #line 682 "./parse.y"
2980
2981                   ctxp->package = EXPR_WFL_NODE (yyvsp[-1].node);
2982                   package_list = tree_cons (ctxp->package, NULL, package_list);
2983                 ;
2984     break;}
2985 case 41:
2986 #line 687 "./parse.y"
2987 {yyerror ("Missing name"); RECOVER;;
2988     break;}
2989 case 42:
2990 #line 689 "./parse.y"
2991 {yyerror ("';' expected"); RECOVER;;
2992     break;}
2993 case 45:
2994 #line 699 "./parse.y"
2995 {
2996                   tree name = EXPR_WFL_NODE (yyvsp[-1].node), node, last_name;
2997                   int   i = IDENTIFIER_LENGTH (name)-1;
2998                   const char *last = &IDENTIFIER_POINTER (name)[i];
2999                   while (last != IDENTIFIER_POINTER (name))
3000                     {
3001                       if (last [0] == '.')
3002                         break;
3003                       last--;
3004                     }
3005                   last_name = get_identifier (++last);
3006                   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (last_name))
3007                     {
3008                       tree err = find_name_in_single_imports (last_name);
3009                       if (err && err != name)
3010                         parse_error_context
3011                           (yyvsp[-1].node, "Ambiguous class: `%s' and `%s'",
3012                            IDENTIFIER_POINTER (name), 
3013                            IDENTIFIER_POINTER (err));
3014                       else
3015                         REGISTER_IMPORT (yyvsp[-1].node, last_name)
3016                     }
3017                   else
3018                     REGISTER_IMPORT (yyvsp[-1].node, last_name);
3019                 ;
3020     break;}
3021 case 46:
3022 #line 725 "./parse.y"
3023 {yyerror ("Missing name"); RECOVER;;
3024     break;}
3025 case 47:
3026 #line 727 "./parse.y"
3027 {yyerror ("';' expected"); RECOVER;;
3028     break;}
3029 case 48:
3030 #line 732 "./parse.y"
3031 {
3032                   tree name = EXPR_WFL_NODE (yyvsp[-3].node);
3033                   /* Don't import java.lang.* twice. */
3034                   if (name != java_lang_id)
3035                     {
3036                       tree node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3037                       read_import_dir (yyvsp[-3].node);
3038                       TREE_CHAIN (node) = ctxp->import_demand_list;
3039                       ctxp->import_demand_list = node;
3040                     }
3041                 ;
3042     break;}
3043 case 49:
3044 #line 744 "./parse.y"
3045 {yyerror ("'*' expected"); RECOVER;;
3046     break;}
3047 case 50:
3048 #line 746 "./parse.y"
3049 {yyerror ("';' expected"); RECOVER;;
3050     break;}
3051 case 51:
3052 #line 751 "./parse.y"
3053 { end_class_declaration (0); ;
3054     break;}
3055 case 52:
3056 #line 753 "./parse.y"
3057 { end_class_declaration (0); ;
3058     break;}
3059 case 53:
3060 #line 755 "./parse.y"
3061 { yyval.node = NULL; ;
3062     break;}
3063 case 54:
3064 #line 757 "./parse.y"
3065 {
3066                   YYERROR_NOW;
3067                   yyerror ("Class or interface declaration expected");
3068                 ;
3069     break;}
3070 case 55:
3071 #line 768 "./parse.y"
3072 {
3073                   yyval.value = (1 << yyvsp[0].value);
3074                 ;
3075     break;}
3076 case 56:
3077 #line 772 "./parse.y"
3078 {
3079                   int acc = (1 << yyvsp[0].value);
3080                   if (yyval.value & acc)
3081                     parse_error_context 
3082                       (ctxp->modifier_ctx [yyvsp[0].value], "Modifier `%s' declared twice",
3083                        java_accstring_lookup (acc));
3084                   else
3085                     {
3086                       yyval.value |= acc;
3087                     }
3088                 ;
3089     break;}
3090 case 57:
3091 #line 788 "./parse.y"
3092 { create_class (yyvsp[-4].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3093     break;}
3094 case 59:
3095 #line 791 "./parse.y"
3096 { create_class (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3097     break;}
3098 case 61:
3099 #line 794 "./parse.y"
3100 {yyerror ("Missing class name"); RECOVER;;
3101     break;}
3102 case 62:
3103 #line 796 "./parse.y"
3104 {yyerror ("Missing class name"); RECOVER;;
3105     break;}
3106 case 63:
3107 #line 798 "./parse.y"
3108 {
3109                   if (!ctxp->class_err) yyerror ("'{' expected"); 
3110                   DRECOVER(class1);
3111                 ;
3112     break;}
3113 case 64:
3114 #line 803 "./parse.y"
3115 {if (!ctxp->class_err) yyerror ("'{' expected"); RECOVER;;
3116     break;}
3117 case 65:
3118 #line 807 "./parse.y"
3119 { yyval.node = NULL; ;
3120     break;}
3121 case 66:
3122 #line 809 "./parse.y"
3123 { yyval.node = yyvsp[0].node; ;
3124     break;}
3125 case 67:
3126 #line 811 "./parse.y"
3127 {yyerror ("'{' expected"); ctxp->class_err=1;;
3128     break;}
3129 case 68:
3130 #line 813 "./parse.y"
3131 {yyerror ("Missing super class name"); ctxp->class_err=1;;
3132     break;}
3133 case 69:
3134 #line 817 "./parse.y"
3135 { yyval.node = NULL_TREE; ;
3136     break;}
3137 case 70:
3138 #line 819 "./parse.y"
3139 { yyval.node = yyvsp[0].node; ;
3140     break;}
3141 case 71:
3142 #line 821 "./parse.y"
3143 {
3144                   ctxp->class_err=1;
3145                   yyerror ("Missing interface name"); 
3146                 ;
3147     break;}
3148 case 72:
3149 #line 829 "./parse.y"
3150
3151                   ctxp->interface_number = 1;
3152                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3153                 ;
3154     break;}
3155 case 73:
3156 #line 834 "./parse.y"
3157
3158                   ctxp->interface_number++;
3159                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3160                 ;
3161     break;}
3162 case 74:
3163 #line 839 "./parse.y"
3164 {yyerror ("Missing interface name"); RECOVER;;
3165     break;}
3166 case 75:
3167 #line 844 "./parse.y"
3168
3169                   /* Store the location of the `}' when doing xrefs */
3170                   if (flag_emit_xref)
3171                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3172                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3173                   yyval.node = GET_CPC ();
3174                 ;
3175     break;}
3176 case 76:
3177 #line 852 "./parse.y"
3178
3179                   /* Store the location of the `}' when doing xrefs */
3180                   if (flag_emit_xref)
3181                     DECL_END_SOURCE_LINE (GET_CPC ()) = 
3182                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3183                   yyval.node = GET_CPC ();
3184                 ;
3185     break;}
3186 case 82:
3187 #line 871 "./parse.y"
3188 {
3189                   TREE_CHAIN (yyvsp[0].node) = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
3190                   SET_CPC_INSTANCE_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3191                 ;
3192     break;}
3193 case 84:
3194 #line 880 "./parse.y"
3195 { yyval.node = yyvsp[-1].node; ;
3196     break;}
3197 case 86:
3198 #line 883 "./parse.y"
3199 { end_class_declaration (1); ;
3200     break;}
3201 case 87:
3202 #line 885 "./parse.y"
3203 { end_class_declaration (1); ;
3204     break;}
3205 case 88:
3206 #line 891 "./parse.y"
3207 { register_fields (0, yyvsp[-2].node, yyvsp[-1].node); ;
3208     break;}
3209 case 89:
3210 #line 893 "./parse.y"
3211 {
3212                   check_modifiers 
3213                     ("Illegal modifier `%s' for field declaration",
3214                      yyvsp[-3].value, FIELD_MODIFIERS);
3215                   check_modifiers_consistency (yyvsp[-3].value);
3216                   register_fields (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node);
3217                 ;
3218     break;}
3219 case 91:
3220 #line 906 "./parse.y"
3221 { yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node); ;
3222     break;}
3223 case 92:
3224 #line 908 "./parse.y"
3225 {yyerror ("Missing term"); RECOVER;;
3226     break;}
3227 case 93:
3228 #line 913 "./parse.y"
3229 { yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE); ;
3230     break;}
3231 case 94:
3232 #line 915 "./parse.y"
3233
3234                   if (java_error_count)
3235                     yyvsp[0].node = NULL_TREE;
3236                   yyval.node = build_tree_list 
3237                     (yyvsp[-2].node, build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node));
3238                 ;
3239     break;}
3240 case 95:
3241 #line 922 "./parse.y"
3242 {
3243                   yyerror ("Missing variable initializer");
3244                   yyval.node = build_tree_list (yyvsp[-2].node, NULL_TREE);
3245                   RECOVER;
3246                 ;
3247     break;}
3248 case 96:
3249 #line 928 "./parse.y"
3250 {
3251                   yyerror ("';' expected");
3252                   yyval.node = build_tree_list (yyvsp[-3].node, NULL_TREE);
3253                   RECOVER;
3254                 ;
3255     break;}
3256 case 98:
3257 #line 938 "./parse.y"
3258 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
3259     break;}
3260 case 99:
3261 #line 940 "./parse.y"
3262 {yyerror ("Invalid declaration"); DRECOVER(vdi);;
3263     break;}
3264 case 100:
3265 #line 942 "./parse.y"
3266 {yyerror ("']' expected"); DRECOVER(vdi);;
3267     break;}
3268 case 101:
3269 #line 944 "./parse.y"
3270 {yyerror ("Unbalanced ']'"); DRECOVER(vdi);;
3271     break;}
3272 case 104:
3273 #line 955 "./parse.y"
3274 {
3275                   current_function_decl = yyvsp[0].node;
3276                   if (current_function_decl
3277                       && TREE_CODE (current_function_decl) == FUNCTION_DECL)
3278                     source_start_java_method (current_function_decl);
3279                   else
3280                     current_function_decl = NULL_TREE;
3281                 ;
3282     break;}
3283 case 105:
3284 #line 964 "./parse.y"
3285 { finish_method_declaration (yyvsp[0].node); ;
3286     break;}
3287 case 106:
3288 #line 966 "./parse.y"
3289 {YYNOT_TWICE yyerror ("'{' expected"); RECOVER;;
3290     break;}
3291 case 107:
3292 #line 971 "./parse.y"
3293 { yyval.node = method_header (0, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3294     break;}
3295 case 108:
3296 #line 973 "./parse.y"
3297 { yyval.node = method_header (0, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3298     break;}
3299 case 109:
3300 #line 975 "./parse.y"
3301 { yyval.node = method_header (yyvsp[-3].value, yyvsp[-2].node, yyvsp[-1].node, yyvsp[0].node); ;
3302     break;}
3303 case 110:
3304 #line 977 "./parse.y"
3305 { yyval.node = method_header (yyvsp[-3].value, void_type_node, yyvsp[-1].node, yyvsp[0].node); ;
3306     break;}
3307 case 111:
3308 #line 979 "./parse.y"
3309 {
3310                   yyerror ("Invalid method declaration, method name required");
3311                   RECOVER;
3312                 ;
3313     break;}
3314 case 112:
3315 #line 984 "./parse.y"
3316 {RECOVER;;
3317     break;}
3318 case 113:
3319 #line 986 "./parse.y"
3320 {yyerror ("Identifier expected"); RECOVER;;
3321     break;}
3322 case 114:
3323 #line 988 "./parse.y"
3324 {yyerror ("Identifier expected"); RECOVER;;
3325     break;}
3326 case 115:
3327 #line 990 "./parse.y"
3328 {
3329                   yyerror ("Invalid method declaration, return type required");
3330                   RECOVER;
3331                 ;
3332     break;}
3333 case 116:
3334 #line 998 "./parse.y"
3335
3336                   ctxp->formal_parameter_number = 0;
3337                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3338                 ;
3339     break;}
3340 case 117:
3341 #line 1003 "./parse.y"
3342 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3343     break;}
3344 case 118:
3345 #line 1005 "./parse.y"
3346 {
3347                   EXPR_WFL_LINECOL (wfl_operator) = yyvsp[-1].operator.location;
3348                   TREE_PURPOSE (yyvsp[-2].node) = 
3349                     build_unresolved_array_type (TREE_PURPOSE (yyvsp[-2].node));
3350                   parse_warning_context 
3351                     (wfl_operator, 
3352                      "Discouraged form of returned type specification");
3353                 ;
3354     break;}
3355 case 119:
3356 #line 1014 "./parse.y"
3357 {yyerror ("')' expected"); DRECOVER(method_declarator);;
3358     break;}
3359 case 120:
3360 #line 1016 "./parse.y"
3361 {yyerror ("']' expected"); RECOVER;;
3362     break;}
3363 case 121:
3364 #line 1021 "./parse.y"
3365 {
3366                   ctxp->formal_parameter_number = 1;
3367                 ;
3368     break;}
3369 case 122:
3370 #line 1025 "./parse.y"
3371 {
3372                   ctxp->formal_parameter_number += 1;
3373                   yyval.node = chainon (yyvsp[-2].node, yyvsp[0].node);
3374                 ;
3375     break;}
3376 case 123:
3377 #line 1030 "./parse.y"
3378 { yyerror ("Missing formal parameter term"); RECOVER; ;
3379     break;}
3380 case 124:
3381 #line 1035 "./parse.y"
3382 {
3383                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3384                 ;
3385     break;}
3386 case 125:
3387 #line 1039 "./parse.y"
3388
3389                   yyval.node = build_tree_list (yyvsp[0].node, yyvsp[-1].node);
3390                   ARG_FINAL_P (yyval.node) = 1;
3391                 ;
3392     break;}
3393 case 126:
3394 #line 1044 "./parse.y"
3395 {
3396                   yyerror ("Missing identifier"); RECOVER;
3397                   yyval.node = NULL_TREE;
3398                 ;
3399     break;}
3400 case 127:
3401 #line 1049 "./parse.y"
3402 {
3403                   yyerror ("Missing identifier"); RECOVER;
3404                   yyval.node = NULL_TREE;
3405                 ;
3406     break;}
3407 case 128:
3408 #line 1057 "./parse.y"
3409 {
3410                   check_modifiers ("Illegal modifier `%s'. Only `final' was expected here",
3411                                    yyvsp[0].value, ACC_FINAL);
3412                   if (yyvsp[0].value != ACC_FINAL)
3413                     MODIFIER_WFL (FINAL_TK) = build_wfl_node (NULL_TREE);
3414                 ;
3415     break;}
3416 case 129:
3417 #line 1066 "./parse.y"
3418 { yyval.node = NULL_TREE; ;
3419     break;}
3420 case 130:
3421 #line 1068 "./parse.y"
3422 { yyval.node = yyvsp[0].node; ;
3423     break;}
3424 case 131:
3425 #line 1070 "./parse.y"
3426 {yyerror ("Missing class type term"); RECOVER;;
3427     break;}
3428 case 132:
3429 #line 1075 "./parse.y"
3430 { yyval.node = build_tree_list (yyvsp[0].node, yyvsp[0].node); ;
3431     break;}
3432 case 133:
3433 #line 1077 "./parse.y"
3434 { yyval.node = tree_cons (yyvsp[0].node, yyvsp[0].node, yyvsp[-2].node); ;
3435     break;}
3436 case 134:
3437 #line 1079 "./parse.y"
3438 {yyerror ("Missing class type term"); RECOVER;;
3439     break;}
3440 case 137:
3441 #line 1086 "./parse.y"
3442 { yyval.node = NULL_TREE; ;
3443     break;}
3444 case 138:
3445 #line 1092 "./parse.y"
3446 {
3447                   TREE_CHAIN (yyvsp[0].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3448                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[0].node);
3449                 ;
3450     break;}
3451 case 139:
3452 #line 1097 "./parse.y"
3453 {
3454                   TREE_CHAIN (yyvsp[-1].node) = CPC_STATIC_INITIALIZER_STMT (ctxp);
3455                   SET_CPC_STATIC_INITIALIZER_STMT (ctxp, yyvsp[-1].node);
3456                 ;
3457     break;}
3458 case 140:
3459 #line 1105 "./parse.y"
3460 {
3461                   check_modifiers ("Illegal modifier `%s' for static initializer", yyvsp[0].value, ACC_STATIC);
3462                   /* Can't have a static initializer in an innerclass */
3463                   if (yyvsp[0].value | ACC_STATIC &&
3464                       GET_CPC_LIST () && !TOPLEVEL_CLASS_DECL_P (GET_CPC ()))
3465                     parse_error_context 
3466                       (MODIFIER_WFL (STATIC_TK),
3467                        "Can't define static initializer in class `%s'. Static initializer can only be defined in top-level classes",
3468                        IDENTIFIER_POINTER (DECL_NAME (GET_CPC ())));
3469                   SOURCE_FRONTEND_DEBUG (("Modifiers: %d", yyvsp[0].value));
3470                 ;
3471     break;}
3472 case 141:
3473 #line 1121 "./parse.y"
3474 {
3475                   current_function_decl = yyvsp[0].node;
3476                   source_start_java_method (current_function_decl);
3477                 ;
3478     break;}
3479 case 142:
3480 #line 1126 "./parse.y"
3481 { finish_method_declaration (yyvsp[0].node); ;
3482     break;}
3483 case 143:
3484 #line 1131 "./parse.y"
3485 { yyval.node = method_header (0, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3486     break;}
3487 case 144:
3488 #line 1133 "./parse.y"
3489 { yyval.node = method_header (yyvsp[-2].value, NULL_TREE, yyvsp[-1].node, yyvsp[0].node); ;
3490     break;}
3491 case 145:
3492 #line 1138 "./parse.y"
3493
3494                   ctxp->formal_parameter_number = 0;  
3495                   yyval.node = method_declarator (yyvsp[-2].node, NULL_TREE);
3496                 ;
3497     break;}
3498 case 146:
3499 #line 1143 "./parse.y"
3500 { yyval.node = method_declarator (yyvsp[-3].node, yyvsp[-1].node); ;
3501     break;}
3502 case 147:
3503 #line 1151 "./parse.y"
3504
3505                   BLOCK_EXPR_BODY (yyvsp[0].node) = empty_stmt_node;
3506                   yyval.node = yyvsp[0].node;
3507                 ;
3508     break;}
3509 case 148:
3510 #line 1156 "./parse.y"
3511 { yyval.node = yyvsp[0].node; ;
3512     break;}
3513 case 149:
3514 #line 1158 "./parse.y"
3515 { yyval.node = yyvsp[0].node; ;
3516     break;}
3517 case 150:
3518 #line 1160 "./parse.y"
3519 { yyval.node = yyvsp[0].node; ;
3520     break;}
3521 case 153:
3522 #line 1170 "./parse.y"
3523
3524                   yyval.node = build_method_invocation (yyvsp[-3].node, NULL_TREE); 
3525                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-3].node), yyval.node);
3526                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3527                 ;
3528     break;}
3529 case 154:
3530 #line 1176 "./parse.y"
3531
3532                   yyval.node = build_method_invocation (yyvsp[-4].node, yyvsp[-2].node); 
3533                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-4].node), yyval.node);
3534                   yyval.node = java_method_add_stmt (current_function_decl, yyval.node);
3535                 ;
3536     break;}
3537 case 155:
3538 #line 1184 "./parse.y"
3539 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3540     break;}
3541 case 156:
3542 #line 1186 "./parse.y"
3543 {yyval.node = parse_jdk1_1_error ("explicit constructor invocation"); ;
3544     break;}
3545 case 157:
3546 #line 1191 "./parse.y"
3547 {
3548                   tree wfl = build_wfl_node (this_identifier_node);
3549                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3550                   yyval.node = wfl;
3551                 ;
3552     break;}
3553 case 158:
3554 #line 1197 "./parse.y"
3555 {
3556                   tree wfl = build_wfl_node (super_identifier_node);
3557                   EXPR_WFL_LINECOL (wfl) = yyvsp[0].operator.location;
3558                   yyval.node = wfl;
3559                 ;
3560     break;}
3561 case 159:
3562 #line 1208 "./parse.y"
3563 { create_interface (0, yyvsp[0].node, NULL_TREE); ;
3564     break;}
3565 case 161:
3566 #line 1211 "./parse.y"
3567 { create_interface (yyvsp[-2].value, yyvsp[0].node, NULL_TREE); ;
3568     break;}
3569 case 163:
3570 #line 1214 "./parse.y"
3571 { create_interface (0, yyvsp[-1].node, yyvsp[0].node);  ;
3572     break;}
3573 case 165:
3574 #line 1217 "./parse.y"
3575 { create_interface (yyvsp[-3].value, yyvsp[-1].node, yyvsp[0].node); ;
3576     break;}
3577 case 167:
3578 #line 1220 "./parse.y"
3579 {yyerror ("'{' expected"); RECOVER;;
3580     break;}
3581 case 168:
3582 #line 1222 "./parse.y"
3583 {yyerror ("'{' expected"); RECOVER;;
3584     break;}
3585 case 169:
3586 #line 1227 "./parse.y"
3587
3588                   ctxp->interface_number = 1;
3589                   yyval.node = build_tree_list (yyvsp[0].node, NULL_TREE);
3590                 ;
3591     break;}
3592 case 170:
3593 #line 1232 "./parse.y"
3594
3595                   ctxp->interface_number++;
3596                   yyval.node = chainon (yyvsp[-2].node, build_tree_list (yyvsp[0].node, NULL_TREE));
3597                 ;
3598     break;}
3599 case 171:
3600 #line 1237 "./parse.y"
3601 {yyerror ("Invalid interface type"); RECOVER;;
3602     break;}
3603 case 172:
3604 #line 1239 "./parse.y"
3605 {yyerror ("Missing term"); RECOVER;;
3606     break;}
3607 case 173:
3608 #line 1244 "./parse.y"
3609 { yyval.node = NULL_TREE; ;
3610     break;}
3611 case 174:
3612 #line 1246 "./parse.y"
3613 { yyval.node = NULL_TREE; ;
3614     break;}
3615 case 179:
3616 #line 1258 "./parse.y"
3617 { end_class_declaration (1); ;
3618     break;}
3619 case 180:
3620 #line 1260 "./parse.y"
3621 { end_class_declaration (1); ;
3622     break;}
3623 case 182:
3624 #line 1269 "./parse.y"
3625
3626                   check_abstract_method_header (yyvsp[-1].node);
3627                   current_function_decl = NULL_TREE; /* FIXME ? */
3628                 ;
3629     break;}
3630 case 183:
3631 #line 1274 "./parse.y"
3632 {yyerror ("';' expected"); RECOVER;;
3633     break;}
3634 case 184:
3635 #line 1280 "./parse.y"
3636 { yyval.node = build_new_array_init (yyvsp[-1].operator.location, NULL_TREE); ;
3637     break;}
3638 case 185:
3639 #line 1282 "./parse.y"
3640 { yyval.node = build_new_array_init (yyvsp[-2].operator.location, yyvsp[-1].node); ;
3641     break;}
3642 case 186:
3643 #line 1284 "./parse.y"
3644 { yyval.node = build_new_array_init (yyvsp[-3].operator.location, yyvsp[-2].node); ;
3645     break;}
3646 case 187:
3647 #line 1289 "./parse.y"
3648
3649                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), 
3650                                   yyvsp[0].node, NULL_TREE);
3651                 ;
3652     break;}
3653 case 188:
3654 #line 1294 "./parse.y"
3655 {
3656                   yyval.node = tree_cons (maybe_build_array_element_wfl (yyvsp[0].node), yyvsp[0].node, yyvsp[-2].node);
3657                 ;
3658     break;}
3659 case 189:
3660 #line 1298 "./parse.y"
3661 {yyerror ("Missing term"); RECOVER;;
3662     break;}
3663 case 190:
3664 #line 1304 "./parse.y"
3665
3666                   /* Store the location of the `}' when doing xrefs */
3667                   if (current_function_decl && flag_emit_xref)
3668                     DECL_END_SOURCE_LINE (current_function_decl) = 
3669                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);
3670                   yyval.node = empty_stmt_node; 
3671                 ;
3672     break;}
3673 case 191:
3674 #line 1312 "./parse.y"
3675 { yyval.node = yyvsp[0].node; ;
3676     break;}
3677 case 192:
3678 #line 1317 "./parse.y"
3679 { enter_block (); ;
3680     break;}
3681 case 193:
3682 #line 1322 "./parse.y"
3683
3684                   maybe_absorb_scoping_blocks ();
3685                   /* Store the location of the `}' when doing xrefs */
3686                   if (current_function_decl && flag_emit_xref)
3687                     DECL_END_SOURCE_LINE (current_function_decl) = 
3688                       EXPR_WFL_ADD_COL (yyvsp[0].operator.location, 1);           
3689                   yyval.node = exit_block ();
3690                 ;
3691     break;}
3692 case 197:
3693 #line 1340 "./parse.y"
3694 { java_method_add_stmt (current_function_decl, yyvsp[0].node); ;
3695     break;}
3696 case 198:
3697 #line 1342 "./parse.y"
3698
3699                   LOCAL_CLASS_P (TREE_TYPE (GET_CPC ())) = 1;
3700                   end_class_declaration (1);
3701                 ;
3702     break;}
3703 case 200:
3704 #line 1354 "./parse.y"
3705 { declare_local_variables (0, yyvsp[-1].node, yyvsp[0].node); ;
3706     break;}
3707 case 201:
3708 #line 1356 "./parse.y"
3709 { declare_local_variables (yyvsp[-2].value, yyvsp[-1].node, yyvsp[0].node); ;
3710     break;}
3711 case 207:
3712 #line 1366 "./parse.y"
3713 { yyval.node = exit_block (); ;
3714     break;}
3715 case 212:
3716 #line 1375 "./parse.y"
3717 { yyval.node = exit_block (); ;
3718     break;}
3719 case 224:
3720 #line 1394 "./parse.y"
3721 { yyval.node = empty_stmt_node; ;
3722     break;}
3723 case 225:
3724 #line 1399 "./parse.y"
3725 {
3726                   yyval.node = build_labeled_block (EXPR_WFL_LINECOL (yyvsp[-1].node), 
3727                                             EXPR_WFL_NODE (yyvsp[-1].node));
3728                   pushlevel (2);
3729                   push_labeled_block (yyval.node);
3730                   PUSH_LABELED_BLOCK (yyval.node);
3731                 ;
3732     break;}
3733 case 226:
3734 #line 1410 "./parse.y"
3735 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3736     break;}
3737 case 227:
3738 #line 1412 "./parse.y"
3739 {yyerror ("':' expected"); RECOVER;;
3740     break;}
3741 case 228:
3742 #line 1417 "./parse.y"
3743 { yyval.node = finish_labeled_statement (yyvsp[-1].node, yyvsp[0].node); ;
3744     break;}
3745 case 229:
3746 #line 1424 "./parse.y"
3747 {
3748                   /* We have a statement. Generate a WFL around it so
3749                      we can debug it */
3750                   yyval.node = build_expr_wfl (yyvsp[-1].node, input_filename, lineno, 0);
3751                   /* We know we have a statement, so set the debug
3752                      info to be eventually generate here. */
3753                   yyval.node = JAVA_MAYBE_GENERATE_DEBUG_INFO (yyval.node);
3754                 ;
3755     break;}
3756 case 230:
3757 #line 1433 "./parse.y"
3758 {
3759                   if (ctxp->prevent_ese != lineno)
3760                     yyerror ("Invalid expression statement");
3761                   DRECOVER (expr_stmt);
3762                 ;
3763     break;}
3764 case 231:
3765 #line 1439 "./parse.y"
3766 {
3767                   if (ctxp->prevent_ese != lineno)
3768                     yyerror ("Invalid expression statement");
3769                   DRECOVER (expr_stmt);
3770                 ;
3771     break;}
3772 case 232:
3773 #line 1445 "./parse.y"
3774 {
3775                   if (ctxp->prevent_ese != lineno)
3776                     yyerror ("Invalid expression statement");
3777                   DRECOVER (expr_stmt);
3778                 ;
3779     break;}
3780 case 233:
3781 #line 1451 "./parse.y"
3782 {yyerror ("')' expected"); RECOVER;;
3783     break;}
3784 case 234:
3785 #line 1453 "./parse.y"
3786 {
3787                   parse_ctor_invocation_error ();
3788                   RECOVER;
3789                 ;
3790     break;}
3791 case 235:
3792 #line 1458 "./parse.y"
3793 {yyerror ("')' expected"); RECOVER;;
3794     break;}
3795 case 236:
3796 #line 1460 "./parse.y"
3797 {
3798                   parse_ctor_invocation_error ();
3799                   RECOVER;
3800                 ;
3801     break;}
3802 case 237:
3803 #line 1465 "./parse.y"
3804 {yyerror ("'(' expected"); RECOVER;;
3805     break;}
3806 case 238:
3807 #line 1467 "./parse.y"
3808 {yyerror ("')' expected"); RECOVER;;
3809     break;}
3810 case 239:
3811 #line 1469 "./parse.y"
3812 {yyerror ("')' expected"); RECOVER;;
3813     break;}
3814 case 240:
3815 #line 1471 "./parse.y"
3816 {yyerror ("';' expected"); RECOVER;;
3817     break;}
3818 case 241:
3819 #line 1473 "./parse.y"
3820 {yyerror ("';' expected"); RECOVER;;
3821     break;}
3822 case 249:
3823 #line 1488 "./parse.y"
3824
3825                   yyval.node = build_if_else_statement (yyvsp[-3].operator.location, yyvsp[-2].node, 
3826                                                 yyvsp[0].node, NULL_TREE);
3827                 ;
3828     break;}
3829 case 250:
3830 #line 1493 "./parse.y"
3831 {yyerror ("'(' expected"); RECOVER;;
3832     break;}
3833 case 251:
3834 #line 1495 "./parse.y"
3835 {yyerror ("Missing term"); RECOVER;;
3836     break;}
3837 case 252:
3838 #line 1497 "./parse.y"
3839 {yyerror ("')' expected"); RECOVER;;
3840     break;}
3841 case 253:
3842 #line 1502 "./parse.y"
3843 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3844     break;}
3845 case 254:
3846 #line 1507 "./parse.y"
3847 { yyval.node = build_if_else_statement (yyvsp[-5].operator.location, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3848     break;}
3849 case 255:
3850 #line 1512 "./parse.y"
3851 {
3852                   enter_block ();
3853                 ;
3854     break;}
3855 case 256:
3856 #line 1516 "./parse.y"
3857
3858                   /* Make into "proper list" of COMPOUND_EXPRs.
3859                      I.e. make the last statment also have its own
3860                      COMPOUND_EXPR. */
3861                   maybe_absorb_scoping_blocks ();
3862                   TREE_OPERAND (yyvsp[-2].node, 1) = exit_block ();
3863                   yyval.node = build_debugable_stmt (EXPR_WFL_LINECOL (yyvsp[-2].node), yyvsp[-2].node);
3864                 ;
3865     break;}
3866 case 257:
3867 #line 1528 "./parse.y"
3868
3869                   yyval.node = build (SWITCH_EXPR, NULL_TREE, yyvsp[-1].node, NULL_TREE);
3870                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
3871                 ;
3872     break;}
3873 case 258:
3874 #line 1533 "./parse.y"
3875 {yyerror ("'(' expected"); RECOVER;;
3876     break;}
3877 case 259:
3878 #line 1535 "./parse.y"
3879 {yyerror ("Missing term or ')'"); DRECOVER(switch_statement);;
3880     break;}
3881 case 260:
3882 #line 1537 "./parse.y"
3883 {yyerror ("'{' expected"); RECOVER;;
3884     break;}
3885 case 261:
3886 #line 1545 "./parse.y"
3887 { yyval.node = NULL_TREE; ;
3888     break;}
3889 case 262:
3890 #line 1547 "./parse.y"
3891 { yyval.node = NULL_TREE; ;
3892     break;}
3893 case 263:
3894 #line 1549 "./parse.y"
3895 { yyval.node = NULL_TREE; ;
3896     break;}
3897 case 264:
3898 #line 1551 "./parse.y"
3899 { yyval.node = NULL_TREE; ;
3900     break;}
3901 case 270:
3902 #line 1570 "./parse.y"
3903
3904                   tree lab = build1 (CASE_EXPR, NULL_TREE, yyvsp[-1].node);
3905                   EXPR_WFL_LINECOL (lab) = yyvsp[-2].operator.location;
3906                   java_method_add_stmt (current_function_decl, lab);
3907                 ;
3908     break;}
3909 case 271:
3910 #line 1576 "./parse.y"
3911
3912                   tree lab = build1 (DEFAULT_EXPR, NULL_TREE, NULL_TREE);
3913                   EXPR_WFL_LINECOL (lab) = yyvsp[-1].operator.location;
3914                   java_method_add_stmt (current_function_decl, lab);
3915                 ;
3916     break;}
3917 case 272:
3918 #line 1582 "./parse.y"
3919 {yyerror ("Missing or invalid constant expression"); RECOVER;;
3920     break;}
3921 case 273:
3922 #line 1584 "./parse.y"
3923 {yyerror ("':' expected"); RECOVER;;
3924     break;}
3925 case 274:
3926 #line 1586 "./parse.y"
3927 {yyerror ("':' expected"); RECOVER;;
3928     break;}
3929 case 275:
3930 #line 1591 "./parse.y"
3931
3932                   tree body = build_loop_body (yyvsp[-2].operator.location, yyvsp[-1].node, 0);
3933                   yyval.node = build_new_loop (body);
3934                 ;
3935     break;}
3936 case 276:
3937 #line 1599 "./parse.y"
3938 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3939     break;}
3940 case 277:
3941 #line 1601 "./parse.y"
3942 {YYERROR_NOW; yyerror ("'(' expected"); RECOVER;;
3943     break;}
3944 case 278:
3945 #line 1603 "./parse.y"
3946 {yyerror ("Missing term and ')' expected"); RECOVER;;
3947     break;}
3948 case 279:
3949 #line 1605 "./parse.y"
3950 {yyerror ("')' expected"); RECOVER;;
3951     break;}
3952 case 280:
3953 #line 1610 "./parse.y"
3954 { yyval.node = finish_loop_body (0, NULL_TREE, yyvsp[0].node, 0); ;
3955     break;}
3956 case 281:
3957 #line 1615 "./parse.y"
3958
3959                   tree body = build_loop_body (0, NULL_TREE, 1);
3960                   yyval.node = build_new_loop (body);
3961                 ;
3962     break;}
3963 case 282:
3964 #line 1624 "./parse.y"
3965 { yyval.node = finish_loop_body (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[-5].node, 1); ;
3966     break;}
3967 case 283:
3968 #line 1629 "./parse.y"
3969 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node); ;
3970     break;}
3971 case 284:
3972 #line 1631 "./parse.y"
3973
3974                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
3975                   /* We have not condition, so we get rid of the EXIT_EXPR */
3976                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
3977                     empty_stmt_node;
3978                 ;
3979     break;}
3980 case 285:
3981 #line 1638 "./parse.y"
3982 {yyerror ("Invalid control expression"); RECOVER;;
3983     break;}
3984 case 286:
3985 #line 1640 "./parse.y"
3986 {yyerror ("Invalid update expression"); RECOVER;;
3987     break;}
3988 case 287:
3989 #line 1642 "./parse.y"
3990 {yyerror ("Invalid update expression"); RECOVER;;
3991     break;}
3992 case 288:
3993 #line 1647 "./parse.y"
3994 { yyval.node = finish_for_loop (EXPR_WFL_LINECOL (yyvsp[-4].node), yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);;
3995     break;}
3996 case 289:
3997 #line 1649 "./parse.y"
3998
3999                   yyval.node = finish_for_loop (0, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4000                   /* We have not condition, so we get rid of the EXIT_EXPR */
4001                   LOOP_EXPR_BODY_CONDITION_EXPR (LOOP_EXPR_BODY (yyval.node), 0) = 
4002                     empty_stmt_node;
4003                 ;
4004     break;}
4005 case 290:
4006 #line 1659 "./parse.y"
4007
4008                   /* This scope defined for local variable that may be
4009                      defined within the scope of the for loop */
4010                   enter_block (); 
4011                 ;
4012     break;}
4013 case 291:
4014 #line 1665 "./parse.y"
4015 {yyerror ("'(' expected"); DRECOVER(for_1);;
4016     break;}
4017 case 292:
4018 #line 1667 "./parse.y"
4019 {yyerror ("Invalid init statement"); RECOVER;;
4020     break;}
4021 case 293:
4022 #line 1672 "./parse.y"
4023
4024                   /* We now declare the loop body. The loop is
4025                      declared as a for loop. */
4026                   tree body = build_loop_body (0, NULL_TREE, 0);
4027                   yyval.node =  build_new_loop (body);
4028                   FOR_LOOP_P (yyval.node) = 1;
4029                   /* The loop is added to the current block the for
4030                      statement is defined within */
4031                   java_method_add_stmt (current_function_decl, yyval.node);
4032                 ;
4033     break;}
4034 case 294:
4035 #line 1684 "./parse.y"
4036 { yyval.node = empty_stmt_node; ;
4037     break;}
4038 case 295:
4039 #line 1686 "./parse.y"
4040
4041                   /* Init statement recorded within the previously
4042                      defined block scope */
4043                   yyval.node = java_method_add_stmt (current_function_decl, yyvsp[0].node);
4044                 ;
4045     break;}
4046 case 296:
4047 #line 1692 "./parse.y"
4048
4049                   /* Local variable are recorded within the previously
4050                      defined block scope */
4051                   yyval.node = NULL_TREE;
4052                 ;
4053     break;}
4054 case 297:
4055 #line 1698 "./parse.y"
4056 {yyerror ("';' expected"); DRECOVER(for_init_1);;
4057     break;}
4058 case 298:
4059 #line 1702 "./parse.y"
4060 {yyval.node = empty_stmt_node;;
4061     break;}
4062 case 299:
4063 #line 1704 "./parse.y"
4064 { yyval.node = build_debugable_stmt (BUILD_LOCATION (), yyvsp[0].node); ;
4065     break;}
4066 case 300:
4067 #line 1709 "./parse.y"
4068 { yyval.node = add_stmt_to_compound (NULL_TREE, NULL_TREE, yyvsp[0].node); ;
4069     break;}
4070 case 301:
4071 #line 1711 "./parse.y"
4072 { yyval.node = add_stmt_to_compound (yyvsp[-2].node, NULL_TREE, yyvsp[0].node); ;
4073     break;}
4074 case 302:
4075 #line 1713 "./parse.y"
4076 {yyerror ("Missing term"); RECOVER;;
4077     break;}
4078 case 303:
4079 #line 1718 "./parse.y"
4080 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 1, NULL_TREE); ;
4081     break;}
4082 case 304:
4083 #line 1720 "./parse.y"
4084 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 1, yyvsp[-1].node); ;
4085     break;}
4086 case 305:
4087 #line 1722 "./parse.y"
4088 {yyerror ("Missing term"); RECOVER;;
4089     break;}
4090 case 306:
4091 #line 1724 "./parse.y"
4092 {yyerror ("';' expected"); RECOVER;;
4093     break;}
4094 case 307:
4095 #line 1729 "./parse.y"
4096 { yyval.node = build_bc_statement (yyvsp[-1].operator.location, 0, NULL_TREE); ;
4097     break;}
4098 case 308:
4099 #line 1731 "./parse.y"
4100 { yyval.node = build_bc_statement (yyvsp[-2].operator.location, 0, yyvsp[-1].node); ;
4101     break;}
4102 case 309:
4103 #line 1733 "./parse.y"
4104 {yyerror ("Missing term"); RECOVER;;
4105     break;}
4106 case 310:
4107 #line 1735 "./parse.y"
4108 {yyerror ("';' expected"); RECOVER;;
4109     break;}
4110 case 311:
4111 #line 1740 "./parse.y"
4112 { yyval.node = build_return (yyvsp[-1].operator.location, NULL_TREE); ;
4113     break;}
4114 case 312:
4115 #line 1742 "./parse.y"
4116 { yyval.node = build_return (yyvsp[-2].operator.location, yyvsp[-1].node); ;
4117     break;}
4118 case 313:
4119 #line 1744 "./parse.y"
4120 {yyerror ("Missing term"); RECOVER;;
4121     break;}
4122 case 314:
4123 #line 1746 "./parse.y"
4124 {yyerror ("';' expected"); RECOVER;;
4125     break;}
4126 case 315:
4127 #line 1751 "./parse.y"
4128
4129                   yyval.node = build1 (THROW_EXPR, NULL_TREE, yyvsp[-1].node);
4130                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-2].operator.location;
4131                 ;
4132     break;}
4133 case 316:
4134 #line 1756 "./parse.y"
4135 {yyerror ("Missing term"); RECOVER;;
4136     break;}
4137 case 317:
4138 #line 1758 "./parse.y"
4139 {yyerror ("';' expected"); RECOVER;;
4140     break;}
4141 case 318:
4142 #line 1763 "./parse.y"
4143
4144                   yyval.node = build (SYNCHRONIZED_EXPR, NULL_TREE, yyvsp[-2].node, yyvsp[0].node);
4145                   EXPR_WFL_LINECOL (yyval.node) = 
4146                     EXPR_WFL_LINECOL (MODIFIER_WFL (SYNCHRONIZED_TK));
4147                 ;
4148     break;}
4149 case 319:
4150 #line 1769 "./parse.y"
4151 {yyerror ("'{' expected"); RECOVER;;
4152     break;}
4153 case 320:
4154 #line 1771 "./parse.y"
4155 {yyerror ("'(' expected"); RECOVER;;
4156     break;}
4157 case 321:
4158 #line 1773 "./parse.y"
4159 {yyerror ("Missing term"); RECOVER;;
4160     break;}
4161 case 322:
4162 #line 1775 "./parse.y"
4163 {yyerror ("Missing term"); RECOVER;;
4164     break;}
4165 case 323:
4166 #line 1780 "./parse.y"
4167 {
4168                   check_modifiers (
4169              "Illegal modifier `%s'. Only `synchronized' was expected here",
4170                                    yyvsp[0].value, ACC_SYNCHRONIZED);
4171                   if (yyvsp[0].value != ACC_SYNCHRONIZED)
4172                     MODIFIER_WFL (SYNCHRONIZED_TK) = 
4173                       build_wfl_node (NULL_TREE);
4174                 ;
4175     break;}
4176 case 324:
4177 #line 1792 "./parse.y"
4178 { yyval.node = build_try_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4179     break;}
4180 case 325:
4181 #line 1794 "./parse.y"
4182 { yyval.node = build_try_finally_statement (yyvsp[-2].operator.location, yyvsp[-1].node, yyvsp[0].node); ;
4183     break;}
4184 case 326:
4185 #line 1796 "./parse.y"
4186 { yyval.node = build_try_finally_statement 
4187                     (yyvsp[-3].operator.location, build_try_statement (yyvsp[-3].operator.location,
4188                                                        yyvsp[-2].node, yyvsp[-1].node), yyvsp[0].node);
4189                 ;
4190     break;}
4191 case 327:
4192 #line 1801 "./parse.y"
4193 {yyerror ("'{' expected"); DRECOVER (try_statement);;
4194     break;}
4195 case 329:
4196 #line 1807 "./parse.y"
4197
4198                   TREE_CHAIN (yyvsp[0].node) = yyvsp[-1].node;
4199                   yyval.node = yyvsp[0].node;
4200                 ;
4201     break;}
4202 case 330:
4203 #line 1815 "./parse.y"
4204
4205                   java_method_add_stmt (current_function_decl, yyvsp[0].node);
4206                   exit_block ();
4207                   yyval.node = yyvsp[-1].node;
4208                 ;
4209     break;}
4210 case 331:
4211 #line 1823 "./parse.y"
4212
4213                   /* We add a block to define a scope for
4214                      formal_parameter (CCBP). The formal parameter is
4215                      declared initialized by the appropriate function
4216                      call */
4217                   tree ccpb = enter_block ();
4218                   tree init = build_assignment (ASSIGN_TK, yyvsp[-2].operator.location, 
4219                                                 TREE_PURPOSE (yyvsp[-1].node), 
4220                                                 soft_exceptioninfo_call_node);
4221                   declare_local_variables (0, TREE_VALUE (yyvsp[-1].node),
4222                                            build_tree_list (TREE_PURPOSE (yyvsp[-1].node),
4223                                                             init));
4224                   yyval.node = build1 (CATCH_EXPR, NULL_TREE, ccpb);
4225                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4226                 ;
4227     break;}
4228 case 332:
4229 #line 1839 "./parse.y"
4230 {yyerror ("'(' expected"); RECOVER; yyval.node = NULL_TREE;;
4231     break;}
4232 case 333:
4233 #line 1841 "./parse.y"
4234 {
4235                   yyerror ("Missing term or ')' expected"); 
4236                   RECOVER; yyval.node = NULL_TREE;
4237                 ;
4238     break;}
4239 case 334:
4240 #line 1846 "./parse.y"
4241 {yyerror ("Missing term"); RECOVER; yyval.node = NULL_TREE;;
4242     break;}
4243 case 335:
4244 #line 1851 "./parse.y"
4245 { yyval.node = yyvsp[0].node; ;
4246     break;}
4247 case 336:
4248 #line 1853 "./parse.y"
4249 {yyerror ("'{' expected"); RECOVER; ;
4250     break;}
4251 case 340:
4252 #line 1865 "./parse.y"
4253 { yyval.node = build_this (yyvsp[0].operator.location); ;
4254     break;}
4255 case 341:
4256 #line 1867 "./parse.y"
4257 {yyval.node = yyvsp[-1].node;;
4258     break;}
4259 case 347:
4260 #line 1877 "./parse.y"
4261
4262                   tree wfl = build_wfl_node (this_identifier_node);
4263                   yyval.node = make_qualified_primary (yyvsp[-2].node, wfl, EXPR_WFL_LINECOL (yyvsp[-2].node));
4264                 ;
4265     break;}
4266 case 348:
4267 #line 1882 "./parse.y"
4268 {yyerror ("')' expected"); RECOVER;;
4269     break;}
4270 case 349:
4271 #line 1884 "./parse.y"
4272 {yyerror ("'class' or 'this' expected" ); RECOVER;;
4273     break;}
4274 case 350:
4275 #line 1886 "./parse.y"
4276 {yyerror ("'class' expected" ); RECOVER;;
4277     break;}
4278 case 351:
4279 #line 1888 "./parse.y"
4280 {yyerror ("'class' expected" ); RECOVER;;
4281     break;}
4282 case 352:
4283 #line 1896 "./parse.y"
4284
4285                   yyval.node = build_java_array_type (yyvsp[-2].node, -1);
4286                   CLASS_LOADED_P (yyval.node) = 1;
4287                 ;
4288     break;}
4289 case 353:
4290 #line 1901 "./parse.y"
4291 { yyval.node = build_unresolved_array_type (yyvsp[-2].node); ;
4292     break;}
4293 case 354:
4294 #line 1911 "./parse.y"
4295 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4296     break;}
4297 case 355:
4298 #line 1913 "./parse.y"
4299 { yyval.node = build_incomplete_class_ref (yyvsp[-1].operator.location, yyvsp[-2].node); ;
4300     break;}
4301 case 356:
4302 #line 1915 "./parse.y"
4303 { yyval.node = build_class_ref (yyvsp[-2].node); ;
4304     break;}
4305 case 357:
4306 #line 1917 "./parse.y"
4307 { yyval.node = build_class_ref (void_type_node); ;
4308     break;}
4309 case 358:
4310 #line 1922 "./parse.y"
4311 { yyval.node = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4312     break;}
4313 case 359:
4314 #line 1924 "./parse.y"
4315 { yyval.node = build_new_invocation (yyvsp[-2].node, NULL_TREE); ;
4316     break;}
4317 case 361:
4318 #line 1930 "./parse.y"
4319
4320                   tree ctor = build_new_invocation (yyvsp[-2].node, NULL_TREE);
4321                   yyval.node = make_qualified_primary (yyvsp[-3].node, ctor, 
4322                                                EXPR_WFL_LINECOL (yyvsp[-3].node));
4323                 ;
4324     break;}
4325 case 363:
4326 #line 1937 "./parse.y"
4327
4328                   tree ctor = build_new_invocation (yyvsp[-3].node, yyvsp[-1].node);
4329                   yyval.node = make_qualified_primary (yyvsp[-4].node, ctor, 
4330                                                EXPR_WFL_LINECOL (yyvsp[-4].node));
4331                 ;
4332     break;}
4333 case 365:
4334 #line 1944 "./parse.y"
4335 {yyerror ("'(' expected"); DRECOVER(new_1);;
4336     break;}
4337 case 366:
4338 #line 1946 "./parse.y"
4339 {yyerror ("'(' expected"); RECOVER;;
4340     break;}
4341 case 367:
4342 #line 1948 "./parse.y"
4343 {yyerror ("')' or term expected"); RECOVER;;
4344     break;}
4345 case 368:
4346 #line 1950 "./parse.y"
4347 {yyerror ("')' expected"); RECOVER;;
4348     break;}
4349 case 369:
4350 #line 1952 "./parse.y"
4351 {YYERROR_NOW; yyerror ("Identifier expected"); RECOVER;;
4352     break;}
4353 case 370:
4354 #line 1954 "./parse.y"
4355 {yyerror ("'(' expected"); RECOVER;;
4356     break;}
4357 case 371:
4358 #line 1964 "./parse.y"
4359 { create_anonymous_class (yyvsp[-4].operator.location, yyvsp[-3].node); ;
4360     break;}
4361 case 372:
4362 #line 1966 "./parse.y"
4363
4364                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4365                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-5].node);
4366
4367                   end_class_declaration (1);
4368
4369                   /* Now we can craft the new expression */
4370                   yyval.node = build_new_invocation (id, yyvsp[-3].node);
4371
4372                   /* Note that we can't possibly be here if
4373                      `class_type' is an interface (in which case the
4374                      anonymous class extends Object and implements
4375                      `class_type', hence its constructor can't have
4376                      arguments.) */
4377
4378                   /* Otherwise, the innerclass must feature a
4379                      constructor matching `argument_list'. Anonymous
4380                      classes are a bit special: it's impossible to
4381                      define constructor for them, hence constructors
4382                      must be generated following the hints provided by
4383                      the `new' expression. Whether a super constructor
4384                      of that nature exists or not is to be verified
4385                      later on in verify_constructor_super. 
4386
4387                      It's during the expansion of a `new' statement
4388                      refering to an anonymous class that a ctor will
4389                      be generated for the anonymous class, with the
4390                      right arguments. */
4391
4392                 ;
4393     break;}
4394 case 373:
4395 #line 1997 "./parse.y"
4396 { create_anonymous_class (yyvsp[-3].operator.location, yyvsp[-2].node); ;
4397     break;}
4398 case 374:
4399 #line 1999 "./parse.y"
4400
4401                   tree id = build_wfl_node (DECL_NAME (GET_CPC ()));
4402                   EXPR_WFL_LINECOL (id) = EXPR_WFL_LINECOL (yyvsp[-4].node);
4403
4404                   end_class_declaration (1);
4405
4406                   /* Now we can craft the new expression. The
4407                      statement doesn't need to be remember so that a
4408                      constructor can be generated, since its signature
4409                      is already known. */
4410                   yyval.node = build_new_invocation (id, NULL_TREE);
4411                 ;
4412     break;}
4413 case 375:
4414 #line 2015 "./parse.y"
4415 { yyval.node = yyvsp[-2].node; ;
4416     break;}
4417 case 376:
4418 #line 2017 "./parse.y"
4419 { yyval.node = yyvsp[-2].node; ;
4420     break;}
4421 case 377:
4422 #line 2022 "./parse.y"
4423
4424                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, NULL_TREE);
4425                   ctxp->formal_parameter_number = 1; 
4426                 ;
4427     break;}
4428 case 378:
4429 #line 2027 "./parse.y"
4430 {
4431                   ctxp->formal_parameter_number += 1;
4432                   yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyvsp[-2].node);
4433                 ;
4434     break;}
4435 case 379:
4436 #line 2032 "./parse.y"
4437 {yyerror ("Missing term"); RECOVER;;
4438     break;}
4439 case 380:
4440 #line 2037 "./parse.y"
4441 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4442     break;}
4443 case 381:
4444 #line 2039 "./parse.y"
4445 { yyval.node = build_newarray_node (yyvsp[-1].node, yyvsp[0].node, 0); ;
4446     break;}
4447 case 382:
4448 #line 2041 "./parse.y"
4449 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4450     break;}
4451 case 383:
4452 #line 2043 "./parse.y"
4453 { yyval.node = build_newarray_node (yyvsp[-2].node, yyvsp[-1].node, CURRENT_OSB (ctxp));;
4454     break;}
4455 case 384:
4456 #line 2047 "./parse.y"
4457 {
4458                   char *sig;
4459                   while (CURRENT_OSB (ctxp)--)
4460                     obstack_1grow (&temporary_obstack, '[');
4461                   sig = obstack_finish (&temporary_obstack);
4462                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE,
4463                               yyvsp[-2].node, get_identifier (sig), yyvsp[0].node);
4464                 ;
4465     break;}
4466 case 385:
4467 #line 2056 "./parse.y"
4468
4469                   tree type = yyvsp[-2].node;
4470                   while (CURRENT_OSB (ctxp)--)
4471                     type = build_java_array_type (type, -1);
4472                   yyval.node = build (NEW_ANONYMOUS_ARRAY_EXPR, NULL_TREE, 
4473                               build_pointer_type (type), NULL_TREE, yyvsp[0].node);
4474                 ;
4475     break;}
4476 case 386:
4477 #line 2064 "./parse.y"
4478 {yyerror ("'[' expected"); DRECOVER ("]");;
4479     break;}
4480 case 387:
4481 #line 2066 "./parse.y"
4482 {yyerror ("']' expected"); RECOVER;;
4483     break;}
4484 case 388:
4485 #line 2071 "./parse.y"
4486 { yyval.node = build_tree_list (NULL_TREE, yyvsp[0].node); ;
4487     break;}
4488 case 389:
4489 #line 2073 "./parse.y"
4490 { yyval.node = tree_cons (NULL_TREE, yyvsp[0].node, yyval.node); ;
4491     break;}
4492 case 390:
4493 #line 2078 "./parse.y"
4494
4495                   EXPR_WFL_LINECOL (yyvsp[-1].node) = yyvsp[-2].operator.location;
4496                   yyval.node = yyvsp[-1].node;
4497                 ;
4498     break;}
4499 case 391:
4500 #line 2083 "./parse.y"
4501 {yyerror ("']' expected"); RECOVER;;
4502     break;}
4503 case 392:
4504 #line 2085 "./parse.y"
4505 {
4506                   yyerror ("Missing term");
4507                   yyerror ("']' expected");
4508                   RECOVER;
4509                 ;
4510     break;}
4511 case 393:
4512 #line 2094 "./parse.y"
4513
4514                   int allocate = 0;
4515                   /* If not initialized, allocate memory for the osb
4516                      numbers stack */
4517                   if (!ctxp->osb_limit)
4518                     {
4519                       allocate = ctxp->osb_limit = 32;
4520                       ctxp->osb_depth = -1;
4521                     }
4522                   /* If capacity overflown, reallocate a bigger chunk */
4523                   else if (ctxp->osb_depth+1 == ctxp->osb_limit)
4524                     allocate = ctxp->osb_limit << 1;
4525                   
4526                   if (allocate)
4527                     {
4528                       allocate *= sizeof (int);
4529                       if (ctxp->osb_number)
4530                         ctxp->osb_number = (int *)xrealloc (ctxp->osb_number,
4531                                                             allocate);
4532                       else
4533                         ctxp->osb_number = (int *)xmalloc (allocate);
4534                     }
4535                   ctxp->osb_depth++;
4536                   CURRENT_OSB (ctxp) = 1;
4537                 ;
4538     break;}
4539 case 394:
4540 #line 2120 "./parse.y"
4541 { CURRENT_OSB (ctxp)++; ;
4542     break;}
4543 case 395:
4544 #line 2122 "./parse.y"
4545 { yyerror ("']' expected"); RECOVER;;
4546     break;}
4547 case 396:
4548 #line 2127 "./parse.y"
4549 { yyval.node = make_qualified_primary (yyvsp[-2].node, yyvsp[0].node, yyvsp[-1].operator.location); ;
4550     break;}
4551 case 397:
4552 #line 2131 "./parse.y"
4553 {
4554                   tree super_wfl = 
4555                     build_wfl_node (super_identifier_node);
4556                   EXPR_WFL_LINECOL (super_wfl) = yyvsp[-2].operator.location;
4557                   yyval.node = make_qualified_name (super_wfl, yyvsp[0].node, yyvsp[-1].operator.location);
4558                 ;
4559     break;}
4560 case 398:
4561 #line 2138 "./parse.y"
4562 {yyerror ("Field expected"); DRECOVER (super_field_acces);;
4563     break;}
4564 case 399:
4565 #line 2143 "./parse.y"
4566 { yyval.node = build_method_invocation (yyvsp[-2].node, NULL_TREE); ;
4567     break;}
4568 case 400:
4569 #line 2145 "./parse.y"
4570 { yyval.node = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node); ;
4571     break;}
4572 case 401:
4573 #line 2147 "./parse.y"
4574
4575                   if (TREE_CODE (yyvsp[-4].node) == THIS_EXPR)
4576                     yyval.node = build_this_super_qualified_invocation 
4577                       (1, yyvsp[-2].node, NULL_TREE, 0, yyvsp[-3].operator.location);
4578                   else
4579                     {
4580                       tree invok = build_method_invocation (yyvsp[-2].node, NULL_TREE);
4581                       yyval.node = make_qualified_primary (yyvsp[-4].node, invok, yyvsp[-3].operator.location);
4582                     }
4583                 ;
4584     break;}
4585 case 402:
4586 #line 2158 "./parse.y"
4587
4588                   if (TREE_CODE (yyvsp[-5].node) == THIS_EXPR)
4589                     yyval.node = build_this_super_qualified_invocation 
4590                       (1, yyvsp[-3].node, yyvsp[-1].node, 0, yyvsp[-4].operator.location);
4591                   else
4592                     {
4593                       tree invok = build_method_invocation (yyvsp[-3].node, yyvsp[-1].node);
4594                       yyval.node = make_qualified_primary (yyvsp[-5].node, invok, yyvsp[-4].operator.location);
4595                     }
4596                 ;
4597     break;}
4598 case 403:
4599 #line 2169 "./parse.y"
4600
4601                   yyval.node = build_this_super_qualified_invocation 
4602                     (0, yyvsp[-2].node, NULL_TREE, yyvsp[-4].operator.location, yyvsp[-3].operator.location);
4603                 ;
4604     break;}
4605 case 404:
4606 #line 2174 "./parse.y"
4607 {
4608                   yyval.node = build_this_super_qualified_invocation 
4609                     (0, yyvsp[-3].node, yyvsp[-1].node, yyvsp[-5].operator.location, yyvsp[-4].operator.location);
4610                 ;
4611     break;}
4612 case 405:
4613 #line 2183 "./parse.y"
4614 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4615     break;}
4616 case 406:
4617 #line 2185 "./parse.y"
4618 { yyerror ("'(' expected"); DRECOVER (method_invocation); ;
4619     break;}
4620 case 407:
4621 #line 2190 "./parse.y"
4622 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4623     break;}
4624 case 408:
4625 #line 2192 "./parse.y"
4626 { yyval.node = build_array_ref (yyvsp[-2].operator.location, yyvsp[-3].node, yyvsp[-1].node); ;
4627     break;}
4628 case 409:
4629 #line 2194 "./parse.y"
4630 {
4631                   yyerror ("Missing term and ']' expected");
4632                   DRECOVER(array_access);
4633                 ;
4634     break;}
4635 case 410:
4636 #line 2199 "./parse.y"
4637 {
4638                   yyerror ("']' expected");
4639                   DRECOVER(array_access);
4640                 ;
4641     break;}
4642 case 411:
4643 #line 2204 "./parse.y"
4644 {
4645                   yyerror ("Missing term and ']' expected");
4646                   DRECOVER(array_access);
4647                 ;
4648     break;}
4649 case 412:
4650 #line 2209 "./parse.y"
4651 {
4652                   yyerror ("']' expected");
4653                   DRECOVER(array_access);
4654                 ;
4655     break;}
4656 case 417:
4657 #line 2224 "./parse.y"
4658 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4659     break;}
4660 case 418:
4661 #line 2229 "./parse.y"
4662 { yyval.node = build_incdec (yyvsp[0].operator.token, yyvsp[0].operator.location, yyvsp[-1].node, 1); ;
4663     break;}
4664 case 421:
4665 #line 2236 "./parse.y"
4666 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4667     break;}
4668 case 422:
4669 #line 2238 "./parse.y"
4670 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4671     break;}
4672 case 424:
4673 #line 2241 "./parse.y"
4674 {yyerror ("Missing term"); RECOVER;
4675     break;}
4676 case 425:
4677 #line 2243 "./parse.y"
4678 {yyerror ("Missing term"); RECOVER;
4679     break;}
4680 case 426:
4681 #line 2248 "./parse.y"
4682 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4683     break;}
4684 case 427:
4685 #line 2250 "./parse.y"
4686 {yyerror ("Missing term"); RECOVER;
4687     break;}
4688 case 428:
4689 #line 2255 "./parse.y"
4690 {yyval.node = build_incdec (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node, 0); ;
4691     break;}
4692 case 429:
4693 #line 2257 "./parse.y"
4694 {yyerror ("Missing term"); RECOVER;
4695     break;}
4696 case 431:
4697 #line 2263 "./parse.y"
4698 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4699     break;}
4700 case 432:
4701 #line 2265 "./parse.y"
4702 {yyval.node = build_unaryop (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[0].node); ;
4703     break;}
4704 case 434:
4705 #line 2268 "./parse.y"
4706 {yyerror ("Missing term"); RECOVER;
4707     break;}
4708 case 435:
4709 #line 2270 "./parse.y"
4710 {yyerror ("Missing term"); RECOVER;
4711     break;}
4712 case 436:
4713 #line 2275 "./parse.y"
4714
4715                   tree type = yyvsp[-3].node;
4716                   while (CURRENT_OSB (ctxp)--)
4717                     type = build_java_array_type (type, -1);
4718                   ctxp->osb_depth--;
4719                   yyval.node = build_cast (yyvsp[-4].operator.location, type, yyvsp[0].node); 
4720                 ;
4721     break;}
4722 case 437:
4723 #line 2283 "./parse.y"
4724 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4725     break;}
4726 case 438:
4727 #line 2285 "./parse.y"
4728 { yyval.node = build_cast (yyvsp[-3].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4729     break;}
4730 case 439:
4731 #line 2287 "./parse.y"
4732
4733                   const char *ptr;
4734                   while (CURRENT_OSB (ctxp)--)
4735                     obstack_1grow (&temporary_obstack, '[');
4736                   ctxp->osb_depth--;
4737                   obstack_grow0 (&temporary_obstack, 
4738                                  IDENTIFIER_POINTER (EXPR_WFL_NODE (yyvsp[-3].node)),
4739                                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (yyvsp[-3].node)));
4740                   ptr = obstack_finish (&temporary_obstack);
4741                   EXPR_WFL_NODE (yyvsp[-3].node) = get_identifier (ptr);
4742                   yyval.node = build_cast (yyvsp[-4].operator.location, yyvsp[-3].node, yyvsp[0].node);
4743                 ;
4744     break;}
4745 case 440:
4746 #line 2300 "./parse.y"
4747 {yyerror ("']' expected, invalid type expression");;
4748     break;}
4749 case 441:
4750 #line 2302 "./parse.y"
4751 {
4752                   if (ctxp->prevent_ese != lineno)
4753                     yyerror ("Invalid type expression"); RECOVER;
4754                   RECOVER;
4755                 ;
4756     break;}
4757 case 442:
4758 #line 2308 "./parse.y"
4759 {yyerror ("Missing term"); RECOVER;;
4760     break;}
4761 case 443:
4762 #line 2310 "./parse.y"
4763 {yyerror ("Missing term"); RECOVER;;
4764     break;}
4765 case 444:
4766 #line 2312 "./parse.y"
4767 {yyerror ("Missing term"); RECOVER;;
4768     break;}
4769 case 446:
4770 #line 2318 "./parse.y"
4771
4772                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), 
4773                                     yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node);
4774                 ;
4775     break;}
4776 case 447:
4777 #line 2323 "./parse.y"
4778 {
4779                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4780                                     yyvsp[-2].node, yyvsp[0].node); 
4781                 ;
4782     break;}
4783 case 448:
4784 #line 2328 "./parse.y"
4785 {
4786                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4787                                     yyvsp[-2].node, yyvsp[0].node); 
4788                 ;
4789     break;}
4790 case 449:
4791 #line 2333 "./parse.y"
4792 {yyerror ("Missing term"); RECOVER;;
4793     break;}
4794 case 450:
4795 #line 2335 "./parse.y"
4796 {yyerror ("Missing term"); RECOVER;;
4797     break;}
4798 case 451:
4799 #line 2337 "./parse.y"
4800 {yyerror ("Missing term"); RECOVER;;
4801     break;}
4802 case 453:
4803 #line 2343 "./parse.y"
4804 {
4805                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4806                                     yyvsp[-2].node, yyvsp[0].node); 
4807                 ;
4808     break;}
4809 case 454:
4810 #line 2348 "./parse.y"
4811 {
4812                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4813                                     yyvsp[-2].node, yyvsp[0].node); 
4814                 ;
4815     break;}
4816 case 455:
4817 #line 2353 "./parse.y"
4818 {yyerror ("Missing term"); RECOVER;;
4819     break;}
4820 case 456:
4821 #line 2355 "./parse.y"
4822 {yyerror ("Missing term"); RECOVER;;
4823     break;}
4824 case 458:
4825 #line 2361 "./parse.y"
4826 {
4827                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4828                                     yyvsp[-2].node, yyvsp[0].node); 
4829                 ;
4830     break;}
4831 case 459:
4832 #line 2366 "./parse.y"
4833 {
4834                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4835                                     yyvsp[-2].node, yyvsp[0].node); 
4836                 ;
4837     break;}
4838 case 460:
4839 #line 2371 "./parse.y"
4840 {
4841                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4842                                     yyvsp[-2].node, yyvsp[0].node); 
4843                 ;
4844     break;}
4845 case 461:
4846 #line 2376 "./parse.y"
4847 {yyerror ("Missing term"); RECOVER;;
4848     break;}
4849 case 462:
4850 #line 2378 "./parse.y"
4851 {yyerror ("Missing term"); RECOVER;;
4852     break;}
4853 case 463:
4854 #line 2380 "./parse.y"
4855 {yyerror ("Missing term"); RECOVER;;
4856     break;}
4857 case 465:
4858 #line 2386 "./parse.y"
4859 {
4860                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4861                                     yyvsp[-2].node, yyvsp[0].node); 
4862                 ;
4863     break;}
4864 case 466:
4865 #line 2391 "./parse.y"
4866 {
4867                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4868                                     yyvsp[-2].node, yyvsp[0].node); 
4869                 ;
4870     break;}
4871 case 467:
4872 #line 2396 "./parse.y"
4873 {
4874                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4875                                     yyvsp[-2].node, yyvsp[0].node); 
4876                 ;
4877     break;}
4878 case 468:
4879 #line 2401 "./parse.y"
4880 {
4881                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4882                                     yyvsp[-2].node, yyvsp[0].node); 
4883                 ;
4884     break;}
4885 case 469:
4886 #line 2406 "./parse.y"
4887 { yyval.node = build_binop (INSTANCEOF_EXPR, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
4888     break;}
4889 case 470:
4890 #line 2408 "./parse.y"
4891 {yyerror ("Missing term"); RECOVER;;
4892     break;}
4893 case 471:
4894 #line 2410 "./parse.y"
4895 {yyerror ("Missing term"); RECOVER;;
4896     break;}
4897 case 472:
4898 #line 2412 "./parse.y"
4899 {yyerror ("Missing term"); RECOVER;;
4900     break;}
4901 case 473:
4902 #line 2414 "./parse.y"
4903 {yyerror ("Missing term"); RECOVER;;
4904     break;}
4905 case 474:
4906 #line 2416 "./parse.y"
4907 {yyerror ("Invalid reference type"); RECOVER;;
4908     break;}
4909 case 476:
4910 #line 2422 "./parse.y"
4911 {
4912                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4913                                     yyvsp[-2].node, yyvsp[0].node); 
4914                 ;
4915     break;}
4916 case 477:
4917 #line 2427 "./parse.y"
4918 {
4919                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4920                                     yyvsp[-2].node, yyvsp[0].node); 
4921                 ;
4922     break;}
4923 case 478:
4924 #line 2432 "./parse.y"
4925 {yyerror ("Missing term"); RECOVER;;
4926     break;}
4927 case 479:
4928 #line 2434 "./parse.y"
4929 {yyerror ("Missing term"); RECOVER;;
4930     break;}
4931 case 481:
4932 #line 2440 "./parse.y"
4933 {
4934                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4935                                     yyvsp[-2].node, yyvsp[0].node); 
4936                 ;
4937     break;}
4938 case 482:
4939 #line 2445 "./parse.y"
4940 {yyerror ("Missing term"); RECOVER;;
4941     break;}
4942 case 484:
4943 #line 2451 "./parse.y"
4944 {
4945                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4946                                     yyvsp[-2].node, yyvsp[0].node); 
4947                 ;
4948     break;}
4949 case 485:
4950 #line 2456 "./parse.y"
4951 {yyerror ("Missing term"); RECOVER;;
4952     break;}
4953 case 487:
4954 #line 2462 "./parse.y"
4955 {
4956                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4957                                     yyvsp[-2].node, yyvsp[0].node); 
4958                 ;
4959     break;}
4960 case 488:
4961 #line 2467 "./parse.y"
4962 {yyerror ("Missing term"); RECOVER;;
4963     break;}
4964 case 490:
4965 #line 2473 "./parse.y"
4966 {
4967                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4968                                     yyvsp[-2].node, yyvsp[0].node); 
4969                 ;
4970     break;}
4971 case 491:
4972 #line 2478 "./parse.y"
4973 {yyerror ("Missing term"); RECOVER;;
4974     break;}
4975 case 493:
4976 #line 2484 "./parse.y"
4977 {
4978                   yyval.node = build_binop (BINOP_LOOKUP (yyvsp[-1].operator.token), yyvsp[-1].operator.location,
4979                                     yyvsp[-2].node, yyvsp[0].node); 
4980                 ;
4981     break;}
4982 case 494:
4983 #line 2489 "./parse.y"
4984 {yyerror ("Missing term"); RECOVER;;
4985     break;}
4986 case 496:
4987 #line 2495 "./parse.y"
4988 {
4989                   yyval.node = build (CONDITIONAL_EXPR, NULL_TREE, yyvsp[-4].node, yyvsp[-2].node, yyvsp[0].node);
4990                   EXPR_WFL_LINECOL (yyval.node) = yyvsp[-3].operator.location;
4991                 ;
4992     break;}
4993 case 497:
4994 #line 2500 "./parse.y"
4995 {
4996                   YYERROR_NOW;
4997                   yyerror ("Missing term");
4998                   DRECOVER (1);
4999                 ;
5000     break;}
5001 case 498:
5002 #line 2506 "./parse.y"
5003 {yyerror ("Missing term"); DRECOVER (2);;
5004     break;}
5005 case 499:
5006 #line 2508 "./parse.y"
5007 {yyerror ("Missing term"); DRECOVER (3);;
5008     break;}
5009 case 502:
5010 #line 2518 "./parse.y"
5011 { yyval.node = build_assignment (yyvsp[-1].operator.token, yyvsp[-1].operator.location, yyvsp[-2].node, yyvsp[0].node); ;
5012     break;}
5013 case 503:
5014 #line 2520 "./parse.y"
5015 {
5016                   if (ctxp->prevent_ese != lineno)
5017                     yyerror ("Missing term");
5018                   DRECOVER (assign);
5019                 ;
5020     break;}
5021 }
5022    /* the action file gets copied in in place of this dollarsign */
5023 #line 543 "/usr/lib/bison.simple"
5024 \f
5025   yyvsp -= yylen;
5026   yyssp -= yylen;
5027 #ifdef YYLSP_NEEDED
5028   yylsp -= yylen;
5029 #endif
5030
5031 #if YYDEBUG != 0
5032   if (yydebug)
5033     {
5034       short *ssp1 = yyss - 1;
5035       fprintf (stderr, "state stack now");
5036       while (ssp1 != yyssp)
5037         fprintf (stderr, " %d", *++ssp1);
5038       fprintf (stderr, "\n");
5039     }
5040 #endif
5041
5042   *++yyvsp = yyval;
5043
5044 #ifdef YYLSP_NEEDED
5045   yylsp++;
5046   if (yylen == 0)
5047     {
5048       yylsp->first_line = yylloc.first_line;
5049       yylsp->first_column = yylloc.first_column;
5050       yylsp->last_line = (yylsp-1)->last_line;
5051       yylsp->last_column = (yylsp-1)->last_column;
5052       yylsp->text = 0;
5053     }
5054   else
5055     {
5056       yylsp->last_line = (yylsp+yylen-1)->last_line;
5057       yylsp->last_column = (yylsp+yylen-1)->last_column;
5058     }
5059 #endif
5060
5061   /* Now "shift" the result of the reduction.
5062      Determine what state that goes to,
5063      based on the state we popped back to
5064      and the rule number reduced by.  */
5065
5066   yyn = yyr1[yyn];
5067
5068   yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
5069   if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
5070     yystate = yytable[yystate];
5071   else
5072     yystate = yydefgoto[yyn - YYNTBASE];
5073
5074   goto yynewstate;
5075
5076 yyerrlab:   /* here on detecting error */
5077
5078   if (! yyerrstatus)
5079     /* If not already recovering from an error, report this error.  */
5080     {
5081       ++yynerrs;
5082
5083 #ifdef YYERROR_VERBOSE
5084       yyn = yypact[yystate];
5085
5086       if (yyn > YYFLAG && yyn < YYLAST)
5087         {
5088           int size = 0;
5089           char *msg;
5090           int x, count;
5091
5092           count = 0;
5093           /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
5094           for (x = (yyn < 0 ? -yyn : 0);
5095                x < (sizeof(yytname) / sizeof(char *)); x++)
5096             if (yycheck[x + yyn] == x)
5097               size += strlen(yytname[x]) + 15, count++;
5098           msg = (char *) malloc(size + 15);
5099           if (msg != 0)
5100             {
5101               strcpy(msg, "parse error");
5102
5103               if (count < 5)
5104                 {
5105                   count = 0;
5106                   for (x = (yyn < 0 ? -yyn : 0);
5107                        x < (sizeof(yytname) / sizeof(char *)); x++)
5108                     if (yycheck[x + yyn] == x)
5109                       {
5110                         strcat(msg, count == 0 ? ", expecting `" : " or `");
5111                         strcat(msg, yytname[x]);
5112                         strcat(msg, "'");
5113                         count++;
5114                       }
5115                 }
5116               yyerror(msg);
5117               free(msg);
5118             }
5119           else
5120             yyerror ("parse error; also virtual memory exceeded");
5121         }
5122       else
5123 #endif /* YYERROR_VERBOSE */
5124         yyerror("parse error");
5125     }
5126
5127   goto yyerrlab1;
5128 yyerrlab1:   /* here on error raised explicitly by an action */
5129
5130   if (yyerrstatus == 3)
5131     {
5132       /* if just tried and failed to reuse lookahead token after an error, discard it.  */
5133
5134       /* return failure if at end of input */
5135       if (yychar == YYEOF)
5136         YYABORT;
5137
5138 #if YYDEBUG != 0
5139       if (yydebug)
5140         fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
5141 #endif
5142
5143       yychar = YYEMPTY;
5144     }
5145
5146   /* Else will try to reuse lookahead token
5147      after shifting the error token.  */
5148
5149   yyerrstatus = 3;              /* Each real token shifted decrements this */
5150
5151   goto yyerrhandle;
5152
5153 yyerrdefault:  /* current state does not do anything special for the error token. */
5154
5155 #if 0
5156   /* This is wrong; only states that explicitly want error tokens
5157      should shift them.  */
5158   yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
5159   if (yyn) goto yydefault;
5160 #endif
5161
5162 yyerrpop:   /* pop the current state because it cannot handle the error token */
5163
5164   if (yyssp == yyss) YYABORT;
5165   yyvsp--;
5166   yystate = *--yyssp;
5167 #ifdef YYLSP_NEEDED
5168   yylsp--;
5169 #endif
5170
5171 #if YYDEBUG != 0
5172   if (yydebug)
5173     {
5174       short *ssp1 = yyss - 1;
5175       fprintf (stderr, "Error: state stack now");
5176       while (ssp1 != yyssp)
5177         fprintf (stderr, " %d", *++ssp1);
5178       fprintf (stderr, "\n");
5179     }
5180 #endif
5181
5182 yyerrhandle:
5183
5184   yyn = yypact[yystate];
5185   if (yyn == YYFLAG)
5186     goto yyerrdefault;
5187
5188   yyn += YYTERROR;
5189   if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
5190     goto yyerrdefault;
5191
5192   yyn = yytable[yyn];
5193   if (yyn < 0)
5194     {
5195       if (yyn == YYFLAG)
5196         goto yyerrpop;
5197       yyn = -yyn;
5198       goto yyreduce;
5199     }
5200   else if (yyn == 0)
5201     goto yyerrpop;
5202
5203   if (yyn == YYFINAL)
5204     YYACCEPT;
5205
5206 #if YYDEBUG != 0
5207   if (yydebug)
5208     fprintf(stderr, "Shifting error token, ");
5209 #endif
5210
5211   *++yyvsp = yylval;
5212 #ifdef YYLSP_NEEDED
5213   *++yylsp = yylloc;
5214 #endif
5215
5216   yystate = yyn;
5217   goto yynewstate;
5218
5219  yyacceptlab:
5220   /* YYACCEPT comes here.  */
5221   if (yyfree_stacks)
5222     {
5223       free (yyss);
5224       free (yyvs);
5225 #ifdef YYLSP_NEEDED
5226       free (yyls);
5227 #endif
5228     }
5229   return 0;
5230
5231  yyabortlab:
5232   /* YYABORT comes here.  */
5233   if (yyfree_stacks)
5234     {
5235       free (yyss);
5236       free (yyvs);
5237 #ifdef YYLSP_NEEDED
5238       free (yyls);
5239 #endif
5240     }
5241   return 1;
5242 }
5243 #line 2546 "./parse.y"
5244
5245 \f
5246
5247 /* This section of the code deal with save/restoring parser contexts.
5248    Add mode documentation here. FIXME */
5249
5250 /* Helper function. Create a new parser context. With
5251    COPY_FROM_PREVIOUS set to a non zero value, content of the previous
5252    context is copied, otherwise, the new context is zeroed. The newly
5253    created context becomes the current one.  */
5254
5255 static void
5256 create_new_parser_context (copy_from_previous)
5257     int copy_from_previous;
5258 {
5259   struct parser_ctxt *new;
5260
5261   new =  (struct parser_ctxt *)xmalloc(sizeof (struct parser_ctxt));
5262   if (copy_from_previous)
5263     {
5264       memcpy ((PTR)new, (PTR)ctxp, sizeof (struct parser_ctxt));
5265       new->saved_data_ctx = 1;
5266     }
5267   else
5268     bzero ((PTR) new, sizeof (struct parser_ctxt));
5269       
5270   new->next = ctxp;
5271   ctxp = new;
5272 }
5273
5274 /* Create a new parser context and make it the current one. */
5275
5276 void
5277 java_push_parser_context ()
5278 {
5279   create_new_parser_context (0);
5280   if (ctxp->next)
5281     {
5282       ctxp->incomplete_class = ctxp->next->incomplete_class;
5283       ctxp->gclass_list = ctxp->next->gclass_list;
5284     }
5285 }  
5286
5287 void 
5288 java_pop_parser_context (generate)
5289      int generate;
5290 {
5291   tree current;
5292   struct parser_ctxt *toFree, *next;
5293
5294   if (!ctxp)
5295     return;
5296
5297   toFree = ctxp;
5298   next = ctxp->next;
5299   if (next)
5300     {
5301       next->incomplete_class = ctxp->incomplete_class;
5302       next->gclass_list = ctxp->gclass_list;
5303       lineno = ctxp->lineno;
5304       finput = ctxp->finput;
5305       current_class = ctxp->current_class;
5306     }
5307
5308   /* Set the single import class file flag to 0 for the current list
5309      of imported things */
5310   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5311     IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 0;
5312
5313   /* And restore those of the previous context */
5314   if ((ctxp = next))            /* Assignment is really meant here */
5315     for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
5316       IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (TREE_PURPOSE (current)) = 1;
5317   
5318   /* If we pushed a context to parse a class intended to be generated,
5319      we keep it so we can remember the class. What we could actually
5320      do is to just update a list of class names.  */
5321   if (generate)
5322     {
5323       toFree->next = ctxp_for_generation;
5324       ctxp_for_generation = toFree;
5325     }
5326   else
5327     free (toFree);
5328 }
5329
5330 /* Create a parser context for the use of saving some global
5331    variables.  */
5332
5333 void
5334 java_parser_context_save_global ()
5335 {
5336   if (!ctxp)
5337     {
5338       java_push_parser_context ();
5339       ctxp->saved_data_ctx = 1;
5340     }
5341
5342   /* If this context already stores data, create a new one suitable
5343      for data storage. */
5344   else if (ctxp->saved_data)
5345     create_new_parser_context (1);
5346
5347   ctxp->finput = finput;
5348   ctxp->lineno = lineno;
5349   ctxp->current_class = current_class;
5350   ctxp->filename = input_filename;
5351   ctxp->current_function_decl = current_function_decl;
5352   ctxp->saved_data = 1;
5353 }
5354
5355 /* Restore some global variables from the previous context. Make the
5356    previous context the current one.  */
5357
5358 void
5359 java_parser_context_restore_global ()
5360 {
5361   finput = ctxp->finput;
5362   lineno = ctxp->lineno;
5363   current_class = ctxp->current_class;
5364   input_filename = ctxp->filename;
5365   current_function_decl = ctxp->current_function_decl;
5366   ctxp->saved_data = 0;
5367   if (ctxp->saved_data_ctx)
5368     java_pop_parser_context (0);
5369 }
5370
5371 /* Suspend vital data for the current class/function being parsed so
5372    that an other class can be parsed. Used to let local/anonymous
5373    classes be parsed.  */
5374
5375 static void
5376 java_parser_context_suspend ()
5377 {
5378   /* This makes debugging through java_debug_context easier */
5379   static char *name = "<inner buffer context>";
5380
5381   /* Duplicate the previous context, use it to save the globals we're
5382      interested in */
5383   create_new_parser_context (1);
5384   ctxp->current_function_decl = current_function_decl;
5385   ctxp->current_class = current_class;
5386
5387   /* Then create a new context which inherits all data from the
5388      previous one. This will be the new current context  */
5389   create_new_parser_context (1);
5390
5391   /* Help debugging */
5392   ctxp->next->filename = name;
5393 }
5394
5395 /* Resume vital data for the current class/function being parsed so
5396    that an other class can be parsed. Used to let local/anonymous
5397    classes be parsed.  The trick is the data storing file position
5398    informations must be restored to their current value, so parsing
5399    can resume as if no context was ever saved. */
5400
5401 static void
5402 java_parser_context_resume ()
5403 {
5404   struct parser_ctxt *old = ctxp;             /* This one is to be discarded */
5405   struct parser_ctxt *saver = old->next;      /* This one contain saved info */
5406   struct parser_ctxt *restored = saver->next; /* This one is the old current */
5407
5408   /* We need to inherit the list of classes to complete/generate */
5409   restored->incomplete_class = old->incomplete_class;
5410   restored->gclass_list = old->gclass_list;
5411   restored->classd_list = old->classd_list;
5412   restored->class_list = old->class_list;
5413
5414   /* Restore the current class and function from the saver */
5415   current_class = saver->current_class;
5416   current_function_decl = saver->current_function_decl;
5417
5418   /* Retrive the restored context */
5419   ctxp = restored;
5420
5421   /* Re-installed the data for the parsing to carry on */
5422   bcopy (&old->marker_begining, &ctxp->marker_begining,
5423          (size_t)(&ctxp->marker_end - &ctxp->marker_begining));
5424
5425   /* Buffer context can now be discarded */
5426   free (saver);
5427   free (old);
5428 }
5429
5430 /* Add a new anchor node to which all statement(s) initializing static
5431    and non static initialized upon declaration field(s) will be
5432    linked.  */
5433
5434 static void
5435 java_parser_context_push_initialized_field ()
5436 {
5437   tree node;
5438
5439   node = build_tree_list (NULL_TREE, NULL_TREE);
5440   TREE_CHAIN (node) = CPC_STATIC_INITIALIZER_LIST (ctxp);
5441   CPC_STATIC_INITIALIZER_LIST (ctxp) = node;
5442
5443   node = build_tree_list (NULL_TREE, NULL_TREE);
5444   TREE_CHAIN (node) = CPC_INITIALIZER_LIST (ctxp);
5445   CPC_INITIALIZER_LIST (ctxp) = node;
5446
5447   node = build_tree_list (NULL_TREE, NULL_TREE);
5448   TREE_CHAIN (node) = CPC_INSTANCE_INITIALIZER_LIST (ctxp);
5449   CPC_INSTANCE_INITIALIZER_LIST (ctxp) = node;
5450 }
5451
5452 /* Pop the lists of initialized field. If this lists aren't empty,
5453    remember them so we can use it to create and populate the $finit$
5454    or <clinit> functions. */
5455
5456 static void
5457 java_parser_context_pop_initialized_field ()
5458 {
5459   tree stmts;
5460   tree class_type = TREE_TYPE (GET_CPC ());
5461
5462   if (CPC_INITIALIZER_LIST (ctxp))
5463     {
5464       stmts = CPC_INITIALIZER_STMT (ctxp);
5465       CPC_INITIALIZER_LIST (ctxp) = TREE_CHAIN (CPC_INITIALIZER_LIST (ctxp));
5466       if (stmts && !java_error_count)
5467         TYPE_FINIT_STMT_LIST (class_type) = reorder_static_initialized (stmts);
5468     }
5469
5470   if (CPC_STATIC_INITIALIZER_LIST (ctxp))
5471     {
5472       stmts = CPC_STATIC_INITIALIZER_STMT (ctxp);
5473       CPC_STATIC_INITIALIZER_LIST (ctxp) = 
5474         TREE_CHAIN (CPC_STATIC_INITIALIZER_LIST (ctxp));
5475       /* Keep initialization in order to enforce 8.5 */
5476       if (stmts && !java_error_count)
5477         TYPE_CLINIT_STMT_LIST (class_type) = nreverse (stmts);
5478     }
5479
5480   /* JDK 1.1 instance initializers */
5481   if (CPC_INSTANCE_INITIALIZER_LIST (ctxp))
5482     {
5483       stmts = CPC_INSTANCE_INITIALIZER_STMT (ctxp);
5484       CPC_INSTANCE_INITIALIZER_LIST (ctxp) = 
5485         TREE_CHAIN (CPC_INSTANCE_INITIALIZER_LIST (ctxp));
5486       if (stmts && !java_error_count)
5487         TYPE_II_STMT_LIST (class_type) = nreverse (stmts);
5488     }
5489 }
5490
5491 static tree
5492 reorder_static_initialized (list)
5493      tree list;
5494 {
5495   /* We have to keep things in order. The alias initializer have to
5496      come first, then the initialized regular field, in reverse to
5497      keep them in lexical order. */
5498   tree marker, previous = NULL_TREE;
5499   for (marker = list; marker; previous = marker, marker = TREE_CHAIN (marker))
5500     if (TREE_CODE (marker) == TREE_LIST 
5501         && !TREE_VALUE (marker) && !TREE_PURPOSE (marker))
5502       break;
5503   
5504   /* No static initialized, the list is fine as is */
5505   if (!previous)
5506     list = TREE_CHAIN (marker);
5507
5508   /* No marker? reverse the whole list */
5509   else if (!marker)
5510     list = nreverse (list);
5511
5512   /* Otherwise, reverse what's after the marker and the new reordered
5513      sublist will replace the marker. */
5514   else
5515     {
5516       TREE_CHAIN (previous) = NULL_TREE;
5517       list = nreverse (list);
5518       list = chainon (TREE_CHAIN (marker), list);
5519     }
5520   return list;
5521 }
5522
5523 /* Helper functions to dump the parser context stack.  */
5524
5525 #define TAB_CONTEXT(C) \
5526   {int i; for (i = 0; i < (C); i++) fputc (' ', stderr);}
5527
5528 static void
5529 java_debug_context_do (tab)
5530      int tab;
5531 {
5532   struct parser_ctxt *copy = ctxp;
5533   while (copy)
5534     {
5535       TAB_CONTEXT (tab);
5536       fprintf (stderr, "ctxt: 0x%0lX\n", (unsigned long)copy);
5537       TAB_CONTEXT (tab);
5538       fprintf (stderr, "filename: %s\n", copy->filename);
5539       TAB_CONTEXT (tab);
5540       fprintf (stderr, "lineno: %d\n", copy->lineno);
5541       TAB_CONTEXT (tab);
5542       fprintf (stderr, "package: %s\n",
5543                (copy->package ? 
5544                 IDENTIFIER_POINTER (copy->package) : "<none>"));
5545       TAB_CONTEXT (tab);
5546       fprintf (stderr, "context for saving: %d\n", copy->saved_data_ctx);
5547       TAB_CONTEXT (tab);
5548       fprintf (stderr, "saved data: %d\n", copy->saved_data);
5549       copy = copy->next;
5550       tab += 2;
5551     }
5552 }
5553
5554 /* Dump the stacked up parser contexts. Intended to be called from a
5555    debugger.  */
5556
5557 void
5558 java_debug_context ()
5559 {
5560   java_debug_context_do (0);
5561 }
5562
5563 \f
5564
5565 /* Flag for the error report routine to issue the error the first time
5566    it's called (overriding the default behavior which is to drop the
5567    first invocation and honor the second one, taking advantage of a
5568    richer context.  */
5569 static int force_error = 0;
5570
5571 /* Reporting an constructor invocation error.  */
5572 static void
5573 parse_ctor_invocation_error ()
5574 {
5575   if (DECL_CONSTRUCTOR_P (current_function_decl))
5576     yyerror ("Constructor invocation must be first thing in a constructor"); 
5577   else
5578     yyerror ("Only constructors can invoke constructors");
5579 }
5580
5581 /* Reporting JDK1.1 features not implemented.  */
5582
5583 static tree
5584 parse_jdk1_1_error (msg)
5585     const char *msg;
5586 {
5587   sorry (": `%s' JDK1.1(TM) feature", msg);
5588   java_error_count++;
5589   return empty_stmt_node;
5590 }
5591
5592 static int do_warning = 0;
5593
5594 void
5595 yyerror (msg)
5596      const char *msg;
5597 {
5598   static java_lc elc;
5599   static int  prev_lineno;
5600   static const char *prev_msg;
5601
5602   int save_lineno;
5603   char *remainder, *code_from_source;
5604   extern struct obstack temporary_obstack;
5605   
5606   if (!force_error && prev_lineno == lineno)
5607     return;
5608
5609   /* Save current error location but report latter, when the context is
5610      richer.  */
5611   if (ctxp->java_error_flag == 0)
5612     {
5613       ctxp->java_error_flag = 1;
5614       elc = ctxp->elc;
5615       /* Do something to use the previous line if we're reaching the
5616          end of the file... */
5617 #ifdef VERBOSE_SKELETON
5618       printf ("* Error detected (%s)\n", (msg ? msg : "(null)"));
5619 #endif
5620       return;
5621     }
5622
5623   /* Ignore duplicate message on the same line. BTW, this is dubious. FIXME */
5624   if (!force_error && msg == prev_msg && prev_lineno == elc.line)
5625     return;
5626
5627   ctxp->java_error_flag = 0;
5628   if (do_warning)
5629     java_warning_count++;
5630   else
5631     java_error_count++;
5632   
5633   if (elc.col == 0 && msg && msg[1] == ';')
5634     {
5635       elc.col  = ctxp->p_line->char_col-1;
5636       elc.line = ctxp->p_line->lineno;
5637     }
5638
5639   save_lineno = lineno;
5640   prev_lineno = lineno = elc.line;
5641   prev_msg = msg;
5642
5643   code_from_source = java_get_line_col (ctxp->filename, elc.line, elc.col);
5644   obstack_grow0 (&temporary_obstack, 
5645                  code_from_source, strlen (code_from_source));
5646   remainder = obstack_finish (&temporary_obstack);
5647   if (do_warning)
5648     warning ("%s.\n%s", msg, remainder);
5649   else
5650     error ("%s.\n%s", msg, remainder);
5651
5652   /* This allow us to cheaply avoid an extra 'Invalid expression
5653      statement' error report when errors have been already reported on
5654      the same line. This occurs when we report an error but don't have
5655      a synchronization point other than ';', which
5656      expression_statement is the only one to take care of.  */
5657   ctxp->prevent_ese = lineno = save_lineno;
5658 }
5659
5660 static void
5661 issue_warning_error_from_context (cl, msg, ap)
5662      tree cl;
5663      const char *msg;
5664      va_list ap;
5665 {
5666   char *saved, *saved_input_filename;
5667   char buffer [4096];
5668   vsprintf (buffer, msg, ap);
5669   force_error = 1;
5670
5671   ctxp->elc.line = EXPR_WFL_LINENO (cl);
5672   ctxp->elc.col  = (EXPR_WFL_COLNO (cl) == 0xfff ? -1 : 
5673                     (EXPR_WFL_COLNO (cl) == 0xffe ? -2 : EXPR_WFL_COLNO (cl)));
5674
5675   /* We have a CL, that's a good reason for using it if it contains data */
5676   saved = ctxp->filename;
5677   if (TREE_CODE (cl) == EXPR_WITH_FILE_LOCATION && EXPR_WFL_FILENAME_NODE (cl))
5678     ctxp->filename = EXPR_WFL_FILENAME (cl);
5679   saved_input_filename = input_filename;
5680   input_filename = ctxp->filename;
5681   java_error (NULL);
5682   java_error (buffer);
5683   ctxp->filename = saved;
5684   input_filename = saved_input_filename;
5685   force_error = 0;
5686 }
5687
5688 /* Issue an error message at a current source line CL */
5689
5690 void
5691 parse_error_context VPARAMS ((tree cl, const char *msg, ...))
5692 {
5693 #ifndef ANSI_PROTOTYPES
5694   tree cl;
5695   const char *msg;
5696 #endif
5697   va_list ap;
5698
5699   VA_START (ap, msg);
5700 #ifndef ANSI_PROTOTYPES
5701   cl = va_arg (ap, tree);
5702   msg = va_arg (ap, const char *);
5703 #endif
5704   issue_warning_error_from_context (cl, msg, ap);
5705   va_end (ap);
5706 }
5707
5708 /* Issue a warning at a current source line CL */
5709
5710 static void
5711 parse_warning_context VPARAMS ((tree cl, const char *msg, ...))
5712 {
5713 #ifndef ANSI_PROTOTYPES
5714   tree cl;
5715   const char *msg;
5716 #endif
5717   va_list ap;
5718
5719   VA_START (ap, msg);
5720 #ifndef ANSI_PROTOTYPES
5721   cl = va_arg (ap, tree);
5722   msg = va_arg (ap, const char *);
5723 #endif
5724
5725   force_error = do_warning = 1;
5726   issue_warning_error_from_context (cl, msg, ap);
5727   do_warning = force_error = 0;
5728   va_end (ap);
5729 }
5730
5731 static tree
5732 find_expr_with_wfl (node)
5733      tree node;
5734 {
5735   while (node)
5736     {
5737       char code;
5738       tree to_return;
5739
5740       switch (TREE_CODE (node))
5741         {
5742         case BLOCK:
5743           node = BLOCK_EXPR_BODY (node);
5744           continue;
5745
5746         case COMPOUND_EXPR:
5747           to_return = find_expr_with_wfl (TREE_OPERAND (node, 0));
5748           if (to_return)
5749             return to_return;
5750           node = TREE_OPERAND (node, 1);
5751           continue;
5752
5753         case LOOP_EXPR:
5754           node = TREE_OPERAND (node, 0);
5755           continue;
5756           
5757         case LABELED_BLOCK_EXPR:
5758           node = TREE_OPERAND (node, 1);
5759           continue;
5760
5761         default:
5762           code = TREE_CODE_CLASS (TREE_CODE (node));
5763           if (((code == '1') || (code == '2') || (code == 'e'))
5764               && EXPR_WFL_LINECOL (node))
5765             return node;
5766           return NULL_TREE;
5767         }
5768     }
5769   return NULL_TREE;
5770 }
5771
5772 /* Issue a missing return statement error. Uses METHOD to figure the
5773    last line of the method the error occurs in.  */
5774
5775 static void
5776 missing_return_error (method)
5777      tree method;
5778 {
5779   EXPR_WFL_SET_LINECOL (wfl_operator, DECL_SOURCE_LINE_LAST (method), -2);
5780   parse_error_context (wfl_operator, "Missing return statement");
5781 }
5782
5783 /* Issue an unreachable statement error. From NODE, find the next
5784    statement to report appropriately.  */
5785 static void
5786 unreachable_stmt_error (node)
5787      tree node;
5788 {
5789   /* Browse node to find the next expression node that has a WFL. Use
5790      the location to report the error */
5791   if (TREE_CODE (node) == COMPOUND_EXPR)
5792     node = find_expr_with_wfl (TREE_OPERAND (node, 1));
5793   else
5794     node = find_expr_with_wfl (node);
5795
5796   if (node)
5797     {
5798       EXPR_WFL_SET_LINECOL (wfl_operator, EXPR_WFL_LINENO (node), -2);
5799       parse_error_context (wfl_operator, "Unreachable statement");
5800     }
5801   else
5802     fatal ("Can't get valid statement - unreachable_stmt_error");
5803 }
5804
5805 int
5806 java_report_errors ()
5807 {
5808   if (java_error_count)
5809     fprintf (stderr, "%d error%s", 
5810              java_error_count, (java_error_count == 1 ? "" : "s"));
5811   if (java_warning_count)
5812     fprintf (stderr, "%s%d warning%s", (java_error_count ? ", " : ""),
5813              java_warning_count, (java_warning_count == 1 ? "" : "s"));
5814   if (java_error_count || java_warning_count)
5815     putc ('\n', stderr);
5816   return java_error_count;
5817 }
5818
5819 static char *
5820 java_accstring_lookup (flags)
5821      int flags;
5822 {
5823   static char buffer [80];
5824 #define COPY_RETURN(S) {strcpy (buffer, S); return buffer;}
5825
5826   /* Access modifier looked-up first for easier report on forbidden
5827      access. */
5828   if (flags & ACC_PUBLIC) COPY_RETURN ("public");
5829   if (flags & ACC_PRIVATE) COPY_RETURN ("private");
5830   if (flags & ACC_PROTECTED) COPY_RETURN ("protected");
5831   if (flags & ACC_STATIC) COPY_RETURN ("static");
5832   if (flags & ACC_FINAL) COPY_RETURN ("final");
5833   if (flags & ACC_SYNCHRONIZED) COPY_RETURN ("synchronized");
5834   if (flags & ACC_VOLATILE) COPY_RETURN ("volatile");
5835   if (flags & ACC_TRANSIENT) COPY_RETURN ("transient");
5836   if (flags & ACC_NATIVE) COPY_RETURN ("native");
5837   if (flags & ACC_INTERFACE) COPY_RETURN ("interface");
5838   if (flags & ACC_ABSTRACT) COPY_RETURN ("abstract");
5839
5840   buffer [0] = '\0';
5841   return buffer;
5842 #undef COPY_RETURN
5843 }
5844
5845 /* Issuing error messages upon redefinition of classes, interfaces or
5846    variables. */
5847
5848 static void
5849 classitf_redefinition_error (context, id, decl, cl)
5850      const char *context;
5851      tree id, decl, cl;
5852 {
5853   parse_error_context (cl, "%s `%s' already defined in %s:%d", 
5854                        context, IDENTIFIER_POINTER (id), 
5855                        DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
5856   /* Here we should point out where its redefined. It's a unicode. FIXME */
5857 }
5858
5859 static void
5860 variable_redefinition_error (context, name, type, line)
5861      tree context, name, type;
5862      int line;
5863 {
5864   const char *type_name;
5865
5866   /* Figure a proper name for type. We might haven't resolved it */
5867   if (TREE_CODE (type) == POINTER_TYPE && !TREE_TYPE (type))
5868     type_name = IDENTIFIER_POINTER (TYPE_NAME (type));
5869   else
5870     type_name = lang_printable_name (type, 0);
5871
5872   parse_error_context (context,
5873                        "Variable `%s' is already defined in this method and was declared `%s %s' at line %d", 
5874                        IDENTIFIER_POINTER (name),
5875                        type_name, IDENTIFIER_POINTER (name), line);
5876 }
5877
5878 static tree
5879 build_array_from_name (type, type_wfl, name, ret_name)
5880      tree type, type_wfl, name, *ret_name;
5881 {
5882   int more_dims = 0;
5883   const char *string;
5884
5885   /* Eventually get more dims */
5886   string = IDENTIFIER_POINTER (name);
5887   while (string [more_dims] == '[')
5888     more_dims++;
5889   
5890   /* If we have, then craft a new type for this variable */
5891   if (more_dims)
5892     {
5893       name = get_identifier (&string [more_dims]);
5894
5895       /* If we have a pointer, use its type */
5896       if (TREE_CODE (type) == POINTER_TYPE)
5897         type = TREE_TYPE (type);
5898
5899       /* Building the first dimension of a primitive type uses this
5900          function */
5901       if (JPRIMITIVE_TYPE_P (type))
5902         {
5903           type = build_java_array_type (type, -1);
5904           CLASS_LOADED_P (type) = 1;
5905           more_dims--;
5906         }
5907       /* Otherwise, if we have a WFL for this type, use it (the type
5908          is already an array on an unresolved type, and we just keep
5909          on adding dimensions) */
5910       else if (type_wfl)
5911         type = type_wfl;
5912
5913       /* Add all the dimensions */
5914       while (more_dims--)
5915         type = build_unresolved_array_type (type);
5916
5917       /* The type may have been incomplete in the first place */
5918       if (type_wfl)
5919         type = obtain_incomplete_type (type);
5920     }
5921
5922   if (ret_name)
5923     *ret_name = name;
5924   return type;
5925 }
5926
5927 /* Build something that the type identifier resolver will identify as
5928    being an array to an unresolved type. TYPE_WFL is a WFL on a
5929    identifier. */
5930
5931 static tree
5932 build_unresolved_array_type (type_or_wfl)
5933      tree type_or_wfl;
5934 {
5935   const char *ptr;
5936
5937   /* TYPE_OR_WFL might be an array on a resolved type. In this case,
5938      just create a array type */
5939   if (TREE_CODE (type_or_wfl) == RECORD_TYPE)
5940     {
5941       tree type = build_java_array_type (type_or_wfl, -1);
5942       CLASS_LOADED_P (type) = CLASS_LOADED_P (type_or_wfl);
5943       return type;
5944     }
5945
5946   obstack_1grow (&temporary_obstack, '[');
5947   obstack_grow0 (&temporary_obstack,
5948                  IDENTIFIER_POINTER (EXPR_WFL_NODE (type_or_wfl)),
5949                  IDENTIFIER_LENGTH (EXPR_WFL_NODE (type_or_wfl)));
5950   ptr = obstack_finish (&temporary_obstack);
5951   return build_expr_wfl (get_identifier (ptr),
5952                          EXPR_WFL_FILENAME (type_or_wfl),
5953                          EXPR_WFL_LINENO (type_or_wfl),
5954                          EXPR_WFL_COLNO (type_or_wfl));
5955 }
5956
5957 static void
5958 parser_add_interface (class_decl, interface_decl, wfl)
5959      tree class_decl, interface_decl, wfl;
5960 {
5961   if (maybe_add_interface (TREE_TYPE (class_decl), TREE_TYPE (interface_decl)))
5962     parse_error_context (wfl, "Interface `%s' repeated",
5963                          IDENTIFIER_POINTER (DECL_NAME (interface_decl)));
5964 }
5965
5966 /* Bulk of common class/interface checks. Return 1 if an error was
5967    encountered. TAG is 0 for a class, 1 for an interface.  */
5968
5969 static int
5970 check_class_interface_creation (is_interface, flags, raw_name, qualified_name, decl, cl)
5971      int is_interface, flags;
5972      tree raw_name, qualified_name, decl, cl;
5973 {
5974   tree node;
5975   int sca = 0;                  /* Static class allowed */
5976   int icaf = 0;                 /* Inner class allowed flags */
5977   int uaaf = CLASS_MODIFIERS;   /* Usually allowed access flags */
5978
5979   if (!quiet_flag)
5980     fprintf (stderr, " %s%s %s", 
5981              (CPC_INNER_P () ? "inner" : ""),
5982              (is_interface ? "interface" : "class"), 
5983              IDENTIFIER_POINTER (qualified_name));
5984
5985   /* Scope of an interface/class type name:
5986        - Can't be imported by a single type import
5987        - Can't already exists in the package */
5988   if (IS_A_SINGLE_IMPORT_CLASSFILE_NAME_P (raw_name)
5989       && (node = find_name_in_single_imports (raw_name)))
5990     {
5991       parse_error_context 
5992         (cl, "%s name `%s' clashes with imported type `%s'",
5993          (is_interface ? "Interface" : "Class"),
5994          IDENTIFIER_POINTER (raw_name), IDENTIFIER_POINTER (node));
5995       return 1;
5996     }
5997   if (decl && CLASS_COMPLETE_P (decl))
5998     {
5999       classitf_redefinition_error ((is_interface ? "Interface" : "Class"), 
6000                                    qualified_name, decl, cl);
6001       return 1;
6002     }
6003
6004   if (check_inner_class_redefinition (raw_name, cl))
6005     return 1;
6006
6007   /* If public, file name should match class/interface name, except
6008      when dealing with an inner class */
6009   if (!CPC_INNER_P () && (flags & ACC_PUBLIC ))
6010     {
6011       const char *f;
6012
6013       /* Contains OS dependent assumption on path separator. FIXME */
6014       for (f = &input_filename [strlen (input_filename)]; 
6015            f != input_filename && f[0] != '/' && f[0] != DIR_SEPARATOR;
6016            f--)
6017         ;
6018       if (f[0] == '/' || f[0] == DIR_SEPARATOR)
6019         f++;
6020       if (strncmp (IDENTIFIER_POINTER (raw_name), 
6021                    f , IDENTIFIER_LENGTH (raw_name)) ||
6022           f [IDENTIFIER_LENGTH (raw_name)] != '.')
6023         parse_error_context
6024           (cl, "Public %s `%s' must be defined in a file called `%s.java'", 
6025                              (is_interface ? "interface" : "class"),
6026                              IDENTIFIER_POINTER (qualified_name),
6027                              IDENTIFIER_POINTER (raw_name));
6028     }
6029
6030   /* Static classes can be declared only in top level classes. Note:
6031      once static, a inner class is a top level class. */
6032   if (flags & ACC_STATIC)
6033     {
6034       /* Catch the specific error of declaring an class inner class
6035          with no toplevel enclosing class. Prevent check_modifiers from
6036          complaining a second time */
6037       if (CPC_INNER_P () && !TOPLEVEL_CLASS_DECL_P (GET_CPC()))
6038         {
6039           parse_error_context (cl, "Inner class `%s' can't be static. Static classes can only occur in interfaces and top-level classes", 
6040                                IDENTIFIER_POINTER (qualified_name));
6041           sca = ACC_STATIC;
6042         }
6043       /* Else, in the context of a top-level class declaration, let
6044          `check_modifiers' do its job, otherwise, give it a go */
6045       else
6046         sca = (GET_CPC_LIST () ? ACC_STATIC : 0);
6047     }
6048
6049   /* Inner classes and interfaces can be declared private or protected
6050      within their enclosing classes. */
6051   if (CPC_INNER_P ())
6052     {
6053       /* A class which is local to a block can't be public, private,
6054          protected or static. But it is created final, so allow this
6055          one. */
6056       if (current_function_decl)
6057         icaf = sca = uaaf = ACC_FINAL;
6058       else
6059         {
6060           check_modifiers_consistency (flags);
6061           icaf = ACC_PRIVATE|ACC_PROTECTED;
6062         }
6063     }
6064
6065   if (is_interface)
6066     check_modifiers ("Illegal modifier `%s' for interface declaration",
6067                      flags, INTERFACE_MODIFIERS);
6068   else
6069     check_modifiers ("Illegal modifier `%s' for class declaration",
6070                      flags, uaaf|sca|icaf);
6071   return 0;
6072 }
6073
6074 static void
6075 make_nested_class_name (cpc_list)
6076      tree cpc_list;
6077 {
6078   tree name;
6079
6080   if (!cpc_list)
6081     return;
6082   else
6083     make_nested_class_name (TREE_CHAIN (cpc_list));
6084
6085   /* Pick the qualified name when dealing with the first upmost
6086      enclosing class */
6087   name = (TREE_CHAIN (cpc_list) ? 
6088           TREE_PURPOSE (cpc_list) : DECL_NAME (TREE_VALUE (cpc_list)));
6089   obstack_grow (&temporary_obstack,
6090                 IDENTIFIER_POINTER (name), IDENTIFIER_LENGTH (name));
6091   /* Why is NO_DOLLAR_IN_LABEL defined? */
6092 #if 0
6093 #ifdef NO_DOLLAR_IN_LABEL
6094   fatal ("make_nested_class_name: Can't use '$' as a separator "
6095          "for inner classes");
6096 #endif
6097 #endif
6098   obstack_1grow (&temporary_obstack, '$');
6099 }
6100
6101 /* Can't redefine a class already defined in an earlier scope. */
6102
6103 static int
6104 check_inner_class_redefinition (raw_name, cl)
6105      tree raw_name, cl;
6106 {
6107   tree scope_list;
6108
6109   for (scope_list = GET_CPC_LIST (); scope_list; 
6110        scope_list = GET_NEXT_ENCLOSING_CPC (scope_list))
6111     if (raw_name == GET_CPC_UN_NODE (scope_list))
6112       {
6113         parse_error_context 
6114           (cl, "The class name `%s' is already defined in this scope. An inner class may not have the same simple name as any of its enclosing classes",
6115            IDENTIFIER_POINTER (raw_name));
6116         return 1;
6117       }
6118   return 0;
6119 }
6120
6121 static tree
6122 find_as_inner_class (enclosing, name, cl)
6123      tree enclosing, name, cl;
6124 {
6125   tree qual, to_return;
6126   if (!enclosing)
6127     return NULL_TREE;
6128
6129   name = TYPE_NAME (name);
6130
6131   /* First search: within the scope of `enclosing', search for name */
6132   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6133     qual = EXPR_WFL_QUALIFICATION (cl);
6134   else if (cl)
6135     qual = build_tree_list (cl, NULL_TREE);
6136   else
6137     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6138   
6139   if ((to_return = find_as_inner_class_do (qual, enclosing)))
6140     return to_return;
6141
6142   /* We're dealing with a qualified name. Try to resolve thing until
6143      we get something that is an enclosing class. */
6144   if (QUALIFIED_P (name) && cl && EXPR_WFL_NODE (cl) == name)
6145     {
6146       tree acc = NULL_TREE, decl = NULL_TREE, ptr;
6147
6148       for(qual = EXPR_WFL_QUALIFICATION (cl); qual && !decl; 
6149           qual = TREE_CHAIN (qual))
6150         {
6151           acc = merge_qualified_name (acc, 
6152                                       EXPR_WFL_NODE (TREE_PURPOSE (qual)));
6153           BUILD_PTR_FROM_NAME (ptr, acc);
6154           decl = do_resolve_class (NULL_TREE, ptr, NULL_TREE, cl);
6155         }
6156
6157       /* A NULL qual and a decl means that the search ended
6158          successfully?!? We have to do something then. FIXME */
6159       
6160       if (decl)
6161         enclosing = decl;
6162       else
6163         qual = EXPR_WFL_QUALIFICATION (cl);
6164     }
6165   /* Otherwise, create a qual for the other part of the resolution. */
6166   else
6167     qual = build_tree_list (build_expr_wfl (name, NULL, 0, 0), NULL_TREE);
6168
6169   return find_as_inner_class_do (qual, enclosing);
6170 }
6171
6172 /* We go inside the list of sub classes and try to find a way
6173    through. */
6174
6175 static tree
6176 find_as_inner_class_do (qual, enclosing)
6177      tree qual, enclosing;
6178 {
6179   if (!qual)
6180     return NULL_TREE;
6181
6182   for (; qual && enclosing; qual = TREE_CHAIN (qual))
6183     {
6184       tree name_to_match = EXPR_WFL_NODE (TREE_PURPOSE (qual));
6185       tree next_enclosing = NULL_TREE;
6186       tree inner_list;
6187
6188       for (inner_list = DECL_INNER_CLASS_LIST (enclosing);
6189            inner_list; inner_list = TREE_CHAIN (inner_list))
6190         {
6191           if (TREE_VALUE (inner_list) == name_to_match)
6192             {
6193               next_enclosing = TREE_PURPOSE (inner_list);
6194               break;
6195             }
6196         }
6197       enclosing = next_enclosing;
6198     }
6199
6200   return (!qual && enclosing ? enclosing : NULL_TREE);
6201 }
6202
6203 /* Reach all inner classes and tie their unqualified name to a
6204    DECL. */
6205
6206 static void
6207 set_nested_class_simple_name_value (outer, set)
6208      tree outer;
6209      int set;
6210 {
6211   tree l;
6212
6213   for (l = DECL_INNER_CLASS_LIST (outer); l; l = TREE_CHAIN (l))
6214     IDENTIFIER_GLOBAL_VALUE (TREE_VALUE (l)) = (set ? 
6215                                                 TREE_PURPOSE (l) : NULL_TREE);
6216 }
6217
6218 static void
6219 link_nested_class_to_enclosing ()
6220 {
6221   if (GET_ENCLOSING_CPC ())
6222     {
6223       tree enclosing = GET_ENCLOSING_CPC_CONTEXT ();
6224       DECL_INNER_CLASS_LIST (enclosing) = 
6225         tree_cons (GET_CPC (), GET_CPC_UN (),
6226                    DECL_INNER_CLASS_LIST (enclosing));
6227       enclosing = enclosing;
6228     }
6229 }
6230
6231 static tree
6232 maybe_make_nested_class_name (name)
6233      tree name;
6234 {
6235   tree id = NULL_TREE;
6236
6237   if (CPC_INNER_P ())
6238     {
6239       make_nested_class_name (GET_CPC_LIST ());
6240       obstack_grow0 (&temporary_obstack,
6241                      IDENTIFIER_POINTER (name), 
6242                      IDENTIFIER_LENGTH (name));
6243       id = get_identifier (obstack_finish (&temporary_obstack));
6244       if (ctxp->package)
6245         QUALIFIED_P (id) = 1;
6246     }
6247   return id;
6248 }
6249
6250 /* If DECL is NULL, create and push a new DECL, record the current
6251    line CL and do other maintenance things.  */
6252
6253 static tree
6254 maybe_create_class_interface_decl (decl, raw_name, qualified_name, cl)
6255      tree decl, raw_name, qualified_name, cl;
6256 {
6257   if (!decl)
6258     decl = push_class (make_class (), qualified_name);
6259
6260   /* Take care of the file and line business */
6261   DECL_SOURCE_FILE (decl) = EXPR_WFL_FILENAME (cl);
6262   /* If we're emiting xrefs, store the line/col number information */
6263   if (flag_emit_xref)
6264     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (cl);
6265   else
6266     DECL_SOURCE_LINE (decl) = EXPR_WFL_LINENO (cl);
6267   CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) = 1;
6268   CLASS_FROM_CURRENTLY_COMPILED_SOURCE_P (TREE_TYPE (decl)) =
6269     IS_A_COMMAND_LINE_FILENAME_P (EXPR_WFL_FILENAME_NODE (cl));
6270
6271   PUSH_CPC (decl, raw_name);
6272   DECL_CONTEXT (decl) = GET_ENCLOSING_CPC_CONTEXT ();
6273
6274   /* Link the declaration to the already seen ones */
6275   TREE_CHAIN (decl) = ctxp->class_list;
6276   ctxp->class_list = decl;
6277
6278   /* Create a new nodes in the global lists */
6279   ctxp->gclass_list = tree_cons (NULL_TREE, decl, ctxp->gclass_list);
6280   all_class_list = tree_cons (NULL_TREE, decl, all_class_list);
6281
6282   /* Install a new dependency list element */
6283   create_jdep_list (ctxp);
6284
6285   SOURCE_FRONTEND_DEBUG (("Defining class/interface %s", 
6286                           IDENTIFIER_POINTER (qualified_name)));
6287   return decl;
6288 }
6289
6290 static void
6291 add_superinterfaces (decl, interface_list)
6292      tree decl, interface_list;
6293 {
6294   tree node;
6295   /* Superinterface(s): if present and defined, parser_check_super_interface ()
6296      takes care of ensuring that:
6297        - This is an accessible interface type,
6298        - Circularity detection.
6299    parser_add_interface is then called. If present but not defined,
6300    the check operation is delayed until the super interface gets
6301    defined.  */
6302   for (node = interface_list; node; node = TREE_CHAIN (node))
6303     {
6304       tree current = TREE_PURPOSE (node);
6305       tree idecl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (current));
6306       if (idecl && CLASS_LOADED_P (TREE_TYPE (idecl)))
6307         {
6308           if (!parser_check_super_interface (idecl, decl, current))
6309             parser_add_interface (decl, idecl, current);
6310         }
6311       else
6312         register_incomplete_type (JDEP_INTERFACE,
6313                                   current, decl, NULL_TREE);
6314     }
6315 }
6316
6317 /* Create an interface in pass1 and return its decl. Return the
6318    interface's decl in pass 2.  */
6319
6320 static tree
6321 create_interface (flags, id, super)
6322      int flags;
6323      tree id, super;
6324 {
6325   tree raw_name = EXPR_WFL_NODE (id);
6326   tree q_name = parser_qualified_classname (flags & ACC_STATIC, raw_name);
6327   tree decl = IDENTIFIER_CLASS_VALUE (q_name);
6328
6329   EXPR_WFL_NODE (id) = q_name;  /* Keep source location, even if refined. */
6330
6331   /* Basic checks: scope, redefinition, modifiers */ 
6332   if (check_class_interface_creation (1, flags, raw_name, q_name, decl, id))
6333     {
6334       PUSH_ERROR ();
6335       return NULL_TREE;
6336     }
6337
6338   /* Suspend the current parsing context if we're parsing an inner
6339      interface */
6340   if (CPC_INNER_P ())
6341     java_parser_context_suspend ();
6342
6343   /* Push a new context for (static) initialized upon declaration fields */
6344   java_parser_context_push_initialized_field ();
6345
6346   /* Interface modifiers check
6347        - public/abstract allowed (already done at that point)
6348        - abstract is obsolete (comes first, it's a warning, or should be)
6349        - Can't use twice the same (checked in the modifier rule) */
6350   if ((flags & ACC_ABSTRACT) && flag_redundant)
6351     parse_warning_context 
6352       (MODIFIER_WFL (ABSTRACT_TK),
6353        "Redundant use of `abstract' modifier. Interface `%s' is implicitely abstract", IDENTIFIER_POINTER (raw_name));
6354
6355   /* Create a new decl if DECL is NULL, otherwise fix it */
6356   decl = maybe_create_class_interface_decl (decl, raw_name, q_name, id);
6357
6358   /* Set super info and mark the class a complete */
6359   set_super_info (ACC_INTERFACE | flags, TREE_TYPE (decl), 
6360                   object_type_node, ctxp->interface_number);
6361   ctxp->interface_number = 0;
6362   CLASS_COMPLETE_P (decl) = 1;
6363   add_superinterfaces (decl, super);
6364
6365   return decl;
6366 }
6367
6368 /* Anonymous class counter. Will be reset to 1 every time a non
6369    anonymous class gets created. */
6370 static int anonymous_class_counter = 1;
6371
6372 /* Patch anonymous class CLASS, by either extending or implementing
6373    DEP.  */
6374
6375 static void
6376 patch_anonymous_class (type_decl, class_decl, wfl)
6377     tree type_decl, class_decl, wfl;
6378 {
6379   tree class = TREE_TYPE (class_decl);
6380   tree type =  TREE_TYPE (type_decl);
6381   tree binfo = TYPE_BINFO (class);
6382
6383   /* If it's an interface, implement it */
6384   if (CLASS_INTERFACE (type_decl))
6385     {
6386       tree s_binfo;
6387       int length;
6388
6389       if (parser_check_super_interface (type_decl, class_decl, wfl))
6390         return;
6391
6392       s_binfo = TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0);
6393       length = TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (class))+1;
6394       TYPE_BINFO_BASETYPES (class) = make_tree_vec (length);
6395       TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO (class)), 0) = s_binfo;
6396       /* And add the interface */
6397       parser_add_interface (class_decl, type_decl, wfl);
6398     }
6399   /* Otherwise, it's a type we want to extend */
6400   else
6401     {
6402       if (parser_check_super (type_decl, class_decl, wfl))
6403         return;
6404       BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), 0)) = type;
6405     }
6406 }
6407
6408 static tree
6409 create_anonymous_class (location, type_name)
6410     int location;
6411     tree type_name;
6412 {
6413   char buffer [80];
6414   tree super = NULL_TREE, itf = NULL_TREE;
6415   tree id, type_decl, class;
6416
6417   /* The unqualified name of the anonymous class. It's just a number. */
6418   sprintf (buffer, "%d", anonymous_class_counter++);
6419   id = build_wfl_node (get_identifier (buffer));
6420   EXPR_WFL_LINECOL (id) = location;
6421
6422   /* We know about the type to extend/implement. We go ahead */
6423   if ((type_decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (type_name))))
6424     {
6425       /* Create a class which either implements on extends the designated
6426          class. The class bears an innacessible name. */
6427       if (CLASS_INTERFACE (type_decl))
6428         {
6429           /* It's OK to modify it here. It's been already used and
6430              shouldn't be reused */
6431           ctxp->interface_number = 1;
6432           /* Interfaces should presented as a list of WFLs */
6433           itf = build_tree_list (type_name, NULL_TREE);
6434         }
6435       else
6436         super = type_name;
6437     }
6438
6439   class = create_class (ACC_FINAL, id, super, itf);
6440
6441   /* We didn't know anything about the stuff. We register a dependence. */
6442   if (!type_decl)
6443     register_incomplete_type (JDEP_ANONYMOUS, type_name, class, NULL_TREE);
6444
6445   ANONYMOUS_CLASS_P (TREE_TYPE (class)) = 1;
6446   return class;
6447 }
6448
6449 /* Create an class in pass1 and return its decl. Return class
6450    interface's decl in pass 2.  */
6451
6452 static tree
6453 create_class (flags, id, super, interfaces)
6454      int flags;
6455      tree id, super, interfaces;
6456 {
6457   tree raw_name = EXPR_WFL_NODE (id);
6458   tree class_id, decl;
6459   tree super_decl_type;
6460
6461   class_id = parser_qualified_classname (0, raw_name);
6462   decl = IDENTIFIER_CLASS_VALUE (class_id);
6463   EXPR_WFL_NODE (id) = class_id;
6464
6465   /* Basic check: scope, redefinition, modifiers */
6466   if (check_class_interface_creation (0, flags, raw_name, class_id, decl, id))
6467     {
6468       PUSH_ERROR ();
6469       return NULL_TREE;
6470     }
6471   
6472   /* Suspend the current parsing context if we're parsing an inner
6473      class or an anonymous class. */
6474   if (CPC_INNER_P ())
6475     java_parser_context_suspend ();
6476   /* Push a new context for (static) initialized upon declaration fields */
6477   java_parser_context_push_initialized_field ();
6478
6479   /* Class modifier check: 
6480        - Allowed modifier (already done at that point)
6481        - abstract AND final forbidden 
6482        - Public classes defined in the correct file */
6483   if ((flags & ACC_ABSTRACT) && (flags & ACC_FINAL))
6484     parse_error_context
6485       (id, "Class `%s' can't be declared both abstract and final",
6486        IDENTIFIER_POINTER (raw_name));
6487
6488   /* Create a new decl if DECL is NULL, otherwise fix it */
6489   decl = maybe_create_class_interface_decl (decl, raw_name, class_id, id);
6490
6491   /* If SUPER exists, use it, otherwise use Object */
6492   if (super)
6493     {
6494       /* Can't extend java.lang.Object */
6495       if (TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_id)) == object_type_node)
6496         {
6497           parse_error_context (id, "Can't extend `java.lang.Object'");
6498           return NULL_TREE;
6499         }
6500
6501       super_decl_type = 
6502         register_incomplete_type (JDEP_SUPER, super, decl, NULL_TREE);
6503     }
6504   else if (TREE_TYPE (decl) != object_type_node)
6505     super_decl_type = object_type_node;
6506   /* We're defining java.lang.Object */
6507   else
6508     super_decl_type = NULL_TREE;
6509
6510   /* Set super info and mark the class a complete */
6511   set_super_info (flags, TREE_TYPE (decl), super_decl_type, 
6512                   ctxp->interface_number);
6513   ctxp->interface_number = 0;
6514   CLASS_COMPLETE_P (decl) = 1;
6515   add_superinterfaces (decl, interfaces);
6516
6517   /* If the class is a top level inner class, install an alias. */
6518   if (INNER_CLASS_DECL_P (decl) && CLASS_STATIC (decl))
6519     {
6520       tree alias = parser_qualified_classname (1, raw_name);
6521       IDENTIFIER_GLOBAL_VALUE (alias) = decl;
6522     }
6523
6524   /* Add the private this$<n> field, Replicate final locals still in
6525      scope as private final fields mangled like val$<local_name>.
6526      This doesn't not occur for top level (static) inner classes. */
6527   if (PURE_INNER_CLASS_DECL_P (decl))
6528     add_inner_class_fields (decl, current_function_decl);
6529
6530   /* If doing xref, store the location at which the inherited class
6531      (if any) was seen. */
6532   if (flag_emit_xref && super)
6533     DECL_INHERITED_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (super);
6534
6535   /* Eventually sets the @deprecated tag flag */
6536   CHECK_DEPRECATED (decl);
6537
6538   /* Reset the anonymous class counter when declaring non inner classes */
6539   if (!INNER_CLASS_DECL_P (decl))
6540     anonymous_class_counter = 1;
6541
6542   return decl;
6543 }
6544
6545 /* End a class declaration: register the statements used to create
6546    $finit$ and <clinit>, pop the current class and resume the prior
6547    parser context if necessary.  */
6548
6549 static void
6550 end_class_declaration (resume)
6551      int resume;
6552 {
6553   /* If an error occured, context weren't pushed and won't need to be
6554      popped by a resume. */
6555   int no_error_occured = ctxp->next && GET_CPC () != error_mark_node;
6556
6557   java_parser_context_pop_initialized_field ();
6558   POP_CPC ();
6559   if (resume && no_error_occured)
6560     java_parser_context_resume ();
6561 }
6562
6563 static void
6564 add_inner_class_fields (class_decl, fct_decl)
6565      tree class_decl;
6566      tree fct_decl;
6567 {
6568   tree block, marker, f;
6569
6570   f = add_field (TREE_TYPE (class_decl),
6571                  build_current_thisn (TREE_TYPE (class_decl)),
6572                  build_pointer_type (TREE_TYPE (DECL_CONTEXT (class_decl))), 
6573                  ACC_PRIVATE);
6574   FIELD_THISN (f) = 1;
6575
6576   if (!fct_decl)
6577     return;
6578     
6579   for (block = GET_CURRENT_BLOCK (fct_decl); 
6580        block && TREE_CODE (block) == BLOCK; block = BLOCK_SUPERCONTEXT (block))
6581     {
6582       tree decl;
6583       for (decl = BLOCK_EXPR_DECLS (block); decl; decl = TREE_CHAIN (decl))
6584         {
6585           char *name, *pname;
6586           tree wfl, init, list;
6587           
6588           /* Avoid non final arguments. */
6589           if (!LOCAL_FINAL (decl))
6590             continue;
6591           
6592           MANGLE_OUTER_LOCAL_VARIABLE_NAME (name, DECL_NAME (decl));
6593           MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_ID (pname, DECL_NAME (decl));
6594           wfl = build_wfl_node (get_identifier (name));
6595           init = build_wfl_node (get_identifier (pname));
6596           /* Build an initialization for the field: it will be
6597              initialized by a parameter added to $finit$, bearing a
6598              mangled name of the field itself (param$<n>.) The
6599              parameter is provided to $finit$ by the constructor
6600              invoking it (hence the constructor will also feature a
6601              hidden parameter, set to the value of the outer context
6602              local at the time the inner class is created.)
6603              
6604              Note: we take into account all possible locals that can
6605              be accessed by the inner class. It's actually not trivial
6606              to minimize these aliases down to the ones really
6607              used. One way to do that would be to expand all regular
6608              methods first, then $finit$ to get a picture of what's
6609              used.  It works with the exception that we would have to
6610              go back on all constructor invoked in regular methods to
6611              have their invokation reworked (to include the right amount
6612              of alias initializer parameters.)
6613
6614              The only real way around, I think, is a first pass to
6615              identify locals really used in the inner class. We leave
6616              the flag FIELD_LOCAL_ALIAS_USED around for that future
6617              use.
6618              
6619              On the other hand, it only affect local inner classes,
6620              whose constructors (and $finit$ call) will be featuring
6621              unecessary arguments. It's easy for a developper to keep
6622              this number of parameter down by using the `final'
6623              keyword only when necessary. For the time being, we can
6624              issue a warning on unecessary finals. FIXME */
6625           init = build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (wfl), 
6626                                    wfl, init);
6627
6628           /* Register the field. The TREE_LIST holding the part
6629              initialized/initializer will be marked ARG_FINAL_P so
6630              that the created field can be marked
6631              FIELD_LOCAL_ALIAS. */
6632           list = build_tree_list (wfl, init);
6633           ARG_FINAL_P (list) = 1;
6634           register_fields (ACC_PRIVATE | ACC_FINAL, TREE_TYPE (decl), list);
6635         }
6636     }
6637
6638   if (!CPC_INITIALIZER_STMT (ctxp))
6639     return;
6640
6641   /* If we ever registered an alias field, insert and marker to
6642      remeber where the list ends. The second part of the list (the one
6643      featuring initialized fields) so it can be later reversed to
6644      enforce 8.5. The marker will be removed during that operation. */
6645   marker = build_tree_list (NULL_TREE, NULL_TREE);
6646   TREE_CHAIN (marker) = CPC_INITIALIZER_STMT (ctxp);
6647   SET_CPC_INITIALIZER_STMT (ctxp, marker);
6648 }
6649
6650 /* Can't use lookup_field () since we don't want to load the class and
6651    can't set the CLASS_LOADED_P flag */
6652
6653 static tree
6654 find_field (class, name)
6655      tree class;
6656      tree name;
6657 {
6658   tree decl;
6659   for (decl = TYPE_FIELDS (class); decl; decl = TREE_CHAIN (decl))
6660     {
6661       if (DECL_NAME (decl) == name)
6662         return decl;
6663     }
6664   return NULL_TREE;
6665 }
6666
6667 /* Wrap around lookup_field that doesn't potentially upset the value
6668    of CLASS */
6669
6670 static tree
6671 lookup_field_wrapper (class, name)
6672      tree class, name;
6673 {
6674   tree type = class;
6675   tree decl;
6676   java_parser_context_save_global ();
6677   decl = lookup_field (&type, name);
6678   java_parser_context_restore_global ();
6679   return decl == error_mark_node ? NULL : decl;
6680 }
6681
6682 /* Find duplicate field within the same class declarations and report
6683    the error. Returns 1 if a duplicated field was found, 0
6684    otherwise.  */
6685
6686 static int
6687 duplicate_declaration_error_p (new_field_name, new_type, cl)
6688      tree new_field_name, new_type, cl;
6689 {
6690   /* This might be modified to work with method decl as well */
6691   tree decl = find_field (TREE_TYPE (GET_CPC ()), new_field_name);
6692   if (decl)
6693     {
6694       char *t1 = xstrdup (purify_type_name
6695                          ((TREE_CODE (new_type) == POINTER_TYPE 
6696                            && TREE_TYPE (new_type) == NULL_TREE) ?
6697                           IDENTIFIER_POINTER (TYPE_NAME (new_type)) :
6698                           lang_printable_name (new_type, 1)));
6699       /* The type may not have been completed by the time we report
6700          the error */
6701       char *t2 = xstrdup (purify_type_name
6702                          ((TREE_CODE (TREE_TYPE (decl)) == POINTER_TYPE 
6703                            && TREE_TYPE (TREE_TYPE (decl)) == NULL_TREE) ?
6704                           IDENTIFIER_POINTER (TYPE_NAME (TREE_TYPE (decl))) :
6705                           lang_printable_name (TREE_TYPE (decl), 1)));
6706       parse_error_context 
6707         (cl , "Duplicate variable declaration: `%s %s' was `%s %s' (%s:%d)", 
6708          t1, IDENTIFIER_POINTER (new_field_name),
6709          t2, IDENTIFIER_POINTER (DECL_NAME (decl)),
6710          DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
6711       free (t1);
6712       free (t2);
6713       return 1;
6714     }
6715   return 0;
6716 }
6717
6718 /* Field registration routine. If TYPE doesn't exist, field
6719    declarations are linked to the undefined TYPE dependency list, to
6720    be later resolved in java_complete_class () */
6721
6722 static void
6723 register_fields (flags, type, variable_list)
6724      int flags;
6725      tree type, variable_list;
6726 {
6727   tree current, saved_type;
6728   tree class_type = NULL_TREE;
6729   int saved_lineno = lineno;
6730   int must_chain = 0;
6731   tree wfl = NULL_TREE;
6732
6733   if (GET_CPC ())
6734     class_type = TREE_TYPE (GET_CPC ());
6735
6736   if (!class_type || class_type == error_mark_node)
6737     return;
6738
6739   /* If we're adding fields to interfaces, those fields are public,
6740      static, final */
6741   if (CLASS_INTERFACE (TYPE_NAME (class_type)))
6742     {
6743       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (PUBLIC_TK),
6744                                  flags, ACC_PUBLIC, "interface field(s)");
6745       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (STATIC_TK),
6746                                  flags, ACC_STATIC, "interface field(s)");
6747       OBSOLETE_MODIFIER_WARNING (MODIFIER_WFL (FINAL_TK),
6748                                  flags, ACC_FINAL, "interface field(s)");
6749       check_modifiers ("Illegal interface member modifier `%s'", flags,
6750                        INTERFACE_FIELD_MODIFIERS);
6751       flags |= (ACC_PUBLIC | ACC_STATIC | ACC_FINAL);
6752     }
6753
6754   /* Obtain a suitable type for resolution, if necessary */
6755   SET_TYPE_FOR_RESOLUTION (type, wfl, must_chain);
6756
6757   /* If TYPE is fully resolved and we don't have a reference, make one */
6758   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6759
6760   for (current = variable_list, saved_type = type; current; 
6761        current = TREE_CHAIN (current), type = saved_type)
6762     {
6763       tree real_type;
6764       tree field_decl;
6765       tree cl = TREE_PURPOSE (current);
6766       tree init = TREE_VALUE (current);
6767       tree current_name = EXPR_WFL_NODE (cl);
6768
6769       /* Can't declare static fields in inner classes */
6770       if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (class_type)
6771           && !CLASS_INTERFACE (TYPE_NAME (class_type)))
6772         parse_error_context 
6773           (cl, "Field `%s' can't be static in innerclass `%s'. Only members of interfaces and top-level classes can be static",
6774            IDENTIFIER_POINTER (EXPR_WFL_NODE (cl)),
6775            lang_printable_name (class_type, 0));
6776
6777       /* Process NAME, as it may specify extra dimension(s) for it */
6778       type = build_array_from_name (type, wfl, current_name, &current_name);
6779
6780       /* Type adjustment. We may have just readjusted TYPE because
6781          the variable specified more dimensions. Make sure we have
6782          a reference if we can and don't have one already. Also
6783          change the name if we have an init. */
6784       if (type != saved_type)
6785         {
6786           PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
6787           if (init)
6788             EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = current_name;
6789         }
6790
6791       real_type = GET_REAL_TYPE (type);
6792       /* Check for redeclarations */
6793       if (duplicate_declaration_error_p (current_name, real_type, cl))
6794         continue;
6795
6796       /* Set lineno to the line the field was found and create a
6797          declaration for it. Eventually sets the @deprecated tag flag. */
6798       if (flag_emit_xref)
6799         lineno = EXPR_WFL_LINECOL (cl);
6800       else
6801         lineno = EXPR_WFL_LINENO (cl);
6802       field_decl = add_field (class_type, current_name, real_type, flags);
6803       CHECK_DEPRECATED (field_decl);
6804
6805       /* If the couple initializer/initialized is marked ARG_FINAL_P, we
6806          mark the created field FIELD_LOCAL_ALIAS, so that we can 
6807          hide parameters to this inner class $finit$ and constructors. */
6808       if (ARG_FINAL_P (current))
6809         FIELD_LOCAL_ALIAS (field_decl) = 1;
6810       
6811       /* Check if we must chain. */
6812       if (must_chain)
6813         register_incomplete_type (JDEP_FIELD, wfl, field_decl, type);
6814           
6815       /* If we have an initialization value tied to the field */
6816       if (init)
6817         {
6818           /* The field is declared static */
6819           if (flags & ACC_STATIC)
6820             {
6821               /* We include the field and its initialization part into
6822                  a list used to generate <clinit>. After <clinit> is
6823                  walked, field initializations will be processed and
6824                  fields initialized with known constants will be taken
6825                  out of <clinit> and have their DECL_INITIAL set
6826                  appropriately. */
6827               TREE_CHAIN (init) = CPC_STATIC_INITIALIZER_STMT (ctxp);
6828               SET_CPC_STATIC_INITIALIZER_STMT (ctxp, init);
6829               if (TREE_OPERAND (init, 1) 
6830                   && TREE_CODE (TREE_OPERAND (init, 1)) == NEW_ARRAY_INIT)
6831                 TREE_STATIC (TREE_OPERAND (init, 1)) = 1;
6832             }
6833           /* A non-static field declared with an immediate initialization is
6834              to be initialized in <init>, if any.  This field is remembered
6835              to be processed at the time of the generation of <init>. */
6836           else
6837             {
6838               TREE_CHAIN (init) = CPC_INITIALIZER_STMT (ctxp);
6839               SET_CPC_INITIALIZER_STMT (ctxp, init);
6840             }
6841           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
6842           DECL_INITIAL (field_decl) = TREE_OPERAND (init, 1);
6843         }
6844     }
6845   lineno = saved_lineno;
6846 }
6847
6848 /* Generate $finit$, using the list of initialized fields to populate
6849    its body. $finit$'s parameter(s) list is adjusted to include the
6850    one(s) used to initialized the field(s) caching outer context
6851    local(s). */
6852
6853 static tree
6854 generate_finit (class_type)
6855      tree class_type;
6856 {
6857   int count = 0;
6858   tree list = TYPE_FINIT_STMT_LIST (class_type);
6859   tree mdecl, current, parms;
6860
6861   parms = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION, 
6862                                                   class_type, NULL_TREE, 
6863                                                   &count);
6864   CRAFTED_PARAM_LIST_FIXUP (parms);
6865   mdecl = create_artificial_method (class_type, ACC_PRIVATE, void_type_node,
6866                                     finit_identifier_node, parms);
6867   fix_method_argument_names (parms, mdecl);
6868   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
6869                        mdecl, NULL_TREE);
6870   DECL_FUNCTION_NAP (mdecl) = count;
6871   start_artificial_method_body (mdecl);
6872
6873   for (current = list; current; current = TREE_CHAIN (current))
6874     java_method_add_stmt (mdecl, 
6875                           build_debugable_stmt (EXPR_WFL_LINECOL (current), 
6876                                                 current));
6877   end_artificial_method_body (mdecl);
6878   return mdecl;
6879 }
6880
6881 static void
6882 add_instance_initializer (mdecl)
6883      tree mdecl;
6884 {
6885   tree current;
6886   tree stmt_list = TYPE_II_STMT_LIST (DECL_CONTEXT (mdecl));
6887   tree compound = NULL_TREE;
6888
6889   if (stmt_list)
6890     {
6891       for (current = stmt_list; current; current = TREE_CHAIN (current))
6892         compound = add_stmt_to_compound (compound, NULL_TREE, current);
6893
6894       java_method_add_stmt (mdecl, build1 (INSTANCE_INITIALIZERS_EXPR,
6895                                            NULL_TREE, compound));
6896     }
6897 }
6898
6899 /* Shared accros method_declarator and method_header to remember the
6900    patch stage that was reached during the declaration of the method.
6901    A method DECL is built differently is there is no patch
6902    (JDEP_NO_PATCH) or a patch (JDEP_METHOD or JDEP_METHOD_RETURN)
6903    pending on the currently defined method.  */
6904
6905 static int patch_stage;
6906
6907 /* Check the method declaration and add the method to its current
6908    class.  If the argument list is known to contain incomplete types,
6909    the method is partially added and the registration will be resume
6910    once the method arguments resolved. If TYPE is NULL, we're dealing
6911    with a constructor.  */
6912
6913 static tree
6914 method_header (flags, type, mdecl, throws)
6915      int flags;
6916      tree type, mdecl, throws;
6917 {
6918   tree meth = TREE_VALUE (mdecl);
6919   tree id = TREE_PURPOSE (mdecl);
6920   tree type_wfl = NULL_TREE;
6921   tree meth_name = NULL_TREE;
6922   tree current, orig_arg, this_class = NULL;
6923   int saved_lineno;
6924   int constructor_ok = 0, must_chain;
6925   int count;
6926   
6927   check_modifiers_consistency (flags);
6928
6929   if (GET_CPC ())
6930     this_class = TREE_TYPE (GET_CPC ());
6931
6932   if (!this_class || this_class == error_mark_node)
6933     return NULL_TREE;
6934   
6935   /* There are some forbidden modifiers for an abstract method and its
6936      class must be abstract as well.  */
6937   if (type && (flags & ACC_ABSTRACT))
6938     {
6939       ABSTRACT_CHECK (flags, ACC_PRIVATE, id, "Private");
6940       ABSTRACT_CHECK (flags, ACC_STATIC, id, "Static");
6941       ABSTRACT_CHECK (flags, ACC_FINAL, id, "Final");
6942       ABSTRACT_CHECK (flags, ACC_NATIVE, id, "Native");
6943       ABSTRACT_CHECK (flags, ACC_SYNCHRONIZED,id, "Synchronized");
6944       if (!CLASS_ABSTRACT (TYPE_NAME (this_class))
6945           && !CLASS_INTERFACE (TYPE_NAME (this_class)))
6946         parse_error_context 
6947           (id, "Class `%s' must be declared abstract to define abstract method `%s'", 
6948            IDENTIFIER_POINTER (DECL_NAME (ctxp->current_parsed_class)),
6949            IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
6950     }
6951
6952   /* Things to be checked when declaring a constructor */
6953   if (!type)
6954     {
6955       int ec = java_error_count;
6956       /* 8.6: Constructor declarations: we might be trying to define a
6957          method without specifying a return type. */
6958       if (EXPR_WFL_NODE (id) != GET_CPC_UN ())
6959         parse_error_context 
6960           (id, "Invalid method declaration, return type required");
6961       /* 8.6.3: Constructor modifiers */
6962       else
6963         {
6964           JCONSTRUCTOR_CHECK (flags, ACC_ABSTRACT, id, "abstract");
6965           JCONSTRUCTOR_CHECK (flags, ACC_STATIC, id, "static");
6966           JCONSTRUCTOR_CHECK (flags, ACC_FINAL, id, "final");
6967           JCONSTRUCTOR_CHECK (flags, ACC_NATIVE, id, "native");
6968           JCONSTRUCTOR_CHECK (flags, ACC_SYNCHRONIZED, id, "synchronized");
6969         }
6970       /* If we found error here, we don't consider it's OK to tread
6971          the method definition as a constructor, for the rest of this
6972          function */
6973       if (ec == java_error_count)
6974         constructor_ok = 1;
6975     }
6976
6977   /* Method declared within the scope of an interface are implicitly
6978      abstract and public. Conflicts with other erroneously provided
6979      modifiers are checked right after. */
6980
6981   if (CLASS_INTERFACE (TYPE_NAME (this_class)))
6982     {
6983       /* If FLAGS isn't set because of a modifier, turn the
6984          corresponding modifier WFL to NULL so we issue a warning on
6985          the obsolete use of the modifier */
6986       if (!(flags & ACC_PUBLIC))
6987         MODIFIER_WFL (PUBLIC_TK) = NULL;
6988       if (!(flags & ACC_ABSTRACT))
6989         MODIFIER_WFL (ABSTRACT_TK) = NULL;
6990       flags |= ACC_PUBLIC;
6991       flags |= ACC_ABSTRACT;
6992     }
6993
6994   /* Inner class can't declare static methods */
6995   if ((flags & ACC_STATIC) && !TOPLEVEL_CLASS_TYPE_P (this_class))
6996     {
6997       parse_error_context 
6998         (id, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
6999          IDENTIFIER_POINTER (EXPR_WFL_NODE (id)),
7000          lang_printable_name (this_class, 0));
7001     }
7002
7003   /* Modifiers context reset moved up, so abstract method declaration
7004      modifiers can be later checked.  */
7005
7006   /* Set constructor returned type to void and method name to <init>,
7007      unless we found an error identifier the constructor (in which
7008      case we retain the original name) */
7009   if (!type)
7010     {
7011       type = void_type_node;
7012       if (constructor_ok)
7013         meth_name = init_identifier_node;
7014     }
7015   else
7016     meth_name = EXPR_WFL_NODE (id);
7017
7018   /* Do the returned type resolution and registration if necessary */
7019   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7020
7021   if (meth_name)
7022     type = build_array_from_name (type, type_wfl, meth_name, &meth_name);
7023   EXPR_WFL_NODE (id) = meth_name;
7024   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
7025
7026   if (must_chain)
7027     {
7028       patch_stage = JDEP_METHOD_RETURN;
7029       register_incomplete_type (patch_stage, type_wfl, id, type);
7030       TREE_TYPE (meth) = GET_REAL_TYPE (type);
7031     }
7032   else
7033     TREE_TYPE (meth) = type;
7034
7035   saved_lineno = lineno;
7036   /* When defining an abstract or interface method, the curly
7037      bracket at level 1 doesn't exist because there is no function
7038      body */
7039   lineno = (ctxp->first_ccb_indent1 ? ctxp->first_ccb_indent1 : 
7040             EXPR_WFL_LINENO (id));
7041
7042   /* Remember the original argument list */
7043   orig_arg = TYPE_ARG_TYPES (meth);
7044
7045   if (patch_stage)              /* includes ret type and/or all args */
7046     {
7047       jdep *jdep;
7048       meth = add_method_1 (this_class, flags, meth_name, meth);
7049       /* Patch for the return type */
7050       if (patch_stage == JDEP_METHOD_RETURN)
7051         {
7052           jdep = CLASSD_LAST (ctxp->classd_list);
7053           JDEP_GET_PATCH (jdep) = &TREE_TYPE (TREE_TYPE (meth));
7054         }
7055       /* This is the stop JDEP. METH allows the function's signature
7056          to be computed. */
7057       register_incomplete_type (JDEP_METHOD_END, NULL_TREE, meth, NULL_TREE);
7058     }
7059   else
7060     meth = add_method (this_class, flags, meth_name, 
7061                        build_java_signature (meth));
7062
7063   /* Remember final parameters */
7064   MARK_FINAL_PARMS (meth, orig_arg);
7065
7066   /* Fix the method argument list so we have the argument name
7067      information */
7068   fix_method_argument_names (orig_arg, meth);
7069
7070   /* Register the parameter number and re-install the current line
7071      number */
7072   DECL_MAX_LOCALS (meth) = ctxp->formal_parameter_number+1;
7073   lineno = saved_lineno;
7074
7075   /* Register exception specified by the `throws' keyword for
7076      resolution and set the method decl appropriate field to the list.
7077      Note: the grammar ensures that what we get here are class
7078      types. */
7079   if (throws)
7080     {
7081       throws = nreverse (throws);
7082       for (current = throws; current; current = TREE_CHAIN (current))
7083         {
7084           register_incomplete_type (JDEP_EXCEPTION, TREE_VALUE (current),
7085                                     NULL_TREE, NULL_TREE);
7086           JDEP_GET_PATCH (CLASSD_LAST (ctxp->classd_list)) = 
7087             &TREE_VALUE (current);
7088         }
7089       DECL_FUNCTION_THROWS (meth) = throws;
7090     }
7091
7092   /* We set the DECL_NAME to ID so we can track the location where
7093      the function was declared. This allow us to report
7094      redefinition error accurately. When method are verified,
7095      DECL_NAME is reinstalled properly (using the content of the
7096      WFL node ID) (see check_method_redefinition). We don't do that
7097      when Object is being defined. Constructor <init> names will be
7098      reinstalled the same way. */
7099   if (TREE_TYPE (GET_CPC ()) != object_type_node)
7100     DECL_NAME (meth) = id;
7101
7102   /* Set the flag if we correctly processed a constructor */
7103   if (constructor_ok)
7104     {
7105       DECL_CONSTRUCTOR_P (meth) = 1;
7106       /* Compute and store the number of artificial parameters declared
7107          for this constructor */
7108       for (count = 0, current = TYPE_FIELDS (this_class); current; 
7109            current = TREE_CHAIN (current))
7110         if (FIELD_LOCAL_ALIAS (current))
7111           count++;
7112       DECL_FUNCTION_NAP (meth) = count;
7113     }
7114
7115   /* Eventually set the @deprecated tag flag */
7116   CHECK_DEPRECATED (meth);
7117
7118   /* If doing xref, store column and line number information instead
7119      of the line number only. */
7120   if (flag_emit_xref)
7121     DECL_SOURCE_LINE (meth) = EXPR_WFL_LINECOL (id);
7122
7123   return meth;
7124 }
7125
7126 static void
7127 fix_method_argument_names (orig_arg, meth)
7128     tree orig_arg, meth;
7129 {
7130   tree arg = TYPE_ARG_TYPES (TREE_TYPE (meth));
7131   if (TREE_CODE (TREE_TYPE (meth)) == METHOD_TYPE)
7132     {
7133       TREE_PURPOSE (arg) = this_identifier_node;
7134       arg = TREE_CHAIN (arg);
7135     }
7136   while (orig_arg != end_params_node)
7137     {
7138       TREE_PURPOSE (arg) = TREE_PURPOSE (orig_arg);
7139       orig_arg = TREE_CHAIN (orig_arg);
7140       arg = TREE_CHAIN (arg);
7141     }
7142 }
7143
7144 /* Complete the method declaration with METHOD_BODY.  */
7145
7146 static void
7147 finish_method_declaration (method_body)
7148      tree method_body;
7149 {
7150   int flags;
7151
7152   if (!current_function_decl)
7153     return;
7154
7155   flags = get_access_flags_from_decl (current_function_decl);
7156
7157   /* 8.4.5 Method Body */
7158   if ((flags & ACC_ABSTRACT || flags & ACC_NATIVE) && method_body)
7159     {
7160       tree wfl = DECL_NAME (current_function_decl);
7161       parse_error_context (wfl, 
7162                            "%s method `%s' can't have a body defined",
7163                            (METHOD_NATIVE (current_function_decl) ?
7164                             "Native" : "Abstract"),
7165                            IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7166       method_body = NULL_TREE;
7167     }
7168   else if (!(flags & ACC_ABSTRACT) && !(flags & ACC_NATIVE) && !method_body)
7169     {
7170       tree wfl = DECL_NAME (current_function_decl);
7171       parse_error_context
7172         (wfl, 
7173          "Non native and non abstract method `%s' must have a body defined",
7174          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
7175       method_body = NULL_TREE;
7176     }
7177
7178   if (flag_emit_class_files && method_body 
7179       && TREE_CODE (method_body) == NOP_EXPR 
7180       && TREE_TYPE (current_function_decl) 
7181       && TREE_TYPE (TREE_TYPE (current_function_decl)) == void_type_node)
7182     method_body = build1 (RETURN_EXPR, void_type_node, NULL);
7183     
7184   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (current_function_decl)) = method_body;
7185   maybe_absorb_scoping_blocks ();
7186   /* Exit function's body */
7187   exit_block ();
7188   /* Merge last line of the function with first line, directly in the
7189      function decl. It will be used to emit correct debug info. */
7190   if (!flag_emit_xref)
7191     DECL_SOURCE_LINE_MERGE (current_function_decl, ctxp->last_ccb_indent1);
7192
7193   /* Since function's argument's list are shared, reset the
7194      ARG_FINAL_P parameter that might have been set on some of this
7195      function parameters. */
7196   UNMARK_FINAL_PARMS (current_function_decl);
7197   
7198   /* So we don't have an irrelevant function declaration context for
7199      the next static block we'll see. */
7200   current_function_decl = NULL_TREE;
7201 }
7202
7203 /* Build a an error message for constructor circularity errors.  */
7204
7205 static char *
7206 constructor_circularity_msg (from, to)
7207      tree from, to;
7208 {
7209   static char string [4096];
7210   char *t = xstrdup (lang_printable_name (from, 0));
7211   sprintf (string, "`%s' invokes `%s'", t, lang_printable_name (to, 0));
7212   free (t);
7213   return string;
7214 }
7215
7216 /* Verify a circular call to METH. Return 1 if an error is found, 0
7217    otherwise.  */
7218
7219 static int
7220 verify_constructor_circularity (meth, current)
7221      tree meth, current;
7222 {
7223   static tree list = NULL_TREE;
7224   tree c;
7225   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7226     {
7227       if (TREE_VALUE (c) == meth)
7228         {
7229           char *t;
7230           if (list)
7231             {
7232               tree liste;
7233               list = nreverse (list);
7234               for (liste = list; liste; liste = TREE_CHAIN (liste))
7235                 {
7236                   parse_error_context 
7237                     (TREE_PURPOSE (TREE_PURPOSE (liste)), "%s",
7238                      constructor_circularity_msg
7239                       (TREE_VALUE (liste), TREE_VALUE (TREE_PURPOSE (liste)))); 
7240                   java_error_count--;
7241                 }
7242             }
7243           t = xstrdup (lang_printable_name (meth, 0));
7244           parse_error_context (TREE_PURPOSE (c), 
7245                                "%s: recursive invocation of constructor `%s'",
7246                                constructor_circularity_msg (current, meth), t);
7247           free (t);
7248           list = NULL_TREE;
7249           return 1;
7250         }
7251     }
7252   for (c = DECL_CONSTRUCTOR_CALLS (current); c; c = TREE_CHAIN (c))
7253     {
7254       list = tree_cons (c, current, list);
7255       if (verify_constructor_circularity (meth, TREE_VALUE (c)))
7256         return 1;
7257       list = TREE_CHAIN (list);
7258     }
7259   return 0;
7260 }
7261
7262 /* Check modifiers that can be declared but exclusively */
7263
7264 static void
7265 check_modifiers_consistency (flags)
7266      int flags;
7267 {
7268   int acc_count = 0;
7269   tree cl = NULL_TREE;
7270
7271   THIS_MODIFIER_ONLY (flags, ACC_PUBLIC, PUBLIC_TK, acc_count, cl);
7272   THIS_MODIFIER_ONLY (flags, ACC_PRIVATE, PRIVATE_TK, acc_count, cl);
7273   THIS_MODIFIER_ONLY (flags, ACC_PROTECTED, PROTECTED_TK, acc_count, cl);
7274   if (acc_count > 1)
7275     parse_error_context
7276       (cl, "Inconsistent member declaration.  At most one of `public', `private', or `protected' may be specified");
7277
7278   acc_count = 0;
7279   cl = NULL_TREE;
7280   THIS_MODIFIER_ONLY (flags, ACC_FINAL, FINAL_TK - PUBLIC_TK,
7281                       acc_count, cl);
7282   THIS_MODIFIER_ONLY (flags, ACC_VOLATILE, VOLATILE_TK - PUBLIC_TK,
7283                       acc_count, cl);
7284   if (acc_count > 1)
7285     parse_error_context (cl,
7286                          "Inconsistent member declaration.  At most one of `final' or `volatile' may be specified");
7287 }
7288
7289 /* Check the methode header METH for abstract specifics features */
7290
7291 static void
7292 check_abstract_method_header (meth)
7293      tree meth;
7294 {
7295   int flags = get_access_flags_from_decl (meth);
7296   /* DECL_NAME might still be a WFL node */
7297   tree name = GET_METHOD_NAME (meth);
7298
7299   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (ABSTRACT_TK), flags,
7300                               ACC_ABSTRACT, "abstract method",
7301                               IDENTIFIER_POINTER (name));
7302   OBSOLETE_MODIFIER_WARNING2 (MODIFIER_WFL (PUBLIC_TK), flags, 
7303                               ACC_PUBLIC, "abstract method",
7304                               IDENTIFIER_POINTER (name));
7305
7306   check_modifiers ("Illegal modifier `%s' for interface method",
7307                   flags, INTERFACE_METHOD_MODIFIERS);
7308 }
7309
7310 /* Create a FUNCTION_TYPE node and start augmenting it with the
7311    declared function arguments. Arguments type that can't be resolved
7312    are left as they are, but the returned node is marked as containing
7313    incomplete types.  */
7314
7315 static tree
7316 method_declarator (id, list)
7317      tree id, list;
7318 {
7319   tree arg_types = NULL_TREE, current, node;
7320   tree meth = make_node (FUNCTION_TYPE);
7321   jdep *jdep;
7322
7323   patch_stage = JDEP_NO_PATCH;
7324
7325   /* If we're dealing with an inner class constructor, we hide the
7326      this$<n> decl in the name field of its parameter declaration.  We
7327      also might have to hide the outer context local alias
7328      initializers. Not done when the class is a toplevel class. */
7329   if (PURE_INNER_CLASS_DECL_P (GET_CPC ()) 
7330       && EXPR_WFL_NODE (id) == GET_CPC_UN ())
7331     {
7332       tree aliases_list, type, thisn;
7333       /* First the aliases, linked to the regular parameters */
7334       aliases_list =
7335         build_alias_initializer_parameter_list (AIPL_FUNCTION_DECLARATION, 
7336                                                 TREE_TYPE (GET_CPC ()),
7337                                                 NULL_TREE, NULL);
7338       list = chainon (nreverse (aliases_list), list);
7339
7340       /* Then this$<n> */
7341       type = TREE_TYPE (DECL_CONTEXT (GET_CPC ()));
7342       thisn = build_current_thisn (TYPE_NAME (GET_CPC ()));
7343       list = tree_cons (build_wfl_node (thisn), build_pointer_type (type),
7344                         list);
7345     }
7346   
7347   for (current = list; current; current = TREE_CHAIN (current))
7348     {
7349       int must_chain = 0;
7350       tree wfl_name = TREE_PURPOSE (current);
7351       tree type = TREE_VALUE (current);
7352       tree name = EXPR_WFL_NODE (wfl_name);
7353       tree already, arg_node;
7354       tree type_wfl = NULL_TREE;
7355       tree real_type;
7356
7357       /* Obtain a suitable type for resolution, if necessary */
7358       SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
7359
7360       /* Process NAME, as it may specify extra dimension(s) for it */
7361       type = build_array_from_name (type, type_wfl, name, &name);
7362       EXPR_WFL_NODE (wfl_name) = name;
7363
7364       real_type = GET_REAL_TYPE (type);
7365       if (TREE_CODE (real_type) == RECORD_TYPE)
7366         {
7367           real_type = promote_type (real_type);
7368           if (TREE_CODE (type) == TREE_LIST)
7369             TREE_PURPOSE (type) = real_type;
7370         }
7371
7372       /* Check redefinition */
7373       for (already = arg_types; already; already = TREE_CHAIN (already))
7374         if (TREE_PURPOSE (already) == name)
7375           {
7376             parse_error_context
7377               (wfl_name, "Variable `%s' is used more than once in the argument list of method `%s'",
7378                IDENTIFIER_POINTER (name),
7379                IDENTIFIER_POINTER (EXPR_WFL_NODE (id)));
7380             break;
7381           }
7382
7383       /* If we've an incomplete argument type, we know there is a location
7384          to patch when the type get resolved, later.  */
7385       jdep = NULL;
7386       if (must_chain)
7387         {
7388           patch_stage = JDEP_METHOD;
7389           type = register_incomplete_type (patch_stage, 
7390                                            type_wfl, wfl_name, type);
7391           jdep = CLASSD_LAST (ctxp->classd_list);
7392           JDEP_MISC (jdep) = id;
7393         }
7394
7395       /* The argument node: a name and a (possibly) incomplete type.  */
7396       arg_node = build_tree_list (name, real_type);
7397       /* Remeber arguments declared final. */
7398       ARG_FINAL_P (arg_node) = ARG_FINAL_P (current);
7399       
7400       if (jdep)
7401         JDEP_GET_PATCH (jdep) = &TREE_VALUE (arg_node);
7402       TREE_CHAIN (arg_node) = arg_types;
7403       arg_types = arg_node;
7404     }
7405   TYPE_ARG_TYPES (meth) = chainon (nreverse (arg_types), end_params_node);
7406   node = build_tree_list (id, meth);
7407   return node;
7408 }
7409
7410 static int
7411 unresolved_type_p (wfl, returned)
7412      tree wfl;
7413      tree *returned;
7414      
7415 {
7416   if (TREE_CODE (wfl) == EXPR_WITH_FILE_LOCATION)
7417     {
7418       if (returned)
7419         {
7420           tree decl = IDENTIFIER_CLASS_VALUE (EXPR_WFL_NODE (wfl));
7421           if (decl && current_class && (decl == TYPE_NAME (current_class)))
7422             *returned = TREE_TYPE (decl);
7423           else if (GET_CPC_UN () == EXPR_WFL_NODE (wfl))
7424             *returned = TREE_TYPE (GET_CPC ());
7425           else
7426             *returned = NULL_TREE;
7427         }
7428       return 1;
7429     }
7430   if (returned)
7431     *returned = wfl;
7432   return 0;
7433 }
7434
7435 /* From NAME, build a qualified identifier node using the
7436    qualification from the current package definition. */
7437
7438 static tree
7439 parser_qualified_classname (is_static, name)
7440      int is_static;
7441      tree name;
7442 {
7443   tree nested_class_name;
7444
7445   if (!is_static 
7446       && (nested_class_name = maybe_make_nested_class_name (name)))
7447     return nested_class_name;
7448
7449   if (ctxp->package)
7450     return merge_qualified_name (ctxp->package, name);
7451   else 
7452     return name;
7453 }
7454
7455 /* Called once the type a interface extends is resolved. Returns 0 if
7456    everything is OK.  */
7457
7458 static int
7459 parser_check_super_interface (super_decl, this_decl, this_wfl)
7460      tree super_decl, this_decl, this_wfl;
7461 {
7462   tree super_type = TREE_TYPE (super_decl);
7463
7464   /* Has to be an interface */
7465   if (!CLASS_INTERFACE (super_decl))
7466     {
7467       parse_error_context 
7468         (this_wfl, "Can't use %s `%s' to implement/extend %s `%s'",
7469          (TYPE_ARRAY_P (super_type) ? "array" : "class"),
7470          IDENTIFIER_POINTER (DECL_NAME (super_decl)),
7471          (CLASS_INTERFACE (TYPE_NAME (TREE_TYPE (this_decl))) ? 
7472           "interface" : "class"),
7473          IDENTIFIER_POINTER (DECL_NAME (this_decl)));
7474       return 1;
7475     }
7476
7477   /* Check scope: same package OK, other package: OK if public */
7478   if (check_pkg_class_access (DECL_NAME (super_decl), lookup_cl (this_decl)))
7479     return 1;
7480
7481   SOURCE_FRONTEND_DEBUG (("Completing interface %s with %s",
7482                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7483                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7484   return 0;
7485 }
7486
7487 /* Makes sure that SUPER_DECL is suitable to extend THIS_DECL. Returns
7488    0 if everthing is OK.  */
7489
7490 static int
7491 parser_check_super (super_decl, this_decl, wfl)
7492      tree super_decl, this_decl, wfl;
7493 {
7494   tree super_type = TREE_TYPE (super_decl);
7495
7496   /* SUPER should be a CLASS (neither an array nor an interface) */
7497   if (TYPE_ARRAY_P (super_type) || CLASS_INTERFACE (TYPE_NAME (super_type)))
7498     {
7499       parse_error_context 
7500         (wfl, "Class `%s' can't subclass %s `%s'",
7501          IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7502          (CLASS_INTERFACE (TYPE_NAME (super_type)) ? "interface" : "array"),
7503          IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7504       return 1;
7505     }
7506
7507   if (CLASS_FINAL (TYPE_NAME (super_type)))
7508     {
7509       parse_error_context (wfl, "Can't subclass final classes: %s",
7510                            IDENTIFIER_POINTER (DECL_NAME (super_decl)));
7511       return 1;
7512     }
7513
7514   /* Check scope: same package OK, other package: OK if public */
7515   if (check_pkg_class_access (DECL_NAME (super_decl), wfl))
7516     return 1;
7517   
7518   SOURCE_FRONTEND_DEBUG (("Completing class %s with %s",
7519                           IDENTIFIER_POINTER (DECL_NAME (this_decl)),
7520                           IDENTIFIER_POINTER (DECL_NAME (super_decl))));
7521   return 0;
7522 }
7523
7524 /* Create a new dependency list and link it (in a LIFO manner) to the
7525    CTXP list of type dependency list.  */
7526
7527 static void
7528 create_jdep_list (ctxp)
7529      struct parser_ctxt *ctxp;
7530 {
7531   jdeplist *new = (jdeplist *)xmalloc (sizeof (jdeplist));      
7532   new->first = new->last = NULL;
7533   new->next = ctxp->classd_list;
7534   ctxp->classd_list = new;
7535 }
7536
7537 static jdeplist *
7538 reverse_jdep_list (ctxp)
7539      struct parser_ctxt *ctxp;
7540 {
7541   register jdeplist *prev = NULL, *current, *next;
7542   for (current = ctxp->classd_list; current; current = next)
7543     {
7544       next = current->next;
7545       current->next = prev;
7546       prev = current;
7547     }
7548   return prev;
7549 }
7550
7551 /* Create a fake pointer based on the ID stored in
7552    TYPE_NAME. TYPE_NAME can be a WFL or a incomplete type asking to be
7553    registered again. */
7554
7555 static tree
7556 obtain_incomplete_type (type_name)
7557      tree type_name;
7558 {
7559   tree ptr, name;
7560
7561   if (TREE_CODE (type_name) == EXPR_WITH_FILE_LOCATION)
7562     name = EXPR_WFL_NODE (type_name);
7563   else if (INCOMPLETE_TYPE_P (type_name))
7564     name = TYPE_NAME (type_name);
7565   else
7566     fatal ("invalid type name - obtain_incomplete_type");
7567
7568   for (ptr = ctxp->incomplete_class; ptr; ptr = TREE_CHAIN (ptr))
7569     if (TYPE_NAME (ptr) == name)
7570       break;
7571
7572   if (!ptr)
7573     {
7574       push_obstacks (&permanent_obstack, &permanent_obstack);
7575       BUILD_PTR_FROM_NAME (ptr, name);
7576       layout_type (ptr);
7577       pop_obstacks ();
7578       TREE_CHAIN (ptr) = ctxp->incomplete_class;
7579       ctxp->incomplete_class = ptr;
7580     }
7581
7582   return ptr;
7583 }
7584
7585 /* Register a incomplete type whose name is WFL. Reuse PTR if PTR is
7586    non NULL instead of computing a new fake type based on WFL. The new
7587    dependency is inserted in the current type dependency list, in FIFO
7588    manner.  */
7589
7590 static tree
7591 register_incomplete_type (kind, wfl, decl, ptr)
7592      int kind;
7593      tree wfl, decl, ptr;
7594 {
7595   jdep *new = (jdep *)xmalloc (sizeof (jdep));
7596
7597   if (!ptr && kind != JDEP_METHOD_END) /* JDEP_METHOD_END is a mere marker */
7598     ptr = obtain_incomplete_type (wfl);
7599
7600   JDEP_KIND (new) = kind;
7601   JDEP_DECL (new) = decl;
7602   JDEP_SOLV (new) = ptr;
7603   JDEP_WFL (new) = wfl;
7604   JDEP_CHAIN (new) = NULL;
7605   JDEP_MISC (new) = NULL_TREE;
7606   if ((kind == JDEP_SUPER || kind == JDEP_INTERFACE)
7607       && GET_ENCLOSING_CPC ())
7608     JDEP_ENCLOSING (new) = TREE_VALUE (GET_ENCLOSING_CPC ());
7609   else
7610     JDEP_ENCLOSING (new) = GET_CPC ();
7611   JDEP_GET_PATCH (new) = (tree *)NULL;
7612
7613   JDEP_INSERT (ctxp->classd_list, new);
7614
7615   return ptr;
7616 }
7617
7618 void
7619 java_check_circular_reference ()
7620 {
7621   tree current;
7622   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7623     {
7624       tree type = TREE_TYPE (current);
7625       if (CLASS_INTERFACE (current))
7626         {
7627           /* Check all interfaces this class extends */
7628           tree basetype_vec = TYPE_BINFO_BASETYPES (type);
7629           int n, i;
7630
7631           if (!basetype_vec)
7632             return;
7633           n = TREE_VEC_LENGTH (basetype_vec);
7634           for (i = 0; i < n; i++)
7635             {
7636               tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
7637               if (vec_elt && BINFO_TYPE (vec_elt) != object_type_node 
7638                   && interface_of_p (type, BINFO_TYPE (vec_elt)))
7639                 parse_error_context (lookup_cl (current),
7640                                      "Cyclic interface inheritance");
7641             }
7642         }
7643       else
7644         if (inherits_from_p (CLASSTYPE_SUPER (type), type))
7645           parse_error_context (lookup_cl (current), 
7646                                "Cyclic class inheritance%s",
7647                                (cyclic_inheritance_report ?
7648                                 cyclic_inheritance_report : ""));
7649     }
7650 }
7651
7652 /* Augment the parameter list PARM with parameters crafted to
7653    initialize outer context locals aliases. Through ARTIFICIAL, a
7654    count is kept of the number of crafted parameters. MODE governs
7655    what eventually gets created: something suitable for a function
7656    creation or a function invocation, either the constructor or
7657    $finit$.  */
7658
7659 static tree
7660 build_alias_initializer_parameter_list (mode, class_type, parm, artificial)
7661     int mode;
7662     tree class_type, parm;
7663     int *artificial;
7664 {
7665   tree field;
7666   for (field = TYPE_FIELDS (class_type); field; field = TREE_CHAIN (field))
7667     if (FIELD_LOCAL_ALIAS (field))
7668       {
7669         char *buffer = IDENTIFIER_POINTER (DECL_NAME (field));
7670         tree purpose = NULL_TREE, value = NULL_TREE, name = NULL_TREE;
7671
7672         switch (mode)
7673           {
7674           case AIPL_FUNCTION_DECLARATION:
7675             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7676             purpose = build_wfl_node (get_identifier (buffer));
7677             if (TREE_CODE (TREE_TYPE (field)) == POINTER_TYPE)
7678               value = build_wfl_node (TYPE_NAME (TREE_TYPE (field)));
7679             else
7680               value = TREE_TYPE (field);
7681             break;
7682
7683           case AIPL_FUNCTION_CREATION:
7684             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7685             purpose = get_identifier (buffer);
7686             value = TREE_TYPE (field);
7687             break;
7688
7689           case AIPL_FUNCTION_FINIT_INVOCATION:
7690             MANGLE_ALIAS_INITIALIZER_PARAMETER_NAME_STR (buffer, &buffer [4]);
7691             /* Now, this is wrong. purpose should always be the NAME
7692                of something and value its matching value (decl, type,
7693                etc...) FIXME -- but there is a lot to fix. */
7694
7695             /* When invoked for this kind of operation, we already
7696                know whether a field is used or not. */
7697             purpose = TREE_TYPE (field);
7698             value = build_wfl_node (get_identifier (buffer));
7699             break;
7700
7701           case AIPL_FUNCTION_CTOR_INVOCATION:
7702             /* There are two case: the constructor invokation happends
7703                outside the local inner, in which case, locales from the outer
7704                context are directly used.
7705
7706                Otherwise, we fold to using the alias directly. */
7707             if (class_type == current_class)
7708               value = field;
7709             else
7710               {
7711                 name = get_identifier (&buffer[4]);
7712                 value = IDENTIFIER_LOCAL_VALUE (name);
7713               }
7714             break;
7715           }
7716         parm = tree_cons (purpose, value, parm);
7717         if (artificial)
7718           *artificial +=1;
7719       }
7720   return parm;
7721 }
7722
7723 /* Craft a constructor for CLASS_DECL -- what we should do when none
7724    where found. ARGS is non NULL when a special signature must be
7725    enforced. This is the case for anonymous classes.  */
7726
7727 static void
7728 craft_constructor (class_decl, args)
7729      tree class_decl, args;
7730 {
7731   tree class_type = TREE_TYPE (class_decl);
7732   tree parm = NULL_TREE;
7733   int flags = (get_access_flags_from_decl (class_decl) & ACC_PUBLIC ?
7734                ACC_PUBLIC : 0);
7735   int i = 0, artificial = 0;
7736   tree decl, ctor_name;
7737   char buffer [80];
7738   
7739   push_obstacks (&permanent_obstack, &permanent_obstack);
7740
7741   /* The constructor name is <init> unless we're dealing with an
7742      anonymous class, in which case the name will be fixed after having
7743      be expanded. */
7744   if (ANONYMOUS_CLASS_P (class_type))
7745     ctor_name = DECL_NAME (class_decl);
7746   else
7747     ctor_name = init_identifier_node;
7748
7749   /* If we're dealing with an inner class constructor, we hide the
7750      this$<n> decl in the name field of its parameter declaration. */
7751   if (PURE_INNER_CLASS_TYPE_P (class_type))
7752     {
7753       tree type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class_type)));
7754       parm = tree_cons (build_current_thisn (class_type),
7755                         build_pointer_type (type), parm);
7756
7757       /* Some more arguments to be hidden here. The values of the local
7758          variables of the outer context that the inner class needs to see. */
7759       parm = build_alias_initializer_parameter_list (AIPL_FUNCTION_CREATION,
7760                                                      class_type, parm, 
7761                                                      &artificial);
7762     }
7763
7764   /* Then if there are any args to be enforced, enforce them now */
7765   for (; args && args != end_params_node; args = TREE_CHAIN (args))
7766     {
7767       sprintf (buffer, "parm%d", i++);
7768       parm = tree_cons (get_identifier (buffer), TREE_VALUE (args), parm);
7769     }
7770
7771   CRAFTED_PARAM_LIST_FIXUP (parm);
7772   decl = create_artificial_method (class_type, flags, void_type_node, 
7773                                    ctor_name, parm);
7774   fix_method_argument_names (parm, decl);
7775   /* Now, mark the artificial parameters. */
7776   DECL_FUNCTION_NAP (decl) = artificial;
7777
7778   pop_obstacks ();
7779   DECL_CONSTRUCTOR_P (decl) = 1;
7780 }
7781
7782
7783 /* Fix the constructors. This will be called right after circular
7784    references have been checked. It is necessary to fix constructors
7785    early even if no code generation will take place for that class:
7786    some generated constructor might be required by the class whose
7787    compilation triggered this one to be simply loaded.  */
7788
7789 void
7790 java_fix_constructors ()
7791 {
7792   tree current;
7793
7794   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
7795     {
7796       tree class_type = TREE_TYPE (current);
7797       int saw_ctor = 0;
7798       tree decl;
7799
7800       if (CLASS_INTERFACE (TYPE_NAME (class_type)))
7801         continue;
7802
7803       for (decl = TYPE_METHODS (class_type); decl; decl = TREE_CHAIN (decl))
7804         {
7805           if (DECL_CONSTRUCTOR_P (decl))
7806             {
7807               fix_constructors (decl);
7808               saw_ctor = 1;
7809             }
7810         }
7811
7812       /* Anonymous class constructor can't be generated that early. */
7813       if (!saw_ctor && !ANONYMOUS_CLASS_P (class_type))
7814         craft_constructor (current, NULL_TREE);
7815     }
7816 }
7817
7818 /* safe_layout_class just makes sure that we can load a class without
7819    disrupting the current_class, input_file, lineno, etc, information
7820    about the class processed currently.  */
7821
7822 void
7823 safe_layout_class (class)
7824      tree class;
7825 {
7826   tree save_current_class = current_class;
7827   char *save_input_filename = input_filename;
7828   int save_lineno = lineno;
7829
7830   push_obstacks (&permanent_obstack, &permanent_obstack);
7831
7832   layout_class (class);
7833   pop_obstacks ();
7834
7835   current_class = save_current_class;
7836   input_filename = save_input_filename;
7837   lineno = save_lineno;
7838   CLASS_LOADED_P (class) = 1;
7839 }
7840
7841 static tree
7842 jdep_resolve_class (dep)
7843      jdep *dep;
7844 {
7845   tree decl;
7846
7847   if (JDEP_RESOLVED_P (dep))
7848     decl = JDEP_RESOLVED_DECL (dep);
7849   else
7850     {
7851       decl = resolve_class (JDEP_ENCLOSING (dep), JDEP_TO_RESOLVE (dep),
7852                             JDEP_DECL (dep), JDEP_WFL (dep));
7853       JDEP_RESOLVED (dep, decl);
7854     }
7855     
7856   if (!decl)
7857     complete_class_report_errors (dep);
7858
7859   return decl;
7860 }
7861
7862 /* Complete unsatisfied class declaration and their dependencies */
7863
7864 void
7865 java_complete_class ()
7866 {
7867   tree cclass;
7868   jdeplist *cclassd;
7869   int error_found;
7870   tree type;
7871
7872   push_obstacks (&permanent_obstack, &permanent_obstack);
7873
7874   /* Process imports and reverse the import on demand list */
7875   process_imports ();
7876   if (ctxp->import_demand_list)
7877     ctxp->import_demand_list = nreverse (ctxp->import_demand_list);
7878
7879   /* Rever things so we have the right order */
7880   ctxp->class_list = nreverse (ctxp->class_list);
7881   ctxp->classd_list = reverse_jdep_list (ctxp);
7882
7883   for (cclassd = ctxp->classd_list, cclass = ctxp->class_list; 
7884        cclass && cclassd; 
7885        cclass = TREE_CHAIN (cclass), cclassd = CLASSD_CHAIN (cclassd))
7886     {
7887       jdep *dep;
7888       for (dep = CLASSD_FIRST (cclassd); dep; dep = JDEP_CHAIN (dep))
7889         {
7890           tree decl;
7891           if (!(decl = jdep_resolve_class (dep)))
7892             continue;
7893
7894           /* Now it's time to patch */
7895           switch (JDEP_KIND (dep))
7896             {
7897             case JDEP_SUPER:
7898               /* Simply patch super */
7899               if (parser_check_super (decl, JDEP_DECL (dep), JDEP_WFL (dep)))
7900                 continue;
7901               BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (TYPE_BINFO 
7902                 (TREE_TYPE (JDEP_DECL (dep)))), 0)) = TREE_TYPE (decl);
7903               break;
7904
7905             case JDEP_FIELD:
7906               {
7907                 /* We do part of the job done in add_field */
7908                 tree field_decl = JDEP_DECL (dep);
7909                 tree field_type = TREE_TYPE (decl);
7910                 push_obstacks (&permanent_obstack, &permanent_obstack);
7911                 if (TREE_CODE (field_type) == RECORD_TYPE)
7912                   field_type = promote_type (field_type);
7913                 pop_obstacks ();
7914                 TREE_TYPE (field_decl) = field_type;
7915                 DECL_ALIGN (field_decl) = 0;
7916                 layout_decl (field_decl, 0);
7917                 SOURCE_FRONTEND_DEBUG 
7918                   (("Completed field/var decl `%s' with `%s'",
7919                     IDENTIFIER_POINTER (DECL_NAME (field_decl)),
7920                     IDENTIFIER_POINTER (DECL_NAME (decl))));
7921                 break;
7922               }
7923             case JDEP_METHOD:   /* We start patching a method */
7924             case JDEP_METHOD_RETURN:
7925               error_found = 0;
7926               while (1)
7927                 {
7928                   if (decl)
7929                     {
7930                       type = TREE_TYPE(decl);
7931                       if (TREE_CODE (type) == RECORD_TYPE)
7932                         type = promote_type (type);
7933                       JDEP_APPLY_PATCH (dep, type);
7934                       SOURCE_FRONTEND_DEBUG 
7935                         (((JDEP_KIND (dep) == JDEP_METHOD_RETURN ?
7936                            "Completing fct `%s' with ret type `%s'":
7937                            "Completing arg `%s' with type `%s'"),
7938                           IDENTIFIER_POINTER (EXPR_WFL_NODE 
7939                                               (JDEP_DECL_WFL (dep))),
7940                           IDENTIFIER_POINTER (DECL_NAME (decl))));
7941                     }
7942                   else
7943                     error_found = 1;
7944                   dep = JDEP_CHAIN (dep);
7945                   if (JDEP_KIND (dep) == JDEP_METHOD_END)
7946                     break;
7947                   else
7948                     decl = jdep_resolve_class (dep);
7949                 }
7950               if (!error_found)
7951                 {
7952                   tree mdecl = JDEP_DECL (dep), signature;
7953                   push_obstacks (&permanent_obstack, &permanent_obstack);
7954                   /* Recompute and reset the signature, check first that
7955                      all types are now defined. If they're not,
7956                      dont build the signature. */
7957                   if (check_method_types_complete (mdecl))
7958                     {
7959                       signature = build_java_signature (TREE_TYPE (mdecl));
7960                       set_java_signature (TREE_TYPE (mdecl), signature);
7961                     }
7962                   pop_obstacks ();
7963                 }
7964               else
7965                 continue;
7966               break;
7967
7968             case JDEP_INTERFACE:
7969               if (parser_check_super_interface (decl, JDEP_DECL (dep),
7970                                                 JDEP_WFL (dep)))
7971                 continue;
7972               parser_add_interface (JDEP_DECL (dep), decl, JDEP_WFL (dep));
7973               break;
7974
7975             case JDEP_PARM:
7976             case JDEP_VARIABLE:
7977               type = TREE_TYPE(decl);
7978               if (TREE_CODE (type) == RECORD_TYPE)
7979                 type = promote_type (type);
7980               JDEP_APPLY_PATCH (dep, type);
7981               break;
7982
7983             case JDEP_TYPE:
7984               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7985               SOURCE_FRONTEND_DEBUG 
7986                 (("Completing a random type dependency on a '%s' node",
7987                   tree_code_name [TREE_CODE (JDEP_DECL (dep))]));
7988               break;
7989
7990             case JDEP_EXCEPTION:
7991               JDEP_APPLY_PATCH (dep, TREE_TYPE (decl));
7992               SOURCE_FRONTEND_DEBUG 
7993                 (("Completing `%s' `throws' argument node",
7994                   IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)))));
7995               break;
7996
7997             case JDEP_ANONYMOUS:
7998               patch_anonymous_class (decl, JDEP_DECL (dep), JDEP_WFL (dep));
7999               break;
8000
8001             default:
8002               fatal ("Can't handle patch code %d - java_complete_class",
8003                      JDEP_KIND (dep));
8004             }
8005         }
8006     }
8007   pop_obstacks ();
8008   return;
8009 }
8010
8011 /* Resolve class CLASS_TYPE. Handle the case of trying to resolve an
8012    array.  */
8013
8014 static tree
8015 resolve_class (enclosing, class_type, decl, cl)
8016      tree enclosing, class_type, decl, cl;
8017 {
8018   const char *name = IDENTIFIER_POINTER (TYPE_NAME (class_type));
8019   const char *base = name;
8020   tree resolved_type = TREE_TYPE (class_type);
8021   tree resolved_type_decl;
8022   
8023   if (resolved_type != NULL_TREE)
8024     {
8025       tree resolved_type_decl = TYPE_NAME (resolved_type);
8026       if (resolved_type_decl == NULL_TREE
8027           || TREE_CODE (resolved_type_decl) == IDENTIFIER_NODE)
8028         {
8029           resolved_type_decl = build_decl (TYPE_DECL,
8030                                            TYPE_NAME (class_type),
8031                                            resolved_type);
8032         }
8033       return resolved_type_decl;
8034     }
8035
8036   /* 1- Check to see if we have an array. If true, find what we really
8037      want to resolve  */
8038   while (name[0] == '[')
8039     name++;
8040   if (base != name)
8041     TYPE_NAME (class_type) = get_identifier (name);
8042
8043   /* 2- Resolve the bare type */
8044   if (!(resolved_type_decl = do_resolve_class (enclosing, class_type, 
8045                                                decl, cl)))
8046     return NULL_TREE;
8047   resolved_type = TREE_TYPE (resolved_type_decl);
8048
8049   /* 3- If we have and array, reconstruct the array down to its nesting */
8050   if (base != name)
8051     {
8052       while (base != name)
8053         {
8054           if (TREE_CODE (resolved_type) == RECORD_TYPE)
8055             resolved_type  = promote_type (resolved_type);
8056           resolved_type = build_java_array_type (resolved_type, -1);
8057           CLASS_LOADED_P (resolved_type) = 1;
8058           name--;
8059         }
8060       /* Build a fake decl for this, since this is what is expected to
8061          be returned.  */
8062       resolved_type_decl =
8063         build_decl (TYPE_DECL, TYPE_NAME (resolved_type), resolved_type);
8064       /* Figure how those two things are important for error report. FIXME */
8065       DECL_SOURCE_LINE (resolved_type_decl) = 0;
8066       DECL_SOURCE_FILE (resolved_type_decl) = input_filename;
8067       TYPE_NAME (class_type) = TYPE_NAME (resolved_type);
8068     }
8069   TREE_TYPE (class_type) = resolved_type;
8070   return resolved_type_decl;
8071 }
8072
8073 /* Effectively perform the resolution of class CLASS_TYPE. DECL or CL
8074    are used to report error messages.  */
8075
8076 tree
8077 do_resolve_class (enclosing, class_type, decl, cl)
8078      tree enclosing, class_type, decl, cl;
8079 {
8080   tree new_class_decl;
8081   tree original_name = NULL_TREE;
8082
8083   /* Do not try to replace TYPE_NAME (class_type) by a variable, since
8084      its is changed by find_in_imports{_on_demand} */
8085
8086   /* 0- Search in the current class as an inner class */
8087
8088   /* Maybe some code here should be added to load the class or
8089      something, at least if the class isn't an inner class and ended
8090      being loaded from class file. FIXME. */
8091   if ((new_class_decl = find_as_inner_class (enclosing, class_type, cl)))
8092     return new_class_decl;
8093
8094   /* 1- Check for the type in single imports */
8095   if (find_in_imports (class_type))
8096     return NULL_TREE;
8097
8098   /* 2- And check for the type in the current compilation unit. If it fails,
8099      try with a name qualified with the package name we've seen so far */
8100   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8101     {
8102       if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8103           !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8104         load_class (TYPE_NAME (class_type), 0);
8105       return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8106     }
8107
8108   original_name = TYPE_NAME (class_type);
8109   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8110     {
8111       tree package;
8112       for (package = package_list; package; package = TREE_CHAIN (package))
8113         {
8114           tree new_qualified;
8115           
8116           new_qualified = merge_qualified_name (TREE_PURPOSE (package),
8117                                                 original_name);
8118           TYPE_NAME (class_type) = new_qualified;
8119           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8120           if (!new_class_decl)
8121             load_class (TYPE_NAME (class_type), 0);
8122           new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8123           if (new_class_decl)
8124             {
8125               if (!CLASS_LOADED_P (TREE_TYPE (new_class_decl)) &&
8126                   !CLASS_FROM_SOURCE_P (TREE_TYPE (new_class_decl)))
8127                 load_class (TYPE_NAME (class_type), 0);
8128               return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8129             }
8130         }
8131     }
8132
8133   TYPE_NAME (class_type) = original_name;
8134
8135   /* 3- Check an other compilation unit that bears the name of type */
8136   load_class (TYPE_NAME (class_type), 0);
8137   if (check_pkg_class_access (TYPE_NAME (class_type), 
8138                               (cl ? cl : lookup_cl (decl))))
8139     return NULL_TREE;
8140
8141   if ((new_class_decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type))))
8142     return new_class_decl;
8143
8144   /* 4- Check the import on demands. Don't allow bar.baz to be
8145      imported from foo.* */
8146   if (!QUALIFIED_P (TYPE_NAME (class_type)))
8147     if (find_in_imports_on_demand (class_type))
8148       return NULL_TREE;
8149
8150   /* 5- Last call for a resolution */
8151   return IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
8152 }
8153
8154 /* Resolve NAME and lay it out (if not done and if not the current
8155    parsed class). Return a decl node. This function is meant to be
8156    called when type resolution is necessary during the walk pass.  */
8157
8158 static tree
8159 resolve_and_layout (something, cl)
8160      tree something;
8161      tree cl;
8162 {
8163   tree decl;
8164
8165   /* Don't do that on the current class */
8166   if (something == current_class)
8167     return TYPE_NAME (current_class);
8168
8169   /* Don't do anything for void and other primitive types */
8170   if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8171     return NULL_TREE;
8172
8173   /* Pointer types can be reall pointer types or fake pointers. When
8174      finding a real pointer, recheck for primitive types */
8175   if (TREE_CODE (something) == POINTER_TYPE)
8176     {
8177       if (TREE_TYPE (something))
8178         {
8179           something = TREE_TYPE (something);
8180           if (JPRIMITIVE_TYPE_P (something) || something == void_type_node)
8181             return NULL_TREE;
8182         }
8183       else
8184         something = TYPE_NAME (something);
8185     }
8186
8187   /* Don't do anything for arrays of primitive types */
8188   if (TREE_CODE (something) == RECORD_TYPE && TYPE_ARRAY_P (something)
8189       && JPRIMITIVE_TYPE_P (TYPE_ARRAY_ELEMENT (something)))
8190     return NULL_TREE;
8191
8192   /* Something might be a WFL */
8193   if (TREE_CODE (something) == EXPR_WITH_FILE_LOCATION)
8194     something = EXPR_WFL_NODE (something);
8195
8196   /* Otherwise, if something is not and IDENTIFIER_NODE, it can be a a
8197      TYPE_DECL or a real TYPE */
8198   else if (TREE_CODE (something) != IDENTIFIER_NODE)
8199     something = (TREE_CODE (TYPE_NAME (something)) == TYPE_DECL ?
8200             DECL_NAME (TYPE_NAME (something)) : TYPE_NAME (something));
8201
8202   if (!(decl = resolve_no_layout (something, cl)))
8203     return NULL_TREE;
8204
8205   /* Resolve and layout if necessary */
8206   layout_class_methods (TREE_TYPE (decl));
8207   /* Check methods, but only once */
8208   if (CLASS_FROM_SOURCE_P (TREE_TYPE (decl)) 
8209       && !CLASS_LOADED_P (TREE_TYPE (decl)))
8210     CHECK_METHODS (decl);
8211   if (TREE_TYPE (decl) != current_class && !CLASS_LOADED_P (TREE_TYPE (decl)))
8212     safe_layout_class (TREE_TYPE (decl));
8213
8214   return decl;
8215 }
8216
8217 /* Resolve a class, returns its decl but doesn't perform any
8218    layout. The current parsing context is saved and restored */
8219
8220 static tree
8221 resolve_no_layout (name, cl)
8222      tree name, cl;
8223 {
8224   tree ptr, decl;
8225   BUILD_PTR_FROM_NAME (ptr, name);
8226   java_parser_context_save_global ();
8227   decl = resolve_class (TYPE_NAME (current_class), ptr, NULL_TREE, cl);
8228   java_parser_context_restore_global ();
8229   
8230   return decl;
8231 }
8232
8233 /* Called when reporting errors. Skip leader '[' in a complex array
8234    type description that failed to be resolved.  */
8235
8236 static const char *
8237 purify_type_name (name)
8238      const char *name;
8239 {
8240   while (*name && *name == '[')
8241     name++;
8242   return name;
8243 }
8244
8245 /* The type CURRENT refers to can't be found. We print error messages.  */
8246
8247 static void
8248 complete_class_report_errors (dep)
8249      jdep *dep;
8250 {
8251   const char *name;
8252
8253   if (!JDEP_WFL (dep))
8254     return;
8255
8256   name = IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep)));
8257   switch (JDEP_KIND (dep))
8258     {
8259     case JDEP_SUPER:
8260       parse_error_context  
8261         (JDEP_WFL (dep), "Superclass `%s' of class `%s' not found",
8262          purify_type_name (name),
8263          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8264       break;
8265     case JDEP_FIELD:
8266       parse_error_context
8267         (JDEP_WFL (dep), "Type `%s' not found in declaration of field `%s'",
8268          purify_type_name (name),
8269          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8270       break;
8271     case JDEP_METHOD:           /* Covers arguments */
8272       parse_error_context
8273         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the argument `%s' of method `%s'",
8274          purify_type_name (name),
8275          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))),
8276          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_MISC (dep))));
8277       break;
8278     case JDEP_METHOD_RETURN:    /* Covers return type */
8279       parse_error_context
8280         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the return type of method `%s'", 
8281          purify_type_name (name),
8282          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_DECL_WFL (dep))));
8283       break;
8284     case JDEP_INTERFACE:
8285       parse_error_context
8286         (JDEP_WFL (dep), "Superinterface `%s' of %s `%s' not found",
8287          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))),
8288          (CLASS_OR_INTERFACE (JDEP_DECL (dep), "class", "interface")),
8289          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8290       break;
8291     case JDEP_VARIABLE:
8292       parse_error_context
8293         (JDEP_WFL (dep), "Type `%s' not found in the declaration of the local variable `%s'", 
8294          purify_type_name (IDENTIFIER_POINTER 
8295                            (EXPR_WFL_NODE (JDEP_WFL (dep)))),
8296          IDENTIFIER_POINTER (DECL_NAME (JDEP_DECL (dep))));
8297       break;
8298     case JDEP_EXCEPTION:        /* As specified by `throws' */
8299       parse_error_context 
8300           (JDEP_WFL (dep), "Class `%s' not found in `throws'",
8301          IDENTIFIER_POINTER (EXPR_WFL_NODE (JDEP_WFL (dep))));
8302       break;
8303     default:
8304       /* Fix for -Wall. Just break doing nothing. The error will be
8305          caught later */
8306       break;
8307     }
8308 }
8309
8310 /* Return a static string containing the DECL prototype string. If
8311    DECL is a constructor, use the class name instead of the form
8312    <init> */
8313
8314 static const char *
8315 get_printable_method_name (decl)
8316      tree decl;
8317 {
8318   const char *to_return;
8319   tree name = NULL_TREE;
8320
8321   if (DECL_CONSTRUCTOR_P (decl))
8322     {
8323       name = DECL_NAME (decl);
8324       DECL_NAME (decl) = DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)));
8325     }
8326       
8327   to_return = lang_printable_name (decl, 0);
8328   if (DECL_CONSTRUCTOR_P (decl))
8329     DECL_NAME (decl) = name;
8330   
8331   return to_return;
8332 }
8333
8334 /* Reinstall the proper DECL_NAME on METHOD. Return 0 if the method
8335    nevertheless needs to be verfied, 1 otherwise.  */
8336
8337 static int
8338 reset_method_name (method)
8339      tree method;
8340 {
8341   if (!DECL_CLINIT_P (method) && !DECL_FINIT_P (method))
8342     {
8343       /* NAME is just the plain name when Object is being defined */
8344       if (DECL_CONTEXT (method) != object_type_node)
8345         DECL_NAME (method) = (DECL_CONSTRUCTOR_P (method) ? 
8346                               init_identifier_node : GET_METHOD_NAME (method));
8347       return 0;
8348     }
8349   else 
8350     return 1;
8351 }
8352
8353 /* Return the name of METHOD_DECL, when DECL_NAME is a WFL */
8354
8355 tree
8356 java_get_real_method_name (method_decl)
8357      tree method_decl;
8358 {
8359   tree method_name = DECL_NAME (method_decl);
8360   if (DECL_CONSTRUCTOR_P (method_decl))
8361     return init_identifier_node;
8362
8363   /* Explain here why METHOD_DECL doesn't have the DECL_CONSTRUCTUR_P
8364      and still can be a constructor. FIXME */
8365
8366   /* Don't confuse method only bearing the name of their class as
8367      constructors */
8368   else if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (method_decl))
8369            && ctxp
8370            && GET_CPC_UN () == EXPR_WFL_NODE (method_name)
8371            && get_access_flags_from_decl (method_decl) <= ACC_PROTECTED
8372            && TREE_TYPE (TREE_TYPE (method_decl)) == void_type_node)
8373     return init_identifier_node;
8374   else
8375     return EXPR_WFL_NODE (method_name);
8376 }
8377
8378 /* Track method being redefined inside the same class. As a side
8379    effect, set DECL_NAME to an IDENTIFIER (prior entering this
8380    function it's a FWL, so we can track errors more accurately.)  */
8381
8382 static int
8383 check_method_redefinition (class, method)
8384      tree class, method;
8385 {
8386   tree redef, name;
8387   tree cl = DECL_NAME (method);
8388   tree sig = TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (method));
8389   /* decl name of artificial <clinit> and $finit$ doesn't need to be
8390      fixed and checked */
8391
8392   /* Reset the method name before running the check. If it returns 1,
8393      the method doesn't need to be verified with respect to method
8394      redeclaration and we return 0 */
8395   if (reset_method_name (method))
8396     return 0;
8397
8398   name = DECL_NAME (method);
8399   for (redef = TYPE_METHODS (class); redef; redef = TREE_CHAIN (redef))
8400     {
8401       if (redef == method)
8402         break;
8403       if (DECL_NAME (redef) == name 
8404           && sig == TYPE_ARGUMENT_SIGNATURE (TREE_TYPE (redef)))
8405         {
8406           parse_error_context 
8407             (cl, "Duplicate %s declaration `%s'",
8408              (DECL_CONSTRUCTOR_P (redef) ? "constructor" : "method"),
8409              get_printable_method_name (redef));
8410           return 1;
8411         }
8412     }
8413   return 0;
8414 }
8415
8416 static void
8417 check_abstract_method_definitions (do_interface, class_decl, type)
8418      int do_interface;
8419      tree class_decl, type;
8420 {
8421   tree class = TREE_TYPE (class_decl);
8422   tree method, end_type;
8423
8424   end_type = (do_interface ? object_type_node : type);
8425   for (method = TYPE_METHODS (type); method; method = TREE_CHAIN (method))
8426     {
8427       tree other_super, other_method, method_sig, method_name;
8428       int found = 0;
8429       int end_type_reached = 0;
8430       
8431       if (!METHOD_ABSTRACT (method) || METHOD_FINAL (method))
8432         continue;
8433       
8434       /* Now verify that somewhere in between TYPE and CLASS,
8435          abstract method METHOD gets a non abstract definition
8436          that is inherited by CLASS.  */
8437       
8438       method_sig = build_java_signature (TREE_TYPE (method));
8439       method_name = DECL_NAME (method);
8440       if (TREE_CODE (method_name) == EXPR_WITH_FILE_LOCATION)
8441         method_name = EXPR_WFL_NODE (method_name);
8442
8443       other_super = class;
8444       do {
8445         if (other_super == end_type)
8446           end_type_reached = 1;
8447         
8448         /* Method search */
8449         for (other_method = TYPE_METHODS (other_super); other_method;
8450             other_method = TREE_CHAIN (other_method))
8451           {
8452             tree s = build_java_signature (TREE_TYPE (other_method));
8453             tree other_name = DECL_NAME (other_method);
8454             
8455             if (TREE_CODE (other_name) == EXPR_WITH_FILE_LOCATION)
8456               other_name = EXPR_WFL_NODE (other_name);
8457             if (!DECL_CLINIT_P (other_method)
8458                 && !DECL_CONSTRUCTOR_P (other_method)
8459                 && method_name == other_name && method_sig == s)
8460              {
8461                found = 1;
8462                break;
8463              }
8464           }
8465         other_super = CLASSTYPE_SUPER (other_super);
8466       } while (!end_type_reached);
8467  
8468       /* Report that abstract METHOD didn't find an implementation
8469          that CLASS can use. */
8470       if (!found)
8471         {
8472           char *t = xstrdup (lang_printable_name 
8473                             (TREE_TYPE (TREE_TYPE (method)), 0));
8474           tree ccn = DECL_NAME (TYPE_NAME (DECL_CONTEXT (method)));
8475           tree saved_wfl = NULL_TREE;
8476           
8477           if (TREE_CODE (DECL_NAME (method)) == EXPR_WITH_FILE_LOCATION)
8478             {
8479               saved_wfl = DECL_NAME (method);
8480               DECL_NAME (method) = EXPR_WFL_NODE (DECL_NAME (method));
8481             }
8482           
8483           parse_error_context 
8484             (lookup_cl (class_decl),
8485              "Class `%s' doesn't define the abstract method `%s %s' from %s `%s'. This method must be defined or %s `%s' must be declared abstract",
8486              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8487              t, lang_printable_name (method, 0), 
8488              (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))) ? 
8489               "interface" : "class"),
8490              IDENTIFIER_POINTER (ccn),
8491              (CLASS_INTERFACE (class_decl) ? "interface" : "class"),
8492              IDENTIFIER_POINTER (DECL_NAME (class_decl)));
8493           
8494           free (t);
8495           
8496           if (saved_wfl)
8497             DECL_NAME (method) = saved_wfl;
8498         }
8499     }
8500 }
8501
8502 /* Check that CLASS_DECL somehow implements all inherited abstract
8503    methods.  */
8504
8505 static void
8506 java_check_abstract_method_definitions (class_decl)
8507      tree class_decl;
8508 {
8509   tree class = TREE_TYPE (class_decl);
8510   tree super, vector;
8511   int i;
8512
8513   if (CLASS_ABSTRACT (class_decl))
8514     return;
8515
8516   /* Check for inherited types */
8517   super = class;
8518   do {
8519     super = CLASSTYPE_SUPER (super);
8520     check_abstract_method_definitions (0, class_decl, super);
8521   } while (super != object_type_node);
8522
8523   /* Check for implemented interfaces. */
8524   vector = TYPE_BINFO_BASETYPES (class);
8525   for (i = 1; i < TREE_VEC_LENGTH (vector); i++)
8526     {
8527       super = BINFO_TYPE (TREE_VEC_ELT (vector, i));
8528       check_abstract_method_definitions (1, class_decl, super);
8529     }
8530 }
8531
8532 /* Check all the types method DECL uses and return 1 if all of them
8533    are now complete, 0 otherwise. This is used to check whether its
8534    safe to build a method signature or not.  */
8535
8536 static int
8537 check_method_types_complete (decl)
8538      tree decl;
8539 {
8540   tree type = TREE_TYPE (decl);
8541   tree args;
8542
8543   if (!INCOMPLETE_TYPE_P (TREE_TYPE (type)))
8544     return 0;
8545   
8546   args = TYPE_ARG_TYPES (type);
8547   if (TREE_CODE (type) == METHOD_TYPE)
8548     args = TREE_CHAIN (args);
8549   for (; args != end_params_node; args = TREE_CHAIN (args))
8550     if (INCOMPLETE_TYPE_P (TREE_VALUE (args)))
8551       return 0;
8552
8553   return 1;
8554 }
8555
8556 /* Check all the methods of CLASS_DECL. Methods are first completed
8557    then checked according to regular method existance rules.  If no
8558    constructor for CLASS_DECL were encountered, then build its
8559    declaration.  */
8560
8561 static void
8562 java_check_regular_methods (class_decl)
8563      tree class_decl;
8564 {
8565   int saw_constructor = ANONYMOUS_CLASS_P (TREE_TYPE (class_decl));
8566   tree method;
8567   tree class = CLASS_TO_HANDLE_TYPE (TREE_TYPE (class_decl));
8568   tree saved_found_wfl = NULL_TREE, found = NULL_TREE;
8569   tree mthrows;
8570
8571   /* It is not necessary to check methods defined in java.lang.Object */
8572   if (class == object_type_node)
8573     return;
8574
8575   if (!TYPE_NVIRTUALS (class))
8576     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8577
8578   /* Should take interfaces into account. FIXME */
8579   for (method = TYPE_METHODS (class); method; method = TREE_CHAIN (method))
8580     {
8581       tree sig;
8582       tree method_wfl = DECL_NAME (method);
8583       int aflags;
8584
8585       /* If we previously found something and its name was saved,
8586          reinstall it now */
8587       if (found && saved_found_wfl)
8588         {
8589           DECL_NAME (found) = saved_found_wfl;
8590           saved_found_wfl = NULL_TREE;
8591         }
8592
8593       /* Check for redefinitions */
8594       if (check_method_redefinition (class, method))
8595         continue;
8596
8597       /* If we see one constructor a mark so we don't generate the
8598          default one. Also skip other verifications: constructors
8599          can't be inherited hence hiden or overriden */
8600      if (DECL_CONSTRUCTOR_P (method))
8601        {
8602          saw_constructor = 1;
8603          continue;
8604        }
8605
8606       /* We verify things thrown by the method. They must inherits from
8607          java.lang.Throwable */
8608       for (mthrows = DECL_FUNCTION_THROWS (method);
8609            mthrows; mthrows = TREE_CHAIN (mthrows))
8610         {
8611           if (!inherits_from_p (TREE_VALUE (mthrows), throwable_type_node))
8612             parse_error_context 
8613               (TREE_PURPOSE (mthrows), "Class `%s' in `throws' clause must be a subclass of class `java.lang.Throwable'",
8614                IDENTIFIER_POINTER 
8615                  (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))));
8616         }
8617
8618       sig = build_java_argument_signature (TREE_TYPE (method));
8619       found = lookup_argument_method2 (class, DECL_NAME (method), sig);
8620
8621       /* Inner class can't declare static methods */
8622       if (METHOD_STATIC (method) && !TOPLEVEL_CLASS_DECL_P (class_decl))
8623         {
8624           char *t = xstrdup (lang_printable_name (class, 0));
8625           parse_error_context 
8626             (method_wfl, "Method `%s' can't be static in inner class `%s'. Only members of interfaces and top-level classes can be static",
8627              lang_printable_name (method, 0), t);
8628           free (t);
8629         }
8630
8631       /* Nothing overrides or it's a private method. */
8632       if (!found)
8633         continue;
8634       if (METHOD_PRIVATE (found))
8635         {
8636           found = NULL_TREE;
8637           continue;
8638         }
8639
8640       /* If found wasn't verified, it's DECL_NAME won't be set properly. 
8641          We set it temporarily for the sake of the error report. */
8642       saved_found_wfl = DECL_NAME (found);
8643       reset_method_name (found);
8644
8645       /* If `found' is declared in an interface, make sure the
8646          modifier matches. */
8647       if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found))) 
8648           && clinit_identifier_node != DECL_NAME (found)
8649           && !METHOD_PUBLIC (method))
8650         {
8651           tree found_decl = TYPE_NAME (DECL_CONTEXT (found));
8652           parse_error_context (method_wfl, "Class `%s' must override `%s' with a public method in order to implement interface `%s'",
8653                                IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8654                                lang_printable_name (method, 0),
8655                                IDENTIFIER_POINTER (DECL_NAME (found_decl)));
8656         }
8657
8658       /* Can't override a method with the same name and different return
8659          types. */
8660       if (TREE_TYPE (TREE_TYPE (found)) != TREE_TYPE (TREE_TYPE (method)))
8661         {
8662           char *t = xstrdup 
8663             (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8664           parse_error_context 
8665             (method_wfl,
8666              "Method `%s' was defined with return type `%s' in class `%s'", 
8667              lang_printable_name (found, 0), t,
8668              IDENTIFIER_POINTER 
8669                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8670           free (t);
8671         }
8672
8673       aflags = get_access_flags_from_decl (found);
8674       /* If the method has default, access in an other package, then
8675          issue a warning that the current method doesn't override the
8676          one that was found elsewhere. Do not issue this warning when
8677          the match was found in java.lang.Object.  */
8678       if (DECL_CONTEXT (found) != object_type_node
8679           && ((aflags & ACC_VISIBILITY) == 0)
8680           && !class_in_current_package (DECL_CONTEXT (found))
8681           && !DECL_CLINIT_P (found)
8682           && flag_not_overriding)
8683         {
8684           parse_warning_context 
8685             (method_wfl, "Method `%s' in class `%s' does not override the corresponding method in class `%s', which is private to a different package",
8686              lang_printable_name (found, 0),
8687              IDENTIFIER_POINTER (DECL_NAME (class_decl)),
8688              IDENTIFIER_POINTER (DECL_NAME 
8689                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8690           continue;
8691         }
8692
8693       /* Can't override final. Can't override static. */
8694       if (METHOD_FINAL (found) || METHOD_STATIC (found))
8695         {
8696           /* Static *can* override static */
8697           if (METHOD_STATIC (found) && METHOD_STATIC (method))
8698             continue;
8699           parse_error_context 
8700             (method_wfl,
8701              "%s methods can't be overriden. Method `%s' is %s in class `%s'",
8702              (METHOD_FINAL (found) ? "Final" : "Static"),
8703              lang_printable_name (found, 0),
8704              (METHOD_FINAL (found) ? "final" : "static"),
8705              IDENTIFIER_POINTER
8706                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8707           continue;
8708         }
8709
8710       /* Static method can't override instance method. */
8711       if (METHOD_STATIC (method))
8712         {
8713           parse_error_context 
8714             (method_wfl,
8715              "Instance methods can't be overriden by a static method. Method `%s' is an instance method in class `%s'",
8716              lang_printable_name (found, 0),
8717              IDENTIFIER_POINTER
8718                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8719           continue;
8720         }
8721
8722       /* - Overriding/hiding public must be public
8723          - Overriding/hiding protected must be protected or public
8724          - If the overriden or hidden method has default (package)
8725            access, then the overriding or hiding method must not be
8726            private; otherwise, a compile-time error occurs.  If
8727            `found' belongs to an interface, things have been already
8728            taken care of.  */
8729       if (!CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (found)))
8730           && ((METHOD_PUBLIC (found) && !METHOD_PUBLIC (method))
8731               || (METHOD_PROTECTED (found) 
8732                   && !(METHOD_PUBLIC (method) || METHOD_PROTECTED (method)))
8733               || (!(aflags & (ACC_PUBLIC | ACC_PRIVATE | ACC_STATIC))
8734                   && METHOD_PRIVATE (method))))
8735         {
8736           parse_error_context 
8737             (method_wfl,
8738              "Methods can't be overridden to be more private. Method `%s' is not %s in class `%s'", lang_printable_name (method, 0),
8739              (METHOD_PUBLIC (method) ? "public" : 
8740               (METHOD_PRIVATE (method) ? "private" : "protected")),
8741              IDENTIFIER_POINTER (DECL_NAME 
8742                                  (TYPE_NAME (DECL_CONTEXT (found)))));
8743           continue;
8744         }
8745
8746       /* Overriding methods must have compatible `throws' clauses on checked
8747          exceptions, if any */
8748       check_throws_clauses (method, method_wfl, found);
8749
8750       /* Inheriting multiple methods with the same signature. FIXME */
8751     }
8752   
8753   /* Don't forget eventual pending found and saved_found_wfl. Take
8754      into account that we might have exited because we saw an
8755      artificial method as the last entry. */
8756
8757   if (found && !DECL_ARTIFICIAL (found) && saved_found_wfl)
8758     DECL_NAME (found) = saved_found_wfl;
8759
8760   if (!TYPE_NVIRTUALS (class))
8761     TYPE_METHODS (class) = nreverse (TYPE_METHODS (class));
8762
8763   /* Search for inherited abstract method not yet implemented in this
8764      class.  */
8765   java_check_abstract_method_definitions (class_decl);
8766
8767   if (!saw_constructor)
8768     fatal ("No constructor found");
8769 }
8770
8771 /* Return a non zero value if the `throws' clause of METHOD (if any)
8772    is incompatible with the `throws' clause of FOUND (if any).  */
8773
8774 static void
8775 check_throws_clauses (method, method_wfl, found)
8776      tree method, method_wfl, found;
8777 {
8778   tree mthrows, fthrows;
8779
8780   /* Can't check these things with class loaded from bytecode. FIXME */
8781   if (!CLASS_FROM_SOURCE_P (DECL_CONTEXT (found)))
8782     return;
8783
8784   for (mthrows = DECL_FUNCTION_THROWS (method);
8785        mthrows; mthrows = TREE_CHAIN (mthrows))
8786     {
8787       /* We don't verify unchecked expressions */
8788       if (IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (mthrows)))
8789         continue;
8790       /* Checked expression must be compatible */
8791       for (fthrows = DECL_FUNCTION_THROWS (found); 
8792            fthrows; fthrows = TREE_CHAIN (fthrows))
8793         if (inherits_from_p (TREE_VALUE (mthrows), TREE_VALUE (fthrows)))
8794           break;
8795       if (!fthrows)
8796         {
8797           parse_error_context 
8798             (method_wfl, "Invalid checked exception class `%s' in `throws' clause. The exception must be a subclass of an exception thrown by `%s' from class `%s'",
8799              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (TREE_VALUE (mthrows)))),
8800              lang_printable_name (found, 0),
8801              IDENTIFIER_POINTER 
8802                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8803         }
8804     }
8805 }
8806
8807 /* Check abstract method of interface INTERFACE */
8808
8809 static void
8810 java_check_abstract_methods (interface_decl)
8811      tree interface_decl;
8812 {
8813   int i, n;
8814   tree method, basetype_vec, found;
8815   tree interface = TREE_TYPE (interface_decl);
8816
8817   for (method = TYPE_METHODS (interface); method; method = TREE_CHAIN (method))
8818     {
8819       tree method_wfl = DECL_NAME (method);
8820
8821       /* 2- Check for double definition inside the defining interface */
8822       if (check_method_redefinition (interface, method))
8823         continue;
8824
8825       /* 3- Overriding is OK as far as we preserve the return type and
8826          the thrown exceptions (FIXME) */
8827       found = lookup_java_interface_method2 (interface, method);
8828       if (found)
8829         {
8830           char *t;
8831           tree saved_found_wfl = DECL_NAME (found);
8832           reset_method_name (found);
8833           t = xstrdup (lang_printable_name (TREE_TYPE (TREE_TYPE (found)), 0));
8834           parse_error_context 
8835             (method_wfl,
8836              "Method `%s' was defined with return type `%s' in class `%s'",
8837              lang_printable_name (found, 0), t,
8838              IDENTIFIER_POINTER 
8839                (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8840           free (t);
8841           DECL_NAME (found) = saved_found_wfl;
8842           continue;
8843         }
8844     }
8845
8846   /* 4- Inherited methods can't differ by their returned types */
8847   if (!(basetype_vec = TYPE_BINFO_BASETYPES (interface)))
8848     return;
8849   n = TREE_VEC_LENGTH (basetype_vec);
8850   for (i = 0; i < n; i++)
8851     {
8852       tree sub_interface_method, sub_interface;
8853       tree vec_elt = TREE_VEC_ELT (basetype_vec, i);
8854       if (!vec_elt)
8855         continue;
8856       sub_interface = BINFO_TYPE (vec_elt);
8857       for (sub_interface_method = TYPE_METHODS (sub_interface); 
8858            sub_interface_method;
8859            sub_interface_method = TREE_CHAIN (sub_interface_method))
8860         {
8861           found = lookup_java_interface_method2 (interface, 
8862                                                  sub_interface_method);
8863           if (found && (found != sub_interface_method))
8864             {
8865               tree saved_found_wfl = DECL_NAME (found);
8866               reset_method_name (found);
8867               parse_error_context 
8868                 (lookup_cl (sub_interface_method),
8869                  "Interface `%s' inherits method `%s' from interface `%s'. This method is redefined with a different return type in interface `%s'",
8870                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (interface))),
8871                  lang_printable_name (found, 0),
8872                  IDENTIFIER_POINTER 
8873                    (DECL_NAME (TYPE_NAME 
8874                                (DECL_CONTEXT (sub_interface_method)))),
8875                  IDENTIFIER_POINTER 
8876                    (DECL_NAME (TYPE_NAME (DECL_CONTEXT (found)))));
8877               DECL_NAME (found) = saved_found_wfl;
8878             }
8879         }
8880     }
8881 }
8882
8883 /* Lookup methods in interfaces using their name and partial
8884    signature. Return a matching method only if their types differ.  */
8885
8886 static tree
8887 lookup_java_interface_method2 (class, method_decl)
8888      tree class, method_decl;
8889 {
8890   int i, n;
8891   tree basetype_vec = TYPE_BINFO_BASETYPES (class), to_return;
8892
8893   if (!basetype_vec)
8894     return NULL_TREE;
8895
8896   n = TREE_VEC_LENGTH (basetype_vec);
8897   for (i = 0; i < n; i++)
8898     {
8899       tree vec_elt = TREE_VEC_ELT (basetype_vec, i), to_return;
8900       if ((BINFO_TYPE (vec_elt) != object_type_node)
8901           && (to_return = 
8902               lookup_java_method2 (BINFO_TYPE (vec_elt), method_decl, 1)))
8903         return to_return;
8904     }
8905   for (i = 0; i < n; i++)
8906     {
8907       to_return = lookup_java_interface_method2 
8908         (BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i)), method_decl);
8909       if (to_return)
8910         return to_return;
8911     }
8912
8913   return NULL_TREE;
8914 }
8915
8916 /* Lookup method using their name and partial signature. Return a
8917    matching method only if their types differ.  */
8918
8919 static tree
8920 lookup_java_method2 (clas, method_decl, do_interface)
8921      tree clas, method_decl;
8922      int do_interface;
8923 {
8924   tree method, method_signature, method_name, method_type, name;
8925
8926   method_signature = build_java_argument_signature (TREE_TYPE (method_decl));
8927   name = DECL_NAME (method_decl);
8928   method_name = (TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ? 
8929                  EXPR_WFL_NODE (name) : name);
8930   method_type = TREE_TYPE (TREE_TYPE (method_decl));
8931
8932   while (clas != NULL_TREE)
8933     {
8934       for (method = TYPE_METHODS (clas);
8935            method != NULL_TREE;  method = TREE_CHAIN (method))
8936         {
8937           tree method_sig = build_java_argument_signature (TREE_TYPE (method));
8938           tree name = DECL_NAME (method);
8939           if ((TREE_CODE (name) == EXPR_WITH_FILE_LOCATION ?
8940                EXPR_WFL_NODE (name) : name) == method_name
8941               && method_sig == method_signature 
8942               && TREE_TYPE (TREE_TYPE (method)) != method_type)
8943             return method;
8944         }
8945       clas = (do_interface ? NULL_TREE : CLASSTYPE_SUPER (clas));
8946     }
8947   return NULL_TREE;
8948 }
8949
8950 /* Return the line that matches DECL line number, and try its best to
8951    position the column number. Used during error reports.  */
8952
8953 static tree
8954 lookup_cl (decl)
8955      tree decl;
8956 {
8957   static tree cl = NULL_TREE;
8958   char *line, *found;
8959   
8960   if (!decl)
8961     return NULL_TREE;
8962
8963   if (cl == NULL_TREE)
8964     cl = build_expr_wfl (NULL_TREE, NULL, 0, 0);
8965
8966   EXPR_WFL_FILENAME_NODE (cl) = get_identifier (DECL_SOURCE_FILE (decl));
8967   EXPR_WFL_SET_LINECOL (cl, DECL_SOURCE_LINE_FIRST (decl), -1);
8968
8969   line = java_get_line_col (IDENTIFIER_POINTER (EXPR_WFL_FILENAME_NODE (cl)),
8970                             EXPR_WFL_LINENO (cl), EXPR_WFL_COLNO (cl));
8971
8972   found = strstr ((const char *)line, 
8973                   (const char *)IDENTIFIER_POINTER (DECL_NAME (decl)));
8974   if (found)
8975     EXPR_WFL_SET_LINECOL (cl, EXPR_WFL_LINENO (cl), found - line);
8976
8977   return cl;
8978 }
8979
8980 /* Look for a simple name in the single-type import list */
8981
8982 static tree
8983 find_name_in_single_imports (name)
8984      tree name;
8985 {
8986   tree node;
8987
8988   for (node = ctxp->import_list; node; node = TREE_CHAIN (node))
8989     if (TREE_VALUE (node) == name)
8990       return (EXPR_WFL_NODE (TREE_PURPOSE (node)));
8991
8992   return NULL_TREE;
8993 }
8994
8995 /* Process all single-type import. */
8996
8997 static int
8998 process_imports ()
8999 {
9000   tree import;
9001   int error_found;
9002
9003   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9004     {
9005       tree to_be_found = EXPR_WFL_NODE (TREE_PURPOSE (import));
9006
9007       /* Don't load twice something already defined. */
9008       if (IDENTIFIER_CLASS_VALUE (to_be_found))
9009         continue;
9010       QUALIFIED_P (to_be_found) = 1;
9011       load_class (to_be_found, 0);
9012       error_found =
9013         check_pkg_class_access (to_be_found, TREE_PURPOSE (import));
9014       if (!IDENTIFIER_CLASS_VALUE (to_be_found))
9015         {
9016           parse_error_context (TREE_PURPOSE (import),
9017                                "Class or interface `%s' not found in import",
9018                                IDENTIFIER_POINTER (to_be_found));
9019           return 1;
9020         }
9021       if (error_found)
9022         return 1;
9023     }
9024   return 0;
9025 }
9026
9027 /* Possibly find a class imported by a single-type import statement. Return
9028    1 if an error occured, 0 otherwise. */
9029
9030 static int
9031 find_in_imports (class_type)
9032      tree class_type;
9033 {
9034   tree import;
9035
9036   for (import = ctxp->import_list; import; import = TREE_CHAIN (import))
9037     if (TREE_VALUE (import) == TYPE_NAME (class_type))
9038       {
9039         TYPE_NAME (class_type) = EXPR_WFL_NODE (TREE_PURPOSE (import));
9040         QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9041       }
9042   return 0;
9043 }
9044
9045 static int
9046 note_possible_classname (name, len)
9047      const char *name;
9048      int len;
9049 {
9050   tree node;
9051   if (len > 5 && strncmp (&name [len-5], ".java", 5) == 0)
9052     len = len - 5;
9053   else if (len > 6 && strncmp (&name [len-6], ".class", 6) == 0)
9054     len = len - 6;
9055   else
9056     return 0;
9057   node = ident_subst (name, len, "", '/', '.', "");
9058   IS_A_CLASSFILE_NAME (node) = 1; /* Or soon to be */
9059   QUALIFIED_P (node) = strchr (name, '/') ? 1 : 0;
9060   return 1;
9061 }
9062
9063 /* Read a import directory, gathering potential match for further type
9064    references. Indifferently reads a filesystem or a ZIP archive
9065    directory.  */
9066
9067 static void
9068 read_import_dir (wfl)
9069      tree wfl;
9070 {
9071   tree package_id = EXPR_WFL_NODE (wfl);
9072   const char *package_name = IDENTIFIER_POINTER (package_id);
9073   int package_length = IDENTIFIER_LENGTH (package_id);
9074   DIR *dirp = NULL;
9075   JCF *saved_jcf = current_jcf;
9076
9077   int found = 0;
9078   int k;
9079   void *entry;
9080   struct buffer filename[1];
9081
9082
9083   if (IS_AN_IMPORT_ON_DEMAND_P (package_id))
9084     return;
9085   IS_AN_IMPORT_ON_DEMAND_P (package_id) = 1;
9086
9087   BUFFER_INIT (filename);
9088   buffer_grow (filename, package_length + 100);
9089
9090   for (entry = jcf_path_start (); entry != NULL; entry = jcf_path_next (entry))
9091     {
9092       const char *entry_name = jcf_path_name (entry);
9093       int entry_length = strlen (entry_name);
9094       if (jcf_path_is_zipfile (entry))
9095         {
9096           ZipFile *zipf;
9097           buffer_grow (filename, entry_length);
9098           memcpy (filename->data, entry_name, entry_length - 1);
9099           filename->data[entry_length-1] = '\0';
9100           zipf = opendir_in_zip (filename->data, jcf_path_is_system (entry));
9101           if (zipf == NULL)
9102             error ("malformed .zip archive in CLASSPATH: %s", entry_name);
9103           else
9104             {
9105               ZipDirectory *zipd = (ZipDirectory *) zipf->central_directory;
9106               BUFFER_RESET (filename);
9107               for (k = 0; k < package_length; k++)
9108                 {
9109                   char ch = package_name[k];
9110                   *filename->ptr++ = ch == '.' ? '/' : ch;
9111                 }
9112               *filename->ptr++ = '/';
9113
9114               for (k = 0; k < zipf->count;  k++, zipd = ZIPDIR_NEXT (zipd))
9115                 {
9116                   const char *current_entry = ZIPDIR_FILENAME (zipd);
9117                   int current_entry_len = zipd->filename_length;
9118
9119                   if (current_entry_len >= BUFFER_LENGTH (filename)
9120                       && strncmp (filename->data, current_entry, 
9121                                   BUFFER_LENGTH (filename)) != 0)
9122                     continue;
9123                   found |= note_possible_classname (current_entry,
9124                                                     current_entry_len);
9125                 }
9126             }
9127         }
9128       else
9129         {
9130           BUFFER_RESET (filename);
9131           buffer_grow (filename, entry_length + package_length + 4);
9132           strcpy (filename->data, entry_name);
9133           filename->ptr = filename->data + entry_length;
9134           for (k = 0; k < package_length; k++)
9135             {
9136               char ch = package_name[k];
9137               *filename->ptr++ = ch == '.' ? '/' : ch;
9138             }
9139           *filename->ptr = '\0';
9140
9141           dirp = opendir (filename->data);
9142           if (dirp == NULL)
9143             continue;
9144           *filename->ptr++ = '/';
9145           for (;;)
9146             {
9147               int len; 
9148               const char *d_name;
9149               struct dirent *direntp = readdir (dirp);
9150               if (!direntp)
9151                 break;
9152               d_name = direntp->d_name;
9153               len = strlen (direntp->d_name);
9154               buffer_grow (filename, len+1);
9155               strcpy (filename->ptr, d_name);
9156               found |= note_possible_classname (filename->data + entry_length,
9157                                                 package_length+len+1);
9158             }
9159           if (dirp)
9160             closedir (dirp);
9161         }
9162     }
9163
9164   free (filename->data);
9165
9166   /* Here we should have a unified way of retrieving an entry, to be
9167      indexed. */
9168   if (!found)
9169     {
9170       static int first = 1;
9171       if (first)
9172         {
9173           error ("Can't find default package `%s'. Check the CLASSPATH environment variable and the access to the archives.", package_name);
9174           java_error_count++;
9175           first = 0;
9176         }
9177       else
9178         parse_error_context (wfl, "Package `%s' not found in import",
9179                              package_name);
9180       current_jcf = saved_jcf;
9181       return;
9182     }
9183   current_jcf = saved_jcf;
9184 }
9185
9186 /* Possibly find a type in the import on demands specified
9187    types. Returns 1 if an error occured, 0 otherwise. Run throught the
9188    entire list, to detected potential double definitions.  */
9189                  
9190 static int
9191 find_in_imports_on_demand (class_type)
9192      tree class_type;
9193 {
9194   tree node, import, node_to_use = NULL_TREE;
9195   int seen_once = -1;
9196   tree cl = NULL_TREE;
9197
9198   for (import = ctxp->import_demand_list; import; import = TREE_CHAIN (import))
9199     {
9200       const char *id_name;
9201       obstack_grow (&temporary_obstack, 
9202                     IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))),
9203                     IDENTIFIER_LENGTH (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9204       obstack_1grow (&temporary_obstack, '.');
9205       obstack_grow0 (&temporary_obstack, 
9206                      IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9207                      IDENTIFIER_LENGTH (TYPE_NAME (class_type)));
9208       id_name = obstack_finish (&temporary_obstack);
9209               
9210       node = maybe_get_identifier (id_name);
9211       if (node && IS_A_CLASSFILE_NAME (node))
9212         {
9213           if (seen_once < 0)
9214             {
9215               cl = TREE_PURPOSE (import);
9216               seen_once = 1;
9217               node_to_use = node;
9218             }
9219           else
9220             {
9221               seen_once++;
9222               parse_error_context 
9223                 (import, "Type `%s' also potentially defined in package `%s'",
9224                  IDENTIFIER_POINTER (TYPE_NAME (class_type)),
9225                  IDENTIFIER_POINTER (EXPR_WFL_NODE (TREE_PURPOSE (import))));
9226             }
9227         }
9228     }
9229
9230   if (seen_once == 1)
9231     {
9232       /* Setup lineno so that it refers to the line of the import (in
9233          case we parse a class file and encounter errors */
9234       tree decl;
9235       int saved_lineno = lineno;
9236       lineno = EXPR_WFL_LINENO (cl);
9237       TYPE_NAME (class_type) = node_to_use;
9238       QUALIFIED_P (TYPE_NAME (class_type)) = 1;
9239       decl = IDENTIFIER_CLASS_VALUE (TYPE_NAME (class_type));
9240       /* If there is no DECL set for the class or if the class isn't
9241          loaded and not seen in source yet, the load */
9242       if (!decl || (!CLASS_LOADED_P (TREE_TYPE (decl))
9243                     && !CLASS_FROM_SOURCE_P (TREE_TYPE (decl))))
9244         load_class (node_to_use, 0);
9245       lineno = saved_lineno;
9246       return check_pkg_class_access (TYPE_NAME (class_type), cl);
9247     }
9248   else
9249     return (seen_once < 0 ? 0 : seen_once); /* It's ok not to have found */
9250 }
9251
9252 static tree
9253 resolve_package (pkg, next)
9254      tree pkg, *next;
9255 {
9256   tree current, acc;
9257   tree type_name = NULL_TREE;
9258   const char *name = IDENTIFIER_POINTER (EXPR_WFL_NODE (pkg));
9259
9260   /* The trick is to determine when the package name stops and were
9261      the name of something contained in the package starts. Then we
9262      return a fully qualified name of what we want to get. */
9263
9264   /* Do a quick search on well known package names */
9265   if (!strncmp (name, "java.lang.reflect", 17))
9266     {
9267       *next = 
9268         TREE_CHAIN (TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg))));
9269       type_name = lookup_package_type (name, 17);
9270     }
9271   else if (!strncmp (name, "java.lang", 9))
9272     {
9273       *next = TREE_CHAIN (TREE_CHAIN (EXPR_WFL_QUALIFICATION (pkg)));
9274       type_name = lookup_package_type (name, 9);
9275     }
9276
9277   /* If we found something here, return */
9278   if (type_name)
9279     return type_name; 
9280
9281   *next = EXPR_WFL_QUALIFICATION (pkg);
9282
9283   /* Try the current package. */
9284   if (ctxp->package && !strncmp (name, IDENTIFIER_POINTER (ctxp->package),  
9285                                  IDENTIFIER_LENGTH (ctxp->package)))
9286     {
9287       type_name = 
9288         lookup_package_type_and_set_next (name, 
9289                                           IDENTIFIER_LENGTH (ctxp->package), 
9290                                           next );
9291       if (type_name)
9292         return type_name;
9293     }
9294
9295   /* Search in imported package */
9296   for (current = ctxp->import_list; current; current = TREE_CHAIN (current))
9297     {
9298       tree current_pkg_name = EXPR_WFL_NODE (TREE_PURPOSE (current));
9299       int len = IDENTIFIER_LENGTH (current_pkg_name);
9300       if (!strncmp (name, IDENTIFIER_POINTER (current_pkg_name), len))
9301         {
9302           tree left, dummy;
9303           
9304           breakdown_qualified (&left, &dummy, current_pkg_name);
9305           len = IDENTIFIER_LENGTH (left);
9306           type_name = lookup_package_type_and_set_next (name, len, next);
9307           if (type_name)
9308             break;
9309         }
9310     }
9311
9312   /* Try to progressively construct a type name */
9313   if (TREE_CODE (pkg) == EXPR_WITH_FILE_LOCATION)
9314     for (acc = NULL_TREE, current = EXPR_WFL_QUALIFICATION (pkg); 
9315          current; current = TREE_CHAIN (current))
9316       {
9317         acc = merge_qualified_name (acc, EXPR_WFL_NODE (QUAL_WFL (current)));
9318         if ((type_name = resolve_no_layout (acc, NULL_TREE)))
9319           {
9320             type_name = acc;
9321             *next = TREE_CHAIN (current);
9322             break;
9323           }
9324       }
9325   return type_name;
9326 }
9327
9328 static tree
9329 lookup_package_type_and_set_next (name, len, next)
9330      const char *name;
9331      int len;
9332      tree *next;
9333 {
9334   const char *ptr;
9335   tree type_name = lookup_package_type (name, len);
9336
9337   if (!type_name)
9338     return NULL;
9339   
9340   ptr = IDENTIFIER_POINTER (type_name);
9341   while (ptr && (ptr = strchr (ptr, '.'))) 
9342     {
9343       *next = TREE_CHAIN (*next);
9344       ptr++;
9345     }
9346   return type_name;
9347 }
9348
9349 static tree
9350 lookup_package_type (name, from)
9351      const char *name;
9352      int from;
9353 {
9354   char subname [128];
9355   const char *sub = &name[from+1];
9356   while (*sub != '.' && *sub)
9357     sub++;
9358   strncpy (subname, name, sub-name);
9359   subname [sub-name] = '\0';
9360   return get_identifier (subname);
9361 }
9362
9363 /* Check that CLASS_NAME refers to a PUBLIC class. Return 0 if no
9364    access violations were found, 1 otherwise.  */
9365
9366 static int
9367 check_pkg_class_access (class_name, cl)
9368      tree class_name;
9369      tree cl;
9370 {
9371   tree type;
9372
9373   if (!QUALIFIED_P (class_name) || !IDENTIFIER_CLASS_VALUE (class_name))
9374     return 0;
9375
9376   if (!(type = TREE_TYPE (IDENTIFIER_CLASS_VALUE (class_name))))
9377     return 0;
9378
9379   if (!CLASS_PUBLIC (TYPE_NAME (type)))
9380     {
9381       /* Access to a private class within the same package is
9382          allowed. */
9383       tree l, r;
9384       breakdown_qualified (&l, &r, class_name);
9385       if (l == ctxp->package)
9386         return 0;
9387
9388       parse_error_context 
9389         (cl, "Can't access %s `%s'. Only public classes and interfaces in other packages can be accessed",
9390          (CLASS_INTERFACE (TYPE_NAME (type)) ? "interface" : "class"),
9391          IDENTIFIER_POINTER (class_name));
9392       return 1;
9393     }
9394   return 0;
9395 }
9396
9397 /* Local variable declaration. */
9398
9399 static void
9400 declare_local_variables (modifier, type, vlist)
9401      int modifier;
9402      tree type;
9403      tree vlist;
9404 {
9405   tree decl, current, saved_type;
9406   tree type_wfl = NULL_TREE;
9407   int must_chain = 0;
9408   int final_p = 0;
9409
9410   /* Push a new block if statements were seen between the last time we
9411      pushed a block and now. Keep a cound of block to close */
9412   if (BLOCK_EXPR_BODY (GET_CURRENT_BLOCK (current_function_decl)))
9413     {
9414       tree body = GET_CURRENT_BLOCK (current_function_decl);
9415       tree b = enter_block ();
9416       BLOCK_EXPR_ORIGIN (b) = body;
9417     }
9418
9419   if (modifier)
9420     {
9421       int i;
9422       for (i = 0; i <= 10; i++) if (1 << i & modifier) break;
9423       if (modifier == ACC_FINAL)
9424         final_p = 1;
9425       else 
9426         {
9427           parse_error_context 
9428             (ctxp->modifier_ctx [i], 
9429              "Only `final' is allowed as a local variables modifier");
9430           return;
9431         }
9432     }
9433
9434   /* Obtain an incomplete type if TYPE is not complete. TYPE_WFL will
9435      hold the TYPE value if a new incomplete has to be created (as
9436      opposed to being found already existing and reused). */
9437   SET_TYPE_FOR_RESOLUTION (type, type_wfl, must_chain);
9438
9439   /* If TYPE is fully resolved and we don't have a reference, make one */
9440   PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9441
9442   /* Go through all the declared variables */
9443   for (current = vlist, saved_type = type; current;
9444        current = TREE_CHAIN (current), type = saved_type)
9445     {
9446       tree other, real_type;
9447       tree wfl  = TREE_PURPOSE (current);
9448       tree name = EXPR_WFL_NODE (wfl);
9449       tree init = TREE_VALUE (current);
9450
9451       /* Process NAME, as it may specify extra dimension(s) for it */
9452       type = build_array_from_name (type, type_wfl, name, &name);
9453
9454       /* Variable redefinition check */
9455       if ((other = lookup_name_in_blocks (name)))
9456         {
9457           variable_redefinition_error (wfl, name, TREE_TYPE (other),
9458                                        DECL_SOURCE_LINE (other));
9459           continue;
9460         }
9461
9462       /* Type adjustment. We may have just readjusted TYPE because
9463          the variable specified more dimensions. Make sure we have
9464          a reference if we can and don't have one already. */
9465       PROMOTE_RECORD_IF_COMPLETE (type, must_chain);
9466
9467       real_type = GET_REAL_TYPE (type);
9468       /* Never layout this decl. This will be done when its scope
9469          will be entered */
9470       decl = build_decl (VAR_DECL, name, real_type);
9471       LOCAL_FINAL (decl) = final_p;
9472       BLOCK_CHAIN_DECL (decl);
9473       
9474       /* If doing xreferencing, replace the line number with the WFL
9475          compound value */
9476       if (flag_emit_xref)
9477         DECL_SOURCE_LINE (decl) = EXPR_WFL_LINECOL (wfl);
9478       
9479       /* Don't try to use an INIT statement when an error was found */
9480       if (init && java_error_count)
9481         init = NULL_TREE;
9482       
9483       /* Add the initialization function to the current function's code */
9484       if (init)
9485         {
9486           /* Name might have been readjusted */
9487           EXPR_WFL_NODE (TREE_OPERAND (init, 0)) = name;
9488           MODIFY_EXPR_FROM_INITIALIZATION_P (init) = 1;
9489           java_method_add_stmt (current_function_decl,
9490                                 build_debugable_stmt (EXPR_WFL_LINECOL (init),
9491                                                       init));
9492         }
9493     
9494       /* Setup dependency the type of the decl */
9495       if (must_chain)
9496         {
9497           jdep *dep;
9498           register_incomplete_type (JDEP_VARIABLE, type_wfl, decl, type);
9499           dep = CLASSD_LAST (ctxp->classd_list);
9500           JDEP_GET_PATCH (dep) = &TREE_TYPE (decl);
9501         }
9502     }
9503   SOURCE_FRONTEND_DEBUG (("Defined locals"));
9504 }
9505
9506 /* Called during parsing. Build decls from argument list.  */
9507
9508 static void
9509 source_start_java_method (fndecl)
9510      tree fndecl;
9511 {
9512   tree tem;
9513   tree parm_decl;
9514   int i;
9515 #if 0
9516   int flag_inner = DECL_CONSTRUCTOR_P (fndecl)
9517       && (INNER_CLASS_TYPE_P (DECL_CONTEXT (fndecl)) ? 1 : 0);
9518 #endif
9519
9520   if (!fndecl)
9521     return;
9522
9523   current_function_decl = fndecl;
9524
9525   /* New scope for the function */
9526   enter_block ();
9527   for (tem = TYPE_ARG_TYPES (TREE_TYPE (fndecl)), i = 0;
9528        tem != end_params_node; tem = TREE_CHAIN (tem), i++)
9529     {
9530       tree type = TREE_VALUE (tem);
9531       tree name = TREE_PURPOSE (tem);
9532       
9533       /* If type is incomplete. Create an incomplete decl and ask for
9534          the decl to be patched later */
9535       if (INCOMPLETE_TYPE_P (type))
9536         {
9537           jdep *jdep;
9538           tree real_type = GET_REAL_TYPE (type);
9539           parm_decl = build_decl (PARM_DECL, name, real_type);
9540           type = obtain_incomplete_type (type);
9541           register_incomplete_type (JDEP_PARM, NULL_TREE, NULL_TREE, type);
9542           jdep = CLASSD_LAST (ctxp->classd_list);
9543           JDEP_MISC (jdep) = name;
9544           JDEP_GET_PATCH (jdep) = &TREE_TYPE (parm_decl);
9545         }
9546       else
9547         parm_decl = build_decl (PARM_DECL, name, type);
9548
9549       /* Remember if a local variable was declared final (via its
9550          TREE_LIST of type/name.) Set LOCAL_FINAL accordingly. */
9551       if (ARG_FINAL_P (tem))
9552         LOCAL_FINAL (parm_decl) = 1;
9553
9554       BLOCK_CHAIN_DECL (parm_decl);
9555
9556 #if 0
9557       /* If this is a constructor of a inner class, hide the extra
9558          this$<n> parameter */
9559       if (i == 0 && flag_inner)
9560         {
9561           tree link = TREE_CHAIN (tem);
9562           tree type = DECL_CONTEXT (TYPE_NAME (DECL_CONTEXT (fndecl)));
9563
9564           type = build_pointer_type (TREE_TYPE (type));
9565           parm_decl = build_decl (PARM_DECL,
9566                                   build_current_thisn (current_class), type);
9567           BLOCK_CHAIN_DECL (parm_decl);
9568           /* We hide the this$<n> decl in the name field of its
9569              parameter declaration. */
9570           parm_decl = build_tree_list (DECL_NAME (parm_decl), type);
9571           TREE_CHAIN (tem) = parm_decl;
9572           TREE_CHAIN (parm_decl) = link;
9573           tem = parm_decl;
9574           i++;
9575         }
9576 #endif
9577
9578     }
9579   tem = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9580   BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl)) =
9581     nreverse (tem);
9582   DECL_ARG_SLOT_COUNT (current_function_decl) = i;
9583   DECL_MAX_LOCALS (current_function_decl) = i;
9584 }
9585
9586 /* Called during parsing. Creates an artificial method declaration.  */
9587
9588 static tree
9589 create_artificial_method (class, flags, type, name, args)
9590      tree class;
9591      int flags;
9592      tree type, name, args;
9593 {
9594   tree mdecl;
9595
9596   java_parser_context_save_global ();
9597   lineno = 0;                                                               
9598   mdecl = make_node (FUNCTION_TYPE);                                
9599   TREE_TYPE (mdecl) = type;
9600   TYPE_ARG_TYPES (mdecl) = args;
9601   mdecl = add_method (class, flags, name, build_java_signature (mdecl)); 
9602   java_parser_context_restore_global ();
9603   DECL_ARTIFICIAL (mdecl) = 1;                                      
9604   return mdecl;
9605 }
9606
9607 /* Starts the body if an artifical method.  */
9608
9609 static void
9610 start_artificial_method_body (mdecl)
9611      tree mdecl;
9612 {
9613   DECL_SOURCE_LINE (mdecl) = 1;
9614   DECL_SOURCE_LINE_MERGE (mdecl, 1);
9615   source_start_java_method (mdecl);
9616   enter_block ();
9617 }
9618
9619 static void
9620 end_artificial_method_body (mdecl)
9621      tree mdecl;
9622 {
9623   BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (mdecl)) = exit_block ();
9624   exit_block ();
9625 }
9626
9627 /* Called during expansion. Push decls formerly built from argument
9628    list so they're usable during expansion. */
9629
9630 static void
9631 expand_start_java_method (fndecl)
9632      tree fndecl;
9633 {
9634   tree tem, *ptr;
9635
9636   current_function_decl = fndecl;
9637
9638   if (! quiet_flag)
9639     fprintf (stderr, " [%s.", lang_printable_name (DECL_CONTEXT (fndecl), 0));
9640   announce_function (fndecl);
9641   if (! quiet_flag)
9642     fprintf (stderr, "]");
9643
9644   pushlevel (1);                /* Prepare for a parameter push */
9645   ptr = &DECL_ARGUMENTS (fndecl);
9646   tem  = BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (current_function_decl));
9647   while (tem)
9648     {
9649       tree next = TREE_CHAIN (tem);
9650       tree type = TREE_TYPE (tem);
9651       if (PROMOTE_PROTOTYPES
9652           && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)
9653           && INTEGRAL_TYPE_P (type))
9654         type = integer_type_node;
9655       DECL_ARG_TYPE (tem) = type;
9656       layout_decl (tem, 0);
9657       pushdecl (tem);
9658       *ptr = tem;
9659       ptr = &TREE_CHAIN (tem);
9660       tem = next;
9661     }
9662   *ptr = NULL_TREE;
9663   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9664   lineno = DECL_SOURCE_LINE_FIRST (fndecl);
9665 }
9666
9667 /* Terminate a function and expand its body.  */
9668
9669 static void
9670 source_end_java_method ()
9671 {
9672   tree fndecl = current_function_decl;
9673   int flag_asynchronous_exceptions = asynchronous_exceptions;
9674
9675   if (!fndecl)
9676     return;
9677
9678   java_parser_context_save_global ();
9679   lineno = ctxp->last_ccb_indent1;
9680
9681   /* Set EH language codes */
9682   java_set_exception_lang_code ();
9683
9684   /* Turn function bodies with only a NOP expr null, so they don't get
9685      generated at all and we won't get warnings when using the -W
9686      -Wall flags. */
9687   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) == empty_stmt_node)
9688     BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)) = NULL_TREE;
9689
9690   /* Generate function's code */
9691   if (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl))
9692       && ! flag_emit_class_files
9693       && ! flag_emit_xref)
9694     expand_expr_stmt (BLOCK_EXPR_BODY (DECL_FUNCTION_BODY (fndecl)));
9695
9696   /* pop out of its parameters */
9697   pushdecl_force_head (DECL_ARGUMENTS (fndecl));
9698   poplevel (1, 0, 1);
9699   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
9700
9701   /* Generate rtl for function exit.  */
9702   if (! flag_emit_class_files && ! flag_emit_xref)
9703     {
9704       lineno = DECL_SOURCE_LINE_LAST (fndecl);
9705       /* Emit catch-finally clauses */
9706       emit_handlers ();
9707       expand_function_end (input_filename, lineno, 0);
9708
9709       /* FIXME: If the current method contains any exception handlers,
9710          force asynchronous_exceptions: this is necessary because signal
9711          handlers in libjava may throw exceptions.  This is far from being
9712          a perfect solution, but it's better than doing nothing at all.*/
9713       if (catch_clauses)
9714         asynchronous_exceptions = 1;
9715
9716       /* Run the optimizers and output assembler code for this function. */
9717       rest_of_compilation (fndecl);
9718     }
9719
9720   current_function_decl = NULL_TREE;
9721   permanent_allocation (1);
9722   java_parser_context_restore_global ();
9723   asynchronous_exceptions = flag_asynchronous_exceptions;
9724 }
9725
9726 /* Record EXPR in the current function block. Complements compound
9727    expression second operand if necessary.  */
9728
9729 tree
9730 java_method_add_stmt (fndecl, expr)
9731      tree fndecl, expr;
9732 {
9733   if (!GET_CURRENT_BLOCK (fndecl))
9734     return NULL_TREE;
9735   return add_stmt_to_block (GET_CURRENT_BLOCK (fndecl), NULL_TREE, expr);
9736 }
9737
9738 static tree
9739 add_stmt_to_block (b, type, stmt)
9740      tree b, type, stmt;
9741 {
9742   tree body = BLOCK_EXPR_BODY (b), c;
9743   
9744   if (java_error_count)
9745     return body;
9746     
9747   if ((c = add_stmt_to_compound (body, type, stmt)) == body)
9748     return body;
9749
9750   BLOCK_EXPR_BODY (b) = c;
9751   TREE_SIDE_EFFECTS (c) = 1;
9752   return c;
9753 }
9754
9755 /* Add STMT to EXISTING if possible, otherwise create a new
9756    COMPOUND_EXPR and add STMT to it. */
9757
9758 static tree
9759 add_stmt_to_compound (existing, type, stmt)
9760      tree existing, type, stmt;
9761 {
9762   if (existing)
9763     return build (COMPOUND_EXPR, type, existing, stmt);
9764   else
9765     return stmt;
9766 }
9767
9768 /* Hold THIS for the scope of the current public method decl.  */
9769 static tree current_this;
9770
9771 void java_layout_seen_class_methods ()
9772 {
9773   tree previous_list = all_class_list;
9774   tree end = NULL_TREE;
9775   tree current;
9776
9777   while (1)
9778     {
9779       for (current = previous_list; 
9780            current != end; current = TREE_CHAIN (current))
9781         layout_class_methods (TREE_TYPE (TREE_VALUE (current)));
9782       
9783       if (previous_list != all_class_list)
9784         {
9785           end = previous_list;
9786           previous_list = all_class_list;
9787         }
9788       else
9789         break;
9790     }
9791 }
9792
9793 void
9794 java_reorder_fields ()
9795 {
9796   static tree stop_reordering = NULL_TREE;
9797
9798   tree current;
9799   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9800     {
9801       current_class = TREE_TYPE (TREE_VALUE (current));
9802
9803       if (current_class == stop_reordering)
9804         break;
9805
9806       /* Reverse the fields, but leave the dummy field in front.
9807          Fields are already ordered for Object and Class */
9808       if (TYPE_FIELDS (current_class) && current_class != object_type_node
9809           && current_class != class_type_node)
9810       {
9811         /* If the dummy field is there, reverse the right fields and
9812            just layout the type for proper fields offset */
9813         if (!DECL_NAME (TYPE_FIELDS (current_class)))
9814           {
9815             tree fields = TYPE_FIELDS (current_class);
9816             TREE_CHAIN (fields) = nreverse (TREE_CHAIN (fields));
9817             TYPE_SIZE (current_class) = NULL_TREE;
9818           }
9819         /* We don't have a dummy field, we need to layout the class,
9820            after having reversed the fields */
9821         else
9822           {
9823             TYPE_FIELDS (current_class) = 
9824               nreverse (TYPE_FIELDS (current_class));
9825             TYPE_SIZE (current_class) = NULL_TREE;
9826           }
9827       }
9828     }
9829   stop_reordering = TREE_TYPE (TREE_VALUE (ctxp->gclass_list));
9830 }
9831
9832 /* Layout the methods of all classes loaded in one way on an
9833    other. Check methods of source parsed classes. Then reorder the
9834    fields and layout the classes or the type of all source parsed
9835    classes */
9836
9837 void
9838 java_layout_classes ()
9839 {
9840   tree current;
9841   int save_error_count = java_error_count;
9842
9843   /* Layout the methods of all classes seen so far */
9844   java_layout_seen_class_methods ();
9845   java_parse_abort_on_error ();
9846   all_class_list = NULL_TREE;
9847
9848   /* Then check the methods of all parsed classes */
9849   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9850     if (CLASS_FROM_SOURCE_P (TREE_TYPE (TREE_VALUE (current))))
9851       CHECK_METHODS (TREE_VALUE (current));
9852   java_parse_abort_on_error ();
9853
9854   for (current = ctxp->gclass_list; current; current = TREE_CHAIN (current))
9855     {
9856       current_class = TREE_TYPE (TREE_VALUE (current));
9857       layout_class (current_class);
9858
9859       /* From now on, the class is considered completely loaded */
9860       CLASS_LOADED_P (current_class) = 1;
9861
9862       /* Error reported by the caller */
9863       if (java_error_count)
9864         return;
9865     }
9866
9867   /* We might have reloaded classes durign the process of laying out
9868      classes for code generation. We must layout the methods of those
9869      late additions, as constructor checks might use them */
9870   java_layout_seen_class_methods ();
9871   java_parse_abort_on_error ();
9872 }
9873
9874 /* Expand methods in the current set of classes rememebered for
9875    generation.  */
9876
9877 static void
9878 java_complete_expand_classes ()
9879 {
9880   tree current;
9881
9882   do_not_fold = flag_emit_xref;
9883
9884   for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
9885     if (!INNER_CLASS_DECL_P (current))
9886       java_complete_expand_class (current);
9887 }
9888
9889 /* Expand the methods found in OUTER, starting first by OUTER's inner
9890    classes, if any.  */
9891
9892 static void
9893 java_complete_expand_class (outer)
9894      tree outer;
9895 {
9896   tree inner_list;
9897
9898   set_nested_class_simple_name_value (outer, 1); /* Set */
9899
9900   /* We need to go after all inner classes and start expanding them,
9901      starting with most nested ones. We have to do that because nested
9902      classes might add functions to outer classes */
9903
9904   for (inner_list = DECL_INNER_CLASS_LIST (outer);
9905        inner_list; inner_list = TREE_CHAIN (inner_list))
9906     java_complete_expand_class (TREE_PURPOSE (inner_list));
9907
9908   java_complete_expand_methods (outer);
9909   set_nested_class_simple_name_value (outer, 0); /* Reset */
9910 }
9911
9912 /* Expand methods registered in CLASS_DECL. The general idea is that
9913    we expand regular methods first. This allows us get an estimate on
9914    how outer context local alias fields are really used so we can add
9915    to the constructor just enough code to initialize them properly (it
9916    also lets us generate $finit$ correctly.) Then we expand the
9917    constructors and then <clinit>.  */
9918
9919 static void
9920 java_complete_expand_methods (class_decl)
9921      tree class_decl;
9922 {
9923   tree clinit, finit, decl, first_decl;
9924
9925   current_class = TREE_TYPE (class_decl);
9926
9927   /* Initialize a new constant pool */
9928   init_outgoing_cpool ();
9929
9930   /* Pre-expand <clinit> to figure whether we really need it or
9931      not. If we do need it, we pre-expand the static fields so they're
9932      ready to be used somewhere else. <clinit> will be fully expanded
9933      after we processed the constructors. */
9934   first_decl = TYPE_METHODS (current_class);
9935   clinit = maybe_generate_pre_expand_clinit (current_class);
9936
9937   /* Then generate $finit$ (if we need to) because constructor will
9938    try to use it.*/
9939   if (TYPE_FINIT_STMT_LIST (current_class))
9940     {
9941       finit = generate_finit (current_class);
9942       java_complete_expand_method (finit);
9943     }
9944
9945   /* Now do the constructors */
9946   for (decl = first_decl ; !java_error_count && decl; decl = TREE_CHAIN (decl))
9947     {
9948       int no_body;
9949
9950       if (!DECL_CONSTRUCTOR_P (decl))
9951         continue;
9952       
9953       no_body = !DECL_FUNCTION_BODY (decl);
9954       /* Don't generate debug info on line zero when expanding a
9955          generated constructor. */
9956       if (no_body)
9957         restore_line_number_status (1);
9958
9959       java_complete_expand_method (decl);
9960       
9961       if (no_body)
9962         restore_line_number_status (0);
9963     }
9964
9965   /* First, do the ordinary methods. */
9966   for (decl = first_decl; decl; decl = TREE_CHAIN (decl))
9967     {
9968       /* Skip abstract or native methods */
9969       if (METHOD_ABSTRACT (decl) || METHOD_NATIVE (decl) 
9970           || DECL_CONSTRUCTOR_P (decl) || DECL_CLINIT_P (decl))
9971         continue;
9972       java_complete_expand_method (decl);
9973     }
9974
9975   /* If there is indeed a <clinit>, fully expand it now */
9976   if (clinit)
9977     {
9978       /* Prevent the use of `this' inside <clinit> */
9979       ctxp->explicit_constructor_p = 1;
9980       java_complete_expand_method (clinit);
9981       ctxp->explicit_constructor_p = 0;
9982     }
9983   
9984   /* We might have generated a class$ that we now want to expand */
9985   if (TYPE_DOT_CLASS (current_class))
9986     java_complete_expand_method (TYPE_DOT_CLASS (current_class));
9987
9988   /* Now verify constructor circularity (stop after the first one we
9989      prove wrong.) */
9990   if (!CLASS_INTERFACE (class_decl))
9991     for (decl = TYPE_METHODS (current_class); decl; decl = TREE_CHAIN (decl))
9992       if (DECL_CONSTRUCTOR_P (decl) 
9993           && verify_constructor_circularity (decl, decl))
9994         break;
9995
9996   /* Save the constant pool. We'll need to restore it later. */
9997   TYPE_CPOOL (current_class) = outgoing_cpool;
9998 }
9999
10000 /* Hold a list of catch clauses list. The first element of this list is
10001    the list of the catch clauses of the currently analysed try block. */
10002 static tree currently_caught_type_list;
10003
10004 /* Attempt to create <clinit>. Pre-expand static fields so they can be
10005    safely used in some other methods/constructors.  */
10006
10007 static tree
10008 maybe_generate_pre_expand_clinit (class_type)
10009      tree class_type;
10010 {
10011   tree current, mdecl;
10012
10013   if (!TYPE_CLINIT_STMT_LIST (class_type))
10014     return NULL_TREE;
10015
10016   /* Go through all static fields and pre expand them */
10017   for (current = TYPE_FIELDS (class_type); current; 
10018        current = TREE_CHAIN (current))
10019     if (FIELD_STATIC (current))
10020       build_field_ref (NULL_TREE, class_type, DECL_NAME (current));
10021
10022   /* Then build the <clinit> method */
10023   mdecl = create_artificial_method (class_type, ACC_STATIC, void_type_node,
10024                                     clinit_identifier_node, end_params_node);
10025   layout_class_method (class_type, CLASSTYPE_SUPER (class_type),
10026                        mdecl, NULL_TREE);
10027   start_artificial_method_body (mdecl);
10028
10029   /* We process the list of assignment we produced as the result of
10030      the declaration of initialized static field and add them as
10031      statement to the <clinit> method. */
10032   for (current = TYPE_CLINIT_STMT_LIST (class_type); current;
10033        current = TREE_CHAIN (current))
10034     {
10035       /* We build the assignment expression that will initialize the
10036          field to its value. There are strict rules on static
10037          initializers (8.5). FIXME */
10038       tree stmt = build_debugable_stmt (EXPR_WFL_LINECOL (current), current);
10039       java_method_add_stmt (mdecl, stmt);
10040     }
10041
10042   end_artificial_method_body (mdecl);
10043
10044   /* Now we want to place <clinit> as the last method for interface so
10045      that it doesn't interfere with the dispatch table based
10046      lookup. */
10047   if (CLASS_INTERFACE (TYPE_NAME (class_type))
10048       && TREE_CHAIN (TYPE_METHODS (class_type)))
10049     {
10050       tree current = 
10051         TYPE_METHODS (class_type) = TREE_CHAIN (TYPE_METHODS (class_type));
10052
10053       while (TREE_CHAIN (current))
10054         current = TREE_CHAIN (current);
10055       TREE_CHAIN (current) = mdecl;
10056       TREE_CHAIN (mdecl) = NULL_TREE;
10057     }
10058
10059   return mdecl;
10060 }
10061
10062 /* Complete and expand a method.  */
10063
10064 static void
10065 java_complete_expand_method (mdecl)
10066      tree mdecl;
10067 {
10068   current_function_decl = mdecl;
10069   /* Fix constructors before expanding them */
10070   if (DECL_CONSTRUCTOR_P (mdecl))
10071     fix_constructors (mdecl);
10072   
10073   /* Expand functions that have a body */
10074   if (DECL_FUNCTION_BODY (mdecl))
10075     {
10076       tree fbody = DECL_FUNCTION_BODY (mdecl);
10077       tree block_body = BLOCK_EXPR_BODY (fbody);
10078       tree exception_copy = NULL_TREE;
10079       expand_start_java_method (mdecl);
10080       build_result_decl (mdecl);
10081
10082       current_this 
10083         = (!METHOD_STATIC (mdecl) ? 
10084            BLOCK_EXPR_DECLS (DECL_FUNCTION_BODY (mdecl)) : NULL_TREE);
10085
10086       /* Purge the `throws' list of unchecked exceptions. If we're
10087          doing xref, save a copy of the list and re-install it
10088          later. */
10089       if (flag_emit_xref)
10090         exception_copy = copy_list (DECL_FUNCTION_THROWS (mdecl));
10091
10092       purge_unchecked_exceptions (mdecl);
10093
10094       /* Install exceptions thrown with `throws' */
10095       PUSH_EXCEPTIONS (DECL_FUNCTION_THROWS (mdecl));
10096
10097       if (block_body != NULL_TREE)
10098         {
10099           block_body = java_complete_tree (block_body);
10100
10101           if (!flag_emit_xref)
10102             check_for_initialization (block_body);
10103           ctxp->explicit_constructor_p = 0;
10104         }
10105       BLOCK_EXPR_BODY (fbody) = block_body;
10106
10107       /* If we saw a return but couldn't evaluate it properly, we'll
10108          have an error_mark_node here. */
10109       if (block_body != error_mark_node
10110           && (block_body == NULL_TREE || CAN_COMPLETE_NORMALLY (block_body))
10111           && TREE_CODE (TREE_TYPE (TREE_TYPE (mdecl))) != VOID_TYPE
10112           && !flag_emit_xref)
10113         missing_return_error (current_function_decl);
10114
10115       complete_start_java_method (mdecl); 
10116
10117       /* Don't go any further if we've found error(s) during the
10118          expansion */
10119       if (!java_error_count)
10120         source_end_java_method ();
10121       else
10122         {
10123           pushdecl_force_head (DECL_ARGUMENTS (mdecl));
10124           poplevel (1, 0, 1);
10125         }
10126
10127       /* Pop the exceptions and sanity check */
10128       POP_EXCEPTIONS();
10129       if (currently_caught_type_list)
10130         fatal ("Exception list non empty - java_complete_expand_method");
10131
10132       if (flag_emit_xref)
10133         DECL_FUNCTION_THROWS (mdecl) = exception_copy;
10134     }
10135 }
10136
10137 \f
10138
10139 /* This section of the code deals with accessing enclosing context
10140    fields either directly by using the relevant access to this$<n> or
10141    by invoking an access method crafted for that purpose.  */
10142
10143 /* Build the necessary access from an inner class to an outer
10144    class. This routine could be optimized to cache previous result
10145    (decl, current_class and returned access).  When an access method
10146    needs to be generated, it always takes the form of a read. It might
10147    be later turned into a write by calling outer_field_access_fix.  */
10148
10149 static tree
10150 build_outer_field_access (id, decl)
10151      tree id, decl;
10152 {
10153   tree access = NULL_TREE;
10154   tree ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
10155
10156   /* If decl's class is the direct outer class of the current_class,
10157      build the access as `this$<n>.<field>'. Not that we will break
10158      the `private' barrier if we're not emitting bytecodes. */
10159   if (ctx == DECL_CONTEXT (decl) 
10160       && (!FIELD_PRIVATE (decl) || !flag_emit_class_files ))
10161     {
10162       tree thisn = build_current_thisn (current_class);
10163       access = make_qualified_primary (build_wfl_node (thisn), 
10164                                        id, EXPR_WFL_LINECOL (id));
10165     }
10166   /* Otherwise, generate access methods to outer this and access the
10167      field (either using an access method or by direct access.) */
10168   else
10169     {
10170       int lc = EXPR_WFL_LINECOL (id);
10171
10172       /* Now we chain the required number of calls to the access$0 to
10173          get a hold to the enclosing instance we need, and the we
10174          build the field access. */
10175       access = build_access_to_thisn (ctx, DECL_CONTEXT (decl), lc);
10176
10177       /* If the field is private and we're generating bytecode, then
10178          we generate an access method */
10179       if (FIELD_PRIVATE (decl) && flag_emit_class_files )
10180         {
10181           tree name = build_outer_field_access_methods (decl);
10182           access = build_outer_field_access_expr (lc, DECL_CONTEXT (decl),
10183                                                   name, access, NULL_TREE);
10184         }
10185       /* Otherwise we use `access$(this$<j>). ... access$(this$<i>).<field>'.
10186          Once again we break the `private' access rule from a foreign
10187          class. */
10188       else
10189         access = make_qualified_primary (access, id, lc);
10190     }
10191   return resolve_expression_name (access, NULL);
10192 }
10193
10194 /* Return a non zero value if NODE describes an outer field inner
10195    access.  */
10196
10197 static int
10198 outer_field_access_p (type, decl)
10199     tree type, decl;
10200 {
10201   if (!INNER_CLASS_TYPE_P (type) 
10202       || TREE_CODE (decl) != FIELD_DECL
10203       || DECL_CONTEXT (decl) == type)
10204     return 0;
10205
10206   for (type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))); ;
10207        type = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))))
10208     {
10209       if (type == DECL_CONTEXT (decl))
10210         return 1;
10211       if (!DECL_CONTEXT (TYPE_NAME (type)))
10212         break;
10213     }
10214
10215   return 0;
10216 }
10217
10218 /* Return a non zero value if NODE represents an outer field inner
10219    access that was been already expanded. As a side effect, it returns
10220    the name of the field being accessed and the argument passed to the
10221    access function, suitable for a regeneration of the access method
10222    call if necessary. */
10223
10224 static int
10225 outer_field_expanded_access_p (node, name, arg_type, arg)
10226     tree node, *name, *arg_type, *arg;
10227 {
10228   int identified = 0;
10229
10230   if (TREE_CODE (node) != CALL_EXPR)
10231     return 0;
10232
10233   /* Well, gcj generates slightly different tree nodes when compiling
10234      to native or bytecodes. It's the case for function calls. */
10235
10236   if (flag_emit_class_files 
10237       && TREE_CODE (node) == CALL_EXPR
10238       && OUTER_FIELD_ACCESS_IDENTIFIER_P (DECL_NAME (TREE_OPERAND (node, 0))))
10239     identified = 1;
10240   else if (!flag_emit_class_files)
10241     {
10242       node = TREE_OPERAND (node, 0);
10243       
10244       if (node && TREE_OPERAND (node, 0)
10245           && TREE_CODE (TREE_OPERAND (node, 0)) == ADDR_EXPR)
10246         {
10247           node = TREE_OPERAND (node, 0);
10248           if (TREE_OPERAND (node, 0)
10249               && TREE_CODE (TREE_OPERAND (node, 0)) == FUNCTION_DECL
10250               && (OUTER_FIELD_ACCESS_IDENTIFIER_P 
10251                   (DECL_NAME (TREE_OPERAND (node, 0)))))
10252             identified = 1;
10253         }
10254     }
10255
10256   if (identified && name && arg_type && arg)
10257     {
10258       tree argument = TREE_OPERAND (node, 1);
10259       *name = DECL_NAME (TREE_OPERAND (node, 0));
10260       *arg_type = TREE_TYPE (TREE_TYPE (TREE_VALUE (argument)));
10261       *arg = TREE_VALUE (argument);
10262     }
10263   return identified;
10264 }
10265
10266 /* Detect in NODE an outer field read access from an inner class and
10267    transform it into a write with RHS as an argument. This function is
10268    called from the java_complete_lhs when an assignment to a LHS can
10269    be identified. */
10270
10271 static tree
10272 outer_field_access_fix (wfl, node, rhs)
10273     tree wfl, node, rhs;
10274 {
10275   tree name, arg_type, arg;
10276   
10277   if (outer_field_expanded_access_p (node, &name, &arg_type, &arg))
10278     {
10279       /* At any rate, check whether we're trying to assign a value to
10280          a final. */
10281       tree accessed = (JDECL_P (node) ? node : 
10282                        (TREE_CODE (node) == COMPONENT_REF ? 
10283                         TREE_OPERAND (node, 1) : node));
10284       if (check_final_assignment (accessed, wfl))
10285         return error_mark_node;
10286   
10287       node = build_outer_field_access_expr (EXPR_WFL_LINECOL (wfl), 
10288                                             arg_type, name, arg, rhs);
10289       return java_complete_tree (node);
10290     }
10291   return NULL_TREE;
10292 }
10293
10294 /* Construct the expression that calls an access method:
10295      <type>.access$<n>(<arg1> [, <arg2>]); 
10296
10297    ARG2 can be NULL and will be omitted in that case. It will denote a
10298    read access.  */
10299
10300 static tree
10301 build_outer_field_access_expr (lc, type, access_method_name, arg1, arg2)
10302     int lc;
10303     tree type, access_method_name, arg1, arg2;
10304 {
10305   tree args, cn, access;
10306
10307   args = arg1 ? arg1 : 
10308     build_wfl_node (build_current_thisn (current_class));
10309   args = build_tree_list (NULL_TREE, args);
10310
10311   if (arg2)
10312     args = tree_cons (NULL_TREE, arg2, args);
10313
10314   access = build_method_invocation (build_wfl_node (access_method_name), args);
10315   cn = build_wfl_node (DECL_NAME (TYPE_NAME (type)));
10316   return make_qualified_primary (cn, access, lc);
10317 }
10318
10319 static tree
10320 build_new_access_id ()
10321 {
10322   static int access_n_counter = 1;
10323   char buffer [128];
10324
10325   sprintf (buffer, "access$%d", access_n_counter++);
10326   return get_identifier (buffer);
10327 }
10328
10329 /* Create the static access functions for the outer field DECL. We define a
10330    read:
10331      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$) {
10332        return inst$.field;
10333      }
10334    and a write access:
10335      TREE_TYPE (<field>) access$<n> (DECL_CONTEXT (<field>) inst$,
10336                                      TREE_TYPE (<field>) value$) {
10337        return inst$.field = value$;
10338      }
10339    We should have a usage flags on the DECL so we can lazily turn the ones
10340    we're using for code generation. FIXME.
10341 */
10342
10343 static tree
10344 build_outer_field_access_methods (decl)
10345     tree decl;
10346 {
10347   tree id, args, stmt, mdecl;
10348   
10349   /* Check point, to be removed. FIXME */
10350   if (FIELD_INNER_ACCESS (decl) 
10351       && TREE_CODE (FIELD_INNER_ACCESS (decl)) != IDENTIFIER_NODE)
10352     abort ();
10353
10354   if (FIELD_INNER_ACCESS (decl))
10355     return FIELD_INNER_ACCESS (decl);
10356
10357   push_obstacks (&permanent_obstack, &permanent_obstack);
10358
10359   /* Create the identifier and a function named after it. */
10360   id = build_new_access_id ();
10361
10362   /* The identifier is marked as bearing the name of a generated write
10363      access function for outer field accessed from inner classes. */
10364   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10365
10366   /* Create the read access */
10367   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10368   TREE_CHAIN (args) = end_params_node;
10369   stmt = make_qualified_primary (build_wfl_node (inst_id),
10370                                  build_wfl_node (DECL_NAME (decl)), 0);
10371   stmt = build_return (0, stmt);
10372   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10373                                            TREE_TYPE (decl), id, args, stmt);
10374   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10375
10376   /* Create the write access method */
10377   args = build_tree_list (inst_id, build_pointer_type (DECL_CONTEXT (decl)));
10378   TREE_CHAIN (args) = build_tree_list (wpv_id, TREE_TYPE (decl));
10379   TREE_CHAIN (TREE_CHAIN (args)) = end_params_node;
10380   stmt = make_qualified_primary (build_wfl_node (inst_id),
10381                                  build_wfl_node (DECL_NAME (decl)), 0);
10382   stmt = build_return (0, build_assignment (ASSIGN_TK, 0, stmt,
10383                                             build_wfl_node (wpv_id)));
10384
10385   mdecl = build_outer_field_access_method (DECL_CONTEXT (decl), 
10386                                            TREE_TYPE (decl), id, args, stmt);
10387   DECL_FUNCTION_ACCESS_DECL (mdecl) = decl;
10388   pop_obstacks ();
10389
10390   /* Return the access name */
10391   return FIELD_INNER_ACCESS (decl) = id;
10392 }
10393
10394 /* Build an field access method NAME.  */
10395
10396 static tree 
10397 build_outer_field_access_method (class, type, name, args, body)
10398     tree class, type, name, args, body;
10399 {
10400   tree saved_current_function_decl, mdecl;
10401
10402   /* Create the method */
10403   mdecl = create_artificial_method (class, ACC_STATIC, type, name, args);
10404   fix_method_argument_names (args, mdecl);
10405   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10406
10407   /* Attach the method body. */
10408   saved_current_function_decl = current_function_decl;
10409   start_artificial_method_body (mdecl);
10410   java_method_add_stmt (mdecl, body);
10411   end_artificial_method_body (mdecl);
10412   current_function_decl = saved_current_function_decl;
10413
10414   return mdecl;
10415 }
10416
10417 \f
10418 /* This section deals with building access function necessary for
10419    certain kinds of method invocation from inner classes.  */
10420
10421 static tree
10422 build_outer_method_access_method (decl)
10423     tree decl;
10424 {
10425   tree saved_current_function_decl, mdecl;
10426   tree args = NULL_TREE, call_args = NULL_TREE;
10427   tree carg, id, body, class;
10428   char buffer [80];
10429   int parm_id_count = 0;
10430
10431   /* Test this abort with an access to a private field */
10432   if (!strcmp (IDENTIFIER_POINTER (DECL_NAME (decl)), "access$"))
10433     abort ();
10434
10435   /* Check the cache first */
10436   if (DECL_FUNCTION_INNER_ACCESS (decl))
10437     return DECL_FUNCTION_INNER_ACCESS (decl);
10438
10439   class = DECL_CONTEXT (decl);
10440
10441   /* Obtain an access identifier and mark it */
10442   id = build_new_access_id ();
10443   OUTER_FIELD_ACCESS_IDENTIFIER_P (id) = 1;
10444
10445   push_obstacks (&permanent_obstack, &permanent_obstack);
10446
10447   carg = TYPE_ARG_TYPES (TREE_TYPE (decl));
10448   /* Create the arguments, as much as the original */
10449   for (; carg && carg != end_params_node; 
10450        carg = TREE_CHAIN (carg))
10451     {
10452       sprintf (buffer, "write_parm_value$%d", parm_id_count++);
10453       args = chainon (args, build_tree_list (get_identifier (buffer), 
10454                                              TREE_VALUE (carg)));
10455     }
10456   args = chainon (args, end_params_node);
10457
10458   /* Create the method */
10459   mdecl = create_artificial_method (class, ACC_STATIC, 
10460                                     TREE_TYPE (TREE_TYPE (decl)), id, args);
10461   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10462   /* There is a potential bug here. We should be able to use
10463      fix_method_argument_names, but then arg names get mixed up and
10464      eventually a constructor will have its this$0 altered and the
10465      outer context won't be assignment properly. The test case is
10466      stub.java FIXME */
10467   TYPE_ARG_TYPES (TREE_TYPE (mdecl)) = args;
10468
10469   /* Attach the method body. */
10470   saved_current_function_decl = current_function_decl;
10471   start_artificial_method_body (mdecl);
10472
10473   /* The actual method invocation uses the same args. When invoking a
10474      static methods that way, we don't want to skip the first
10475      argument. */
10476   carg = args;
10477   if (!METHOD_STATIC (decl))
10478     carg = TREE_CHAIN (carg);
10479   for (; carg && carg != end_params_node; carg = TREE_CHAIN (carg))
10480     call_args = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (carg)),
10481                            call_args);
10482
10483   body = build_method_invocation (build_wfl_node (DECL_NAME (decl)), 
10484                                   call_args);
10485   if (!METHOD_STATIC (decl))
10486     body = make_qualified_primary (build_wfl_node (TREE_PURPOSE (args)), 
10487                                    body, 0);
10488   if (TREE_TYPE (TREE_TYPE (decl)) != void_type_node)
10489     body = build_return (0, body);
10490   java_method_add_stmt (mdecl,body);
10491   end_artificial_method_body (mdecl);
10492   current_function_decl = saved_current_function_decl;
10493   pop_obstacks ();
10494
10495   /* Back tag the access function so it know what it accesses */
10496   DECL_FUNCTION_ACCESS_DECL (decl) = mdecl;
10497
10498   /* Tag the current method so it knows it has an access generated */
10499   return DECL_FUNCTION_INNER_ACCESS (decl) = mdecl;
10500 }
10501
10502 \f
10503 /* This section of the code deals with building expressions to access
10504    the enclosing instance of an inner class. The enclosing instance is
10505    kept in a generated field called this$<n>, with <n> being the
10506    inner class nesting level (starting from 0.)  */
10507     
10508 /* Build an access to a given this$<n>, possibly by chaining access
10509    call to others. Access methods to this$<n> are build on the fly if
10510    necessary */
10511
10512 static tree
10513 build_access_to_thisn (from, to, lc)
10514      tree from, to;
10515      int lc;
10516 {
10517   tree access = NULL_TREE;
10518
10519   while (from != to)
10520     {
10521       tree access0_wfl, cn;
10522
10523       maybe_build_thisn_access_method (from);
10524       access0_wfl = build_wfl_node (access0_identifier_node);
10525       cn = build_wfl_node (DECL_NAME (TYPE_NAME (from)));
10526       EXPR_WFL_LINECOL (access0_wfl) = lc;
10527       
10528       if (!access)
10529         {
10530           access = build_current_thisn (current_class);
10531           access = build_wfl_node (access);
10532         }
10533       access = build_tree_list (NULL_TREE, access);
10534       access = build_method_invocation (access0_wfl, access);
10535       access = make_qualified_primary (cn, access, lc);
10536       
10537       from = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (from)));
10538     }
10539   return access;
10540 }
10541
10542 /* Build an access function to the this$<n> local to TYPE. NULL_TREE
10543    is returned if nothing needs to be generated. Otherwise, the method
10544    generated, fully walked and a method decl is returned.  
10545
10546    NOTE: These generated methods should be declared in a class file
10547    attribute so that they can't be referred to directly.  */
10548
10549 static tree
10550 maybe_build_thisn_access_method (type)
10551     tree type;
10552 {
10553   tree mdecl, args, stmt, rtype;
10554   tree saved_current_function_decl;
10555
10556   /* If TYPE is a top-level class, no access method is required.
10557      If there already is such an access method, bail out. */
10558   if (CLASS_ACCESS0_GENERATED_P (type) || !INNER_CLASS_TYPE_P (type))
10559     return NULL_TREE;
10560
10561   /* We generate the method. The method looks like:
10562      static <outer_of_type> access$0 (<type> inst$) { return inst$.this$<n>; }
10563   */
10564   push_obstacks (&permanent_obstack, &permanent_obstack);
10565   args = build_tree_list (inst_id, build_pointer_type (type));
10566   TREE_CHAIN (args) = end_params_node;
10567   rtype = build_pointer_type (TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))));
10568   mdecl = create_artificial_method (type, ACC_STATIC, rtype,
10569                                     access0_identifier_node, args);
10570   fix_method_argument_names (args, mdecl);
10571   layout_class_method (type, NULL_TREE, mdecl, NULL_TREE);
10572   stmt = build_current_thisn (type);
10573   stmt = make_qualified_primary (build_wfl_node (inst_id), 
10574                                  build_wfl_node (stmt), 0);
10575   stmt = build_return (0, stmt);
10576
10577   saved_current_function_decl = current_function_decl;
10578   start_artificial_method_body (mdecl);
10579   java_method_add_stmt (mdecl, stmt);
10580   end_artificial_method_body (mdecl);
10581   current_function_decl = saved_current_function_decl;
10582   pop_obstacks ();
10583
10584   CLASS_ACCESS0_GENERATED_P (type) = 1;
10585
10586   return mdecl;
10587 }
10588
10589 /* Craft an correctly numbered `this$<n>'string. this$0 is used for
10590    the first level of innerclassing. this$1 for the next one, etc...
10591    This function can be invoked with TYPE to NULL, available and then
10592    has to count the parser context.  */
10593
10594 static tree
10595 build_current_thisn (type)
10596     tree type;
10597 {
10598   static int saved_i = -1;
10599   static tree saved_thisn = NULL_TREE;
10600
10601   tree decl;
10602   char buffer [80];
10603   int i = 0;
10604
10605   if (type)
10606     {
10607       static tree saved_type = NULL_TREE;
10608       static int saved_type_i = 0;
10609
10610       if (type == saved_type)
10611         i = saved_type_i;
10612       else
10613         {
10614           for (i = -1, decl = DECL_CONTEXT (TYPE_NAME (type)); 
10615                decl; decl = DECL_CONTEXT (decl), i++)
10616             ;
10617       
10618           saved_type = type;
10619           saved_type_i = i;
10620         }
10621     }
10622   else
10623     i = list_length (GET_CPC_LIST ())-2;
10624
10625   if (i == saved_i)
10626     return saved_thisn;
10627     
10628   sprintf (buffer, "this$%d", i);
10629   saved_i = i;
10630   saved_thisn = get_identifier (buffer);
10631   return saved_thisn;
10632 }
10633
10634 /* Return the assignement to the hidden enclosing context `this$<n>'
10635    by the second incoming parameter to the innerclass constructor. The
10636    form used is `this.this$<n> = this$<n>;'.  */
10637
10638 static tree
10639 build_thisn_assign ()
10640 {
10641   if (current_class && PURE_INNER_CLASS_TYPE_P (current_class))
10642     {
10643       tree thisn = build_current_thisn (current_class);
10644       tree lhs = make_qualified_primary (build_wfl_node (this_identifier_node),
10645                                          build_wfl_node (thisn), 0);
10646       tree rhs = build_wfl_node (thisn);
10647       EXPR_WFL_SET_LINECOL (lhs, lineno, 0);
10648       return build_assignment (ASSIGN_TK, EXPR_WFL_LINECOL (lhs), lhs, rhs);
10649     }
10650   return NULL_TREE;
10651 }
10652
10653 \f
10654 /* Building the synthetic `class$' used to implement the `.class' 1.1
10655    extension for non primitive types. This method looks like:
10656
10657     static Class class$(String type) throws NoClassDefFoundError
10658     {
10659       try {return (java.lang.Class.forName (String));}
10660       catch (ClassNotFoundException e) {
10661         throw new NoClassDefFoundError(e.getMessage());}
10662     } */
10663
10664 static tree
10665 build_dot_class_method (class)
10666      tree class;
10667 {
10668 #define BWF(S) build_wfl_node (get_identifier ((S)))
10669 #define MQN(X,Y) make_qualified_name ((X), (Y), 0)
10670   tree args, tmp, saved_current_function_decl, mdecl;
10671   tree stmt, throw_stmt, catch, catch_block, try_block;
10672   tree catch_clause_param;
10673   tree class_not_found_exception, no_class_def_found_error;
10674
10675   static tree get_message_wfl, type_parm_wfl;
10676
10677   if (!get_message_wfl)
10678     {
10679       get_message_wfl = build_wfl_node (get_identifier ("getMessage"));
10680       type_parm_wfl = build_wfl_node (get_identifier ("type$"));
10681     }
10682
10683   /* Build the arguments */
10684   args = build_tree_list (get_identifier ("type$"),
10685                           build_pointer_type (string_type_node));
10686   TREE_CHAIN (args) = end_params_node;
10687
10688   /* Build the qualified name java.lang.Class.forName */
10689   tmp = MQN (MQN (MQN (BWF ("java"), 
10690                        BWF ("lang")), BWF ("Class")), BWF ("forName"));
10691
10692   /* For things we have to catch and throw */
10693   class_not_found_exception = 
10694     lookup_class (get_identifier ("java.lang.ClassNotFoundException"));
10695   no_class_def_found_error = 
10696     lookup_class (get_identifier ("java.lang.NoClassDefFoundError"));
10697   load_class (class_not_found_exception, 1);
10698   load_class (no_class_def_found_error, 1);
10699
10700   /* Create the "class$" function */
10701   mdecl = create_artificial_method (class, ACC_STATIC, 
10702                                     build_pointer_type (class_type_node),
10703                                     get_identifier ("class$"), args);
10704   DECL_FUNCTION_THROWS (mdecl) = build_tree_list (NULL_TREE,
10705                                                   no_class_def_found_error);
10706   
10707   /* We start by building the try block. We need to build:
10708        return (java.lang.Class.forName (type)); */
10709   stmt = build_method_invocation (tmp, 
10710                                   build_tree_list (NULL_TREE, type_parm_wfl));
10711   stmt = build_return (0, stmt);
10712   /* Put it in a block. That's the try block */
10713   try_block = build_expr_block (stmt, NULL_TREE);
10714
10715   /* Now onto the catch block. We start by building the expression
10716      throwing a new exception: 
10717        throw new NoClassDefFoundError (_.getMessage); */
10718   throw_stmt = make_qualified_name (build_wfl_node (wpv_id), 
10719                                     get_message_wfl, 0);
10720   throw_stmt = build_method_invocation (throw_stmt, NULL_TREE);
10721   
10722   /* Build new NoClassDefFoundError (_.getMessage) */
10723   throw_stmt = build_new_invocation 
10724     (build_wfl_node (get_identifier ("NoClassDefFoundError")),
10725      build_tree_list (build_pointer_type (string_type_node), throw_stmt));
10726
10727   /* Build the throw, (it's too early to use BUILD_THROW) */
10728   throw_stmt = build1 (THROW_EXPR, NULL_TREE, throw_stmt);
10729
10730   /* Build the catch block to encapsulate all this. We begin by
10731      building an decl for the catch clause parameter and link it to
10732      newly created block, the catch block. */
10733   catch_clause_param = 
10734     build_decl (VAR_DECL, wpv_id, 
10735                 build_pointer_type (class_not_found_exception));
10736   catch_block = build_expr_block (NULL_TREE, catch_clause_param);
10737   
10738   /* We initialize the variable with the exception handler. */
10739   catch = build (MODIFY_EXPR, NULL_TREE, catch_clause_param,
10740                  soft_exceptioninfo_call_node);
10741   add_stmt_to_block (catch_block, NULL_TREE, catch);
10742
10743   /* We add the statement throwing the new exception */
10744   add_stmt_to_block (catch_block, NULL_TREE, throw_stmt);
10745
10746   /* Build a catch expression for all this */
10747   catch_block = build1 (CATCH_EXPR, NULL_TREE, catch_block);
10748
10749   /* Build the try/catch sequence */
10750   stmt = build_try_statement (0, try_block, catch_block);
10751
10752   fix_method_argument_names (args, mdecl);
10753   layout_class_method (class, NULL_TREE, mdecl, NULL_TREE);
10754   saved_current_function_decl = current_function_decl;
10755   start_artificial_method_body (mdecl);
10756   java_method_add_stmt (mdecl, stmt);
10757   end_artificial_method_body (mdecl);
10758   current_function_decl = saved_current_function_decl;
10759   TYPE_DOT_CLASS (class) = mdecl;
10760
10761   return mdecl;
10762 }
10763
10764 static tree
10765 build_dot_class_method_invocation (name)
10766      tree name;
10767 {
10768   tree s = make_node (STRING_CST);
10769   TREE_STRING_LENGTH (s) = IDENTIFIER_LENGTH (name);
10770   TREE_STRING_POINTER (s) = obstack_alloc (expression_obstack,
10771                                            TREE_STRING_LENGTH (s)+1);
10772   strcpy (TREE_STRING_POINTER (s), IDENTIFIER_POINTER (name));
10773   return build_method_invocation (build_wfl_node (get_identifier ("class$")),
10774                                   build_tree_list (NULL_TREE, s));
10775 }
10776
10777 /* This section of the code deals with constructor.  */
10778
10779 /* Craft a body for default constructor. Patch existing constructor
10780    bodies with call to super() and field initialization statements if
10781    necessary.  */
10782
10783 static void
10784 fix_constructors (mdecl)
10785      tree mdecl;
10786 {
10787   tree body = DECL_FUNCTION_BODY (mdecl);
10788   tree thisn_assign, compound = NULL_TREE;
10789   tree class_type = DECL_CONTEXT (mdecl);
10790
10791   if (!body)
10792     {
10793       /* It is an error for the compiler to generate a default
10794          constructor if the superclass doesn't have a constructor that
10795          takes no argument, or the same args for an anonymous class */
10796       if (verify_constructor_super (mdecl))
10797         {
10798           tree sclass_decl = TYPE_NAME (CLASSTYPE_SUPER (class_type));
10799           tree save = DECL_NAME (mdecl);
10800           const char *n = IDENTIFIER_POINTER (DECL_NAME (sclass_decl));
10801           DECL_NAME (mdecl) = DECL_NAME (sclass_decl);
10802           parse_error_context
10803             (lookup_cl (TYPE_NAME (class_type)), 
10804              "No constructor matching `%s' found in class `%s'",
10805              lang_printable_name (mdecl, 0), n);
10806           DECL_NAME (mdecl) = save;
10807         }
10808       
10809       /* The constructor body must be crafted by hand. It's the
10810          constructor we defined when we realize we didn't have the
10811          CLASSNAME() constructor */
10812       start_artificial_method_body (mdecl);
10813       
10814       /* We don't generate a super constructor invocation if we're
10815          compiling java.lang.Object. build_super_invocation takes care
10816          of that. */
10817       compound = java_method_add_stmt (mdecl, build_super_invocation (mdecl));
10818
10819       /* Insert the instance initializer block right here, after the
10820          super invocation. */
10821       add_instance_initializer (mdecl);
10822
10823       /* Insert an assignment to the this$<n> hidden field, if
10824          necessary */
10825       if ((thisn_assign = build_thisn_assign ()))
10826         java_method_add_stmt (mdecl, thisn_assign);
10827
10828       end_artificial_method_body (mdecl);
10829     }
10830   /* Search for an explicit constructor invocation */
10831   else 
10832     {
10833       int found = 0;
10834       tree main_block = BLOCK_EXPR_BODY (body);
10835       
10836       while (body)
10837         switch (TREE_CODE (body))
10838           {
10839           case CALL_EXPR:
10840             found = CALL_EXPLICIT_CONSTRUCTOR_P (body);
10841             body = NULL_TREE;
10842             break;
10843           case COMPOUND_EXPR:
10844           case EXPR_WITH_FILE_LOCATION:
10845             body = TREE_OPERAND (body, 0);
10846             break;
10847           case BLOCK:
10848             body = BLOCK_EXPR_BODY (body);
10849             break;
10850           default:
10851             found = 0;
10852             body = NULL_TREE;
10853           }
10854       /* The constructor is missing an invocation of super() */
10855       if (!found)
10856         compound = add_stmt_to_compound (compound, NULL_TREE,
10857                                          build_super_invocation (mdecl));
10858       
10859       /* Insert the instance initializer block right here, after the
10860          super invocation. */
10861       add_instance_initializer (mdecl);
10862
10863       /* Generate the assignment to this$<n>, if necessary */
10864       if ((thisn_assign = build_thisn_assign ()))
10865         compound = add_stmt_to_compound (compound, NULL_TREE, thisn_assign);
10866
10867       /* Fix the constructor main block if we're adding extra stmts */
10868       if (compound)
10869         {
10870           compound = add_stmt_to_compound (compound, NULL_TREE,
10871                                            BLOCK_EXPR_BODY (main_block));
10872           BLOCK_EXPR_BODY (main_block) = compound;
10873         }
10874     }
10875 }
10876
10877 /* Browse constructors in the super class, searching for a constructor
10878    that doesn't take any argument. Return 0 if one is found, 1
10879    otherwise.  If the current class is an anonymous inner class, look
10880    for something that has the same signature. */
10881
10882 static int
10883 verify_constructor_super (mdecl)
10884      tree mdecl;
10885 {
10886   tree class = CLASSTYPE_SUPER (current_class);
10887   tree sdecl;
10888
10889   if (!class)
10890     return 0;
10891
10892   if (ANONYMOUS_CLASS_P (current_class))
10893     {
10894       tree mdecl_arg_type;
10895       SKIP_THIS_AND_ARTIFICIAL_PARMS (mdecl_arg_type, mdecl);
10896       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10897         if (DECL_CONSTRUCTOR_P (sdecl))
10898           {
10899             tree arg_type;
10900             for (arg_type = TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl)));
10901                  arg_type != end_params_node && 
10902                    mdecl_arg_type != end_params_node;
10903                  arg_type = TREE_CHAIN (arg_type), 
10904                  mdecl_arg_type = TREE_CHAIN (mdecl_arg_type))
10905               if (TREE_VALUE (arg_type) != TREE_VALUE (mdecl_arg_type))
10906                 break;
10907
10908             if (arg_type == end_params_node && 
10909                 mdecl_arg_type == end_params_node)
10910               return 0;
10911           }
10912     }
10913   else
10914     {
10915       for (sdecl = TYPE_METHODS (class); sdecl; sdecl = TREE_CHAIN (sdecl))
10916         {
10917           if (DECL_CONSTRUCTOR_P (sdecl)
10918               && TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (sdecl))) 
10919                  == end_params_node)
10920             return 0;
10921         }
10922     }
10923   return 1;
10924 }
10925
10926 /* Generate code for all context remembered for code generation.  */
10927
10928 void
10929 java_expand_classes ()
10930 {
10931   int save_error_count = 0;
10932   static struct parser_ctxt *saved_ctxp = NULL;
10933
10934   java_parse_abort_on_error ();
10935   if (!(ctxp = ctxp_for_generation))
10936     return;
10937   java_layout_classes ();
10938   java_parse_abort_on_error ();
10939
10940   /* The list of packages declaration seen so far needs to be
10941      reversed, so that package declared in a file being compiled gets
10942      priority over packages declared as a side effect of parsing other
10943      files.*/
10944   package_list = nreverse (package_list);
10945
10946   saved_ctxp = ctxp_for_generation;
10947   for (; ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10948     {
10949       ctxp = ctxp_for_generation;
10950       lang_init_source (2);            /* Error msgs have method prototypes */
10951       java_complete_expand_classes (); /* Complete and expand classes */
10952       java_parse_abort_on_error ();
10953     }
10954
10955   /* Find anonymous classes and expand their constructor, now they
10956      have been fixed. */
10957   for (ctxp_for_generation = saved_ctxp;
10958        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10959     {
10960       tree current;
10961       ctxp = ctxp_for_generation;
10962       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10963         {
10964           current_class = TREE_TYPE (current);
10965           if (ANONYMOUS_CLASS_P (current_class))
10966             {
10967               tree d;
10968               for (d = TYPE_METHODS (current_class); d; d = TREE_CHAIN (d))
10969                 {
10970                   if (DECL_CONSTRUCTOR_P (d))
10971                     {
10972                       restore_line_number_status (1);
10973                       reset_method_name (d);
10974                       java_complete_expand_method (d);
10975                       restore_line_number_status (0);
10976                       break;    /* We now there are no other ones */
10977                     }
10978                 }
10979             }
10980         }
10981     }
10982
10983   /* If we've found error at that stage, don't try to generate
10984      anything, unless we're emitting xrefs or checking the syntax only
10985      (but not using -fsyntax-only for the purpose of generating
10986      bytecode. */
10987   if (java_error_count && !flag_emit_xref 
10988       && (!flag_syntax_only && !flag_emit_class_files))
10989     return;
10990
10991   /* Now things are stable, go for generation of the class data. */
10992   for (ctxp_for_generation = saved_ctxp;
10993        ctxp_for_generation; ctxp_for_generation = ctxp_for_generation->next)
10994     {
10995       tree current;
10996       ctxp = ctxp_for_generation;
10997       for (current = ctxp->class_list; current; current = TREE_CHAIN (current))
10998         {
10999           current_class = TREE_TYPE (current);
11000           outgoing_cpool = TYPE_CPOOL (current_class);
11001           if (flag_emit_class_files)
11002             write_classfile (current_class);
11003           if (flag_emit_xref)
11004             expand_xref (current_class);
11005           else if (! flag_syntax_only)
11006             finish_class ();
11007         }
11008     }
11009 }
11010
11011 /* Wrap non WFL PRIMARY around a WFL and set EXPR_WFL_QUALIFICATION to
11012    a tree list node containing RIGHT. Fore coming RIGHTs will be
11013    chained to this hook. LOCATION contains the location of the
11014    separating `.' operator.  */
11015
11016 static tree
11017 make_qualified_primary (primary, right, location)
11018      tree primary, right;
11019      int location;
11020 {
11021   tree wfl;
11022
11023   if (TREE_CODE (primary) != EXPR_WITH_FILE_LOCATION)
11024     wfl = build_wfl_wrap (primary);
11025   else
11026     {
11027       wfl = primary;
11028       /* If wfl wasn't qualified, we build a first anchor */
11029       if (!EXPR_WFL_QUALIFICATION (wfl))
11030         EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (wfl, NULL_TREE);
11031     }
11032
11033   /* And chain them */
11034   EXPR_WFL_LINECOL (right) = location;
11035   chainon (EXPR_WFL_QUALIFICATION (wfl), build_tree_list (right, NULL_TREE));
11036   PRIMARY_P (wfl) =  1;
11037   return wfl;
11038 }
11039
11040 /* Simple merge of two name separated by a `.' */
11041
11042 static tree
11043 merge_qualified_name (left, right)
11044      tree left, right;
11045 {
11046   tree node;
11047   if (!left && !right)
11048     return NULL_TREE;
11049
11050   if (!left)
11051     return right;
11052
11053   if (!right)
11054     return left;
11055
11056   obstack_grow (&temporary_obstack, IDENTIFIER_POINTER (left),
11057                 IDENTIFIER_LENGTH (left));
11058   obstack_1grow (&temporary_obstack, '.');
11059   obstack_grow0 (&temporary_obstack, IDENTIFIER_POINTER (right),
11060                  IDENTIFIER_LENGTH (right));
11061   node =  get_identifier (obstack_base (&temporary_obstack));
11062   obstack_free (&temporary_obstack, obstack_base (&temporary_obstack));
11063   QUALIFIED_P (node) = 1;
11064   return node;
11065 }
11066
11067 /* Merge the two parts of a qualified name into LEFT.  Set the
11068    location information of the resulting node to LOCATION, usually
11069    inherited from the location information of the `.' operator. */
11070
11071 static tree
11072 make_qualified_name (left, right, location)
11073      tree left, right;
11074      int location;
11075 {
11076 #ifdef USE_COMPONENT_REF
11077   tree node = build (COMPONENT_REF, NULL_TREE, left, right);
11078   EXPR_WFL_LINECOL (node) = location;
11079   return node;
11080 #else
11081   tree left_id = EXPR_WFL_NODE (left);
11082   tree right_id = EXPR_WFL_NODE (right);
11083   tree wfl, merge;
11084
11085   merge = merge_qualified_name (left_id, right_id);
11086
11087   /* Left wasn't qualified and is now qualified */
11088   if (!QUALIFIED_P (left_id))
11089     {
11090       tree wfl = build_expr_wfl (left_id, ctxp->filename, 0, 0);
11091       EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (left);
11092       EXPR_WFL_QUALIFICATION (left) = build_tree_list (wfl, NULL_TREE);
11093     }
11094   
11095   wfl = build_expr_wfl (right_id, ctxp->filename, 0, 0);
11096   EXPR_WFL_LINECOL (wfl) = location;
11097   chainon (EXPR_WFL_QUALIFICATION (left), build_tree_list (wfl, NULL_TREE));
11098
11099   EXPR_WFL_NODE (left) = merge;
11100   return left;
11101 #endif
11102 }
11103
11104 /* Extract the last identifier component of the qualified in WFL. The
11105    last identifier is removed from the linked list */
11106
11107 static tree
11108 cut_identifier_in_qualified (wfl)
11109      tree wfl;
11110 {
11111   tree q;
11112   tree previous = NULL_TREE;
11113   for (q = EXPR_WFL_QUALIFICATION (wfl); ; previous = q, q = TREE_CHAIN (q))
11114     if (!TREE_CHAIN (q))
11115       {
11116         if (!previous)
11117           fatal ("Operating on a non qualified qualified WFL - cut_identifier_in_qualified");
11118         TREE_CHAIN (previous) = NULL_TREE;
11119         return TREE_PURPOSE (q);
11120       }
11121 }
11122
11123 /* Resolve the expression name NAME. Return its decl.  */
11124
11125 static tree
11126 resolve_expression_name (id, orig)
11127      tree id;
11128      tree *orig;
11129 {
11130   tree name = EXPR_WFL_NODE (id);
11131   tree decl;
11132
11133   /* 6.5.5.1: Simple expression names */
11134   if (!PRIMARY_P (id) && !QUALIFIED_P (name))
11135     {
11136       /* 15.13.1: NAME can appear within the scope of a local variable
11137          declaration */
11138       if ((decl = IDENTIFIER_LOCAL_VALUE (name)))
11139         return decl;
11140
11141       /* 15.13.1: NAME can appear within a class declaration */
11142       else 
11143         {
11144           decl = lookup_field_wrapper (current_class, name);
11145
11146           /* Last chance: if we're within the context of an inner
11147              class, we might be trying to access a local variable
11148              defined in an outer context. We try to look for it
11149              now. */
11150           if (!decl && INNER_CLASS_TYPE_P (current_class))
11151             {
11152               char *alias_buffer;
11153               MANGLE_OUTER_LOCAL_VARIABLE_NAME (alias_buffer, name);
11154               name = get_identifier (alias_buffer);
11155               decl = lookup_field_wrapper (current_class, name);
11156               if (decl)
11157                 FIELD_LOCAL_ALIAS_USED (decl) = 1;
11158             }
11159
11160           if (decl)
11161             {
11162               tree access = NULL_TREE;
11163               int fs = FIELD_STATIC (decl);
11164               /* Instance variable (8.3.1.1) can't appear within
11165                  static method, static initializer or initializer for
11166                  a static variable. */
11167               if (!fs && METHOD_STATIC (current_function_decl))
11168                 {
11169                   static_ref_err (id, name, current_class);
11170                   return error_mark_node;
11171                 }
11172               /* Instance variables can't appear as an argument of
11173                  an explicit constructor invocation */
11174               if (!fs && ctxp->explicit_constructor_p)
11175                 {
11176                   parse_error_context
11177                     (id, "Can't reference `%s' before the superclass constructor has been called", IDENTIFIER_POINTER (name));
11178                   return error_mark_node;
11179                 }
11180
11181               /* If we're processing an inner class and we're trying
11182                  to access a field belonging to an outer class, build
11183                  the access to the field */
11184               if (!fs && outer_field_access_p (current_class, decl))
11185                 return build_outer_field_access (id, decl);
11186
11187               /* Otherwise build what it takes to access the field */
11188               access = build_field_ref ((fs ? NULL_TREE : current_this),
11189                                         DECL_CONTEXT (decl), name);
11190               if (fs && !flag_emit_class_files && !flag_emit_xref)
11191                 access = build_class_init (DECL_CONTEXT (access), access);
11192               /* We may be asked to save the real field access node */
11193               if (orig)
11194                 *orig = access;
11195               /* And we return what we got */
11196               return access;
11197             }
11198           /* Fall down to error report on undefined variable */
11199         }
11200     }
11201   /* 6.5.5.2 Qualified Expression Names */
11202   else
11203     {
11204       if (orig)
11205         *orig = NULL_TREE;
11206       qualify_ambiguous_name (id);
11207       /* 15.10.1 Field Access Using a Primary and/or Expression Name */
11208       /* 15.10.2: Accessing Superclass Members using super */
11209       return resolve_field_access (id, orig, NULL);
11210     }
11211
11212   /* We've got an error here */
11213   parse_error_context (id, "Undefined variable `%s'", 
11214                        IDENTIFIER_POINTER (name));
11215
11216   return error_mark_node;
11217 }
11218
11219 static void
11220 static_ref_err (wfl, field_id, class_type)
11221     tree wfl, field_id, class_type;
11222 {
11223   parse_error_context 
11224     (wfl, 
11225      "Can't make a static reference to nonstatic variable `%s' in class `%s'",
11226      IDENTIFIER_POINTER (field_id), 
11227      IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (class_type))));
11228 }
11229
11230 /* 15.10.1 Field Acess Using a Primary and/or Expression Name.
11231    We return something suitable to generate the field access. We also
11232    return the field decl in FIELD_DECL and its type in FIELD_TYPE.  If
11233    recipient's address can be null. */
11234
11235 static tree
11236 resolve_field_access (qual_wfl, field_decl, field_type)
11237      tree qual_wfl;
11238      tree *field_decl, *field_type;
11239 {
11240   int is_static = 0;
11241   tree field_ref;
11242   tree decl, where_found, type_found;
11243
11244   if (resolve_qualified_expression_name (qual_wfl, &decl,
11245                                          &where_found, &type_found))
11246     return error_mark_node;
11247
11248   /* Resolve the LENGTH field of an array here */
11249   if (DECL_NAME (decl) == length_identifier_node && TYPE_ARRAY_P (type_found)
11250       && ! flag_emit_class_files && ! flag_emit_xref)
11251     {
11252       tree length = build_java_array_length_access (where_found);
11253       field_ref =
11254         build_java_arraynull_check (type_found, length, int_type_node);
11255     }
11256   /* We might have been trying to resolve field.method(). In which
11257      case, the resolution is over and decl is the answer */
11258   else if (JDECL_P (decl) && IDENTIFIER_LOCAL_VALUE (DECL_NAME (decl)) == decl)
11259     field_ref = decl;
11260   else if (JDECL_P (decl))
11261     {
11262       int static_final_found = 0;
11263       if (!type_found)
11264         type_found = DECL_CONTEXT (decl);
11265       is_static = JDECL_P (decl) && FIELD_STATIC (decl);
11266       if (FIELD_FINAL (decl) 
11267           && JPRIMITIVE_TYPE_P (TREE_TYPE (decl))
11268           && DECL_LANG_SPECIFIC (decl)
11269           && DECL_INITIAL (decl))
11270         {
11271           field_ref = DECL_INITIAL (decl);
11272           static_final_found = 1;
11273         }
11274       else
11275         field_ref = build_field_ref ((is_static && !flag_emit_xref? 
11276                                       NULL_TREE : where_found), 
11277                                      type_found, DECL_NAME (decl));
11278       if (field_ref == error_mark_node)
11279         return error_mark_node;
11280       if (is_static && !static_final_found 
11281           && !flag_emit_class_files && !flag_emit_xref)
11282         field_ref = build_class_init (type_found, field_ref);
11283     }
11284   else
11285     field_ref = decl;
11286
11287   if (field_decl)
11288     *field_decl = decl;
11289   if (field_type)
11290     *field_type = (QUAL_DECL_TYPE (decl) ? 
11291                    QUAL_DECL_TYPE (decl) : TREE_TYPE (decl));
11292   return field_ref;
11293 }
11294
11295 /* If NODE is an access to f static field, strip out the class
11296    initialization part and return the field decl, otherwise, return
11297    NODE. */
11298
11299 static tree
11300 strip_out_static_field_access_decl (node)
11301     tree node;
11302 {
11303   if (TREE_CODE (node) == COMPOUND_EXPR)
11304     {
11305       tree op1 = TREE_OPERAND (node, 1);
11306       if (TREE_CODE (op1) == COMPOUND_EXPR)
11307          {
11308            tree call = TREE_OPERAND (op1, 0);
11309            if (TREE_CODE (call) == CALL_EXPR
11310                && TREE_CODE (TREE_OPERAND (call, 0)) == ADDR_EXPR
11311                && TREE_OPERAND (TREE_OPERAND (call, 0), 0)
11312                == soft_initclass_node)
11313              return TREE_OPERAND (op1, 1);
11314          }
11315       else if (JDECL_P (op1))
11316         return op1;
11317     }
11318   return node;
11319 }
11320
11321 /* 6.5.5.2: Qualified Expression Names */
11322
11323 static int
11324 resolve_qualified_expression_name (wfl, found_decl, where_found, type_found)
11325      tree wfl;
11326      tree *found_decl, *type_found, *where_found;
11327 {
11328   int from_type = 0;            /* Field search initiated from a type */
11329   int from_super = 0, from_cast = 0, from_qualified_this = 0;
11330   int previous_call_static = 0;
11331   int is_static;
11332   tree decl = NULL_TREE, type = NULL_TREE, q;
11333   /* For certain for of inner class instantiation */
11334   tree saved_current, saved_this;               
11335 #define RESTORE_THIS_AND_CURRENT_CLASS                          \
11336   { current_class = saved_current; current_this = saved_this;}
11337
11338   *type_found = *where_found = NULL_TREE;
11339
11340   for (q = EXPR_WFL_QUALIFICATION (wfl); q; q = TREE_CHAIN (q))
11341     {
11342       tree qual_wfl = QUAL_WFL (q);
11343       tree ret_decl;            /* for EH checking */
11344       int location;             /* for EH checking */
11345
11346       /* 15.10.1 Field Access Using a Primary */
11347       switch (TREE_CODE (qual_wfl))
11348         {
11349         case CALL_EXPR:
11350         case NEW_CLASS_EXPR:
11351           /* If the access to the function call is a non static field,
11352              build the code to access it. */
11353           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11354             {
11355               decl = maybe_access_field (decl, *where_found, 
11356                                          DECL_CONTEXT (decl));
11357               if (decl == error_mark_node)
11358                 return 1;
11359             }
11360
11361           /* And code for the function call */
11362           if (complete_function_arguments (qual_wfl))
11363             return 1;
11364
11365           /* We might have to setup a new current class and a new this
11366              for the search of an inner class, relative to the type of
11367              a expression resolved as `decl'. The current values are
11368              saved and restored shortly after */
11369           saved_current = current_class;
11370           saved_this = current_this;
11371           if (decl && TREE_CODE (qual_wfl) == NEW_CLASS_EXPR)
11372             {
11373               current_class = type;
11374               current_this = decl;
11375             }
11376
11377           if (from_super && TREE_CODE (qual_wfl) == CALL_EXPR)
11378             CALL_USING_SUPER (qual_wfl) = 1;
11379           location = (TREE_CODE (qual_wfl) == CALL_EXPR ?
11380                       EXPR_WFL_LINECOL (TREE_OPERAND (qual_wfl, 0)) : 0);
11381           *where_found = patch_method_invocation (qual_wfl, decl, type, 
11382                                                   &is_static, &ret_decl);
11383           if (*where_found == error_mark_node)
11384             {
11385               RESTORE_THIS_AND_CURRENT_CLASS;
11386               return 1;
11387             }
11388           *type_found = type = QUAL_DECL_TYPE (*where_found);
11389
11390           /* If we're creating an inner class instance, check for that
11391              an enclosing instance is in scope */
11392           if (TREE_CODE (qual_wfl) == NEW_CLASS_EXPR
11393               && INNER_ENCLOSING_SCOPE_CHECK (type))
11394             {
11395               parse_error_context 
11396                 (qual_wfl, "No enclosing instance for inner class `%s' is in scope%s",
11397                  lang_printable_name (type, 0),
11398                  (!current_this ? "" :
11399                   "; an explicit one must be provided when creating this inner class"));
11400               RESTORE_THIS_AND_CURRENT_CLASS;
11401               return 1;
11402             }
11403
11404           /* In case we had to change then to resolve a inner class
11405              instantiation using a primary qualified by a `new' */
11406           RESTORE_THIS_AND_CURRENT_CLASS;
11407
11408           /* EH check */
11409           if (location)
11410             check_thrown_exceptions (location, ret_decl);
11411
11412           /* If the previous call was static and this one is too,
11413              build a compound expression to hold the two (because in
11414              that case, previous function calls aren't transported as
11415              forcoming function's argument. */
11416           if (previous_call_static && is_static)
11417             {
11418               decl = build (COMPOUND_EXPR, type, decl, *where_found);
11419               TREE_SIDE_EFFECTS (decl) = 1;
11420             }
11421           else
11422             {
11423               previous_call_static = is_static;
11424               decl = *where_found;
11425             }
11426           from_type = 0;
11427           continue;
11428
11429         case NEW_ARRAY_EXPR:
11430         case NEW_ANONYMOUS_ARRAY_EXPR:
11431           *where_found = decl = java_complete_tree (qual_wfl);
11432           if (decl == error_mark_node)
11433             return 1;
11434           *type_found = type = QUAL_DECL_TYPE (decl);
11435           CLASS_LOADED_P (type) = 1;
11436           continue;
11437
11438         case CONVERT_EXPR:
11439           *where_found = decl = java_complete_tree (qual_wfl);
11440           if (decl == error_mark_node)
11441             return 1;
11442           *type_found = type = QUAL_DECL_TYPE (decl);
11443           from_cast = 1;
11444           continue;
11445
11446         case CONDITIONAL_EXPR:
11447         case STRING_CST:
11448         case MODIFY_EXPR:
11449           *where_found = decl = java_complete_tree (qual_wfl);
11450           if (decl == error_mark_node)
11451             return 1;
11452           *type_found = type = QUAL_DECL_TYPE (decl);
11453           continue;
11454
11455         case ARRAY_REF:
11456           /* If the access to the function call is a non static field,
11457              build the code to access it. */
11458           if (JDECL_P (decl) && !FIELD_STATIC (decl))
11459             {
11460               decl = maybe_access_field (decl, *where_found, type);
11461               if (decl == error_mark_node)
11462                 return 1;
11463             }
11464           /* And code for the array reference expression */
11465           decl = java_complete_tree (qual_wfl);
11466           if (decl == error_mark_node)
11467             return 1;
11468           type = QUAL_DECL_TYPE (decl);
11469           continue;
11470
11471         case PLUS_EXPR:
11472           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11473             return 1;
11474           if ((type = patch_string (decl)))
11475             decl = type;
11476           *where_found = QUAL_RESOLUTION (q) = decl;
11477           *type_found = type = TREE_TYPE (decl);
11478           break;
11479
11480         case CLASS_LITERAL:
11481           if ((decl = java_complete_tree (qual_wfl)) == error_mark_node)
11482             return 1;
11483           *where_found = QUAL_RESOLUTION (q) = decl;
11484           *type_found = type = TREE_TYPE (decl);
11485           break;
11486
11487         default:
11488           /* Fix for -Wall Just go to the next statement. Don't
11489              continue */
11490           break;
11491         }
11492
11493       /* If we fall here, we weren't processing a (static) function call. */
11494       previous_call_static = 0;
11495
11496       /* It can be the keyword THIS */
11497       if (EXPR_WFL_NODE (qual_wfl) == this_identifier_node)
11498         {
11499           if (!current_this)
11500             {
11501               parse_error_context 
11502                 (wfl, "Keyword `this' used outside allowed context");
11503               return 1;
11504             }
11505           if (ctxp->explicit_constructor_p)
11506             {
11507               parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
11508               return 1;
11509             }
11510           /* We have to generate code for intermediate acess */
11511           if (!from_type || TREE_TYPE (TREE_TYPE (current_this)) == type)
11512             {
11513               *where_found = decl = current_this;
11514               *type_found = type = QUAL_DECL_TYPE (decl);
11515             }
11516           /* We're trying to access the this from somewhere else... */
11517           else
11518             {
11519               *where_found = decl = build_current_thisn (type);
11520               from_qualified_this = 1;
11521             }
11522
11523           from_type = 0;
11524           continue;
11525         }
11526
11527       /* 15.10.2 Accessing Superclass Members using SUPER */
11528       if (EXPR_WFL_NODE (qual_wfl) == super_identifier_node)
11529         {
11530           tree node;
11531           /* Check on the restricted use of SUPER */
11532           if (METHOD_STATIC (current_function_decl)
11533               || current_class == object_type_node)
11534             {
11535               parse_error_context 
11536                 (wfl, "Keyword `super' used outside allowed context");
11537               return 1;
11538             }
11539           /* Otherwise, treat SUPER as (SUPER_CLASS)THIS */
11540           node = build_cast (EXPR_WFL_LINECOL (qual_wfl), 
11541                              CLASSTYPE_SUPER (current_class),
11542                              build_this (EXPR_WFL_LINECOL (qual_wfl)));
11543           *where_found = decl = java_complete_tree (node);
11544           if (decl == error_mark_node)
11545             return 1;
11546           *type_found = type = QUAL_DECL_TYPE (decl);
11547           from_super = from_type = 1;
11548           continue;
11549         }
11550
11551       /* 15.13.1: Can't search for field name in packages, so we
11552          assume a variable/class name was meant. */
11553       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
11554         {
11555           tree name = resolve_package (wfl, &q);
11556           if (name)
11557             {
11558               tree list;
11559               *where_found = decl = resolve_no_layout (name, qual_wfl);
11560               /* We wan't to be absolutely that the class is laid
11561                  out. We're going to search something inside it. */
11562               *type_found = type = TREE_TYPE (decl);
11563               layout_class (type);
11564               from_type = 1;
11565
11566               /* Fix them all the way down, if any are left. */
11567               if (q)
11568                 {
11569                   list = TREE_CHAIN (q);
11570                   while (list)
11571                     {
11572                       RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (list)) = 1;
11573                       RESOLVE_PACKAGE_NAME_P (QUAL_WFL (list)) = 0;
11574                       list = TREE_CHAIN (list);
11575                     }
11576                 }
11577             }
11578           else
11579             {
11580               if (from_super || from_cast)
11581                 parse_error_context 
11582                   ((from_cast ? qual_wfl : wfl),
11583                    "No variable `%s' defined in class `%s'",
11584                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11585                    lang_printable_name (type, 0));
11586               else
11587                 parse_error_context
11588                   (qual_wfl, "Undefined variable or class name: `%s'",
11589                    IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)));
11590               return 1;
11591             }
11592         }
11593
11594       /* We have a type name. It's been already resolved when the
11595          expression was qualified. */
11596       else if (RESOLVE_TYPE_NAME_P (qual_wfl))
11597         {
11598           if (!(decl = QUAL_RESOLUTION (q)))
11599             return 1;           /* Error reported already */
11600
11601           /* Sneak preview. If next we see a `new', we're facing a
11602              qualification with resulted in a type being selected
11603              instead of a field.  Report the error */
11604           if(TREE_CHAIN (q) 
11605              && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR)
11606             {
11607               parse_error_context (qual_wfl, "Undefined variable `%s'",
11608                                    IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
11609               return 1;
11610             }
11611
11612           if (not_accessible_p (TREE_TYPE (decl), decl, 0))
11613             {
11614               parse_error_context 
11615                 (qual_wfl, "Can't access %s field `%s.%s' from `%s'",
11616                  java_accstring_lookup (get_access_flags_from_decl (decl)),
11617                  GET_TYPE_NAME (type),
11618                  IDENTIFIER_POINTER (DECL_NAME (decl)),
11619                  IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
11620               return 1;
11621             }
11622           check_deprecation (qual_wfl, decl);
11623
11624           type = TREE_TYPE (decl);
11625           from_type = 1;
11626         }
11627       /* We resolve and expression name */
11628       else 
11629         {
11630           tree field_decl = NULL_TREE;
11631
11632           /* If there exists an early resolution, use it. That occurs
11633              only once and we know that there are more things to
11634              come. Don't do that when processing something after SUPER
11635              (we need more thing to be put in place below */
11636           if (!from_super && QUAL_RESOLUTION (q))
11637             {
11638               decl = QUAL_RESOLUTION (q);
11639               if (!type)
11640                 {
11641                   if (TREE_CODE (decl) == FIELD_DECL && !FIELD_STATIC (decl))
11642                     {
11643                       if (current_this)
11644                         *where_found = current_this;
11645                       else
11646                         {
11647                           static_ref_err (qual_wfl, DECL_NAME (decl),
11648                                           current_class);
11649                           return 1;
11650                         }
11651                     }
11652                   else
11653                     {
11654                       *where_found = TREE_TYPE (decl);
11655                       if (TREE_CODE (*where_found) == POINTER_TYPE)
11656                         *where_found = TREE_TYPE (*where_found);
11657                     }
11658                 }
11659             }
11660
11661           /* We have to search for a field, knowing the type of its
11662              container. The flag FROM_TYPE indicates that we resolved
11663              the last member of the expression as a type name, which
11664              means that for the resolution of this field, we'll look
11665              for other errors than if it was resolved as a member of
11666              an other field. */
11667           else
11668             {
11669               int is_static;
11670               tree field_decl_type; /* For layout */
11671
11672               if (!from_type && !JREFERENCE_TYPE_P (type))
11673                 {
11674                   parse_error_context 
11675                     (qual_wfl, "Attempt to reference field `%s' in `%s %s'",
11676                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)),
11677                      lang_printable_name (type, 0),
11678                      IDENTIFIER_POINTER (DECL_NAME (field_decl)));
11679                   return 1;
11680                 }
11681               
11682               field_decl = lookup_field_wrapper (type,
11683                                                  EXPR_WFL_NODE (qual_wfl));
11684               if (field_decl == NULL_TREE)
11685                 {
11686                   parse_error_context 
11687                     (qual_wfl, "No variable `%s' defined in type `%s'",
11688                      IDENTIFIER_POINTER (EXPR_WFL_NODE (qual_wfl)), 
11689                      GET_TYPE_NAME (type));
11690                   return 1;
11691                 }
11692               if (field_decl == error_mark_node)
11693                 return 1;
11694
11695               /* Layout the type of field_decl, since we may need
11696                  it. Don't do primitive types or loaded classes. The
11697                  situation of non primitive arrays may not handled
11698                  properly here. FIXME */
11699               if (TREE_CODE (TREE_TYPE (field_decl)) == POINTER_TYPE)
11700                 field_decl_type = TREE_TYPE (TREE_TYPE (field_decl));
11701               else
11702                 field_decl_type = TREE_TYPE (field_decl);
11703               if (!JPRIMITIVE_TYPE_P (field_decl_type) 
11704                   && !CLASS_LOADED_P (field_decl_type)
11705                   && !TYPE_ARRAY_P (field_decl_type))
11706                 resolve_and_layout (field_decl_type, NULL_TREE);
11707               if (TYPE_ARRAY_P (field_decl_type))
11708                 CLASS_LOADED_P (field_decl_type) = 1;
11709               
11710               /* Check on accessibility here */
11711               if (not_accessible_p (type, field_decl, from_super))
11712                 {
11713                   parse_error_context 
11714                     (qual_wfl,
11715                      "Can't access %s field `%s.%s' from `%s'",
11716                      java_accstring_lookup 
11717                        (get_access_flags_from_decl (field_decl)),
11718                      GET_TYPE_NAME (type),
11719                      IDENTIFIER_POINTER (DECL_NAME (field_decl)),
11720                      IDENTIFIER_POINTER 
11721                        (DECL_NAME (TYPE_NAME (current_class))));
11722                   return 1;
11723                 }
11724               check_deprecation (qual_wfl, field_decl);
11725               
11726               /* There are things to check when fields are accessed
11727                  from type. There are no restrictions on a static
11728                  declaration of the field when it is accessed from an
11729                  interface */
11730               is_static = FIELD_STATIC (field_decl);
11731               if (!from_super && from_type 
11732                   && !TYPE_INTERFACE_P (type) 
11733                   && !is_static 
11734                   && (current_function_decl 
11735                       && METHOD_STATIC (current_function_decl)))
11736                 {
11737                   static_ref_err (qual_wfl, EXPR_WFL_NODE (qual_wfl), type);
11738                   return 1;
11739                 }
11740               from_cast = from_super = 0;
11741
11742               /* It's an access from a type but it isn't static, we
11743                  make it relative to `this'. */
11744               if (!is_static && from_type)
11745                 decl = current_this;
11746
11747               /* If we need to generate something to get a proper
11748                  handle on what this field is accessed from, do it
11749                  now. */
11750               if (!is_static)
11751                 {
11752                   decl = maybe_access_field (decl, *where_found, *type_found);
11753                   if (decl == error_mark_node)
11754                     return 1;
11755                 }
11756
11757               /* We want to keep the location were found it, and the type
11758                  we found. */
11759               *where_found = decl;
11760               *type_found = type;
11761
11762               /* Generate the correct expression for field access from
11763                  qualified this */
11764               if (from_qualified_this)
11765                 {
11766                   field_decl = build_outer_field_access (qual_wfl, field_decl);
11767                   from_qualified_this = 0;
11768                 }
11769
11770               /* This is the decl found and eventually the next one to
11771                  search from */
11772               decl = field_decl;
11773             }
11774           from_type = 0;
11775           type = QUAL_DECL_TYPE (decl);
11776
11777           /* Sneak preview. If decl is qualified by a `new', report
11778              the error here to be accurate on the peculiar construct */
11779           if (TREE_CHAIN (q) 
11780               && TREE_CODE (TREE_PURPOSE (TREE_CHAIN (q))) == NEW_CLASS_EXPR
11781               && !JREFERENCE_TYPE_P (type))
11782             {
11783               parse_error_context (qual_wfl, "Attempt to reference field `new' in a `%s'", 
11784                                    lang_printable_name (type, 0));
11785               return 1;
11786             }
11787         }
11788       /* `q' might have changed due to a after package resolution
11789          re-qualification */
11790       if (!q)
11791         break;
11792     }
11793   *found_decl = decl;
11794   return 0;
11795 }
11796
11797 /* 6.6 Qualified name and access control. Returns 1 if MEMBER (a decl)
11798    can't be accessed from REFERENCE (a record type). */
11799
11800 static int
11801 not_accessible_p (reference, member, from_super)
11802      tree reference, member;
11803      int from_super;
11804 {
11805   int access_flag = get_access_flags_from_decl (member);
11806
11807   /* Access always granted for members declared public */
11808   if (access_flag & ACC_PUBLIC)
11809     return 0;
11810   
11811   /* Check access on protected members */
11812   if (access_flag & ACC_PROTECTED)
11813     {
11814       /* Access granted if it occurs from within the package
11815          containing the class in which the protected member is
11816          declared */
11817       if (class_in_current_package (DECL_CONTEXT (member)))
11818         return 0;
11819
11820       /* If accessed with the form `super.member', then access is granted */
11821       if (from_super)
11822         return 0;
11823
11824       /* Otherwise, access is granted if occuring from the class where
11825          member is declared or a subclass of it */
11826       if (inherits_from_p (reference, current_class))
11827         return 0;
11828       return 1;
11829     }
11830
11831   /* Check access on private members. Access is granted only if it
11832      occurs from within the class in witch it is declared. Exceptions
11833      are access from inner-classes. This section is probably not
11834      complete. FIXME */
11835   if (access_flag & ACC_PRIVATE)
11836     return (current_class == DECL_CONTEXT (member) ? 0 : 
11837             (INNER_CLASS_TYPE_P (current_class) ? 0 : 1));
11838
11839   /* Default access are permitted only when occuring within the
11840      package in which the type (REFERENCE) is declared. In other words,
11841      REFERENCE is defined in the current package */
11842   if (ctxp->package)
11843     return !class_in_current_package (reference);
11844   
11845   /* Otherwise, access is granted */
11846   return 0;
11847 }
11848
11849 /* Test deprecated decl access.  */
11850 static void
11851 check_deprecation (wfl, decl)
11852      tree wfl, decl;
11853 {
11854   const char *file = DECL_SOURCE_FILE (decl);
11855   /* Complain if the field is deprecated and the file it was defined
11856      in isn't compiled at the same time the file which contains its
11857      use is */
11858   if (DECL_DEPRECATED (decl) 
11859       && !IS_A_COMMAND_LINE_FILENAME_P (get_identifier (file)))
11860     {
11861       char the [20];
11862       switch (TREE_CODE (decl))
11863         {
11864         case FUNCTION_DECL:
11865           strcpy (the, "method");
11866           break;
11867         case FIELD_DECL:
11868           strcpy (the, "field");
11869           break;
11870         case TYPE_DECL:
11871           strcpy (the, "class");
11872           break;
11873         default:
11874           fatal ("unexpected DECL code - check_deprecation");
11875         }
11876       parse_warning_context 
11877         (wfl, "The %s `%s' in class `%s' has been deprecated", 
11878          the, lang_printable_name (decl, 0),
11879          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl)))));
11880     }
11881 }
11882
11883 /* Returns 1 if class was declared in the current package, 0 otherwise */
11884
11885 static int
11886 class_in_current_package (class)
11887      tree class;
11888 {
11889   static tree cache = NULL_TREE;
11890   int qualified_flag;
11891   tree left;
11892
11893   if (cache == class)
11894     return 1;
11895
11896   qualified_flag = QUALIFIED_P (DECL_NAME (TYPE_NAME (class)));
11897
11898   /* If the current package is empty and the name of CLASS is
11899      qualified, class isn't in the current package.  If there is a
11900      current package and the name of the CLASS is not qualified, class
11901      isn't in the current package */
11902   if ((!ctxp->package && qualified_flag) || (ctxp->package && !qualified_flag))
11903     return 0;
11904
11905   /* If there is not package and the name of CLASS isn't qualified,
11906      they belong to the same unnamed package */
11907   if (!ctxp->package && !qualified_flag)
11908     return 1;
11909
11910   /* Compare the left part of the name of CLASS with the package name */
11911   breakdown_qualified (&left, NULL, DECL_NAME (TYPE_NAME (class)));
11912   if (ctxp->package == left)
11913     {
11914       cache = class;
11915       return 1;
11916     }
11917   return 0;
11918 }
11919
11920 /* This function may generate code to access DECL from WHERE. This is
11921    done only if certain conditions meet.  */
11922
11923 static tree
11924 maybe_access_field (decl, where, type)
11925   tree decl, where, type;
11926 {
11927   if (TREE_CODE (decl) == FIELD_DECL && decl != current_this
11928       && !FIELD_STATIC (decl))
11929     decl = build_field_ref (where ? where : current_this, 
11930                             (type ? type : DECL_CONTEXT (decl)),
11931                             DECL_NAME (decl));
11932   return decl;
11933 }
11934
11935 /* Build a method invocation, by patching PATCH. If non NULL
11936    and according to the situation, PRIMARY and WHERE may be
11937    used. IS_STATIC is set to 1 if the invoked function is static. */
11938
11939 static tree
11940 patch_method_invocation (patch, primary, where, is_static, ret_decl)
11941      tree patch, primary, where;
11942      int *is_static;
11943      tree *ret_decl;
11944 {
11945   tree wfl = TREE_OPERAND (patch, 0);
11946   tree args = TREE_OPERAND (patch, 1);
11947   tree name = EXPR_WFL_NODE (wfl);
11948   tree list;
11949   int is_static_flag = 0;
11950   int is_super_init = 0;
11951   tree this_arg = NULL_TREE;
11952   
11953   /* Should be overriden if everything goes well. Otherwise, if
11954      something fails, it should keep this value. It stop the
11955      evaluation of a bogus assignment. See java_complete_tree,
11956      MODIFY_EXPR: for the reasons why we sometimes want to keep on
11957      evaluating an assignment */
11958   TREE_TYPE (patch) = error_mark_node;
11959
11960   /* Since lookup functions are messing with line numbers, save the
11961      context now.  */
11962   java_parser_context_save_global ();
11963
11964   /* 15.11.1: Compile-Time Step 1: Determine Class or Interface to Search */
11965
11966   /* Resolution of qualified name, excluding constructors */
11967   if (QUALIFIED_P (name) && !CALL_CONSTRUCTOR_P (patch))
11968     {
11969       tree identifier, identifier_wfl, type, resolved;
11970       /* Extract the last IDENTIFIER of the qualified
11971          expression. This is a wfl and we will use it's location
11972          data during error report. */
11973       identifier_wfl = cut_identifier_in_qualified (wfl);
11974       identifier = EXPR_WFL_NODE (identifier_wfl);
11975       
11976       /* Given the context, IDENTIFIER is syntactically qualified
11977          as a MethodName. We need to qualify what's before */
11978       qualify_ambiguous_name (wfl);
11979       resolved = resolve_field_access (wfl, NULL, NULL);
11980
11981       if (resolved == error_mark_node)
11982         PATCH_METHOD_RETURN_ERROR ();
11983
11984       type = GET_SKIP_TYPE (resolved);
11985       resolve_and_layout (type, NULL_TREE);
11986       list = lookup_method_invoke (0, identifier_wfl, type, identifier, args);
11987       args = nreverse (args);
11988
11989       /* We're resolving a call from a type */
11990       if (TREE_CODE (resolved) == TYPE_DECL)
11991         {
11992           if (CLASS_INTERFACE (resolved))
11993             {
11994               parse_error_context
11995                 (identifier_wfl,
11996                 "Can't make static reference to method `%s' in interface `%s'",
11997                  IDENTIFIER_POINTER (identifier), 
11998                  IDENTIFIER_POINTER (name));
11999               PATCH_METHOD_RETURN_ERROR ();
12000             }
12001           if (list && !METHOD_STATIC (list))
12002             {
12003               char *fct_name = xstrdup (lang_printable_name (list, 0));
12004               parse_error_context 
12005                 (identifier_wfl,
12006                  "Can't make static reference to method `%s %s' in class `%s'",
12007                  lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12008                  fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
12009               free (fct_name);
12010               PATCH_METHOD_RETURN_ERROR ();
12011             }
12012         }
12013       else
12014         this_arg = primary = resolved;
12015       
12016       /* IDENTIFIER_WFL will be used to report any problem further */
12017       wfl = identifier_wfl;
12018     }
12019   /* Resolution of simple names, names generated after a primary: or
12020      constructors */
12021   else
12022     {
12023       tree class_to_search = NULL_TREE;
12024       int lc;                   /* Looking for Constructor */
12025       
12026       /* We search constructor in their target class */
12027       if (CALL_CONSTRUCTOR_P (patch))
12028         {
12029           if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12030             class_to_search = EXPR_WFL_NODE (wfl);
12031           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) == 
12032                    this_identifier_node)
12033             class_to_search = NULL_TREE;
12034           else if (EXPR_WFL_NODE (TREE_OPERAND (patch, 0)) ==
12035                    super_identifier_node)
12036             {
12037               is_super_init = 1;
12038               if (CLASSTYPE_SUPER (current_class))
12039                 class_to_search = 
12040                   DECL_NAME (TYPE_NAME (CLASSTYPE_SUPER (current_class)));
12041               else
12042                 {
12043                   parse_error_context (wfl, "Can't invoke super constructor on java.lang.Object");
12044                   PATCH_METHOD_RETURN_ERROR ();
12045                 }
12046             }
12047
12048           /* Class to search is NULL if we're searching the current one */
12049           if (class_to_search)
12050             {
12051               class_to_search = resolve_and_layout (class_to_search, wfl);
12052
12053               if (!class_to_search)
12054                 {
12055                   parse_error_context 
12056                     (wfl, "Class `%s' not found in type declaration",
12057                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12058                   PATCH_METHOD_RETURN_ERROR ();
12059                 }
12060               
12061               /* Can't instantiate an abstract class, but we can
12062                  invoke it's constructor. It's use within the `new'
12063                  context is denied here. */
12064               if (CLASS_ABSTRACT (class_to_search) 
12065                   && TREE_CODE (patch) == NEW_CLASS_EXPR)
12066                 {
12067                   parse_error_context 
12068                     (wfl, "Class `%s' is an abstract class. It can't be instantiated",
12069                      IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
12070                   PATCH_METHOD_RETURN_ERROR ();
12071                 }
12072
12073               class_to_search = TREE_TYPE (class_to_search);
12074             }
12075           else
12076             class_to_search = current_class;
12077           lc = 1;
12078         }
12079       /* This is a regular search in the local class, unless an
12080          alternate class is specified. */
12081       else
12082         {
12083           class_to_search = (where ? where : current_class);
12084           lc = 0;
12085         }
12086
12087       /* NAME is a simple identifier or comes from a primary. Search
12088          in the class whose declaration contain the method being
12089          invoked. */
12090       resolve_and_layout (class_to_search, NULL_TREE);
12091
12092       list = lookup_method_invoke (lc, wfl, class_to_search, name, args);
12093       /* Don't continue if no method were found, as the next statement
12094          can't be executed then. */
12095       if (!list)
12096         PATCH_METHOD_RETURN_ERROR ();
12097
12098       /* Check for static reference if non static methods */
12099       if (check_for_static_method_reference (wfl, patch, list, 
12100                                              class_to_search, primary))
12101         PATCH_METHOD_RETURN_ERROR ();
12102
12103       /* Check for inner classes creation from illegal contexts */
12104       if (lc && (INNER_CLASS_TYPE_P (class_to_search)
12105                  && !CLASS_STATIC (TYPE_NAME (class_to_search)))
12106           && INNER_ENCLOSING_SCOPE_CHECK (class_to_search))
12107         {
12108           parse_error_context 
12109             (wfl, "No enclosing instance for inner class `%s' is in scope%s",
12110              lang_printable_name (class_to_search, 0),
12111              (!current_this ? "" :
12112               "; an explicit one must be provided when creating this inner class"));
12113           PATCH_METHOD_RETURN_ERROR ();
12114         }
12115
12116       /* Non static methods are called with the current object extra
12117          argument. If patch a `new TYPE()', the argument is the value
12118          returned by the object allocator. If method is resolved as a
12119          primary, use the primary otherwise use the current THIS. */
12120       args = nreverse (args);
12121       if (TREE_CODE (patch) != NEW_CLASS_EXPR)
12122         {
12123           this_arg = primary ? primary : current_this;
12124
12125           /* If we're using an access method, things are different.
12126              There are two familly of cases:
12127
12128              1) We're not generating bytecodes:
12129
12130              - LIST is non static. It's invocation is transformed from
12131                x(a1,...,an) into this$<n>.x(a1,....an).
12132              - LIST is static. It's invocation is transformed from
12133                x(a1,...,an) into TYPE_OF(this$<n>).x(a1,....an)
12134
12135              2) We're generating bytecodes:
12136              
12137              - LIST is non static. It's invocation is transformed from
12138                x(a1,....,an) into access$<n>(this$<n>,a1,...,an).
12139              - LIST is static. It's invocation is transformed from
12140                x(a1,....,an) into TYPEOF(this$<n>).x(a1,....an).
12141
12142              Of course, this$<n> can be abitrary complex, ranging from
12143              this$0 (the immediate outer context) to 
12144              access$0(access$0(...(this$0))). 
12145              
12146              maybe_use_access_method returns a non zero value if the
12147              this_arg has to be deplaced into the (then generated)
12148              stub argument list. In the mean time, the selected
12149              function might have be replaced by a generated stub. */
12150           if (maybe_use_access_method (is_super_init, &list, &this_arg))
12151             args = tree_cons (NULL_TREE, this_arg, args);
12152         }
12153     }
12154
12155   /* Merge point of all resolution schemes. If we have nothing, this
12156      is an error, already signaled */
12157   if (!list) 
12158     PATCH_METHOD_RETURN_ERROR ();
12159
12160   /* Check accessibility, position the is_static flag, build and
12161      return the call */
12162   if (not_accessible_p (DECL_CONTEXT (current_function_decl), list, 0))
12163     {
12164       char *fct_name = xstrdup (lang_printable_name (list, 0));
12165       parse_error_context 
12166         (wfl, "Can't access %s method `%s %s.%s' from `%s'",
12167          java_accstring_lookup (get_access_flags_from_decl (list)),
12168          lang_printable_name (TREE_TYPE (TREE_TYPE (list)), 0), 
12169          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (list)))), 
12170          fct_name, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))));
12171       free (fct_name);
12172       PATCH_METHOD_RETURN_ERROR ();
12173     }
12174   check_deprecation (wfl, list);
12175
12176   /* If invoking a innerclass constructor, there are hidden parameters
12177      to pass */
12178   if (TREE_CODE (patch) == NEW_CLASS_EXPR 
12179       && PURE_INNER_CLASS_TYPE_P (DECL_CONTEXT (list)))
12180     {
12181       /* And make sure we add the accessed local variables to be saved
12182          in field aliases. */
12183       args = build_alias_initializer_parameter_list
12184         (AIPL_FUNCTION_CTOR_INVOCATION, DECL_CONTEXT (list), args, NULL);
12185
12186       /* We have to reverse things. Find out why. FIXME */
12187       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (list)))
12188         args = nreverse (args);
12189       
12190       /* Secretely pass the current_this/primary as a second argument */
12191       if (primary || current_this)
12192         args = tree_cons (NULL_TREE, (primary ? primary : current_this), args);
12193       else
12194         args = tree_cons (NULL_TREE, integer_zero_node, args);
12195     }
12196
12197   is_static_flag = METHOD_STATIC (list);
12198   if (! METHOD_STATIC (list) && this_arg != NULL_TREE)
12199     args = tree_cons (NULL_TREE, this_arg, args);
12200
12201   /* In the context of an explicit constructor invocation, we can't
12202      invoke any method relying on `this'. Exceptions are: we're
12203      invoking a static function, primary exists and is not the current
12204      this, we're creating a new object. */
12205   if (ctxp->explicit_constructor_p 
12206       && !is_static_flag 
12207       && (!primary || primary == current_this)
12208       && (TREE_CODE (patch) != NEW_CLASS_EXPR))
12209     {
12210       parse_error_context (wfl, "Can't reference `this' before the superclass constructor has been called");
12211       PATCH_METHOD_RETURN_ERROR ();
12212     }
12213   java_parser_context_restore_global ();
12214   if (is_static) 
12215     *is_static = is_static_flag;
12216   /* Sometimes, we want the decl of the selected method. Such as for
12217      EH checking */
12218   if (ret_decl)
12219     *ret_decl = list;
12220   patch = patch_invoke (patch, list, args);
12221   if (is_super_init && CLASS_HAS_FINIT_P (current_class))
12222     {
12223       tree finit_parms, finit_call;
12224       
12225       /* Prepare to pass hidden parameters to $finit$, if any. */
12226       finit_parms = build_alias_initializer_parameter_list 
12227         (AIPL_FUNCTION_FINIT_INVOCATION, current_class, NULL_TREE, NULL);
12228
12229       finit_call = 
12230         build_method_invocation (build_wfl_node (finit_identifier_node),
12231                                  finit_parms);
12232
12233       /* Generate the code used to initialize fields declared with an
12234          initialization statement and build a compound statement along
12235          with the super constructor invocation. */
12236       patch = build (COMPOUND_EXPR, void_type_node, patch,
12237                      java_complete_tree (finit_call));
12238       CAN_COMPLETE_NORMALLY (patch) = 1;
12239     }
12240   return patch;
12241 }
12242
12243 /* Check that we're not trying to do a static reference to a method in
12244    non static method. Return 1 if it's the case, 0 otherwise. */
12245
12246 static int
12247 check_for_static_method_reference (wfl, node, method, where, primary)
12248      tree wfl, node, method, where, primary;
12249 {
12250   if (METHOD_STATIC (current_function_decl) 
12251       && !METHOD_STATIC (method) && !primary && !CALL_CONSTRUCTOR_P (node))
12252     {
12253       char *fct_name = xstrdup (lang_printable_name (method, 0));
12254       parse_error_context 
12255         (wfl, "Can't make static reference to method `%s %s' in class `%s'", 
12256          lang_printable_name (TREE_TYPE (TREE_TYPE (method)), 0), fct_name,
12257          IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (where))));
12258       free (fct_name);
12259       return 1;
12260     }
12261   return 0;
12262 }
12263
12264 /* Fix the invocation of *MDECL if necessary in the case of a
12265    invocation from an inner class. *THIS_ARG might be modified
12266    appropriately and an alternative access to *MDECL might be
12267    returned.  */
12268
12269 static int
12270 maybe_use_access_method (is_super_init, mdecl, this_arg)
12271      int is_super_init;
12272      tree *mdecl, *this_arg;
12273 {
12274   tree ctx;
12275   tree md = *mdecl, ta = *this_arg;
12276   int to_return = 0;
12277   int non_static_context = !METHOD_STATIC (md);
12278
12279   if (is_super_init 
12280       || DECL_CONTEXT (md) == current_class
12281       || !PURE_INNER_CLASS_TYPE_P (current_class) 
12282       || DECL_FINIT_P (md))
12283     return 0;
12284   
12285   /* If we're calling a method found in an enclosing class, generate
12286      what it takes to retrieve the right this. Don't do that if we're
12287      invoking a static method. */
12288
12289   if (non_static_context)
12290     {
12291       ctx = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (current_class)));
12292       if (ctx == DECL_CONTEXT (md))
12293         {
12294           ta = build_current_thisn (current_class);
12295           ta = build_wfl_node (ta);
12296         }
12297       else
12298         {
12299           tree type = ctx;
12300           while (type)
12301             {
12302               maybe_build_thisn_access_method (type);
12303               if (type == DECL_CONTEXT (md))
12304                 {
12305                   ta = build_access_to_thisn (ctx, type, 0);
12306                   break;
12307                 }
12308               type = (DECL_CONTEXT (TYPE_NAME (type)) ? 
12309                       TREE_TYPE (DECL_CONTEXT (TYPE_NAME (type))) : NULL_TREE);
12310             }
12311         }
12312       ta = java_complete_tree (ta);
12313     }
12314
12315   /* We might have to use an access method to get to MD. We can
12316      break the method access rule as far as we're not generating
12317      bytecode */
12318   if (METHOD_PRIVATE (md) && flag_emit_class_files)
12319     {
12320       md = build_outer_method_access_method (md);
12321       to_return = 1;
12322     }
12323
12324   *mdecl = md;
12325   *this_arg = ta;
12326
12327   /* Returnin a non zero value indicates we were doing a non static
12328      method invokation that is now a static invocation. It will have
12329      callee displace `this' to insert it in the regular argument
12330      list. */
12331   return (non_static_context && to_return);
12332 }
12333
12334 /* Patch an invoke expression METHOD and ARGS, based on its invocation
12335    mode.  */
12336
12337 static tree
12338 patch_invoke (patch, method, args)
12339      tree patch, method, args;
12340 {
12341   tree dtable, func;
12342   tree original_call, t, ta;
12343
12344   /* Last step for args: convert build-in types. If we're dealing with
12345      a new TYPE() type call, the first argument to the constructor
12346      isn't found in the incomming argument list, but delivered by
12347      `new' */
12348   t = TYPE_ARG_TYPES (TREE_TYPE (method));
12349   if (TREE_CODE (patch) == NEW_CLASS_EXPR)
12350     t = TREE_CHAIN (t);
12351   for (ta = args; t != end_params_node && ta; 
12352        t = TREE_CHAIN (t), ta = TREE_CHAIN (ta))
12353     if (JPRIMITIVE_TYPE_P (TREE_TYPE (TREE_VALUE (ta))) &&
12354         TREE_TYPE (TREE_VALUE (ta)) != TREE_VALUE (t))
12355       TREE_VALUE (ta) = convert (TREE_VALUE (t), TREE_VALUE (ta));
12356
12357   /* Resolve unresolved returned type isses */
12358   t = TREE_TYPE (TREE_TYPE (method));
12359   if (TREE_CODE (t) == POINTER_TYPE && !CLASS_LOADED_P (TREE_TYPE (t)))
12360     resolve_and_layout (TREE_TYPE (t), NULL);
12361
12362   if (flag_emit_class_files || flag_emit_xref)
12363     func = method;
12364   else
12365     {
12366       tree signature = build_java_signature (TREE_TYPE (method));
12367       switch (invocation_mode (method, CALL_USING_SUPER (patch)))
12368         {
12369         case INVOKE_VIRTUAL:
12370           dtable = invoke_build_dtable (0, args);
12371           func = build_invokevirtual (dtable, method);
12372           break;
12373
12374         case INVOKE_SUPER:
12375         case INVOKE_STATIC:
12376           func = build_known_method_ref (method, TREE_TYPE (method),
12377                                          DECL_CONTEXT (method),
12378                                          signature, args);
12379           break;
12380
12381         case INVOKE_INTERFACE:
12382           dtable = invoke_build_dtable (1, args);
12383           func = build_invokeinterface (dtable, method);
12384           break;
12385
12386         default:
12387           fatal ("internal error - unknown invocation_mode result");
12388         }
12389
12390       /* Ensure self_type is initialized, (invokestatic). FIXME */
12391       func = build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (method)), func);
12392     }
12393
12394   TREE_TYPE (patch) = TREE_TYPE (TREE_TYPE (method));
12395   TREE_OPERAND (patch, 0) = func;
12396   TREE_OPERAND (patch, 1) = args;
12397   original_call = patch;
12398
12399   /* We're processing a `new TYPE ()' form. New is called an its
12400      returned value is the first argument to the constructor. We build
12401      a COMPOUND_EXPR and use saved expression so that the overall NEW
12402      expression value is a pointer to a newly created and initialized
12403      class. */
12404   if (TREE_CODE (original_call) == NEW_CLASS_EXPR)
12405     {
12406       tree class = DECL_CONTEXT (method);
12407       tree c1, saved_new, size, new;
12408       if (flag_emit_class_files || flag_emit_xref)
12409         {
12410           TREE_TYPE (patch) = build_pointer_type (class);
12411           return patch;
12412         }
12413       if (!TYPE_SIZE (class))
12414         safe_layout_class (class);
12415       size = size_in_bytes (class);
12416       new = build (CALL_EXPR, promote_type (class),
12417                    build_address_of (alloc_object_node),
12418                    tree_cons (NULL_TREE, build_class_ref (class),
12419                               build_tree_list (NULL_TREE, 
12420                                                size_in_bytes (class))),
12421                    NULL_TREE);
12422       saved_new = save_expr (new);
12423       c1 = build_tree_list (NULL_TREE, saved_new);
12424       TREE_CHAIN (c1) = TREE_OPERAND (original_call, 1);
12425       TREE_OPERAND (original_call, 1) = c1;
12426       TREE_SET_CODE (original_call, CALL_EXPR);
12427       patch = build (COMPOUND_EXPR, TREE_TYPE (new), patch, saved_new);
12428     }
12429   return patch;
12430 }
12431
12432 static int
12433 invocation_mode (method, super)
12434      tree method;
12435      int super;
12436 {
12437   int access = get_access_flags_from_decl (method);
12438
12439   if (super)
12440     return INVOKE_SUPER;
12441
12442   if (access & ACC_STATIC || access & ACC_FINAL || access & ACC_PRIVATE)
12443     return INVOKE_STATIC;
12444
12445   if (CLASS_FINAL (TYPE_NAME (DECL_CONTEXT (method))))
12446     return INVOKE_STATIC;
12447   
12448   if (CLASS_INTERFACE (TYPE_NAME (DECL_CONTEXT (method))))
12449     return INVOKE_INTERFACE;
12450   
12451   if (DECL_CONSTRUCTOR_P (method))
12452     return INVOKE_STATIC;
12453
12454   return INVOKE_VIRTUAL;
12455 }
12456
12457 /* Retrieve a refined list of matching methods. It covers the step
12458    15.11.2 (Compile-Time Step 2) */
12459
12460 static tree
12461 lookup_method_invoke (lc, cl, class, name, arg_list)
12462      int lc;
12463      tree cl;
12464      tree class, name, arg_list;
12465 {
12466   tree atl = end_params_node;           /* Arg Type List */
12467   tree method, signature, list, node;
12468   const char *candidates;               /* Used for error report */
12469   char *dup;
12470
12471   /* Fix the arguments */
12472   for (node = arg_list; node; node = TREE_CHAIN (node))
12473     {
12474       tree current_arg = TREE_TYPE (TREE_VALUE (node));
12475       /* Non primitive type may have to be resolved */
12476       if (!JPRIMITIVE_TYPE_P (current_arg))
12477         resolve_and_layout (current_arg, NULL_TREE);
12478       /* And promoted */
12479       if (TREE_CODE (current_arg) == RECORD_TYPE)
12480         current_arg = promote_type (current_arg);
12481       atl = tree_cons (NULL_TREE, current_arg, atl);
12482     }
12483
12484   /* Presto. If we're dealing with an anonymous class and a
12485      constructor call, generate the right constructor now, since we
12486      know the arguments' types. */
12487
12488   if (lc && ANONYMOUS_CLASS_P (class))
12489     craft_constructor (TYPE_NAME (class), atl);
12490
12491   /* Find all candidates and then refine the list, searching for the
12492      most specific method. */
12493   list = find_applicable_accessible_methods_list (lc, class, name, atl);
12494   list = find_most_specific_methods_list (list);
12495   if (list && !TREE_CHAIN (list))
12496     return TREE_VALUE (list);
12497
12498   /* Issue an error. List candidates if any. Candidates are listed
12499      only if accessible (non accessible methods may end-up here for
12500      the sake of a better error report). */
12501   candidates = NULL;
12502   if (list)
12503     {
12504       tree current;
12505       obstack_grow (&temporary_obstack, ". Candidates are:\n", 18);
12506       for (current = list; current; current = TREE_CHAIN (current))
12507         {
12508           tree cm = TREE_VALUE (current);
12509           char string [4096];
12510           if (!cm || not_accessible_p (class, cm, 0))
12511             continue;
12512           sprintf 
12513             (string, "  `%s' in `%s'%s",
12514              get_printable_method_name (cm),
12515              IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (DECL_CONTEXT (cm)))),
12516              (TREE_CHAIN (current) ? "\n" : ""));
12517           obstack_grow (&temporary_obstack, string, strlen (string));
12518         }
12519       obstack_1grow (&temporary_obstack, '\0');
12520       candidates = obstack_finish (&temporary_obstack);
12521     }
12522   /* Issue the error message */
12523   method = make_node (FUNCTION_TYPE);
12524   TYPE_ARG_TYPES (method) = atl;
12525   signature = build_java_argument_signature (method);
12526   dup = xstrdup (lang_printable_name (class, 0));
12527   parse_error_context (cl, "Can't find %s `%s(%s)' in type `%s'%s",
12528                        (lc ? "constructor" : "method"),
12529                        (lc ? dup : IDENTIFIER_POINTER (name)),
12530                        IDENTIFIER_POINTER (signature), dup,
12531                        (candidates ? candidates : ""));
12532   free (dup);
12533   return NULL_TREE;
12534 }
12535
12536 /* 15.11.2.1: Find Methods that are Applicable and Accessible. LC is 1
12537    when we're looking for a constructor. */
12538
12539 static tree
12540 find_applicable_accessible_methods_list (lc, class, name, arglist)
12541      int lc;
12542      tree class, name, arglist;
12543 {
12544   static int object_done = 0;
12545   tree list = NULL_TREE, all_list = NULL_TREE;
12546
12547   if (!CLASS_LOADED_P (class) && !CLASS_FROM_SOURCE_P (class))
12548     {
12549       load_class (class, 1);
12550       safe_layout_class (class);
12551     }
12552
12553   /* Search interfaces */
12554   if (CLASS_INTERFACE (TYPE_NAME (class)))
12555     {
12556       static struct hash_table t, *searched_interfaces = NULL;
12557       static int search_not_done = 0;
12558       int i, n;
12559       tree basetype_vec = TYPE_BINFO_BASETYPES (class);
12560
12561       /* Search in the hash table, otherwise create a new one if
12562          necessary and insert the new entry. */
12563
12564       if (searched_interfaces)
12565         {
12566           if (hash_lookup (searched_interfaces, 
12567                            (const hash_table_key) class, FALSE, NULL))
12568             return NULL;
12569         }
12570       else
12571         {
12572           hash_table_init (&t, hash_newfunc, java_hash_hash_tree_node,
12573                            java_hash_compare_tree_node);
12574           searched_interfaces = &t;
12575         }
12576
12577       hash_lookup (searched_interfaces, 
12578                    (const hash_table_key) class, TRUE, NULL);
12579
12580       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12581                                       name, arglist, &list, &all_list);
12582       n = TREE_VEC_LENGTH (basetype_vec);
12583       for (i = 1; i < n; i++)
12584         {
12585           tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12586           tree rlist;
12587
12588           search_not_done++;
12589           rlist = find_applicable_accessible_methods_list (lc,  t, name, 
12590                                                            arglist);
12591           list = chainon (rlist, list);
12592           search_not_done--;
12593         }
12594
12595       /* We're done. Reset the searched interfaces list and finally search
12596          java.lang.Object */
12597       if (!search_not_done)
12598         {  
12599           if (!object_done)
12600             search_applicable_methods_list (lc, 
12601                                             TYPE_METHODS (object_type_node),
12602                                             name, arglist, &list, &all_list);
12603           hash_table_free (searched_interfaces);
12604           searched_interfaces = NULL;  
12605         }
12606     }
12607   /* Search classes */
12608   else
12609     {
12610       tree sc = class;
12611       int seen_inner_class = 0;
12612       search_applicable_methods_list (lc, TYPE_METHODS (class), 
12613                                       name, arglist, &list, &all_list);
12614
12615       /* We must search all interfaces of this class */
12616       if (!lc)
12617       {
12618         tree basetype_vec = TYPE_BINFO_BASETYPES (sc);
12619         int n = TREE_VEC_LENGTH (basetype_vec), i;
12620         object_done = 1;
12621         for (i = 1; i < n; i++)
12622           {
12623             tree t = BINFO_TYPE (TREE_VEC_ELT (basetype_vec, i));
12624             tree rlist;
12625             if (t != object_type_node)
12626               rlist = find_applicable_accessible_methods_list (lc, t,
12627                                                                name, arglist);
12628             list = chainon (rlist, list);
12629           }
12630         object_done = 0;
12631       }
12632
12633       /* Search enclosing context of inner classes before looking
12634          ancestors up. */
12635       while (!lc && INNER_CLASS_TYPE_P (class))
12636         {
12637           tree rlist;
12638           seen_inner_class = 1;
12639           class = TREE_TYPE (DECL_CONTEXT (TYPE_NAME (class)));
12640           rlist = find_applicable_accessible_methods_list (lc, class, 
12641                                                            name, arglist);
12642           list = chainon (rlist, list);
12643         }
12644
12645       if (!lc && seen_inner_class 
12646           && TREE_TYPE (DECL_CONTEXT (TYPE_NAME (sc))) == CLASSTYPE_SUPER (sc))
12647         class = CLASSTYPE_SUPER (sc);
12648       else
12649         class = sc;
12650
12651       for (class = (lc ? NULL_TREE : CLASSTYPE_SUPER (class)); 
12652         class; class = CLASSTYPE_SUPER (class))
12653        search_applicable_methods_list (lc, TYPE_METHODS (class), 
12654                                        name, arglist, &list, &all_list);
12655     }
12656
12657   /* Either return the list obtained or all selected (but
12658      inaccessible) methods for better error report. */
12659   return (!list ? all_list : list);
12660 }
12661
12662 /* Effectively search for the approriate method in method */
12663
12664 static void 
12665 search_applicable_methods_list (lc, method, name, arglist, list, all_list)
12666      int lc;
12667      tree method, name, arglist;
12668      tree *list, *all_list;
12669 {
12670   for (; method; method = TREE_CHAIN (method))
12671     {
12672       /* When dealing with constructor, stop here, otherwise search
12673          other classes */
12674       if (lc && !DECL_CONSTRUCTOR_P (method))
12675         continue;
12676       else if (!lc && (DECL_CONSTRUCTOR_P (method) 
12677                        || (GET_METHOD_NAME (method) != name)))
12678         continue;
12679           
12680       if (argument_types_convertible (method, arglist))
12681         {
12682           /* Retain accessible methods only */
12683           if (!not_accessible_p (DECL_CONTEXT (current_function_decl), 
12684                                  method, 0))
12685             *list = tree_cons (NULL_TREE, method, *list);
12686           else
12687             /* Also retain all selected method here */
12688             *all_list = tree_cons (NULL_TREE, method, *list);
12689         }
12690     }
12691 }    
12692
12693 /* 15.11.2.2 Choose the Most Specific Method */
12694
12695 static tree
12696 find_most_specific_methods_list (list)
12697      tree list;
12698 {
12699   int max = 0;
12700   tree current, new_list = NULL_TREE;
12701   for (current = list; current; current = TREE_CHAIN (current))
12702     {
12703       tree method;
12704       DECL_SPECIFIC_COUNT (TREE_VALUE (current)) = 0;
12705
12706       for (method = list; method; method = TREE_CHAIN (method))
12707         {
12708           /* Don't test a method against itself */
12709           if (method == current)
12710             continue;
12711
12712           /* Compare arguments and location where method where declared */
12713           if (argument_types_convertible (TREE_VALUE (method), 
12714                                           TREE_VALUE (current))
12715               && valid_method_invocation_conversion_p 
12716                    (DECL_CONTEXT (TREE_VALUE (method)), 
12717                     DECL_CONTEXT (TREE_VALUE (current))))
12718             {
12719               int v = ++DECL_SPECIFIC_COUNT (TREE_VALUE (current));
12720               max = (v > max ? v : max);
12721             }
12722         }
12723     }
12724
12725   /* Review the list and select the maximally specific methods */
12726   for (current = list; current; current = TREE_CHAIN (current))
12727     if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12728       new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12729
12730   /* If we have several and they're all abstract, just pick the
12731      closest one. */
12732
12733   if (new_list && TREE_CHAIN (new_list))
12734     {
12735       tree c;
12736       for (c = new_list; c && METHOD_ABSTRACT (TREE_VALUE (c)); 
12737            c = TREE_CHAIN (c))
12738         ;
12739       if (!c)
12740         {
12741           new_list = nreverse (new_list);
12742           TREE_CHAIN (new_list) = NULL_TREE;
12743         }
12744     }
12745
12746   /* If we can't find one, lower expectations and try to gather multiple
12747      maximally specific methods */
12748   while (!new_list && max)
12749     {
12750       while (--max > 0)
12751         {
12752           if (DECL_SPECIFIC_COUNT (TREE_VALUE (current)) == max)
12753             new_list = tree_cons (NULL_TREE, TREE_VALUE (current), new_list);
12754         }
12755     }
12756
12757   return new_list;
12758 }
12759
12760 /* Make sure that the type of each M2_OR_ARGLIST arguments can be
12761    converted by method invocation conversion (5.3) to the type of the
12762    corresponding parameter of M1. Implementation expects M2_OR_ARGLIST
12763    to change less often than M1. */
12764
12765 static int
12766 argument_types_convertible (m1, m2_or_arglist)
12767     tree m1, m2_or_arglist;
12768 {
12769   static tree m2_arg_value = NULL_TREE;
12770   static tree m2_arg_cache = NULL_TREE;
12771
12772   register tree m1_arg, m2_arg;
12773
12774   SKIP_THIS_AND_ARTIFICIAL_PARMS (m1_arg, m1)
12775
12776   if (m2_arg_value == m2_or_arglist)
12777     m2_arg = m2_arg_cache;
12778   else
12779     {
12780       /* M2_OR_ARGLIST can be a function DECL or a raw list of
12781          argument types */
12782       if (m2_or_arglist && TREE_CODE (m2_or_arglist) == FUNCTION_DECL)
12783         {
12784           m2_arg = TYPE_ARG_TYPES (TREE_TYPE (m2_or_arglist));
12785           if (!METHOD_STATIC (m2_or_arglist))
12786             m2_arg = TREE_CHAIN (m2_arg);
12787         }
12788       else
12789         m2_arg = m2_or_arglist;
12790
12791       m2_arg_value = m2_or_arglist;
12792       m2_arg_cache = m2_arg;
12793     }
12794
12795   while (m1_arg != end_params_node && m2_arg != end_params_node)
12796     {
12797       resolve_and_layout (TREE_VALUE (m1_arg), NULL_TREE);
12798       if (!valid_method_invocation_conversion_p (TREE_VALUE (m1_arg),
12799                                                  TREE_VALUE (m2_arg)))
12800         break;
12801       m1_arg = TREE_CHAIN (m1_arg);
12802       m2_arg = TREE_CHAIN (m2_arg);
12803     }
12804   return m1_arg == end_params_node && m2_arg == end_params_node;
12805 }
12806
12807 /* Qualification routines */
12808
12809 static void
12810 qualify_ambiguous_name (id)
12811      tree id;
12812 {
12813   tree qual, qual_wfl, name = NULL_TREE, decl, ptr_type = NULL_TREE,
12814     saved_current_class;
12815   int again, super_found = 0, this_found = 0, new_array_found = 0;
12816   int code;
12817
12818   /* We first qualify the first element, then derive qualification of
12819      others based on the first one. If the first element is qualified
12820      by a resolution (field or type), this resolution is stored in the
12821      QUAL_RESOLUTION of the qual element being examined. We need to
12822      save the current_class since the use of SUPER might change the
12823      its value. */
12824   saved_current_class = current_class;
12825   qual = EXPR_WFL_QUALIFICATION (id);
12826   do {
12827
12828     /* Simple qualified expression feature a qual_wfl that is a
12829        WFL. Expression derived from a primary feature more complicated
12830        things like a CALL_EXPR. Expression from primary need to be
12831        worked out to extract the part on which the qualification will
12832        take place. */
12833     qual_wfl = QUAL_WFL (qual);
12834     switch (TREE_CODE (qual_wfl))
12835       {
12836       case CALL_EXPR:
12837         qual_wfl = TREE_OPERAND (qual_wfl, 0);
12838         if (TREE_CODE (qual_wfl) != EXPR_WITH_FILE_LOCATION)
12839           {
12840             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12841             qual_wfl = QUAL_WFL (qual);
12842           }
12843         break;
12844       case NEW_ARRAY_EXPR:
12845       case NEW_ANONYMOUS_ARRAY_EXPR:
12846         qual = TREE_CHAIN (qual);
12847         again = new_array_found = 1;
12848         continue;
12849       case NEW_CLASS_EXPR:
12850       case CONVERT_EXPR:
12851         qual_wfl = TREE_OPERAND (qual_wfl, 0);
12852         break;
12853       case ARRAY_REF:
12854         while (TREE_CODE (qual_wfl) == ARRAY_REF)
12855           qual_wfl = TREE_OPERAND (qual_wfl, 0);
12856         break;
12857       case STRING_CST:
12858         qual = TREE_CHAIN (qual);
12859         qual_wfl = QUAL_WFL (qual);
12860         break;
12861       case CLASS_LITERAL:
12862         qual = TREE_CHAIN (qual);
12863         qual_wfl = QUAL_WFL (qual);
12864       break;
12865       default:
12866         /* Fix for -Wall. Just break doing nothing */
12867         break;
12868       }
12869
12870     ptr_type = current_class;
12871     again = 0;
12872     code = TREE_CODE (qual_wfl);
12873
12874     /* Pos evaluation: non WFL leading expression nodes */
12875     if (code == CONVERT_EXPR
12876         && TREE_CODE (TREE_TYPE (qual_wfl)) == EXPR_WITH_FILE_LOCATION)
12877       name = EXPR_WFL_NODE (TREE_TYPE (qual_wfl));
12878
12879     else if (code == INTEGER_CST)
12880       name = qual_wfl;
12881     
12882     else if ((code == ARRAY_REF || code == CALL_EXPR || code == MODIFY_EXPR) &&
12883              TREE_CODE (TREE_OPERAND (qual_wfl, 0)) == EXPR_WITH_FILE_LOCATION)
12884       name = EXPR_WFL_NODE (TREE_OPERAND (qual_wfl, 0));
12885
12886     else if (code == TREE_LIST)
12887       name = EXPR_WFL_NODE (TREE_PURPOSE (qual_wfl));
12888
12889     else if (code == STRING_CST || code == CONDITIONAL_EXPR 
12890              || code == PLUS_EXPR)
12891       {
12892         qual = TREE_CHAIN (qual);
12893         qual_wfl = QUAL_WFL (qual);
12894         again = 1;
12895       }
12896     else 
12897       {
12898         name = EXPR_WFL_NODE (qual_wfl);
12899         if (!name)
12900           {
12901             qual = EXPR_WFL_QUALIFICATION (qual_wfl);
12902             again = 1;
12903           }
12904       }
12905
12906     /* If we have a THIS (from a primary), we set the context accordingly */
12907     if (name == this_identifier_node)
12908       {
12909         qual = TREE_CHAIN (qual);
12910         qual_wfl = QUAL_WFL (qual);
12911         if (TREE_CODE (qual_wfl) == CALL_EXPR)
12912           again = 1;
12913         else
12914           name = EXPR_WFL_NODE (qual_wfl);
12915         this_found = 1;
12916       }
12917     /* If we have a SUPER, we set the context accordingly */
12918     if (name == super_identifier_node)
12919       {
12920         current_class = CLASSTYPE_SUPER (ptr_type);
12921         /* Check that there is such a thing as a super class. If not,
12922            return.  The error will be caught later on, during the
12923            resolution */
12924         if (!current_class)
12925           {
12926             current_class = saved_current_class;
12927             return;
12928           }
12929         qual = TREE_CHAIN (qual);
12930         /* Do one more interation to set things up */
12931         super_found = again = 1;
12932       }
12933   } while (again);
12934   
12935   /* If name appears within the scope of a location variable
12936      declaration or parameter declaration, then it is an expression
12937      name. We don't carry this test out if we're in the context of the
12938      use of SUPER or THIS */
12939   if (!this_found && !super_found 
12940       && TREE_CODE (name) != STRING_CST && TREE_CODE (name) != INTEGER_CST
12941       && (decl = IDENTIFIER_LOCAL_VALUE (name)))
12942     {
12943       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12944       QUAL_RESOLUTION (qual) = decl;
12945     }
12946
12947   /* If within the class/interface NAME was found to be used there
12948      exists a (possibly inherited) field named NAME, then this is an
12949      expression name. If we saw a NEW_ARRAY_EXPR before and want to
12950      address length, it is OK. */
12951   else if ((decl = lookup_field_wrapper (ptr_type, name))
12952            || (new_array_found && name == length_identifier_node))
12953     {
12954       RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12955       QUAL_RESOLUTION (qual) = (new_array_found ? NULL_TREE : decl);
12956     }
12957
12958   /* We reclassify NAME as yielding to a type name resolution if:
12959      - NAME is a class/interface declared within the compilation
12960        unit containing NAME,
12961      - NAME is imported via a single-type-import declaration,
12962      - NAME is declared in an another compilation unit of the package
12963        of the compilation unit containing NAME,
12964      - NAME is declared by exactly on type-import-on-demand declaration
12965      of the compilation unit containing NAME. 
12966      - NAME is actually a STRING_CST. */
12967   else if (TREE_CODE (name) == STRING_CST || TREE_CODE (name) == INTEGER_CST
12968            || (decl = resolve_and_layout (name, NULL_TREE)))
12969     {
12970       RESOLVE_TYPE_NAME_P (qual_wfl) = 1;
12971       QUAL_RESOLUTION (qual) = decl;
12972     }
12973
12974   /* Method call are expression name */
12975   else if (TREE_CODE (QUAL_WFL (qual)) == CALL_EXPR
12976            || TREE_CODE (QUAL_WFL (qual)) == ARRAY_REF
12977            || TREE_CODE (QUAL_WFL (qual)) == CONVERT_EXPR)
12978     RESOLVE_EXPRESSION_NAME_P (qual_wfl) = 1;
12979
12980   /* Check here that NAME isn't declared by more than one
12981      type-import-on-demand declaration of the compilation unit
12982      containing NAME. FIXME */
12983
12984   /* Otherwise, NAME is reclassified as a package name */
12985   else 
12986     RESOLVE_PACKAGE_NAME_P (qual_wfl) = 1;
12987
12988   /* Propagate the qualification accross other components of the
12989      qualified name */
12990   for (qual = TREE_CHAIN (qual); qual;
12991        qual_wfl = QUAL_WFL (qual), qual = TREE_CHAIN (qual))
12992     {
12993       if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
12994         RESOLVE_PACKAGE_NAME_P (QUAL_WFL (qual)) = 1;
12995       else 
12996         RESOLVE_EXPRESSION_NAME_P (QUAL_WFL (qual)) = 1;
12997     }
12998
12999   /* Store the global qualification for the ambiguous part of ID back
13000      into ID fields */
13001   if (RESOLVE_EXPRESSION_NAME_P (qual_wfl))
13002     RESOLVE_EXPRESSION_NAME_P (id) = 1;
13003   else if (RESOLVE_TYPE_NAME_P (qual_wfl))
13004     RESOLVE_TYPE_NAME_P (id) = 1;
13005   else if (RESOLVE_PACKAGE_NAME_P (qual_wfl))
13006     RESOLVE_PACKAGE_NAME_P (id) = 1;
13007
13008   /* Restore the current class */
13009   current_class = saved_current_class;
13010 }
13011
13012 static int
13013 breakdown_qualified (left, right, source)
13014     tree *left, *right, source;
13015 {
13016   char *p = IDENTIFIER_POINTER (source), *base;
13017   int   l = IDENTIFIER_LENGTH (source);
13018
13019   /* Breakdown NAME into REMAINDER . IDENTIFIER */
13020   base = p;
13021   p += (l-1);
13022   while (*p != '.' && p != base)
13023     p--;
13024
13025   /* We didn't find a '.'. Return an error */
13026   if (p == base)
13027     return 1;
13028
13029   *p = '\0';
13030   if (right)
13031     *right = get_identifier (p+1);
13032   *left = get_identifier (IDENTIFIER_POINTER (source));
13033   *p = '.';
13034   
13035   return 0;
13036 }
13037
13038 /* Patch tree nodes in a function body. When a BLOCK is found, push
13039    local variable decls if present.
13040    Same as java_complete_lhs, but does resolve static finals to values. */
13041
13042 static tree
13043 java_complete_tree (node)
13044      tree node;
13045 {
13046   node = java_complete_lhs (node);
13047   if (TREE_CODE (node) == VAR_DECL && FIELD_STATIC (node)
13048       && FIELD_FINAL (node) && DECL_INITIAL (node) != NULL_TREE
13049       && !flag_emit_xref)
13050     {
13051       tree value = DECL_INITIAL (node);
13052       DECL_INITIAL (node) = NULL_TREE;
13053       push_obstacks (&permanent_obstack, &permanent_obstack);
13054       value = fold_constant_for_init (value, node);
13055       pop_obstacks ();
13056       DECL_INITIAL (node) = value;
13057       if (value != NULL_TREE)
13058         {
13059           /* fold_constant_for_init sometimes widen the original type
13060              of the constant (i.e. byte to int.) It's not desirable,
13061              especially if NODE is a function argument. */
13062           if (TREE_CODE (value) == INTEGER_CST
13063               && TREE_TYPE (node) != TREE_TYPE (value))
13064             return convert (TREE_TYPE (node), value);
13065           else
13066             return value;
13067         }
13068     }
13069   return node;
13070 }
13071
13072 static tree
13073 java_stabilize_reference (node)
13074      tree node;
13075 {
13076   if (TREE_CODE (node) == COMPOUND_EXPR)
13077     {
13078       tree op0 = TREE_OPERAND (node, 0);
13079       tree op1 = TREE_OPERAND (node, 1);
13080       TREE_OPERAND (node, 0) = save_expr (op0);
13081       TREE_OPERAND (node, 1) = java_stabilize_reference (op1);
13082       return node;
13083     }
13084   return stabilize_reference (node);
13085 }
13086
13087 /* Patch tree nodes in a function body. When a BLOCK is found, push
13088    local variable decls if present.
13089    Same as java_complete_tree, but does not resolve static finals to values. */
13090
13091 static tree
13092 java_complete_lhs (node)
13093      tree node;
13094 {
13095   tree nn, cn, wfl_op1, wfl_op2, wfl_op3;
13096   int flag;
13097
13098   /* CONVERT_EXPR always has its type set, even though it needs to be
13099      worked out. */
13100   if (TREE_TYPE (node) && TREE_CODE (node) != CONVERT_EXPR)
13101     return node;
13102
13103   /* The switch block implements cases processing container nodes
13104      first.  Contained nodes are always written back. Leaves come
13105      next and return a value. */
13106   switch (TREE_CODE (node))
13107     {
13108     case BLOCK:
13109
13110       /* 1- Block section.
13111          Set the local values on decl names so we can identify them
13112          faster when they're referenced. At that stage, identifiers
13113          are legal so we don't check for declaration errors. */
13114       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13115         {
13116           DECL_CONTEXT (cn) = current_function_decl;
13117           IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = cn;
13118         }
13119       if (BLOCK_EXPR_BODY (node) == NULL_TREE)
13120           CAN_COMPLETE_NORMALLY (node) = 1;
13121       else
13122         {
13123           tree stmt = BLOCK_EXPR_BODY (node);
13124           tree *ptr;
13125           int error_seen = 0;
13126           if (TREE_CODE (stmt) == COMPOUND_EXPR)
13127             {
13128               /* Re-order from (((A; B); C); ...; Z) to 
13129                  (A; (B; (C ; (...; Z)))).
13130                  This makes it easier to scan the statements left-to-right
13131                  without using recursion (which might overflow the stack
13132                  if the block has many statements. */
13133               for (;;)
13134                 {
13135                   tree left = TREE_OPERAND (stmt, 0);
13136                   if (TREE_CODE (left) != COMPOUND_EXPR)
13137                     break;
13138                   TREE_OPERAND (stmt, 0) = TREE_OPERAND (left, 1);
13139                   TREE_OPERAND (left, 1) = stmt;
13140                   stmt = left;
13141                 }
13142               BLOCK_EXPR_BODY (node) = stmt;
13143             }
13144
13145           /* Now do the actual complete, without deep recursion for
13146              long blocks. */
13147           ptr = &BLOCK_EXPR_BODY (node);
13148           while (TREE_CODE (*ptr) == COMPOUND_EXPR
13149                  && TREE_OPERAND (*ptr, 1) != empty_stmt_node)
13150             {
13151               tree cur = java_complete_tree (TREE_OPERAND (*ptr, 0));
13152               tree *next = &TREE_OPERAND (*ptr, 1);
13153               TREE_OPERAND (*ptr, 0) = cur;
13154               if (cur == empty_stmt_node)
13155                 {
13156                   /* Optimization;  makes it easier to detect empty bodies.
13157                      Most useful for <clinit> with all-constant initializer. */
13158                   *ptr = *next;
13159                   continue;
13160                 }
13161               if (TREE_CODE (cur) == ERROR_MARK)
13162                 error_seen++;
13163               else if (! CAN_COMPLETE_NORMALLY (cur))
13164                 {
13165                   wfl_op2 = *next;
13166                   for (;;)
13167                     {
13168                       if (TREE_CODE (wfl_op2) == BLOCK)
13169                         wfl_op2 = BLOCK_EXPR_BODY (wfl_op2);
13170                       else if (TREE_CODE (wfl_op2) == COMPOUND_EXPR)
13171                         wfl_op2 = TREE_OPERAND (wfl_op2, 0);
13172                       else
13173                         break;
13174                     }
13175                   if (TREE_CODE (wfl_op2) != CASE_EXPR
13176                       && TREE_CODE (wfl_op2) != DEFAULT_EXPR)
13177                     unreachable_stmt_error (*ptr);
13178                 }
13179               ptr = next;
13180             }
13181           *ptr = java_complete_tree (*ptr);
13182
13183           if (TREE_CODE (*ptr) == ERROR_MARK || error_seen > 0)
13184             return error_mark_node;
13185           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (*ptr);
13186         }
13187       /* Turn local bindings to null */
13188       for (cn = BLOCK_EXPR_DECLS (node); cn; cn = TREE_CHAIN (cn))
13189         IDENTIFIER_LOCAL_VALUE (DECL_NAME (cn)) = NULL_TREE;
13190
13191       TREE_TYPE (node) = void_type_node;
13192       break;
13193
13194       /* 2- They are expressions but ultimately deal with statements */
13195
13196     case THROW_EXPR:
13197       wfl_op1 = TREE_OPERAND (node, 0);
13198       COMPLETE_CHECK_OP_0 (node);
13199       /* 14.19 A throw statement cannot complete normally. */
13200       CAN_COMPLETE_NORMALLY (node) = 0;
13201       return patch_throw_statement (node, wfl_op1);
13202
13203     case SYNCHRONIZED_EXPR:
13204       wfl_op1 = TREE_OPERAND (node, 0);
13205       return patch_synchronized_statement (node, wfl_op1);
13206
13207     case TRY_EXPR:
13208       return patch_try_statement (node);
13209
13210     case TRY_FINALLY_EXPR:
13211       COMPLETE_CHECK_OP_0 (node);
13212       COMPLETE_CHECK_OP_1 (node);
13213       CAN_COMPLETE_NORMALLY (node)
13214         = (CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0))
13215            && CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)));
13216       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 0));
13217       return node;
13218
13219     case CLEANUP_POINT_EXPR:
13220       COMPLETE_CHECK_OP_0 (node);
13221       TREE_TYPE (node) = void_type_node;
13222       CAN_COMPLETE_NORMALLY (node) = 
13223         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13224       return node;
13225
13226     case WITH_CLEANUP_EXPR:
13227       COMPLETE_CHECK_OP_0 (node);
13228       COMPLETE_CHECK_OP_2 (node);
13229       CAN_COMPLETE_NORMALLY (node) = 
13230         CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 0));
13231       TREE_TYPE (node) = void_type_node;
13232       return node;
13233
13234     case LABELED_BLOCK_EXPR:
13235       PUSH_LABELED_BLOCK (node);
13236       if (LABELED_BLOCK_BODY (node))
13237         COMPLETE_CHECK_OP_1 (node);
13238       TREE_TYPE (node) = void_type_node;
13239       POP_LABELED_BLOCK ();
13240
13241       if (LABELED_BLOCK_BODY (node) == empty_stmt_node)
13242         {
13243           LABELED_BLOCK_BODY (node) = NULL_TREE;
13244           CAN_COMPLETE_NORMALLY (node) = 1;
13245         }
13246       else if (CAN_COMPLETE_NORMALLY (LABELED_BLOCK_BODY (node)))
13247         CAN_COMPLETE_NORMALLY (node) = 1;
13248       return node;
13249
13250     case EXIT_BLOCK_EXPR:
13251       /* We don't complete operand 1, because it's the return value of
13252          the EXIT_BLOCK_EXPR which doesn't exist it Java */
13253       return patch_bc_statement (node);
13254
13255     case CASE_EXPR:
13256       cn = java_complete_tree (TREE_OPERAND (node, 0));
13257       if (cn == error_mark_node)
13258         return cn;
13259
13260       /* First, the case expression must be constant. Values of final
13261          fields are accepted. */
13262       cn = fold (cn);
13263       if ((TREE_CODE (cn) == COMPOUND_EXPR || TREE_CODE (cn) == COMPONENT_REF)
13264           && JDECL_P (TREE_OPERAND (cn, 1))
13265           && FIELD_FINAL (TREE_OPERAND (cn, 1))
13266           && DECL_INITIAL (TREE_OPERAND (cn, 1)))
13267         {
13268           push_obstacks (&permanent_obstack, &permanent_obstack);
13269           cn = fold_constant_for_init (DECL_INITIAL (TREE_OPERAND (cn, 1)),
13270                                        TREE_OPERAND (cn, 1));
13271           pop_obstacks ();
13272         }
13273
13274       if (!TREE_CONSTANT (cn) && !flag_emit_xref)
13275         {
13276           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13277           parse_error_context (node, "Constant expression required");
13278           return error_mark_node;
13279         }
13280
13281       nn = ctxp->current_loop;
13282
13283       /* It must be assignable to the type of the switch expression. */
13284       if (!try_builtin_assignconv (NULL_TREE, 
13285                                    TREE_TYPE (TREE_OPERAND (nn, 0)), cn))
13286         {
13287           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13288           parse_error_context 
13289             (wfl_operator,
13290              "Incompatible type for case. Can't convert `%s' to `int'",
13291              lang_printable_name (TREE_TYPE (cn), 0));
13292           return error_mark_node;
13293         }
13294
13295       cn = fold (convert (int_type_node, cn));
13296
13297       /* Multiple instance of a case label bearing the same
13298          value is checked during code generation. The case
13299          expression is allright so far. */
13300       TREE_OPERAND (node, 0) = cn;
13301       TREE_TYPE (node) = void_type_node;
13302       CAN_COMPLETE_NORMALLY (node) = 1;
13303       TREE_SIDE_EFFECTS (node) = 1;
13304       break;
13305
13306     case DEFAULT_EXPR:
13307       nn = ctxp->current_loop;
13308       /* Only one default label is allowed per switch statement */
13309       if (SWITCH_HAS_DEFAULT (nn))
13310         {
13311           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13312           parse_error_context (wfl_operator, 
13313                                "Duplicate case label: `default'");
13314           return error_mark_node;
13315         }
13316       else
13317         SWITCH_HAS_DEFAULT (nn) = 1;
13318       TREE_TYPE (node) = void_type_node;
13319       TREE_SIDE_EFFECTS (node) = 1;
13320       CAN_COMPLETE_NORMALLY (node) = 1;
13321       break;
13322
13323     case SWITCH_EXPR:
13324     case LOOP_EXPR:
13325       PUSH_LOOP (node);
13326       /* Check whether the loop was enclosed in a labeled
13327          statement. If not, create one, insert the loop in it and
13328          return the node */
13329       nn = patch_loop_statement (node);
13330
13331       /* Anyways, walk the body of the loop */
13332       if (TREE_CODE (node) == LOOP_EXPR)
13333         TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13334       /* Switch statement: walk the switch expression and the cases */
13335       else
13336         node = patch_switch_statement (node);
13337
13338       if (TREE_OPERAND (node, 0) == error_mark_node)
13339         nn = error_mark_node;
13340       else
13341         {
13342           TREE_TYPE (nn) = TREE_TYPE (node) = void_type_node;
13343           /* If we returned something different, that's because we
13344              inserted a label. Pop the label too. */
13345           if (nn != node)
13346             {
13347               if (CAN_COMPLETE_NORMALLY (node))
13348                 CAN_COMPLETE_NORMALLY (nn) = 1;
13349               POP_LABELED_BLOCK ();
13350             }
13351         }
13352       POP_LOOP ();
13353       return nn;
13354
13355     case EXIT_EXPR:
13356       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13357       return patch_exit_expr (node);
13358
13359     case COND_EXPR:
13360       /* Condition */
13361       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13362       if (TREE_OPERAND (node, 0) == error_mark_node)
13363         return error_mark_node;
13364       /* then-else branches */
13365       TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13366       if (TREE_OPERAND (node, 1) == error_mark_node)
13367         return error_mark_node;
13368       TREE_OPERAND (node, 2) = java_complete_tree (TREE_OPERAND (node, 2));
13369       if (TREE_OPERAND (node, 2) == error_mark_node)
13370         return error_mark_node;
13371       return patch_if_else_statement (node);
13372       break;
13373
13374     case CONDITIONAL_EXPR:
13375       /* Condition */
13376       wfl_op1 = TREE_OPERAND (node, 0);
13377       COMPLETE_CHECK_OP_0 (node);
13378       wfl_op2 = TREE_OPERAND (node, 1);
13379       COMPLETE_CHECK_OP_1 (node);
13380       wfl_op3 = TREE_OPERAND (node, 2);
13381       COMPLETE_CHECK_OP_2 (node);
13382       return patch_conditional_expr (node, wfl_op1, wfl_op2);
13383
13384       /* 3- Expression section */
13385     case COMPOUND_EXPR:
13386       wfl_op2 = TREE_OPERAND (node, 1);
13387       TREE_OPERAND (node, 0) = nn = 
13388         java_complete_tree (TREE_OPERAND (node, 0));
13389       if (wfl_op2 == empty_stmt_node)
13390         CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (nn);
13391       else
13392         {
13393           if (! CAN_COMPLETE_NORMALLY (nn) && TREE_CODE (nn) != ERROR_MARK)
13394             {
13395               /* An unreachable condition in a do-while statement
13396                  is *not* (technically) an unreachable statement. */
13397               nn = wfl_op2;
13398               if (TREE_CODE (nn) == EXPR_WITH_FILE_LOCATION)
13399                 nn = EXPR_WFL_NODE (nn);
13400               if (TREE_CODE (nn) != EXIT_EXPR)
13401                 {
13402                   SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
13403                   parse_error_context (wfl_operator, "Unreachable statement");
13404                 }
13405             }
13406           TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
13407           if (TREE_OPERAND (node, 1) == error_mark_node)
13408             return error_mark_node;
13409           CAN_COMPLETE_NORMALLY (node)
13410             = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1));
13411         }
13412       TREE_TYPE (node) = TREE_TYPE (TREE_OPERAND (node, 1));
13413       break;
13414
13415     case RETURN_EXPR:
13416       /* CAN_COMPLETE_NORMALLY (node) = 0; */
13417       return patch_return (node);
13418
13419     case EXPR_WITH_FILE_LOCATION:
13420       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
13421           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
13422         {
13423           tree wfl = node;
13424           node = resolve_expression_name (node, NULL);
13425           if (node == error_mark_node)
13426             return node;
13427           /* Keep line number information somewhere were it doesn't
13428              disrupt the completion process. */
13429           if (flag_emit_xref && TREE_CODE (node) != CALL_EXPR)
13430             {
13431               EXPR_WFL_NODE (wfl) = TREE_OPERAND (node, 1);
13432               TREE_OPERAND (node, 1) = wfl;
13433             }
13434           CAN_COMPLETE_NORMALLY (node) = 1;
13435         }
13436       else
13437         {
13438           tree body;
13439           int save_lineno = lineno;
13440           lineno = EXPR_WFL_LINENO (node);
13441           body = java_complete_tree (EXPR_WFL_NODE (node));
13442           lineno = save_lineno;
13443           EXPR_WFL_NODE (node) = body;
13444           TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (body);
13445           CAN_COMPLETE_NORMALLY (node) = CAN_COMPLETE_NORMALLY (body);
13446           if (body == empty_stmt_node)
13447             {
13448               /* Optimization;  makes it easier to detect empty bodies. */
13449               return body;
13450             }
13451           if (body == error_mark_node)
13452             {
13453               /* Its important for the evaluation of assignment that
13454                  this mark on the TREE_TYPE is propagated. */
13455               TREE_TYPE (node) = error_mark_node;
13456               return error_mark_node;
13457             }
13458           else
13459             TREE_TYPE (node) = TREE_TYPE (EXPR_WFL_NODE (node));
13460           
13461         }
13462       break;
13463
13464     case NEW_ARRAY_EXPR:
13465       /* Patch all the dimensions */
13466       flag = 0;
13467       for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13468         {
13469           int location = EXPR_WFL_LINECOL (TREE_VALUE (cn));
13470           tree dim = convert (int_type_node, 
13471                               java_complete_tree (TREE_VALUE (cn)));
13472           if (dim == error_mark_node)
13473             {
13474               flag = 1;
13475               continue;
13476             }
13477           else
13478             {
13479               TREE_VALUE (cn) = dim;
13480               /* Setup the location of the current dimension, for
13481                  later error report. */
13482               TREE_PURPOSE (cn) = 
13483                 build_expr_wfl (NULL_TREE, input_filename, 0, 0);
13484               EXPR_WFL_LINECOL (TREE_PURPOSE (cn)) = location;
13485             }
13486         }
13487       /* They complete the array creation expression, if no errors
13488          were found. */
13489       CAN_COMPLETE_NORMALLY (node) = 1;
13490       return (flag ? error_mark_node
13491               : force_evaluation_order (patch_newarray (node)));
13492
13493     case NEW_ANONYMOUS_ARRAY_EXPR:
13494       /* Create the array type if necessary. */
13495       if (ANONYMOUS_ARRAY_DIMS_SIG (node))
13496         {
13497           tree type = ANONYMOUS_ARRAY_BASE_TYPE (node);
13498           if (!(type = resolve_type_during_patch (type)))
13499             return error_mark_node;
13500           type = build_array_from_name (type, NULL_TREE,
13501                                         ANONYMOUS_ARRAY_DIMS_SIG (node), NULL);
13502           ANONYMOUS_ARRAY_BASE_TYPE (node) = build_pointer_type (type);
13503         }
13504       node = patch_new_array_init (ANONYMOUS_ARRAY_BASE_TYPE (node),
13505                                    ANONYMOUS_ARRAY_INITIALIZER (node));
13506       if (node == error_mark_node)
13507         return error_mark_node;
13508       CAN_COMPLETE_NORMALLY (node) = 1;
13509       return node;
13510
13511     case NEW_CLASS_EXPR:
13512     case CALL_EXPR:
13513       /* Complete function's argument(s) first */
13514       if (complete_function_arguments (node))
13515         return error_mark_node;
13516       else
13517         {
13518           tree decl, wfl = TREE_OPERAND (node, 0);
13519           int in_this = CALL_THIS_CONSTRUCTOR_P (node);
13520
13521           node = patch_method_invocation (node, NULL_TREE, 
13522                                           NULL_TREE, 0, &decl);
13523           if (node == error_mark_node)
13524             return error_mark_node;
13525
13526           check_thrown_exceptions (EXPR_WFL_LINECOL (node), decl);
13527           /* If we call this(...), register signature and positions */
13528           if (in_this)
13529             DECL_CONSTRUCTOR_CALLS (current_function_decl) = 
13530               tree_cons (wfl, decl, 
13531                          DECL_CONSTRUCTOR_CALLS (current_function_decl));
13532           CAN_COMPLETE_NORMALLY (node) = 1;
13533           return force_evaluation_order (node);
13534         }
13535
13536     case MODIFY_EXPR:
13537       /* Save potential wfls */
13538       wfl_op1 = TREE_OPERAND (node, 0);
13539       TREE_OPERAND (node, 0) = nn = java_complete_lhs (wfl_op1);
13540       
13541       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node)
13542           && TREE_CODE (nn) == VAR_DECL && TREE_STATIC (nn)
13543           && DECL_INITIAL (nn) != NULL_TREE)
13544         {
13545           tree value;
13546           
13547           push_obstacks (&permanent_obstack, &permanent_obstack);
13548           value = fold_constant_for_init (nn, nn);
13549           pop_obstacks ();
13550
13551           if (value != NULL_TREE)
13552             {
13553               tree type = TREE_TYPE (value);
13554               if (JPRIMITIVE_TYPE_P (type) || 
13555                   (type == string_ptr_type_node && ! flag_emit_class_files))
13556                 return empty_stmt_node;
13557             }
13558           DECL_INITIAL (nn) = NULL_TREE;
13559         }
13560       wfl_op2 = TREE_OPERAND (node, 1);
13561
13562       if (TREE_OPERAND (node, 0) == error_mark_node)
13563         return error_mark_node;
13564
13565       flag = COMPOUND_ASSIGN_P (wfl_op2);
13566       if (flag)
13567         {
13568           /* This might break when accessing outer field from inner
13569              class. TESTME, FIXME */
13570           tree lvalue = java_stabilize_reference (TREE_OPERAND (node, 0)); 
13571
13572           /* Hand stablize the lhs on both places */
13573           TREE_OPERAND (node, 0) = lvalue;
13574           TREE_OPERAND (TREE_OPERAND (node, 1), 0) = 
13575             (flag_emit_class_files ? lvalue : save_expr (lvalue));
13576
13577           /* 15.25.2.a: Left hand is not an array access. FIXME */
13578           /* Now complete the RHS. We write it back later on. */
13579           nn = java_complete_tree (TREE_OPERAND (node, 1));
13580
13581           if ((cn = patch_string (nn)))
13582             nn = cn;
13583
13584           /* The last part of the rewrite for E1 op= E2 is to have 
13585              E1 = (T)(E1 op E2), with T being the type of E1. */
13586           nn = java_complete_tree (build_cast (EXPR_WFL_LINECOL (wfl_op2), 
13587                                                TREE_TYPE (lvalue), nn));
13588
13589           /* 15.25.2.b: Left hand is an array access. FIXME */
13590         }
13591
13592       /* If we're about to patch a NEW_ARRAY_INIT, we call a special
13593          function to complete this RHS. Note that a NEW_ARRAY_INIT
13594          might have been already fully expanded if created as a result
13595          of processing an anonymous array initializer. We avoid doing
13596          the operation twice by testing whether the node already bears
13597          a type. */
13598       else if (TREE_CODE (wfl_op2) == NEW_ARRAY_INIT && !TREE_TYPE (wfl_op2))
13599         nn = patch_new_array_init (TREE_TYPE (TREE_OPERAND (node, 0)),
13600                                    TREE_OPERAND (node, 1));
13601       /* Otherwise we simply complete the RHS */
13602       else
13603         nn = java_complete_tree (TREE_OPERAND (node, 1));
13604
13605       if (nn == error_mark_node)
13606         return error_mark_node;
13607
13608       /* Write back the RHS as we evaluated it. */
13609       TREE_OPERAND (node, 1) = nn;
13610
13611       /* In case we're handling = with a String as a RHS, we need to
13612          produce a String out of the RHS (it might still be a
13613          STRING_CST or a StringBuffer at this stage */
13614       if ((nn = patch_string (TREE_OPERAND (node, 1))))
13615         TREE_OPERAND (node, 1) = nn;
13616
13617       if ((nn = outer_field_access_fix (wfl_op1, TREE_OPERAND (node, 0),
13618                                         TREE_OPERAND (node, 1))))
13619         {
13620           /* We return error_mark_node if outer_field_access_fix
13621              detects we write into a final. */
13622           if (nn == error_mark_node)
13623             return error_mark_node;
13624           node = nn;
13625         }
13626       else
13627         {
13628           node = patch_assignment (node, wfl_op1, wfl_op2);
13629           /* Reorganize the tree if necessary. */
13630           if (flag && (!JREFERENCE_TYPE_P (TREE_TYPE (node)) 
13631                        || JSTRING_P (TREE_TYPE (node))))
13632             node = java_refold (node);
13633         }
13634       
13635       CAN_COMPLETE_NORMALLY (node) = 1;
13636       return node;
13637
13638     case MULT_EXPR:
13639     case PLUS_EXPR:
13640     case MINUS_EXPR:
13641     case LSHIFT_EXPR:
13642     case RSHIFT_EXPR:
13643     case URSHIFT_EXPR:
13644     case BIT_AND_EXPR:
13645     case BIT_XOR_EXPR:
13646     case BIT_IOR_EXPR:
13647     case TRUNC_MOD_EXPR:
13648     case TRUNC_DIV_EXPR:
13649     case RDIV_EXPR:
13650     case TRUTH_ANDIF_EXPR:
13651     case TRUTH_ORIF_EXPR:
13652     case EQ_EXPR: 
13653     case NE_EXPR:
13654     case GT_EXPR:
13655     case GE_EXPR:
13656     case LT_EXPR:
13657     case LE_EXPR:
13658       /* Operands 0 and 1 are WFL in certain cases only. patch_binop
13659          knows how to handle those cases. */
13660       wfl_op1 = TREE_OPERAND (node, 0);
13661       wfl_op2 = TREE_OPERAND (node, 1);
13662
13663       CAN_COMPLETE_NORMALLY (node) = 1;
13664       /* Don't complete string nodes if dealing with the PLUS operand. */
13665       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op1))
13666         {
13667           nn = java_complete_tree (wfl_op1);
13668           if (nn == error_mark_node)
13669             return error_mark_node;
13670
13671           TREE_OPERAND (node, 0) = nn;
13672         }
13673       if (TREE_CODE (node) != PLUS_EXPR || !JSTRING_P (wfl_op2))
13674         {
13675           nn = java_complete_tree (wfl_op2);
13676           if (nn == error_mark_node)
13677             return error_mark_node;
13678
13679           TREE_OPERAND (node, 1) = nn;
13680         }
13681       return force_evaluation_order (patch_binop (node, wfl_op1, wfl_op2));
13682
13683     case INSTANCEOF_EXPR:
13684       wfl_op1 = TREE_OPERAND (node, 0);
13685       COMPLETE_CHECK_OP_0 (node);
13686       if (flag_emit_xref)
13687         {
13688           TREE_TYPE (node) = boolean_type_node;
13689           return node;
13690         }
13691       return patch_binop (node, wfl_op1, TREE_OPERAND (node, 1));
13692
13693     case UNARY_PLUS_EXPR:
13694     case NEGATE_EXPR:
13695     case TRUTH_NOT_EXPR:
13696     case BIT_NOT_EXPR:
13697     case PREDECREMENT_EXPR:
13698     case PREINCREMENT_EXPR:
13699     case POSTDECREMENT_EXPR:
13700     case POSTINCREMENT_EXPR:
13701     case CONVERT_EXPR:
13702       /* There are cases were wfl_op1 is a WFL. patch_unaryop knows
13703          how to handle those cases. */
13704       wfl_op1 = TREE_OPERAND (node, 0);
13705       CAN_COMPLETE_NORMALLY (node) = 1;
13706       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13707       if (TREE_OPERAND (node, 0) == error_mark_node)
13708         return error_mark_node;
13709       node = patch_unaryop (node, wfl_op1);
13710       CAN_COMPLETE_NORMALLY (node) = 1;
13711       break;
13712
13713     case ARRAY_REF:
13714       /* There are cases were wfl_op1 is a WFL. patch_array_ref knows
13715          how to handle those cases. */
13716       wfl_op1 = TREE_OPERAND (node, 0);
13717       TREE_OPERAND (node, 0) = java_complete_tree (wfl_op1);
13718       if (TREE_OPERAND (node, 0) == error_mark_node)
13719         return error_mark_node;
13720       if (!flag_emit_class_files && !flag_emit_xref)
13721         TREE_OPERAND (node, 0) = save_expr (TREE_OPERAND (node, 0));
13722       /* The same applies to wfl_op2 */
13723       wfl_op2 = TREE_OPERAND (node, 1);
13724       TREE_OPERAND (node, 1) = java_complete_tree (wfl_op2);
13725       if (TREE_OPERAND (node, 1) == error_mark_node)
13726         return error_mark_node;
13727       if (!flag_emit_class_files && !flag_emit_xref)
13728         TREE_OPERAND (node, 1) = save_expr (TREE_OPERAND (node, 1));
13729       return patch_array_ref (node);
13730
13731     case RECORD_TYPE:
13732       return node;;
13733
13734     case COMPONENT_REF:
13735       /* The first step in the re-write of qualified name handling.  FIXME.
13736          So far, this is only to support PRIMTYPE.class -> PRIMCLASS.TYPE. */
13737       TREE_OPERAND (node, 0) = java_complete_tree (TREE_OPERAND (node, 0));
13738       if (TREE_CODE (TREE_OPERAND (node, 0)) == RECORD_TYPE)
13739         {
13740           tree name = TREE_OPERAND (node, 1);
13741           tree field = lookup_field_wrapper (TREE_OPERAND (node, 0), name);
13742           if (field == NULL_TREE)
13743             {
13744               error ("missing static field `%s'", IDENTIFIER_POINTER (name));
13745               return error_mark_node;
13746             }
13747           if (! FIELD_STATIC (field))
13748             {
13749               error ("not a static field `%s'", IDENTIFIER_POINTER (name));
13750               return error_mark_node;
13751             }
13752           return field;
13753         }
13754       else
13755         fatal ("unimplemented java_complete_tree for COMPONENT_REF");
13756       break;
13757
13758     case THIS_EXPR:
13759       /* Can't use THIS in a static environment */
13760       if (!current_this)
13761         {
13762           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13763           parse_error_context (wfl_operator,
13764                                "Keyword `this' used outside allowed context");
13765           TREE_TYPE (node) = error_mark_node;
13766           return error_mark_node;
13767         }
13768       if (ctxp->explicit_constructor_p)
13769         {
13770           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
13771           parse_error_context 
13772             (wfl_operator, "Can't reference `this' or `super' before the superclass constructor has been called");
13773           TREE_TYPE (node) = error_mark_node;
13774           return error_mark_node;
13775         }
13776       return current_this;
13777       
13778     case CLASS_LITERAL:
13779       CAN_COMPLETE_NORMALLY (node) = 1;
13780       node = patch_incomplete_class_ref (node);
13781       if (node == error_mark_node)
13782         return error_mark_node;
13783       break;
13784
13785     case INSTANCE_INITIALIZERS_EXPR:
13786       in_instance_initializer++;
13787       node = java_complete_tree (TREE_OPERAND (node, 0));
13788       in_instance_initializer--;
13789       if (node != error_mark_node)
13790         TREE_TYPE (node) = void_type_node;
13791       else
13792         return error_mark_node;
13793       break;
13794
13795     default:
13796       CAN_COMPLETE_NORMALLY (node) = 1;
13797       /* Ok: may be we have a STRING_CST or a crafted `StringBuffer'
13798          and it's time to turn it into the appropriate String object */
13799       if ((nn = patch_string (node)))
13800         node = nn;
13801       else
13802         fatal ("No case for tree code `%s' - java_complete_tree\n",
13803                tree_code_name [TREE_CODE (node)]);
13804     }
13805   return node;
13806 }
13807
13808 /* Complete function call's argument. Return a non zero value is an
13809    error was found.  */
13810
13811 static int
13812 complete_function_arguments (node)
13813      tree node;
13814 {
13815   int flag = 0;
13816   tree cn;
13817
13818   ctxp->explicit_constructor_p += (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13819   for (cn = TREE_OPERAND (node, 1); cn; cn = TREE_CHAIN (cn))
13820     {
13821       tree wfl = TREE_VALUE (cn), parm, temp;
13822       parm = java_complete_tree (wfl);
13823
13824       if (parm == error_mark_node)
13825         {
13826           flag = 1;
13827           continue;
13828         }
13829       /* If have a string literal that we haven't transformed yet or a
13830          crafted string buffer, as a result of use of the the String
13831          `+' operator. Build `parm.toString()' and expand it. */
13832       if ((temp = patch_string (parm)))
13833         parm = temp;
13834       /* Inline PRIMTYPE.TYPE read access */
13835       parm = maybe_build_primttype_type_ref (parm, wfl);
13836
13837       TREE_VALUE (cn) = parm;
13838     }
13839   ctxp->explicit_constructor_p -= (CALL_EXPLICIT_CONSTRUCTOR_P (node) ? 1 : 0);
13840   return flag;
13841 }
13842
13843 /* Sometimes (for loops and variable initialized during their
13844    declaration), we want to wrap a statement around a WFL and turn it
13845    debugable.  */
13846
13847 static tree
13848 build_debugable_stmt (location, stmt)
13849     int location;
13850     tree stmt;
13851 {
13852   if (TREE_CODE (stmt) != EXPR_WITH_FILE_LOCATION)
13853     {
13854       stmt = build_expr_wfl (stmt, input_filename, 0, 0);
13855       EXPR_WFL_LINECOL (stmt) = location;
13856     }
13857   JAVA_MAYBE_GENERATE_DEBUG_INFO (stmt);
13858   return stmt;
13859 }
13860
13861 static tree
13862 build_expr_block (body, decls)
13863      tree body, decls;
13864 {
13865   tree node = make_node (BLOCK);
13866   BLOCK_EXPR_DECLS (node) = decls;
13867   BLOCK_EXPR_BODY (node) = body;
13868   if (body)
13869     TREE_TYPE (node) = TREE_TYPE (body);
13870   TREE_SIDE_EFFECTS (node) = 1;
13871   return node;
13872 }
13873
13874 /* Create a new function block and link it approriately to current
13875    function block chain */
13876
13877 static tree
13878 enter_block ()
13879 {
13880   return (enter_a_block (build_expr_block (NULL_TREE, NULL_TREE)));
13881 }
13882
13883 /* Link block B supercontext to the previous block. The current
13884    function DECL is used as supercontext when enter_a_block is called
13885    for the first time for a given function. The current function body
13886    (DECL_FUNCTION_BODY) is set to be block B.  */
13887
13888 static tree
13889 enter_a_block (b)
13890      tree b;
13891 {
13892   tree fndecl = current_function_decl; 
13893
13894   if (!fndecl) {
13895     BLOCK_SUPERCONTEXT (b) = current_static_block;
13896     current_static_block = b;
13897   }
13898
13899   else if (!DECL_FUNCTION_BODY (fndecl))
13900     {
13901       BLOCK_SUPERCONTEXT (b) = fndecl;
13902       DECL_FUNCTION_BODY (fndecl) = b;
13903     }
13904   else
13905     {
13906       BLOCK_SUPERCONTEXT (b) = DECL_FUNCTION_BODY (fndecl);
13907       DECL_FUNCTION_BODY (fndecl) = b;
13908     }
13909   return b;
13910 }
13911
13912 /* Exit a block by changing the current function body
13913    (DECL_FUNCTION_BODY) to the current block super context, only if
13914    the block being exited isn't the method's top level one.  */
13915
13916 static tree
13917 exit_block ()
13918 {
13919   tree b;
13920   if (current_function_decl)
13921     {
13922       b = DECL_FUNCTION_BODY (current_function_decl);
13923       if (BLOCK_SUPERCONTEXT (b) != current_function_decl)
13924         DECL_FUNCTION_BODY (current_function_decl) = BLOCK_SUPERCONTEXT (b);
13925     }
13926   else
13927     {
13928       b = current_static_block;
13929
13930       if (BLOCK_SUPERCONTEXT (b))
13931         current_static_block = BLOCK_SUPERCONTEXT (b);
13932     }
13933   return b;
13934 }
13935
13936 /* Lookup for NAME in the nested function's blocks, all the way up to
13937    the current toplevel one. It complies with Java's local variable
13938    scoping rules.  */
13939
13940 static tree
13941 lookup_name_in_blocks (name)
13942      tree name;
13943 {
13944   tree b = GET_CURRENT_BLOCK (current_function_decl);
13945
13946   while (b != current_function_decl)
13947     {
13948       tree current;
13949
13950       /* Paranoid sanity check. To be removed */
13951       if (TREE_CODE (b) != BLOCK)
13952         fatal ("non block expr function body - lookup_name_in_blocks");
13953
13954       for (current = BLOCK_EXPR_DECLS (b); current; 
13955            current = TREE_CHAIN (current))
13956         if (DECL_NAME (current) == name)
13957           return current;
13958       b = BLOCK_SUPERCONTEXT (b);
13959     }
13960   return NULL_TREE;
13961 }
13962
13963 static void
13964 maybe_absorb_scoping_blocks ()
13965 {
13966   while (BLOCK_EXPR_ORIGIN (GET_CURRENT_BLOCK (current_function_decl)))
13967     {
13968       tree b = exit_block ();
13969       java_method_add_stmt (current_function_decl, b);
13970       SOURCE_FRONTEND_DEBUG (("Absorbing scoping block at line %d", lineno));
13971     }
13972 }
13973
13974 \f
13975 /* This section of the source is reserved to build_* functions that
13976    are building incomplete tree nodes and the patch_* functions that
13977    are completing them.  */
13978
13979 /* Wrap a non WFL node around a WFL.  */
13980 static tree
13981 build_wfl_wrap (node)
13982     tree node;
13983 {
13984   tree wfl, node_to_insert = node;
13985   
13986   /* We want to process THIS . xxx symbolicaly, to keep it consistent
13987      with the way we're processing SUPER. A THIS from a primary as a
13988      different form than a SUPER. Turn THIS into something symbolic */
13989   if (TREE_CODE (node) == THIS_EXPR)
13990     node_to_insert = wfl = build_wfl_node (this_identifier_node);
13991   else
13992     wfl = build_expr_wfl (NULL_TREE, ctxp->filename, 0, 0);
13993
13994   EXPR_WFL_LINECOL (wfl) = EXPR_WFL_LINECOL (node);
13995   EXPR_WFL_QUALIFICATION (wfl) = build_tree_list (node_to_insert, NULL_TREE);
13996   return wfl;
13997 }
13998
13999
14000 /* Build a super() constructor invocation. Returns empty_stmt_node if
14001    we're currently dealing with the class java.lang.Object. */
14002
14003 static tree
14004 build_super_invocation (mdecl)
14005      tree mdecl;
14006 {
14007   if (DECL_CONTEXT (mdecl) == object_type_node)
14008     return empty_stmt_node;
14009   else
14010     {
14011       tree super_wfl = build_wfl_node (super_identifier_node);
14012       tree a = NULL_TREE, t;
14013       /* If we're dealing with an anonymous class, pass the arguments
14014          of the crafted constructor along. */
14015       if (ANONYMOUS_CLASS_P (DECL_CONTEXT (mdecl)))
14016         {
14017           SKIP_THIS_AND_ARTIFICIAL_PARMS (t, mdecl);
14018           for (; t != end_params_node; t = TREE_CHAIN (t))
14019             a = tree_cons (NULL_TREE, build_wfl_node (TREE_PURPOSE (t)), a);
14020         }
14021       return build_method_invocation (super_wfl, a);
14022     }
14023 }
14024
14025 /* Build a SUPER/THIS qualified method invocation.  */
14026
14027 static tree
14028 build_this_super_qualified_invocation (use_this, name, args, lloc, rloc)
14029      int use_this;
14030      tree name, args;
14031      int lloc, rloc;
14032 {
14033   tree invok;
14034   tree wfl = 
14035     build_wfl_node (use_this ? this_identifier_node : super_identifier_node);
14036   EXPR_WFL_LINECOL (wfl) = lloc;
14037   invok = build_method_invocation (name, args);
14038   return make_qualified_primary (wfl, invok, rloc);
14039 }
14040
14041 /* Build an incomplete CALL_EXPR node. */
14042
14043 static tree
14044 build_method_invocation (name, args)
14045     tree name;
14046     tree args;
14047 {
14048   tree call = build (CALL_EXPR, NULL_TREE, name, args, NULL_TREE);
14049   TREE_SIDE_EFFECTS (call) = 1;
14050   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14051   return call;
14052 }
14053
14054 /* Build an incomplete new xxx(...) node. */
14055
14056 static tree
14057 build_new_invocation (name, args)
14058     tree name, args;
14059 {
14060   tree call = build (NEW_CLASS_EXPR, NULL_TREE, name, args, NULL_TREE);
14061   TREE_SIDE_EFFECTS (call) = 1;
14062   EXPR_WFL_LINECOL (call) = EXPR_WFL_LINECOL (name);
14063   return call;
14064 }
14065
14066 /* Build an incomplete assignment expression. */
14067
14068 static tree
14069 build_assignment (op, op_location, lhs, rhs)
14070      int op, op_location;
14071      tree lhs, rhs;
14072 {
14073   tree assignment;
14074   /* Build the corresponding binop if we deal with a Compound
14075      Assignment operator. Mark the binop sub-tree as part of a
14076      Compound Assignment expression */
14077   if (op != ASSIGN_TK)
14078     {
14079       rhs = build_binop (BINOP_LOOKUP (op), op_location, lhs, rhs);
14080       COMPOUND_ASSIGN_P (rhs) = 1;
14081     }
14082   assignment = build (MODIFY_EXPR, NULL_TREE, lhs, rhs);
14083   TREE_SIDE_EFFECTS (assignment) = 1;
14084   EXPR_WFL_LINECOL (assignment) = op_location;
14085   return assignment;
14086 }
14087
14088 /* Print an INTEGER_CST node in a static buffer, and return the buffer. */
14089
14090 char *
14091 print_int_node (node)
14092     tree node;
14093 {
14094   static char buffer [80];
14095   if (TREE_CONSTANT_OVERFLOW (node))
14096     sprintf (buffer, "<overflow>");
14097     
14098   if (TREE_INT_CST_HIGH (node) == 0)
14099     sprintf (buffer, HOST_WIDE_INT_PRINT_UNSIGNED,
14100              TREE_INT_CST_LOW (node));
14101   else if (TREE_INT_CST_HIGH (node) == -1
14102            && TREE_INT_CST_LOW (node) != 0)
14103     {
14104       buffer [0] = '-';
14105       sprintf (&buffer [1], HOST_WIDE_INT_PRINT_UNSIGNED,
14106                -TREE_INT_CST_LOW (node));
14107     }
14108   else
14109     sprintf (buffer, HOST_WIDE_INT_PRINT_DOUBLE_HEX,
14110              TREE_INT_CST_HIGH (node), TREE_INT_CST_LOW (node));
14111
14112   return buffer;
14113 }
14114
14115 /* Return 1 if an assignment to a FINAL is attempted in a non suitable
14116    context.  */
14117
14118 static int
14119 check_final_assignment (lvalue, wfl)
14120      tree lvalue, wfl;
14121 {
14122   if (TREE_CODE (lvalue) == COMPOUND_EXPR 
14123       && JDECL_P (TREE_OPERAND (lvalue, 1)))
14124     lvalue = TREE_OPERAND (lvalue, 1);
14125
14126   /* When generating class files, references to the `length' field
14127      look a bit different.  */
14128   if ((flag_emit_class_files
14129        && TREE_CODE (lvalue) == COMPONENT_REF
14130        && TYPE_ARRAY_P (TREE_TYPE (TREE_OPERAND (lvalue, 0)))
14131        && FIELD_FINAL (TREE_OPERAND (lvalue, 1)))
14132       || (TREE_CODE (lvalue) == FIELD_DECL
14133           && FIELD_FINAL (lvalue)
14134           && !DECL_CLINIT_P (current_function_decl)
14135           && !DECL_FINIT_P (current_function_decl)))
14136     {
14137       parse_error_context 
14138         (wfl, "Can't assign a value to the final variable `%s'",
14139          IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl)));
14140       return 1;
14141     }
14142   return 0;
14143 }
14144
14145 /* Inline references to java.lang.PRIMTYPE.TYPE when accessed in
14146    read. This is needed to avoid circularities in the implementation
14147    of these fields in libjava. */
14148
14149 static tree
14150 maybe_build_primttype_type_ref (rhs, wfl)
14151     tree rhs, wfl;
14152 {
14153   tree to_return = NULL_TREE;
14154   tree rhs_type = TREE_TYPE (rhs);
14155   if (TREE_CODE (rhs) == COMPOUND_EXPR)
14156     {
14157       tree n = TREE_OPERAND (rhs, 1);
14158       if (TREE_CODE (n) == VAR_DECL 
14159           && DECL_NAME (n) == TYPE_identifier_node
14160           && rhs_type == class_ptr_type)
14161         {
14162           const char *self_name = IDENTIFIER_POINTER (EXPR_WFL_NODE (wfl));
14163           if (!strncmp (self_name, "java.lang.", 10))
14164             to_return = build_primtype_type_ref (self_name);
14165         }
14166     }
14167   return (to_return ? to_return : rhs );
14168 }
14169
14170 /* 15.25 Assignment operators. */
14171
14172 static tree
14173 patch_assignment (node, wfl_op1, wfl_op2)
14174      tree node;
14175      tree wfl_op1;
14176      tree wfl_op2;
14177 {
14178   tree rhs = TREE_OPERAND (node, 1);
14179   tree lvalue = TREE_OPERAND (node, 0), llvalue;
14180   tree lhs_type = NULL_TREE, rhs_type, new_rhs = NULL_TREE;
14181   int error_found = 0;
14182   int lvalue_from_array = 0;
14183
14184   /* Can't assign to a (blank) final. */
14185   if (check_final_assignment (lvalue, wfl_op1))
14186     error_found = 1;
14187
14188   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14189
14190   /* Lhs can be a named variable */
14191   if (JDECL_P (lvalue))
14192     {
14193       lhs_type = TREE_TYPE (lvalue);
14194     }
14195   /* Or Lhs can be a array acccess. Should that be lvalue ? FIXME +
14196      comment on reason why */
14197   else if (TREE_CODE (wfl_op1) == ARRAY_REF)
14198     {
14199       lhs_type = TREE_TYPE (lvalue);
14200       lvalue_from_array = 1;
14201     }
14202   /* Or a field access */
14203   else if (TREE_CODE (lvalue) == COMPONENT_REF)
14204     lhs_type = TREE_TYPE (lvalue);
14205   /* Or a function return slot */
14206   else if (TREE_CODE (lvalue) == RESULT_DECL)
14207     lhs_type = TREE_TYPE (lvalue);
14208   /* Otherwise, we might want to try to write into an optimized static
14209      final, this is an of a different nature, reported further on. */
14210   else if (TREE_CODE (wfl_op1) == EXPR_WITH_FILE_LOCATION
14211            && resolve_expression_name (wfl_op1, &llvalue))
14212     {
14213       if (!error_found && check_final_assignment (llvalue, wfl_op1))
14214         {
14215           /* What we should do instead is resetting the all the flags
14216              previously set, exchange lvalue for llvalue and continue. */
14217           error_found = 1;
14218           return error_mark_node;
14219         }
14220       else 
14221         lhs_type = TREE_TYPE (lvalue);
14222     }
14223   else 
14224     {
14225       parse_error_context (wfl_op1, "Invalid left hand side of assignment");
14226       error_found = 1;
14227     }
14228
14229   rhs_type = TREE_TYPE (rhs);
14230   /* 5.1 Try the assignment conversion for builtin type. */
14231   new_rhs = try_builtin_assignconv (wfl_op1, lhs_type, rhs);
14232
14233   /* 5.2 If it failed, try a reference conversion */
14234   if (!new_rhs && (new_rhs = try_reference_assignconv (lhs_type, rhs)))
14235     lhs_type = promote_type (rhs_type);
14236
14237   /* 15.25.2 If we have a compound assignment, convert RHS into the
14238      type of the LHS */
14239   else if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14240     new_rhs = convert (lhs_type, rhs);
14241
14242   /* Explicit cast required. This is an error */
14243   if (!new_rhs)
14244     {
14245       char *t1 = xstrdup (lang_printable_name (TREE_TYPE (rhs), 0));
14246       char *t2 = xstrdup (lang_printable_name (lhs_type, 0));
14247       tree wfl;
14248       char operation [32];      /* Max size known */
14249
14250       /* If the assignment is part of a declaration, we use the WFL of
14251          the declared variable to point out the error and call it a
14252          declaration problem. If the assignment is a genuine =
14253          operator, we call is a operator `=' problem, otherwise we
14254          call it an assignment problem. In both of these last cases,
14255          we use the WFL of the operator to indicate the error. */
14256
14257       if (MODIFY_EXPR_FROM_INITIALIZATION_P (node))
14258         {
14259           wfl = wfl_op1;
14260           strcpy (operation, "declaration");
14261         }
14262       else
14263         {
14264           wfl = wfl_operator;
14265           if (COMPOUND_ASSIGN_P (TREE_OPERAND (node, 1)))
14266             strcpy (operation, "assignment");
14267           else if (TREE_CODE (TREE_OPERAND (node, 0)) == RESULT_DECL)
14268             strcpy (operation, "`return'");
14269           else
14270             strcpy (operation, "`='");
14271         }
14272
14273       if (!valid_cast_to_p (rhs_type, lhs_type))
14274         parse_error_context
14275           (wfl, "Incompatible type for %s. Can't convert `%s' to `%s'",
14276            operation, t1, t2);
14277       else
14278         parse_error_context (wfl, "Incompatible type for %s. Explicit cast needed to convert `%s' to `%s'",
14279                              operation, t1, t2);
14280       free (t1); free (t2);
14281       error_found = 1;
14282     }
14283
14284   /* Inline read access to java.lang.PRIMTYPE.TYPE */
14285   if (new_rhs)
14286     new_rhs = maybe_build_primttype_type_ref (new_rhs, wfl_op2);
14287
14288   if (error_found)
14289     return error_mark_node;
14290
14291   /* 10.10: Array Store Exception runtime check */
14292   if (!flag_emit_class_files
14293       && !flag_emit_xref
14294       && lvalue_from_array 
14295       && JREFERENCE_TYPE_P (TYPE_ARRAY_ELEMENT (lhs_type)))
14296     {
14297       tree check;
14298       tree base = lvalue;
14299
14300       /* We need to retrieve the right argument for _Jv_CheckArrayStore */
14301       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14302         base = TREE_OPERAND (lvalue, 0);
14303       else
14304         {
14305           if (flag_bounds_check)
14306             base = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (base, 0), 1), 0);
14307           else
14308             base = TREE_OPERAND (TREE_OPERAND (base, 0), 0);
14309         }
14310
14311       /* Build the invocation of _Jv_CheckArrayStore */
14312       new_rhs = save_expr (new_rhs);
14313       check = build (CALL_EXPR, void_type_node,
14314                      build_address_of (soft_checkarraystore_node),
14315                      tree_cons (NULL_TREE, base,
14316                                 build_tree_list (NULL_TREE, new_rhs)),
14317                      NULL_TREE);
14318       TREE_SIDE_EFFECTS (check) = 1;
14319
14320       /* We have to decide on an insertion point */
14321       if (TREE_CODE (lvalue) == COMPOUND_EXPR)
14322         {
14323           tree t;
14324           if (flag_bounds_check)
14325             {
14326               t = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0);
14327               TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (lvalue, 1), 0), 0) =
14328                 build (COMPOUND_EXPR, void_type_node, t, check);
14329             }
14330           else
14331             TREE_OPERAND (lvalue, 1) = build (COMPOUND_EXPR, lhs_type,
14332                                               check, TREE_OPERAND (lvalue, 1));
14333         }
14334       else 
14335         {
14336           /* Make sure the bound check will happen before the store check */
14337           if (flag_bounds_check)
14338             TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0) =
14339               build (COMPOUND_EXPR, void_type_node,
14340                      TREE_OPERAND (TREE_OPERAND (lvalue, 0), 0), check);
14341           else
14342             lvalue = build (COMPOUND_EXPR, lhs_type, check, lvalue);
14343         }
14344     }
14345
14346   TREE_OPERAND (node, 0) = lvalue;
14347   TREE_OPERAND (node, 1) = new_rhs;
14348   TREE_TYPE (node) = lhs_type;
14349   return node;
14350 }
14351
14352 /* Check that type SOURCE can be cast into type DEST. If the cast
14353    can't occur at all, return 0 otherwise 1. This function is used to
14354    produce accurate error messages on the reasons why an assignment
14355    failed. */
14356
14357 static tree
14358 try_reference_assignconv (lhs_type, rhs)
14359      tree lhs_type, rhs;
14360 {
14361   tree new_rhs = NULL_TREE;
14362   tree rhs_type = TREE_TYPE (rhs);
14363
14364   if (!JPRIMITIVE_TYPE_P (rhs_type) && JREFERENCE_TYPE_P (lhs_type))
14365     {
14366       /* `null' may be assigned to any reference type */
14367       if (rhs == null_pointer_node)
14368         new_rhs = null_pointer_node;
14369       /* Try the reference assignment conversion */
14370       else if (valid_ref_assignconv_cast_p (rhs_type, lhs_type, 0))
14371         new_rhs = rhs;
14372       /* This is a magic assignment that we process differently */
14373       else if (rhs == soft_exceptioninfo_call_node)
14374         new_rhs = rhs;
14375     }
14376   return new_rhs;
14377 }
14378
14379 /* Check that RHS can be converted into LHS_TYPE by the assignment
14380    conversion (5.2), for the cases of RHS being a builtin type. Return
14381    NULL_TREE if the conversion fails or if because RHS isn't of a
14382    builtin type. Return a converted RHS if the conversion is possible.  */
14383
14384 static tree
14385 try_builtin_assignconv (wfl_op1, lhs_type, rhs)
14386      tree wfl_op1, lhs_type, rhs;
14387 {
14388   tree new_rhs = NULL_TREE;
14389   tree rhs_type = TREE_TYPE (rhs);
14390
14391   /* Zero accepted everywhere */
14392   if (TREE_CODE (rhs) == INTEGER_CST 
14393       && TREE_INT_CST_HIGH (rhs) == 0 && TREE_INT_CST_LOW (rhs) == 0
14394       && JPRIMITIVE_TYPE_P (rhs_type))
14395     new_rhs = convert (lhs_type, rhs);
14396
14397   /* 5.1.1 Try Identity Conversion,
14398      5.1.2 Try Widening Primitive Conversion */
14399   else if (valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type))
14400     new_rhs = convert (lhs_type, rhs);
14401
14402   /* Try a narrowing primitive conversion (5.1.3): 
14403        - expression is a constant expression of type int AND
14404        - variable is byte, short or char AND
14405        - The value of the expression is representable in the type of the 
14406          variable */
14407   else if (rhs_type == int_type_node && TREE_CONSTANT (rhs)
14408            && (lhs_type == byte_type_node || lhs_type == char_type_node
14409                || lhs_type == short_type_node))
14410     {
14411       if (int_fits_type_p (rhs, lhs_type))
14412         new_rhs = convert (lhs_type, rhs);
14413       else if (wfl_op1)         /* Might be called with a NULL */
14414         parse_warning_context 
14415           (wfl_op1, "Constant expression `%s' to wide for narrowing primitive conversion to `%s'", 
14416            print_int_node (rhs), lang_printable_name (lhs_type, 0));
14417       /* Reported a warning that will turn into an error further
14418          down, so we don't return */
14419     }
14420
14421   return new_rhs;
14422 }
14423
14424 /* Return 1 if RHS_TYPE can be converted to LHS_TYPE by identity
14425    conversion (5.1.1) or widening primitve conversion (5.1.2).  Return
14426    0 is the conversion test fails.  This implements parts the method
14427    invocation convertion (5.3).  */
14428
14429 static int
14430 valid_builtin_assignconv_identity_widening_p (lhs_type, rhs_type)
14431      tree lhs_type, rhs_type;
14432 {
14433   /* 5.1.1: This is the identity conversion part. */
14434   if (lhs_type == rhs_type)
14435     return 1;
14436
14437   /* Reject non primitive types */
14438   if (!JPRIMITIVE_TYPE_P (lhs_type) || !JPRIMITIVE_TYPE_P (rhs_type))
14439     return 0;
14440
14441   /* 5.1.2: widening primitive conversion. byte, even if it's smaller
14442      than a char can't be converted into a char. Short can't too, but
14443      the < test below takes care of that */
14444   if (lhs_type == char_type_node && rhs_type == byte_type_node)
14445     return 0;
14446
14447   /* Accept all promoted type here. Note, we can't use <= in the test
14448      below, because we still need to bounce out assignments of short
14449      to char and the likes */
14450   if (lhs_type == int_type_node
14451       && (rhs_type == promoted_byte_type_node
14452           || rhs_type == promoted_short_type_node
14453           || rhs_type == promoted_char_type_node
14454           || rhs_type == promoted_boolean_type_node))
14455     return 1;
14456
14457   /* From here, an integral is widened if its precision is smaller
14458      than the precision of the LHS or if the LHS is a floating point
14459      type, or the RHS is a float and the RHS a double. */
14460   if ((JINTEGRAL_TYPE_P (rhs_type) && JINTEGRAL_TYPE_P (lhs_type) 
14461        && (TYPE_PRECISION (rhs_type) < TYPE_PRECISION (lhs_type)))
14462       || (JINTEGRAL_TYPE_P (rhs_type) && JFLOAT_TYPE_P (lhs_type))
14463       || (rhs_type == float_type_node && lhs_type == double_type_node))
14464     return 1;
14465
14466   return 0;
14467 }
14468
14469 /* Check that something of SOURCE type can be assigned or cast to
14470    something of DEST type at runtime. Return 1 if the operation is
14471    valid, 0 otherwise. If CAST is set to 1, we're treating the case
14472    were SOURCE is cast into DEST, which borrows a lot of the
14473    assignment check. */
14474
14475 static int
14476 valid_ref_assignconv_cast_p (source, dest, cast)
14477      tree source;
14478      tree dest;
14479      int cast;
14480 {
14481   /* SOURCE or DEST might be null if not from a declared entity. */
14482   if (!source || !dest)
14483     return 0;
14484   if (JNULLP_TYPE_P (source))
14485     return 1;
14486   if (TREE_CODE (source) == POINTER_TYPE)
14487     source = TREE_TYPE (source);
14488   if (TREE_CODE (dest) == POINTER_TYPE)
14489     dest = TREE_TYPE (dest);
14490   /* Case where SOURCE is a class type */
14491   if (TYPE_CLASS_P (source))
14492     {
14493       if (TYPE_CLASS_P (dest))
14494         return  (source == dest 
14495                  || inherits_from_p (source, dest)
14496                  || enclosing_context_p (dest, source /*source, dest*/)
14497                  || (cast && inherits_from_p (dest, source)));
14498       if (TYPE_INTERFACE_P (dest))
14499         {
14500           /* If doing a cast and SOURCE is final, the operation is
14501              always correct a compile time (because even if SOURCE
14502              does not implement DEST, a subclass of SOURCE might). */
14503           if (cast && !CLASS_FINAL (TYPE_NAME (source)))
14504             return 1;
14505           /* Otherwise, SOURCE must implement DEST */
14506           return interface_of_p (dest, source);
14507         }
14508       /* DEST is an array, cast permited if SOURCE is of Object type */
14509       return (cast && source == object_type_node ? 1 : 0);
14510     }
14511   if (TYPE_INTERFACE_P (source))
14512     {
14513       if (TYPE_CLASS_P (dest))
14514         {
14515           /* If not casting, DEST must be the Object type */
14516           if (!cast)
14517             return dest == object_type_node;
14518           /* We're doing a cast. The cast is always valid is class
14519              DEST is not final, otherwise, DEST must implement SOURCE */
14520           else if (!CLASS_FINAL (TYPE_NAME (dest)))
14521             return 1;
14522           else
14523             return interface_of_p (source, dest);
14524         }
14525       if (TYPE_INTERFACE_P (dest))
14526         {
14527           /* If doing a cast, then if SOURCE and DEST contain method
14528              with the same signature but different return type, then
14529              this is a (compile time) error */
14530           if (cast)
14531             {
14532               tree method_source, method_dest;
14533               tree source_type;
14534               tree source_sig;
14535               tree source_name;
14536               for (method_source = TYPE_METHODS (source); method_source; 
14537                    method_source = TREE_CHAIN (method_source))
14538                 {
14539                   source_sig = 
14540                     build_java_argument_signature (TREE_TYPE (method_source));
14541                   source_type = TREE_TYPE (TREE_TYPE (method_source));
14542                   source_name = DECL_NAME (method_source);
14543                   for (method_dest = TYPE_METHODS (dest);
14544                        method_dest; method_dest = TREE_CHAIN (method_dest))
14545                     if (source_sig == 
14546                         build_java_argument_signature (TREE_TYPE (method_dest))
14547                         && source_name == DECL_NAME (method_dest)
14548                         && source_type != TREE_TYPE (TREE_TYPE (method_dest)))
14549                       return 0;
14550                 }
14551               return 1;
14552             }
14553           else
14554             return source == dest || interface_of_p (dest, source);
14555         }
14556       else                      /* Array */
14557         return (cast ? 
14558                 (DECL_NAME (TYPE_NAME (source)) == java_lang_cloneable) : 0);
14559     }
14560   if (TYPE_ARRAY_P (source))
14561     {
14562       if (TYPE_CLASS_P (dest))
14563         return dest == object_type_node;
14564       /* Can't cast an array to an interface unless the interface is
14565          java.lang.Cloneable */
14566       if (TYPE_INTERFACE_P (dest))
14567         return (DECL_NAME (TYPE_NAME (dest)) == java_lang_cloneable ? 1 : 0);
14568       else                      /* Arrays */
14569         {
14570           tree source_element_type = TYPE_ARRAY_ELEMENT (source);
14571           tree dest_element_type = TYPE_ARRAY_ELEMENT (dest);
14572           
14573           /* In case of severe errors, they turn out null */
14574           if (!dest_element_type || !source_element_type)
14575             return 0;
14576           if (source_element_type == dest_element_type)
14577             return 1;
14578           return valid_ref_assignconv_cast_p (source_element_type,
14579                                               dest_element_type, cast);
14580         }
14581       return 0;
14582     }
14583   return 0;
14584 }
14585
14586 static int
14587 valid_cast_to_p (source, dest)
14588      tree source;
14589      tree dest;
14590 {
14591   if (TREE_CODE (source) == POINTER_TYPE)
14592     source = TREE_TYPE (source);
14593   if (TREE_CODE (dest) == POINTER_TYPE)
14594     dest = TREE_TYPE (dest);
14595
14596   if (TREE_CODE (source) == RECORD_TYPE && TREE_CODE (dest) == RECORD_TYPE)
14597     return valid_ref_assignconv_cast_p (source, dest, 1);
14598
14599   else if (JNUMERIC_TYPE_P (source) && JNUMERIC_TYPE_P (dest))
14600     return 1;
14601
14602   return 0;
14603 }
14604
14605 /* Method invocation conversion test. Return 1 if type SOURCE can be
14606    converted to type DEST through the methond invocation conversion
14607    process (5.3) */
14608
14609 static tree
14610 do_unary_numeric_promotion (arg)
14611      tree arg;
14612 {
14613   tree type = TREE_TYPE (arg);
14614   if (TREE_CODE (type) == INTEGER_TYPE ? TYPE_PRECISION (type) < 32
14615       : TREE_CODE (type) == CHAR_TYPE)
14616     arg = convert (int_type_node, arg);
14617   return arg;
14618 }
14619
14620 /* Return a non zero value if SOURCE can be converted into DEST using
14621    the method invocation conversion rule (5.3).  */
14622 static int
14623 valid_method_invocation_conversion_p (dest, source)
14624      tree dest, source;
14625 {
14626   return ((JPRIMITIVE_TYPE_P (source) && JPRIMITIVE_TYPE_P (dest)
14627            && valid_builtin_assignconv_identity_widening_p (dest, source))
14628           || ((JREFERENCE_TYPE_P (source) || JNULLP_TYPE_P (source))
14629               && (JREFERENCE_TYPE_P (dest) || JNULLP_TYPE_P (dest))
14630               && valid_ref_assignconv_cast_p (source, dest, 0)));
14631 }
14632
14633 /* Build an incomplete binop expression. */
14634
14635 static tree
14636 build_binop (op, op_location, op1, op2)
14637      enum tree_code op;
14638      int op_location;
14639      tree op1, op2;
14640 {
14641   tree binop = build (op, NULL_TREE, op1, op2);
14642   TREE_SIDE_EFFECTS (binop) = 1;
14643   /* Store the location of the operator, for better error report. The
14644      string of the operator will be rebuild based on the OP value. */
14645   EXPR_WFL_LINECOL (binop) = op_location;
14646   return binop;
14647 }
14648
14649 /* Build the string of the operator retained by NODE. If NODE is part
14650    of a compound expression, add an '=' at the end of the string. This
14651    function is called when an error needs to be reported on an
14652    operator. The string is returned as a pointer to a static character
14653    buffer. */
14654
14655 static char *
14656 operator_string (node)
14657      tree node;
14658 {
14659 #define BUILD_OPERATOR_STRING(S)                                        \
14660   {                                                                     \
14661     sprintf (buffer, "%s%s", S, (COMPOUND_ASSIGN_P (node) ? "=" : "")); \
14662     return buffer;                                                      \
14663   }
14664   
14665   static char buffer [10];
14666   switch (TREE_CODE (node))
14667     {
14668     case MULT_EXPR: BUILD_OPERATOR_STRING ("*");
14669     case RDIV_EXPR: BUILD_OPERATOR_STRING ("/");
14670     case TRUNC_MOD_EXPR: BUILD_OPERATOR_STRING ("%");
14671     case PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14672     case MINUS_EXPR: BUILD_OPERATOR_STRING ("-");
14673     case LSHIFT_EXPR: BUILD_OPERATOR_STRING ("<<");
14674     case RSHIFT_EXPR: BUILD_OPERATOR_STRING (">>");
14675     case URSHIFT_EXPR: BUILD_OPERATOR_STRING (">>>");
14676     case BIT_AND_EXPR: BUILD_OPERATOR_STRING ("&");
14677     case BIT_XOR_EXPR: BUILD_OPERATOR_STRING ("^");
14678     case BIT_IOR_EXPR: BUILD_OPERATOR_STRING ("|");
14679     case TRUTH_ANDIF_EXPR: BUILD_OPERATOR_STRING ("&&");
14680     case TRUTH_ORIF_EXPR: BUILD_OPERATOR_STRING ("||");
14681     case EQ_EXPR: BUILD_OPERATOR_STRING ("==");
14682     case NE_EXPR: BUILD_OPERATOR_STRING ("!=");
14683     case GT_EXPR: BUILD_OPERATOR_STRING (">");
14684     case GE_EXPR: BUILD_OPERATOR_STRING (">=");
14685     case LT_EXPR: BUILD_OPERATOR_STRING ("<");
14686     case LE_EXPR: BUILD_OPERATOR_STRING ("<=");
14687     case UNARY_PLUS_EXPR: BUILD_OPERATOR_STRING ("+");
14688     case NEGATE_EXPR: BUILD_OPERATOR_STRING ("-");
14689     case TRUTH_NOT_EXPR: BUILD_OPERATOR_STRING ("!");
14690     case BIT_NOT_EXPR: BUILD_OPERATOR_STRING ("~");
14691     case PREINCREMENT_EXPR:     /* Fall through */
14692     case POSTINCREMENT_EXPR: BUILD_OPERATOR_STRING ("++");
14693     case PREDECREMENT_EXPR:     /* Fall through */
14694     case POSTDECREMENT_EXPR: BUILD_OPERATOR_STRING ("--");
14695     default:
14696       fatal ("unregistered operator %s - operator_string",
14697              tree_code_name [TREE_CODE (node)]);
14698     }
14699   return NULL;
14700 #undef BUILD_OPERATOR_STRING
14701 }
14702
14703 /* Return 1 if VAR_ACCESS1 is equivalent to VAR_ACCESS2.  */
14704
14705 static int
14706 java_decl_equiv (var_acc1, var_acc2)
14707      tree var_acc1, var_acc2;
14708 {
14709   if (JDECL_P (var_acc1))
14710     return (var_acc1 == var_acc2);
14711   
14712   return (TREE_CODE (var_acc1) == COMPONENT_REF
14713           && TREE_CODE (var_acc2) == COMPONENT_REF
14714           && TREE_OPERAND (TREE_OPERAND (var_acc1, 0), 0)
14715              == TREE_OPERAND (TREE_OPERAND (var_acc2, 0), 0)
14716           && TREE_OPERAND (var_acc1, 1) == TREE_OPERAND (var_acc2, 1));
14717 }
14718
14719 /* Return a non zero value if CODE is one of the operators that can be
14720    used in conjunction with the `=' operator in a compound assignment.  */
14721
14722 static int
14723 binop_compound_p (code)
14724     enum tree_code code;
14725 {
14726   int i;
14727   for (i = 0; i < BINOP_COMPOUND_CANDIDATES; i++)
14728     if (binop_lookup [i] == code)
14729       break;
14730
14731   return i < BINOP_COMPOUND_CANDIDATES;
14732 }
14733
14734 /* Reorganize after a fold to get SAVE_EXPR to generate what we want.  */
14735
14736 static tree
14737 java_refold (t)
14738      tree t;
14739 {
14740   tree c, b, ns, decl;
14741
14742   if (TREE_CODE (t) != MODIFY_EXPR)
14743     return t;
14744
14745   c = TREE_OPERAND (t, 1);
14746   if (! (c && TREE_CODE (c) == COMPOUND_EXPR
14747          && TREE_CODE (TREE_OPERAND (c, 0)) == MODIFY_EXPR
14748          && binop_compound_p (TREE_CODE (TREE_OPERAND (c, 1)))))
14749     return t;
14750
14751   /* Now the left branch of the binary operator. */
14752   b = TREE_OPERAND (TREE_OPERAND (c, 1), 0);
14753   if (! (b && TREE_CODE (b) == NOP_EXPR 
14754          && TREE_CODE (TREE_OPERAND (b, 0)) == SAVE_EXPR))
14755     return t;
14756
14757   ns = TREE_OPERAND (TREE_OPERAND (b, 0), 0);
14758   if (! (ns && TREE_CODE (ns) == NOP_EXPR
14759          && TREE_CODE (TREE_OPERAND (ns, 0)) == SAVE_EXPR))
14760     return t;
14761
14762   decl = TREE_OPERAND (TREE_OPERAND (ns, 0), 0);
14763   if ((JDECL_P (decl) || TREE_CODE (decl) == COMPONENT_REF)
14764       /* It's got to be the an equivalent decl */
14765       && java_decl_equiv (decl, TREE_OPERAND (TREE_OPERAND (c, 0), 0)))
14766     {
14767       /* Shorten the NOP_EXPR/SAVE_EXPR path. */
14768       TREE_OPERAND (TREE_OPERAND (c, 1), 0) = TREE_OPERAND (ns, 0);
14769       /* Substitute the COMPOUND_EXPR by the BINOP_EXPR */
14770       TREE_OPERAND (t, 1) = TREE_OPERAND (c, 1);
14771       /* Change the right part of the BINOP_EXPR */
14772       TREE_OPERAND (TREE_OPERAND (t, 1), 1) = TREE_OPERAND (c, 0);
14773     }
14774
14775   return t;
14776 }
14777
14778 /* Binary operators (15.16 up to 15.18). We return error_mark_node on
14779    errors but we modify NODE so that it contains the type computed
14780    according to the expression, when it's fixed. Otherwise, we write
14781    error_mark_node as the type. It allows us to further the analysis
14782    of remaining nodes and detects more errors in certain cases.  */
14783
14784 static tree
14785 patch_binop (node, wfl_op1, wfl_op2)
14786      tree node;
14787      tree wfl_op1;
14788      tree wfl_op2;
14789 {
14790   tree op1 = TREE_OPERAND (node, 0);
14791   tree op2 = TREE_OPERAND (node, 1);
14792   tree op1_type = TREE_TYPE (op1);
14793   tree op2_type = TREE_TYPE (op2);
14794   tree prom_type = NULL_TREE, cn;
14795   int code = TREE_CODE (node);
14796
14797   /* If 1, tell the routine that we have to return error_mark_node
14798      after checking for the initialization of the RHS */
14799   int error_found = 0;
14800
14801   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
14802
14803   switch (code)
14804     {
14805     /* 15.16 Multiplicative operators */
14806     case MULT_EXPR:             /* 15.16.1 Multiplication Operator * */
14807     case RDIV_EXPR:             /* 15.16.2 Division Operator / */
14808     case TRUNC_DIV_EXPR:        /* 15.16.2 Integral type Division Operator / */
14809     case TRUNC_MOD_EXPR:        /* 15.16.3 Remainder operator % */
14810       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14811         {
14812           if (!JPRIMITIVE_TYPE_P (op1_type))
14813             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14814           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14815             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14816           TREE_TYPE (node) = error_mark_node;
14817           error_found = 1;
14818           break;
14819         }
14820       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14821       /* Change the division operator if necessary */
14822       if (code == RDIV_EXPR && TREE_CODE (prom_type) == INTEGER_TYPE)
14823         TREE_SET_CODE (node, TRUNC_DIV_EXPR);
14824
14825       if (TREE_CODE (prom_type) == INTEGER_TYPE
14826           && flag_use_divide_subroutine
14827           && ! flag_emit_class_files
14828           && (code == RDIV_EXPR || code == TRUNC_MOD_EXPR))
14829         return build_java_soft_divmod (TREE_CODE (node), prom_type, op1, op2);
14830  
14831       /* This one is more complicated. FLOATs are processed by a
14832          function call to soft_fmod. Duplicate the value of the
14833          COMPOUND_ASSIGN_P flag. */
14834       if (code == TRUNC_MOD_EXPR)
14835         {
14836           tree mod = build_java_binop (TRUNC_MOD_EXPR, prom_type, op1, op2);
14837           COMPOUND_ASSIGN_P (mod) = COMPOUND_ASSIGN_P (node);
14838           TREE_SIDE_EFFECTS (mod)
14839             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14840           return mod;
14841         }
14842       break;
14843
14844     /* 15.17 Additive Operators */
14845     case PLUS_EXPR:             /* 15.17.1 String Concatenation Operator + */
14846
14847       /* Operation is valid if either one argument is a string
14848          constant, a String object or a StringBuffer crafted for the
14849          purpose of the a previous usage of the String concatenation
14850          operator */
14851
14852       if (TREE_CODE (op1) == STRING_CST 
14853           || TREE_CODE (op2) == STRING_CST
14854           || JSTRING_TYPE_P (op1_type)
14855           || JSTRING_TYPE_P (op2_type)
14856           || IS_CRAFTED_STRING_BUFFER_P (op1)
14857           || IS_CRAFTED_STRING_BUFFER_P (op2))
14858         return build_string_concatenation (op1, op2);
14859
14860     case MINUS_EXPR:            /* 15.17.2 Additive Operators (+ and -) for
14861                                    Numeric Types */
14862       if (!JPRIMITIVE_TYPE_P (op1_type) || !JPRIMITIVE_TYPE_P (op2_type))
14863         {
14864           if (!JPRIMITIVE_TYPE_P (op1_type))
14865             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
14866           if (!JPRIMITIVE_TYPE_P (op2_type) && (op1_type != op2_type))
14867             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
14868           TREE_TYPE (node) = error_mark_node;
14869           error_found = 1;
14870           break;
14871         }
14872       prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
14873       break;
14874
14875     /* 15.18 Shift Operators */
14876     case LSHIFT_EXPR:
14877     case RSHIFT_EXPR:
14878     case URSHIFT_EXPR:
14879       if (!JINTEGRAL_TYPE_P (op1_type) || !JINTEGRAL_TYPE_P (op2_type))
14880         {
14881           if (!JINTEGRAL_TYPE_P (op1_type))
14882             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
14883           else
14884             {
14885               if (JPRIMITIVE_TYPE_P (op2_type))
14886                 parse_error_context (wfl_operator,
14887                                      "Incompatible type for `%s'. Explicit cast needed to convert shift distance from `%s' to integral",
14888                                      operator_string (node),
14889                                      lang_printable_name (op2_type, 0));
14890               else
14891                 parse_error_context (wfl_operator,
14892                                      "Incompatible type for `%s'. Can't convert shift distance from `%s' to integral", 
14893                                      operator_string (node),
14894                                      lang_printable_name (op2_type, 0));
14895             }
14896           TREE_TYPE (node) = error_mark_node;
14897           error_found = 1;
14898           break;
14899         }
14900
14901       /* Unary numeric promotion (5.6.1) is performed on each operand
14902          separatly */
14903       op1 = do_unary_numeric_promotion (op1);
14904       op2 = do_unary_numeric_promotion (op2);
14905
14906       /* The type of the shift expression is the type of the promoted
14907          type of the left-hand operand */
14908       prom_type = TREE_TYPE (op1);
14909
14910       /* Shift int only up to 0x1f and long up to 0x3f */
14911       if (prom_type == int_type_node)
14912         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
14913                            build_int_2 (0x1f, 0)));
14914       else
14915         op2 = fold (build (BIT_AND_EXPR, int_type_node, op2, 
14916                            build_int_2 (0x3f, 0)));
14917
14918       /* The >>> operator is a >> operating on unsigned quantities */
14919       if (code == URSHIFT_EXPR && ! flag_emit_class_files)
14920         {
14921           tree to_return;
14922           tree utype = unsigned_type (prom_type);
14923           op1 = convert (utype, op1);
14924           TREE_SET_CODE (node, RSHIFT_EXPR);
14925           TREE_OPERAND (node, 0) = op1;
14926           TREE_OPERAND (node, 1) = op2;
14927           TREE_TYPE (node) = utype;
14928           to_return = convert (prom_type, node);
14929           /* Copy the original value of the COMPOUND_ASSIGN_P flag */
14930           COMPOUND_ASSIGN_P (to_return) = COMPOUND_ASSIGN_P (node);
14931           TREE_SIDE_EFFECTS (to_return)
14932             = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
14933           return to_return;
14934         }
14935       break;
14936
14937       /* 15.19.1 Type Comparison Operator instaceof */
14938     case INSTANCEOF_EXPR:
14939
14940       TREE_TYPE (node) = boolean_type_node;
14941
14942       if (!(op2_type = resolve_type_during_patch (op2)))
14943         return error_mark_node;
14944
14945       /* The first operand must be a reference type or the null type */
14946       if (!JREFERENCE_TYPE_P (op1_type) && op1 != null_pointer_node)
14947         error_found = 1;        /* Error reported further below */
14948
14949       /* The second operand must be a reference type */
14950       if (!JREFERENCE_TYPE_P (op2_type))
14951         {
14952           SET_WFL_OPERATOR (wfl_operator, node, wfl_op2);
14953           parse_error_context
14954             (wfl_operator, "Invalid argument `%s' for `instanceof'",
14955              lang_printable_name (op2_type, 0));
14956           error_found = 1;
14957         }
14958
14959       if (!error_found && valid_ref_assignconv_cast_p (op1_type, op2_type, 1))
14960         {
14961           /* If the first operand is null, the result is always false */
14962           if (op1 == null_pointer_node)
14963             return boolean_false_node;
14964           else if (flag_emit_class_files)
14965             {
14966               TREE_OPERAND (node, 1) = op2_type;
14967               TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1);
14968               return node;
14969             }
14970           /* Otherwise we have to invoke instance of to figure it out */
14971           else
14972             {
14973               tree call =
14974                 build (CALL_EXPR, boolean_type_node,
14975                        build_address_of (soft_instanceof_node),
14976                        tree_cons 
14977                        (NULL_TREE, op1,
14978                         build_tree_list (NULL_TREE,
14979                                          build_class_ref (op2_type))),
14980                        NULL_TREE);
14981               TREE_SIDE_EFFECTS (call) = TREE_SIDE_EFFECTS (op1);
14982               return call;
14983             }
14984         }
14985       /* There is no way the expression operand can be an instance of
14986          the type operand. This is a compile time error. */
14987       else
14988         {
14989           char *t1 = xstrdup (lang_printable_name (op1_type, 0));
14990           SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
14991           parse_error_context 
14992             (wfl_operator, "Impossible for `%s' to be instance of `%s'",
14993              t1, lang_printable_name (op2_type, 0));
14994           free (t1);
14995           error_found = 1;
14996         }
14997       
14998       break;
14999
15000       /* 15.21 Bitwise and Logical Operators */
15001     case BIT_AND_EXPR:
15002     case BIT_XOR_EXPR:
15003     case BIT_IOR_EXPR:
15004       if (JINTEGRAL_TYPE_P (op1_type) && JINTEGRAL_TYPE_P (op2_type))
15005         /* Binary numeric promotion is performed on both operand and the
15006            expression retain that type */
15007         prom_type = binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15008
15009       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE 
15010                && TREE_CODE (op1_type) == BOOLEAN_TYPE)
15011         /* The type of the bitwise operator expression is BOOLEAN */
15012         prom_type = boolean_type_node;
15013       else
15014         {
15015           if (!JINTEGRAL_TYPE_P (op1_type))
15016             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op1_type);
15017           if (!JINTEGRAL_TYPE_P (op2_type) && (op1_type != op2_type))
15018             ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op2_type);
15019           TREE_TYPE (node) = error_mark_node;
15020           error_found = 1;
15021           /* Insert a break here if adding thing before the switch's
15022              break for this case */
15023         }
15024       break;
15025
15026       /* 15.22 Conditional-And Operator */
15027     case TRUTH_ANDIF_EXPR:
15028       /* 15.23 Conditional-Or Operator */
15029     case TRUTH_ORIF_EXPR:
15030       /* Operands must be of BOOLEAN type */
15031       if (TREE_CODE (op1_type) != BOOLEAN_TYPE || 
15032           TREE_CODE (op2_type) != BOOLEAN_TYPE)
15033         {
15034           if (TREE_CODE (op1_type) != BOOLEAN_TYPE)
15035             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op1_type);
15036           if (TREE_CODE (op2_type) != BOOLEAN_TYPE && (op1_type != op2_type))
15037             ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op2_type);
15038           TREE_TYPE (node) = boolean_type_node;
15039           error_found = 1;
15040           break;
15041         }
15042       /* The type of the conditional operators is BOOLEAN */
15043       prom_type = boolean_type_node;
15044       break;
15045
15046       /* 15.19.1 Numerical Comparison Operators <, <=, >, >= */
15047     case LT_EXPR:
15048     case GT_EXPR:
15049     case LE_EXPR:
15050     case GE_EXPR:
15051       /* The type of each of the operands must be a primitive numeric
15052          type */
15053       if (!JNUMERIC_TYPE_P (op1_type) || ! JNUMERIC_TYPE_P (op2_type))
15054         {
15055           if (!JNUMERIC_TYPE_P (op1_type))
15056             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op1_type);
15057           if (!JNUMERIC_TYPE_P (op2_type) && (op1_type != op2_type))
15058             ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op2_type);
15059           TREE_TYPE (node) = boolean_type_node;
15060           error_found = 1;
15061           break;
15062         }
15063       /* Binary numeric promotion is performed on the operands */
15064       binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15065       /* The type of the relation expression is always BOOLEAN */
15066       prom_type = boolean_type_node;
15067       break;
15068
15069       /* 15.20 Equality Operator */
15070     case EQ_EXPR:
15071     case NE_EXPR:
15072       /* It's time for us to patch the strings. */
15073       if ((cn = patch_string (op1))) 
15074        {
15075          op1 = cn;
15076          op1_type = TREE_TYPE (op1);
15077        }
15078       if ((cn = patch_string (op2))) 
15079        {
15080          op2 = cn;
15081          op2_type = TREE_TYPE (op2);
15082        }
15083       
15084       /* 15.20.1 Numerical Equality Operators == and != */
15085       /* Binary numeric promotion is performed on the operands */
15086       if (JNUMERIC_TYPE_P (op1_type) && JNUMERIC_TYPE_P (op2_type))
15087         binary_numeric_promotion (op1_type, op2_type, &op1, &op2);
15088       
15089       /* 15.20.2 Boolean Equality Operators == and != */
15090       else if (TREE_CODE (op1_type) == BOOLEAN_TYPE &&
15091           TREE_CODE (op2_type) == BOOLEAN_TYPE)
15092         ;                       /* Nothing to do here */
15093       
15094       /* 15.20.3 Reference Equality Operators == and != */
15095       /* Types have to be either references or the null type. If
15096          they're references, it must be possible to convert either
15097          type to the other by casting conversion. */
15098       else if (op1 == null_pointer_node || op2 == null_pointer_node 
15099                || (JREFERENCE_TYPE_P (op1_type) && JREFERENCE_TYPE_P (op2_type)
15100                    && (valid_ref_assignconv_cast_p (op1_type, op2_type, 1)
15101                        || valid_ref_assignconv_cast_p (op2_type, 
15102                                                        op1_type, 1))))
15103         ;                       /* Nothing to do here */
15104           
15105       /* Else we have an error figure what can't be converted into
15106          what and report the error */
15107       else
15108         {
15109           char *t1;
15110           t1 = xstrdup (lang_printable_name (op1_type, 0));
15111           parse_error_context 
15112             (wfl_operator,
15113              "Incompatible type for `%s'. Can't convert `%s' to `%s'",
15114              operator_string (node), t1, 
15115              lang_printable_name (op2_type, 0));
15116           free (t1);
15117           TREE_TYPE (node) = boolean_type_node;
15118           error_found = 1;
15119           break;
15120         }
15121       prom_type = boolean_type_node;
15122       break;
15123     }
15124
15125   if (error_found)
15126     return error_mark_node;
15127
15128   TREE_OPERAND (node, 0) = op1;
15129   TREE_OPERAND (node, 1) = op2;
15130   TREE_TYPE (node) = prom_type;
15131   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15132   
15133   if (flag_emit_xref)
15134     return node;
15135
15136   /* fold does not respect side-effect order as required for Java but not C.
15137    * Also, it sometimes create SAVE_EXPRs which are bad when emitting
15138    * bytecode.
15139    */
15140   if (flag_emit_class_files ? (TREE_CONSTANT (op1) && TREE_CONSTANT (op2))
15141       : ! TREE_SIDE_EFFECTS (node))
15142     node = fold (node);
15143   return node;
15144 }
15145
15146 /* Concatenate the STRING_CST CSTE and STRING. When AFTER is a non
15147    zero value, the value of CSTE comes after the valude of STRING */
15148
15149 static tree
15150 do_merge_string_cste (cste, string, string_len, after)
15151      tree cste;
15152      const char *string;
15153      int string_len, after;
15154 {
15155   int len = TREE_STRING_LENGTH (cste) + string_len;
15156   const char *old = TREE_STRING_POINTER (cste);
15157   TREE_STRING_LENGTH (cste) = len;
15158   TREE_STRING_POINTER (cste) = obstack_alloc (expression_obstack, len+1);
15159   if (after)
15160     {
15161       strcpy (TREE_STRING_POINTER (cste), string);
15162       strcat (TREE_STRING_POINTER (cste), old);
15163     }
15164   else
15165     {
15166       strcpy (TREE_STRING_POINTER (cste), old);
15167       strcat (TREE_STRING_POINTER (cste), string);
15168     }
15169   return cste;
15170 }
15171
15172 /* Tries to merge OP1 (a STRING_CST) and OP2 (if suitable). Return a
15173    new STRING_CST on success, NULL_TREE on failure */
15174
15175 static tree
15176 merge_string_cste (op1, op2, after)
15177      tree op1, op2;
15178      int after;
15179 {
15180   /* Handle two string constants right away */
15181   if (TREE_CODE (op2) == STRING_CST)
15182     return do_merge_string_cste (op1, TREE_STRING_POINTER (op2), 
15183                                  TREE_STRING_LENGTH (op2), after);
15184   
15185   /* Reasonable integer constant can be treated right away */
15186   if (TREE_CODE (op2) == INTEGER_CST && !TREE_CONSTANT_OVERFLOW (op2))
15187     {
15188       static const char *boolean_true = "true";
15189       static const char *boolean_false = "false";
15190       static const char *null_pointer = "null";
15191       char ch[3];
15192       const char *string;
15193       
15194       if (op2 == boolean_true_node)
15195         string = boolean_true;
15196       else if (op2 == boolean_false_node)
15197         string = boolean_false;
15198       else if (op2 == null_pointer_node)
15199         string = null_pointer;
15200       else if (TREE_TYPE (op2) == char_type_node)
15201         {
15202           ch[0] = (char )TREE_INT_CST_LOW (op2);
15203           ch[1] = '\0';
15204           string = ch;
15205         }
15206       else
15207           string = print_int_node (op2);
15208       
15209       return do_merge_string_cste (op1, string, strlen (string), after);
15210     }
15211   return NULL_TREE;
15212 }
15213
15214 /* Tries to statically concatenate OP1 and OP2 if possible. Either one
15215    has to be a STRING_CST and the other part must be a STRING_CST or a
15216    INTEGRAL constant. Return a new STRING_CST if the operation
15217    succeed, NULL_TREE otherwise.
15218
15219    If the case we want to optimize for space, we might want to return
15220    NULL_TREE for each invocation of this routine. FIXME */
15221
15222 static tree
15223 string_constant_concatenation (op1, op2)
15224      tree op1, op2;
15225 {
15226   if (TREE_CODE (op1) == STRING_CST || (TREE_CODE (op2) == STRING_CST))
15227     {
15228       tree string, rest;
15229       int invert;
15230       
15231       string = (TREE_CODE (op1) == STRING_CST ? op1 : op2);
15232       rest   = (string == op1 ? op2 : op1);
15233       invert = (string == op1 ? 0 : 1 );
15234       
15235       /* Walk REST, only if it looks reasonable */
15236       if (TREE_CODE (rest) != STRING_CST
15237           && !IS_CRAFTED_STRING_BUFFER_P (rest)
15238           && !JSTRING_TYPE_P (TREE_TYPE (rest))
15239           && TREE_CODE (rest) == EXPR_WITH_FILE_LOCATION)
15240         {
15241           rest = java_complete_tree (rest);
15242           if (rest == error_mark_node)
15243             return error_mark_node;
15244           rest = fold (rest);
15245         }
15246       return merge_string_cste (string, rest, invert);
15247     }
15248   return NULL_TREE;
15249 }
15250
15251 /* Implement the `+' operator. Does static optimization if possible,
15252    otherwise create (if necessary) and append elements to a
15253    StringBuffer. The StringBuffer will be carried around until it is
15254    used for a function call or an assignment. Then toString() will be
15255    called on it to turn it into a String object. */
15256
15257 static tree
15258 build_string_concatenation (op1, op2)
15259      tree op1, op2;
15260 {
15261   tree result;
15262   int side_effects = TREE_SIDE_EFFECTS (op1) | TREE_SIDE_EFFECTS (op2);
15263
15264   if (flag_emit_xref)
15265     return build (PLUS_EXPR, string_type_node, op1, op2);
15266   
15267   /* Try to do some static optimization */
15268   if ((result = string_constant_concatenation (op1, op2)))
15269     return result;
15270
15271   /* Discard empty strings on either side of the expression */
15272   if (TREE_CODE (op1) == STRING_CST && TREE_STRING_LENGTH (op1) == 0)
15273     {
15274       op1 = op2;
15275       op2 = NULL_TREE;
15276     }
15277   else if (TREE_CODE (op2) == STRING_CST && TREE_STRING_LENGTH (op2) == 0)
15278     op2 = NULL_TREE;
15279
15280   /* If operands are string constant, turn then into object references */
15281   if (TREE_CODE (op1) == STRING_CST)
15282     op1 = patch_string_cst (op1);
15283   if (op2 && TREE_CODE (op2) == STRING_CST)
15284     op2 = patch_string_cst (op2);
15285
15286   /* If either one of the constant is null and the other non null
15287      operand is a String object, return it. */
15288   if (JSTRING_TYPE_P (TREE_TYPE (op1)) && !op2)
15289     return op1;
15290
15291   /* If OP1 isn't already a StringBuffer, create and
15292      initialize a new one */
15293   if (!IS_CRAFTED_STRING_BUFFER_P (op1))
15294     {
15295       /* Two solutions here: 
15296          1) OP1 is a constant string reference, we call new StringBuffer(OP1)
15297          2) OP1 is something else, we call new StringBuffer().append(OP1).  */
15298       if (TREE_CONSTANT (op1) && JSTRING_TYPE_P (TREE_TYPE (op1)))
15299         op1 = BUILD_STRING_BUFFER (op1);
15300       else
15301         {
15302           tree aNew = BUILD_STRING_BUFFER (NULL_TREE);
15303           op1 = make_qualified_primary (aNew, BUILD_APPEND (op1), 0);
15304         }
15305     }
15306
15307   if (op2)
15308     {
15309       /* OP1 is no longer the last node holding a crafted StringBuffer */
15310       IS_CRAFTED_STRING_BUFFER_P (op1) = 0;
15311       /* Create a node for `{new...,xxx}.append (op2)' */
15312       if (op2)
15313         op1 = make_qualified_primary (op1, BUILD_APPEND (op2), 0);
15314     }
15315
15316   /* Mark the last node holding a crafted StringBuffer */
15317   IS_CRAFTED_STRING_BUFFER_P (op1) = 1;
15318
15319   TREE_SIDE_EFFECTS (op1) = side_effects;
15320   return op1;
15321 }
15322
15323 /* Patch the string node NODE. NODE can be a STRING_CST of a crafted
15324    StringBuffer. If no string were found to be patched, return
15325    NULL. */
15326
15327 static tree
15328 patch_string (node)
15329     tree node;
15330 {
15331   if (node == error_mark_node)
15332     return error_mark_node;
15333   if (TREE_CODE (node) == STRING_CST)
15334     return patch_string_cst (node);
15335   else if (IS_CRAFTED_STRING_BUFFER_P (node))
15336     {
15337       int saved = ctxp->explicit_constructor_p;
15338       tree invoke = build_method_invocation (wfl_to_string, NULL_TREE);
15339       tree ret;
15340       /* Temporary disable forbid the use of `this'. */
15341       ctxp->explicit_constructor_p = 0;
15342       ret = java_complete_tree (make_qualified_primary (node, invoke, 0));
15343       /* String concatenation arguments must be evaluated in order too. */
15344       ret = force_evaluation_order (ret);
15345       /* Restore it at its previous value */
15346       ctxp->explicit_constructor_p = saved;
15347       return ret;
15348     }
15349   return NULL_TREE;
15350 }
15351
15352 /* Build the internal representation of a string constant.  */
15353
15354 static tree
15355 patch_string_cst (node)
15356      tree node;
15357 {
15358   int location;
15359   if (! flag_emit_class_files)
15360     {
15361       push_obstacks (&permanent_obstack, &permanent_obstack);
15362       node = get_identifier (TREE_STRING_POINTER (node));
15363       location = alloc_name_constant (CONSTANT_String, node);
15364       node = build_ref_from_constant_pool (location);
15365       pop_obstacks ();
15366     }
15367   TREE_TYPE (node) = string_ptr_type_node;
15368   TREE_CONSTANT (node) = 1;
15369   return node;
15370 }
15371
15372 /* Build an incomplete unary operator expression. */
15373
15374 static tree
15375 build_unaryop (op_token, op_location, op1)
15376      int op_token, op_location;
15377      tree op1;
15378 {
15379   enum tree_code op;
15380   tree unaryop;
15381   switch (op_token)
15382     {
15383     case PLUS_TK: op = UNARY_PLUS_EXPR; break;
15384     case MINUS_TK: op = NEGATE_EXPR; break;
15385     case NEG_TK: op = TRUTH_NOT_EXPR; break;
15386     case NOT_TK: op = BIT_NOT_EXPR; break;
15387     default: fatal ("Unknown token `%d' for unary operator - build_unaryop",
15388                     op_token);
15389     }
15390
15391   unaryop = build1 (op, NULL_TREE, op1);
15392   TREE_SIDE_EFFECTS (unaryop) = 1;
15393   /* Store the location of the operator, for better error report. The
15394      string of the operator will be rebuild based on the OP value. */
15395   EXPR_WFL_LINECOL (unaryop) = op_location;
15396   return unaryop;
15397 }
15398
15399 /* Special case for the ++/-- operators, since they require an extra
15400    argument to build, which is set to NULL and patched
15401    later. IS_POST_P is 1 if the operator, 0 otherwise.  */
15402
15403 static tree
15404 build_incdec (op_token, op_location, op1, is_post_p)
15405      int op_token, op_location;
15406      tree op1;
15407      int is_post_p;
15408 {
15409   static enum tree_code lookup [2][2] = 
15410     {
15411       { PREDECREMENT_EXPR, PREINCREMENT_EXPR, },
15412       { POSTDECREMENT_EXPR, POSTINCREMENT_EXPR, },
15413     };
15414   tree node = build (lookup [is_post_p][(op_token - DECR_TK)], 
15415                      NULL_TREE, op1, NULL_TREE);
15416   TREE_SIDE_EFFECTS (node) = 1;
15417   /* Store the location of the operator, for better error report. The
15418      string of the operator will be rebuild based on the OP value. */
15419   EXPR_WFL_LINECOL (node) = op_location;
15420   return node;
15421 }     
15422
15423 /* Build an incomplete cast operator, based on the use of the
15424    CONVERT_EXPR. Note that TREE_TYPE of the constructed node is
15425    set. java_complete_tree is trained to walk a CONVERT_EXPR even
15426    though its type is already set.  */
15427
15428 static tree
15429 build_cast (location, type, exp)
15430      int location;
15431      tree type, exp;
15432 {
15433   tree node = build1 (CONVERT_EXPR, type, exp);
15434   EXPR_WFL_LINECOL (node) = location;
15435   return node;
15436 }
15437
15438 /* Build an incomplete class reference operator.  */
15439 static tree
15440 build_incomplete_class_ref (location, class_name)
15441     int location;
15442     tree class_name;
15443 {
15444   tree node = build1 (CLASS_LITERAL, NULL_TREE, class_name);
15445   EXPR_WFL_LINECOL (node) = location;
15446   return node;
15447 }
15448
15449 /* Complete an incomplete class reference operator.  */
15450 static tree
15451 patch_incomplete_class_ref (node)
15452     tree node;
15453 {
15454   tree type = TREE_OPERAND (node, 0);
15455   tree ref_type;
15456
15457   if (!(ref_type = resolve_type_during_patch (type)))
15458     return error_mark_node;
15459
15460   if (!flag_emit_class_files || JPRIMITIVE_TYPE_P (ref_type))
15461     return build_class_ref (ref_type);
15462
15463   /* If we're emitting class files and we have to deal with non
15464      primitive types, we invoke (and consider generating) the
15465      synthetic static method `class$'. */
15466   if (!TYPE_DOT_CLASS (current_class))
15467       build_dot_class_method (current_class);
15468   ref_type = 
15469     build_dot_class_method_invocation (DECL_NAME (TYPE_NAME (ref_type)));
15470   return java_complete_tree (ref_type);
15471 }
15472
15473 /* 15.14 Unary operators. We return error_mark_node in case of error,
15474    but preserve the type of NODE if the type is fixed.  */
15475
15476 static tree
15477 patch_unaryop (node, wfl_op)
15478      tree node;
15479      tree wfl_op;
15480 {
15481   tree op = TREE_OPERAND (node, 0);
15482   tree op_type = TREE_TYPE (op);
15483   tree prom_type = NULL_TREE, value, decl;
15484   int outer_field_flag = 0;
15485   int code = TREE_CODE (node);
15486   int error_found = 0;
15487
15488   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15489
15490   switch (code)
15491     {
15492       /* 15.13.2 Postfix Increment Operator ++ */
15493     case POSTINCREMENT_EXPR:
15494       /* 15.13.3 Postfix Increment Operator -- */
15495     case POSTDECREMENT_EXPR:
15496       /* 15.14.1 Prefix Increment Operator ++ */
15497     case PREINCREMENT_EXPR:
15498       /* 15.14.2 Prefix Decrement Operator -- */
15499     case PREDECREMENT_EXPR:
15500       op = decl = strip_out_static_field_access_decl (op);
15501       outer_field_flag = outer_field_expanded_access_p (op, NULL, NULL, NULL);
15502       /* We might be trying to change an outer field accessed using
15503          access method. */
15504       if (outer_field_flag)
15505         {
15506           /* Retrieve the decl of the field we're trying to access. We
15507              do that by first retrieving the function we would call to
15508              access the field. It has been already verified that this
15509              field isn't final */
15510           if (flag_emit_class_files)
15511             decl = TREE_OPERAND (op, 0);
15512           else
15513             decl = TREE_OPERAND (TREE_OPERAND (TREE_OPERAND (op, 0), 0), 0);
15514           decl = DECL_FUNCTION_ACCESS_DECL (decl);
15515         }
15516       /* We really should have a JAVA_ARRAY_EXPR to avoid this */
15517       else if (!JDECL_P (decl) 
15518           && TREE_CODE (decl) != COMPONENT_REF
15519           && !(flag_emit_class_files && TREE_CODE (decl) == ARRAY_REF)
15520           && TREE_CODE (decl) != INDIRECT_REF
15521           && !(TREE_CODE (decl) == COMPOUND_EXPR
15522                && TREE_OPERAND (decl, 1)
15523                && (TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)))
15524         {
15525           tree lvalue;
15526           /* Before screaming, check that we're not in fact trying to
15527              increment a optimized static final access, in which case
15528              we issue an different error message. */
15529           if (!(TREE_CODE (wfl_op) == EXPR_WITH_FILE_LOCATION
15530                 && resolve_expression_name (wfl_op, &lvalue)
15531                 && check_final_assignment (lvalue, wfl_op)))
15532             parse_error_context (wfl_operator, "Invalid argument to `%s'",
15533                                  operator_string (node));
15534           TREE_TYPE (node) = error_mark_node;
15535           error_found = 1;
15536         }
15537       
15538       if (check_final_assignment (op, wfl_op))
15539         error_found = 1;
15540
15541       /* From now on, we know that op if a variable and that it has a
15542          valid wfl. We use wfl_op to locate errors related to the
15543          ++/-- operand. */
15544       else if (!JNUMERIC_TYPE_P (op_type))
15545         {
15546           parse_error_context
15547             (wfl_op, "Invalid argument type `%s' to `%s'",
15548              lang_printable_name (op_type, 0), operator_string (node));
15549           TREE_TYPE (node) = error_mark_node;
15550           error_found = 1;
15551         }
15552       else
15553         {
15554           /* Before the addition, binary numeric promotion is performed on
15555              both operands, if really necessary */
15556           if (JINTEGRAL_TYPE_P (op_type))
15557             {
15558               value = build_int_2 (1, 0);
15559               TREE_TYPE (value) = TREE_TYPE (node) = op_type;
15560             }
15561           else
15562             {
15563               value = build_int_2 (1, 0);
15564               TREE_TYPE (node) = 
15565                 binary_numeric_promotion (op_type, 
15566                                           TREE_TYPE (value), &op, &value);
15567             }
15568
15569           /* We remember we might be accessing an outer field */
15570           if (outer_field_flag)
15571             {
15572               /* We re-generate an access to the field */
15573               value = build (PLUS_EXPR, TREE_TYPE (op), 
15574                              build_outer_field_access (wfl_op, decl), value);
15575                                                     
15576               /* And we patch the original access$() into a write 
15577                  with plus_op as a rhs */
15578               return outer_field_access_fix (node, op, value);
15579             }
15580
15581           /* And write back into the node. */
15582           TREE_OPERAND (node, 0) = op;
15583           TREE_OPERAND (node, 1) = value;
15584           /* Convert the overall back into its original type, if
15585              necessary, and return */
15586           if (JINTEGRAL_TYPE_P (op_type))
15587             return fold (node);
15588           else
15589             return fold (convert (op_type, node));
15590         }
15591       break;
15592
15593       /* 15.14.3 Unary Plus Operator + */
15594     case UNARY_PLUS_EXPR:
15595       /* 15.14.4 Unary Minus Operator - */
15596     case NEGATE_EXPR:
15597       if (!JNUMERIC_TYPE_P (op_type))
15598         {
15599           ERROR_CANT_CONVERT_TO_NUMERIC (wfl_operator, node, op_type);
15600           TREE_TYPE (node) = error_mark_node;
15601           error_found = 1;
15602         }
15603       /* Unary numeric promotion is performed on operand */
15604       else
15605         {
15606           op = do_unary_numeric_promotion (op);
15607           prom_type = TREE_TYPE (op);
15608           if (code == UNARY_PLUS_EXPR)
15609             return fold (op);
15610         }
15611       break;
15612
15613       /* 15.14.5 Bitwise Complement Operator ~ */
15614     case BIT_NOT_EXPR:
15615       if (!JINTEGRAL_TYPE_P (op_type))
15616         {
15617           ERROR_CAST_NEEDED_TO_INTEGRAL (wfl_operator, node, op_type);
15618           TREE_TYPE (node) = error_mark_node;
15619           error_found = 1;
15620         }
15621       else
15622         {
15623           op = do_unary_numeric_promotion (op);
15624           prom_type = TREE_TYPE (op);
15625         }
15626       break;
15627
15628       /* 15.14.6 Logical Complement Operator ! */
15629     case TRUTH_NOT_EXPR:
15630       if (TREE_CODE (op_type) != BOOLEAN_TYPE)
15631         {
15632           ERROR_CANT_CONVERT_TO_BOOLEAN (wfl_operator, node, op_type);
15633           /* But the type is known. We will report an error if further
15634              attempt of a assignment is made with this rhs */
15635           TREE_TYPE (node) = boolean_type_node;
15636           error_found = 1;
15637         }
15638       else
15639         prom_type = boolean_type_node;
15640       break;
15641
15642       /* 15.15 Cast Expression */
15643     case CONVERT_EXPR:
15644       value = patch_cast (node, wfl_operator);
15645       if (value == error_mark_node)
15646         {
15647           /* If this cast is part of an assignment, we tell the code
15648              that deals with it not to complain about a mismatch,
15649              because things have been cast, anyways */
15650           TREE_TYPE (node) = error_mark_node;
15651           error_found = 1;
15652         }
15653       else
15654         {
15655           value = fold (value);
15656           TREE_SIDE_EFFECTS (value) = TREE_SIDE_EFFECTS (op);
15657           return value;
15658         }
15659       break;
15660     }
15661   
15662   if (error_found)
15663     return error_mark_node;
15664
15665   /* There are cases where node has been replaced by something else
15666      and we don't end up returning here: UNARY_PLUS_EXPR,
15667      CONVERT_EXPR, {POST,PRE}{INCR,DECR}EMENT_EXPR. */
15668   TREE_OPERAND (node, 0) = fold (op);
15669   TREE_TYPE (node) = prom_type;
15670   TREE_SIDE_EFFECTS (node) = TREE_SIDE_EFFECTS (op);
15671   return fold (node);
15672 }
15673
15674 /* Generic type resolution that sometimes takes place during node
15675    patching. Returned the resolved type or generate an error
15676    message. Return the resolved type or NULL_TREE.  */
15677
15678 static tree
15679 resolve_type_during_patch (type)
15680      tree type;
15681 {
15682   if (unresolved_type_p (type, NULL))
15683     {
15684       tree type_decl = resolve_no_layout (EXPR_WFL_NODE (type), NULL_TREE);
15685       if (!type_decl)
15686         {
15687           parse_error_context (type, 
15688                                "Class `%s' not found in type declaration",
15689                                IDENTIFIER_POINTER (EXPR_WFL_NODE (type)));
15690           return NULL_TREE;
15691         }
15692       else
15693         {
15694           CLASS_LOADED_P (TREE_TYPE (type_decl)) = 1;
15695           return TREE_TYPE (type_decl);
15696         }
15697     }
15698   return type;
15699 }
15700 /* 5.5 Casting Conversion. error_mark_node is returned if an error is
15701    found. Otherwise NODE or something meant to replace it is returned.  */
15702
15703 static tree
15704 patch_cast (node, wfl_operator)
15705      tree node;
15706      tree wfl_operator;
15707 {
15708   tree op = TREE_OPERAND (node, 0);
15709   tree op_type = TREE_TYPE (op);
15710   tree cast_type = TREE_TYPE (node);
15711   char *t1;
15712
15713   /* First resolve OP_TYPE if unresolved */
15714   if (!(cast_type = resolve_type_during_patch (cast_type)))
15715     return error_mark_node;
15716
15717   /* Check on cast that are proven correct at compile time */
15718   if (JNUMERIC_TYPE_P (cast_type) && JNUMERIC_TYPE_P (op_type))
15719     {
15720       /* Same type */
15721       if (cast_type == op_type)
15722         return node;
15723
15724       /* float and double type are converted to the original type main
15725          variant and then to the target type. */
15726       if (JFLOAT_TYPE_P (op_type) && TREE_CODE (cast_type) == CHAR_TYPE)
15727         op = convert (integer_type_node, op);
15728
15729       /* Try widening/narowwing convertion. Potentially, things need
15730          to be worked out in gcc so we implement the extreme cases
15731          correctly. fold_convert() needs to be fixed. */
15732       return convert (cast_type, op);
15733     }
15734
15735   /* It's also valid to cast a boolean into a boolean */
15736   if (op_type == boolean_type_node && cast_type == boolean_type_node)
15737     return node;
15738
15739   /* null can be casted to references */
15740   if (op == null_pointer_node && JREFERENCE_TYPE_P (cast_type))
15741     return build_null_of_type (cast_type);
15742
15743   /* The remaining legal casts involve conversion between reference
15744      types. Check for their compile time correctness. */
15745   if (JREFERENCE_TYPE_P (op_type) && JREFERENCE_TYPE_P (cast_type) 
15746       && valid_ref_assignconv_cast_p (op_type, cast_type, 1))
15747     {
15748       TREE_TYPE (node) = promote_type (cast_type);
15749       /* Now, the case can be determined correct at compile time if
15750          OP_TYPE can be converted into CAST_TYPE by assignment
15751          conversion (5.2) */
15752
15753       if (valid_ref_assignconv_cast_p (op_type, cast_type, 0))
15754         {
15755           TREE_SET_CODE (node, NOP_EXPR);
15756           return node;
15757         }
15758
15759       if (flag_emit_class_files)
15760         {
15761           TREE_SET_CODE (node, CONVERT_EXPR);
15762           return node;
15763         }
15764
15765       /* The cast requires a run-time check */
15766       return build (CALL_EXPR, promote_type (cast_type),
15767                     build_address_of (soft_checkcast_node),
15768                     tree_cons (NULL_TREE, build_class_ref (cast_type),
15769                                build_tree_list (NULL_TREE, op)),
15770                     NULL_TREE);
15771     }
15772
15773   /* Any other casts are proven incorrect at compile time */
15774   t1 = xstrdup (lang_printable_name (op_type, 0));
15775   parse_error_context (wfl_operator, "Invalid cast from `%s' to `%s'",
15776                        t1, lang_printable_name (cast_type, 0));
15777   free (t1);
15778   return error_mark_node;
15779 }
15780
15781 /* Build a null constant and give it the type TYPE.  */
15782
15783 static tree
15784 build_null_of_type (type)
15785      tree type;
15786 {
15787   tree node = build_int_2 (0, 0);
15788   TREE_TYPE (node) = promote_type (type);
15789   return node;
15790 }
15791
15792 /* Build an ARRAY_REF incomplete tree node. Note that operand 1 isn't
15793    a list of indices. */
15794 static tree
15795 build_array_ref (location, array, index)
15796      int location;
15797      tree array, index;
15798 {
15799   tree node = build (ARRAY_REF, NULL_TREE, array, index);
15800   EXPR_WFL_LINECOL (node) = location;
15801   return node;
15802 }
15803
15804 /* 15.12 Array Access Expression */
15805
15806 static tree
15807 patch_array_ref (node)
15808      tree node;
15809 {
15810   tree array = TREE_OPERAND (node, 0);
15811   tree array_type  = TREE_TYPE (array);
15812   tree index = TREE_OPERAND (node, 1);
15813   tree index_type = TREE_TYPE (index);
15814   int error_found = 0;
15815
15816   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
15817
15818   if (TREE_CODE (array_type) == POINTER_TYPE)
15819     array_type = TREE_TYPE (array_type);
15820
15821   /* The array reference must be an array */
15822   if (!TYPE_ARRAY_P (array_type))
15823     {
15824       parse_error_context 
15825         (wfl_operator,
15826          "`[]' can only be applied to arrays. It can't be applied to `%s'",
15827          lang_printable_name (array_type, 0));
15828       TREE_TYPE (node) = error_mark_node;
15829       error_found = 1;
15830     }
15831
15832   /* The array index undergoes unary numeric promotion. The promoted
15833      type must be int */
15834   index = do_unary_numeric_promotion (index);
15835   if (TREE_TYPE (index) != int_type_node)
15836     {
15837       if (valid_cast_to_p (index_type, int_type_node))
15838         parse_error_context (wfl_operator,
15839    "Incompatible type for `[]'. Explicit cast needed to convert `%s' to `int'",
15840                              lang_printable_name (index_type, 0));
15841       else
15842         parse_error_context (wfl_operator,
15843           "Incompatible type for `[]'. Can't convert `%s' to `int'",
15844                              lang_printable_name (index_type, 0));
15845       TREE_TYPE (node) = error_mark_node;
15846       error_found = 1;
15847     }
15848
15849   if (error_found)
15850     return error_mark_node;
15851
15852   array_type = TYPE_ARRAY_ELEMENT (array_type);
15853
15854   if (flag_emit_class_files || flag_emit_xref)
15855     {
15856       TREE_OPERAND (node, 0) = array;
15857       TREE_OPERAND (node, 1) = index;
15858     }
15859   else
15860     {
15861       /* The save_expr is for correct evaluation order.  It would be cleaner
15862          to use force_evaluation_order (see comment there), but that is
15863          difficult when we also have to deal with bounds checking. */
15864       if (TREE_SIDE_EFFECTS (index))
15865         array = save_expr (array);
15866       node = build_java_arrayaccess (array, array_type, index);
15867       if (TREE_SIDE_EFFECTS (index))
15868         node = build (COMPOUND_EXPR, array_type, array, node);
15869     }
15870   TREE_TYPE (node) = array_type;
15871   return node;
15872 }
15873
15874 /* 15.9 Array Creation Expressions */
15875
15876 static tree
15877 build_newarray_node (type, dims, extra_dims)
15878      tree type;
15879      tree dims;
15880      int extra_dims;
15881 {
15882   tree node =
15883     build (NEW_ARRAY_EXPR, NULL_TREE, type, nreverse (dims), 
15884            build_int_2 (extra_dims, 0));
15885   return node;
15886 }
15887
15888 static tree
15889 patch_newarray (node)
15890      tree node;
15891 {
15892   tree type = TREE_OPERAND (node, 0);
15893   tree dims = TREE_OPERAND (node, 1);
15894   tree cdim, array_type;
15895   int error_found = 0;
15896   int ndims = 0;
15897   int xdims = TREE_INT_CST_LOW (TREE_OPERAND (node, 2));
15898
15899   /* Dimension types are verified. It's better for the types to be
15900      verified in order. */
15901   for (cdim = dims, ndims = 0; cdim; cdim = TREE_CHAIN (cdim), ndims++ )
15902     {
15903       int dim_error = 0;
15904       tree dim = TREE_VALUE (cdim);
15905
15906       /* Dim might have been saved during its evaluation */
15907       dim = (TREE_CODE (dim) == SAVE_EXPR ? dim = TREE_OPERAND (dim, 0) : dim);
15908
15909       /* The type of each specified dimension must be an integral type. */
15910       if (!JINTEGRAL_TYPE_P (TREE_TYPE (dim)))
15911         dim_error = 1;
15912
15913       /* Each expression undergoes an unary numeric promotion (5.6.1) and the
15914          promoted type must be int. */
15915       else
15916         {
15917           dim = do_unary_numeric_promotion (dim);
15918           if (TREE_TYPE (dim) != int_type_node)
15919             dim_error = 1;
15920         }
15921
15922       /* Report errors on types here */
15923       if (dim_error)
15924         {
15925           parse_error_context 
15926             (TREE_PURPOSE (cdim), 
15927              "Incompatible type for dimension in array creation expression. %s convert `%s' to `int'", 
15928              (valid_cast_to_p (TREE_TYPE (dim), int_type_node) ?
15929               "Explicit cast needed to" : "Can't"),
15930              lang_printable_name (TREE_TYPE (dim), 0));
15931           error_found = 1;
15932         }
15933
15934       TREE_PURPOSE (cdim) = NULL_TREE;
15935     }
15936
15937   /* Resolve array base type if unresolved */
15938   if (!(type = resolve_type_during_patch (type)))
15939     error_found = 1;
15940
15941   if (error_found)
15942     {
15943       /* We don't want further evaluation of this bogus array creation
15944          operation */
15945       TREE_TYPE (node) = error_mark_node;
15946       return error_mark_node;
15947     }
15948
15949   /* Set array_type to the actual (promoted) array type of the result. */
15950   if (TREE_CODE (type) == RECORD_TYPE)
15951     type = build_pointer_type (type);
15952   while (--xdims >= 0)
15953     {
15954       type = promote_type (build_java_array_type (type, -1));
15955     }
15956   dims = nreverse (dims);
15957   array_type = type;
15958   for (cdim = dims; cdim; cdim = TREE_CHAIN (cdim))
15959     {
15960       type = array_type;
15961       array_type
15962         = build_java_array_type (type,
15963                                  TREE_CODE (cdim) == INTEGER_CST
15964                                  ? (HOST_WIDE_INT) TREE_INT_CST_LOW (cdim)
15965                                  : -1);
15966       array_type = promote_type (array_type);
15967     }
15968   dims = nreverse (dims);
15969
15970   /* The node is transformed into a function call. Things are done
15971      differently according to the number of dimensions. If the number
15972      of dimension is equal to 1, then the nature of the base type
15973      (primitive or not) matters. */
15974   if (ndims == 1)
15975     return build_new_array (type, TREE_VALUE (dims));
15976   
15977   /* Can't reuse what's already written in expr.c because it uses the
15978      JVM stack representation. Provide a build_multianewarray. FIXME */
15979   return build (CALL_EXPR, array_type,
15980                 build_address_of (soft_multianewarray_node),
15981                 tree_cons (NULL_TREE, build_class_ref (TREE_TYPE (array_type)),
15982                            tree_cons (NULL_TREE, 
15983                                       build_int_2 (ndims, 0), dims )),
15984                 NULL_TREE);
15985 }
15986
15987 /* 10.6 Array initializer.  */
15988
15989 /* Build a wfl for array element that don't have one, so we can
15990    pin-point errors.  */
15991
15992 static tree
15993 maybe_build_array_element_wfl (node)
15994      tree node;
15995 {
15996   if (TREE_CODE (node) != EXPR_WITH_FILE_LOCATION)
15997     return build_expr_wfl (NULL_TREE, ctxp->filename,
15998                            ctxp->elc.line, ctxp->elc.prev_col);
15999   else
16000     return NULL_TREE;
16001 }
16002
16003 /* Build a NEW_ARRAY_INIT that features a CONSTRUCTOR node. This makes
16004    identification of initialized arrays easier to detect during walk
16005    and expansion.  */
16006
16007 static tree
16008 build_new_array_init (location, values)
16009      int location;
16010      tree values;
16011 {
16012   tree constructor = build (CONSTRUCTOR, NULL_TREE, NULL_TREE, values);
16013   tree to_return = build1 (NEW_ARRAY_INIT, NULL_TREE, constructor);
16014   EXPR_WFL_LINECOL (to_return) = location;
16015   return to_return;
16016 }
16017
16018 /* Expand a NEW_ARRAY_INIT node. Return error_mark_node if an error
16019    occurred.  Otherwise return NODE after having set its type
16020    appropriately.  */
16021
16022 static tree
16023 patch_new_array_init (type, node)
16024      tree type, node;
16025 {
16026   int error_seen = 0;
16027   tree current, element_type;
16028   HOST_WIDE_INT length;
16029   int all_constant = 1;
16030   tree init = TREE_OPERAND (node, 0);
16031
16032   if (TREE_CODE (type) != POINTER_TYPE || ! TYPE_ARRAY_P (TREE_TYPE (type)))
16033     {
16034       parse_error_context (node,
16035                            "Invalid array initializer for non-array type `%s'",
16036                            lang_printable_name (type, 1));
16037       return error_mark_node;
16038     }
16039   type = TREE_TYPE (type);
16040   element_type = TYPE_ARRAY_ELEMENT (type);
16041
16042   CONSTRUCTOR_ELTS (init) = nreverse (CONSTRUCTOR_ELTS (init));
16043
16044   for (length = 0, current = CONSTRUCTOR_ELTS (init);
16045        current;  length++, current = TREE_CHAIN (current))
16046     {
16047       tree elt = TREE_VALUE (current);
16048       if (elt == NULL_TREE || TREE_CODE (elt) != NEW_ARRAY_INIT)
16049         {
16050           error_seen |= array_constructor_check_entry (element_type, current);
16051           elt = TREE_VALUE (current);
16052           /* When compiling to native code, STRING_CST is converted to
16053              INDIRECT_REF, but still with a TREE_CONSTANT flag. */
16054           if (! TREE_CONSTANT (elt) || TREE_CODE (elt) == INDIRECT_REF)
16055             all_constant = 0;
16056         }
16057       else
16058         {
16059           TREE_VALUE (current) = patch_new_array_init (element_type, elt);
16060           TREE_PURPOSE (current) = NULL_TREE;
16061           all_constant = 0;
16062         }
16063       if (elt && TREE_VALUE (elt) == error_mark_node)
16064         error_seen = 1;
16065     }
16066
16067   if (error_seen)
16068     return error_mark_node;
16069
16070   /* Create a new type. We can't reuse the one we have here by
16071      patching its dimension because it originally is of dimension -1
16072      hence reused by gcc. This would prevent triangular arrays. */
16073   type = build_java_array_type (element_type, length);
16074   TREE_TYPE (init) = TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (type))));
16075   TREE_TYPE (node) = promote_type (type);
16076   TREE_CONSTANT (init) = all_constant;
16077   TREE_CONSTANT (node) = all_constant;
16078   return node;
16079 }
16080
16081 /* Verify that one entry of the initializer element list can be
16082    assigned to the array base type. Report 1 if an error occurred, 0
16083    otherwise.  */
16084
16085 static int
16086 array_constructor_check_entry (type, entry)
16087      tree type, entry;
16088 {
16089   char *array_type_string = NULL;       /* For error reports */
16090   tree value, type_value, new_value, wfl_value, patched;
16091   int error_seen = 0;
16092
16093   new_value = NULL_TREE;
16094   wfl_value = TREE_VALUE (entry);
16095
16096   push_obstacks (&permanent_obstack, &permanent_obstack);
16097   value = java_complete_tree (TREE_VALUE (entry));
16098   /* patch_string return error_mark_node if arg is error_mark_node */
16099   if ((patched = patch_string (value)))
16100     value = patched;
16101   if (value == error_mark_node)
16102     return 1;
16103   
16104   type_value = TREE_TYPE (value);
16105   
16106   /* At anytime, try_builtin_assignconv can report a warning on
16107      constant overflow during narrowing. */
16108   SET_WFL_OPERATOR (wfl_operator, TREE_PURPOSE (entry), wfl_value);
16109   new_value = try_builtin_assignconv (wfl_operator, type, value);
16110   if (!new_value && (new_value = try_reference_assignconv (type, value)))
16111     type_value = promote_type (type);
16112
16113   pop_obstacks ();
16114   /* Check and report errors */
16115   if (!new_value)
16116     {
16117       const char *msg = (!valid_cast_to_p (type_value, type) ?
16118                    "Can't" : "Explicit cast needed to");
16119       if (!array_type_string)
16120         array_type_string = xstrdup (lang_printable_name (type, 1));
16121       parse_error_context 
16122         (wfl_operator, "Incompatible type for array. %s convert `%s' to `%s'",
16123          msg, lang_printable_name (type_value, 1), array_type_string);
16124       error_seen = 1;
16125     }
16126   
16127   if (new_value)
16128     {
16129       new_value = maybe_build_primttype_type_ref (new_value, wfl_operator);
16130       TREE_VALUE (entry) = new_value;
16131     }
16132
16133   if (array_type_string)
16134     free (array_type_string);
16135
16136   TREE_PURPOSE (entry) = NULL_TREE;
16137   return error_seen;
16138 }
16139
16140 static tree
16141 build_this (location)
16142      int location;
16143 {
16144   tree node = build_wfl_node (this_identifier_node);
16145   TREE_SET_CODE (node, THIS_EXPR);
16146   EXPR_WFL_LINECOL (node) = location;
16147   return node;
16148 }
16149
16150 /* 14.15 The return statement. It builds a modify expression that
16151    assigns the returned value to the RESULT_DECL that hold the value
16152    to be returned. */
16153
16154 static tree
16155 build_return (location, op)
16156      int location;
16157      tree op;
16158 {
16159   tree node = build1 (RETURN_EXPR, NULL_TREE, op);
16160   EXPR_WFL_LINECOL (node) = location;
16161   node = build_debugable_stmt (location, node);
16162   return node;
16163 }
16164
16165 static tree
16166 patch_return (node)
16167      tree node;
16168 {
16169   tree return_exp = TREE_OPERAND (node, 0);
16170   tree meth = current_function_decl;
16171   tree mtype = TREE_TYPE (TREE_TYPE (current_function_decl));
16172   int error_found = 0;
16173
16174   TREE_TYPE (node) = error_mark_node;
16175   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16176
16177   /* It's invalid to have a return value within a function that is
16178      declared with the keyword void or that is a constructor */
16179   if (return_exp && (mtype == void_type_node || DECL_CONSTRUCTOR_P (meth)))
16180     error_found = 1;
16181
16182   /* It's invalid to use a return statement in a static block */
16183   if (DECL_CLINIT_P (current_function_decl))
16184     error_found = 1;
16185
16186   /* It's invalid to have a no return value within a function that
16187      isn't declared with the keyword `void' */
16188   if (!return_exp && (mtype != void_type_node && !DECL_CONSTRUCTOR_P (meth)))
16189     error_found = 2;
16190   
16191   if (in_instance_initializer)
16192     error_found = 1;
16193
16194   if (error_found)
16195     {
16196       if (in_instance_initializer)
16197         parse_error_context (wfl_operator,
16198                              "`return' inside instance initializer");
16199         
16200       else if (DECL_CLINIT_P (current_function_decl))
16201         parse_error_context (wfl_operator,
16202                              "`return' inside static initializer");
16203
16204       else if (!DECL_CONSTRUCTOR_P (meth))
16205         {
16206           char *t = xstrdup (lang_printable_name (mtype, 0));
16207           parse_error_context (wfl_operator, 
16208                                "`return' with%s value from `%s %s'",
16209                                (error_found == 1 ? "" : "out"), 
16210                                t, lang_printable_name (meth, 0));
16211           free (t);
16212         }
16213       else
16214         parse_error_context (wfl_operator, 
16215                              "`return' with value from constructor `%s'",
16216                              lang_printable_name (meth, 0));
16217       return error_mark_node;
16218     }
16219
16220   /* If we have a return_exp, build a modify expression and expand
16221      it. Note: at that point, the assignment is declared valid, but we
16222      may want to carry some more hacks */
16223   if (return_exp)
16224     {
16225       tree exp = java_complete_tree (return_exp);
16226       tree modify, patched;
16227
16228       /* If the function returned value and EXP are booleans, EXP has
16229       to be converted into the type of DECL_RESULT, which is integer
16230       (see complete_start_java_method) */
16231       if (TREE_TYPE (exp) == boolean_type_node &&
16232           TREE_TYPE (TREE_TYPE (meth)) == boolean_type_node)
16233         exp = convert_to_integer (TREE_TYPE (DECL_RESULT (meth)), exp);
16234
16235       /* `null' can be assigned to a function returning a reference */
16236       if (JREFERENCE_TYPE_P (TREE_TYPE (TREE_TYPE (meth))) &&
16237           exp == null_pointer_node)
16238         exp = build_null_of_type (TREE_TYPE (TREE_TYPE (meth)));
16239
16240       if ((patched = patch_string (exp)))
16241         exp = patched;
16242       
16243       modify = build (MODIFY_EXPR, NULL_TREE, DECL_RESULT (meth), exp);
16244       EXPR_WFL_LINECOL (modify) = EXPR_WFL_LINECOL (node);
16245       modify = java_complete_tree (modify);
16246
16247       if (modify != error_mark_node)
16248         {
16249           TREE_SIDE_EFFECTS (modify) = 1;
16250           TREE_OPERAND (node, 0) = modify;
16251         }
16252       else
16253         return error_mark_node;
16254     }
16255   TREE_TYPE (node) = void_type_node;
16256   TREE_SIDE_EFFECTS (node) = 1;
16257   return node;
16258 }
16259
16260 /* 14.8 The if Statement */
16261
16262 static tree
16263 build_if_else_statement (location, expression, if_body, else_body)
16264      int location;
16265      tree expression, if_body, else_body;
16266 {
16267   tree node;
16268   if (!else_body)
16269     else_body = empty_stmt_node;
16270   node = build (COND_EXPR, NULL_TREE, expression, if_body, else_body);
16271   EXPR_WFL_LINECOL (node) = location;
16272   node = build_debugable_stmt (location, node);
16273   return node;
16274 }
16275
16276 static tree
16277 patch_if_else_statement (node)
16278      tree node;
16279 {
16280   tree expression = TREE_OPERAND (node, 0);
16281
16282   TREE_TYPE (node) = error_mark_node;
16283   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16284
16285   /* The type of expression must be boolean */
16286   if (TREE_TYPE (expression) != boolean_type_node
16287       && TREE_TYPE (expression) != promoted_boolean_type_node)
16288     {
16289       parse_error_context 
16290         (wfl_operator, 
16291          "Incompatible type for `if'. Can't convert `%s' to `boolean'", 
16292          lang_printable_name (TREE_TYPE (expression), 0));
16293       return error_mark_node;
16294     }
16295   
16296   TREE_TYPE (node) = void_type_node;
16297   TREE_SIDE_EFFECTS (node) = 1;
16298   CAN_COMPLETE_NORMALLY (node)
16299     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1))
16300     | CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 2));
16301   return node;
16302 }
16303
16304 /* 14.6 Labeled Statements */
16305
16306 /* Action taken when a lableled statement is parsed. a new
16307    LABELED_BLOCK_EXPR is created. No statement is attached to the
16308    label, yet.  LABEL can be NULL_TREE for artificially-generated blocks. */
16309
16310 static tree
16311 build_labeled_block (location, label)
16312      int location;
16313      tree label;
16314 {
16315   tree label_name ;
16316   tree label_decl, node;
16317   if (label == NULL_TREE || label == continue_identifier_node)
16318     label_name = label;
16319   else
16320     {
16321       label_name = merge_qualified_name (label_id, label);
16322       /* Issue an error if we try to reuse a label that was previously
16323          declared */
16324       if (IDENTIFIER_LOCAL_VALUE (label_name))
16325         {
16326           EXPR_WFL_LINECOL (wfl_operator) = location;
16327           parse_error_context (wfl_operator,
16328             "Declaration of `%s' shadows a previous label declaration",
16329                                IDENTIFIER_POINTER (label));
16330           EXPR_WFL_LINECOL (wfl_operator) = 
16331             EXPR_WFL_LINECOL (IDENTIFIER_LOCAL_VALUE (label_name));
16332           parse_error_context (wfl_operator,
16333             "This is the location of the previous declaration of label `%s'",
16334                                IDENTIFIER_POINTER (label));
16335           java_error_count--;
16336         }
16337     }
16338
16339   label_decl = create_label_decl (label_name);
16340   node = build (LABELED_BLOCK_EXPR, NULL_TREE, label_decl, NULL_TREE);
16341   EXPR_WFL_LINECOL (node) = location;
16342   TREE_SIDE_EFFECTS (node) = 1;
16343   return node;
16344 }
16345
16346 /* A labeled statement LBE is attached a statement.  */
16347
16348 static tree
16349 finish_labeled_statement (lbe, statement)
16350      tree lbe;                  /* Labeled block expr */
16351      tree statement;
16352 {
16353   /* In anyways, tie the loop to its statement */
16354   LABELED_BLOCK_BODY (lbe) = statement;
16355   pop_labeled_block ();
16356   POP_LABELED_BLOCK ();
16357   return lbe;
16358 }
16359
16360 /* 14.10, 14.11, 14.12 Loop Statements */
16361
16362 /* Create an empty LOOP_EXPR and make it the last in the nested loop
16363    list. */
16364
16365 static tree
16366 build_new_loop (loop_body)
16367      tree loop_body;
16368 {
16369   tree loop =  build (LOOP_EXPR, NULL_TREE, loop_body);
16370   TREE_SIDE_EFFECTS (loop) = 1;
16371   PUSH_LOOP (loop);
16372   return loop;
16373 }
16374
16375 /* Create a loop body according to the following structure:
16376      COMPOUND_EXPR
16377        COMPOUND_EXPR            (loop main body)
16378          EXIT_EXPR              (this order is for while/for loops.
16379          LABELED_BLOCK_EXPR      the order is reversed for do loops)
16380            LABEL_DECL           (a continue occuring here branches at the 
16381            BODY                  end of this labeled block)
16382        INCREMENT                (if any)
16383
16384   REVERSED, if non zero, tells that the loop condition expr comes
16385   after the body, like in the do-while loop.
16386
16387   To obtain a loop, the loop body structure described above is
16388   encapsulated within a LOOP_EXPR surrounded by a LABELED_BLOCK_EXPR:
16389
16390    LABELED_BLOCK_EXPR
16391      LABEL_DECL                   (use this label to exit the loop)
16392      LOOP_EXPR
16393        <structure described above> */
16394
16395 static tree
16396 build_loop_body (location, condition, reversed)
16397      int location;
16398      tree condition;
16399      int reversed;
16400 {
16401   tree first, second, body;
16402
16403   condition = build (EXIT_EXPR, NULL_TREE, condition); /* Force walk */
16404   EXPR_WFL_LINECOL (condition) = location; /* For accurate error report */
16405   condition = build_debugable_stmt (location, condition);
16406   TREE_SIDE_EFFECTS (condition) = 1;
16407
16408   body = build_labeled_block (0, continue_identifier_node);
16409   first = (reversed ? body : condition);
16410   second = (reversed ? condition : body);
16411   return 
16412     build (COMPOUND_EXPR, NULL_TREE, 
16413            build (COMPOUND_EXPR, NULL_TREE, first, second), empty_stmt_node);
16414 }
16415
16416 /* Install CONDITION (if any) and loop BODY (using REVERSED to tell
16417    their order) on the current loop. Unlink the current loop from the
16418    loop list.  */
16419
16420 static tree
16421 finish_loop_body (location, condition, body, reversed)
16422      int location;
16423      tree condition, body;
16424      int reversed;
16425 {
16426   tree to_return = ctxp->current_loop;
16427   tree loop_body = LOOP_EXPR_BODY (to_return);
16428   if (condition)
16429     {
16430       tree cnode = LOOP_EXPR_BODY_CONDITION_EXPR (loop_body, reversed);
16431       /* We wrapped the EXIT_EXPR around a WFL so we can debug it.
16432          The real EXIT_EXPR is one operand further. */
16433       EXPR_WFL_LINECOL (cnode) = location;
16434       /* This one is for accurate error reports */
16435       EXPR_WFL_LINECOL (TREE_OPERAND (cnode, 0)) = location;
16436       TREE_OPERAND (TREE_OPERAND (cnode, 0), 0) = condition;
16437     }
16438   LOOP_EXPR_BODY_BODY_EXPR (loop_body, reversed) = body;
16439   POP_LOOP ();
16440   return to_return;
16441 }
16442
16443 /* Tailored version of finish_loop_body for FOR loops, when FOR
16444    loops feature the condition part */
16445
16446 static tree
16447 finish_for_loop (location, condition, update, body)
16448     int location;
16449     tree condition, update, body;
16450 {
16451   /* Put the condition and the loop body in place */
16452   tree loop = finish_loop_body (location, condition, body, 0);
16453   /* LOOP is the current loop which has been now popped of the loop
16454      stack. Install the update block */
16455   LOOP_EXPR_BODY_UPDATE_BLOCK (LOOP_EXPR_BODY (loop)) = update;
16456   return loop;
16457 }
16458
16459 /* Try to find the loop a block might be related to. This comprises
16460    the case where the LOOP_EXPR is found as the second operand of a
16461    COMPOUND_EXPR, because the loop happens to have an initialization
16462    part, then expressed as the first operand of the COMPOUND_EXPR. If
16463    the search finds something, 1 is returned. Otherwise, 0 is
16464    returned. The search is assumed to start from a
16465    LABELED_BLOCK_EXPR's block.  */
16466
16467 static tree
16468 search_loop (statement)
16469     tree statement;
16470 {
16471   if (TREE_CODE (statement) == LOOP_EXPR)
16472     return statement;
16473
16474   if (TREE_CODE (statement) == BLOCK)
16475     statement = BLOCK_SUBBLOCKS (statement);
16476   else
16477     return NULL_TREE;
16478
16479   if (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16480     while (statement && TREE_CODE (statement) == COMPOUND_EXPR)
16481       statement = TREE_OPERAND (statement, 1);
16482
16483   return (TREE_CODE (statement) == LOOP_EXPR
16484           && FOR_LOOP_P (statement) ? statement : NULL_TREE);
16485 }
16486
16487 /* Return 1 if LOOP can be found in the labeled block BLOCK. 0 is
16488    returned otherwise.  */
16489
16490 static int
16491 labeled_block_contains_loop_p (block, loop)
16492     tree block, loop;
16493 {
16494   if (!block)
16495     return 0;
16496
16497   if (LABELED_BLOCK_BODY (block) == loop)
16498     return 1;
16499
16500   if (FOR_LOOP_P (loop) && search_loop (LABELED_BLOCK_BODY (block)) == loop)
16501     return 1;
16502
16503   return 0;
16504 }
16505
16506 /* If the loop isn't surrounded by a labeled statement, create one and
16507    insert LOOP as its body.  */
16508
16509 static tree
16510 patch_loop_statement (loop)
16511      tree loop;
16512 {
16513   tree loop_label;
16514
16515   TREE_TYPE (loop) = void_type_node;
16516   if (labeled_block_contains_loop_p (ctxp->current_labeled_block, loop))
16517     return loop;
16518
16519   loop_label = build_labeled_block (0, NULL_TREE);
16520   /* LOOP is an EXPR node, so it should have a valid EXPR_WFL_LINECOL
16521      that LOOP_LABEL could enquire about, for a better accuracy. FIXME */
16522   LABELED_BLOCK_BODY (loop_label) = loop;
16523   PUSH_LABELED_BLOCK (loop_label);
16524   return loop_label;
16525 }
16526
16527 /* 14.13, 14.14: break and continue Statements */
16528
16529 /* Build a break or a continue statement. a null NAME indicates an
16530    unlabeled break/continue statement.  */
16531
16532 static tree
16533 build_bc_statement (location, is_break, name)
16534      int location, is_break;
16535      tree name;
16536 {
16537   tree break_continue, label_block_expr = NULL_TREE;
16538
16539   if (name)
16540     {
16541       if (!(label_block_expr = IDENTIFIER_LOCAL_VALUE 
16542             (merge_qualified_name (label_id, EXPR_WFL_NODE (name)))))
16543         /* Null means that we don't have a target for this named
16544            break/continue. In this case, we make the target to be the
16545            label name, so that the error can be reported accuratly in
16546            patch_bc_statement. */
16547         label_block_expr = EXPR_WFL_NODE (name);
16548     }
16549   /* Unlabeled break/continue will be handled during the
16550      break/continue patch operation */
16551   break_continue 
16552     = build (EXIT_BLOCK_EXPR, NULL_TREE, label_block_expr, NULL_TREE);
16553
16554   IS_BREAK_STMT_P (break_continue) = is_break;
16555   TREE_SIDE_EFFECTS (break_continue) = 1;
16556   EXPR_WFL_LINECOL (break_continue) = location;
16557   break_continue = build_debugable_stmt (location, break_continue);
16558   return break_continue;
16559 }
16560
16561 /* Verification of a break/continue statement. */
16562
16563 static tree
16564 patch_bc_statement (node)
16565      tree node;
16566 {
16567   tree bc_label = EXIT_BLOCK_LABELED_BLOCK (node), target_stmt;
16568   tree labeled_block = ctxp->current_labeled_block;
16569   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16570  
16571   /* Having an identifier here means that the target is unknown. */
16572   if (bc_label != NULL_TREE && TREE_CODE (bc_label) == IDENTIFIER_NODE)
16573     {
16574       parse_error_context (wfl_operator, "No label definition found for `%s'",
16575                            IDENTIFIER_POINTER (bc_label));
16576       return error_mark_node;
16577     }
16578   if (! IS_BREAK_STMT_P (node))
16579     {
16580       /* It's a continue statement. */
16581       for (;; labeled_block = TREE_CHAIN (labeled_block))
16582         {
16583           if (labeled_block == NULL_TREE)
16584             {
16585               if (bc_label == NULL_TREE)
16586                 parse_error_context (wfl_operator,
16587                                      "`continue' must be in loop");
16588               else
16589                 parse_error_context 
16590                   (wfl_operator, "continue label `%s' does not name a loop",
16591                    IDENTIFIER_POINTER (bc_label));
16592               return error_mark_node;
16593             }
16594           if ((DECL_NAME (LABELED_BLOCK_LABEL (labeled_block))
16595                == continue_identifier_node)
16596               && (bc_label == NULL_TREE
16597                   || TREE_CHAIN (labeled_block) == bc_label))
16598             {
16599               bc_label = labeled_block;
16600               break;
16601             }
16602         }
16603     }
16604   else if (!bc_label)
16605     { 
16606       for (;; labeled_block = TREE_CHAIN (labeled_block))
16607         {
16608           if (labeled_block == NULL_TREE)
16609             {
16610               parse_error_context (wfl_operator,
16611                                      "`break' must be in loop or switch");
16612               return error_mark_node;
16613             }
16614           target_stmt = LABELED_BLOCK_BODY (labeled_block);
16615           if (TREE_CODE (target_stmt) == SWITCH_EXPR
16616               || search_loop (target_stmt))
16617             {
16618               bc_label = labeled_block;
16619               break;
16620             }
16621         }
16622     }
16623
16624   EXIT_BLOCK_LABELED_BLOCK (node) = bc_label;
16625   CAN_COMPLETE_NORMALLY (bc_label) = 1;
16626
16627   /* Our break/continue don't return values. */
16628   TREE_TYPE (node) = void_type_node;
16629   /* Encapsulate the break within a compound statement so that it's
16630      expanded all the times by expand_expr (and not clobbered
16631      sometimes, like after a if statement) */
16632   node = add_stmt_to_compound (NULL_TREE, void_type_node, node);
16633   TREE_SIDE_EFFECTS (node) = 1;
16634   return node;
16635 }
16636
16637 /* Process the exit expression belonging to a loop. Its type must be
16638    boolean.  */
16639
16640 static tree
16641 patch_exit_expr (node)
16642      tree node;
16643 {
16644   tree expression = TREE_OPERAND (node, 0);
16645   TREE_TYPE (node) = error_mark_node;
16646   EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16647
16648   /* The type of expression must be boolean */
16649   if (TREE_TYPE (expression) != boolean_type_node)
16650     {
16651       parse_error_context 
16652         (wfl_operator, 
16653     "Incompatible type for loop conditional. Can't convert `%s' to `boolean'", 
16654          lang_printable_name (TREE_TYPE (expression), 0));
16655       return error_mark_node;
16656     }
16657   /* Now we know things are allright, invert the condition, fold and
16658      return */
16659   TREE_OPERAND (node, 0) = 
16660     fold (build1 (TRUTH_NOT_EXPR, boolean_type_node, expression));
16661
16662   if (! integer_zerop (TREE_OPERAND (node, 0))
16663       && ctxp->current_loop != NULL_TREE
16664       && TREE_CODE (ctxp->current_loop) == LOOP_EXPR)
16665     CAN_COMPLETE_NORMALLY (ctxp->current_loop) = 1;
16666   if (! integer_onep (TREE_OPERAND (node, 0)))
16667     CAN_COMPLETE_NORMALLY (node) = 1;
16668
16669
16670   TREE_TYPE (node) = void_type_node;
16671   return node;
16672 }
16673
16674 /* 14.9 Switch statement */
16675
16676 static tree
16677 patch_switch_statement (node)
16678      tree node;
16679 {
16680   tree se = TREE_OPERAND (node, 0), se_type;
16681
16682   /* Complete the switch expression */
16683   se = TREE_OPERAND (node, 0) = java_complete_tree (se);
16684   se_type = TREE_TYPE (se);
16685   /* The type of the switch expression must be char, byte, short or
16686      int */
16687   if (!JINTEGRAL_TYPE_P (se_type))
16688     {
16689       EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (node);
16690       parse_error_context (wfl_operator,
16691           "Incompatible type for `switch'. Can't convert `%s' to `int'",
16692                            lang_printable_name (se_type, 0));
16693       /* This is what java_complete_tree will check */
16694       TREE_OPERAND (node, 0) = error_mark_node;
16695       return error_mark_node;
16696     }
16697
16698   TREE_OPERAND (node, 1) = java_complete_tree (TREE_OPERAND (node, 1));
16699
16700   /* Ready to return */
16701   if (TREE_CODE (TREE_OPERAND (node, 1)) == ERROR_MARK)
16702     {
16703       TREE_TYPE (node) = error_mark_node;
16704       return error_mark_node;
16705     }
16706   TREE_TYPE (node) = void_type_node;
16707   TREE_SIDE_EFFECTS (node) = 1;
16708   CAN_COMPLETE_NORMALLY (node)
16709     = CAN_COMPLETE_NORMALLY (TREE_OPERAND (node, 1)) 
16710       || ! SWITCH_HAS_DEFAULT (node);
16711   return node;
16712 }
16713
16714 /* 14.18 The try/catch statements */
16715
16716 static tree
16717 build_try_statement (location, try_block, catches)
16718      int location;
16719      tree try_block, catches;
16720 {
16721   tree node = build (TRY_EXPR, NULL_TREE, try_block, catches);
16722   EXPR_WFL_LINECOL (node) = location;
16723   return node;
16724 }
16725
16726 static tree
16727 build_try_finally_statement (location, try_block, finally)
16728      int location;
16729      tree try_block, finally;
16730 {
16731   tree node = build (TRY_FINALLY_EXPR, NULL_TREE, try_block, finally);
16732   EXPR_WFL_LINECOL (node) = location;
16733   return node;
16734 }
16735
16736 static tree
16737 patch_try_statement (node)
16738      tree node;
16739 {
16740   int error_found = 0;
16741   tree try = TREE_OPERAND (node, 0);
16742   /* Exception handlers are considered in left to right order */
16743   tree catch = nreverse (TREE_OPERAND (node, 1));
16744   tree current, caught_type_list = NULL_TREE;
16745
16746   /* Check catch clauses, if any. Every time we find an error, we try
16747      to process the next catch clause. We process the catch clause before
16748      the try block so that when processing the try block we can check thrown
16749      exceptions againts the caught type list. */
16750   for (current = catch; current; current = TREE_CHAIN (current))
16751     {
16752       tree carg_decl, carg_type;
16753       tree sub_current, catch_block, catch_clause;
16754       int unreachable;
16755
16756       /* At this point, the structure of the catch clause is
16757            CATCH_EXPR           (catch node)
16758              BLOCK              (with the decl of the parameter)
16759                COMPOUND_EXPR
16760                  MODIFY_EXPR   (assignment of the catch parameter)
16761                  BLOCK          (catch clause block)
16762        */
16763       catch_clause = TREE_OPERAND (current, 0);
16764       carg_decl = BLOCK_EXPR_DECLS (catch_clause);
16765       carg_type = TREE_TYPE (TREE_TYPE (carg_decl));
16766
16767       /* Catch clauses can't have more than one parameter declared,
16768          but it's already enforced by the grammar. Make sure that the
16769          only parameter of the clause statement in of class Throwable
16770          or a subclass of Throwable, but that was done earlier. The
16771          catch clause parameter type has also been resolved. */
16772       
16773       /* Just make sure that the catch clause parameter type inherits
16774          from java.lang.Throwable */
16775       if (!inherits_from_p (carg_type, throwable_type_node))
16776         {
16777           EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16778           parse_error_context (wfl_operator,
16779                                "Can't catch class `%s'. Catch clause parameter type must be a subclass of class `java.lang.Throwable'",
16780                                lang_printable_name (carg_type, 0));
16781           error_found = 1;
16782           continue;
16783         }
16784       
16785       /* Partial check for unreachable catch statement: The catch
16786          clause is reachable iff is no earlier catch block A in
16787          the try statement such that the type of the catch
16788          clause's parameter is the same as or a subclass of the
16789          type of A's parameter */
16790       unreachable = 0;
16791       for (sub_current = catch;
16792            sub_current != current; sub_current = TREE_CHAIN (sub_current))
16793         {
16794           tree sub_catch_clause, decl;
16795           sub_catch_clause = TREE_OPERAND (sub_current, 0);
16796           decl = BLOCK_EXPR_DECLS (sub_catch_clause);
16797
16798           if (inherits_from_p (carg_type, TREE_TYPE (TREE_TYPE (decl))))
16799             {
16800               EXPR_WFL_LINECOL (wfl_operator) = EXPR_WFL_LINECOL (current);
16801               parse_error_context 
16802                 (wfl_operator,
16803                  "`catch' not reached because of the catch clause at line %d",
16804                  EXPR_WFL_LINENO (sub_current));
16805               unreachable = error_found = 1;
16806               break;
16807             }
16808         }
16809       /* Complete the catch clause block */
16810       catch_block = java_complete_tree (TREE_OPERAND (current, 0));
16811       if (catch_block == error_mark_node)
16812         {
16813           error_found = 1;
16814           continue;
16815         }
16816       if (CAN_COMPLETE_NORMALLY (catch_block))
16817         CAN_COMPLETE_NORMALLY (node) = 1;
16818       TREE_OPERAND (current, 0) = catch_block;
16819
16820       if (unreachable)
16821         continue;
16822
16823       /* Things to do here: the exception must be thrown */
16824
16825       /* Link this type to the caught type list */
16826       caught_type_list = tree_cons (NULL_TREE, carg_type, caught_type_list);
16827     }
16828
16829   PUSH_EXCEPTIONS (caught_type_list);
16830   if ((try = java_complete_tree (try)) == error_mark_node)
16831     error_found = 1;
16832   if (CAN_COMPLETE_NORMALLY (try))
16833     CAN_COMPLETE_NORMALLY (node) = 1;
16834   POP_EXCEPTIONS ();
16835
16836   /* Verification ends here */
16837   if (error_found) 
16838     return error_mark_node;
16839
16840   TREE_OPERAND (node, 0) = try;
16841   TREE_OPERAND (node, 1) = catch;
16842   TREE_TYPE (node) = void_type_node;
16843   return node;
16844 }
16845
16846 /* 14.17 The synchronized Statement */
16847
16848 static tree
16849 patch_synchronized_statement (node, wfl_op1)
16850     tree node, wfl_op1;
16851 {
16852   tree expr = java_complete_tree (TREE_OPERAND (node, 0));
16853   tree block = TREE_OPERAND (node, 1);
16854
16855   tree enter, exit, expr_decl, assignment;
16856
16857   if (expr == error_mark_node)
16858     {
16859       block = java_complete_tree (block);
16860       return expr;
16861     }
16862
16863   /* The TYPE of expr must be a reference type */
16864   if (!JREFERENCE_TYPE_P (TREE_TYPE (expr)))
16865     {
16866       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16867       parse_error_context (wfl_operator, "Incompatible type for `synchronized'. Can't convert `%s' to `java.lang.Object'",
16868                            lang_printable_name (TREE_TYPE (expr), 0));
16869       return error_mark_node;
16870     }
16871
16872   if (flag_emit_xref)
16873     {
16874       TREE_OPERAND (node, 0) = expr;
16875       TREE_OPERAND (node, 1) = java_complete_tree (block);
16876       CAN_COMPLETE_NORMALLY (node) = 1;
16877       return node;
16878     }
16879
16880   /* Generate a try-finally for the synchronized statement, except
16881      that the handler that catches all throw exception calls
16882      _Jv_MonitorExit and then rethrow the exception.
16883      The synchronized statement is then implemented as:
16884      TRY 
16885        {
16886          _Jv_MonitorEnter (expression)
16887          synchronized_block
16888          _Jv_MonitorExit (expression)
16889        }
16890      CATCH_ALL
16891        {
16892          e = _Jv_exception_info ();
16893          _Jv_MonitorExit (expression)
16894          Throw (e);
16895        } */
16896
16897   expr_decl = build_decl (VAR_DECL, generate_name (), TREE_TYPE (expr));
16898   BUILD_MONITOR_ENTER (enter, expr_decl);
16899   BUILD_MONITOR_EXIT (exit, expr_decl);
16900   CAN_COMPLETE_NORMALLY (enter) = 1;
16901   CAN_COMPLETE_NORMALLY (exit) = 1;
16902   assignment = build (MODIFY_EXPR, NULL_TREE, expr_decl, expr);
16903   TREE_SIDE_EFFECTS (assignment) = 1;
16904   node = build1 (CLEANUP_POINT_EXPR, NULL_TREE,
16905                  build (COMPOUND_EXPR, NULL_TREE,
16906                         build (WITH_CLEANUP_EXPR, NULL_TREE,
16907                                build (COMPOUND_EXPR, NULL_TREE,
16908                                       assignment, enter),
16909                                NULL_TREE, exit),
16910                         block));
16911   node = build_expr_block (node, expr_decl);
16912
16913   return java_complete_tree (node);
16914 }
16915
16916 /* 14.16 The throw Statement */
16917
16918 static tree
16919 patch_throw_statement (node, wfl_op1)
16920     tree node, wfl_op1;
16921 {
16922   tree expr = TREE_OPERAND (node, 0);
16923   tree type = TREE_TYPE (expr);
16924   int unchecked_ok = 0, tryblock_throws_ok = 0;
16925
16926   /* Thrown expression must be assignable to java.lang.Throwable */
16927   if (!try_reference_assignconv (throwable_type_node, expr))
16928     {
16929       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16930       parse_error_context (wfl_operator,
16931     "Can't throw `%s'; it must be a subclass of class `java.lang.Throwable'",
16932                            lang_printable_name (type, 0));
16933       /* If the thrown expression was a reference, we further the
16934          compile-time check. */
16935       if (!JREFERENCE_TYPE_P (type))
16936         return error_mark_node;
16937     }
16938
16939   /* At least one of the following must be true */
16940
16941   /* The type of the throw expression is a not checked exception,
16942      i.e. is a unchecked expression. */
16943   unchecked_ok = IS_UNCHECKED_EXCEPTION_P (TREE_TYPE (type));
16944
16945   SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
16946   /* An instance can't throw a checked excetion unless that exception
16947      is explicitely declared in the `throws' clause of each
16948      constructor. This doesn't apply to anonymous classes, since they
16949      don't have declared constructors. */
16950   if (!unchecked_ok 
16951       && in_instance_initializer && !ANONYMOUS_CLASS_P (current_class))
16952     {
16953       tree current;
16954       for (current = TYPE_METHODS (current_class); current; 
16955            current = TREE_CHAIN (current))
16956         if (DECL_CONSTRUCTOR_P (current) 
16957             && !check_thrown_exceptions_do (TREE_TYPE (expr)))
16958           {
16959             parse_error_context (wfl_operator, "Checked exception `%s' can't be thrown in instance initializer (not all declared constructor are declaring it in their `throws' clause)", 
16960                                  lang_printable_name (TREE_TYPE (expr), 0));
16961             return error_mark_node;
16962           }
16963     }
16964
16965   /* Throw is contained in a try statement and at least one catch
16966      clause can receive the thrown expression or the current method is
16967      declared to throw such an exception. Or, the throw statement is
16968      contained in a method or constructor declaration and the type of
16969      the Expression is assignable to at least one type listed in the
16970      throws clause the declaration. */
16971   if (!unchecked_ok)
16972     tryblock_throws_ok = check_thrown_exceptions_do (TREE_TYPE (expr));
16973   if (!(unchecked_ok || tryblock_throws_ok))
16974     {
16975       /* If there is a surrounding try block that has no matching
16976          clatch clause, report it first. A surrounding try block exits
16977          only if there is something after the list of checked
16978          exception thrown by the current function (if any). */
16979       if (IN_TRY_BLOCK_P ())
16980         parse_error_context (wfl_operator, "Checked exception `%s' can't be caught by any of the catch clause(s) of the surrounding `try' block",
16981                              lang_printable_name (type, 0));
16982       /* If we have no surrounding try statement and the method doesn't have
16983          any throws, report it now. FIXME */
16984
16985       /* We report that the exception can't be throw from a try block
16986          in all circumstances but when the `throw' is inside a static
16987          block. */
16988       else if (!EXCEPTIONS_P (currently_caught_type_list) 
16989                && !tryblock_throws_ok)
16990         {
16991           if (DECL_CLINIT_P (current_function_decl))
16992             parse_error_context (wfl_operator,
16993                    "Checked exception `%s' can't be thrown in initializer",
16994                                  lang_printable_name (type, 0));
16995           else
16996             parse_error_context (wfl_operator,
16997                    "Checked exception `%s' isn't thrown from a `try' block", 
16998                                  lang_printable_name (type, 0));
16999         }
17000       /* Otherwise, the current method doesn't have the appropriate
17001          throws declaration */
17002       else
17003         parse_error_context (wfl_operator, "Checked exception `%s' doesn't match any of current method's `throws' declaration(s)", 
17004                              lang_printable_name (type, 0));
17005       return error_mark_node;
17006     }
17007
17008   if (! flag_emit_class_files && ! flag_emit_xref)
17009     BUILD_THROW (node, expr);
17010
17011   /* If doing xrefs, keep the location where the `throw' was seen. */
17012   if (flag_emit_xref)
17013     EXPR_WFL_LINECOL (node) = EXPR_WFL_LINECOL (wfl_op1);
17014   return node;
17015 }
17016
17017 /* Check that exception said to be thrown by method DECL can be
17018    effectively caught from where DECL is invoked.  */
17019
17020 static void
17021 check_thrown_exceptions (location, decl)
17022      int location;
17023      tree decl;
17024 {
17025   tree throws;
17026   /* For all the unchecked exceptions thrown by DECL */
17027   for (throws = DECL_FUNCTION_THROWS (decl); throws; 
17028        throws = TREE_CHAIN (throws)) 
17029     if (!check_thrown_exceptions_do (TREE_VALUE (throws)))
17030       {
17031 #if 1
17032         /* Temporary hack to suppresses errors about cloning arrays. FIXME */
17033         if (DECL_NAME (decl) == get_identifier ("clone"))
17034           continue;
17035 #endif
17036         EXPR_WFL_LINECOL (wfl_operator) = location;
17037         if (DECL_FINIT_P (current_function_decl))
17038           parse_error_context
17039             (wfl_operator, "Exception `%s' can't be thrown in initializer",
17040              lang_printable_name (TREE_VALUE (throws), 0));
17041         else 
17042           {
17043             parse_error_context 
17044               (wfl_operator, "Exception `%s' must be caught, or it must be declared in the `throws' clause of `%s'", 
17045                lang_printable_name (TREE_VALUE (throws), 0),
17046                (DECL_INIT_P (current_function_decl) ?
17047                 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (current_class))) :
17048                 IDENTIFIER_POINTER (DECL_NAME (current_function_decl))));
17049           }
17050       }
17051 }
17052
17053 /* Return 1 if checked EXCEPTION is caught at the current nesting level of
17054    try-catch blocks, OR is listed in the `throws' clause of the
17055    current method.  */
17056
17057 static int
17058 check_thrown_exceptions_do (exception)
17059      tree exception;
17060 {
17061   tree list = currently_caught_type_list;
17062   resolve_and_layout (exception, NULL_TREE);
17063   /* First, all the nested try-catch-finally at that stage. The
17064      last element contains `throws' clause exceptions, if any. */
17065   if (IS_UNCHECKED_EXCEPTION_P (exception))
17066     return 1;
17067   while (list)
17068     {
17069       tree caught;
17070       for (caught = TREE_VALUE (list); caught; caught = TREE_CHAIN (caught))
17071         if (valid_ref_assignconv_cast_p (exception, TREE_VALUE (caught), 0))
17072           return 1;
17073       list = TREE_CHAIN (list);
17074     }
17075   return 0;
17076 }
17077
17078 static void
17079 purge_unchecked_exceptions (mdecl)
17080      tree mdecl;
17081 {
17082   tree throws = DECL_FUNCTION_THROWS (mdecl);
17083   tree new = NULL_TREE;
17084
17085   while (throws)
17086     {
17087       tree next = TREE_CHAIN (throws);
17088       if (!IS_UNCHECKED_EXCEPTION_P (TREE_VALUE (throws)))
17089         {
17090           TREE_CHAIN (throws) = new;
17091           new = throws;
17092         }
17093       throws = next;
17094     }
17095   /* List is inverted here, but it doesn't matter */
17096   DECL_FUNCTION_THROWS (mdecl) = new;
17097 }
17098
17099 /* 15.24 Conditional Operator ?: */
17100
17101 static tree
17102 patch_conditional_expr (node, wfl_cond, wfl_op1)
17103      tree node, wfl_cond, wfl_op1;
17104 {
17105   tree cond = TREE_OPERAND (node, 0);
17106   tree op1 = TREE_OPERAND (node, 1);
17107   tree op2 = TREE_OPERAND (node, 2);
17108   tree resulting_type = NULL_TREE;
17109   tree t1, t2, patched;
17110   int error_found = 0;
17111
17112   /* Operands of ?: might be StringBuffers crafted as a result of a
17113      string concatenation. Obtain a descent operand here.  */
17114   if ((patched = patch_string (op1)))
17115     TREE_OPERAND (node, 1) = op1 = patched;
17116   if ((patched = patch_string (op2)))
17117     TREE_OPERAND (node, 2) = op2 = patched;
17118
17119   t1 = TREE_TYPE (op1);
17120   t2 = TREE_TYPE (op2);
17121
17122   /* The first expression must be a boolean */
17123   if (TREE_TYPE (cond) != boolean_type_node)
17124     {
17125       SET_WFL_OPERATOR (wfl_operator, node, wfl_cond);
17126       parse_error_context (wfl_operator,
17127                "Incompatible type for `?:'. Can't convert `%s' to `boolean'",
17128                            lang_printable_name (TREE_TYPE (cond), 0));
17129       error_found = 1;
17130     }
17131
17132   /* Second and third can be numeric, boolean (i.e. primitive),
17133      references or null. Anything else results in an error */
17134   if (!((JNUMERIC_TYPE_P (t1) && JNUMERIC_TYPE_P (t2))
17135         || ((JREFERENCE_TYPE_P (t1) || op1 == null_pointer_node) 
17136             && (JREFERENCE_TYPE_P (t2) || op2 == null_pointer_node))
17137         || (t1 == boolean_type_node && t2 == boolean_type_node)))
17138     error_found = 1;
17139
17140   /* Determine the type of the conditional expression. Same types are
17141      easy to deal with */
17142   else if (t1 == t2)
17143     resulting_type = t1;
17144
17145   /* There are different rules for numeric types */
17146   else if (JNUMERIC_TYPE_P (t1))
17147     {
17148       /* if byte/short found, the resulting type is short */
17149       if ((t1 == byte_type_node && t2 == short_type_node)
17150           || (t1 == short_type_node && t2 == byte_type_node))
17151         resulting_type = short_type_node;
17152
17153       /* If t1 is a constant int and t2 is of type byte, short or char
17154          and t1's value fits in t2, then the resulting type is t2 */
17155       else if ((t1 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 1)))
17156           && JBSC_TYPE_P (t2) && int_fits_type_p (TREE_OPERAND (node, 1), t2))
17157         resulting_type = t2;
17158
17159       /* If t2 is a constant int and t1 is of type byte, short or char
17160          and t2's value fits in t1, then the resulting type is t1 */
17161       else if ((t2 == int_type_node && TREE_CONSTANT (TREE_OPERAND (node, 2)))
17162           && JBSC_TYPE_P (t1) && int_fits_type_p (TREE_OPERAND (node, 2), t1))
17163         resulting_type = t1;
17164
17165       /* Otherwise, binary numeric promotion is applied and the
17166          resulting type is the promoted type of operand 1 and 2 */
17167       else 
17168         resulting_type = binary_numeric_promotion (t1, t2, 
17169                                                    &TREE_OPERAND (node, 1), 
17170                                                    &TREE_OPERAND (node, 2));
17171     }
17172
17173   /* Cases of a reference and a null type */
17174   else if (JREFERENCE_TYPE_P (t1) && op2 == null_pointer_node)
17175     resulting_type = t1;
17176
17177   else if (JREFERENCE_TYPE_P (t2) && op1 == null_pointer_node)
17178     resulting_type = t2;
17179
17180   /* Last case: different reference types. If a type can be converted
17181      into the other one by assignment conversion, the latter
17182      determines the type of the expression */
17183   else if ((resulting_type = try_reference_assignconv (t1, op2)))
17184     resulting_type = promote_type (t1);
17185
17186   else if ((resulting_type = try_reference_assignconv (t2, op1)))
17187     resulting_type = promote_type (t2);
17188
17189   /* If we don't have any resulting type, we're in trouble */
17190   if (!resulting_type)
17191     {
17192       char *t = xstrdup (lang_printable_name (t1, 0));
17193       SET_WFL_OPERATOR (wfl_operator, node, wfl_op1);
17194       parse_error_context (wfl_operator,
17195                  "Incompatible type for `?:'. Can't convert `%s' to `%s'",
17196                            t, lang_printable_name (t2, 0));
17197       free (t);
17198       error_found = 1;
17199     }
17200
17201   if (error_found)
17202     {
17203       TREE_TYPE (node) = error_mark_node;
17204       return error_mark_node;
17205     }
17206
17207   TREE_TYPE (node) = resulting_type;
17208   TREE_SET_CODE (node, COND_EXPR);
17209   CAN_COMPLETE_NORMALLY (node) = 1;
17210   return node;
17211 }
17212
17213 /* Try to constant fold NODE.
17214    If NODE is not a constant expression, return NULL_EXPR.
17215    CONTEXT is a static final VAR_DECL whose initializer we are folding. */
17216
17217 static tree
17218 fold_constant_for_init (node, context)
17219      tree node;
17220      tree context;
17221 {
17222   tree op0, op1, val;
17223   enum tree_code code = TREE_CODE (node);
17224
17225   if (code == STRING_CST)
17226     return node;
17227
17228   if (code == INTEGER_CST || code == REAL_CST)
17229     return convert (TREE_TYPE (context), node);
17230   if (TREE_TYPE (node) != NULL_TREE && code != VAR_DECL && code != FIELD_DECL)
17231     return NULL_TREE;
17232
17233   switch (code)
17234     {
17235     case PLUS_EXPR:
17236     case MINUS_EXPR:
17237     case MULT_EXPR:
17238     case TRUNC_MOD_EXPR:
17239     case RDIV_EXPR:
17240     case LSHIFT_EXPR:
17241     case RSHIFT_EXPR:
17242     case URSHIFT_EXPR:
17243     case BIT_AND_EXPR:
17244     case BIT_XOR_EXPR:
17245     case BIT_IOR_EXPR:
17246     case TRUTH_ANDIF_EXPR:
17247     case TRUTH_ORIF_EXPR:
17248     case EQ_EXPR: 
17249     case NE_EXPR:
17250     case GT_EXPR:
17251     case GE_EXPR:
17252     case LT_EXPR:
17253     case LE_EXPR:
17254       op0 = TREE_OPERAND (node, 0);
17255       op1 = TREE_OPERAND (node, 1);
17256       val = fold_constant_for_init (op0, context);
17257       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17258         return NULL_TREE;
17259       TREE_OPERAND (node, 0) = val;
17260       val = fold_constant_for_init (op1, context);
17261       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17262         return NULL_TREE;
17263       TREE_OPERAND (node, 1) = val;
17264       return patch_binop (node, op0, op1);
17265
17266     case UNARY_PLUS_EXPR:
17267     case NEGATE_EXPR:
17268     case TRUTH_NOT_EXPR:
17269     case BIT_NOT_EXPR:
17270     case CONVERT_EXPR:
17271       op0 = TREE_OPERAND (node, 0);
17272       val = fold_constant_for_init (op0, context);
17273       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17274         return NULL_TREE;
17275       TREE_OPERAND (node, 0) = val;
17276       return patch_unaryop (node, op0);
17277       break;
17278
17279     case COND_EXPR:
17280       val = fold_constant_for_init (TREE_OPERAND (node, 0), context);
17281       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17282         return NULL_TREE;
17283       TREE_OPERAND (node, 0) = val;
17284       val = fold_constant_for_init (TREE_OPERAND (node, 1), context);
17285       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17286         return NULL_TREE;
17287       TREE_OPERAND (node, 1) = val;
17288       val = fold_constant_for_init (TREE_OPERAND (node, 2), context);
17289       if (val == NULL_TREE || ! TREE_CONSTANT (val))
17290         return NULL_TREE;
17291       TREE_OPERAND (node, 2) = val;
17292       return integer_zerop (TREE_OPERAND (node, 0)) ? TREE_OPERAND (node, 1)
17293         : TREE_OPERAND (node, 2);
17294
17295     case VAR_DECL:
17296     case FIELD_DECL:
17297       if (! FIELD_FINAL (node)
17298           || DECL_INITIAL (node) == NULL_TREE)
17299         return NULL_TREE;
17300       val = DECL_INITIAL (node);
17301       /* Guard against infinite recursion. */
17302       DECL_INITIAL (node) = NULL_TREE;
17303       val = fold_constant_for_init (val, node);
17304       DECL_INITIAL (node) = val;
17305       return val;
17306
17307     case EXPR_WITH_FILE_LOCATION:
17308       /* Compare java_complete_tree and resolve_expression_name. */
17309       if (!EXPR_WFL_NODE (node) /* Or a PRIMARY flag ? */
17310           || TREE_CODE (EXPR_WFL_NODE (node)) == IDENTIFIER_NODE)
17311         {
17312           tree name = EXPR_WFL_NODE (node);
17313           tree decl;
17314           if (PRIMARY_P (node))
17315             return NULL_TREE;
17316           else if (! QUALIFIED_P (name))
17317             {
17318               decl = lookup_field_wrapper (DECL_CONTEXT (context), name);
17319               if (decl == NULL_TREE 
17320                   || (! FIELD_STATIC (decl) && ! FIELD_FINAL (decl)))
17321                 return NULL_TREE;
17322               return fold_constant_for_init (decl, decl);
17323             }
17324           else
17325             {
17326               /* Wait until the USE_COMPONENT_REF re-write.  FIXME. */
17327               qualify_ambiguous_name (node);
17328               if (resolve_field_access (node, &decl, NULL)
17329                   && decl != NULL_TREE)
17330                 return fold_constant_for_init (decl, decl);
17331               return NULL_TREE;
17332             }
17333         }
17334       else
17335         {
17336           op0 = TREE_OPERAND (node, 0);
17337           val = fold_constant_for_init (op0, context);
17338           if (val == NULL_TREE || ! TREE_CONSTANT (val))
17339             return NULL_TREE;
17340           TREE_OPERAND (node, 0) = val;
17341           return val;
17342         }
17343
17344 #ifdef USE_COMPONENT_REF
17345     case IDENTIFIER:
17346     case COMPONENT_REF:
17347       ?;
17348 #endif
17349
17350     default:
17351       return NULL_TREE;
17352     }
17353 }
17354
17355 #ifdef USE_COMPONENT_REF
17356 /* Context is 'T' for TypeName, 'P' for PackageName,
17357    'M' for MethodName, 'E' for ExpressionName, and 'A' for AmbiguousName. */
17358
17359 tree
17360 resolve_simple_name (name, context)
17361      tree name;
17362      int context;
17363 {
17364 }
17365
17366 tree
17367 resolve_qualified_name (name, context)
17368      tree name;
17369      int context;
17370 {
17371 }
17372 #endif